Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4511

Camera board • trying Global Shutter camera with external trigger Pi

$
0
0
Hi,
I'm using:
Raspberry pi 3 model B PLUS REV 1.3
Operating System: Raspbian GNU/Linux 11 (bullseye)
Kernel: Linux 6.1.21-v7+
Architecture: arm

I am trying to externally trigger the global shutter camera using a Raspberry Pi 3 which acts as both the source of the trigger pulse and operates the camera, and using a Python script (not the command terminal). I find the documentation not very clear (https://github.com/raspberrypi/document ... igger.adoc).

-I followed the instructions on removing the relevant resistor.
-I wired the GND and XTR soldering pads on the camera board.
-The source of the pulse at the moment is not a pi GPIO pin but a TTL (0-5V) signal from an mcc 152 HAT and check with an oscilloscope.
-I use a voltage inverter to flip high and low and a voltage divider to make sure that the signal to the camera board is 0 to 1.8V where the LOW should trigger the camera.
- I first tested that the camera works (without an external trigger) using the following code (this works fine):

Code:

from picamera2 import Picamera2, Previewimport timepicam2 = Picamera2()camera_config = picam2.create_preview_configuration()picam2.configure(camera_config)picam2.start_preview(Preview.QTGL)   # for GUI useres. If viewing via VNC, the QTGL can be used only if there is also a physical display connected to the pi, if not use QT insteadpicam2.start()time.sleep(30)picam2.capture_file("test.jpg")picam2.stop_preview()
- first question: should this work? after removing the resistor should this operation be at all possible?

- To try an external trigger, I first followed your instructions to enable external triggering:
pi@raspberrypi:~ $ sudo su
echo 1 > /sys/module/imx296/parameters/trigger_mode
exit
root@raspberrypi:/home/pi#

- Although when I run these 3 lines separately something else is happening:
pi@raspberrypi:~ $ sudo su
root@raspberrypi:/home/pi# echo 1 > /sys/module/imx296/parameters/trigger_mode
bash: /sys/module/imx296/parameters/trigger_mode: No such file or directory
root@raspberrypi:/home/pi# exit
exit
pi@raspberrypi:~ $

- Second question: this enabling of the external trigger is something that needs to be repeated every reboot?

- Nevertheless, I tried the following code to activate the camera and generate the pulse:

Code:

try:    from daqhats import mcc152, mcc118, HatError, HatIDs, DIOConfigItem, OptionFlagsexcept:    print("could not import mcc152")from picamera2 import Picamera2, Previewimport time# camera configurationpicam2 = Picamera2()camera_config = picam2.create_preview_configuration()picam2.configure(camera_config)picam2.start_preview(Preview.QTGL)   # for GUI useres. If viewing via VNC, the QTGL can be used only if there is also a physical display connected to the pi, if not use QT instead# board configurationboard = mcc152(0)# pulse confugurationcycles = 1000          # number of pulsesfrq = 30              # Hzperiod = 1 / frq      # pulse_width = 0.010   # On time in secoff_time = period - pulse_width# start pulset2 = 0if off_time <= 0:    print('frequncy must be below 100 HRaspberryz')    count = cycleselse:    count = 0ts = time.perf_counter()while count < cycles:    try:        board.dio_output_write_bit(4, 1)            # turn digital out to 1        t1 = time.perf_counter()        while t2 - t1 < pulse_width:            t2 = time.perf_counter()        board.dio_output_write_bit(4, 0)            # turn digital out to 0        t1 = time.perf_counter()        while t2 - t1 < off_time:            t2 = time.perf_counter()     except:        print('missed injection TTL ON/OFF')    count = count + 1dt = time.perf_counter() - tsacc_frq = count / dtpicam2.stop_preview()print('injection complete, actual frq ', acc_frq, ' Hz')
- This, naturally, didn’t work. There are no error messages and the preview window does not show an image.
- To try an external trigger in a way that is more similar to your instructions, while the TTL is generated in the background (f = 30 Hz, and width of 10 msec), I tried to operate the camera from the command terminal and got this:
pi@raspberrypi:~ $ rpicam-hello -t 0 --qt-preview --shutter 3000
bash: rpicam-hello: command not found

- in your example, you used a pico to generate the pulse and then you run the above command also on the pico to activate the camera. This is something I dont understand. what needs to happen on the pi that the camera is actually connected to?

hope you can help with this
thanks!

Statistics: Posted by nirb — Wed May 29, 2024 3:45 pm — Replies 1 — Views 50



Viewing all articles
Browse latest Browse all 4511

Trending Articles