This article explains how to set up camera shutter triggering for CanonCameras that support the Canon Hacker Development Kit (CHDK).
![Canon Canon](https://vignette.wikia.nocookie.net/chdk/images/6/6a/Palette-sx260hs-record.png/revision/latest?cb=20130214195745)
Overview¶
Canon SX260 HS Common OSD elements. Various modes have specific OSD elements. In PASM modes, most likely to be used by CHDK users, there are some common OSD elements shown in the image here. Note that most of the elements lay on an outer 'ring' which may interfere with CHDK OSD element display. Canon’s compact PowerShot SX lineup has ruled the roost for the past half of a decade, and the Canon PowerShot SX260 HS ($349.99) picks up where the SX230 left off.
ArduPilot allows you toconfigure a servo or relay output as the control signal for the camera shutterso that it can be used inCamera Missions.Additional hardware is required to convert the shutter activation signalto the format expected by the particular camera.
This article explains how to set up the shutter-trigger for CanonCameras that support the Canon Hacker Development Kit (CHDK). Themethod connects the ArduPilot output to the camera using a *customcable*, and causes a script running on the camera to take pictures whenthe relay output voltage goes high.
At the end of the article is alist of cables that you can purchaseinstead of using the custom cable (please extend this list if you find another appropriate cable).
The article covers both Pixhawk and APM2.x.
APM Connected to aCanon SX260 HS using a custom cable
Note
It is also possible to use aservo output instead of a relay.
CHKD and ArduPilot integration¶
CHDK is an experimental (and free) development tool, which temporarilypatches (supported) Canon cameras so that they can be controlled usingscripts. The scripts are able to take pictures, control the camera zoom,set the focus, and access many other camera features.
Scripts can also read the camera USB port voltage and execute differentinstructions/functions based on the signal pulse-length. When using arelay, the script can be very simple — all it needs to do is check thevoltage (in a loop), and take a picture when it detects the relayvoltage go high. More complicated scripts might first set the focus,zoom, or preform any other default behaviour.
The CHDK Wiki documentationexplains which cameras are supported, how you install CHDK on youcamera, and how to install and run scripts.
Cable for connecting to Pixhawk¶
Note
See CHDK cables for purchase ifyou just want to buy a cable. This section is useful if you want tocreate your own cable or understand what the cable needs to do.
For Pixhawk you have to modify the APM cable in the following section,adding a circuit step the output pin signal voltage from 3.3 to 5 volts.This is required because the relay/servo output voltage is approximately3.3V while CHDK needs 5V to trigger.
A circuit and PCB you can use are shown below. 5V should be suppliedfrom a BEC (or from a BEC powering the central pin on the AUX outputrail) because the servo rail itself is not powered.
1 x BC547 or 2N3904
1 x BC557 or 2N3906
2 x 1 K
1 x 220 ohm
3V to5V Shifter (PCB)
Note
The voltage stepper circuit and PCB above are from the community discussion boards.
It is also possible to find pre-built stepper circuits like theSparkFun 5V Step-Up Breakout - NCP1402 (not tested).
Cable for connecting to APM¶
A cable is needed to connect the APM board to the camera USB port. Thissection shows how to modify the USB cable that is supplied with thecamera, replacing the standard USB connector with a 3-position headerthat can connect to the AMP output port.
Note
This example uses the USB Mini-B connector that comes with theSX260 HS camera. The same approach should work equally well using thesupplied cable on any CHDK-supported Canon Powershot camera.
The components used to attach the servo connector to the wire are shownbelow. If you don’t have a crimp tool you can just solder a spare servowire connector instead.
We’ll only be using the Mini-B side of this cable, so measure whateverlength you need from that end depending on how your camera and autopilotmount in your airframe. I’ve measured out about 14″ and cut the cablecompletely through. Inside are four wires, we only need the red andblack wire so cut away the green and white wires. Strip the ends of thered and black wires.
CHDK Camera Control Cable:Stripped Wires
If you have the crimp tool, crimp and insert the wires into the firstand third positions of a 3-position header. If you don’t have the crimptool, solder these two wires to the ground and signal wires of a spareservo wire. Insert the ground wire into the side with an arrow so youcan tell which wire is which later on.
Cover the connector with heatshrink. Be careful with the hot air nearthe connector as it can cause the locking plastic pieces in thereceptacle to deform.
ACHDK Camera Cable: Connector covered withHeatshrink
Camera shutter configuration in Mission Planner¶
Camera Shutter Configuration in Mission Planner explains how to configurea Pixhawk AUX output or the APM2.x A9 pin as a relay camera trigger.Connect the cable to the appropriate port as described, and to thecamera.
The specific Mission Planner settings required for this CHDK hardwareare listed below. Note that duration required may be different on somecameras:
- Pixhawk:
CAM_TRIG_TYPE
: 1 (Relay).Shutter(Port)
: RC10 (Name of connected port, in this examplewe use RC10 = AUX2).
- APM2.x:
Shutter(Port)
: Relay (A9 Pin).
ShutterDuration
: 1 (1/10 second)CH7_OPT
: 9 (Optional - enables manual shutter triggering onCopter only).
The servo settings are not used for the relay configuration, and can beignored.
Creating and installing the CHDK script¶
One of the simplest scripts you can use is E38_APM.bas, whichsimply waits on the relay signal and then takes a picture (originallyfrom www.event38.com):
Alternatively you can use a more advanced script to set up the camerafocus, exposure or other settings before taking the picture. A goodstarting point is the open source KAP UAV Exposure Control Script(v3.1). This was used as the basis for the 3DR Aero Plane3DR EAI (Exposure-Aperture-ISO)script described in the Aero-M Operation Manual.
The CHDK Wiki explains how you setup CHDK and install and activate scripts for your particular camera.Installing scripts is usually as simple as copying them into the“scripts” directory on your SD card. You can then activate them bynavigating to the menu Miscellaneous Stuff | Remote Parameters andmaking sure the Enable Remote setting is checked.
CHDK: Camera Menu to EnableRemote
Testing¶
Load and run your CHDK script. On Copter you should be able to triggerthe shutter using the CH7 switch.
On other vehicles set the
CAM_TRIGG_DIST
to 1 or 2 meters. Smallchanges in the GPS readings will cause the distance value to count upslowly and it should trigger the shutter every few seconds. If nothinghappens at all, take your vehicle outside and walk around to make surethat some distance is detected. If your camera lens closes and opensinstead of taking a picture, make sure the CHDK remote enable settingis activated on the camera.Using a servo instead of a relay¶
It is also possible to trigger the camera shutter using a servo output,but that requires additional (and often more expensive) hardware todecode the servo’s PWM signal.The CHDK Camera Control Tutorial describes a suitablePWM-to-voltage pulse cable, and information from which the servosettings can be inferred.
Note
The CHDK Camera Control Tutorial integrates with thecamera as a “generic servo” rather than as a shutter trigger. Thisapproach means that camera triggering is not as well integrated withmission planning, but more camera commands can be called.
CHDK Cables for purchase¶
This section is for listing CHDK cables that you can purchase (ratherthan creating your own, as described in this article). Please extend thelist if you discover more.
Tuffwing camera trigger cable for Pixhawk¶
Tuffwing camera trigger cable for connecting Pixhawk to a CHDK CanonPowerShot. This includes circuitry to upscale the Pixhawk 3.3 voltsignal to 5 volts from the + pin. You’ll need to have an ESC with an BECor UBEC plugged into any of the open AUX or MAIN OUTs on the Pixhawk.
- Pixhawk Camera Trigger Cable(User Guide)