System designHow-to

Encoder ticks per pixel for line scan: set the scale right

Set encoder ticks per pixel on a line scan camera: counts per mm, the divider formula, a worked example at 300 mm/s, exposure limits and direction handling.

LumaSpec Vision11 min read Share on LinkedIn

On this page 9 sections
  1. 01The rule: one line per pixel of travel
  2. 02Worked example: a 300 mm/s belt at 20 lines per mm
  3. 03Pick an encoder that divides cleanly
  4. 04Set the divider in eight steps
  5. 05Exposure: the limit that compresses the image
  6. 06Rotary wheel or linear scale, differential or TTL
  7. 07Checks before you release it
  8. 08When the usual answer is wrong
  9. 09Questions

A line scan camera that follows an encoder captures one line for every fixed distance the product moves, not every tick of a clock. The result is a square image: a pixel along the belt equals a pixel across it, at any speed. Set the encoder ticks per pixel wrong and every dimension along travel is wrong with it — circles print as ellipses and gauging drifts by whole percent. This guide computes the divider from belt speed, pixel size and encoder resolution, works a complete example at 300 mm/s, and covers the exposure limit and direction handling that break an otherwise correct setting. You finish with a number to type in and a test that proves it.

The rule: one line per pixel of travel

Start from the object-side pixel size: the width of belt one sensor pixel sees. If the optics deliver 0.05 mm per pixel across the belt, the belt must advance exactly that much between lines, and the encoder must release one trigger per pixel of travel. Three formulas cover the whole job:

lines per mm = 1 / pixel size (mm) line rate (Hz) = belt speed (mm/s) / pixel size (mm) encoder counts per mm = pulses per revolution × 4 / wheel circumference (mm) divider = encoder counts per mm × pixel size (mm)

The ×4 is quadrature: both channels, both edges, four counts per pulse. Fix the ×4 question first, because an input set to ×1 quarters the counts and your divider with it. The divider lives in the camera or grabber configuration — usually named encoder divider, decimation or StepsPerLine — and passes one line trigger to the sensor for every N encoder counts.

A line scan camera building an image line by line The camera images one thin line of the moving web per exposure, lit by a line light. An encoder on the conveyor triggers each line so the pixels stay square at any speed.one line per exposureLine scanline lightweb speed vencoderline rate = v / object pixelexposure < 1 / line rate
A line scan camera building an image line by line. The camera images one thin line of the moving web per exposure, lit by a line light. An encoder on the conveyor triggers each line so the pixels stay square at any speed.

Line rate is the first gate: the camera must sustain it and the link must carry it. How to set the line rate of a line scan camera works that half of the problem.

Worked example: a 300 mm/s belt at 20 lines per mm

Inputs. Belt speed 300 mm/s, from the machine data. Target scale 0.05 mm per pixel, from the defect spec: a 0.2 mm defect then spans 4 pixels. Camera: 8K. Encoder on the shelf: 1024 pulses per revolution, quadrature, on a measuring wheel with 200 mm rolling circumference. Task: dimensional gauging with a 0.5 % scale tolerance.

Rate and field of view. Lines per mm: 1 ÷ 0.05 = 20. Line rate: 300 mm/s ÷ 0.05 mm = 6000 lines/s, or 6 kHz — 8K line scan sensors commonly run to tens of kilohertz, so this leaves margin. Field of view: 8192 pixels × 0.05 mm = 409.6 mm, so one camera covers a 410 mm belt. Data load: 8192 × 6000 = 49.2 million pixels per second, which a 10GigE camera carries with room to spare.

For that width, an 8K camera on 10GigE is the right call:

Line scan camerasLine scan camera, 8K, 10GigE, Mono, 8192*4 resolution (LS-LCM-0099)LS-LCM-0099
Lens mount
M72
Interface
10GigE
Line length
8K
$1,439.00View partBuild a system with it

The line scan camera line rate calculator runs the same arithmetic on your own numbers:

Line-scan camera line rate
Units
Pixel on the part
– mm
Line rate needed
– kHz
Longest exposure
– µs
Data rate
– MB/s
Lines per metre
–
Encoder setting
–

Square pixels: line rate = speed / pixel on the part; the exposure must end within one line period. Encoder: lines per pulse = (π × roller diameter / pulses per revolution) / pixel on the part.

Find line scan cameras Open the full calculator

Encoder arithmetic. Pulses per mm: 1024 ÷ 200 mm = 5.12. Counts per mm at ×4: 5.12 × 4 = 20.48. Counts per line: 20.48 counts per mm ÷ 20 lines per mm = 1.024. There is the failure. A divider passes whole counts, so no setting produces exactly one line per pixel of travel. Divider 1 gives one line per count: 1 ÷ 20.48 = 0.0488 mm per line, a line rate of 300 ÷ 0.0488 = 6144 Hz, and a travel scale 2.4 % too long — five times the tolerance.

