System designExplainer

Set the camera timestamp over USB3 Vision, not UART lines

A USB3 Vision camera timestamp is set over USB with GenICam, never over the I/O UART lines, which only pass bytes. Worked host-time mapping.

LumaSpec Vision10 min read Share on LinkedIn

On this page 10 sections
  1. 01What the UART lines actually carry
  2. 02Where the camera timestamp comes from
  3. 03Setting and anchoring the clock over USB
  4. 04Worked example: ticks to wall time
  5. 05Drift sets your re-latch interval
  6. 06Four routes to real time, compared
  7. 07What the UART is for, then
  8. 08Checks before you build the anchor
  9. 09The decision, case by case
  10. 10Questions

You have a USB3 Vision camera, you found the UART option in the I/O chapter of its manual, and the obvious idea follows: feed time-of-day in over those two serial pins and every image comes out stamped with real time. It does not work that way. The UART lines on a USB3 Vision camera are a transparent serial pipe between your host software and an external device; the camera forwards bytes and understands none of them. The camera clock is an internal free-running counter, and the only route to it is the GenICam feature set over the USB3 Vision control channel. What follows is what the UART lines carry, where the timestamp comes from, and the arithmetic that anchors it to your host clock with an accuracy you can budget.

What the UART lines actually carry

The I/O connector of a USB3 Vision camera mixes opto-isolated inputs, GPIO lines and two UART pins. The UART function exists so the camera's cable harness also reaches a serial peripheral sitting next to the camera: a lighting or lens controller, a stage, a small PLC. Your software writes bytes to a serial path the camera exposes over USB; the camera pushes those bytes out of the UART pins unchanged and returns whatever the peripheral sends back. The camera is a wire with two connectors. It never parses the stream, and no camera feature is reachable through it - device control lives on the USB3 Vision protocol by design, on every conforming camera.

So the answer to "can I set the time over the I/O UART" is no, structurally. A time string sent down those pins reaches the peripheral wired to them; the camera's timestamp counter keeps counting as if nothing happened, because for the camera nothing did.

Where the camera timestamp comes from

Every frame the sensor delivers, the camera latches the current value of a free-running hardware counter and attaches it to the image as chunk data. Enable the timestamp chunk and each buffer arrives carrying that value, taken at exposure end on cameras that follow that convention - the chunk data timestamp at exposure end and how to latch it covers the details. Frame-to-frame intervals are hardware-latched, so they are good to well under a microsecond. What the counter cannot tell you on its own is where it sits in your lab's time; that anchor is yours to build.

Two device properties decide the arithmetic:

  • The tick frequency. Current machine-vision cameras commonly run the counter at 1 GHz - one tick per nanosecond - but the value is a device property. Read the tick frequency from the camera's feature list at start-up and convert with what you read.
  • The counter width. A 64-bit counter at 1 GHz wraps after 2^64 / 1e9 ≈ 1.84 × 10^10 s, about 585 years. Narrower latched values wrap sooner; camera timestamp clock rollover and monotonic time mapping shows how to live with the wrap.

Under auto exposure the exposure value rides the same metadata route, and reading exposure time from frame metadata under auto exposure shows how to pull feature values back per frame.

Setting and anchoring the clock over USB

Across USB3 Vision cameras, the GenICam feature list exposes timestamp control as a small set of commands: a latch that freezes the current counter into a readable value, a reset that zeroes it, and on some models a write that loads a value you supply. Writing your host's time-of-day straight into the counter is tempting, but the write lands somewhere inside the USB round trip, so the value is already old when it takes effect. The latch is the better anchor on every camera, because it freezes the counter at a moment the camera itself defines and lets you measure the rest.

Writing a feature through a GenICam API is the same call you already use for exposure - setting camera exposure time through a GenICam API in Python shows the pattern - only the feature differs. The anchor routine is three steps:

  1. Read the host clock, send the latch command, read the latched value back, read the host clock again, and pair the latched ticks with the midpoint of the two host samples. The midpoint centres the round-trip error.
  2. Convert the latched ticks to seconds and subtract from that midpoint to get the offset.
  3. Convert every frame's chunk timestamp the same way and add the offset.
t_latched = ticks_latched / f_tick offset = t_host_mid - t_latched t_frame_host = ticks_frame / f_tick + offset

Worked example: ticks to wall time

Assume the camera reports f_tick = 1,000,000,000 ticks per second, read from the feature list at start-up.

  1. The latch returns ticks_latched = 4,200,000,000,000 ticks, with host clock samples straddling it at a midpoint of t_host_mid = 452.123456 s.
  2. t_latched = 4,200,000,000,000 / 1e9 = 4200.000000 s.
  3. offset = 452.123456 - 4200.000000 = -3747.876544 s.
  4. A frame arrives with a chunk timestamp of 4,213,762,455,100 ticks = 4213.7624551 s.
  5. t_frame_host = 4213.7624551 - 3747.876544 = 465.8859111 s, so about 465.886 s on the host's monotonic clock.
  6. If that host's monotonic zero was 12:00:00.000, exposure ended at 12:07:45.886 - 465.886 s is 7 min 45.886 s.

Drift sets your re-latch interval

