Friday, June 1, 2012

AVRcam Resurrection

AVRcam right, my SMT version lower left, OV6620 camera.
If you've never heard of it, the  AVRcam tracks multiple color blobs, up to 8 colors simultaneously, at 17fps. It uses an ATmega8 processor. By contrast, the CMUcam1 with a 75MHz SX28 only tracks a single color and a single blob at 17fps.

John O., maker of the AVRcam, was kind enough to send to me what I believe to be the last unpopulated AVRcam on Planet Earth. So don't bug him for more. Meanwhile, I've gotten it working and created a much smaller SMT version.

Wait a second... What?!  An ATmega8 with 1K of SRAM running at a molasses slow 17MHz spanks the snot out of the famous, lauded, widely used CMUcam and it's 75MHz processor?!

How is that possible?!

It's possible because of some amazing real time embedded programming skills on John's part, that's how. One major efficiency is that the ATmega8 and camera both run on the same clock so there's no synchronization code for grabbing data.

The event-driven software is cleverly written to process incoming requests while also running the camera. Various memory-saving and time-saving approaches are used. I hope to apply some of these techniques to my future camera projects.

The Original

So anyway, here's a picture of the original board tracking some Sparkfun boxes on my desk.

The original AVRcam used all through-hole components, the majority of which I had in my stash o' parts. All that I needed to buy was an ATmega8.

The firmware in source and hex format is still available for download. I programmed the MCU with my Pololu AVR Programmer using AVRdude (I could've used AVR Studio 4, too).

avrdude -p m8 -P COM9 -c avrispv2 -e -U flash:w:AVRcam.hex

Next, I set fuses so the Mega8 would use the external clock from the camera board. Set fuses as follows: low fuse=0xFF, high fuse=0xCF which equates to:
  • BOOTSZ set to size=128 words, address $0F80
  • CKOPT checked, and 
  • SUT_CLKSEL set to Ext Crystal/resonator High Freq, Startup Time 16K CK + 64 ms.

I programmed the fuses in AVR Studio 4.

The original design calls for an ATtiny12. For giggles I ported the code over to an ATtiny13. That went fine but my attempt to port the main code to an ATmega328P has failed thus far.

The Bot Thoughts SMT Version

The SMT version uses 0603 passives, a SOT-23 transistor, and a QFP version of the Mega8. I kept the 8PDIP ATtiny13 and socketed it for easy programming. The Mega8 programs through a 6-pin AVRISP connector. The new board is just slightly larger than the camera board that plugs into it..

After checking, fixing, and rechecking, the Gerbers went off to DorkbotPDX PCB ordering.

The crystal and caps were insurance for programming; not needed.
The boards came back a few weeks later, coincidentally on the same day a red package arrived with SMT tweezers from Sparkfun.
These tweezers make board assembly 4.87e8 times easier!
I previously used curved needle-nose pliers to pick up tiny parts and a nail to hold them down. That really sucked. I might as well try needlepoint with mittens and a railroad spike. The tweezers made short work of the SMT population.

The beautiful red glow of success.

I updated the AVRcamVIEW application as well, so that I could easily configure the camera and observe its tracking behavior.

So, now I'm all set to locate and track all kinds of, oh, I don't know, giant red barrels??

Well, except that I have to interface the camera to the mbed on Data Bus...

All source, CAD Files: bot-thoughts-avrcam


  1. It looks like we're thinking along the same lines. The CMUCAM4 (based on Arduino) just recently became available and mine should show up today, or tomorrow. I'm still not sure if I'll be able to use it in my car, but machine vision does offer some interesting options.

  2. @Wayne -- nice!! Best of luck. If you want to swap thoughts and ideas, let me know. Two weeks isn't much time to get vision working, solo. :)

  3. Thanks. I wasn't planning on even working on obstacle avoidance until I saw that Sparkfun recently announced that they "may" move the barrels around. So, yeah, not much time left. Best of luck with Data Bus.

  4. Michael,
    Your SMD implementation of that is a thing of beauty. DAMN nice work.

    The tweezers... I have 4 pairs of those. 2 curved and 2 straight. They are THE TOOL for picking up and manipulating SMD parts. What I do is have a curved and a straight on each side of my workspace. Whatever I need is right there.

  5. Michael,
    The link for source+CAD files is not update, I don't find any files to download in it

  6. Mickael,
    I'm there with subkhan. Are you going to publish the CAD files and source code? I'd like to build several of these - in fact, if you wish to sell them I could build some up for you. I have a small CM shop but am venturing into robotics. I've been working with ATMega's and Arduino's for a while, but have recently switched to the MBed1768 platform. Do you think this design could be ported to the MBed? A friend of mine is doing a stereo board on the Raspberry Pi, but that processor is pretty slow - too slow for a hough transform, for example. An MBed might be able to do both blob and edge detection, so stereo vision might work. What are your thoughts?

  7. It's all there just click the source tab then click browse then find trunk and click that. Hope this helps!