Lenses & opticsExplainer

M12 lens thread travel: why short threads lock out close focus

How M12 lens thread travel sets the focus range, why a lens with short threads cannot lock close focus, and how to verify focal length with the FOV math.

LumaSpec Vision11 min read Share on LinkedIn

On this page 8 sections
  1. 01The decision: trust the arithmetic, not the cap
  2. 02What thread travel is and what it caps
  3. 03Worked example: a 6 mm lens at 400 mm on a 1/2.3-inch sensor
  4. 04Why a 3.9 mm lens cannot stand in for a 6 mm
  5. 05Checks before you bolt the lens in
  6. 06When the usual answer is wrong
  7. 07Checklist: ten minutes before you trust the marking
  8. 08Questions

An M12 lens focuses by screwing in and out of its mount, so the length of thread on the barrel is not cosmetic — it is the focus range. A barrel threaded over only part of its length seats too far from the sensor, runs out of adjustment at one end, and cannot be locked where a close-focus station needs it. Add a cap whose printed angle disagrees with the glass inside, and you can chase focus for an afternoon while framing the wrong field the whole time. This explainer gives the mechanics, the arithmetic that ties focal length, working distance and extension together, and a set of checks that settle in ten minutes whether the lens in your hand is the lens you ordered. It is written for anyone fitting M12 board lenses to board-level cameras on a macro or inspection station.

The decision: trust the arithmetic, not the cap

Check framing first, because it catches the expensive mistake in five minutes. Three numbers decide whether an M12 barrel can serve your station, and only one of them ever appears on a cap.

Measured focal length. Frame a ruler at your working distance and solve f = sensor active width × WD ÷ framed width. If the answer sits more than 10 percent from the marked focal length, the marking is wrong and the lens goes back. No shim and no amount of turning changes what a lens frames.

Threaded length. The sharp position is an absolute lens-to-sensor distance. A barrel whose threads stop partway down cannot seat deep enough to reach far focus, and it cannot hold a stable lock near the end where the threads disengage.

Engagement at the lock. Keep at least two full turns of thread in the mount at the locked position. A barrel standing on its last turn rocks under the locking screw, and focus walks as you tighten.

The sections below turn those three numbers into arithmetic you can run with a ruler and a pair of calipers.

What thread travel is and what it caps

The S-mount thread is M12×0.5: one full turn advances the barrel 0.5 mm along its axis. Finer M12×0.35 barrels exist; a turn of those advances 0.35 mm, so the same threaded length buys fewer millimetres of travel but a finer set. Focus lives in a window between two hard limits.

At the deep limit the lens is screwed fully in, as close to the sensor as the threads allow; that is the farthest subject distance the barrel can ever focus. At the out limit the last thread is about to leave the mount; that is the closest subject distance. Threads that stop halfway down the barrel cut the deep limit short — the lens bottoms on its thread runout before reaching its design seat, so every focus position shifts closer and the far end of the range, where long working distances live, disappears. That is the classic signature of a lens that focuses only at close distance with perfect glass. Where the window falls is set by the distance from the mount face to the sensor — the distinction between focal length and back focus on a board camera.

usable travel = threaded length − 2 × pitch extension needed e = f² / (WD − f) turns of adjustment = e / pitch HFOV = 2 × atan(sensor width / (2 × f))

A threaded zone of 2.5 mm at 0.5 mm pitch leaves 1.5 mm of usable travel — three full turns. The rule to carry to the bench: the threaded length must exceed the extension your distance needs plus two turns of reserve, L ≥ e + 1.0 mm at 0.5 mm pitch. Shorter than that, the barrel cannot both reach the position and lock it.

Worked example: a 6 mm lens at 400 mm on a 1/2.3-inch sensor

The inputs, each with its source:

  • Working distance WD = 400 mm, the fixed glass-to-part distance of the station.
  • Focal length f = 6 mm, the lens as ordered and marked.
  • Active sensor area 6.2 × 4.65 mm, a common 1/2.3-inch CMOS figure; read your own sensor's width from its data.
  • Pitch 0.5 mm, the M12×0.5 S-mount standard.

The rule in words: a thin lens images a subject at WD at a lens-to-sensor distance s' = f × WD ÷ (WD − f). The extension beyond the infinity seat is e = f² ÷ (WD − f). One full turn moves the lens one pitch, and the field of view follows from sensor width and focal length.

The arithmetic, written out:

