Skip to content

External Trigger Mode

Introduction


Global Shutter Camera Bundle Kits are used to capture the image and helps in synchronized streaming by connecting two or multiple cameras. In production applications (such as assembly line production), the external trigger mode can easily synchronize the camera with other devices.

Supported Cameras


Product Image SKU Sensor Resolution Pin/Connect Type Features Lens Type Field of View(HxV) Focus Type IR Sensitivity
Image B0492R AR0234 2MP 22/Bottom Color Global Shutter M12 120°(D)×90°(H)×75°(V) Manual Focus Integrate IR-cut filter
B0331 OV9782 1MP 15/Bottom Color Global Shutter Quad Camera M12 75°(H) x 46.8°(V) Manual Focus without IR-cut filter
Image B0266 OV9281 1MP 15/Bottom Mono Global Shutter Stereo Camera M12 70°(H) x 43.75°(V) Manual Focus without IR-cut filter
B0267 75°(H) x 46.8°(V)

Hardware


Abstract

The external trigger pins used by different cameras may not be the same. For the boards populated with UC-788, they use the XVS pin as the external trigger pin, while other cameras use pins such as F. For specific pin information, you can refer to the camera datasheet.

First, solder headers onto the XVS/F and GND pins, then use DuPont wires and a breadboard to connect all two/four cameras' XVS and GND pins together to the Raspberry Pi GPIO pins.

  • XVS Pin

You can refer to the following diagram for the pinout of the XVS pin. 4

Software


Step 1: Connect the External Trigger Pin

Connect the GPIO 17 on the Raspberry Pi to the cameras' XVS and GND pins using DuPont wires.

Raspberry Pi Camera
GPIO 17 XVS
GND GND

Step 2: Configure Timeout Value

The rpicam-apps may time out if all cameras fail to start within one second. To prevent this, you need to modify the configuration file to extend the timeout period. First, create a copy of the default configuration file. The command varies depending on your Raspberry Pi model.

  • On Raspberry Pi 5 or CM5:
cd /usr/share/libcamera/pipeline/rpi/pisp
sudo cp example.yaml timeout.yaml
  • On other Raspberry Pi models:
cd /usr/share/libcamera/pipeline/rpi/vc4
sudo cp rpi_apps.yaml timeout.yaml

Next, edit the new timeout.yaml file. Locate the line "camera_timeout_value_ms":, remove the leading # to uncomment it, and change the value to 100000 (100 seconds).

sudo nano timeout.yaml

external_1.png

Step 3: Start the Camera

Execute the following commands to start the camera stream.

  • On Raspberry Pi 5 or CM5:
export LIBCAMERA_RPI_CONFIG_FILE=/usr/share/libcamera/pipeline/rpi/pisp/timeout.yaml
libcamera-still -t 0 --shutter 1000
  • On other Raspberry Pi models:
export LIBCAMERA_RPI_CONFIG_FILE=timeout.yaml
libcamera-still -t 0 --shutter 1000

Note

The export command only applies to the current terminal session.

Step 4: Enable External Trigger Mode

Open a new terminal window and execute the following command to enable external trigger mode. After running this command, the camera will enter external trigger mode, and the preview window will freeze, waiting for an external trigger signal.

v4l2-ctl -d /dev/v4l-subdev0 -c trigger_mode=1

Note

On Raspberry Pi 5 or CM5, it should be /dev/v4l-subdev2, while on other Raspberry Pi models, it should be /dev/v4l-subdev0.

Step 5: Download and Run the Trigger Script

Download the required Python script and run it using the following commands. After running the script, you can find that the frame rate of the camera will change according to the external trigger signal. The frame rate will be determined by the frequency of the external trigger signal.

wget -O trigger_multi_cam.zip https://cdn.arducam.com/downloads/trigger_multi_cam.zip
unzip trigger_multi_cam.zip
python3 trigger_multi_cam.py

Step 6: Disable External Trigger Mode

Disable the external trigger mode to return the camera to its default state.

v4l2-ctl -d /dev/v4l-subdev0 -c trigger_mode=0

Troubleshooting