How to Focus a Camera: M12 & C-Mount Lens Setup Guide | Commonlands

How to Focus a Camera: M12 & C-Mount Lens Guide

Learn focusing techniques for camera hardware: ceiling target methods, through-focus, and proper locking.

Download free focus test charts (Siemens stars, resolution targets)

Download Focus Charts

What Are the Physics Behind Camera Focus?

Camera focus happens when light rays from your object converge precisely onto the image sensor. Getting this right is the foundation of every machine vision system.

The distance between lens and sensor where sharp focus occurs is the lens-to-sensor spacing, not the back focal length, a fixed rear-vertex-to-rear-focal-point distance at infinite conjugate (Smith, Modern Optical Engineering, 4th ed.). Adjusting focus changes this spacing to match the working distance.

For M12 lenses, each full rotation moves the lens 0.5mm (thanks to the M12×0.5 thread pitch). How far the object plane moves depends on the conjugates, not on focal length alone: |Δu| ≈ (u/f)² × |Δv|, with u the working distance, f the focal length, and Δv the 0.5mm of travel.

A 4mm lens focused at 300mm sweeps the object plane roughly 2.8 meters per turn, and an 8mm lens at the same distance roughly 0.7 meters. Only long focal lengths at short working distances reach the tens of millimeters, for example 16mm at 100mm, near 20mm per turn. One full turn is a coarse move for the wide M12 lenses this procedure targets; step 5 below works in 1/16-turn increments. C-mount lenses work differently: the focus ring drives an internal cam that shifts lens groups, not the whole lens.

Key Terms You'll Need

Effective Focal Length (EFL): Determines your field of view and depth of field. This is what lens specs typically list (e.g., "4mm lens").

Mechanical Back Focal Length: Distance from the lens rear housing to the sensor. This determines if a lens physically fits your camera.

Flange Focal Distance: For C-mount systems, this is standardized at 17.526mm from the mount flange to the sensor.

Note: Both back focal lengths get used, for different jobs. Optical back focal length, from the last optical surface to the image plane, is what the designer budgets against the IR-cut filter and cover-glass stack, rear-element clearance, and the exit pupil position that sets chief ray angle. Mechanical back focal length, from the rear housing face, tells you whether a lens fits and reaches focus on your camera.

Consider Commonlands M12 lenses for compact applications or C-mount lenses for standardized flange focal distance systems. Check your sensor's pixel size and optical format on our image sensors reference before you pick a lens, since the lens image circle must cover your sensor's full diagonal.

How Do I Focus an M12 Lens?

M12 lens focusing for board level cameras requires systematic adjustment of the threaded mount while monitoring image sharpness. Each rotation = 0.5mm of lens movement. The key is using the ceiling target method to eliminate image tilt.

Thread tolerance mismatches between M12 lenses and holders often cause the lens to sit at a slight angle. This makes one side of your image sharp while the other is blurry, a common problem detailed in our M12 lens technical guide. The fix? Point your camera straight up at a ceiling target. Level both, and the target and sensor planes stay parallel.

1

Mount Camera Securely

Fix the board level camera rigidly, either facing your target or pointing upward for the ceiling target method. Even small movements during focusing will affect results.

2

Position Test Charts

Place four test charts at 50% of the image diagonal from center. This reveals any image plane tilt immediately during adjustment.

3

Illuminate Uniformly

Add consistent lighting across the field of view. Uneven lighting can mask focus issues by creating false contrast gradients.

4

Set Proper Exposure

Establish correct exposure settings using gray cards before focusing. See our detailed exposure setting guide below for OECF and ColorChecker procedures.

5

Thread Lens to Focus

Rotate in 1/16-turn increments (31.25μm axial movement). Watch for equal sharpness across all test points, not just center.

6

Lock and Verify

Apply UV+heat dual cure adhesive or mechanical lock ring, then verify no focus shift occurred during locking.

Test chart positioning showing four Siemens star targets placed at 50% of the image diagonal from center
Figure 2: Four targets at 50% of the image diagonal reveal image plane tilt that a single center target misses

Professional Tip

Ceiling target focusing is standard practice at Commonlands' camera module assembly facility. Our production lines use precision ceiling fixtures with integrated lighting for consistent, tilt-free focusing across all units. Consider our professional assembly services for production volumes starting at 100 pieces minimum order.

How Do I Focus C-Mount Lenses?

C-mount lenses require a different focusing approach due to their standardized flange focal distance. They have a fixed 17.526mm flange focal distance. You focus by rotating the lens's focus ring, not by threading the whole lens like M12.

C-Mount Focus Procedure

  1. Mount lens to camera: Thread C-mount lens fully into mount until flange contacts. This sets the precise 17.526mm spacing.
  2. Set aperture: Open to maximum aperture for brightest view during focusing, then stop down to working f-number after focusing.
  3. Rotate focus ring: Turn the focus ring (not the entire lens) while viewing live image. Focus-ring travel varies by lens.
  4. Verify across field: Check center and corners at working aperture. Acceptable center-to-corner MTF variation depends on frequency, field, and wavelength.
  5. Lock focus ring: Tighten set screws on focus ring or apply removable thread locker to prevent drift during operation.