1 ÷ s' = 1 ÷ 6 − 1 ÷ 400 = 0.16667 − 0.00250 = 0.16417 per mm s' = 1 ÷ 0.16417 = 6.09 mm e = 6.09 − 6.00 = 0.09 mm, which is 0.09 ÷ 0.5 = 0.18 turn, about 65 degrees of rotation past the infinity seat HFOV = 2 × atan(6.2 ÷ 12.0) = 2 × 27.3° = 54.7° VFOV = 2 × atan(4.65 ÷ 12.0) = 2 × 21.2° = 42.4° Framed field at the part: width = 400 × 6.2 ÷ 6 = 413 mm, height = 400 × 4.65 ÷ 6 = 310 mm Magnification = 6.09 ÷ 400 = 0.0152, so a 50 mm feature covers 50 × 0.0152 = 0.76 mm on the sensor

A true 6 mm lens therefore frames about 410 × 310 mm at this station and sits a fifth of a turn past its infinity seat. Two failure signatures, two verdicts. If it frames roughly 640 mm wide instead — near 77 degrees — the glass is a 3.9 mm lens wearing the wrong cap; it goes back, because focal length cannot be screwed in. If the framing is right but the image never sharpens at 400 mm even fully seated, the threads run out before your distance: that barrel cannot focus at 400 mm on that mount.

How sensor width, working distance and field of view set the focal length Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.CameraField of view (FOV)Working distance (WD)≈ fsensor width slensm = s / FOVf = WD × m / (1 + m)
How sensor width, working distance and field of view set the focal length. Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.

The lens focal length calculator runs the same arithmetic for your own sensor and distance.

Lens focal length, field of view and working distance
Units
Solve for
Focal length
– mm
Field of view
– mm
Working distance
– mm
Magnification
– x
Angle of view
– °
Pixel on the part
– mm

Thin-lens model: m = sensor width / field of view, f = WD × m / (1 + m). Accurate to a few percent above about 150 mm; check the lens's minimum object distance.

Find lenses with this focal length Open the full calculator

Why a 3.9 mm lens cannot stand in for a 6 mm

At WD 400 mm, 1/2.3-inch sensor (6.2 × 4.65 mm) 6 mm lens 3.9 mm lens
Horizontal field of view 54.7° 77°
Framed field at the part 413 × 310 mm 636 × 477 mm
Magnification 0.0152 0.0098
Extension past the infinity seat 0.09 mm (0.18 turn) 0.04 mm (0.08 turn)

The shorter lens renders a feature about a third smaller in each dimension — 1 − 3.9 ÷ 6 = 0.35 — and no thread position changes that. Turning the barrel moves the plane of focus; the ratio of sensor width to focal length fixes the field size. Note the last row: at 400 mm the 3.9 mm needs less extension, not more, so when a short-thread 3.9 mm fails at that distance the fault is seating, not travel. Travel bites at genuinely close range. The 6 mm at 60 mm needs 36 ÷ 54 = 0.67 mm, or 1.3 turns; at 30 mm it needs 36 ÷ 24 = 1.5 mm, or 3 turns. Against a 2.5 mm threaded zone — 1.5 mm usable — the 30 mm position barely exists and leaves nothing to lock on. Below about 100 mm of working distance, settle the focal length first with the guide to choosing a machine vision lens focal length, then apply the thread rule.

Checks before you bolt the lens in

  1. Ruler test. Focus a ruler at the working distance and divide: measured f = sensor width × WD ÷ framed width. A 6.2 mm sensor that frames 640 mm at 400 mm is holding a 3.9 mm lens, whatever the cap says. More than 10 percent off the marking: exchange it.
  2. Threaded-length test. Measure the threaded zone with calipers. Usable travel is length − 1.0 mm at 0.5 mm pitch, and it must exceed e = f² ÷ (WD − f).
  3. Seat test. Screw the lens gently home. The sharpest subject distance at full seat is the farthest the barrel can ever focus; your working distance must fall at or inside it.
  4. Lock test. Find the sharp position, count the turns still engaged — two minimum — and check all four corners, because a tilted barrel sharpens one corner first. The corner routine is in M12 lens focusing: adjust, check corners and lock; the clamping practice in lens locking screws.
  5. Format test. The lens image circle must cover the sensor diagonal or the corners fall off; the sizes are untangled in lens sensor format explained. Set the sensor-format filter in the lens finder before the focal-length filter.

Match the format first. For a 1/2.3-inch board sensor, a low-distortion option in that format is the LS-MBL-0159, a 3.3 mm M12-mount lens rated at 16 MP.

M12 board lenses3.3 mm, 1/2.3", 16 MP, M12-mount Low-Distortion M12 lens (LS-MBL-0159)LS-MBL-0159
Type
Low-distortion M12
Sensor format
1/2.3"
Mount
M12
Resolution
16-25 MP
$109.00View partBuild a system with it

Any M12-mount board camera takes these barrels the same way; the MV-CB016-10GM-M-W is one example. A wide barrel for that sensor class is the LS-MBL-0018, a 2.8 mm F2.8 lens listed for 1/2.5-inch formats, and its image circle covers smaller sensors.

