June 25, 2011

Stereo Camera rig


This is something I've been wanting to try for awhile: I'd like to take pictures I can use with an old-school stereoscope. It seems like a simple enough idea: you just need two pictures of the same thing, taken from a few inches apart. I've seen it done with just two cameras —no external synchronization, just push both buttons at the same time — but it seemed like I could probably synchronize things a bit better than that.

Ideally, it would be perfect to set things up so that one camera was a master and the other a slave: exposure and zoom parameters would be set on the one, which would then be duplicated on the other. The Canon Hack Development Kit (CHDK) gave me some hope that this might be doable, but I haven't found any straightforward way of setting up a master/slave relationship, so instead I used cruder methods. The cameras use a CHDK script to time how long power is applied to the USB connectors, and depending on the pulse width the cameras either zoom in, zoom out, or shoot.

The pill-bottle on the left contains a 4-AA battery pack, 5V regulator, some buttons, and an ATtiny85 to convert button presses to appropriate-length pulses for the cameras. It's not ideal, but it does give me synchronized zoom and shoot capacity using the one set of controls on the pill-bottle.

Here's the code for the cameras, and here's the code for the ATtiny85. One thing I found out by extensive trial and error is that the signal at the USB connector must be 5V. Less than 4.5V does not work, at least on these eBay-special A590is cameras.

I still think there should be some way of having one of the two cameras tell the microcontroller its settings, and have the microcontroller set things to the same values on the second camera. That would allow much easier use of the excellent controls available on the A590is camera. But someone else will have to figure that one out. Send me a link if you know of someone who's successfully managed this!

June 21, 2011

Morse-code trainer

My kids are learning Morse code this summer, so I threw together this little circuit to help them learn. And to make it more fun...
It uses an ATtiny85 ($2.26 at digikey.com) to drive a piezo beeper (≈ $3.50 at Radio Shack.) The ATtiny85 takes 5.5V max, so I built the circuit on a piece of strip-board so as to fit onto the back of a 3-AA-cell ($3 or so at Radio Shack) battery pack.
To program it, I used MIT's "High-Low Tech" ATtiny85 core using an Arduino as an ISP programmer. I actually built a 6-pin ISP header into the board, so I don't have to pull the chip out to reprogram it as you would with MIT's instructions, but that's neither here nor there. Using an Arduino core allows me to  use all the Arduino tools I'm familiar with, but I don't have to spend $20 or more on a full Arduino when all I really need is one output pin and a couple kb of program space. The ATtiny85 is perfect for this: plenty of memory and dirt cheap. (Actually, an ATtiny25 would work with the amount of memory this program takes, but ATtiny85s are so cheap you don't save much buying the ATtiny25.)

Here's the code. When the device is powered up, it waits 3 seconds then puts out the message at the desired speed. The message repeats until power is removed. Currently the message is "SOS the moon rover has broken down and I am stuck in the trash can in the garden shed." Once the kids decode it, they'll find a small Lego moon rover there as a prize.

Changing the speed of the Morse output is easy: just increase or decrease the definition of DOTLENGTH and everything adjusts proportionally. Changing the message is equally simple: just change the value of message[] in the source code. As written, it can handle up to 255 characters in the message. The program can handle upper/lower case, numbers, and some punctuation.

The program will also work with an Arduino, of course. You can even change the value of OUTLINE to 13 and the Arduino will use the built-in LED. (No circuit required, just a bare Arduino!)

I know Morse code is pretty much obsolete now. You don't even need it for a ham license any more... but all the more reason to learn it! 

.... .- ...- .  ..-. ..- -.  .-- .. - ....  .. -  .- -. -..  . -- .- .. .-..  -- .  .. ..-.  -.-- --- ..-  ..- ... .  .. - .-.-.-