System designHow-to

Encoder-triggered line scan capture: wiring quadrature inputs

Wire quadrature A/B pairs to a frame grabber, set up encoder-triggered line scan capture, divide counts per line, and avoid grab timeouts when motion stops.

LumaSpec Vision11 min read Share on LinkedIn

On this page 11 sections
  1. 01Why the encoder drives the camera
  2. 02The signals you are tapping
  3. 03What you need
  4. 04How many counts per line
  5. 05Worked example: an 8K camera over a 400 mm web
  6. 06Configure the trigger chain
  7. 07Assemble the image without grab timeouts
  8. 08Verify before you ship
  9. 09When encoder triggering is the wrong answer
  10. 10Checklist
  11. 11Questions

A line scan camera builds a true image only when every line covers the same slice of the moving part. Trigger it from its internal clock and any change in belt speed stretches or squeezes the picture; trigger it from the motion itself and the image stays dimensionally correct at any speed. This guide shows you how to tap a quadrature encoder's differential A/B signals into a frame grabber, set the camera to expose one line per fixed number of encoder counts, and assemble the lines into one tall image without grab timeouts when motion stops. The wiring, the divider math and the buffer pattern apply to any grabber that accepts quadrature; the examples use Camera Link, still the workhorse interface for 8K-class line scan.

Why the encoder drives the camera

Free-running the camera is only as good as your speed assumption. A 1 % speed error accumulates 10 mm of drift per metre of travel; at 0.049 mm per pixel that is about 200 pixels, enough to stretch defects and corrupt every measurement on the line. Encoder triggering removes the assumption: the camera samples by distance, so the pixel scale is locked to the roller and the image comes out metric at any speed.

Commit to the encoder whenever the motion starts and stops, reverses, or carries more than about 0.5 % speed ripple. Reserve free-running for a line whose speed is servo-locked and measured — the case covered in how to set the line rate of a line scan camera — and even there, expect slow drift over a long image.

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.

The signals you are tapping

Quadrature means two square waves, A and B, offset by 90 electrical degrees. The offset lets the grabber's counter recover four counts per encoder cycle and read direction from whichever input leads. Machine-vision encoders drive each channel as a differential pair — A+/A- and B+/B-, typically RS-422 at 5 V. The pair is the noise immunity: interference lands on both legs and cancels in the receiver, which is what lets one tap survive a cabinet full of drives.

Wire it accordingly: keep each pair twisted its whole length, land the shield at the grabber chassis only, route away from motor leads, and keep the pigtail short. From cabinet to grabber, an I/O cable with open leads saves building a harness — the LS-CBL-0224 runs 7 m from a DB9 female connector to bare leads for the solder joint at the encoder.

A third channel, Z, pulses once per revolution. Ignore it on a continuous web; wire it when every revolution must start a new image. If the same encoder also feeds a controller-side counting module, configuring triggered encoder capture on an I/O module covers the other half of that shared tap.

What you need

Four parts carry the system: camera, grabber, encoder, cables. An 8K Camera Link model such as the MV-CL081-41CM — 7 μm pixels, 57 mm image circle, M72 mount — is the class the numbers below assume:

Line scan camerasHikrobot MV-CL081-41CM 8k Camera Link Line Scan Camera, MonoMV-CL081-41CM
Lens mount
M72
Interface
Camera Link
Line length
8K
Pixel size
7 μm
$2,679.00 · quotedView and quoteBuild a system with it

The grabber does the counting and the line triggering; whatever board you use must expose a quadrature counter on its auxiliary I/O connector and route the divided output to the camera. On the Camera Link side, the MV-GC1102IOL pairs with cameras of this class:

Frame grabbersHikrobot MV-GC1102IOL Frame GrabberMV-GC1102IOL
Interface
Camera Link
$2,189.00View partBuild a system with it

Match camera and grabber generations before configuration — the camera-file and tap checks in Camera Link frame grabber compatibility for line scan apply here too. For the links between them: a Camera Link data cable — the LS-CBL-0191, 5 m, SDR to SDR — and the open-lead I/O assembly from the wiring section:

Cables5 m Camera Link camera cable, SDR to SDR (LS-CBL-0191)LS-CBL-0191$170.00View part
CablesFrame Grabber I/O Cable, DB9F to Open, 7 m (LS-CBL-0224)LS-CBL-0224
Type
Frame grabber I/O cables
Length
6-8 m
$79.00View part

