Wednesday, September 21, 2011

An Intro to Hardware Hacking for CS folk: Part 1, What's a microcontroller?

N.B. You can find a prelude to this post here.

Microcontrollers are everywhere. They engage the brakes in your car, open the doors of your building's elevator, and yes, cook the frozen dinner in your microwave.  But what are they, and how can you, the budding hardware hacker, take advantage of them? Hopefully this post will serve as an introduction to the most popular computing devices around.

Microcontrollers are part of the grander scheme of an embedded system. Embedded systems have the philosophy of doing only a few things, but doing them well. They are embedded into a device or service. For example, an embedded system inside a building's central A/C unit uses sensors to determine the current temperature, and from that data, calculates and sets the right fan speed and air flow to reach your desired temperature. A microcontroller is a computer-on-a-chip that does the calculation part. It has I/O pins to interact with the sensors and the fans, non-volatile programmable memory to hold the software that implements the cooling algorithm, some RAM for run-time scratch space, and of course a CPU to execute the software.

Realize, though, that this calculation is the only job this microcontroller has to do. It doesn't take 4GB of RAM to calculate the fan speed (I hope). Typical microcontrollers run at 1-100MHz, and have 2KB of RAM and 32KB of program memory. The microcontrollers that come with the TI LaunchPad developer kit only have 128B of RAM (yes, bytes). When the device's only job is to to calculate fan speed, or start a microwave when the user pushes "Go," though, 128B can be enough. You get some advantages on price and power consumption too. Try to find a Core i5 that costs 50 cents and uses micro-watts of power.

I hope that this gives a satisfactory introduction to what a microcontroller is. The question of how to use them is a bit more open-ended, though. The next post will look at how to develop for microcontrollers, specifically the Arduino, the most popular microcontroller development platform around.

No comments:

Post a Comment