CODEV Ch3
CODEV Ch3
Search
Chapter 2
Just Do It: Design a Digital
Camera Lens
In this chapter, you will design a fixed-focus digital camera lens for VGA resolution
(640 x 480). Guided by the required specifications, you will use the New Lens Wizard
to identify a suitable starting point. You will then modify, analyze, and optimize the
optical system to meet the requirements. This will allow you to learn most of the basic
techniques needed to use CODE V.
Contents
Learning by Doing......................................................................................................18
The New Lens Wizard ................................................................................................21
Working with Surfaces ...............................................................................................25
Analyze the Starting Point ..........................................................................................33
Conclusions ................................................................................................................42
Learning by Doing
Search
A Simple Digital Camera Lens
Digital cameras are very common these days, and the latest mega-pixel models
have high-resolution CCD arrays and sophisticated optics and electronics. But don’t
worry, that won’t be your very first task with CODE V. Instead, you will design a
fairly simple objective lens for a fixed-focus digital camera. This will still require
some optical design, but it’s a relatively simple problem, a two- or three-element
centered lens with glass and/or plastic refracting lens elements.
Here is what you will learn in this chapter:
• Interpret general design specifications for a simple lens
• Use this information to identify a starting point
• Modify the starting point to match the requirements
• Perform a basic analysis, compare these results with the specs, and determine
guidelines for optimization
In the next chapter, you will use the results of this chapter as a starting point to
• Optimize the lens
• Identify problems with the design for potential refinement
These steps will allow you to work with many of CODE V’s features through
various phases of optical design. We will explain some of these features as they are
introduced here, with additional explanations in subsequent chapters.
Design Specifications
Sometimes you will receive a lens prescription from someone and you will need to
enter it in CODE V, analyze it, and perhaps optimize it. This is fairly
straightforward. In other cases, a design problem starts out with a spec, or set of
specifications, on how the lens must perform, and from these guidelines you must
determine a starting point, set it up, analyze, and optimize it.
For this digital camera problem, the spec came from a CODE V customer who
makes consumer products. The question was, “If you wanted to define a low-cost,
fixed-focus digital camera for VGA, how would you specify it?”
• Objective Lens
In this case, the image height is 3 mm (half of the detector diagonal), and the EFL is
6 mm, so you can solve this for the semi-FOV of 26.5° (this is useful since the
Search patent database lenses are listed by f/number and semi-FOV). Given that you want a
small number of elements, this is all the information you need to find some starting
points.
CODE V has analysis features to allow evaluation of the other specs (distortion,
MTF, relative illumination, transmission). We will introduce most of these features
later, as they are needed, but consider the term sharpness for a moment. Sharpness
is often defined by MTF, which quantifies the lens' ability to image information as a
function of spatial frequency. Maximum sharpness is given by an MTF of 1.0.
Minimum sharpness (i.e., no information) occurs for an MTF of 0.0. High spatial
frequencies represent small details and are measured in lines per millimeter. We
will discuss MTF and other evaluation methods in more detail later.
A digital camera uses a CCD array consisting of small but finite-sized cells called
pixels (there are actually three color pixels for each cell, but for design purposes,
we will think of each cell as consisting of a single pixel). The spec indicates that the
pixel size is 7.4 microns square. The maximum spatial frequency that this array will
resolve can be calculated as one over twice the pixel size, 1/(2*0.0074) = 67.6 lines/
mm. With this CCD array, any image information with a higher spatial frequency
(i.e., finer detail) than this will not be seen. In spite of this, the optics must actually
have non-zero MTF somewhat beyond the CCD cutoff frequency, so the combined
optics/detector MTF will produce a usable contrast up to the CCD cutoff frequency.
This is the meaning of the small table on page 19 under the Sharpness specification.
Patent Database
In addition to some 30 sample lenses that demonstrate program features, CODE V
Search
includes a database of some 2,456 expired patents (mainly centered optical systems
for various applications). You can use the New Lens Wizard or the Patent Lens
Search feature (Tools > Patent Lens Search menu) to access and search this
database through the use of filters that specify various properties. In the following
procedure, you will continue using the New Lens Wizard to select a patent lens.
1. In the New Lens Wizard, click the Filter button.
The Filter dialog box displays, which allows you to narrow down the search for
a starting point. In the case of the digital camera lens, you need both a relatively
fast (small) f/number and a fairly wide field of view or field angle (26.5° semi-
field angle, which corresponds to the 3 mm half-diagonal of the CCD array).
You also want this lens to be fairly cheap, so it should have a small number of
elements (1-3). You can fill in the filter dialog to start the search. It's a good idea
to expand the range slightly since you can often slightly modify or optimize a
system to the needed specifications. If you make the search targets too narrow,
you may miss some promising design forms.
2. Click the check boxes and fill in the Min/Max entries for
– F/# (f/number, try 1 to 4), goal is 3.5
– Semi-Field of View (try 20° to 33°), goal is 26.5°
– Number of elements (try 1 to 3), goal is smallest possible for low cost
3. Click OK.
The New Lens Wizard returns you to the patent list where you will now find
around 13 lenses that meet these requirements.
You could try several different starting points, but note that it will probably be
hard to expand the field of view, so wider field starting points are better. The
Search lens named or02248 looks promising – it has a 27.5° FOV, and a faster
(smaller) f/number than we need (2.4 -- this is good, since stopping down a lens
to a larger f/number usually improves image quality).
4. Click the lens named or02248 in the spreadsheet of patents.
F/number is a ratio, so it won’t need to be scaled when the lens is scaled (and the
lens will most likely need to be scaled).
Search
2. Click the Next button to go to the Wavelengths page, and change the weight for
the green wavelength (589.0) to 2.
This will give the central wavelength more emphasis later in optimization.
3. Click the Next button to go to the Reference wavelength page, but do not
change the default value.
This is the wavelength used for paraxial and reference-ray tracing; the default is
OK.
4. Click the Next button to go to the Fields page. Right-click on field 2 and choose
Insert from the shortcut menu to add an additional field angle, then type the
values 0, 11, 19, and 26.5 for the four field Y angles.
The LDM window behaves like spreadsheets in other programs in that you can re-
size rows or columns, select cells or groups of cells, and enter data in cells. Note
that some cells are gray and do not accept data entry—these cells contain data
calculated by the program and this can't be directly changed. You can right-click on
any cell, including gray cells, to see a menu for that cell. Right clicking is a very
common operation which gives quick access to all available information for a cell.
Tip: To see the full value of any displayed number, position the mouse pointer over
the value and leave the pointer there (don’t click). To change the number of
displayed digits for all numbers in the interface, choose the Tools > Customize
menu and go to the Format Cell tab in the Customize dialog box (General format
with 5 digits is used in this guide). You cannot format cells individually.
Note also that in the discussion below, we are considering the default display of the
LDM window for rotationally symmetric optics. It is possible to hide columns
(right click any header cell) or to make certain common entries blank (e.g., Sphere
and Refract; choose the Tools > Preferences > menu and go to the UI tab in the
Preferences dialog box to change this). If there are non-rotationally symmetric
Search surface properties, the LDM window will add additional columns for certain X and
Y data.
Surface Details
Every lens model will start with an object surface and end with an image surface (it
is really just the last surface, since not every lens model will form an image there,
though most will). You will also note that there is always a surface labeled Stop,
which is the aperture stop surface. This is defined as the limiting surface for on-axis
rays. The chief ray (or principal ray) from every field point will be iterated to pass
through the center (x=0, y=0) of the stop surface, unless you override this behavior
with chief ray aiming (this is only necessary in a few unusual situations).
Each row in the LDM spreadsheet has a surface number and a surface name
(optional but very useful in complex systems). To select an entire surface (each is
displayed in a row), click the surface number. The surface type is next, which is a
dropdown list (double-click it to display a list of surface types), with the default
type of Sphere. The Y Radius is the radius of curvature, which is the reciprocal of
curvature. Spheres and other rotationally symmetric surface shapes have only a
single curvature, and Y is used for this (types such as Y Toroid have X and Y
curvatures). You can also choose to display the Y Curvature (reciprocal of radius,
e.g., units of 1/mm). See the tip below.
Tip: You can work with radius of curvature or its reciprocal, curvature, by
checking or un-checking the Edit > Radius Mode menu item.
Thickness is defined as the distance to the next surface, measured along the local Z
axis of the current surface (which is the optical axis for centered systems such as
this). Note that the thickness (air space) of surface 6 is gray and has a small S next
to it. This thickness is set by a paraxial image (PIM) solve, which calculates the
thickness at which the paraxial marginal ray has a height of zero at the following
surface. This sets the paraxial image distance, where the lens is approximately in
focus. This may not be the best focus, however, so the thickness of the image
surface is used as a focal shift from the PIM value (the total image distance is the
sum of these two values). Optimization usually determines the best focus shift (the
combination of PIM solve and variable defocus is recommended for most optical
systems).
Glass cells contain the name of the material in the space following the surface, and
if it is blank, the material is AIR. The glass determines the index of refraction,
which is a fundamental requirement for ray tracing. There are several possible
forms for glass names, depending on whether they are from glass makers, defined
locally for the lens (“private catalog”), or defined as “fictitious” glass whose index
Search can be varied to allow optimization, as shown in the example (there is a supplied
macro, glassfit.seq, that can help you convert fictitious glasses into real glasses that
you can buy). Refract mode determines the basic behavior of a surface, whether
rays are refracted or reflected at the surface (double-click the cell to see the
choices).
The final column is labeled Y Semi-Aperture and represents the size of the
optically useful portion of the lens surface. By default, this is a centered, circular
aperture calculated by the program to pass the reference rays from all field and
zoom positions. You can change this to a user-defined aperture for any surface in
several ways, the simplest of which is to right-click and choose one of the Change
to… options that pops up. You can just accept default apertures for now, though
later you will learn about the relationships between apertures, pupil size, and
vignetting factors.
Drawing Pictures
Now you can understand the LDM spreadsheet, but as they say, a picture is worth a
thousand numbers. So it’s a good idea to draw a picture of the lens as soon as you
can. Many problems are easy to spot on a lens picture. There are a number of ways
to draw lenses, including the very flexible VIEW option (Display > View Lens
menu), but for now, there’s a quicker way.
Search
It’s the middle one that shows a lens and a pencil along with the letter Q (for quick)
and the letter L (for labeled—float the mouse over it to see the tool-tip help to see
the message “Quick 2D – Labeled”). Keep the resulting window open as you work
(resize and move the window as desired). When you change something, click the
Execute button in the upper left corner of the window to redraw the lens picture.
Before analyzing this lens, you will more than likely need to scale it to the required
effective focal length (EFL).
Search Tip: You can place the EFL and various other lens properties on the status bar
at the bottom of the main CODE V workspace. This allows continuous
monitoring of these items. Choose the Tools > Customize menu and click on
the Status Bar tab in the Customize dialog box to access this feature.
2. Select surfaces 1 to Image in the LDM spreadsheet window (click in the surface
# column and drag to Image to select the range).
3. Choose the Edit > Scale menu to display a dialog box (note that the surface
range is set to 1 to Image).
4. Click the button labeled Scale Effective Focal Length, then enter the value 6.0
in the field labeled Scale Value.
Search
• Choose the File > Save Lens As menu and enter a file name such as
DigCamStart.len, then click Save.
You are first looking for large deviations, including separations between the curves
for different wavelengths (chromatic aberration). You may also look for distinctive
Search patterns that represent coma, astigmatism, and other basic aberrations. Experience
can tell you where such aberrations come from, suggesting where you might make
corrections, perhaps in the form of additional elements or aspheres.
The Quick Ray Aberration plot is a one-click version, which you run by clicking
the Quick Ray Aberration plot toolbar button, shown below (for the general case,
choose the Analysis > Diagnostics > Ray Aberration Curves menu, option name:
RIM, for “rim ray”). The Quick version is actually done by a macro and performs
automatic scaling (it also supplies a text table of ray aberrations, generated by the
ANA option). Note that the following graph is shown after zooming and positioning
only the highest field angle in the Quick Ray Aberration Plot window.
The starting point doesn’t show signs of any gross aberrations, though you can only
tell this by looking at the scale and knowing what is big. The automatic scale value
here is 0.023 mm, 23 microns. For comparison, the Airy disk diameter (diffraction
spot size for a perfect lens) is 2.44*(wavelength)*(f/number), or about 0.004 mm
for f/3.5. This lens is not diffraction limited (nor would you expect it to be), but its
aberrations are within a factor of 6 of the Airy size.
Tip: Always use the graphical zoom tool to zoom in on the scale numbers for plots.
Automatic scaling may make a lens look good, but the scale size may be large.
Tip: The supplied macro spotdet.seq will plot spot diagrams with superimposed
circles or rectangles representing a specified detector size or Airy disk. Choose the
Tools > Macro Manager menu and locate the macro under Sample Macros/
Geometrical Analysis. Note that you will have to fill in the required data to run this
macro.
Distortion
The paraxial image height is related to field angle by the relationship h = f tan θ. If
Search
the real image height differs from this paraxial prediction, you have distortion.
Distortion is therefore a field-related aberration, and it is often displayed as a plot
along with another field-based aberration, astigmatism. These field curves are
available by choosing the Analysis > Diagnostics > Field Curves menu, or by
clicking the Quick Field Plot button on the toolbar.
The resulting distortion curve has field angle as the vertical coordinate and percent
distortion as the horizontal coordinate. It shows that the starting point is well within
the specified 4% distortion for the lens. In fact, it's less than plus or minus 1%
across the entire field of view. Astigmatism (left side in plot window below) is well
corrected at the full field, but there is substantial zonal residual at the intermediate
fields.
A distortion grid is another way to view distortion that is perhaps a little more
intuitive. In this case, you see a rectangular grid that represents the ideal (paraxial)
image, with the distorted grid superimposed on it. Since the field of view is defined
by field angle for this lens, you need to convert the CCD horizontal (X) and vertical
(Y) dimensions into field angle using h = f tan θ again (we used the 3 mm corner
distance to define the maximum field, but in this case we want to view the actual
format of the field). From the spec, recall that the full detector dimensions are 3.55
x 4.74 mm. Divide these by twice the focal length and take the arctan to get the
maximum Y and X field angles (16.48° and 21.55°).
The distortion is small, so you need to zoom in on the plot to see it. Fiducial marks
show the paraxial ray positions. This makes a less cluttered plot for small distor-
tion cases.
MTF (“Sharpness”)
With any type of camera, users are interested in qualities such as sharpness or
resolution. Optical designers relate these qualities to MTF, or modulation transfer
function. Modulation is essentially relative contrast, with 1.0 representing ideal
contrast (perfect black and white, no degradation to intermediate grays). For large
features (low spatial frequency), even a poor lens will have good contrast, while for
higher frequencies (fine details), aberrations and diffraction blend the dark and light
areas. If you determine and plot the MTF for the full range of spatial frequencies,
for all field points, you can define the sharpness of a lens in very compact form.
1. Choose the Analysis > Diffraction > MTF menu.
Note that there is a Quick MTF button, but we want specific spatial frequencies,
and the quick version doesn't support this.
2. On the Frequency/Calculation tab, enter 68 for the Maximum frequency and
17 for the Increment in frequency.
Note that when you change a value on a tab, a red star (also called a change
indicator), displays next to the tab title.
Search
3. On the Graphics tab, enter 68 for the Maximum plot frequency and click OK.
Recall that the CCD array has a maximum spatial frequency of about 67 lines/
mm, and the combination of 17 and 68 (4*17) works well for this analysis.
Tip: You can use the line-drawing and text tools on any graphics window to add
information to help you read and interpret the plot. The added graphics will go away
if you recalculate the plot, but you can choose the File > Save Window As menu if
you want to save the annotated plot.
It appears that the starting lens has very good MTF properties, meeting the low and
high frequency sharpness requirements for all fields and azimuths (MTF can vary
with direction, so two orthogonal directions are calculated, radial and tangential).
The horizontal line at 0.25 MTF was added by hand using the line drawing tool.
Note that we have not yet considered the depth of field issue, which requires that
the lens meet the MTF spec with the object distance at 750 mm as well as the
Search current “infinite” (1.0E10 mm) value. We will discuss this in Chapter 3, which
covers optimization.
Vignetting/Illumination
The spec requires at least 60% relative illumination at the corner of the field (full
field in your system data). This is to include vignetting effects (clipping of off-axis
rays due to apertures on surfaces other than the aperture stop surface) as well as
angular effects (“cosine fourth” is a well-known approximation to relative
illumination vs. angle). The program will model the relationship between pupil size
(or f/number), surface apertures, and so-called vignetting factors.
The system used for this is very flexible but a bit complex and will be explained in
more detail in Chapter 10. Here is the short version: Vignetting factors determine
the reference rays, which in turn determine default apertures. These in turn
determine the rays that get through in calculations such as MTF and many others.
For design purposes, you can directly change the vignetting factors, to expand or
contract the cone of light from off-axis fields, and the default apertures are adjusted
accordingly. In this patent, the upper and lower Y vignetting factors for the full
field are 0.21 and 0.11, respectively. What relative illumination does this produce?
There are at least two ways to look at this, and one is already done.
• Click the Text tab of the MTF output window you created in the last section.
Scroll down to the output table for the last field. (0.0, 26.5 degrees).
Note that in addition to the tabular MTF data, there is additional information for
each field point. Relative illumination is especially helpful in this case, and it is
58.8%, just a little below the required 60% in the spec (note that the value for
cos**4 of 26.5° is 0.64). You could play with the vignetting factors (found on the
Fields/Vignetting page of the System Data window) to try to improve this, but
since this is close to the spec, you can leave the vignetting alone for now, and see if
Search it improves during optimization.
The other place to see illumination data is in the Transmission Analysis option
(Analysis > System menu), which will provide more detailed illumination data,
including the effects of coatings, if any. For this option, CODE V will assume a
quarter-wave anti-reflection coating on each glass surface, unless you delete this
coating or apply a user-defined coating.
Establish Feasibility
This lens looks pretty good as it is, considering that you simply picked an old patent
based on some requirements, then scaled it. Are you done? Consider the size and
thickness of the elements. Although it is possible to fabricate and mount very small
lens elements, these elements are awfully thin for their size.
The original patent had a focal length of about 1 mm, though it was probably scaled
to unit focal length for patent purposes (it may have been a much larger lens,
perhaps for 35 mm film, for which it would have a focal length of about 43 mm for
this field of view). At EFL=6 mm, the middle (negative) element is 1.5 mm in
diameter and only 0.126 mm thick -- just 126 microns (at 43 mm, this element is a
more reasonable 0.9 mm thick). Just to give you a visual impression, here is a plot
of this lens at approximately real scale:
For optics of this size to be handled and worked, you will need to require
reasonable center and edge thickness values, perhaps 0.9 mm for the center and 0.8
mm for the edge thickness values. This means that as good as this design appears to
be, you are not done yet. You will need to use constrained optimization (the
Automatic Design or AUTO option) to reconfigure the lens to meet all the
requirements.
There is at least one additional issue of practicality, which is glass selection. All
three fictitious glasses in the patent are all high index glasses (1.786, 1.717, 1.835).
High or low index (e.g., >1.65 or <1.45) glasses are generally less common and
thus more expensive than mid-range index glasses. You can use the glassfit.seq
macro to quickly convert these glasses to the closest real equivalents (choose the
Tools > Macro Manager menu, then run glassfit.seq, found under Sample
Macros/Material Information in the Macro dialog box). This macro runs
Conclusions
Search To summarize, in this chapter you have:
• Interpreted a spec for a digital camera lens design
• Used the New Lens Wizard to locate a suitable starting point from a database of
expired patents
• Scaled the lens for the application
• Analyzed the starting point and determined some guidelines for optimization
If you haven't saved your work, you should do so now, so it is available for use
in subsequent chapters of this guide. Choose the File > Save Lens As menu and
give the lens file a name such as DigCamStart.len. In the next chapter, you will use
this starting point to optimize a lens that has acceptable optical performance as well
as reasonable fabrication possibilities.