Friday, 8 February 2013

Arduino Remote Trigger for DSLR, stop motion etc.

I have a Canon DSLR camera which uses a 2.5mm stereo phono jack connector to allow for a tethered remote. These are surprisingly expensive. http://www.doc-diy.net provides an illustration of the way the connector works. It is pretty simple to put some electronics behind your camera for stop motion or candid photography.

I ended up with something looking like this:

It controls the camera to automatically take a photograph within a period of 0-60 seconds or 0-60 minutes, set by a sliding potentiometer. I can enable or disable the focus control. I can also switch it to take a photo at a random interval within 0-60 seconds/minutes. It runs off two 1.5v AAA batteries.

This post mostly explains the electronics. The arduino code is provided at the end. I don't explain my butchery of a cigar box tin. Read on if you fancy replicating!

The principle:

Image from http://www.doc-diy.net

Using a stereo connector allows you to focus your camera as well as take a shot. The drawing above shows how it works. The left most ring is connected to the internal ground of the DSLR camera. The focus and shutter are connected to pull-up resistors inside the camera. Shorting either to the ground triggers the actions. As you see, making a wired push button remote is trivial.

Concerning some smarter electronics; we don't want to apply any voltage to the DSLR camera, these things are expensive after all. By this, I mean we don't want to use a microcontroller to directly source or sink the shutter and focus pins of the camera. So it is best to keep it electrically isolated with relays and make the connections as if they were push buttons.

The Relays:

I raided my electronic scrap and found some Finder 30.22.7.005.0010 relays. They are conveniently low power, requiring 40mA to activate the relay. The official Arduino web page says the atmel chip should be able to source 40mA, but that would be working on the upper limit. So it is best to use a transistor to trigger the relay, and keep the relay a little isolated from the heart of the project. I found some BC238B npn transistors to use. Any general purpose npn transistor should suffice.

Drawn in Fritzing, ignore the relay designation

I used 220 ohm resistors on the base of the transistors. Remember your flyback diode across the relay activation terminals to nullify the collapse of the electromagnetic field. I connected the transistors to the digital pins 1 and 2 on the arduino, but they could connect to any. You want to wire the normally open terminal to your phono jack connector, so that the camera only takes photo graphs when the relay is activated.

Interface Electronics:

I wanted to keep the interface as simple as possible, so no LCD or seven segment display. I used 5 light emitting diodes (LEDs) to determine the state of the controller, 2 push buttons to toggle the mode, and a sliding potentiometer to set the time.

Drawn in Fritzing

The Arduino digital pins 10 to 13 are used as outputs to turn on and off 4 of the LEDs. Pins 10 and 11 can provide pulse-width modulation (PWM), so we will make this get dimmer as the time to shoot runs down. The LEDs require current limiting resistors, which are all 220 ohms. We use the 5 LEDs in the following way:

Power (connected to 5v)

Autofocus (on/off)

Random timing (on/off)

Time in Minutes ( PWM / off)

Time in Seconds ( PWM / off )

The Arduino digital pins 4 and 5 are used as inputs for the 2 push buttons. It is conventional to add a pull up resistor on a push button, but the Arduino has internal pull-up resistors we can use. You can activate them by writing a 'high' value to the pin after you have declared it as an input. One button is used to toggle the Autofocus, the other is used to move between the modes

'time set in seconds'

'time set in minutes'

'time randomly set in seconds'

'time randomly set in minutes'

The sliding potentiometer is simply wired between 5v and ground, with the armature pin wired in to an Arduino analog input pin.

Power:

Lastly, we provide power and a power switch to the Arduino. I used a Polulu 5v Boost regulator to convert my 3v power source into a 5v power source. It provides up to 200mA (not necessarily 200mA), which should be enough for a few LEDs and two low power relays. I placed a 22uF capacitor across the power lines to help absorb some noise from the supply and switching relays. The power switch needs to break the connection to the batteries, isolating all of the electronics. Remember to tie your grounds together.