APM to CHDK Camera Link Tutorial

[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.]

ArduPilot Camera Tie-In Tutorial

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.

APM CHDK Connection

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.

SAMSUNG CSC

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.

SAMSUNG CSC

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.

CHDK Cable

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.

APM Relay Pin A9

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.

SAMSUNG CSC

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

Params_CAM

Params_Relay

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.

Original Post

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Are you sure the image isn't focused? More likely it's got some motion blur in it. Try setting the camera to Tv mode with a shutter speed of at least 1/1250th of a second. That should fix it.

  • I Have the same problem with bad images that was not focused, like Eladio Garcia. Any sugestion?

    Thanks

  • Hello Jeff,

    I wonder if I can use the USB cable from my camera SX260 that came with E382 to mount this cable release by APM. My camera already came with the install CHDK Event38 is the same you need to use the method of distance trip or have to install another?

  • Unfortunately right now there's no way to trigger the camera using this method other than by distance... If it's widely desired the dev team will likely add it in a future ArduPlane release though.

  • Great tutorial. I managed to have the camera working.

    I have question how do we manually control the camera to take picture with this setup? for example when we reached at way point then take picture. Thank you guys.

  • By the way, the script that does not focus is E38_APM.bas

  • I have runned the script with my Canon A3300 and a cable like this and it shutter at specified distance (that works fine) but I have another kind of problem with the photos. The pictures are not focused. I am sure that is not a problem of vibration neither shutter speed because I have done several trials with different configurations (ISO, Shutter speed, IS, etc.) and it is the same. But, on the other hand, camera works fine with other script  like a time intervalometer (without usb cable) so I suppose that is a problem of the script. Some one else have the same problem? Any suggestion is welcome.

  • If you want to use a Gent-Wire USB cable, you'll need to use an R/C output instead of the relay output and change the trigger type to R/C.

  • Does this tutorial apply for the Gent-WireUSB cable also or do I have to make a cable like the one in the tutorial? I ask because other tutorials I've seen say that you should use RC_OUT_CH_7 as trigger control.

  • Just to be clear, you don't need a special cable for this method, APM puts out a pulse that CHDK can read just fine.

    I think this feature is only implemented in ArduPlane right now, that's probably why!

This reply was deleted.