-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synchronous and external trigger documentation.
Added files to documentation about how to externally trigger IMX296 and information about synchronising cameras for IMX477 & IMX296
- Loading branch information
Ben Benson
committed
Aug 13, 2023
1 parent
4e0a787
commit 323191e
Showing
4 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
documentation/asciidoc/computers/camera/external_trigger.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
== External Trigger on the Global Shutter Camera | ||
The global shutter camera can be triggered externally by pulsing the XTR pin on the board. | ||
Multiple cameras can be connected to the same pulse leading to a better way to synchronise two cameras. | ||
|
||
The low puslewidth plus an extra 14.26us is equal to the exposure time. i.e. a low pulse of 10000us leads to an exposure time of 10014.26us. | ||
Framerate is directly controlled by how often you pulse the pin. A PWM frequency of 30Hz will lead to a framerate of 30 frames per second. | ||
|
||
image::images/external_trigger.jpg[Image showing pulse format] | ||
|
||
=== Preparation | ||
|
||
First, remove/desolder resistor 22 on the GS Camera board. This connects GP0 to XTR and without removal, the camera will not operate | ||
in external trigger mode. | ||
|
||
Next solder a wire to the touchpoint of XTR on the GS Camera board. | ||
Connect these to the pico - XTR to any pin. Pin 28 is used in this example. Ground is not needed to be connected. | ||
==== Boot up the Raspberry Pi with the camera connected. | ||
|
||
Enable external triggering through superuser mode: | ||
[,bash] | ||
---- | ||
sudo su | ||
echo 1 > /sys/module/imx296/parameters/trigger_mode | ||
exit | ||
---- | ||
|
||
==== Raspberry Pi Pico Code | ||
[,python] | ||
---- | ||
from machine import Pin, PWM | ||
from time import sleep | ||
pwm = PWM(Pin(28)) | ||
framerate = 30 | ||
shutter = 6000 # In microseconds | ||
frame_length = 1000000 / framerate | ||
pwm.freq(framerate) | ||
pwm.duty_u16(int((1 - (shutter - 14) / frame_length) * 65535)) | ||
---- | ||
The low pulsewidth is equal to the shutter time, and the frequency of the PWM equals the framerate. | ||
|
||
=== Operation | ||
|
||
Run the code on the pico, and run the code for the camera: | ||
[,bash] | ||
---- | ||
libcamera-hello -t 0 --qt-preview --shutter 3000 | ||
---- | ||
|
||
=== Note | ||
When running libcamera apps, you will need to specify a fixed shutter duration. | ||
This will ensure the AGC does not try adjusting camera's shutter speed, which is controlled by the external trigger pulse. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions
83
documentation/asciidoc/computers/camera/synchronous_cameras.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
== Synchronous Captures | ||
=== IMX477 | ||
==== Preparation | ||
|
||
Connect a potential divider of 2x 1.5KOhm Resistors to 3v3 and ground, creating 1.65V. This can be connected to either Pi. | ||
|
||
Solder the GND and XVS touchpoints of each HQ Camera board to each other. | ||
|
||
Connect the XVS wires to the 1.65V potential divider pull up. | ||
|
||
==== Boot up both Raspberry Pis | ||
|
||
The file `/sys/module/imx477/parameters/trigger_mode` determines which board outputs pulses, or waits to recieve pulses (source and sink). | ||
This parameter can only be altered in superuser mode. | ||
|
||
On the sink, run: | ||
[,bash] | ||
---- | ||
sudo su | ||
echo 2 > /sys/module/imx477/parameters/trigger_mode | ||
exit | ||
---- | ||
|
||
On the source, run: | ||
[,bash] | ||
---- | ||
sudo su | ||
echo 1 > /sys/module/imx477/parameters/trigger_mode | ||
exit | ||
---- | ||
|
||
Start the sink running: | ||
[,bash] | ||
---- | ||
libcamera-vid --frames 300 --qt-preview -o sync.h264 | ||
---- | ||
|
||
Start the source running | ||
[,bash] | ||
---- | ||
libcamera-vid --frames 300 --qt-preview -o sync.h264 | ||
---- | ||
|
||
Frames should be synchronous. Use --frames to ensure the same amount of frames are captured, and that the recordings are exactly the same length. | ||
Running the sink first ensures that no frames are missed. | ||
|
||
==== Notes | ||
|
||
The potential divider is needed to pull up the XVS pin to high whilst the source is in an idle state. | ||
This ensures that no frames are created or lost upon startup. The source whilst initialising goes from LOW to HIGH which can trigger a false frame. | ||
|
||
=== IMX296 | ||
==== Preparation | ||
|
||
Create a potential divider made of 2x 1.5KOhm Resistors to 3v3 and ground, creating 1.65V. This can be connected to either pi. | ||
|
||
Solder 2 wires to the XVS touchpoint on each board and connect both of these wires together to the 1.65V potential divider. | ||
|
||
Solder the GND of each Camera board to each other. Also solder 2 wires to the XHS touchpoints on each board and connect these. No pullup is needed for XHS pin. | ||
|
||
On the boards that you wish to act as sinks, solder the two halves of the MAS pad together. This enters the sensor into sink mode. | ||
|
||
==== Boot up both Raspberry Pis | ||
|
||
Start the sink running: | ||
[,bash] | ||
---- | ||
libcamera-vid --frames 300 -o sync.h264 | ||
---- | ||
Allow a delay before you start the source running (see note below). Needs to be roughly > 2 seconds. | ||
|
||
Start the source running: | ||
[,bash] | ||
---- | ||
libcamera-vid --frames 299 -o sync.h264 | ||
---- | ||
==== Note | ||
Due to limitations of the IMX296 sensor, we are unable to get the sink to record exactly the same amount of frames as the source. | ||
**The source will record one extra frame before the sink starts recording.** This will need to be accounted for later in the application. | ||
Because of this, you need to specify that the sink records one less frame in the '--frames' option. | ||
|
||
A potential workaround for this is to use the external trigger modes for the IMX296, as described xref:camera_software.adoc#external-trigger-on-the-global-shutter-camera[here].This ensures that both cameras | ||
act in an identical manner. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters