Your capture callback knows one thing: a frame arrived. It does not know whether the photoelectric sensor fired the camera or your code sent a software trigger, and when both paths feed one capture stream, frames from different parts can interleave without a trace. A camera that implements chunk data can settle it. The camera stamps its own evidence into every image at the moment of exposure: which trigger input was active, where its frame counter stood, when the shutter opened. This guide shows you which chunks to enable, a classification rule you can code in an afternoon, the timing arithmetic that tells you how much trigger traffic to expect, and the bench test that proves the attribution works before you carry it to the line.
Why the snap event cannot tell you
The snap event is a single bit of news: pixels are ready. Most capture APIs raise the identical event for a hardware trigger, a software command or a free-running camera, because the event comes from the SDK, which never sees the wire side of the trigger. The camera was there. At exposure it held exactly one armed trigger source, and its input lines had definite states.
Chunk data is the mechanism that lets the camera write that knowledge into the frame itself. Selected feature values are captured at exposure and travel inside the image payload, not in a separate message that can arrive late or out of order. Both major machine-vision interfaces carry it: chunk data is part of the GenICam standard used by area scan cameras on GigE Vision and USB3 Vision alike. Each model implements a subset under its own feature names, so the first stop is the camera's feature browser — the chunk features it lists there are the ones you can actually use.
The three chunks that attribute a frame
Three chunks do the whole job.
Input-line status. The state of the digital inputs at exposure. A frame the photoelectric sensor triggered shows its line high; frames taken on software commands show whatever the sensor output is doing at that moment, which is exactly the evidence the classification rule needs.
Frame counter. The camera's own count of acquired frames, incremented by one per exposure. It is the referee: if it advances by exactly one between frames you received, nothing was lost. A jump means frames vanished between camera and callback, and every frame in that span is unattributable.
Timestamp. The camera's clock at exposure, so a burst can be ordered by when the light actually hit the sensor rather than by when the network delivered it.
Reading per-frame metadata and trusting it is the same habit as verifying exposure and gain per frame: capture the values with the image, not from memory.
The classification rule for every frame
Keep one integer in your application: pending, the number of software trigger commands sent that have not yet produced a frame. Increment it when you send a command. In the frame callback, read the chunks and classify:
| Evidence in the frame | Verdict | Action |
|---|---|---|
| Counter +1, pending > 0 | A software command fired it | Decrement pending |
| Counter +1, pending = 0, line high | The sensor triggered it | Start the next part |
| Counter +1, pending = 0, line low | Nobody requested it | Check the trigger mode; something is free-running |
| Counter jumped by 2 or more | Frames lost in transit | Mark the span unattributed, reset pending, re-trigger |
pending: int = 0 # software commands sent, not yet seen
last_counter: int = -1 # frame-counter chunk of the previous frame
def on_frame(image, counter, line_high):
# counter and line_high come from the camera's chunk values,
# read with your SDK's chunk accessor
if counter != last_counter + 1:
log_unattributed_span(last_counter + 1, counter - 1)
pending = 0
if pending > 0:
classify(image, "software")
pending -= 1
elif line_high:
classify(image, "sensor")
else:
classify(image, "unexpected")
last_counter = counter
Between frames, also read the input's live state from the feature list. A line that goes high while you are armed for software means an edge arrived that produced no frame: a part coming in unannounced. That condition deserves an alarm, not a silent pass.
Worked example: pots at 250 mm/s with four software triggers per revolution
Take the station this article is written for: a rotating pot carrying a single barcode, started by a part-present sensor and read position by position with software triggers. The numbers below are typical values for such a line; scale them to your own.
Inputs: belt at 250 mm/s with pots pitched every 400 mm; pot diameter 90 mm spinning at 1 rev/s, one read attempt per 90° of rotation, so at most four software triggers per pot; camera at 30 fps with 100 µs exposure; 2,000 pixels across a 160 mm field of view, or 80 µm per pixel.
A pot reaches the sensor every 1.6 s, and the worst-case burst occupies 167 ms of that — about a tenth of the interval. Timing is not the constraint; attribution is. The blur check runs the other way: at 100 µs the rim blur is 28 µm against an 80 µm pixel, about 0.35 pixels, harmless. Let exposure drift to 1 ms and blur grows to 283 µm, or 3.5 pixels, and the barcode fails. Budgeting two pixels of blur puts the ceiling at 160 µm / 0.283 m/s ≈ 560 µs.
The decisions: keep exposure at or below 500 µs at these speeds, with 100 µs as the working setting; and treat a second pot's sensor edge inside the 167 ms burst — pending above zero while the line reads high — as the event that stops or diverts the line, because the barcode cannot say which pot it belongs to.
Set it up in six steps
- Open the camera's feature browser and note which chunk features it offers — input-line status, frame counter, timestamp — and their exact names on your model.
- Enable chunk mode, then enable each chunk individually. The mode switch alone leaves the values empty; the enable order is the whole fix, as covered in chunk data exposure time error.
- Configure the trigger block so the camera never free-runs by default; the per-camera settings are in hardware trigger configuration per camera. Wire the sensor with the polarity the input expects — see PNP or NPN wiring.
- Add the pending counter to your application: one integer, initialized to 0, incremented every time you send a software trigger command.
- In the frame callback, read the chunks, apply the table and write the verdict beside the saved image.
- Poll the input's live state between frames so an edge that lands during a software burst raises the collision alarm instead of vanishing.
Prove it on the bench before the site test
Four tests cover every branch of the table. Arm software and send three commands: expect three frames classified software and pending back at 0. Arm the line and trip the sensor by hand: one frame classified sensor. Arm software and trip the sensor: no frame, but the polled line reads high and the alarm fires. Pull the network cable mid-burst: the counter jump marks the span unattributed and resets pending. If all four behave, the logic is sound.
If a light or a reject gate hangs off the same event, sequence the chain with the same discipline — the camera, light and reject gate timing guide covers that side.
Common mistakes and what they look like
- A software command issued while the line is armed does nothing and raises nothing; the fix is reading the trigger source selector before each phase. When the value you read back disagrees with what you set, work through trigger mode and source readback mismatches.
- Chunk mode on but individual chunks off: every value reads as empty. Empty chunk data from a GigE camera walks the isolation step by step.
- Trusting arrival order instead of the frame counter: retransmission can reorder delivery, and only the counter says what the camera actually did.
- Exposure set for a static part: the rotation blur math above is where the barcode fails first. Timing math for a fast moving object shows the general case.
Where chunk data stops
No chunk support on the camera: command counting alone still works until the first dropped frame, which you will never see. The sturdier fallback is to move the trigger decision into a controller and hand it to the application as data, the pattern in synchronizing serial data with triggered capture; the capture-side wiring is in triggering a camera from a part sensor. Two hardware sources on one input stay unresolvable in metadata — that is a wiring fix. Which chunks a given model implements is a per-model fact, so make the feature list part of camera selection rather than a surprise at commissioning.
Parts for this station
A global-shutter camera on the interface your host speaks, a part-present sensor with settable distance, and the wiring between them: that is the whole hardware list. A 2.5 MP global-shutter GigE camera with a 1/1.7" sensor and a C-mount suits a barcode of this size:
- Sensor format
- 1/1.7"
- Lens mount
- C-mount
- Interface
- GigE
- Resolution
- Up to 3 MP
For finer codes the same arrangement steps up to 12 MP over USB3 in the MV-CH120-11UC, a 1.1" sensor, high-speed version, global shutter, C-mount:
- Sensor format
- 1.1"
- Lens mount
- C-mount
- Interface
- USB3
- Resolution
- 12 MP
The part-present trigger is a diffuse-reflective photoelectric sensor with settable distance; the MV-PE5502 is one such, 10-350 mm, red LED, NPN output:
- Output
- NPN
- Light source
- Red LED
- Sensing range
- 100 mm - 1 m
- Type
- Diffuse-reflective
Point the camera finder at your resolution and interface, the trigger sensor finder at the sensing distance, or walk the camera configurator and trigger configurator end to end. The photoelectric sensors category holds the full sensor range. For more on the camera side, the cameras topic page collects the guides, and the contact page reaches us when a specific camera's chunk list needs a second opinion.
Questions
Can a camera tell me which trigger produced a specific frame?
Only through per-frame metadata or your own bookkeeping. If the model implements a trigger-source chunk, the frame names its source directly. Otherwise enable the line-status and frame-counter chunks and apply the pending-command rule from this guide. A camera with no chunk data at all leaves command counting as the only method, and one dropped frame silently corrupts it.
Why does a software trigger command sometimes not fire the camera?
The standard trigger block arms one source at a time. With the input line armed, a software trigger command is ignored without any error, so no frame appears and the application never learns why. Read the trigger source selector before each capture phase, log every switch your application makes, and treat a command issued against the wrong armed source as the first thing to check when frames go missing.
What does a jump in the frame-counter chunk mean?
Frames were acquired but never reached your callback — dropped between camera and host, usually under buffer or network pressure. Every frame inside the gap is unattributable, because the counter cannot say what fired it. Reset the pending-command count, re-trigger the part, and treat the jump as an alarm in its own right: the same drops that break attribution also break process control.
Can I separate two sensors wired to one camera input?
Not with any metadata setting: both sensors make the same line go high, so every frame records one identical event. Give each source its own input and read both lines' status in each frame, or merge them upstream through a controller that tags which sensor fired. This is a wiring decision, and it is worth making before any classification code is written.
Does chunk data work over USB3 as well as GigE?
Yes. Chunk data belongs to the GenICam standard, which USB3 Vision cameras follow just as GigE Vision cameras do, so the same chunks and the same classification rule apply on either interface. What changes between models is the subset of chunks implemented and the exact feature names, both of which the camera's own feature browser lists.


