Monday, January 5, 2009

Junkbot

I started building Junkbot a couple of years ago. At the time, I wasn't very familiar with microcontroller programming, digital circuitry, or much of anything related to prototyping circuit boards. I did, however, have a decent background of assembly programming for embedded systems (mostly 68k and Z80) and I knew my way around a soldering iron.

I decided to embark upon building Junkbot as my first foray into the wild and woolly world of microcontroller programming. I had several goals that I wished to meet when Junkbot was complete.

  • The robot needed a remote camera. Honestly, it didn't *need* a remote camera, but the thought of driving the robot around without being able to see it was pretty freaking appealing. Not to mention the coolness factor goes up ten fold.
  • I also wanted to create an interface to the robot that was easy to use. Joysticks are fairly simple, but I wanted a digital interface with an LCD screen. (More coolness factor)
  • I wanted Junkbot's range to be around 100ft or so. I ran into some noise issues with the wireless serial comm link I used with the system, but was able to fix them early on.
  • Junkbot had to look like I built it out of a pile of junk (hence the imaginative name). I used an old license plate (which by the way, is wonderful project material) to create Junkbot's chassis. The license plate is from Ohio, where Sara and I hark from. Go Bucks!
  • I also wanted to use my mad assembly language programming skillz to create the control interface. This turned out easier than I expected due to the excellent AVR Studio 4 programming suite provided by Atmel. The studio includes a strong debugger / simulator for their processors. This functionality is vital when your ability to debug with blinking LEDs hits a wall. :)

So, after looking at these goals and deciding how it was going to fit together, I promptly got frustrated and watched some mindless television (Stargate, w00t!). Seriously, this project was way bigger than I expected and I was not nearly prepared for it. So, I hit the internets to search for a proper introduction to microcontroller programming.

Ask the interweb and you shall receive. The goldmine for setting up an AVR microcroller with power and the proper (magic) oscillator crystals was on SparkFun. I was flabbergasted at how easy the was to read and comprehend.

(me discovering sparkfun electronics)

Seriously, I may have posed that shot for fun but that's exactly how it went down at the time (ask my wife). SparkFun is really that good.

Onward! After reading the embedded electronics tutorials straight through in one night, I had an epiphany. The building tools I owned were ehh... kinda scary for everyday usage. While I could certainly use the soldering irons I own to embed my initials into plastic or wooden stuff, going for broke on Junkbot's brains really seemed like a bad idea. (Look at 'em, just waiting to burn down my house...)

My first step was to gather the proper tools for the job. Screwdrivers, tin snips, tweezers (very important!), a grossly over-powered calculator, and some serious Mt. Dew supplies got me pretty far. However, in order to get into the neat stuff, I needed some specialty items.

First and formost, I got a solderless breadboard. These things are freaking great! They allow you to prototype a circuit without the hassle messing with solder. Check it out, here's a picture of my 3M solderless breadboard stuck in the middle of a project that uses an LCD.

As you can see, each component is connected via wires instead of solder. Solderless breadboards simple really. You only need to master one principle: wires go into holes. Easy, eh? Some holes are connected to other holes and allow you to interconnect components that sit in the holes waiting for power. Using the breadboard instead of actually soldering up a circuit makes life significantly easier during the debugging phases of your project. (And trust me, you will be doing a lot of debugging if you intend to take up this hobby.)

The information in the SparkFun tutorial was dead on and soon I found myself with an 8bit 16MHz AVR Atmega8 processor that was powered by a big 'ole stack of AA batteries (actually, just 4 of them since AA's are 1.5V apiece and I needed at least 6V for the 5V voltage regulator). This circuit is actually very boring. I had built the neato power circuit outlined in the SparkFun tutorial, but since I had no way of interacting with the processor, it just sat there. I needed software and a programming cable capable of speaking AVRese.

Luckily for me, there is tons and tons of information on how to build a cable for programming an AVR without spending too much money (good for me cause I'm cheap!) There is also excellent free software to program said AVR processors for Linux, Windows, and MacOS.

(cheap, cheap, cheap)


I decided to build a cheapo parallel programming cable. Now, had I realized what a pain it was going to be to debug this board, I probably would have flung frugal caution into the wind and bought the capable serial programmer from SparkFun for $12 (which, incidentally, I now use). I mean, geez, look at all those wires coming out of the parallel interface…

With the programmer built, I moved on to finding an application that would read my compiled code and send it on to the AVR to be run in realtime. I quickly stumbled across PonyProg. I had trouble getting the software to program my processor at first, but this was due to the cable and not the software (see the previous paragraph).

Now I was able to write programs in C, compile them using GCC for AVR processors and write the compiled program to the microcontroller. My next step was to find a way to interact with the processor. According to the SparkFun tutorial, the simplest way to interact with a microcontroller is to blink and LED. Not exactly an amazing feat, but I certainly got a good feeling once I got the LED to blink off and on at 20hz.

I will continue this post later this week with my crazy adventures in metal shaping and servo control.

1 comment:

  1. so here is the question that all us nerds are really asking...can junkbot with camera be used to look up coeds skirts???

    ReplyDelete