ApplicationsTroubleshooting

Wrist camera blurry when running program: lock the focus

Sharp at teach, blurry when running the program: why a wrist camera refocuses on every capture and how to lock manual focus at one fixed working distance.

LumaSpec Vision11 min read Share on LinkedIn

On this page 8 sections
  1. 01The symptom and the 30-second tell
  2. 02Likely causes, ranked, with a test for each
  3. 03The fix: lock focus to a manual distance
  4. 04How much distance error the focus tolerates
    1. Worked example: 12 mm lens at a 300 mm standoff
  5. 05Hardware that cannot re-focus
  6. 06Prevention checklist
  7. 07When blur survives the focus lock
  8. 08Questions

The camera teaches clean: the part sits in a crisp image, the locator scores it high, and the cell passes its dry run. Hours later the program's snapshot comes back soft, detection collapses, and the arm stops over a part it saw perfectly at teach. In most cases the lens, the light and the robot are innocent: the camera's autofocus re-runs at capture time and settles at a different focus distance than the one you taught at. Teach-time light, part position and background all feed the autofocus decision, and any of them moving is enough to move the focus point. The fix takes minutes: switch focus to manual at the teach standoff, re-teach the part, then check the depth of field against your part height variation. Below are the symptom signature, the other causes worth ruling out, and the numbers that tell you how much defocus your setting tolerates.

The symptom and the 30-second tell

The signature is specific. At teach, the image is sharp and the locator scores the part well. At run time, a snapshot of the same part in the same pose is soft and the score collapses. The part did not change between the two captures, so the variable is in the camera.

Run the 30-second tell. Trigger two snapshots from the identical robot pose, back to back, without touching the cell. If one frame is sharp and the next is soft, or a soft frame sharpens after the scene sits still for a few seconds, focus is moving between captures. A mechanical fault such as a loose focus ring blurs every frame the same way; it never alternates sharp and soft.

Two sibling faults share the teach-versus-run gap. If images stay sharp at run but the locator still misses, the acquisition path is the suspect — that is the territory of vision locate works in teach but fails at run time: stream vs snapshot. If the live view itself freezes once the program starts, that is a different failure again: why a wrist camera preview freezes during program run.

Likely causes, ranked, with a test for each

Rank Cause Test Fix
1 Autofocus re-runs each capture and stops at a new distance Alternating sharp and soft frames at one pose Lock focus to manual (next section)
2 Focus ring drifted: arm vibration backs an unsecured lens off its seat Compare the ring against a paint mark made at set-up Re-seat, refocus, tighten and mark
3 Standoff changed: bracket shifted, pose edited, camera re-mounted Measure lens-to-part at the run pose, compare with teach Restore the distance or refocus at the new one
4 Motion blur, not defocus: snapshot fires while the arm still settles Smear runs along the motion direction; defocus softens in all directions Add settle time before the trigger, shorten exposure
5 Dirty or fogged protective window in front of the lens Clean and recapture; fog returns after temperature swings Clean or dry the window, recheck the seal

Cause 1 deserves its mechanism spelled out. Automatic focus in these cameras is contrast-driven: it sweeps the focus mechanism, scores edge contrast, and stops where contrast peaks. The scene at teach is not the scene at run. The part sits 15 mm lower because this tray is a different one, the LED output has warmed up, a shiny neighbouring part steals contrast. Each change moves the contrast peak, so the camera stops at a new focus distance and the taught image plane is no longer the focused plane.

Cause 2 matters on any camera whose lens threads into an M12 mount: thread travel is short, and a barrel backed off a fraction of a turn shifts focus quickly at close distance — the geometry is in M12 lens thread travel: why short threads lock out close focus. Arm vibration is the usual driver, the same mechanism that autofocus vs fixed focus lenses on mobile robots: vibration and blur works through.

Cause 4 has its own arithmetic: smear length equals robot speed during the exposure. An arm settling at 10 mm/s through a 20 ms exposure smears 0.2 mm at the part. At the magnification in the worked example below, that is about 8 µm on the sensor, nearly 3 pixels at 3 µm pitch — enough to read as defocus. Exposure and settle time are the levers, as reduce wrist camera snapshot time: fix focus and exposure lays out.

The fix: lock focus to a manual distance

  1. Return the robot to the snapshot pose with a good part in place, lights on, exactly as at teach.
  2. Open the camera node in the program — the same node where you taught the part — and find its camera settings. Look for two parameters: focus mode and focus distance.
  3. Run autofocus once in this scene and note the focus distance it lands on, or focus by hand while watching the live image until the part edges are at their crispest. Write the distance down.
  4. Switch focus mode from automatic to manual and enter the noted distance. From now on the focus mechanism does not move.
  5. Re-teach the part at the locked focus. The locator template must come from the same focus setting the run-time snapshots will use.
  6. Run 20-30 cycles with parts across the normal height spread and confirm every snapshot stays sharp.

