What are microcontrollers? They are what their name suggests. Today they can be found in almost any complex electronic device – from portable music devices to washing machines to your car. They are programmable, cheap, small, can handle abuse, require almost zero power, and there are so many variaties to suit every need. This is what makes them so useful for robotics – they are like tiny affordable computers that you can put right onto your robot.
Augmented Microcontrollers and Development Boards
In a pure sense, a microcontroller is just an IC (integrated circuit, or a black chip thing with pins coming out of it). However it is very common to add additional external components, such as a voltage regulator, capacitors, LEDs, motor driver, timing crystals, rs232, etc to the basic IC. Formally, this is called an augmented microcontroller. But in reality, most people just say microcontroller even if it has augmentation. Other abbreviations would be ucontroller and MicroController Unit (MCU). Usually when I say microcontroller what I really mean to say is augmented microcontroller.

As a beginner it is probably best to buy an augmented microcontroller. Why? Well because they have tons of goodies built onto them that are all assembled and debugged for you. They also often come with tech support, sample code, and a community of people to help you with them. My microcontroller parts list shows the more popular types that you can buy. They tend to cost from $30 to $150 depending on the features. This will give you a good introductory to microcontroller programming without having to be concerned with all the technical stuff.
In the long term however you should build your own augmented microcontroller so that you may understand them better. The advantage to making your own is that it will probably cost you from $10-$30.
Between getting a full augmented board and doing it yourself is something called a development board. These boards come pre-augmented with just the bare basics to get you started. They are designed for prototyping and testing of new ideas very quickly. They typically cost between $15 and $40.

What comes with the IC?
There is a huge variety of microcontrollers out on the market, but I will go over a few common features that you will find useful for your robotics project.
For robots, ore important than any other feature on a microcontroller, is the I/O ports. Input ports are used for taking in sensor data, while output is used for sending commands to external hardware such as servos. There are two types of I/O ports, analog and digital.
Analog Input Ports
Analog Ports are necessary to connect sensors to your robot. Also known as an analog to digital converter (ADC), they recieve analog signals and convert them to a digital number within a certain numerical range.
So what is analog? Analog is a continuous voltage range and is typically found with sensors. However computers can only operate in the digital realm with 0s and 1s. So how does a microcontroller convert an analog signal to a digital signal?
First, the analog is measured after a predefined period of time passes. At each time period, the voltage is recorded as a number. This number then defines a signal of 0s and 1s as shown: 
The advantage of digital over analog is that digital is much better at eliminating background noise. Cell phones are all digital today, and although the digital signal is less representative than an analog signal, it is much less likely to degrade since computers can restore damaged digital signals. This allows for a clearer output signal to talk to your mom or whoever. MP3s are all digital too, usually encoded in 128 bit. Higher bit rates obviously mean higher quality because they better represent the analog signal. But higher bit rates also require more memory and processing power.
Most microcontrollers today are 8 bit, meaning they have a range of 256 (2^8=256). There are a few that are 10 bit, 12 bit, and even 32 bit, but as you increase precision you also need a much faster processor.
What does this bit stuff mean for ADC? For example, suppose a sensor reads 0V to an 8 bit ADC. This would give you a digital ouput of 0. 5V would be 255. Now suppose a sensor gave an output of 2.9V, what would the ADC output be?
Doing the math:
- 2.9V/5V = X/255
X = 2.9*255/5 = 148
So how do you use an analog port? First make sure your sensor output does not exceed your digital logic voltage (usually 0V -> 5V). Then plug that output directly to the analog port.
This bit range could also be seen as a resolution. Higher resolutions mean higher accuracy, but occasionally can mean slower processing and more succeptability to noise. For example, suppose you had a 3 bit controller which has a range of 2^3=8. Then you have a distance sensor that outputed a number 0->7 (a total of
that represents the distance between your robot and the wall. If your sensor can see only 8 feet, then you get a resolution of 1 bit per foot (8 resolution / 8 feet = 1). But then suppose you have an 8 bit controller, you would get 256/8=32 ~ 1 bit per centimeter – way more accurate and useful! With the 3 bit controller, you could not tell the difference between 1 inch and 11 inches.
Digital I/O Ports
Digital ports are like analog ports, but with only 1 bit (2^1=2) hence a resolution of 2 – on and off. Digital ports obviously for that reason are rarely used for sensors, except for maybe on/off switches . . . What they are mostly used for is signal output. You can use them to control motors or LEDs or just about anything. Send a high 5V signal to turn something on, or a low 0V to turn something off. Or if you want to have an LED at only half brightness, or a motor at half speed, send a square wave. Square waves are like turning something on and off so fast that its almost like sending out an analog voltage of your choice. Neat, huh?
This is an example of a square wave for PWM:
These squarewaves are called PWM, short for pulse width modulation. They are most often used for controlling servos or DC motor H-Bridges.
Also a quick side note, analog ports can be used as digital ports.
Trackback URL for this entry