Board-level camerasHikrobot MV-CB016-10GM-M-W 1.6 MP GigE board-level camera, IMX296, Mono, M12 lens mount, WTB GigE portMV-CB016-10GM-M-W
Sensor format
1/2.9"
Lens mount
M12
$559.00View part
M12 board lenses2.8 mm M12 board lens, 8 MP, F2.8 (LS-MBL-0018)LS-MBL-0018
Sensor format
1/2.5"
Mount
M12
$50.00View part

When the sharp position sits far out with little thread left, add clamping thread instead of patience: a focusing ring holder such as the LS-LXR-0087, with a 24-45 mm length range, carries the barrel at a set distance and locks there. Lens accessories also carry adapter and spacer rings that shift the focus window toward close range.

Lens accessoriesFocusing ring, length 24-45 mm (LS-LXR-0087)LS-LXR-0087
Type
Adapters & rings
$89.00View partBuild a system with it

When the usual answer is wrong

Unscrew it for more magnification. Each turn out focuses closer but spends engagement, and past the last full turn the lens rocks in a vertical mount. It never enlarges the subject beyond what focal length and sensor fix: at 400 mm the magnification is 0.0152 for the 6 mm and 0.0098 for the 3.9 mm, wherever the thread sits.

The cap says the angle, so it is the angle. The printed figure assumes the maker's reference sensor. A lens sold as 75 degrees still frames 77 degrees across a 6.2 mm sensor; compute from focal length and your own sensor, never from the cap.

It focuses sharp, so it must be the right lens. A 3.9 mm reaches sharp focus at plenty of distances; it just frames 54 percent more width (636 ÷ 413 = 1.54). Sharpness proves focus, not focal length.

Tighten the lock screw harder. One screw bearing on a turn and a half tilts the barrel, and corner focus shifts as the screw takes load. Move the position inboard, add a holder, or change the lens.

Checklist: ten minutes before you trust the marking

  • Ruler framing test at the real working distance; measured focal length within 10 percent of the marking.
  • Calipers on the threaded zone; length at least e + 1.0 mm at 0.5 mm pitch, with e = f² ÷ (WD − f).
  • Seat test passed: the farthest sharp distance at full seat lies beyond your working distance.
  • Two full turns engaged at the locked position; corners sharp after the screw is tight.
  • Lens image circle covers the sensor diagonal; sensor-format filter set before the focal-length filter.
  • Cap angle recomputed for your sensor, then ignored.

When the numbers clear, the lens step of the configurator turns them into a part choice, and M12 lens selection for board cameras covers the format and IR-cut questions that follow. If a measurement lands outside these rules, send the ruler numbers, the caliper reading and the working distance through the contact page and we will identify a barrel that reaches your focus and locks there.

Questions

How many thread turns does an M12 lens need engaged before you lock focus?

Two full turns at minimum on the common M12×0.5 thread. A single turn leaves the barrel 0.5 mm from disengaging, and the locking screw's side force tilts a lens held by less, so corner focus shifts as you tighten. If the sharp position sits with fewer than two turns left, add a spacer ring under the barrel or move to a lens with a longer threaded section rather than tightening harder.

Why do some M12 lenses need more turns than others to reach the same focus?

The S-mount standard is M12×0.5, but finer M12×0.35 barrels exist. A 0.35 mm pitch advances 30 percent less per turn, so the same focus change takes about 1.4 times as many turns and the same threaded length gives less travel but a finer set. The two pitches do not interchange: a mismatched barrel starts to bind after a turn or two, which is one cause of a lens that stops halfway. Check the pitch against the mount before forcing anything.

How can I measure the focal length of an M12 lens with no marking I trust?

Put a ruler in the field at a measured working distance, in sharp focus, and divide: focal length equals sensor active width times working distance divided by the framed width. Example: a 6.2 mm wide sensor framing 640 mm of ruler at 400 mm gives 6.2 × 400 ÷ 640 = 3.9 mm. Work at a distance well above ten times the focal length so the thin-lens error stays under one percent.

Does the field of view printed on a lens cap apply to my sensor?

Only if your sensor matches the one the maker assumed. Field of view is 2 × atan(sensor width ÷ (2 × focal length)), so the same glass spreads wider on a bigger sensor. A 3.9 mm lens that frames about 77 degrees across a 6.2 mm sensor frames about 71 degrees across a 5.6 mm one. Recompute for your active sensor area before you order.

My M12 lens focuses only up close and never sharpens at distance. Is that the thread?

Usually seating, not glass. To push focus from near to far you screw the lens in, toward the sensor; if the barrel's threads run out before it seats deep enough, the far end of the range is unreachable and every sharp position is close. Measure the threaded length and compare it with the same lens type's drawing, or test on a second body with a known mount: the same result means the barrel, a different result means the mount flange.