You usually know two numbers before a board camera lens is chosen: how far the camera will sit from the part, and how much of the part the image must cover. With the sensor's active-area width and height, those numbers fix the focal length. Everything after that is rounding to a catalog value and checking that the image circle, mount thread and back focus match the board. This guide runs the calculation for an M12 (S-mount) board camera, works a real case — an 8 in (203 mm) square field at 400 mm working distance — and ends with the bench checks that catch what a formula cannot. Ten minutes with a calculator and the sensor data sheet is enough.
What you need
- Working distance (WD) in millimetres, part to lens front. Below 0.1× magnification, front-of-lens versus lens-centre is worth a few percent at most.
- Field width and field height in millimetres. Convert inches once: 1 in = 25.4 mm.
- Sensor active-area width and height. The optical-format name is a nominal diagonal, not a width. Use the table below when the data sheet gives only the name; where it prints a real active area, use that, because 16:9 and 3:2 parts are shorter than the 4:3 nominal.
| Optical format | Nominal width × height (4:3) | Nominal diagonal |
|---|---|---|
| 1/4" | 3.2 × 2.4 mm | 4.0 mm |
| 1/3" | 4.8 × 3.6 mm | 6.0 mm |
| 1/2.3" | 6.2 × 4.6 mm | 7.7 mm |
| 1/2" | 6.4 × 4.8 mm | 8.0 mm |
| 1/1.8" | 7.2 × 5.4 mm | 9.0 mm |
| 1/1.7" | 7.4 × 5.6 mm | 9.3 mm |
| 2/3" | 8.8 × 6.6 mm | 11.0 mm |
| 1" | 12.8 × 9.6 mm | 16.0 mm |
The board-level cameras listings print sensor format and lens mount for each camera, and the M12 board lenses listings print the format each lens covers, so the pairing can be checked before any arithmetic.
The focal length formula
Run the calculation twice: once with sensor width and field width, once with sensor height and field height. The smaller focal length wins, because it is the direction that runs out of sensor first. On a square field with a 4:3 sensor, height always binds, and the height answer is the width answer times 3/4. The exact form costs a factor of (1 + m) against the approximation: 2.7% at m = 0.027, 10% at m = 0.1. Above about 0.1×, use the exact line.
That exact line is the standard thin-lens focal length result with magnification substituted in.
Worked example: an 8 in square field at 400 mm
Inputs: WD = 400 mm throughout this example; field 203.2 × 203.2 mm (8 in × 25.4); sensor 1/1.8" nominal 4:3, so 7.2 mm wide and 5.4 mm high.
- Width direction: f = 7.2 mm × WD ÷ 203.2 mm = 14.2 mm.
- Height direction: f = 5.4 mm × WD ÷ 203.2 mm = 10.6 mm, so height binds.
- Exact value: m = 5.4 ÷ 203.2 = 0.0266, so f = WD × 0.0266 ÷ 1.0266 = 10.4 mm.
- Round down to a catalog focal length: 10 mm. At WD it covers 7.2 × 400 ÷ 10 = 288 mm wide and 5.4 × 400 ÷ 10 = 216 mm high — +42% and +6% over the 203.2 mm target. The +6% holds with a rigid mount.
- If 12 mm is the nearest lens available, move the camera: required distance = focal length × field ÷ sensor height = 12 mm × 203.2 mm ÷ 5.4 mm = 452 mm minimum. Set about 480 mm and the field is 288 × 216 mm again, the same margins as the 10 mm answer.
Decision: a 10 mm focal length at WD, or a 12 mm lens backed off to roughly 480 mm. For contrast, a 25 mm lens covers 5.4 × 400 ÷ 25 = 86 mm of height at the same stand-off — it belongs to the next part size up, not this one.
The calculator runs the same geometry; its button opens the lens finder at the focal length it returns.
From focal length to a catalog lens
The lens finder filters by sensor format and focal-length class, so 1/1.8" plus 6-12 mm is where this example's answer lives.
Two 12 mm M12 models built for 1/1.8" boards, with an 8-11 mm image circle and a 5 MP rating:
- Sensor format
- 1/1.8"
- Mount
- M12
- Sensor format
- 1/1.8"
- Mount
- M12
Set the working distance near 480 mm and either covers the 203 mm square with the margins computed above.
For a smaller part at the same stand-off — a 100 mm (4 in) field — the focal length rises: 7.2 × 400 ÷ 25 = 115 mm wide and 86 mm high. The LS-MBL-0031 is a 25 mm M12 board lens with a 1/1.8" format and an 8-11 mm image circle.
- Sensor format
- 1/1.8"
- Mount
- M12
- Resolution
- 5 MP
- Image circle
- 8-11 mm
At the wide end, a 2.8 mm lens on a nominal 5.8 mm wide 1/2.5" sensor reaches 5.8 × 400 ÷ 2.8 = 829 mm (about 33 in) across at WD. The LS-MBL-0018 is a 2.8 mm F2.8 M12 lens with an 8 MP rating for 1/2.5" sensors.
- Sensor format
- 1/2.5"
- Mount
- M12
- Resolution
- 6-10 MP
- Image circle
- Up to 8 mm
Board cameras ordered as C-mount variants instead take the machine vision lenses range, where working distance is printed per lens; the same geometry picks the magnification. The lens step of the configurator pairs format, mount and focal length in one pass.
Checks before you order
Image circle against sensor diagonal. The image circle must meet or exceed the diagonal. A 1/1.8" sensor has a 9 mm diagonal, so lenses in the Up to 8 mm circle class vignette its corners; the 8-11 mm class covers it. A 1/2.3" sensor, 7.7 mm on the diagonal, still fits the Up to 8 mm class.
Mount thread. M12 is the common holder size, but M6 and M8 appear on small modules; board camera lens mount thread sizes: M12 or M6 lists what to measure.
Focus range at your distance. The lens must reach focus inside its thread travel; when it cannot, holder height or a shim is the fix, as lens focal length vs back focus in board cameras explains.
Pixel footprint. Divide field width by horizontal pixel count. A 20 MP 3:2 sensor has √(20,000,000 × 3 ÷ 2) ≈ 5,477 pixels across, so the 288 mm field gives 288 ÷ 5,477 ≈ 53 μm per pixel, and a feature held across 3 pixels measures about 0.16 mm. Diffraction at F2.8-F4 blurs 2.44 × 0.55 μm × N ≈ 3.8-5.4 μm, far below the pixel footprint, so geometry sets the limit; Airy disk size and the diffraction limit shows the full comparison.
Depth of field at this magnification. With the blur circle set at one pixel (c = 0.053 mm), DOF ≈ 2 × N × c × (1 + m) ÷ m² = 2 × 2.8 × 0.053 × 1.027 ÷ 0.000707 ≈ 430 mm at F2.8. Depth of field is not the constraint at 0.027×; exposure is, and M12 lens light gathering shows what a lower F-number buys. The exact treatment is in aperture f-number and depth of field in machine vision cameras.
Infrared. Mono board sensors respond into the near-IR, so find out where the IR-cut filter sits, in the lens glass or on the board; M12 lens IR cut filter: is it in the glass or on the board covers both cases, and unfiltered daylight will shift image contrast.
Bench check and common mistakes
- Thread the lens to focus at the working distance, corners included, following M12 lens focusing: adjust, check corners and lock.
- Photograph a ruler across the part plane: the ruler should span less than the computed field by the designed margin.
- Lock the lens, let the camera reach operating temperature, then re-shoot; camera focus drift with temperature: diagnose daytime blur covers the diagnosis if sharpness moves.
- Re-check the field at the nearest and farthest part positions; the ~430 mm depth of field absorbs normal part settle.
Three mistakes cause most returned board lenses: reading the format name as a width (1/1.8" means 7.2 mm across, not 1.8 mm), computing only the width of a square field so the part clips top and bottom, and switching between inches and millimetres mid-calculation. Convert once, stay in millimetres.
When the simple answer is wrong
Above 0.1× magnification — fields narrower than about ten sensor widths — the (1 + m) term shifts the answer by 10% or more, so use the exact formula and expect fixed-magnification ratings in place of focal lengths. If the job is measurement rather than viewing, barrel distortion in wide M12 lenses bends straight edges that are otherwise sharp; either calibrate the camera-lens pair (Brown-Conrady distortion fitting from point pairs alone) or step up to a telecentric lens (telecentric lens field of view calculation from magnification). On a C-mount camera the same geometry applies with a different catalog; how to choose a machine vision lens focal length is the matching walk-through.
Measure working distance and field height, run the two divisions, and focal length, format, image circle and mount come out in the same pass. The configurator linked above turns those into a part number; if the numbers refuse to line up, the contact page is the fastest route to a second opinion.
Questions
How much field margin should I design in?
Aim for 10-20% beyond the part in the binding direction. Margin absorbs aim error, part-position tolerance and the focus shift that M12 thread adjustment introduces. On the worked example, 15% margin lifts the 203.2 mm target to 233.7 mm, and the height calculation becomes 5.4 × WD ÷ 233.7 = 9.2 mm, so the lens choice moves from 10 mm to 8-9 mm. A rigid, shimmed mount can live with the thinner 6% margin of the 10 mm answer.
Can I keep a 12 mm lens and just move the camera back?
Yes. Field size scales linearly with working distance, so required WD = focal length × field ÷ sensor dimension. For the example: 12 mm × 203.2 ÷ 5.4 = 452 mm minimum, and each 1% of extra margin costs 1% more distance. When the camera position is fixed at the planned distance, the shorter focal length is the only route; when the mount can move, backing off is the simpler fix.
What changes when the sensor is 16:9 or 3:2 instead of 4:3?
Only the height you substitute. Width stays near the nominal value; height drops to width × 9/16 at 16:9 or × 2/3 at 3:2. A 20 MP 3:2 part in a 1/1.8"-class package has roughly 7.2 × 4.8 mm active area, so the height calculation becomes 4.8 × WD ÷ 203.2 = 9.4 mm and the focal length tightens from 10.6 mm to 9.4 mm. Read the active area from the sensor data sheet whenever it is printed.
Does focal length change if I shoot in near-IR or with a bandpass filter?
The geometry ignores wavelength, but focus does not. Most M12 lenses are corrected for visible light, so an NIR-illuminated system can lose sharpness at the same thread position; IR-corrected models hold focus across both bands. Filtering to the illuminant's wavelength with a bandpass filter also rejects ambient light. Re-focus after swapping filters and expect the field of view itself to stay put.
Will any M12 lens screw onto any board camera?
Mechanically usually, optically not always. Three things must match: the holder's thread (M12 is standard, M6 and M8 exist on small modules), the back focal length the board expects, and the image circle against the sensor diagonal. A lens that screws in flush but sits at the wrong optical height never reaches focus; repositioning the sensor or shimming the holder restores it.