Commonlands offers a comprehensive selection of C-mount lenses optimized for 1/2" to 1" sensors, with focus rings designed for smooth adjustment and reliable locking. These lenses feature low-distortion designs ideal for measurement applications.

Quick Reference: M12 vs C-Mount

  • M12 Thread Pitch 0.5mm per rotation
  • C-Mount Flange Distance 17.526mm
  • M12 Focus Method Thread lens in/out
  • C-Mount Focus Method Rotate focus ring

How Do I Find Peak Focus Using the Overshoot Method?

The overshoot-and-return technique finds true peak focus rather than a local maximum. Passing deliberately through best focus and returning with finer adjustments takes up thread backlash and confirms the global optimum.

M12 thread backlash varies by lens and holder, so always approach your final focus position from the same direction. This works for manual adjustment and for reviewing MTF measurement curves.

MTF through-focus curve showing initial approach, overshoot past the peak, and return to the maximum MTF position
Figure 3: An MTF through-focus curve annotated with the initial approach, the overshoot past peak, and the return to maximum MTF

Why Overshoot Works

1. Eliminates backlash: M12 thread backlash varies by lens and holder.

2. Confirms global maximum: Passing through ensures you haven't stopped at a local peak.

3. Provides repeatability: Always approaching from the same direction gives consistent results.

4. Reveals focus curve shape: Understanding the sharpness falloff helps set depth of field expectations.

Which Focus Locking Method Should I Choose?

The choice of focus locking method for board level cameras affects long-term stability, serviceability, and production throughput.

Focus Locking Method Comparison for Board Level Cameras
Method Cure/Set Time Strength Reversible Best For
UV Cure Adhesive 30-60 seconds Moderate No Indoor/controlled environments
UV+Heat Dual Cure 30s UV + 5min heat High No Automotive, outdoor, high vibration
Lock Ring Immediate Moderate Yes R&D, field-serviceable units
PTFE/Teflon Tape Immediate Low Yes Prototyping, temporary setups

Commonlands Recommendation

For production volumes, we recommend UV+heat dual cure adhesive applied as a small fillet around the lens-holder interface. This provides maximum environmental resistance while maintaining optical alignment through temperature cycling.

How Do I Calculate Depth of Field?

Proper depth of field calculations ensure your entire object range remains in acceptable focus. Your DOF depends on focal length, working f-number, working distance, and the permissible circle of confusion, the blur diameter you accept at the sensor. That last term follows from pixel pitch, not sensor format, so two cameras of the same format with different pitches have different usable DOF.

Visit our Camera Depth of Field Calculator to determine optimal focus settings for your specific lens/sensor combination and working distance requirements.

How Do I Set Proper Exposure Before Assembly?

Set exposure before final focus locking so image quality stays consistent across production. Standardized targets, ColorChecker gray patches or OECF charts, give repeatable calibration and remove unit-to-unit variation in brightness and contrast.

X-Rite ColorChecker Passport target showing the 18% gray patch used for exposure calibration
Figure 5: The 18% gray patch on an X-Rite ColorChecker gives a consistent exposure reference across camera modules

Simple Exposure Setting Procedure

1

Position Gray Target

Place an 18% gray card or ColorChecker gray patch at your working distance under production lighting.

2

Set Standard Illumination

Establish your production lighting conditions. Document lux levels for repeatability across all units.

3

Adjust Sensor Settings

On an sRGB-like pipeline, 18% gray sits near code value 118 (46% of 255); the right target depends on your ISP.

4

Document Settings

Record exposure time, gain, and any ISP parameters. These become your production standards for all modules.

Critical for Production

Always set exposure parameters before applying focus lock adhesive. Exposure time and gain do not move focus; only the aperture shifts depth of field. Commonlands' assembly service includes standardized exposure calibration using professional gray targets as part of our camera module assembly process.

What Are Common Focus Problems and Solutions?

Focus issues cost production time and reduce yield. These are the failure modes Commonlands sees most often in module assembly, with their root causes and fixes.

Focus Troubleshooting Guide
Problem Symptoms Root Cause Solution
Focus Drift Sharpness degrades over hours/days Mechanical loosening, weak locking UV+heat dual cure, proper torque specs
Corner Blur Center sharp, edges soft Sensor tilt, field curvature Use ceiling target method, select low-field-curvature lens
Material Mismatch Focus changes with environment CTE differences, plastic elements All-glass lenses, matched materials
Vibration Loosening Focus shifts during operation Insufficient locking torque Dual cure adhesive + mechanical retention
Unit Variation Each camera needs different focus Component tolerances stack-up Active alignment process, tighter QC on components

Professional Camera Module Assembly Services

Commonlands assembles camera modules with professional focusing, starting at 100 pieces minimum order quantity. Clean room facilities and precision alignment fixtures keep results consistent for robotics, surveillance, and automotive builds.

