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

The Basics - Microcontrollers (part 2)


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.

This is part two of this article. Check out The Basics - Microcontrollers for the first part of this article.

I/O Ports

One important distinction between a Microcontroller and a Microprocessor is that a Microcontroller usually has special hardware for dealing with the outside world. These are called input/output lines, or I/O lines. We normally use I/O lines to interface the Microcontroller to sensors or actuators. For a discussion about different types of sensors, check out The Basics - Sensors.

Part of the mix of knowing which Microcontroller to choose is having a feel for the number of I/O lines you are going to need. Most microcontrollers will have at least 8 digital I/O lines. Some, such as the 68HC812A4, have 96 I/O lines. It is pretty common to find Microcontrollers with between 12 and 32 I/O lines for your use. .

Take a quick look at the diagram for the 68HC11:

This diagram shows that there are several PORTS. A common way to describe a grouping of I/O lines is as a port. The 68HC11 has 40 I/O lines, arranged into five groupings of 8. Not all ports are equal, and the term I/O port doesn't really do justice to reality. Some of the ports, such as port E (PORTE) are input only. PORTB is output only. PORTC is called a bi-directional port, and can be programmed as input or output. PORTD is also programmable as input or output, but only 6 of its bits are useful to the programmer. PORTA is split between input and output.

When looking at a chip, the number of I/O pins isn't quite as important as the types of I/O pins and how they can be used. As you can see by disecting the 68HC11, many of the pins are special purpose. For example, PORTA is usually reserved for use with the timer module. PORTE is where the A/D converter is located. PORTD holds the serial port and the SPI port. These are all great features, and you should plan on using them. However, you need to take into account that these features use up I/O pins.

Another important one to watch for is the difference between single chip and expanded modes. If you are planning on using external RAM, most Microcontrollers will support that. However, the interface to that RAM normally uses up two or more I/O ports. In the case of the 68HC11, PORTB and PORTC are used as the memory bus in expanded mode.

Whats good in I/O lines?

Here are the useful features when building a robot:

What are some good chips to look into?

There are several 'familys' of chips out there. The 68HC11, the 68HC12, PIC, and the 8051 are some extremely common ones. Each family usually has a number of variations. The 68HC11, for example, has about 12 variations. The PIC family has 30 or so.

A special note about the 8051. The 8051 started life as an Intel processor, and of course still is. Intel has licensed the rights to the chip to other manufacturers. The 8051 based processors have been around for a very long time. There are easily 300 different chips from about 10 manufacturers based on the 8051. You can get just about any configuration of an 8051 that you want. Most all of the support the same 8051 architecture. You will find that Intel, Philips, Siemens, and Dallas are the popular 8051 based chip makers.

Most engineers are partial to one family of chips. The debate about which chips are 'best' is a hot button issue with many people. The important point to remember is that all chips have strengths and weaknesses.

On the other hand, I am going to tell you my biased, yet very objective opinions about a few of the popular chips.

The Motorola 68HC11 family

The 68HC11 has been around for quite a while. It has an excellent reputation among robotics engineers because it has a good mix of peripherals such as its timer module, onboard serial ports, etc. One of the best features is the ability to set the chip to start in 'bootstrap' mode. This allows you to download software to the onboard RAM and EEPROM via the serial port, thus avoiding the need for expensive programming hardware. There is a lot of support software available for free. The chip costs from between $6 to $20, depending on the specific hardware selections.

The 68HC811E2 is an extremely popular version of the chip. It has 2k of EEPROM, and 256 bytes of RAM. The chip comes in a 52-pin PLCC package.

Motorolas MC68HC11 Home Page

Karl Lunts Tips and techniques Page

BOTBoard Information

The Motorola 68HC12 family

The 68HC12 is a very new chip. In fact, it is still in final testing stages though it is available for purchase. Its internal architecture is similar to the 68HC11, but it runs much faster and has a much more powerful instruction set. Its an easy step up for those familiar with the HC11.

There are two known versions of the chip. The 68HC812A4 and the 68HC912B32. Both share the same CPU core with slightly different peripherals and memory configurations. The 68HC12 family also has a very cool debugger interface which allows you to debug software using some support hardware.

The 68HC812A4 has 4k of EEPROM, 1k of RAM, and a whopping 96 I/O pins, including A/D, a good timer module, two serial ports, and a host of other cool things. It comes in a 112 pin quad flat pack.

The 68HC912B32 is still in development, but samples are available. It has 32k of Flash EEPROM, 1k of RAM, and 768 bytes of EEPROM. It is in a 88 pin quad flat pack.

Here are some links for more information:

Motorolas MC68HC12 Home Page

68HC812A4 Development Board

BDM Interface Board Specification

The PIC family

Microchip has a set of controllers based on the PIC architecture. (See The PIC Chip Uncovered in a previous Encoder). There are quite a few variations on the chip, and more are added every month or two.

The PIC is a great chip for small robots that don't have many sensors, and for dedicated subsystem work. I have used them in my own products before. However, they can be a real challenge to program, and don't have the abundant resources that some of the other chips on this page do. I really like the PIC, but it is not a great general purpose microcontroller. I wouldn't recommend them to a beginning builder. I do recommend them to anyone who has at least some experience, and is looking for a small, low power, very fast dedicated controller.

Microchips product support is excellent, and they have invested a lot of time and effort into producing really good technical application notes, and have all their information available on the web. As far as chip companies go, Microchip does an outstanding job.

Microchip Home Page

The 8051 derivatives

I have done work with the 8051, 8031, and 87C750. All are capable chips. The 8051 architecture has a very nice boolean processing unit that allows you to address certain ranges of memory as bits as well as bytes. It is, in my experience, a unique and often times useful feature.

Another great plus for the 8051 family is the shear number of chips available. Many different manufacturers have 8051 based parts, and it isn't too difficult to find information on the web. There are chips with almost every concievable set of peripherals onboard. Some are readily available, some are not. You can even get chips such as the 8052BASIC chip, which have an onboard BASIC interpreter.

The 8051 architecture does have its drawbacks. The memory map is a little confusing at first. They have set aside the first 128 bytes of memory for Register Banks, Bit Addressable Areas, and the Scratch Pad area, which is normally used for the stack. The stack is also limited to being in addresses $30 thru $7F and competes with variable storage unless you add external RAM. This is a backward compatible architecture that is somewhat outdated, especially if you want to use a higher level langauge such as C.

The 8051 family is worth a look mostly because of the number of different chips out there.

Intel MCS 51/151/251 Microcontrollers

Philips Microcontrollers: Main Page

Siemens Microcontrollers

Dallas Semiconductor Corp: Microcontroller Products

In Summary

Microcontrollers are complex little machines. There are lots of considerations you should think about when choosing a controller for your project. Doing some investigating before you decide. The internet is full of great information, free software, application notes, and of course opinions for all of the different Microcontroller families.

 


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