[Edit 12/31/2015: Note for Pixhawk users that Canon cameras require a 5V pulse to trigger so a voltage step-up from Pixhawk's 3.3V output is required. See compatible cable and link to more instructions here.]

This tutorial will show you how to get your CHDK-enabled camera connected to your ArduPilot Mega (APM) without buying any extra hardware or decoding PWM outputs. You might want to make this connection to take advantage of the camera trigger function based on distance covered, to ensure a certain overlap and to avoid excessively high overlap. This modification is not necessary, if you have a CHDK camera and want to keep it simple, you won’t gain much by switching to this method right away.
For this tutorial, I’ll use an SX260 HS but this should work equally well on any CHDK-supported Canon Powershot camera. You’ll need just the supplies below to make the cable. The SX260 uses a USB Mini-B connector. Most Powershot cameras come with a USB cable, you can just use that one to be safe.

If you don’t have a crimp tool to attach the servo connector, just take a spare servo wire and solder the wires together instead.
We’ll only be using the Mini-B side of this cable, so measure whatever length you need from that end depending on how your camera and autopilot mount in your airframe. I’ve measured out about 14″ and cut the cable completely through. Inside are four wires, we only need the red and black wire so cut away the green and white wires. Strip the ends of the red and black wires.

If you have the crimp tool, crimp and insert the wires into the first and third positions of a 3-position header. If you don’t have the crimp tool, solder these two wires to the ground and signal wires of a spare servo wire. Insert the ground wire into the side with an arrow so you can tell which wire is which later on.

Cover the connector with heatshrink. Be careful with the hot air near the connector as it can cause the locking plastic pieces in the receptacle to deform.
Now plug this cable into pin A9 on the side row of APM. The text doesn’t line up exactly so be sure to count rows. SPI takes two rows, then A11 and A10 are two more so there should be 4 rows of free pins, then our new connector.
If you already have CHDK installed, just install the script file (right click, save link as) into the scripts directory on your SD card. If not, follow instructions for installing CHDK from the page corresponding to your camera atthe CHDK wiki. Load up CHDK and go into the menu then navigate to Miscellaneous Stuff -> Remote Parameters and make sure the Enable Remote setting is checked.
Now connect to your APM and open the Full Parameters List in the Config/Tuning tab. Set the parameters as following:
- CAM_DURATION: 1
- CAM_TRIGG_DIST: Depending on overlap required.. be sure to keep in mind the normal downwind speed of your plane as well as the maximum rate at which the camera can take pictures. For the SX260 and the E382 that’s once every 2.7 seconds and about 18m/s. I plan to operate below those condition in most cases but I do like to get as many pictures as possible, so I set my distance to 49 (meters).
- CAM_TRIGG_TYPE: 1
- RELAY_PIN: 13
All that’s left is to test it out. Load the E38_APM.bas script file like any normal CHDK script and start running it. If you can get a 3d fix inside, you can test it on your lab bench just using USB power. Just set the CAM_TRIGG_DIST to 1 or 2 meters and let your plane sit on the desk. Small movements between GPS readings will cause the distance value to count up slowly and it should trigger the shutter every few seconds.
If your camera lens closes and opens instead of taking a picture, make sure the CHDK remote enable setting saved properly. If nothing happens at all, take your APM outside and walk around to make sure you are getting some distance covered.





Comments
Hi Jeff,
It is now installed in the Wiki for both Copter and plane and is accessible through the Table Of Contents for each of them.
http://copter.ardupilot.com/wiki/common-apm-to-chdk-camera-link-tut...
@Gary: Looks great, no changes needed!
@Ferdi: No need, you don't need power and the power pin is not even connected, just ground and signal.
@Simon: Good to know, I'll keep that in mind if I ever see that issue.
@Gerard: That's a creative way to send power off signals, I like it!
Technically the duration of the pulse can already be changed, so developing the function for that in APM should be easy. The accuracy of pulse duration on the Canon is around 40ms precision, so multiples of 100ms duration should provide a range of different functions.
Without that function in APM at the moment, I wrote a script that tracks the number of pulses arriving within a second of one another. Since the relay switch is also hooked up to ch7, I can flick a switch three times to retract the lens.
There was this thing "DO_SET_PARAMETER" which could reprogram parameters in flight plans, but I don't think this was ever implemented or is to be removed. Anyway, if you have a gcs, you could just modify the duration there, write the param and then trigger the camera again. The script needs to detect the two pulse lengths of course.
There is ways to script lens retraction or power off in chdk, but there is any way to control ardupilot signal to do more tan just triggering signal?. I mean if we could send a longer signal for example, we could use that to script power off camera for landing. That should almost complete most needed functions for aerial mapping.
Be careful with "Cover the connector with heatshrink". It might reduce the efficiency of your vibration damping.
Brilliant post Jeff, thanks for letting it form part of the wiki.
Also, excellent tutorial Jeff.
Maybe important to note is, that the canon SX 260 HS can only trigger every 2.7 secs if you have a fast SD card. Not all class 10 cards have been giving me that speed. If your camera takes longer, check the card's speed (I usually do this by copying a large file from my PC).
Hi Jeff,
Here is the common wiki page I have made for this tutorial, I have not put it in the Tables of contents for the various vehicles yet. http://planner.ardupilot.com/wiki/common-apm-to-chdk-camera-link-tu...
Please look it over and let me know if there is anything you would like to change or if you would prefer to not have it included in our wiki.
As it is this is just your page with a local index and local headings added and the images moved to wiki local storage.
Thank You,
Gary
-
2
-
3
-
4
-
5
-
6
of 6 Next