Table of Contents

Trigger Cameras

The Behavior generates camera trigger pulses on DO0 and DO1, so video frames are captured — and timestamped — on the device clock. Trigger frequency is set per camera with the Camera0Frequency register, triggering is switched with StartCameras and StopCameras, and each emitted trigger broadcasts a Camera0Frame event. The examples below use camera 0 on DO0.

The complete workflow is shown below:

Trigger Cameras

Configure Trigger Frequency

Configure Trigger Frequency

  • Insert a KeyDown operator and set the Filter property to A.
  • Insert a CreateMessage operator and configure the following properties:
    • Payload - Select Camera0FrequencyPayload.
    • Camera0Frequency - Set the trigger frequency in Hz (e.g. 30). Valid values are 2 to 600.
  • Insert a MulticastSubject operator named Behavior Commands.

Run the workflow and press A to set the trigger frequency. Configure the frequency before starting the camera — the value is read when triggering starts.

Start and Stop Cameras

Start and Stop Cameras

  • Insert a KeyDown operator and set the Filter property to S.
  • Insert a CreateMessage operator and configure the following properties:
    • Payload - Select StartCamerasPayload.
    • StartCameras - Select CameraOutput0.
  • Insert a MulticastSubject operator named Behavior Commands.

In a separate branch:

  • Insert a KeyDown operator and set the Filter property to D.
  • Insert a CreateMessage operator and configure the following properties:
    • Payload - Select StopCamerasPayload.
    • StopCameras - Select CameraOutput0.
  • Insert a MulticastSubject operator named Behavior Commands.

Run the workflow, press S to start the trigger train on DO0 and D to stop it. The stop command lets the current trigger pulse finish cleanly — the device broadcasts a StopCameras event when the last pulse has actually been emitted, so no truncated frame reaches the camera. Triggering also stops automatically when the device leaves active mode.

Visualize Frame Events

Each trigger pulse broadcasts a Camera0Frame event, giving the device timestamp of every captured frame:

Visualize Frame Events

  • Insert a SubscribeSubject operator named Behavior Events.
  • Insert a FilterMessageType operator and configure the MessageType property to Event.
  • Insert a Parse operator and configure the Register property to Timestamped<Camera0Frame>.
  • Insert a VisualizerWindow operator. This will automatically open a window displaying the parsed events when the workflow starts.

Run the workflow and press S. The visualizer displays:

FrameAcquired@10.351072

The first value confirms the frame trigger and the second is the timestamp on the device clock. Match these timestamps against the frames saved by your video capture software to align video with the rest of the data.

Warning

DO0 and DO1 share their hardware timers with the PWM generator. Don't run PWM and a camera trigger on the same output at the same time.



Last updated with:
Hardware v2.1
Firmware v3.3
Bonsai Package v0.2