Microcontrollers

Microcontrollers are single chip computers that slow, have very little memory, but are cheap and very easy to interface to real world devices. They are present in most electronics these days, from microwave ovens to televisions. They are typically programmed in either C or assembly language, though for this workshop you will not need to program them. We have written a monitor program called ez-mon that allows the user to send commands from a PC to the microcontroller, either to control devices (lights, motors, etc.) or to read data from devices (temperature sensors, buttons, etc.)

Such interfacing is done through the microcontroller's I/O pins (input/output pins). A microcontroller can take actions in the world by changing the voltages of its output pins. Output pins typically take on two discrete voltages (usually 0 and 5 volts). Each output pin reflects the value of some bit in the microcontroller's memory. When the bit is set to 1, the pin goes to 5 volts, and when the bit is set to 0, the pin goes to 0 volts.

A microcontroller can sense the world through its input pins. Input pins are either digital or analog. Digital inputs are the opposite of digital outputs - they expect to be set to either 0 or 5 volts by some external device. For each digital input there is a bit in the microcontroller's memory that reflects its value.

Analog inputs are more flexible than digital inputs. They can be set to any voltage between 0 and 5 volts by some external device. Typically, an analog input has a byte in the microcontroller's memory that reflects its voltage - 0 volts maps to 0, 2.5 volts maps to 128, and 5 volts maps to 255 (since 255 is the maximum value a byte can take on.)

In this workshop we use the Motorola 6811 microcontroller. The 6811's I/O pins are divided into groups of eight, called ports. There are three ports:

Each port has a corresponding byte in the 6811's memory. The digital input and output pins are actually the same pins, and can be programmed to take on either role. Why does Port C correspond to eight bytes instead of one? Because the 8 analog inputs are selectable - at any time, only one analog input can be read, and it is that analog input to which the Port C memory byte corresponds.

These ports can be accessed easily through ez-mon.


Pushpinder Singh <push@mit.edu>