Autofocus in Machine Vision: Fixed Focus, Motorized M12 Mounts, and Manual Focus Mechanics
The decision framework for fixed focus vs autofocus, the voice-coil and piezo hardware that motorizes M12 lenses, and the focus mechanics behind both.
Autofocus in machine vision means an actuator moves the lens focus position during operation to keep the target sharp as working distance changes. The lens is a standard fixed-focal-length optic. The mechanism lives in a motorized mount or voice-coil actuator and in the host control loop.
When working geometry is stable, set-and-lock manual focus is the better default because it is simpler to integrate and holds calibration. Specify autofocus only when the camera-to-target distance changes during operation by more than the available depth of field, and optics alone cannot close the gap.
What is autofocus in machine vision?
Autofocus in machine vision means the system adjusts the lens focus position during operation to keep a target sharp as the camera-to-target distance changes. A motorized mount or voice-coil actuator moves a standard fixed-focal-length M12 lens along the optical axis, so the mechanism lives in the mount and its control electronics, not in the glass.
A consumer camera integrates sensing, actuator, and search in one body. A machine vision camera splits those apart, keeping the lens passive while the host decides when and where to move it. Autofocus here is a system-design decision, not a lens purchase. Focus changes where the lens is sharpest, not its focal length, so reframing between products needs a different focal length, not an actuator.
Systems land on one of three architectures: set-and-lock manual focus (the default for stable geometry), motorized refocus at changeover, and continuous autofocus per part or per frame. Each step up adds hardware and failure modes, so the framework below starts from the simplest. Commonlands supplies all three: focus lock rings, and the CLA321 and CLA322 M12 mounts. The hands-on bench procedure is in the guide on how to focus a camera.
Fixed focus vs autofocus: which does your machine vision system need?
Fixed focus, set once at installation and locked, is the correct default for stable working geometry. Specify autofocus only when the working distance changes during operation by more than the available depth of field, and when a shorter focal length or a smaller aperture cannot cover the variation.
The comparison reads as fixed focus lens vs autofocus lens, but in machine vision it is two architectures built around the same passive optic: a locked M12 lens and one in a motorized mount can be the identical part number, differing only in whether anything moves it after bring-up.
Fixed focus is not fixed focal length. Fixed focal length describes the optics: one focal length, one angle of view, no zoom. Fixed focus describes the strategy: the lens is set to one distance and locked. Most M12 machine vision lenses are fixed focal length with adjustable focus, so the same lens ships locked or motorized.
Why a locked lens holds calibration
A locked lens fixes the lens-to-sensor distance, which sets the intrinsic parameters (focal length in pixels and principal point) that pixel-to-world calibration depends on. Dimension gauging, position detection, and code reading assume those stay put, and an autofocus move changes them. A system that must measure across a focus range has to recalibrate after each move, qualify a tolerance window, or command only positions calibrated at bring-up, which is why calibration-critical systems default to set-and-lock.
Check depth of field before buying hardware
Depth of field is the no-moving-parts alternative. On a C-mount lens with an adjustable iris, stopping down trades light for a wider sharp zone. Commonlands M12 lenses have fixed apertures, so their depth of field is set by F-number, focal length, and working distance. That is why autofocus questions come up more often on M12 systems. Run the range through the depth of field calculator before specifying an actuator. If it covers the variation, lock the lens. The depth of field guide covers the underlying math.
Depth of field shrinks as focal length grows, so telephoto systems reach the threshold sooner. A 35mm telephoto such as the CIL350 holds a much thinner sharp zone than a 12mm lens like the CIL122 at the same distance, because depth of field scales roughly with the square of the focal length ratio. A shorter lens and a revised standoff often remove the need for an actuator entirely. The working distance guide and the depth of field calculator quantify each case.
M12 lenses at the two ends of the focus-tolerance range
How do contrast-detect and phase-detect autofocus work in embedded vision?
Contrast-detect autofocus steps the lens while maximizing an image sharpness metric. It works with any sensor but needs several frames to find the peak. Phase-detect autofocus samples opposite sides of the aperture on dedicated pixels and reads defocus direction and magnitude in one frame, but only on sensors that include those pixels.
A contrast-detect loop computes a focus score, typically gradient energy or Laplacian variance, moves the actuator one step, and compares. It cannot tell it passed the peak until the score falls, so the search overshoots and returns. Budget five to twenty frames per refocus. Machine vision is friendlier than consumer photography, since controlled illumination, high-contrast targets, and a bounded distance range shorten the search. This is the sensing approach behind most embedded systems that drive mounts like the CLA321 and CLA322.
Phase-detect pixels split light from opposite sides of the exit pupil. The disparity gives the distance and direction to best focus, so the controller commands one directed move. The catch is sensor support: mobile-derived rolling-shutter sensors often include these pixels, while many industrial global-shutter sensors do not, so verify support in the image sensor datasheet. A third path skips image feedback: when the target distance is known from an encoder or a time-of-flight sensor, the host commands a position from a bring-up lookup table.
Neither Commonlands autofocus mount contains a focus-seeking controller. The host owns the loop: it evaluates sharpness or reads distance, then commands the actuator over USB-C (CLA322) or a drive current (CLA321). Budget host processing and acquisition frames for the search when planning cycle time.
How does M12 autofocus work? Voice coil vs piezo mounts
M12 autofocus adds an actuator that moves a standard M12x0.5 threaded lens along the optical axis. The lens is unchanged. The CLA321 voice-coil mount positions the lens with drive current and needs continuous power to hold, dropping to rest on power loss, carrying lenses up to 7g on 23.5mm hole spacing. The CLA322 piezoelectric ultrasonic mount walks a friction-coupled, non-back-drivable stage in sub-micron steps, holds position unpowered, and reaches a 6.5mm stroke. A fixed-focus lens locked with a ring is the third option and the default whenever geometry is stable.
Liquid lenses: refocus with no stroke at all
A liquid lens changes optical power instead of position. Corning Varioptic drives an electrowetting cell whose water-oil interface reshapes with applied voltage. Optotune deflects a polymer membrane over a fluid reservoir. Neither translates a lens group, so refocus takes milliseconds with no sliding surfaces to wear, which is why fixed-mount barcode readers that see many package heights favor them. Commonlands sells neither. Both are the usual answer when a mechanical mount cannot keep up.
| Attribute | CLA321-VCM | CLA322-AFM |
|---|---|---|
| Actuation | Voice-coil motor, current against spring return | Piezoelectric ultrasonic linear actuator, friction-coupled stage |
| Rated stroke | ≥0.6mm at 100mA with a 5g lens | 6.5mm |
| Holds position unpowered | No; continuous current required | Yes; friction coupling is non-back-drivable |
| On power loss | Returns to spring rest position | Holds last commanded position |
| Control interface | Standard VCM current driver | USB-C via detachable adapter board |
| Lens compatibility | M12x0.5 lenses up to 7g | M12x0.5 lenses up to 5g |
| Price | $29.00 | $199.00 |
Size the stroke before choosing the mount
Required travel grows with the square of the focal length and falls roughly as 1/WD, so short lenses need microns and long lenses at close range need millimeters. It follows from first-order Gaussian optics: for a unit-focusing lens, one that moves as a rigid assembly, the travel from infinity focus to a working distance WD is approximately:
A 12mm lens focused from infinity to 200mm needs 12² / (200 − 12) = 0.77mm of travel, which exceeds the CLA321's 0.6mm rated stroke. Few systems refocus from infinity, though: the same lens moving between 300mm and 700mm needs only about 0.29mm, inside the CLA321 stroke. Run the between-distances form across the real working range before selecting the mount. The stroke budget, not the control interface, is usually the binding constraint. The table below extends the calculation and shows which mount covers each case.
| Focal length f | Travel, infinity to WD 200mm | Travel, infinity to WD 1000mm | Mount that covers it from infinity |
|---|---|---|---|
| 6mm | 0.19mm | 0.04mm | CLA321 or CLA322 |
| 12mm | 0.77mm | 0.15mm | CLA322 at 200mm; CLA321 at 1000mm |
| 25mm | 3.57mm | 0.64mm | CLA322 |
| 35mm | 7.42mm | 1.27mm | CLA322 at 1000mm; neither from infinity at 200mm |
M12 autofocus mounts
IR Cut-Off Filter Switcher, 20mm Hole Spacing, 7.6mm Height, Day/Night Compensated
$12.00
Download .STPView Product
IR Cut-Off / 850nm Bandpass Switcher, 20mm Hole Spacing, 7.6mm Height, Day/Night Compensated
$12.00
View ProductCommonlands stocks M12 lens variants in the US, and standard M12x0.5 lenses thread into either mount within its rated payload (7g for the CLA321, 5g for the CLA322). Inside that limit, lens selection and focus architecture are decided independently. Browse the M12 lens collection for the optics and the lens autofocus motors for both mounts.
What is a manual focus lens?
A manual focus lens is one whose focus position a person sets at installation, by threading an M12 lens in its holder or turning a C-mount focus ring, then locks. After locking it behaves as a fixed-focus optic, but the engineer chose the distance to match the installed geometry, and the lock can be released and reset if that geometry changes.
M12 focus mechanics: the thread is the focus mechanism
A standard M12 lens is a rigid optical assembly. Nothing moves inside it. Focus comes from the M12x0.5 mount thread: one full turn moves the whole lens 0.5mm along the axis, so a quarter turn gives 0.125mm, fine enough for bring-up by hand. Threading toward the sensor pushes best focus farther away. Backing it out pulls focus closer. The M12 lens guide covers holder heights and thread engagement.
A C-mount lens is different: an internal cam translates lens groups to rebalance aberrations across the focus range (Kingslake, Lens Design Fundamentals, 2nd ed., §18.3), so it moves glass inside a stationary barrel rather than as one rigid body. Factory fixed-focus modules are a third case, set at manufacture and not user-adjustable, suited to high-volume products with one known geometry. The C-mount guide covers the mount standard and iris options.
Locking is not optional. Vibration and thermal cycling can loosen an unlocked lens, letting it rotate and drift out of focus. A Commonlands AL6061 lock nut ring tightened against the holder face holds the position, and a low out-gassing thread adhesive adds margin in high-vibration installations.
Set-and-lock hardware
Frequently asked questions
What is the difference between fixed focus and autofocus in machine vision?
Fixed focus means the lens is set to one working distance at installation and locked. It does not change during operation. Autofocus means an actuator adjusts the lens focus position during operation as working distance changes. Fixed focus has fewer failure modes and holds calibration. Autofocus earns its complexity only when distance variation exceeds the depth of field.
What is M12 autofocus?
M12 autofocus is a system, not a lens category. An actuator, either a voice-coil mount like the CLA321 or a piezoelectric ultrasonic mount like the CLA322, moves a standard M12x0.5 threaded lens along the optical axis. The autofocus mechanism lives in the mount and its control electronics. The lens itself is a passive fixed-focal-length optic.
What is a manual focus lens?
A manual focus lens is a lens whose focus position is set by a person during setup rather than by an actuator during operation. In machine vision, the engineer threads an M12 lens in its holder or turns a C-mount focus ring until the image is sharpest at the working distance. Then the engineer locks the position.
When is autofocus worth using in machine vision?
Autofocus is worth using when the working distance changes during operation by more than the available depth of field, and when a shorter focal length or a stopped-down aperture cannot cover the range. Typical cases are conveyor parts of varying height, arm-mounted robot cameras, and multi-format product lines.
Does autofocus solve a depth-of-field problem?
No. Autofocus moves the focus plane to track the target. It does not increase depth of field. Evaluate optics first: a C-mount lens stopped down from F/2 to F/8 gains roughly four times the depth of field. Specify autofocus when aperture and focal length choices alone cannot cover the working distance range.
What is the difference between a voice coil and a piezo autofocus mount?
The Commonlands CLA321 voice-coil mount positions the lens with drive current against a spring return and needs continuous power to hold position. Rated stroke is 0.6mm or more at 100mA with a 5g lens. A piezoelectric ultrasonic mount like the CLA322 steps a friction-coupled stage across 6.5mm and holds position with power removed.
Does machine vision use phase-detect autofocus like consumer cameras?
Rarely in the consumer sense. Phase-detect autofocus requires sensor pixels that sample opposite sides of the aperture, and many industrial global-shutter sensors omit them. Embedded systems more often run a contrast-detect sharpness search on the host, or command focus open-loop from a known or measured target distance.
Need help choosing a focus architecture?
Send your working distance range, sensor, cycle time, and format count to the engineering team, or request CLA321 and CLA322 samples to prototype the focus loop. Commonlands orders placed before 12 PM PST typically ship same day from San Diego.









