Category: Hacks

Tic Tac Timelapse

A timelapse camera in a Tic Tac box.

 

Among my more questionable life choices is my regular participation (as part of The B-Team) in the 24 Hours of LeMons endurance racing series. We take old cars (many of which weren’t good when they were new), kit them out with roll cages and such, and race them all weekend. Good times are had by all. A friend of mine is half of the LeMons Supreme Court, and their job is to assign penalties to drivers/teams who do stupid things during the race. This generally involves public humiliation, and is pretty darn entertaining for everyone else. Anyway, one of the other things this chap does is attach timelapse cameras to competitors’ cars. He gets some pretty exciting on-track shots this way. He asked me to make something more disposable to help with this. The fact is, in a race this long and with this many cars (over one hundred is common), some swapping of paint is inevitable. Sooner or later, the camera will be in the wrong place at the wrong time. Why not try making something really cheap that, if crushed under the paws of a V8 e30, is no big loss?

He suggested the infamous “808” camera as a starting point, and after a little research, I was inclined to agree. The 808 is a keychain camera that is cranked out by the fu shipload in China, and they are ridiculously cheap. They can be found on eBay, and other places as well. The quality on them is awful (as you might imagine for that price) but they are quite hackable, and a subculture has developed around them. In actual fact, “the 808” is a series of around twenty cameras that are all quite different internally, and you don’t really know what you’re going to get when you order one. Each variation has its own quirks, but they all have fun “features” like unprotected battery charging and high lead content in the plastic. Good times.

Around the same time as this idea came about, the fine folks at Newark sent over some some signal relays for me to test. I love these things, because they make it really easy (and cheap) to hack a microcontroller on to any existing device in order to automate it. This would turn out to be very serendipitous timing, as we’ll see.

My thought was to take one of these 808 cameras, hack an ATtiny microcontroller on to it to make it into a timelapse, and shove the whole thing in a magnetic box that can be slapped on the side of a race car. Here’s how I went about doing precisely that.

 

Here's the camera I got from eBay for less than a cup of fancy coffee. Except for the flying cars, I think we officially now live in The Future.

Screws! Glorious hackable screws! No sonic plastic welding or snapping clips here.

Here's the guts. There's a tiny Lithium-Ion battery, a MicroSD slot, and... uh.. computery stuff. There are two buttons, power and "function" on the other side. The "function" button does a whole bunch of things, depending on when and how long you push it.

 

With the guts ripped out, I set about trying to figure out how to control this thing. The instructions are translated so poorly that they make for some delicious word salad . Here’s an unedited sample:

Enter the camera mode in turned off status long time press til yellow light on click the yellow light flash one time then take one photo. The product video recording same time with time display function canadjust the time according to their own

So… um… yeah. Your guess is as good as mine. Luckily, this website is a virtual encyclopedia of the 808 and it has a much better explanation. Without that information, it might have been quite difficult to figure out. All you have are two unmarked buttons, and a yellow light that blinks furiously at you in inscrutable patterns. It’s pretty tough to automate something when you can’t even figure out how a human is supposed to use it. The camera has a surprising number of special modes and features, so knowing exactly how to get the right behaviour is important.

With that sorted, it was time to try controlling it digitally. The aforementioned website has an article on using a microcontroller to drive this camera, but no part of those instructions worked for me. As I mentioned, the 808 is really a whole series of cameras, and while they appear identical on the outside, they seem to vary wildly on the inside.

I poked around at mine with some jumpers, and found that I could turn on the power by applying 5V to a particular pin on the power button. That’s great, because it saves a relay. The shutter button was not so cooperative, and refused to behave in any way except when bridged with a jumper. Clearly a signal relay would be needed here. Luckily, as mentioned earlier,  Newark had just sent me some! Huzzah!

The lithium battery had to go. The stock 808 has really poor battery life (under two hours) even for light usage. I’m going to be driving it hard and putting it away wet, so that won’t do. I need it to last for an entire 24 hour endurance race, and it should use batteries that you can find at a small-town convenience store. That’s frequently the only source of supplies at racetracks. I measured a peak of 180mA when the camera is writing to the SD card following a photo, so that means quite a bit of maH capacity will be needed. The SD card I’ll be using is 4GB, and the photos are quite low resolution, so storage isn’t a concern. The limiting factor is how quickly the camera will allow the shutter to be pressed. In my testing, that proved to be about four seconds. So, with the camera snapping a photo every four seconds for twenty four hours straight, we’ll need some serious juice.

