Encoder Front Page
SRS Home | Front Page | Monthly Issue | Index
Search WWW Search seattlerobotics.org

The Basics - Microcontrollers (part 1)

New robot builders have many decisions to make. One important one is how to put their creation into motion doing something interesting. Eventually, the choice has to be made about which Microcontroller to base their robot on (if any at all!). This article is going to describe some of the basic features of the Microcontroller that newer users may not know about. I will then discuss some of the tradeoffs in choosing a particular Microcontroller.

Microcontroller 101

So, what does a Microcontroller do? Most Microcontrollers are general purpose Microprocessors which have additional parts that allow them to control external devices. We often use the terms Microcontroller and Microprocessor interchangably.

A designer will use a Microcontroller to

  1. Gather input from various sensors
  2. Process this input into a set of actions
  3. Use the output mechanisms on the Microcontroller to do something useful

The 'general purpose' attribute of a Microcontroller is very significant, and shouldn't be overlooked. A general purpose Microcontroller is a very powerful tool that allows a designer to create a special purpose design. The design becomes partially hardware and partially software. There is great flexibility in the software end, as the designer can create practically unlimited variations on the design by changing the software.

A Microcontroller has several major sections that are pretty typical no matter which type or version of Microcontroller you end up using. Talking about Microcontrollers in the abstract is going to be pretty boring, so I am going to focus this section around the Motorola MC68HC11. I will discuss alternative chips later in the article.

CPU Diagrams

One thing you will see often are CPU diagrams. Usually, these are done as block diagrams to help you see how the different sub-systems on the chip fit together. Its kind of like a road map. Here is such a diagram for the 68HC11.

This overall diagram is very helpful for trying to locate major features of a chip. For example, I can see from the map that there is an A/D converter, and it is connected to PORT E. I also see that there is EEPROM, RAM, and ROM available on the chip. It also tells me that PORTC is a bidirectional port, and PORTB is a output only port. Most chips will come with some sort of documentation along these lines. You can expect to find a block diagram like this near the front of most manuals.

You can often find manuals online in PDF files, such as http://freeware.aus.sps.mot.com/hc11/home.html for the 68HC11 or http://www.mcu.motsps.com/hc12/home.html for the 68HC12. Or, if you prefer a nice book, most companies will send you literature for free. Motorola has an online service at http://design-net.com/home2/lit_ord.html which is an automated system were you can order books.

The CPU core

The CPU core is the 'computer' part of the Microcontroller. Its job is to run the program supplied by the designer. It does this by using memory, some registers, and the program memory. As seen in the block diagram above, the M68HC11 CPU is called out as a subcomponent of the chip as a whole. There is a reason. Most Microcontrollers are available in multiple versions. Each version will have its own interesting set of features. The 68HC811E2, for example, is a chip with the 68HC11 CPU at its core, but 2k of EEPROM and some extra timer options. The 68HC11A1 has 512 bytes of EEPROM, and 256 bytes of RAM. It is quite typical for manufacturers to put out multiple versions of the chip, so you need to know which version you are dealing with!

Memory Types

Microprocessors come with several different types of memory. The amount of memory on a single chip varies quite a bit by manufacturer. Typically, 512 to 2k of program space and 256-512 bytes of RAM are available.

There are memory options available. I will give you a brief overview of each.


RAM means Random Access Memory. It is general purpose memory that can store data or programs. RAM is 'volatile', which means when the power is shut off, the contents of the memory is lost. Most personal computers have several megabytes of RAM. Most microcontrollers have some RAM built into them, but not very much. 256 bytes is a fairly common amount. Some have more, some have less.


ROM is Read Only Memory. This is typically memory that is programmed at the factory to have certain values. It cannot be changed, but it can be read as many times as you want. ROM is typically used to store programs and data that doesn't change over time. Many Microcontrollers have lots of ROM. Unfortunately, unless you are ordering thousands of parts, the ROM is useless to you, and in fact is wasting address space. Most individuals stay away from controllers with lots of ROM.


EPROM is Erasable Programmable Read Only Memory. This is ROM that can be field programmed using an EPROM programmer, which is a special device that takes your program information and programs (often called burning) the EPROM. To erase an EPROM, you need an EPROM eraser. This is usually a small box that has a strong UV light bulb. You place the EPROM part into the box for several minutes. The UV light causes the program to be erased. Most EPROM chips have a small clear window into the chip. This is for the UV light to pass through. EPROM devices range from 8kb to 32kb. Bigger versions are available, but not usually used on Microcontrollers.

There are EPROM chips that are not 'windowed'. A more correct term for this is PROM or OTP (One Time Programmable) packages. You will typically find that windowed parts usually cost more. The Microchip PIC series of processors are a well known OTP chip. For example, a PIC16C61 costs about $7, and the windowed version of the PIC16C61 costs about $15. OTP parts are great if your design is done, and you never intend to change the program again.


EEPROM is Electrically Erasable Programmable Read Only Memory. Yes, the acronymns are getting long! EEPROM is extremely useful for a variety of uses. For example, when you save configuration information on many household devices, the information is commonly written into EEPROM. EEPROM can also be 'programmed' from software, so you typically do not need to remove the part from your circuit to reprogram it. This is a big advantage. It typically takes about 10 milliseconds to write each byte of EEPROM.


Yet another version of the EEPROM, Flash memory programs much faster. A byte may only take a few hundred microseconds to program. That is an advantage over EEPROM. However, Flash memory typically requires you to erase the entire contents before you can program it. Flash EEPROM usually comes in large quanities. The 68HC912B32, for example, is a single chip controller with 32kb of FLASH EEPROM on the chip!

Summarizing Memory:

Excuse the pun, but the different types of memory is just too much to remember! In summary: RAM is good. EEPROM is good. EPROM requires programming hardware. ROM is mostly useless. Flash EEPROM is OK.

Next Time:

In the next issue, I will discuss I/O ports and some other great features.


What else do you want to know? Send me mail and ask away. Kevin Ross