A remotely actuated intervalometer for aerial mapping using Canon cameras

I can’t really take much credit for this idea. I first saw it as a posting by BloomingtonFPV on the FPVLab.com forum on January 6, 2013, so he deserves the bulk of the credit for this. He did a LOT of work on it. Here’s a link to that thread as there’s a lot of good, detailed info there beyond what I’m presenting here and you should read it also .

Ummmm, the problem was I couldn’t get the damn thing to work. Delving deeper into the code posted it looked like pieces were missing, especially in the Arduino code. It looks like something maybe got hosed during its posting. So I jumped into the code and put in what was needed to get it to work and did a little streamlining. I also added annotations so that others could better see what it was doing. I know I had a hell of a time figuring it out myself so you’re benefiting from my failings. Furthermore, while it was originally written for a Canon SX230 HS camera (a GPS enabled camera) I’ve tested it on not only on that camera but also a Canon A2200, a smaller, lighter and cheaper non-GPS camera. And it works. It will probably work on a lot of Canon cameras.

Why you want this

If you are using a Canon camera for aerial photos, a model supported by the CHDK software, this device allows you to take off with your camera lens safely retracted. Then when you are where you want to be to take images, throw a switch on your RC transmitter and the camera comes alive, extends the lens and starts taking pictures at an interval you’ve specified. When you’re ready to land, you throw that same switch on your transmitter and the lens retracts and the camera shuts down. This is ideal to protect a belly mounted camera in a fixed wing aircraft. It also is useful in the case of a multirotor setup where the camera is facing straight down beneath the aircraft and susceptible to blown dirt and grit from the rotor blast.

The complete Arduino system, minus the camera 'cause you know what that looks like. You may only need the FTDI board once for the initial programming.

The complete Arduino system, minus the camera ’cause you know what that looks like. You may only need the FTDI board once for the initial programming.

How it works

Most RC transmitters send out Pulse Wave Modulation (PWM) signals (If yours isn’t PWM, you can stop reading now). By assigning a three position switch (or an analog knob) to a spare channel on your transmitter you can send PWM signals that range from low to medium to high.

An Arduino microprocessor sits between the RC receiver in the aircraft and the Canon camera. The Arduino is programmed with the “USBController.ino” to monitor the PWM signal coming out of the aircraft’s RC receiver. If the PWM level is less than 1250, the Arduino generates 15 millisecond pulses on the USB input to the camera. If the PWM level coming from the receiver increases to between 1350 and 1650, the Arduino starts generating 45 millisecond pulses. Finally, if the PWM rises to 1750 or above, the Arduino generates 90 millisecond USB pulses.

Here’s the cool part. While the Arduino is doing its thing the Canon camera is operating the CHDK software and running the script “PictUAV2.lua”. It watches the signal coming in on the USB port. When it sees only 15 millisecond pulses it just sits there in standby, sucking its thumb. Pulses greater than 30 milliseconds but less than 90 cause it to extend its lens and begin taking pictures at rapid intervals. And when the pulse lengths increase to 90 milliseconds or greater, the camera shuts itself down. Sweet!

What you need to make this happen:

• Arduino Pro Mini 328 – 5V/16MHz (Available from Sparkfun.com for $9.95 ….that’s way cheap!). You want the 5 volt version, not the 3.3 volts as the power is coming from the RC receiver and is 5 volts. This is a tiny friggin’ unit!
• Mini USB cable to chop up
• Canon Camera running CHDK software
• “USBController.ino” to program the Arduino
• “PictUAV2.lua” script to run the camera under CHDK
• A programmer for the Arduino if you don’t already have one. The FTDI Basic Breakout – 5V from Sparkfun for $14.95  will do it and allow for programming of other Pro Minis.
• Maybe some header pins like these  to make connecting to the Arduino easier. You certainly need some to connect the FTDI board.

Putting it together

Here’s the super simple wiring diagram:

Pin guide for Arduino Pro Mini 328 - 5V/16MHz

Pin guide for Arduino Pro Mini 328 – 5V/16MHz

Solder in four header pins in the Arduino’s following holes:, 10, 12, VCC and GND. You’ll also need to solder in 6 header pins for the FTDI programmer along the bottom of the board as shown in the image above. Ummm…You do know how to solder, don’t you?

Power for the Arduino and the PWM signal are obtained from the aircraft’s RC receiver. Using a typical servo cable connect the +5 volts (middle wire), signal (usually white or yellow)  and ground (usually black or brown) to the Arduino header pins at the locations shown.

The USB connector you need is the very common Mini Type A. Chances are you have some of these in a box somewhere ready to chop up. You’ll only use two connections to the Canon camera, contact 1 (ground) and contact 5 (+5 volts).

There are two ways to figure out which wires go to which USB contacts. The first is to do a continuity check between the contacts until you find the correct wire. Hold the mini USB plug so that you are looking into its opening and the five copper contacts are at the bottom. The “top” of the pin is narrower than the bottom. Looking at the contacts from this perspective, contact 5 (+5 volts) is the one at the far right and contact 1 (ground) is the pin at the far left.