The lens that covers a 57 mm line at your working distance is its own selection — line scan lens selection for 4K, 8K and 16K cameras works through that trade-off. The encoder comes last, because its resolution falls out of the divider math.

How many counts per line

The divider is the whole calibration: one line trigger for every N encoder counts, with N chosen so that one line of travel equals one object-side pixel. The field-of-view half of the product is worked through in line scan camera field of view: how to calculate it; the line-scan-specific chain is:

magnification = sensor line length / field of view object pixel = sensor pixel size / magnification counts per line = counts per mm × object pixel line rate = web speed / object pixel

Sensor line length is pixels × pixel size. Counts per mm come from the encoder: pulses per revolution × 4 for quadrature decoding, divided by the roller's travel per revolution. Demand N of at least 4 — the divider works in whole counts, and 4 gives you 25 % trim steps when you fine-tune scale. If the arithmetic lands below 2, the encoder is too coarse for the pixel; raise its pulse count or drive it from a faster shaft, because no configuration recovers counts the encoder never produced.

Worked example: an 8K camera over a 400 mm web

Take an 8K line — 8192 pixels at 7 μm, so 57.3 mm of silicon — covering a 400 mm web. Magnification is 57.3 / 400 = 0.143, and one object pixel is 0.007 / 0.143 = 0.049 mm. A 2048 pulse-per-revolution encoder on a 100 mm circumference roller yields 2048 × 4 = 8192 counts per 100 mm, or 81.9 counts per mm. The divider is 81.9 × 0.049 = 4 counts per line.

At 0.5 m/s the web carries 500 mm/s past the camera, so it triggers 500 / 0.049 = 10,200 lines per second — a 10.2 kHz line rate, about 84 Mpix/s, comfortable on a Full-configuration Camera Link link. Exposure must fit the 98 μs line period: set 80 μs and keep the margin. The counter itself sees 500 × 81.9 ≈ 41,000 counts per second, three orders of magnitude below the megahertz-class ceiling of grabber counters. One metre of web becomes 1000 / 0.049 ≈ 20,400 lines — an 8192 × 20,400 image, 167 megapixels, about 160 MB mono — so set a shorter frame length or stream to disk.

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

Configure the trigger chain

  1. With power off, land A+/A- and B+/B- (plus Z if used) on the quadrature inputs of the grabber's I/O connector, following the board's pinout, pairs still twisted at the terminals.
  2. Check the count before touching the camera: open the encoder count register in the vendor's acquisition tool, roll the web a measured 250 mm, and confirm the reading — 81.9 × 250 = 20,480 counts here.
  3. Point the camera's line trigger at the external source. Many Camera Link line scan cameras do this through an exposure-mode register rather than a GenICam trigger selector; on one widely used 8K family the encoder-controlled setting is exposure mode 6. The value varies by family — what must change is that the camera stops free-running and waits for each external trigger.
  4. Route the grabber's divided encoder output to the camera's trigger input and program the divider — 4 in this example.
  5. Cap exposure at 80 % of the line period at top speed: 80 μs against the 98 μs computed above.
  6. Choose the frame length: a fixed lines-per-frame count for cut lengths, or continuous acquisition with software frame boundaries for a web.
  7. Live test: run the motion and grab. A stream while the motor turns and a clean freeze when it stops — not an error — means the chain is wired and routed. What remains is buffer handling.

Assemble the image without grab timeouts

The failure that follows a working trigger chain always has the same shape: motion stops, no counts arrive, no line triggers fire, the frame never fills, and a grab call waiting for a complete frame times out. That timeout is not a failure — it is the system reporting that the part stopped moving. Handle it in the acquisition loop:

  1. Poll the acquisition status; most APIs expose a newest-buffer or frame-complete flag.
  2. Extract a buffer only when the flag says a frame completed. A tight loop that extracts unconditionally re-reads the same partial buffer and duplicates lines in the stitched image.
  3. On timeout, keep the last valid image and return to polling. Lines resume when motion returns, and the next frame completes.

This flag-before-extract pattern is the classic fix for the report that a line works in the vendor's tool but times out in the program. The wait-call discipline is the one described in frame didn't arrive within timeout: one wait call per frame, and the acquisition primitives are those in frame grabber image acquisition for Camera Link and CoaXPress.

