Last time, I introduced the Arduino platform and the version of it that I am using, a "Boarduino" from Adafruit Technologies. In function, all of these devices are very similar. For my purposes I decided to go with the Boarduino simply because the vendor was local and I could get it quickly, as well as offering a basic set of extra components for experimentation.
I will suggest that folks who are completely new to microcomputers and interfacing go for the "true" Arduino at the outset. The reason is simply that the support community and software out there focus on the Arduino as the common ground.. therefore "everything" works on the Arduino, while some variants (such as mine, the Boarduino) might require a little bit of tweaking to work properly. For me, this was a fun challenge- for some it might have been discouraging. In the end, to work with the latest version of the programming environment, I needed to select the device as a "Lilypad 328" and edit the file to properly reflect the 16Mhz CPU clock rate. That's something a novice wouldn't know to do, and had I been working with "true" Arduino hardware, the problems I had would not have been there in the first place. This being said, I truly am happy with my choice of the Boarduino, and think that there's room for both the off-the-rack Arduino and the Boarduino in my toolbox. The Boarduino is cheaper, simpler, and easy to incorporate into a finished project.. the Arduino is good for development, as it is the gold standard of the platform. From here on, I will refer to the Boarduino as an Arduino, as in all aspects that matter in terms of this project, they are functionally equivalent. I won't give a complete tutorial on the Arduino programming language, there are a number of them available online. If you are using this blog to construct a similar device, I also assume that you have gotten an Arduino of some flavor, and have successfully connected to it.
If you decide to get an Arduino, the first thing you are going to do is make a blinky light. The reason is quite simple.. the most basic demonstration program for the Arduino is "Blink"... which blinks the LED on the Arduino off and on once a second. This is about as basic a program as can be written that actually DOES something, if you can call using hours of work and thirty dollars to do something that you can do with a $1.99 component from Radio Shack (blinking LED's are cheap) "something". This of course should not stop you from being proud that you did it. Here's the program, with the program comments changed.. this is the original "Blink" code included as an example program in the programming environment. A double slash "//" indicates the rest of the text on a line is a comment.
int ledPin = 13; // The arduino has an LED on pin 13. This requires no external wiring.
void setup() // When the arduino starts up, the setup() routine is run once
pinMode(ledPin, OUTPUT); // Tell the Arduino we plan to use the LED pin for output.
void loop() // The loop() routine runs over and over as long as the unit has power.
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
When this program is downloaded to the Arduino, sure enough, the LED blinks off and on, once a second. The program itself shows the simplified "C" language structure used, as well as what will be the most heavily used functions in control projects.. the ability to turn a pin output off and on, and the ability to implement precise enough delays to control external things, in my case, a camera. The program is simple enough for nearly anyone to understand and modify.. for example, if you were asked how to make the blink rate two seconds, it's not hard to figure out that would be done by changing the delay(1000) to delay(2000). (the delay command takes milliseconds, thousandths of a second, as it's parameter.) "Blink" is an excellent program to fiddle with, to learn a little. Try setting the "on" period to two seconds, with a half a second "off" period. The Arduino is "for" fiddling and learning, go ahead and fiddle and learn. Just don't admit in public just how much time you were able to amuse yourself by making a blinking light..
Blink is the core of what I will be doing- controlling external hardware based upon timing. The first project for the camera, an HDR Photography shutter trigger, is scarcely more complex, only adding some changing delays to handle a range of exposures.
HDR, or High Dynamic Range photography, is a process that is the natural extension of a photographic process known as bracketing. When a photo is taken, due to the nature of light, certain parts of any scene will be overexposed, some underexposed, and hopefully most will fall into the middle "correct" exposure. Bracketing simply means taking extra pictures, intentionally underexposing and overexposing on the extras- with the end result being that between the shots, ALL parts of the scene will have been properly exposed. These shots are then combined to produce a single image, with correct exposure levels on all parts of the scene. Sometimes aspects are manipulated for artistic effect, but often, the effect of HDR in general is both beautiful and surreal without taking liberties. Most higher-end consumer cameras and all professional cameras can do single bracketing, taking one shot above and below in terms of exposure, as a function. This project will do full-range bracketing for two ranges.. daylight and night. To do this, we lock the camera in terms of aperture and focus, and simply use the shutter "bulb" mode controlled by the Arduino via the remote control port on the camera. Via the shutter remote port, we can get speeds as fast as 1/200 second, which should be usable in the aperture ranges we will use.. typically f8 to f11- because at small apertures, the "in focus" depth of field will change little as the shutter time changes. Our little Arduino's job will be to open and close an electronic "switch" at the proper intervals to take the series of time shots to produce up nine bracketing images, across the entire range of exposures.
There are a number of methods that could be used to change the digital output of the Arduino into the switch-type behavior we want- but for the sake of doing it "the right way" and protecting external equipment (like my camera), either a relay or an optical isolator puts an electronic barrier between your circuit and what you are controlling.. protecting both in the process. Relays introduce a certain amount of delay, draw quite a bit of current, and are more expensive- so I've chosen optical isolators. I was able to get a pack of six for three dollars from a local electronics store, Radio Shack also sells comparable ones. I'll be using Fairchild 4N25 Optoisolators. Aside from a couple of wires and a 2.5mm phono plug (Canon's remote trigger plug is simply a 2.5mm stereo plug) all we need is one of these optoisolators and a single resistor.
If you question the need for the isolator, as I have been experimenting, I was triggering a flash unit which was faulty and backfed nearly 2000 volts into the circuit.. and the Arduino was still also connected to the PC at the time. Had the optoisolator not been in place, that voltage could have ended up frying both the Arduino and even potentially my PC. The fault cost me a fifty cent isolator, and convinced me to isolate as much as I can, to avoid problems!