Encoder Counts per Millimetre: The Line-Scan Trigger Record Before the Camera Is Ordered
A line-scan camera does not decide when to take a line; the encoder does. The number that matters is not the encoder’s pulses per...
read more…
Focus shift is the change in the plane of best focus when the aperture is stopped down. In a machine vision lens it comes mainly from residual spherical aberration: rays through the outer pupil and rays near the axis do not meet at the same image distance, so blocking the outer rays moves the best focus. The shift can be small enough to hide inside the depth of field, which is why a lens can look sharp at f/8 after it was focused at f/2.8 and still fail a measurement that depends on the true focus plane. The fix is not a different focusing technique. It is to focus at the production f-number and prove the focus position with a through-focus test.
Focus shift is not the same as a lens that will not hold focus. A lens that drifts while the camera is stationary, or that loses focus after a temperature change, has a different problem. Focus shift is repeatable and tied to the aperture: at each f-number the lens has a best-focus position, and that position moves as the iris closes. The effect is a property of the optical design and the position of the iris inside the barrel, not a random error.
The main cause is spherical aberration. A real lens does not bring all rays from one object point to one image point. Rays that pass through the outer part of the pupil can focus at a slightly different distance from rays near the axis. At full aperture, the image is a blend of those contributions. When the iris cuts off the outer rays, the blend changes, and the plane of maximum sharpness moves. Lenses with more residual spherical aberration show a larger shift; aspherical elements and a different iris position can reduce it.
Other aberrations can add to the effect. Coma, astigmatism and field curvature change across the field, so the shift at the centre may differ from the shift at the corner. Wavelength matters too: a lens focused in white light can move its best focus when the illumination changes to a narrow band. The RP Photonics explanation of spherical aberration is a useful reference for the underlying optics, but the production question is simpler: how much does the best focus move at the apertures and wavelengths the line actually uses?
Stopping down increases depth of field. The range around the best focus that looks acceptably sharp grows, so an image taken at f/8 can look sharp even when the true best focus has moved away from the sensor plane. The depth of field acts as a tolerance band that absorbs the shift. If the band is wider than the shift, the operator sees no problem. If the measurement depends on the exact focus plane, the same shift can bias a dimension or soften a small defect.
This is why a visual check at one aperture is not enough. A lens focused wide open and then stopped down may produce an image that looks fine, while the plane of maximum contrast has moved by tens of microns. The Edmund Optics discussion of depth of field and depth of focus shows how the acceptable range depends on aperture, magnification and the circle of confusion. The shift has to be compared with that range, not judged by eye.
Put a high-contrast target on a micrometer stage at the production working distance. A slanted edge, a line pair chart or a small dot target all work; the target should contain the spatial frequency the inspection needs. Keep the camera, lens and target fixed, and move the target or the camera through a range that covers several times the expected depth of field. Record a sharpness metric at each position: MTF at the chosen frequency, edge width, or the contrast of a small feature.
Run the sweep at the production aperture first. Find the position of maximum sharpness and write it down. Then change the aperture and repeat the sweep without touching the focus ring. The movement of the peak is the focus shift. Do this at the apertures the line will use, not at every marked f-number. If production runs at f/4, the f/2.8 and f/8 points are useful context, but the f/4 peak is the one that must match the setup record.