The counter runs on the camera's oscillator, typically within ±50 ppm of nominal. At that tolerance the offset error grows 50 microseconds every second:

error = drift_ppm * 1e-6 * delta_t

After 60 s that is 60 × 50e-6 = 3 ms; after 600 s it is 30 ms. To hold 1 ms, re-latch every 0.001 / 50e-6 = 20 s.

If you need absolute time tighter than about a millisecond, stop pushing the USB path: route one electrical trigger to both the camera and a host input that timestamps it, and anchor camera and host to that shared event. Sub-microsecond alignment across several cameras is the territory of GigE Vision with IEEE 1588, not USB3.

Four routes to real time, compared

Route What it touches Use it when Verdict
I/O UART lines Serial bytes host to peripheral A serial device sits at the camera Never touches the clock
GenICam latch over USB3 Vision Counter to host clock anchor One camera, event logging, millisecond accuracy The default; ~1 ms absolute, sub-µs between frames
Counter write over USB3 Vision Loads the counter directly Downstream gear reads camera time Works where exposed; keep anchoring with latch pairs
IEEE 1588 PTP on GigE Vision Hardware clock sync across cameras Sub-µs multi-camera alignment Switch interface, not cables

What the UART is for, then

Point the UART at the peripheral it was designed for. A lighting controller bolted beside the camera can take its level commands from the host through the camera's own power and I/O cables, with replies riding back the same way, and you save a separate serial run out to the line. Aligning that serial traffic with images is a host-side job - the camera forwards the bytes but never timestamps them - and synchronize serial data with triggered image capture works the pattern at 60 fps.

Meanwhile every latch command and every chunk value rides the USB3 data cable together with the image stream, so that cable is part of the timing chain:

Cables3 m USB3.0 camera cable, high-flex (drag chain) (LS-CBL-0219)LS-CBL-0219$62.00View partBuild a system with it

The same control architecture holds across the area scan cameras category - filter by interface in the camera finder, for example:

Area scan cameras12 MP USB3 area scan camera, IMX226, 1/1.7" rolling shutter, 30 fps, 4000 × 3000 resolution (LS-CMR-0166)LS-CMR-0166
Sensor format
1/1.7"
Interface
USB3
$560.00View part
Area scan camerasHikrobot MV-CS200-10UM 20 MP Area Scan Camera, USB3.0, IMX183, 2nd Gen., MonoMV-CS200-10UM
Sensor format
1"
Lens mount
C-mount
$759.00View part

Checks before you build the anchor

The decision, case by case

  • One camera, wall-clock time per image: enable the chunk timestamp, anchor with latch pairs over USB, re-latch every 20 s. Expect about 1 ms absolute and sub-microsecond between frames.
  • A serial peripheral at the camera: use the UART lines for exactly that, and align the data in software on the host clock.
  • Several cameras aligned tighter than 1 ms: USB3 Vision has no shared hardware clock. Choose GigE Vision cameras with IEEE 1588, or share one electrical trigger timed once.
  • Downstream equipment that reads camera time directly: write the counter once at start-up where the camera allows it, then keep the write honest with periodic latch pairs.

If you are specifying the station, start at the camera step of the system configurator. If the sync budget is already fixed, send the accuracy your line needs through the contact page and the interface, camera and cabling can be matched to it in one pass.

Questions

Can the I/O UART lines control any camera feature, not just the clock?

No. On a USB3 Vision camera the UART function is a byte pipe between host software and an external device wired to the I/O connector; the camera forwards the stream without interpreting it. Every controllable feature - exposure, gain, trigger mode, the timestamp counter - is reached through the GenICam feature list over the USB3 Vision control channel. The same holds for the GPIO lines: inputs trigger, outputs switch, neither accepts a command.

Is one timestamp tick always one nanosecond?

No - the tick frequency is a device property. Many current machine-vision cameras run the counter at 1 GHz, which makes one tick 1 ns, but devices differ. Read the timestamp tick frequency from the camera's feature list at start-up and use that value in every conversion: hard-coding 1 GHz silently scales every converted time by the ratio between the two frequencies.

How accurate is image time once I map ticks to the host clock?

Frame-to-frame intervals are hardware-latched and good to well under a microsecond. Absolute host time is limited by the USB round trip between commanding the latch and reading your host clock - budget about 1 ms, and average five anchor pairs to pull the offset noise down. Oscillator drift then adds roughly 50 microseconds per second at ±50 ppm, so re-latch every 20 s to hold 1 ms.

What should the UART pins be wired to, then?

Serial peripherals that live at the camera: a lighting or lens controller, a stage, a small PLC. Keep the link logic-level and add a level shifter for any true RS-232 device, because RS-232 swings between negative and positive supply rails and can damage the I/O stage. The camera forwards the bytes but never timestamps them - alignment with images happens on the host clock.

Does the counter reset at power-up, and does it matter?

Most cameras zero the counter at power-up, so an offset captured in a previous session is meaningless. Capture a fresh anchor pair every time the device enumerates, then re-latch on a timer. For long-running applications check the counter width as well: a 64-bit counter at 1 GHz runs about 585 years, but narrower latched values wrap much sooner.