Introduction: High-speed Photography With Arduino and CHDK
This project uses an Arduino microcontroller and a laser break-beam trigger to fire via USB remote a Canon camera modified with CHDK (Canon Hack Development Kit) firmware.
Immediate influences are the high-speed flash photography triggered by sound or light project by Glacial Wanderer and the Laser Triggered High-Speed Photography instructable by Saskview. The first uses a laser break-beam and an Arduino to trigger a flash in a dark room and capture action while the second uses two 555 timer ICs to generate a signal to trigger the camera. The second method does not require a dark room.
The approach described here requires a Canon camera modified with CHDK, uses the Arduino to do the electronic heavy lifting, and does not require a dark room. My intention was to keep things relatively easy -- no etching circuit boards, no cramming stuff in to small spaces &c. That said, there is some careful soldering and fabrication required but nothing beyond that.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Blah Blah Blah
This step is here because the first step seems to appear below the Introduction. I don't understand why and I don't think it is a good idea.
Step 2: Parts
Parts can be obtained from any of a number of electronic suppliers. Because of the reliance on the Arduino, external parts are kept to a minimum. If you are lucky, you already have the parts lying around and the project is essentially free.
Arduino Diecimila or comparable board. The actual board does not matter as long as you understand what the various pins do and can adjust input, output, analog, and digital pins accordingly.
In the interest of keeping this relatively simple, I built this on a Proto Shield for Arduino from Adafruit Industries outfitted with a tiny breadboard. Again, this is optional but makes things easier.
The electronic components need depend on one another -- the resistors for the LEDs depend on the LEDs, the potentiometer depends on itself, the resistors for the voltage dividers depend on the LSR and the laser. Because of this, exact values are not given below.
Potentiometer - linear taper is best
Similarly, the particulars of the following components are not critical. Use what you have on hand or order ones you like.
Battery holder (1)
Push-button momentarily on switch (1)
Phone jack stereo 3.5mm (1)
Plug 3.5mm (1)
USB cable (1)
LED holders (3)
Pin headers (many)
Heat shrink tubing
Loc-Line from ModularHose. This stuff is really fun and pretty expensive. Buy the pliers. Also, buy a lot because you will want to make other stuff using it. See the DeskSquid and GorillaPod instructables.
Step 3: CHDK
The Canon Hack Development Kit (CHDK) modifies (improves?) the firmware for many Canon cameras and adds quite incredible capabilities to relatively modest cameras. The best part is that the changes are NOT permanent, do not damage the camera, and you can use your camera as always even with the firmware upgrade in place. It probably voids the warranty.
This instructable is NOT about the CHDK and really only uses it to enable the USB triggering of the camera. It enabled my Canon a480 (simple, cheap, point and shoot) to use a USB remote trigger, among other things. See the CHDK Wiki for information about installing and using the features of CHDK on your Canon camera.
Step 4: CHDK Primer
Installing Determine whether the CHDK has been ported for your camera. Download the CHDK for your camera and install it on your memory card. It's that easy.
Loading Start your camera in Review mode (press on the little play button; lens should not be open). Press Menu and scroll to the bottom and update the firmware.
Using Press the Program button to get into ALT mode. This is the mode in which you access the CHDK features. Once in ALT mode (which you will recognize by the text at the bottom of your screen), press the Menu button to access the CHDK features.
Note I found it difficult to understand how to install the CHDK and access it features from material on the Internet. Because the port is different for each camera and the buttons and button layout is different for each camera, names and actions are not consistent. After working with the CHDK on my camera, things came to make sense. Be patient with this part of the project.
Step 5: Enclosure
Determine the enclosure you are going to use BEFORE you start soldering wires to parts. Locate and drill all of the holes so you can determine the shortest reasonable length for each set of wires. Also, because of the orientation of the Arduino and the location of the power jack, the position of the Arduino in the enclosure may also be determined. Take this in to account when calculating component positions and wire length.
The tin needs several sets of holes of varying diameters. I use a metal punch to mark the hole locations and brad point bits (for wood) to drill the holes. The brad point bits have a center point and two cutting edges. They won't skate and the edges cut slowly and cleanly through the metal. Brad point bits are available from Lee Valley (among other places).
Holes in the top
The three LED's, the push button switch, and the potentiometer all are attached to the top and need appropriately sized and spaced holes.
Holes in the right side
The Loc-Line arm holding the laser runs out the right side and needs a 1/2 inch hole and the USB trigger for the camera runs out the right side. It needs a 1/4 inch hole.
Even though the potentiometer allows one to change the timing interval, I found it more convenient to power the Arduino via USB from a laptop. This allowed me to upload a new timing range as I was taking pictures. This necessitated yet another 1/2 inch hole on the left side of the tin. To accommodate the USB plug I had to file it slightly wider.
Holes in the left side
Only one hole is needed in the left side. The Loc-Line arm holding the LSR runs out the left side and needs a 1/2 inch hole.
Step 6: Schematic
The image and attached file are the schematic for this project. Thank you to LinemenOwn for suggesting that they be included. I believe that this schematic is correct, but as the project was not ever turned into a board, I have not fully checked it out. Please let me know if there are any connections in error.
Step 7: Arduino Board
Begin preparing the Arduino board by laying out wires from pins to the breadboard. I used red, yellow, and green wires for the LEDs, blue for signals, red for power and black for ground. Note that there are two connections to ground and two connections to power. For a clearer view of the connections, see the schematic.
At the same time that you layout the wires, put in the resistors for the LEDs, the pull-up resistor for the switch, the single resistor for the LSR and the two resistors for the voltage divider for the laser.
In the second and third picture, I put pin headers to mark the locations of the various components. Note that the laser pin header is NOT correct in the third picture.
Note Because of the orientation of the Arduino board in the enclosure and the location of the LEDs, I used three analog input pins for the LEDs. They are configured in code to be digital pins.
Step 8: Ground Bus
To minimize space and wires on the breadboard, I fabricated a connection to ground for each side of the breadboard. After laying out the various parts on the breadboard, identify each ground connection. Take a pin header and remove all but the requisite pins. Create small looped wires that connect the remaining pins and solder.
The small loops in the wires were made using a jewelry making tool that forms wire coils.
Step 9: LEDs, Switch, Potentiometer
After determining the position of the holes in the enclosure and the location of the Arduino, figure out reasonable lengths for wires for the various components. To keep this project as simple as possible and have everything on the breadboard, I just soldered pin headers to the ends of each set of wires. These connections were reinforced with heat shrink tubing.
Note The location of these parts on the breadboard was determined in an earlier step. This step just shows the fabrication of the various parts.
Each LED requires a resistor. Determine the appropriate resistance using an LED Resistor calculator. These are readily available on the Internet.
The switch requires a 10K pull-up resistor. One of the options on the CHDK USB Remote Trigger is to fire on the falling edge. This is, apparently, faster, easier and more reliable. For this reason, use a pull-up resistor and drop the voltage when the button is pushed.
Step 10: USB Cable
The USB cable connects the Arduino to the camera. Start with a standard USB cable with USB Mini-B plug at one end (your camera probably came with one). Determine how you want to attach the cable to the Arduino and modify the OTHER (not the Mini-B) end accordingly.
I had both a stereo plug and jack and decided to attach the plug to the cable and the jack to the Arduino. This makes it easy to plug in and prevents me from accidentally reversing the contacts. See warning below. A multimeter is essential to verify that you have the correct connections and nothing is shorted.
This was a difficult solder but the result was worth it.
WARNING The wires are really small and it is absolutely important that you get ground to ground and power to power. The connection to the Arduino should be such that you (or someone else) cannot accidentally reverse the plug. Current the wrong way through your camera...
Step 11: Light Sensitive Resistor
This is a straightforward solder. Solder pins to one end of the wires and the LSR to the other. Heat shrink tubing prevents shorting.
The LSR is one of two resistors in a voltage divider. The laser beam shines on the LSR and keeps the resistance LOW and consequently the voltage to the analog input pin HIGH. When the laser beam is broken, the resistance on the LSR goes HIGH, which causes the voltage to the analog input pin to go LOW. When the pin goes low enough (below a certain threshold), the Arduino responds and triggers the camera.
Step 12: Laser
This is a straightforward solder. Solder pins to one end of the wires of the laser. Heat shrink tubing prevents shorting.
The Arduino outputs +5V on its output pins. The laser I used (check the voltage requirement of your laser) requires only +3V. The laser receives output from a voltage divider circuit that drops the +5V to about +3V. I used a 47 ohm resistor and a 100 ohm resistor to give 100 / (47 + 100) * 5 = +3.4V which seems to be within the range for my laser.
This is NOT the laser I ended up using. The photograph is from an intermediate stage in the construction when I mocked-up the parts to test out the system. The actual laser is embedded in the Loc-Line at the end of the right arm.
Step 13: Battery Pack
I used a switched 9V battery to power the Arduino. This makes the whole contraption portable. It is, however, easier to update code (particularly the threshold levels) if it is powered from the computers USB. The decision to use a battery represents a trade-off.
Note The project pictured here does not actually use a battery pack. I decided to run the Arduino via USB power from a laptop. If I were to use a battery pack, I would do what I described here.
This is a straightforward solder. Solder the battery plug to the wires coming out of the switched battery holder. Be care to respect polarity.
Remember to switch the jumper from USB to EXT when running the Arduino on battery power. (I think this may not be necessary for newer boards, but I am not completely sure). Also remember to switch back when running the Arduino off the computer.
Step 14: Potentiometer
Check whether your potentiometer is a linear taper potentiometer or an audio taper potentiometer. Since the potentiometer is used to set the time between the laser beam breaking and the camera triggering, the linear taper potentiometer is better. It means that the dial turned half-way will set the delay time to half of the difference between the maximum and minimum time values. (With the audio taper potentiometer, the dial turned half-way is intended to make the volume sound half as loud as the dial turned up all of the way and this skews the numbers in a logarithmic/exponential fashion.)
With the potentiometer in place, run the Arduino code and read the output in the Serial window. Check the following dial positions -- all the way to the left, approximate one-quarter, approximate middle, approximate three-quarters, and all the way to the right. A linear taper potentiometer should give readings of about 0, 255, 512, 767, and 1023 (or these numbers in reverse order). My audio taper potentiometer gave readings of 1023, 990, 870, 674, and 0.
Correcting for this in code I graphed my output and it appeared logarithmic. I did a logarithmic regression to find a best-fit natural log approximation to my data points and used that to modify the potentiometer reading before plugging it into the map() function to determine the actual delay. Because the range of delay values is relatively small, this worked quite well.
Step 15: Armed and Ready
Building the arms is as easy as clicking together the right parts, running wires through the Loc-Line hose and attaching the arms to the enclosure. The hardest part was finding appropriate nuts to use.
Because the thread on the Loc-Line hose is NPT (National Pipe Thread Tapered Thread) there are NOT nuts for it! At least not that I could find and I spent a lot of time looking. I ended up getting two brass connector fittings from a plumbing department, cutting off the end I did not want and grinding the remaining washer-like piece clean. If I were to do this again, I would look for a 1/4 inch thick piece of plastic and cut and tap my own washers.
Step 16: Assembled
Everything in place and ready to go. Arms attached and threaded with the LSR and laser. Plug and play!
Step 17: Arduino Code
Attached is the code for this project. It works for me on my computer. Famous last words :-)
Testing There are several routines in place (commented out or at least not called in the working version) that test the various systems. You should install the code and test the systems as you go along. This will prevent headaches once everything is in place.
Step 18: Photographs
This system works as follows. Fire up the Arduino and load the script. Experiment with the timing for your setup and set the minimum and maximum delay times in the script. If the range is smal enough, the potentiometer adjustments will be quite sensitive. Align the laser and the LSR. Press the red button to prefocus and arm the camera. Break the beam and take a picture! Repeat as often as necessary to get a good picture.
I found the interaction between the CHDK and Arduino and the camera's operating system to be very flaky. Leave the camera out and everything works really well. I don't know what the camera is doing when and it seemed like the whole system could get out of sync with itself. Unplugging the Arduino and starting it up helped. Just trying the same thing again helped. Waiting for the camera to time-out and take a picture helped. Fortunately, there is little to no cost associated with bad pictures, so patience helped the most.
Step 19: Future Plans
To meet the deadline for the Epilog Contest, I did not have time to fully experiment with this apparatus. It certainly works but needs to have kinks worked out.
Because of the open nature of this project, any number of sensors or configurations can be used to trigger the camera. The first that come to mind are a sound trigger (which should be easy to attach to and through the Arduino) and long Loc-Line arms so that a bat swinging through and smashing something can trigger the camera.
Any thoughts or suggestions would be appreciated.
Participated in the