The other way to get the correct wires is to just look at the color of the wires in the USB cable bundle. The wire to pin 5 is SUPPOSED to be red and the wire to pin 1 is SUPPOSED to be black. Those are the standards. If the USB cable you’re slicing up is extraordinarily cheap and made by slave labor in a remote country….Then who knows. But my colors were correct.

So contact 5 on the USB plug (probably the red wire) goes to pin 12 of the Arduino and contact 1 of the USB (probably the black wire) goes to the GRD pin of the Arduino.

Wow, you’re all done with the hardware!

Software

I have links to the two software items below. I put each on a separate web page so just copy and paste them at your end with whatever text editor you like.

To program the Arduino you’ll need the free software from Arduino  and the FTDI Basic Breakout board. The reason you need the FTDI board is that this version of Arduino is designed to be tiny so they left out the programming interface. You could use a larger Arduino if you like and not have to use an FDTI interface. The Arduino website has all the programming info you’ll need. In summary you’ll install the Arduino software on your PC, plug in the Arduino to be programmed via a USB cable and the FTDI programmer, load the USBController.ino code into the Arduino software and upload it to the Arduino.

The Canon software is simply written into a text file named PictUAV2.lua and put into the “SCRIPTS” subdirectory of the SD card in your Canon, running the CHDK software.

I will admit that I’m far from adept at using the CHDK software and can’t offer you much in the way of help there. There’s a bit of a learning curve. But it’s real powerful stuff. And if I can learn enough to get it working, so can you. The CHDK software is here , be sure and get the version for your specific camera AND firmware. If you’re not familiar with CHDK, you’ll be doing some reading….

Setting up the Canon camera

Once you have your Arduino programmed and the PictUAV2.lua placed in the SCRIPTS directory of the camera’s SD card (AND the write protect on the card enabled….CHDK is funny that way!) you’ll need to change a few settings in the camera’s CHDK setup. These worked for me for both the SX230 HS and A2200 but it’s possible other models could be just a little different.

With the camera off, press the “Playback” button. You should see a CHDK splash screen appear but the lens will not extend. Press the “Func Set” button, and you’ll get a full screen CHDK menu. Select “Load script from file” and then select PictUAV2.lua. Then, back at the menu, set “Autostart” to “On”. Next, select “Remote Parameters”. You want to set “Enable remote” to “On” (This activates the USB port to act as a remote). Now select “Back” to go up a level to the first menu. The last thing you need to do is make sure the “Save params” option is checked. This ensures the changes you just made will be retained the next time the camera powers up.

Having done the camera setup at the bottom of the menu, below the line labeled PictUAV2, are the parameters you can set for the actual program’s operation. Most important is “Secs/frame” which sets the interval at which you want images taken. Note that some camera models have a minimum interval at which they can run. For some reason my SX230 can run at a shorter interval (2 seconds) than my A2200 (3 seconds). Probably due to the SX230 being a better camera.

To be honest I haven’t really played much with the other options but it appears you can set the length of time you want the intervalometer to run, whether or not to focus for every shot (for aerials a single focus will save time) and if you want to turn the display off (which saves battery life). More choices than you know what to do with.

Operating the system

The RC receiver should be on and providing power to the Arduino. I suppose it’s wise to press the reset on the Arduino to make sure it’s booted up properly, but mine has always been fine with just the power up. You mileage may vary.

Activate the Canon by pressing the “Playback” button. The choice of the button can vary for different Canon models under CHDK, so check the CHDK Wiki for whatever model you’re using.

If everything is working as it should (Hey, it happens occasionally) after you see the CHDK splash screen there will be a box in the lower left showing “Autostart”, “PictUAV2 Started”, “PictUAV2 loop” and a = 0. The lens should still be retracted. If the USB cable is already connected you’ll see the a value to be dancing around between 0 and 1. This is it reading the 15 millisecond standby pulses. If you’re seeing this, all may well be golden.

Now throw your selected switch on your RC transmitter to Record. The lens should now extend. You’ll see a notation pop up on the camera’s display that recording has started and the a value will increase. And, if all is well, the camera should be taking pictures at the interval you’ve selected.

Now, to shut the beast off, move your transmitter’s switch to Shutdown. You should see the a value increase to 90, the lens retract and everything go off. Did it do it? If so, buy a lottery ticket. You’re on a roll. Note that once it’s off you can’t turn it back on until it’s on the ground and you manually press the camera’s “playback” button.

Oh, one last thing….Since the script is now set to autostart, suppose you need to break it to do other things with the camera. If you turn it on now it just starts taking pictures like a maniac. If so just press the shutter. You’ll see “Interrupted” appear on the display screen and the incessant picture taking will cease. Or it should. If not smack it against a wall.

Anyway, that’s it. It’s a nifty way to loft a camera and keep it reasonably protected. I mean other than it being flown around hundreds of feet over the ground.