Experimenting with Arduino and Time Lapse Photography

First of all I want to thank Chuck On Tech for giving me the impetus to start working out this project. The blog post I started with is Arduino Based Time Lapse Timer in Altoid Tin. Not as much detail as I would like, and I have a couple of thing happening that are going to be different, but the page was a useful starting point.

For my setup I was not concerned about getting it set up in an Altoids tin. I don’t have a problem with altoids tins, but for this project, it seems to me to be overkill.

The reason I ended up on Chuck’s page are a couple of limitations of my cameras. I actually have 3 different Pentax K mount DSLRs. I have a K100D, K20D and a K7D. I’ve seriously thought about getting the K5D, but by the time I’m really ready for another camera, I suspect that there will be something even “better” on the market. In any case the K7D is my primary camera at this point, and I ran into two different limitations with the camera that make it a little difficult to do serious time lapse photography.

The first limitation is that I can take no more than 99 images in a cluster. Depending on what region of the world you are in, and how you treat video and images, that ranges from 3.3 seconds of 30fps video, to 4.1 seconds of 24fps video. OK, if you want to drop down to 16 or even 15 fps video, you can stretch the video more, but you still are not going to get much over 10 seconds of video, and it starts to be a bit jerky unless you start playing with frame doubling, or the like.

As if that were not bad enough, the camera automatically goes into power savings mode after so many seconds of no operator interaction, and at that point, whether you are 70 frames in, or 1, the interval shooting mode stops. So while I can program it to take an image every 9 hrs, 59 min, and 59 seconds, (or longer) I won’t get more than one or two images out of the camera, if that.

So, I started looking for a way to remotely control the camera. It supports being controlled via an IR receiver built into the camera, but noting that I have three Pentax cameras, I’m not really interested in controlling all three with the same device, although I’ll admit that the idea has some merit.