Decision. Change the encoder, not the tolerance. The pulses per revolution that divide cleanly come from:

pulses per revolution = divider × wheel circumference / (4 × pixel size)

With a 200 mm wheel and 20 lines per mm that is divider × 1000. A 2000 P/R encoder gives divider 2 exactly: 2000 ÷ 200 = 10 pulses/mm, ×4 = 40 counts/mm, and 40 ÷ 20 = 2 counts per line. Set the input to ×4, the divider to 2, and the scale is exact at every belt speed. If the job were label reading or presence checks, divider 1 on the 1024 P/R part would ship at 2.4 %; for gauging it does not.

Pick an encoder that divides cleanly

Compute counts per line first. If it is not a whole number, change the encoder or the wheel, not the tolerance. On the 200 mm wheel of the example:

Pulses per revolution Counts per mm at ×4 Counts per line Divider Travel scale
1024 20.48 1.024 none whole 2.4 % off at divider 1
2000 40 2 2 exact
4000 80 4 4 exact
10,000 200 10 10 exact

Aim for 2 to 10 counts per line. One count per line is the floor, because the divider cannot follow the belt more finely than its input; past ten you buy resolution the divider throws away.

A narrower web changes the camera, not the method: at the same scale, 4096 pixels cover 4096 ÷ 20 = 204.8 mm. The MV-CL042-91GC-V2 is a 4K GigE line scan camera with 7 μm pixels and an M42 mount.

Line scan camerasHikrobot MV-CL042-91GC-V2 4k GigE line scan, Color, Isolated versionMV-CL042-91GC-V2
Lens mount
M42
Interface
GigE
Line length
4K
Pixel size
7 μm
$1,459.00View partBuild a system with it

Set the divider in eight steps

  1. Measure the wheel by rolling it. Ten turns on a steel rule: 10 × 200 mm = 2000 mm. A worn wheel is the most common scale error, and it hides here.
  2. Mount the encoder on the shaft that follows the product — the wheel rolling on the belt, not a shaft behind a gearbox.
  3. Wire channels A and B to the encoder input: differential pairs (A+/A−, B+/B−) for long or electrically noisy runs, single-ended TTL for short ones. Encoder-triggered line scan capture: wiring quadrature inputs shows the connections.
  4. Set the encoder input to quadrature ×4.
  5. Compute and enter the divider: counts per mm ÷ lines per mm = 40 ÷ 20 = 2 in this example.
  6. Cap the exposure below the line period and strobe the light, as the next section sets out.
  7. Jog the belt both ways. Forward must advance the image; a backward jog must add no lines, because quadrature direction counting holds the counter until forward motion returns.
  8. Prove the scale with a known length: 100 mm × 20 lines per mm = 2000 pixels.

Exposure: the limit that compresses the image

The divider is correct in distance, but exposure runs in time, and the camera cannot start a line while the previous one is still exposing. At an 18 kHz line rate the period is 1 ÷ 18,000 s = 55.6 µs — the entire exposure budget, and the reason dark line scan images come out compressed. Let auto exposure stretch past the trigger period and the camera drops lines: objects shorten along travel and thin defects disappear from the image.

The 6 kHz line of the example buys 1 ÷ 6000 s = 167 µs, but an exposure held open that long smears a full pixel, because the belt advances 300 mm/s × 167 µs = 50 µm — one pixel width — while the shutter is open. Two ways out:

  • Strobe the light. Twenty microseconds of LED light per line moves the belt 300,000 µm/s × 20 µs = 6 µm, which is 0.12 pixel of smear, at a 12 % duty cycle (20 µs × 6000 lines = 120 ms of light per second). A strobe-capable digital controller such as the LS-CTL-0070 fires the light on every line:
Light controllersDigital control box, 4 ch, 200 W, RS232 (LS-CTL-0070)LS-CTL-0070
Output
Constant voltage 24 V
Channels
4 channels
Control
Digital
Feature
Strobe
$549.00View partBuild a system with it

Lighting controllers for line scan cameras covers sizing the pulse and the channel.

  • Gather more light per microsecond. Bigger pixels or TDI multiply what the sensor collects at the same short exposure: the LS-LCM-0016 is a 2K line scan camera with 7 μm pixels, a 58 kHz line rate and TDI. Pixel binning on a line scan camera buys similar headroom by trading cross-belt resolution.

Either way, set a hard ceiling so the software can never drift past the line period — cap the maximum auto exposure time to stop motion blur — and keep exposure time versus shutter speed straight while you do it.