Stitching is row-append with a running line counter. When frames restart at a boundary — Z reset, software trigger, a fixed lines-per-frame count — expect a seam and trim or blend it as covered in line scan image overlap across frame boundaries. If the stitch loop cannot keep up with the line rate, the queue is the bottleneck, not the camera: read acquisition faster than processing: fix the frame rate gap before buying anything faster.

Verify before you ship

Four checks, ten minutes, before a batch depends on them:

  • Squareness. Image a 50 × 50 mm plate: expect about 1020 pixels on a side (50 / 0.049) and accept 2 % or less.
  • Direction. Run the web backwards: the image mirrors and the count stays clean; tearing means a marginal pair.
  • Seam. Stop mid-frame and restart over a printed ruler: no doubled or missing lines at the restart.
  • Count roll. Hand-roll a measured distance and read the register against counts per mm × distance.

If position resets appear later in production, conveyor encoder calibration troubleshooting: position resets walks that diagnosis end to end.

When encoder triggering is the wrong answer

Three conditions defeat it. Direction chatter: a web that hesitates or reverses under inspection dithers the counter around one edge, and the camera records the same line repeatedly — thin bands in the image. Enable the grabber's input filter, or gate inspection to steady travel. Slip: an encoder on a driven roller measures the roller, not the product; where grip is marginal, fit a spring-loaded measuring wheel riding the web itself. Starvation: with N below 1 the encoder never produces the counts the pixel needs — change pulse count or gearing. And on a line that truly runs at locked, measured speed, free-running at a fixed line rate is the simpler system; that is the boundary case, not the default.

Checklist

Wiring

  • A+/A-, B+/B- on twisted pairs; shield to chassis at the grabber end only.
  • Encoder output mode matches the input: RS-422 differential, never 24 V HTL direct.
  • Count register read against a measured roll before any configuration.

Configuration

  • Camera line trigger on the external encoder source; free-running off.
  • Divider N ≥ 4, from counts per mm × object pixel.
  • Exposure at or below 80 % of the line period at top speed.

Software

  • Frame-complete flag checked before every buffer extract.
  • Timeout treated as motion stopped, last valid image kept.
  • Seam handling at frame boundaries; line counter carried across frames.

Ready to specify hardware around these numbers? Start at the camera step of the system configurator, and send anything the arithmetic does not settle to the contact page.

Questions

Why does the grab time out when the motor stops?

Because with encoder triggering, no counts means no line triggers, so the frame never completes and a grab call waiting for a full frame times out. Treat that timeout as expected: catch it, keep the last valid buffer, and resume when motion returns. A timeout while the motor is running is different — it points to a broken encoder pair or a divider programmed above the count rate you actually generate.

Can I use a single-ended encoder instead of a differential one?

Yes, within limits. A single-ended TTL encoder is workable under about 1 m of quiet cabinet cable; beyond that, or anywhere near drives, the differential pair is the only reliable choice because noise cancels at the receiver. The first symptom of a marginal single-ended tap is not garbage but quietly missed counts — the image tears or compresses at speed. A 24 V HTL encoder needs a level converter ahead of the grabber.

What encoder resolution do I need for my line scan camera?

Pick the pulse count from the pixel, not the camera: counts per mm must reach at least 4 divided by your object-side pixel. For 0.05 mm pixels that is 80 counts per mm; a 2500 pulse-per-revolution encoder on a 100 mm roller gives 100 counts per mm and a divider of 5. Going finer costs little and buys trim resolution; going coarser than a divider of 2 cannot be fixed in software.

How do I reverse the scan direction if the web runs the other way?

Swap the A and B channel positions at the grabber connector, or invert the polarity of one differential pair, and the quadrature direction reverses along with the image. Do it at the tap, not by rewiring the motor. Some grabbers also expose a software direction flag, which is the cleaner fix when the line must inspect in both travel directions during production.

Why is my captured image stretched even though encoder triggering works?

Two usual causes. Roller slip — the product moves while the encoder wheel does not — shows as local stretch wherever grip is lost; fit a spring-loaded measuring wheel riding the web. A mis-set divider shows as uniform stretch everywhere: image a known square, recompute the divider from counts per mm times object pixel, and reload the configuration. Direction chatter at reversals looks different again, producing thin repeated bands.