First up was to start assembling the stuff I would need. First up, an Arduino. I went with an Arduino Uno board, though this could easily be done on a nano, up to a point. For that matter, long term I’m not even going to be using the Uno board for much more than programming the Atmel328p controller. Once that’s done, the chip will go into a socket on a board, so I can start doin other projects with the Uno board. (I’ve already got two more of the chips for the next couple of projects.

Next up a breadboard. Oh I suppose I could wire things directly to the uno board, but that gets a bit old pretty soon. And I’m not all that enthusiastic about dead bug wiring, though I may do some of that down the line. But having it breadboarded means that I can build a schematic in Fritzing of what I’ve got laid out, and if I really want to, down the line I could have the resulting porard mass produced. However low volume production would be a bit more expensive than I’m interested in picking up at the moment. But if I have it breadboarded, I can transition that to a fairly simple solder down equivalent of the breadboard and I think that’s good.

I also picked up a beginner parts kit, and some jumpers. However I was not able to find the optical isolator/couplers locally on a holiday weekend, so I ordered them from Amazon, and started writing code.

The neat thing about this project was that I could code and build this project in steps. Since I didn’t have the couplers, I could start by using some LEDs to indicate the state of the shutter control, what mode I had selected, whether I was ‘operating’ or not, and so on. In fact if I wanted to I could have built a final product using the LEDs and a pair of photo sensitive resistors. I decided not to, simply because I would have had to build an interface to allow that to work, and simultaniously isolate them from each other.

Oh, one of the differences between what I am doing, and what Chuck did is that I do not tie the ring and tip together in my rig. Experience for me is that I want a separate control for the two connectors. One of these conductors will allow the camera to come up out of sleep mode. It will then force the camera to auto-focus, if I haven’t switched to manual focus mode. As you might imagine, I think this idea of the camera going to sleep between shots is a good one. However when I do that, the camera needs some time to come out of sleep mode before it will take a picture. So I have the program putting a short delay between the shutter ‘half press’ state and the shutter ‘full press’ state which trips the shutter and the camera takes a picture.

I also wanted a little bit more flexibility with the interval than the example that Chuck presented. Initially I was thinking, put in an up and down button for hours, another for minutes, still another for seconds, a ‘display’ button for each, then put in an led that allows me to blink the number of times that each of those has as a value. I ot to thinking and realized, 45 blinks is going to et old trying to count.

Ok, well, how about using morse code? So I wrote up a program that I could use with the uno board to blink pin 13 (the led on the board that the blink program you test the board with uses) in morse code. Well, that gets me 5 dit/dot values per digit, and I could build in a display of 6 leds to indicate which of the hh,mm,ss digits is being displayed.  And yes, that could work, and perhaps at a later date I may build something like that, but it occurred to me that really I’m only interested in a few intervals.

I got to thinking and realized I’m interested in intervals of 1 second, 10 seconds, 20 seconds, 30 seconds one minute, and 10 minutes. And that’s just six values. I think I can keep track of how many times an LED blinks up to a count of 6. Perhaps up to 12 or 15 would not be a major problem either. For now though, let’s stick with 1, 10, 20, 30, 1 min, and 10 minutes. For something where I want to take pictures at specific times of the day, or over months, I’m pretty sure that I’m going to want to do something different anyway. And if I decide that instead of those intervals I want to do something like 5, 10, 15, 30, 45 and 60 seconds, or 15, 30, 45, 60 minutes, and 2hrs, and 8hrs, I can simply update the values in the array and upload new code to the controller.

The most surprising issue I ran into had to do with the cable to the camera. The cable uses a 2.5mm connector. This is also known as the 3/32″ connector. If you had a cell phone before the iPhone came out, and you got a wired headset for that phone, it probably uses this connector. I’ve seen it as well for cordless phones. So time to run around and see if I can find an older wired phone headset. First stop, Radio Shack. Or perhaps “Cellular Shack” is more appropriate, though I’ll give them credit, I’ve found a number of the parts I’ve needed for this project available at Radio Shack. So, how about a headset. “Sure we’ve got one right over here. It only costs $29.95.” $30 for a wire to connect the camera? I could order a pre-manufactured controller for the camera for less than that. Time to move on.

Well, if Radio Shack doesn’t have something workable, perhaps Target? They are in the same shopping center after all. Well, they also have a headset. Price, $24.99. Hmm, not much better. I’m not expecting much, but there’s a dollar store in the same shopping center. Ah, they have lots of cheap headphones, but the smallest connector I see on ay of them is 1/8″ or 3.5mm. Too large. OK, where else. Well, kitty corner from the center is an AxMan store. Now if you’ve never been to an AxMan store, that’s ok. However you’re probably missing something that they either have, or have a substitute for sitting on their shelves. They are a retail surplus store. Although ‘retail’ may be stretching it. In any case I walk over, and find out that on Labor Day, they are closed. Oh well, it’s not like they are the only place I might find something that works. So onwards.

I head over to a local shopping mall. I’ve decided that I’ll at least browse the cell phone stores, but I’m not holding out much hope that they have something workable. I again find a couple of devices that might work, but at that $25-30 range again. They are holding the people carrying the older cell phones over a barrel and beating on them it looks like. I decide to start curving my way back home, plan a quick stop over at Worst Buy, Office Depot, Staples, and if I haven’t found anythin by then, perhaps a stop over at MicroCenter (Midwest variation of Fry’s.) I get into Best Buy, and I find a headset at $15. Best price so far. So, on the presumption that I’m not likely to find anything else I go ahead and buy one. In a worst case situation, I should be able to return it, eh?

I decide to o ahead and hit Office Depot. They are on the way, and I find an adapter for 1/8″ to 3/32″. for $6. Hmm. that and a $1 headset from the dollar store really beats the best buy solution, and I grab it, and continue on. I get to another dollar store, pick up a pair of headphones, and go home.

Time to figure out which wires do which. I crack open the headphones, clip the wires close to the headphones and strip back the insulation a bit. Just a tip for people, you don’t need to worry too much about these headphones damaging your hearing. The wires inside of them are about 30 gauge enamel insulated single strand for each conductor. If you try to dump more than a couple of db through these wires they will probably burn out from the electrical load. But what do you expect for a buck? You don’t buy these because you’re an audiophile.

Well, erode the enamel off of some of the wires, figure out which does what with the camera, and set that aside. nothing I can do with them till the optocouplers show up. Meanwhile the next day comes up, and, I make another stab at AxMan, and find that they do have the headset I’m interested in, and it’s under $2. Yep, the set from Best Buy is oin back to Best Buy.

Most of a week later the optocouplers I ordered show up. And we’re off to the races. so to speak.

In addition to the Uno, and some jumper wires, the project consists of two momentary switches, one diode, and one resistor. Oh yeah, and the optocoupler. One switches from operate to setup mode, and back. The other will cycle through the various intervals when the system is in setup mode. The LED is used to indicate switching from operate to setup, and back, and is also used to indicate which interval position is selected. The resistor is there to protect the led. During development I also used 2 more leds in place of the opto-coupler, and used them to verify that the opto-couplers were functioning before attaching the camera.

When I move the micro-controller to the board, I’m going to also need to add a 5-volt regulator, and some capacitors, and probably a power switch. At that point I can plug in a 9v battery and set it up in a project box, or who knows, perhaps even an Altoids tin.

As it stands I can start doing a time lapse recording at any time. I’ll probably not use the K7D though. I usually shoot raw with that, and it has a 14 megapixel sensor on it. unless I’m planning on putting together an IMAX capable video, it’s far more than I’ll ever need. Even for a 1920×1080 video I shouldn’t need anything more than the low or medium resolution mode on the K100D. OK, the low-light characteristics of that sensor are not very good either, but I think I can live with them.

I’ll post a video once I’ve shot something. Not saying that it will be ‘interesting’, but we’ll see.