-
Notifications
You must be signed in to change notification settings - Fork 4
Making A Trigger Generator
A good external trigger generator for image collection would have several important properties.
- Stable. Same pulse rate day in, day out.
- Low power.
- Programmable. If you want to change from 2 fps to something else...
- Cheap.
- Small.
A crystal-controlled microprocessor can have all of these. For example, an Arduino Nano. While the official Nano is rather expensive, Chinese versions of the device can be found online (Amazon) for less than $5 each. They may require a bit of soldering to install the pins so the device can be socketed, but you can always solder to the holes if you want to hardwire the connections.
The code to create a simple, fixed 2fps pulse generator is very simple. The 1/2 second interval is provided by the two instances of the constant "500000" -- 500,000 microseconds. It is left to the reader as an exercise to determine how you would create a four fps trigger source.
unsigned long now;
void setup() {
// put your setup code here, to run once:
pinMode( 4, OUTPUT );
pinMode( 5, OUTPUT );
pinMode( 6, OUTPUT );
pinMode( 13, OUTPUT );
digitalWrite( 4, HIGH );
digitalWrite( 5, HIGH );
digitalWrite( 6, HIGH );
digitalWrite( 13, LOW );
now = micros();
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite( 4, HIGH );
digitalWrite( 5, HIGH );
digitalWrite( 6, HIGH );
digitalWrite( 13, LOW );
while( (micros() - now) < 500000 ) { };
now += 500000;
digitalWrite( 13, HIGH );
digitalWrite( 4, LOW );
digitalWrite( 5, LOW );
digitalWrite( 6, LOW );
}
The "setup" function configures the I/O pins to be output for D4, D5, and D6 and sets all three to "high". The "loop" function repeatedly sets the same pins high, waits for 500,000 microseconds, turns the output pins low. It immediately returns to the top of the loop and sets the outputs back to high. This creates a short (20ms or so) low pulse on the output pins. Pin 13 is the red LED on the Nano, which is pulsed "on" when the low trigger pulse is output.
Three outputs are pulsed so that you can distribute the load across multiple outputs. I.e., camera 1 goes to D4, camera 2 to D5, etc. This circuit will drive more than two cameras per pin.
The Chinese version of the Nano is certainly the cheaper one, and the difference is, in large part, the use of a different USB to serial interface circuit. The Chinese Nano has a CH340, which is not found automatically by Windows Update (at least not for my version of Windows.) You can download the driver from here.
The wiring to the Nano is very simple. Here's a diagram.
CIRN
Wiki Home
CIRN Website
CIRN Research and Workshops
CIRN Monthly Webinars Existing Monitoring Stations
Sampling Goals
Pixel Resolution
Fixed Mounting Platforms
Temporary Towers
FOV and Lenses
Installation Design
Cookbook
Data Processing
Understanding Image Geometries
Photogrammetry
Intrinsic Calibration
GCPs
Extrinsic Calibration
File Naming
Directory Naming
Time Conventions
Common Variable Names
Parallel Processing Issues
Etc
GitHub Help
GitHub Cheat Sheet
CIRN repository help
GitHub Best Practices and GuidelinesGitHub Repository Structure
GitHub Workflow Overview
Using Teams & Roles
Issues
Testing & Review
Code Requirements
General Guidance
Admin
Software Development Life Cycle