Commonlands USB camera module ready for integration into customer systems
Figure 6: Commonlands camera modules ready for integration into customer systems

100 Piece Minimum

Ideal for pilot production and small batches without massive MOQs.

Backlit Vertical Targets

Tilt-free alignment eliminating left-right focus gradients.

Professional Locking

UV+heat dual cure standard, custom options available.

Quality Assurance

100% optical inspection and focus verification.

Fast Turnaround

2-3 week standard delivery for most orders.

Volume Scaling

From 100 to 10,000+ units with consistent quality.

Commonlands camera module assembly stations with backlit vertical targets and precision tooling
Figure 7: Commonlands assembly stations with backlit vertical targets and precision tooling

Minimum order quantity: 100 pieces. Learn more about our assembly services or contact our engineers to discuss your requirements.

Ready to Eliminate Focusing Challenges?

Our team handles the complex alignment process so you can focus on your application.

Get Assembly Quote

What Is Active Alignment? (OEM Production Only)

Active alignment optimizes focus while monitoring image quality in real-time, improving yield for high-volume OEM production. This technique is only cost-effective for large production runs due to significant capital equipment costs and complex changeover requirements between different camera models.

The process uses 6-axis positioning with MTF or contrast feedback to compensate for component tolerances by optimizing each unit individually.

When Active Alignment Makes Sense

Minimum Suggested Volume: High-volume OEM production only

Yield Improvement: Higher first-pass yield

Typical Applications: Automotive ADAS cameras, smartphone modules, high-end surveillance

Equipment Investment: Significant capital costs per alignment station

For lower volumes, manual focusing with proper fixtures and ceiling targets provides excellent results without the capital investment. Contact Commonlands for standard assembly services starting at 100 pieces minimum order quantity.

For the full technical breakdown of active alignment, including the 6-axis error budget and UV-cure locking process, read our active alignment guide for camera modules.

Frequently Asked Questions

What is the correct procedure for focusing an M12 lens?

To focus an M12 lens: 1) Start with the lens at nominal position, 2) Place a test target at your working distance or on the ceiling for tilt-free alignment, 3) Rotate the lens in 1/16 turn increments while monitoring sharpness, 4) Pass through best focus then return with finer adjustments, 5) Lock with UV+heat dual cure adhesive or focus ring. Each full rotation moves the lens 0.5mm due to the M12 × 0.5 thread pitch. Consider Commonlands' professional assembly service for production volumes starting at 100 pieces minimum order.

How do I focus a C-mount lens?

C-mount lenses have a fixed 17.526mm flange focal distance. Focus is achieved by adjusting the focus ring on the lens barrel rather than threading. Use the same target and verification procedures as M12, but rotate the focus ring instead of the entire lens. Lock with set screws on the focus ring or friction tape. Browse our C-mount lens collection for options optimized for your sensor size.

Why use ceiling targets for focusing?

Ceiling targets eliminate image plane tilt caused by M12 thread tolerance mismatches. When threads don't perfectly align, the lens sits at a slight angle, causing one side of the image to be sharp while the opposite side is blurry. By using gravity to ensure perfect parallelism between sensor and target, ceiling focusing prevents this left-right focus gradient. This method is standard in professional camera production and is used at Commonlands' assembly facility.

What's the difference between UV cure and UV+heat dual cure?

UV cure adhesive sets in 30-60 seconds but may have shadowed areas that don't fully cure. UV+heat dual cure adds a thermal activation (80°C for 5 minutes) that ensures complete curing even in shadowed regions, providing superior strength and environmental resistance. Dual cure is recommended for automotive and outdoor applications.

What is active alignment?

Active alignment adjusts lens position while monitoring image quality metrics in real-time. This compensates for component tolerances by optimizing each unit individually. It's essential for high-volume production where consistent quality is required despite manufacturing variations. The process typically uses 6-axis positioning with MTF or contrast feedback.

How do I prevent focus drift over time?

Focus drift is prevented by: 1) Using proper locking methods (UV+heat dual cure for production), 2) Selecting mechanically stable materials (all-glass lenses vs plastic), 3) Allowing adequate cure time before handling, 4) Using mechanical retention as backup for high-vibration environments. Our assembly service includes validated locking procedures for long-term stability.

Can Commonlands assemble and focus my camera modules?

Yes, Commonlands provides complete camera module assembly including professional focusing, tilt-correction with ceiling targets, and permanent locking. We use clean room environments and precision fixtures to ensure consistent quality. Services include M12 and C-mount lens integration, custom fixtures for your specifications, and 100% optical verification. Minimum order quantity is 100 pieces. Contact our engineering team to discuss your requirements.

What focus locking method should I use for my application?

For production: UV+heat dual cure adhesive. For R&D: mechanical lock rings for adjustability. For prototyping: PTFE tape for temporary holding. For automotive/outdoor: always use dual cure for temperature resistance. For serviceable products: lock rings with thread locker. Each method has trade-offs between permanence, strength, and reversibility.