Steps 1 to 4 remove the hunting; step 5 matters more than it looks. A template taught on soft images, or on a different focus distance than the run uses, scores poorly no matter how sharp the new snapshots are.

A fixed-focus lens takes the whole failure off the table: the MV-SCB007EC-12S-WBN pairs a 1.6 MP color sensor with a 12 mm manual-focus lens, so focus is set once and then holds.

Smart cameras & vision sensorsHikrobot MV-SCB007EC-12S-WBN SCB vision sensor, 1.6 MP, Color, 12 mm lens, Manual focusMV-SCB007EC-12S-WBN
Interface
Fast Ethernet
Resolution
Up to 3 MP
Sensor format
1/2.9"
Shutter
Global
$1,989.00 · quotedView and quote

Where the standoff is known and fixed, a sensor factory-focused for that distance is simpler still. The MV-SCA002M-03S-WBN-SR is a 0.3 MP mono sensor with a 3 mm lens, focused at 240 mm as delivered.

Smart cameras & vision sensorsHikrobot MV-SCA002M-03S-WBN-SR SCA vision sensor, 0.3 MP, Mono, 3 mm lens, Focus distance 240 mmMV-SCA002M-03S-WBN-SR
Interface
Fast Ethernet
Resolution
Up to 3 MP
Sensor format
1/6"
Shutter
Global
$1,989.00 · quotedView and quote

How much distance error the focus tolerates

Locking focus removes the hunting, not the physics: the part still has to sit inside the depth of field. Two settings decide it — the working f-number, and the blur level you accept as sharp enough for the locator.

m = sensor width / field of view DOF ≈ 2 · N · c · (1 + m) / m²

N is the f-number, c is the circle of confusion you tolerate — one to two pixel widths is the usual choice for a locator — and m is magnification. The expression is the standard close-object approximation, good to a few percent at these magnifications.

