Robotics/Computer Control/The Interface/Microcontrollers

From Wikibooks, open books for an open world
Jump to: navigation, search


Microcontrollers are the core of many robots. They have considerable processing power packed on to one chip, allowing lots of freedom for programmers. Microcontrollers are low level devices and it is common to program them using an assembly language, this provides a great deal of control over the hardware connected to the controller. Many manufacturers also provide high-level language compilers for their chips, including BASIC and C.

What's the difference between a microcontroller, microprocessor, and a CPU ? The CPU is the part which actually executes the instructions (add, subtract, shift, fetch, etc.).

A microprocessor is any CPU on a single chip.

A microcontroller is a kind of microprocessor, because it includes a CPU, but it typically also contains all of the following components on the same single chip:

  • (discrete) inputs
  • (discrete) outputs
  • ROM for the program
  • RAM for temporary data
  • EEPROM for non-volatile data
  • counter/timer
  • clock

Some microcontrollers even include on board Analog-to-Digital converters (ADCs). This allows analog sensors to be directly connected to the microcontroller.

With this capability, microcontrollers are quite convenient pieces of silicon.

The outputs of a microcontroller can be used to drive many things, common examples include LEDs and transistors. The outputs on a microcontroller are generally low power. Transistors are used to switch higher power devices (such as motors) on and off.


All CPUs are useless without software.

Most software for a PC is stored on the hard drive. But when you first turn one on, it starts executing the software in the boot ROM. If you wanted to change that software, you would have to pull out the ROM chip, program a new ROM chip (in a "chip programmer"), and then plug the new chip into the PC.

Most robots don't have a hard drive -- all their software is stored in ROM. So changing that software is exactly like changing the boot code of a PC. (If your robot has an external ROM chip, then that is the one that is pulled and replaced. If your robot uses a microcontroller with internal ROM, then the microcontroller is pulled and replaced).

Many recent PC motherboards and microcontrollers use Flash instead of ROM. That allows people to change the program without pulling out or putting in any chips. They can be rewritten with new data, like a memory chip, but permanently, and only a certain number of times (10,000 to 100,000 erase/write cycles).


Here are a few pages about specific µcontrollers:

Further reading[edit]