Rotary wheel or linear scale, differential or TTL

Two encoder families do this job. A rotary encoder on a measuring wheel is the default: mount it where the wheel rolls on the belt or web. A linear encoder — a read head over an adhesive magnetic tape — resolves down to 0.001 mm, which at one line per pixel of travel gives 50 counts per line, divider 50. Choose the tape when a wheel would slip, mark, or wear: it measures the web itself, and the scale doubles as a length gauge.

Both families come as differential (A+/A−, B+/B− pairs) or single-ended TTL outputs; match the output to the encoder input on your line scan cameras or frame grabbers. Rate is rarely the constraint at conveyor speeds — 40 counts/mm at 300 mm/s is 12,000 counts per second — but at high shaft speeds dropped counts appear: why encoder-triggered image capture drops images at high RPM names the causes, and Camera Link frame grabber compatibility for line scan covers the grabber side of that link.

Checks before you release it

  • Known length at both ends of travel: 100 mm must span 2000 pixels near the camera and at the far end. A difference between the two means the wheel slips or the circumference is wrong.
  • Direction: jog back 20 mm, then forward; the image must show no duplicated rows.
  • At speed: capture at 300 mm/s and re-measure the same gauge. The divider corrects for speed by construction, so the number must not move.
  • Residual error: line scan camera calibration with a moving checkerboard target removes the last fractions of a percent from lens distortion and trigger timing.

When the usual answer is wrong

  • Varying speed without an encoder. Free-running at a fixed line rate distorts the image by the full speed change: a belt drifting 10 % stretches features 10 %. Encoder sync removes this by construction, because triggers follow distance, not time. If hardware triggering is impossible, make the line rate follow machine speed at runtime is the software route.
  • An encoder behind a gearbox. The ratio divides your counts per mm; the FAQ works a 5:1 box that starves the divider to 0.4 counts per line. Mount on the wheel shaft and the problem disappears.
  • Belt bounce on stopping. A belt that rolls back a few millimetres duplicates rows on a single-channel trigger. Quadrature direction counting holds the counter through the bounce, so buy the camera or grabber input that does it.
  • Tolerance mismatch. Presence checks and code reading tolerate roughly 2 % of scale error; dimensional gauging does not. The 1024 P/R encoder ships in the first job and fails the second.

Next step: put your belt speed, pixel size and encoder pitch through the camera finder or the system configurator. If the divider refuses to come out whole, a programmable encoder or a different wheel circumference ends the hunt — bring the numbers to the contact page and we will work them with you.

Questions

How many encoder counts should one line scan pixel get?

Two is the smallest clean value and ten is the practical ceiling. One count per line is the hard floor, because a divider cannot pass less than a whole count, but it leaves the scale set entirely by the encoder, so any wheel circumference error lands straight on the image. Between two and ten the divider is a whole number with margin for rounding. Above ten you are paying for resolution the divider throws away.

A 100 mm gauge measures 1956 pixels in the image. What is wrong?

At 20 lines per mm it should span 2000, so the travel step is 100 ÷ 1956 = 0.0511 mm instead of 0.0500, which is 2.2 % coarse. With the divider at 1 that implies 19.56 counts per mm rather than 20.48, which points at the wheel: 4096 ÷ 19.56 = 209 mm of circumference instead of 200. Roll the wheel ten turns against a steel rule and re-enter the true circumference; a worn or mis-specified wheel is the usual culprit.

Should the encoder go on the drive motor or on the belt wheel?

On the belt wheel. Through a 5:1 gearbox a 2000 P/R quadrature encoder yields 2000 × 4 = 8000 counts per motor turn, ÷ 5 = 1600 counts per wheel turn, and 1600 ÷ 200 mm = 8 counts per mm. That is 0.4 counts per line, which no divider can use. Gear ratio and belt slip both sit between the motor and the product, so measure where the product actually moves.

Is a linear encoder better than a measuring wheel?

A 1 μm magnetic tape gives 50 counts per line, and the scale then never depends on wheel wear, slip or diameter. Use one where a wheel would slip, on tensioned or glossy webs, where contact is not allowed, or when the encoder doubles as a length gauge. On a plain conveyor with a true-rolling wheel, a rotary encoder holds the scale with far less install effort.

The image suddenly looks four times too short along travel. What changed?

The encoder input dropped from ×4 to ×1 counting. Counts per mm fell from 40 to 10, so a divider of 2 now releases a line every 0.2 mm instead of every pixel of travel, and objects shrink four to one along travel. Set the input back to quadrature ×4, both channels and both edges, then re-measure a known length: 100 mm must span 2000 pixels.