With those details figured out, it’s off to the breadboard.

 

Here's my ATtiny13a driving a signal relay, and wired up to the camera. I've soldered jumpers to the old battery terminals, the upper right pin on the power button, and the two left pins on the shutter button. That's the minimum interface I could find that would do everything I needed. Getting rid of the old battery also means I can have everything on one power source, which will be convenient.

 

The circuit I ended up with is very simple:

Yep.

 

The code is equally trivial. The only tricks were figuring out the delay needed for the camera to start up, the delay between photos, and how long to push the shutter button. Here’s the code I ended up with to do that:

 

With that settled, I needed an enclosure. I decided to use a Tic Tac box for this. It’s a good size, and should be easy to modify.

Of all the flavors to choose from, I had to go with "powermint". Seems appropriate, and I'm a sucker for a portmanteau.

 

As soon as I saw the box, I knew I had to make the lid into an integral lens cap. It was too nifty to pass up. In order to keep the lens centered in the opening, I hacked a bit of plastic off an old cell phone cover and superglued it in place. It has an oblong opening that happened to fit the lens on the 808 nicely.

In order to align the lens with that hole, the camera's PCB has to be suspended in the middle of the box. To do this, I cut more plastic out of that old cellphone and made this bulkhead. It holds the PCB, and has a notch to hold the wiring in place as well. Then I figured out where the SD card slot on the camera would end up, and cut a hole in the Tic Tac box for access to it.

 

Next, I soldered up the control circuit. I opted to dead-bug it to save space.

 

I applied power and tested the outputs of the control circuit before hooking it up to the camera. It's always a good idea to test units in isolation before connecting them to each other. That way, if something goes wrong later, you have a lot less variables to worry about.

 

Then I hooked up the camera, and ran more tests. The camera's PCB is mounted into the lid of the Tic Tac box by filling the space around it with modeling clay, then covering it all in epoxy. This has the extra advantage of securing the small solder connections on the camera. Everything works, so we're ready for final assembly, right?

 

Well.... not quite. It seems that I neglected to flash the final version of my code on to the ATtiny before dead-bugging it into the circuit. Whoops! Luckily, my Bread Head programming header is compatible with standard logic probes, so I was able to reflash the chip in situ. Close call!

 

Here's the final assembly. You can see the battery pack (composed of six AAAs) wired underneath, and eight magnets attached to the top with JB Weld. I tested it like this, and it worked beautifully. Then I assembled everything, and.... it didn't work at all.

 

It seems like every project has that one little “gotcha”. Sometimes it can be a real killer, like the counterfeit chips in my EEPROM burner. Other times, it just makes you laugh. The camera behaved strangely when fully assembled. The power would come on, but instead of going into photo mode, the 808 was doing something I didn’t understand. The status light was flashing one of its wacky enigma patterns, and I couldn’t tell what was wrong. I pulled the case apart again to check for problems, and it started it working again. So… it works when outside the case, but not when inside. What’s different about being inside the case?

MAGNETS! (how do they work?)

Yes, in my infinite subgenius, I neglected to consider that perhaps a magnetic relay wouldn’t like living right next to eight strong magnets. Luckily, this problem was pretty easy to figure out, and I laughed out loud when the cause dawned on me. It’s just as well, because I was underwhelmed by the strength of the magnets. A race car is a very difficult environment, and they were not likely strong enough to hold anyway. It will need to be zip-tied in place.

It also occurred to me that the batteries are projectiles waiting to happen (not good on a racetrack), so the camera should be mounted with the battery pack face-down against the surface of the car. In light of all this, I opted to affix a lanyard to the new top of the camera to pass a zip-tie through. It’s made of more scrap plastic from that old cellphone. I secured it with JB Weld, and made sure it’s at the balance point of the whole device (with batteries installed), in case the user wants to hang it from something (like say, in the pit area).

 

Here's the final device! It should be easy to use. Just zip-tie it to a car using the handy lanyard, and turn on the switch. It will take a picture every four seconds for more than 24 hours straight before needing a battery or memory card swap.

 

Here's another angle, showing how the lens-cap works. If you look closely, you can see the lens in there. The cap is well clear of the camera's FOV in this position.

 

That wraps up the Tic Tac Timelapse. If my LeMons Supreme Court Justice friend ends up taking some nice shots with it, I’ll post them here!

 

 

 

Hacks