Skip to content

External trigger tutorial

Hardware Connection


Please first check the pin definition of the specific camera before using this document. If the camera supports external triggering, the pin definition will be described at the beginning of the product wiki page.

Connection Diagram


Tip

This tutorial is based on Raspberry Pi. You can use any embedded device that supports signal transmission in practice. Please correctly connect the camera and trigger signal parts according to the hardware connection section.

The example camera is OG01A1B Camera Evaluation Kit

Windows GUI


Please download Arducam Camera Evaluation Kit GUI and access the camera kit with specific configuration file:

You can contact sales@arducam.com for the specific configuration file that supports external trigger function(please state the camera model info:.e.g OV01V1B Camera)


External Trigger Python Code


import RPi.GPIO as GPIO
import time
import argparse

GPIO.setwarnings(False)
GPIO.cleanup()
GPIO.setmode(GPIO.BCM)

GPIO.setup(18,GPIO.OUT)

def main(framerate, trigger_time):
    trigger_time = trigger_time / 1000
    sleep_time = 1/framerate
    sleep_time = round(sleep_time, 3) - trigger_time
    print("Start Trigger! Press CTRL+C to exit")
    try:
        while 1:
            GPIO.output(18, GPIO.HIGH)
            time.sleep(trigger_time)
            GPIO.output(18, GPIO.LOW)
            time.sleep(sleep_time)

    except KeyboardInterrupt:
        GPIO.cleanup()

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Trigger")
    parser.add_argument("-f", "--framerate", type=float, default=30, help="frame rate")
    parser.add_argument("-t", "--trigger-time", type=float, default=1, help="Trigger signal maintains high level time (ms)")
    args = parser.parse_args()

    main(args.framerate, args.trigger_time)

-f: frame rate of external trigger, in this example the trigger is 70 frames(Please set the frame rate according to the actual situation.)

python3 trigger.py -f 140

Demonstration


Due to the default exposure time is relatively long, if you want to get a higher frame rate, you need to reduce the exposure time. For example, if you need to trigger externally to 140 frames, you need to adjust the exposure time to about 600 us.

Note

If the frame rate does not reach the desired frame rate, you can try to reduce the exposure time.