Depth of field around the focus plane Light from the lens converges on the focus plane. In front of and behind it, each point spreads into a blur circle; the zone where that blur stays below about a pixel or two is the depth of field. A smaller aperture gives a narrower cone and a deeper zone.depth of fieldfocus planeapertureoutside it, pointsblur into circleswide aperture: steep cone, shallow zonesmall aperture (high F#): deeper zone
Depth of field around the focus plane. Light from the lens converges on the focus plane. In front of and behind it, each point spreads into a blur circle; the zone where that blur stays below about a pixel or two is the depth of field. A smaller aperture gives a narrower cone and a deeper zone.

Worked example: 12 mm lens at a 300 mm standoff

A wrist camera looks straight down at a tray from 300 mm, sensor plane to part surface. The camera carries a 12 mm lens on a 1/2.9-inch sensor 4.9 mm wide with 3 µm pixels, and runs wide open at f/2.8.

Magnification: m = f / (WD − f) = 12 / (300 − 12) = 0.0417

Field of view: 4.9 / 0.0417 ≈ 118 mm across

Circle of confusion: c = 2 pixels = 6 µm = 0.006 mm

Depth of field: DOF ≈ 2 × 2.8 × 0.006 × (1 + 0.0417) / 0.0417² = 0.035 / 0.00174 ≈ 20 mm

So the tolerance is about ±10 mm around the 300 mm focus point. A part 10 mm taller or shorter than at teach starts to soften, and the locator score drops with it.

Stopping down stretches the budget in proportion to N: f/5.6 doubles it to about 40 mm, f/8 reaches about 58 mm (±29 mm). The price is light: closing from f/2.8 to f/8 cuts light by (8 / 2.8)² ≈ 8×, so exposure grows eight times at the same lighting — which walks you straight back into motion blur unless the arm settles longer or the light gets brighter.

Decision: lock focus first, it is free. Then compare your real height spread with the tolerance. Inside ±10 mm with these example optics, you are done. Beyond it, stop down one or two steps, or make the standoff repeatable with a locating stop on the gripper so the camera-to-part distance cannot wander.

Run your own focal length, f-number and pixel size here:

Depth of field and diffraction
Units
Depth of field
– mm
About the focus plane
– mm
Diffraction limit
– F/#
Blur limit
– µm
Diffraction spot
– µm
At this F-number
–

DOF ≈ 2 × N × c × (1 + m) / m², c = allowed blur × pixel size. Diffraction spot (Airy disk) ≈ 2.44 × wavelength × N × (1 + m); past the diffraction limit it is larger than the blur you allowed.

Browse lenses by aperture and format Open the full calculator

Hardware that cannot re-focus

For cycles that also fight motion, the shutter type matters on top of focus: a global shutter samples every pixel at the same instant, so a settling arm cannot shear the image. Two run-ready options: the LS-SMC-0063, a 1.6 MP smart camera with built-in white light and a 16 mm lens running 60 fps, and the MV-SC3050XC-16M-ATN-H, a 5 MP color global-shutter vision sensor on an M12 mount.

Smart cameras & vision sensors1.6 MP smart camera, 60 fps, 16 mm lens, white light (polarized, transparent light) (LS-SMC-0063)LS-SMC-0063
Interface
GigE
Resolution
Up to 3 MP
$1,110.00View part
Smart cameras & vision sensorsHikrobot MV-SC3050XC-16M-ATN-H 5 MP color vision sensorMV-SC3050XC-16M-ATN-H
Interface
Fast Ethernet
Resolution
5 MP
$1,809.00View part

Set and prove the focus at the bench, where the standoff is measurable, before the camera goes onto the wrist. The LS-MNT-0040 slide-table stand — 700 mm height, 400 × 450 mm base — holds the sensor at a fixed height while you focus, lock and mark the ring; lighter brackets live in the shop's camera stands range.

Camera standsMachine vision camera stand, professional slide-table type, height 700 mm, 400 x 450 mm base (LS-MNT-0040)LS-MNT-0040
Type
Camera stands
$629.00View partBuild a system with it

The same order of operations applies to calibration: focus, lock, then calibrate. That workflow is written up in calibrate a camera with autofocus: lock the focus first.

Prevention checklist

Focus faults return after lens swaps, collisions and cell moves. Five minutes of bookkeeping at set-up prevents the repeat:

  • Record the manual focus distance next to the snapshot pose in the program notes.
  • Paint-mark the focus ring and lock screw; photograph the setting.
  • Measure and write down the lens-to-part distance at teach; re-check it after any collision or bracket work.
  • Re-teach the part after every focus change, including a refocus after a lens swap.
  • Gate the snapshot on arm settle and keep exposure as short as the light allows; smear equals speed times exposure.
  • Once per shift, capture a reference part and compare a focus score against the value recorded at set-up; pick the metric with image sharpness metrics for autofocus.

When blur survives the focus lock

If focus is locked, the ring is marked, the standoff is measured and the snapshot still blurs, work the rest in order. Clean the protective window and recapture. Re-measure the run pose against the teach pose instead of trusting the program. Shorten exposure and lengthen settle time. If the blur is uniform in every direction and the distance checks out, put the camera on the bench stand and capture a flat target at the recorded distance: a sharp bench image with a blurred wrist image means something in the mechanical stack — bracket, adapter, mount screws — is moving, and going over each fastener finds it.

If the camera itself keeps losing focus across the fleet, or a rolling shutter cannot be lived with, shortlist replacements in the smart cameras and vision sensors range or the camera finder, or start at the camera step of the configurator. More run-time failure modes from the same family sit on the applications topic page.

Questions

Why does my wrist camera refocus between teach and run?

Automatic focus is contrast-driven: it sweeps the focus mechanism and stops where edge contrast peaks. The scene at run time differs from teach — part height, background, reflections, LED warmth — so the contrast peak lands at a different distance and the frame comes back soft. Setting focus mode to manual pins the focus distance so nothing hunts between captures.

How much can the camera-to-part distance change before the image blurs?

Each way, it is half the total depth of field. For a 12 mm lens at a 300 mm standoff on a 1/2.9-inch sensor at f/2.8, the depth of field is about 20 mm, so roughly ±10 mm. Stopping down to f/8 stretches the same set-up to about ±29 mm, at the cost of roughly eight times the exposure.

Do I have to re-teach the part after switching to manual focus?

Yes, if the teach images were captured under a different focus setting. The locator template stores edge and feature detail from the teach images; if run-time snapshots use a different focus distance, that detail no longer matches. Re-teach once the focus distance is locked, so the template and the run-time images come from the same optics.

Can I fix the blur by just stopping the aperture down instead of locking focus?

No. Stopping down widens the depth of field but does not stop the focus mechanism from moving. If autofocus re-runs and lands far from the taught distance, even a deep depth of field may not cover the error, and the longer exposure invites motion blur. Lock focus first, then stop down only as far as the part height spread demands.

Is the blur defocus or motion?

Look at the direction of the smear. Motion blur runs along the path of movement, and its length is robot speed times exposure time: 10 mm/s through a 20 ms exposure smears 0.2 mm at the part. Defocus softens edges equally in every direction and tracks the focus distance, not the exposure. One capture with the arm fully settled separates the two.