Thursday, December 1, 2011

The Picaxe Microcontroller

Ok, maybe you’ve heard about the Arduino.  A lot of people think the Arduino is awesome.  The Arduino is a programmable microcontroller with a bunch of connection terminals, the serial programming bus, an led or two, a 5v regulator, an oscillator, and whatnot all soldered to a small circuit board.  This post is not about the Arduino.  This post is about the Picaxe microcontroller, which is seriously awesome.  I know you’re thinking, “Whoa!  Wait a second!  Let’s talk about the Arduino; that sounds pretty nice!” but I’m not going to do it.  I’m a Picaxe guy.
What’s a microcontroller? It’s an integrated circuit (those little pieces of black plastic with the legs you see soldered onto circuit boards) that you can connect to your computer and program to make decisions based on electrical input on some of the legs to output different electrical signals on other legs.  It will continue to do what you programmed it to do even after you disconnect it from your computer, whenever it has a 5v electrical source.  It remembers what you programmed it to do even after you remove the power.

Let’s say you want an LED to blink every time you push a button.  You would hook your microcontroller to your computer, run the programming software and program it to blink the output of leg #1 every time the input on leg #2 is detected.  Then you would disconnect it from your computer and solder an LED to leg #1 and a button to leg #2, hook it to 3 AAA batteries (4.5v is close enough) and POW!  You got your wish about the LED and the button you’ve been dreaming about all these years.  You can also make it do more complicated things, like adjust a bank of servos based on input from a 3 axis gyroscope to control some autonomous flying vehicle, or something more practical like controlling the pump and heating element in your hot tub based on a temperature sensor.

So there’s like dozens of microcontrollers.  Maybe hundreds or even thousands.  I don’t know.  Why the Picaxe?  Let me tell you why:
1) It was designed to be used in education.  You program it in the Basic programming language, which is intuitive and easy to learn.  I taught myself Basic when I was in the 7th grade (on the TI 99/4A, which is also awesome) and it’s still the only programming language I know.  It’s also a bare chip, unlike the Arduino, which has tons of external components soldered to it already.  This means you have to learn to solder, when to use pull-up resistors, a thing or two about power supplies, and lots of other things that you really need to know to fully embrace electronics.  The Arduino is practically a device, as opposed to a component.
2) It’s fast.  The slower ones operate at 32 MHz.  MEGA Hertz.  It can perform 32 million tasks per second.  That’s slow for a microprocessor (like in your computer, that’s doing a lot of math) but crazy fast for whatever you need a microcontroller to do.  32 MILLION!
3) It’s cheap. The most basic model costs $2.95 from Sparkfun (Sparkfun is also awesome).  Yeah, you could blink that LED with a 555 timer IC from Radio Shack for $1.99, but seriously.  What if you want your LED to blink slower?  You’ve got to de- and re-solder your resistor and capacitor that sets the blink time on the 555, but you can just hook that Picaxe back up to your computer and adjust your blink rate to the millisecond.  An Arduino costs $30, so that's a lot more.
4) It's small. It seems like most of my projects need to fit inside something small, like 1" tube, or a wooden railroad train, and the Picaxe fits just right.  You can get surface mount microcontrollers that are a lot smaller, but so far I haven't needed anything that small.

So, is it the greatest microcontroller of all time? Probably not, but it is super easy and accessible, cheap, and very powerful.


Here's the datasheet: http://www.picaxe.com/docs/picaxe_manual1.pdf
Here's Sparkfun's product page for the most basic model: http://www.sparkfun.com/products/10803

No comments:

Post a Comment