[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

Views: 29917

Comment by Gerard Toonstra on October 1, 2013 at 3:06pm

These newer cameras ought to be able to shoot a photo within a second. You're probably not locking focus, which causes the camera to try to acquire that every time. This is somewhat dangerous from a moving vehicle because if there's a lot of movement or even texture underneath the focus may not get acquired. Ideally you want the focus set to infinity and lock it there.

Here's a script from the paparazzi project for the SX220HS that shows how to do this (pre_focus function, or through the properties):

https://github.com/paparazzi/paparazzi/blob/master/sw/extras/chdk/p...

When testing the functions, do this in sufficient light so shutter time is reasonable. Then you should be able to keep triggering and shoot a photo within a second. If the LED keeps blinking a long time after every picture, you may be recording RAW ones. Those take significantly longer to write to the card.

For arducopter users, as I found out the hard way; the GPS shoot-by-distance function doesn't work on the 3.0.1b version because the parameter isn't written (CAMERA_TRIGG_DIST) and probably the code itself. That required an update introduced quite recently, but it's now available on beta. If you're not into beta stuff, you can use the older method. On the newest version of the mission planner, you don't have the Grid V2 anymore. It instead has a survey grid calculation which pops up a new dialog box. In that dialog you can click the "advanced options" checkbox, which shows up a couple more tabs. In the last tab you can switch teh method for triggering the camera to "waypoint based" or whatever its' called. The standard method is distance-triggered, so if you don't click the advanced options on arducopter, you're not going to make any photos!

Comment by Gary McCray on October 1, 2013 at 3:07pm

Hi Jeff,

I think this excellent tutorial really needs to have its whole own dedicated wiki page.

Do you mind if I make a wiki page out of it including your images?

I may edit it a bit for format and ask a few questions for clarification, but basically I would like to put in what you have here.

Thank You,

Gary

Comment by Nicholas Witham on October 1, 2013 at 5:04pm

Great tutorial, nice one. Just what I was looking for. I think this needs to be a part of the wiki.

Comment by Nicholas Witham on October 1, 2013 at 5:12pm

@Gary,

Any chance you can expand that tutorial to include more detail on the "Survey" function of mission planner?

Comment by Bill Isenberger on October 1, 2013 at 5:28pm

Nice thread! thanks for the tutorial Jeff.

Comment by Gary McCray on October 1, 2013 at 5:28pm

Hi Nicholas,

I am far from an expert on this myself, but as I uncover additional information I'll get it in there too.

A lot of new stuff is happening very quickly now and we try to get it into the Wiki ASAP.

Gary

Comment by Nicholas Witham on October 1, 2013 at 5:43pm

Thanks heaps Gary. I know all you Wiki Ninjas work hard.

Comment by Jeff Taylor on October 1, 2013 at 6:13pm

Sure, feel free to use anything/everything in a wiki page! Let me know if you need clarification on anything.

Comment by Gary McCray on October 1, 2013 at 6:26pm

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

Comment by Ferdi on October 1, 2013 at 10:34pm

Hi Jeff,

Thanks for the article it is great.

Just a quick question.  Would I need to use the JP1 connector to power the A-Rail ? I am using the 3DR power module to power my APM2.6

Cheers,

Ferdi

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2017   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service