If the line runs at a fixed aperture, the FA machine vision lens range is the place to compare lenses that publish through-focus data at that f-number.
Not every change in focus is optical. The iris ring can move the lens barrel slightly when it closes, the focus ring can have backlash, and the mount can shift under the weight of a cable. These effects can look like focus shift because they change the image when the aperture changes. Before accepting an optical explanation, repeat the sweep with the lens untouched and watch the mechanical parts. If the focus position changes when the iris is moved but the lens barrel does not move, the cause is likely optical. If the barrel moves, fix the mount or the ring first.
A simple check is to mark the focus ring and the barrel with a pencil line before the test. After each aperture change, compare the marks. A ring that has moved is a mechanical clue. A ring that has not moved, while the best focus moves, points to the optical design. The check costs a minute and prevents a long argument with the lens maker about a problem that belongs to the fixture.
Temperature is another confounder. A lens that warms during the test can drift, and the drift can be mistaken for aperture shift. Let the camera and lens reach a stable temperature, or run the apertures in both directions and see whether the result repeats. A shift that follows the aperture in both directions is more credible than a shift that only appears on the first pass.
Choosing an FA lens for a fixed production aperture? Ask for through-focus data at that f-number, not only a centre MTF curve. Compare the FA machine vision lens range and include the production aperture in the inquiry.
The setup record should name the lens serial number, the camera, the working distance, the aperture, the illumination wavelength and the target used for focus. It should also record the focus position, either as a scale reading on the lens or as a stage coordinate. Without those fields, a later shift cannot be separated from a different setup. The record is the baseline that makes a future focus check meaningful.
Focus at the production aperture, not wide open. If the line runs at f/4, set f/4 and focus there. If the lens must be focused wide open because the image is too dark at the production aperture, record that condition and treat the stopped-down focus position as a separate verified state. The operator should not have to guess which aperture the focus mark represents.
Lock the focus ring and the iris ring after setting them. A ring that can be moved by a cleaning cloth or a cable is a source of drift that looks like an optical fault. The MTF reading guide explains how to interpret the through-focus curve; the setup record explains which curve belongs to the line. Keep the two together so a replacement lens can be compared with the original. The machine vision lens selection guide covers the other selection inputs before a trial.
The pass limit should come from the application, not from a generic number. Start with the depth of field at the production aperture, then subtract the focus repeatability, the stage positioning error, the thermal drift and the lens-to-lens variation. The remainder is the focus-shift allowance. If the measured shift is larger than that allowance, the lens is not suitable for the measurement, even if the image looks acceptable.
For a presence or defect-detection task, the limit can be looser because the inspection does not depend on the exact plane. For a gauging task, the limit can be much tighter because a shift in focus changes the apparent edge position. Write the limit in the same units as the measurement, not in vague terms such as “minimal” or “acceptable.” A limit that cannot be measured cannot be enforced.
| Symptom | Likely cause | Test that separates it |
|---|---|---|
| Best focus moves when the iris closes | Residual spherical aberration | Through-focus sweep at each aperture with the lens untouched |
| Focus mark moves after the aperture change | Mechanical movement of the ring or barrel | Pencil mark on the ring and barrel before the sweep |
| Shift changes with wavelength | Chromatic focal shift | Repeat the sweep with the production bandpass filter |
| Centre and corner peaks move differently | Field curvature or astigmatism | Measure the peak at the centre and at the corners |
| Result drifts over time | Thermal or mount movement | Repeat the sweep after warm-up and in both directions |
If the lens passes at the production aperture but fails at another aperture, the line can still use it if the production aperture is locked and the record states the limit. If the lens fails at the production aperture, a different lens or a different iris position is the answer. Do not compensate with a focus offset that is not written down; the next operator will not know why the mark is shifted.
No. Depth of field is the range around the best focus that looks acceptably sharp. Focus shift is the movement of the best focus itself when the aperture changes. A large depth of field can hide a shift, but it does not remove it.
Focus at the aperture production will use. If the lens must be focused wide open for light reasons, record that state and verify the stopped-down focus separately.
Yes. Aspherical elements can reduce spherical aberration, but they do not guarantee zero shift. The iris position, the remaining aberrations and the wavelength can still move the best focus.
Test the production aperture first, then one or two apertures on either side. The extra points show whether the shift is monotonic and how much margin the production setting has.
Use a target with the spatial frequency and contrast the inspection needs. A slanted edge or a line pair chart at the defect frequency is more relevant than a generic resolution target.
Ask the lens maker for through-focus data at the production aperture and test one sample on the line’s own target.
Related products: Machine Vision Lenses
Related reading: The Machine Vision Lens Selection Guide, FA C-Mount Lens Selection by Sensor Format (2/3 in to 1.1 in)