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

  • Enable remote was checked and I double checked the pin count multiple times. It was working back when I had access to the Relay_Pin parameter. Now that it has disappeared from the parameter list, its not working. I have the check box for the advanced Full Params checked as well.  Jeff, do you still have the "relay_pin" parameter showing in your params? If so, what firmware versions are you running on MP and the APM?

  • There is an option in CHDK that needs to be checked, it's called something like "enable remote trigger" or "USB shutter control", did you set that?

    Also the writing on the case doesn't line up exactly with the correct pins, so it might be accidentally in an adjacent pin.

  • So apparently I can no longer trigger my camera off of pin A9. The forums new CHDK page doesn't do a good job of how to connect everything with their new revamp of pin outputs (digital vs analog).A while back, I was using this tutorial for setup and it worked like a champ. I went without for a little while and now that I am trying to get back into messing around with mapping projects, I cant get it to work. Any pointers?? My original setup was using A9 as per this thread. Now that I have re installed the camera back on A9, I get nothing. Ive tried doing what the APM forum says, using the actual RC Output channel 7, and setting it to camera trigger in the FullParamsList but still, nothing. Even tried A7..  I tried using trigger type as "relay" and "servo;" which happens to toggle a servo when I connected it. There is no "relay_pin" command anymore to activate A9. Im kinda at a loss here.. help?? 

  • wth happend to the camera_tiggger_dist and Relay_pin parameters??? They arent showing up anymore. Did they get removed from the full param list?

  • That's right, its resolution is 10ms at best. I have Ch. 7 of my transmitter coupled to the relay switch of the APM though. This way when you apply a high pwm value, the relay pin remains set. I used that previously to turn off the camera before landing so that I have better lens protection. If you need more commands you get the complexity of timing by hand how long the switch should be on and there's not an easy way to check whether the command was actually applied from the ground.

    That could be an interesting feature for the APM, to translate a pwm value to a pin 'on' duration.

  • Ultrojo, get usb power reads the length of the pulse, so if you're sending it PWM it will potentially read the same value every time. The way to do it would be to use digital pulses of varying length instead of PWM. Last I checked though, CHDK couldn't even read quickly enough to register PWM values so I'm not sure how you're able to get something from PWM. I think it also reads out in multiples of 10ms.. so a value of 10 for me was more like a 100ms pulse.

  • It appears that DO_SET_CAM_TRIGG_DIST  does not work with ArduCopter V3.1.2. To bad, this would be icing on the cake.

  • i hv 1 more question ,  i test from remote --> apm --> chdk camera, i check get usb power only get value 10 only.  i want to make multiple command in the script depend on the value "get usb power".

    already change pwm in remote , also get value (get usb power) "10"

    am i missing somewhere?

  • i change script from  "shoot_full" command to "shoot half - shoot full" style, then its works.

    seems like the script "shoot_full" doesnt works for diferent distance. my camera  fw 100a. canon A2500

    thanks

  • I've seen when the camera is unable to focus that it might not finish taking the picture. Are you sure it's actually completing the focus routine or might it just be trying to focus and failing?

This reply was deleted.