Doug Leppard (DLeppard@CCCI.Org )
Benjamin Leppard (Benjamin@Leppard.Com)
This is the second in a series of articles outlining the steps we have taken to build our robot. Both Benjamin and I are newbies at this and thus this article will be written for newbies. These articles are focused on a robot that will compete in the Fire Fighting contest, be able to roam around the house and that will be a fun learning tool. The 68HC912B32 is our processor, so articles will be on interfacing to the B32 to various mechanical devices and sensors using SBasic as our programming language.
In the previous article "Setting the Stage for Building a Robot," we set goals for the robot and did research. From the goals and research we will make fundamental decisions on what our robot will be like.
I am sure there are lots of opinions on which CPU to choose. None of them is especially right or wrong, there are so many good choices. There seems to be three basic families or types:
Basic Stamp, PIC and associated CPUs. The Stamp family has lots of support and many various options with much in the area of peripherals and software. It seemed to me there was not enough power in the Stamp family to meet my criteria of being in the Fire Fighting contest and be a base for future projects,. If I was just experimenting with robotics and didnt have the above criteria, the Stamp would be my choice.
PC family, 386, 486, Pentium. Lot of power, lots of peripherals, lots of software. But, most software is not in the area of robotics. The CPUs are not designed with robotics in mind. I built my first attempt in robotics based on the 386sx. It is tempting. The CPUs are lying around and no one wants them, they are for free. But adding all the peripherals to the PC boards will cost you a lot more than a CPU designed for robotics. Also the CPUs are power hungry. A motor cycle battery powered the 386sx robot I made and it couldnt stay alive more then minutes at a time. The CPU ate a lot more power than the motors. So for me this was not a choice.
68HCXX family. To me this seemed the route to go. There are lots of articles and robotic software for the 68HC11. Whole books were based on this CPU. Power supply certainly wasnt a problem and many seemed to have done some significant things using these chips. During my investigation it came apparent the 68HC12 was going to be its replacement in the future. Building for the future, the 68HC12 seemed to be the choice. Kevin Ross and Karl Lunt had written several articles on the 68HC12 and seemed convinced that it was a good choice for a chip.
There are two CPUs to choose from in the 68HC12 family, 68HC812A4 and the 68HC912B32. The B32 won me over with its built in 32kb flash, (so possibly no external ram would be needed,) and its built in Pulse Width Modulation (PWM) to directly control my robots motors. Also, it has an on board boot loader and debugger so no BDM is needed. (Note this turned out not to be a full solution. To do true debugging a BDM board is often still needed.) Click on http://www.mcu.motsps.com/hc12/sib/Intro1.html for a three part series on these chips. It gives a chart with side by side comparison.
At the time of my purchase there were not that many choices. Motorola had its evaluation board and it was cheap in the $100 range. Kevin Ross has a board, but you had to add the B32 (at the time, but now he supplies it with the B32). I then came across the Technological Arts page. Techart was just releasing the B32 having already produced the 68HC11 and 68HC812A4.
The big thing with Technological Arts boards is their connections. I liked the way you could mount them on a breadboard and then have plenty of ways to connect to the boards to all the various peripherals. They have many different ways to hook up their boards and peripherals. So their B32 board was my choice.
I feel you would not go wrong with going with any one of the three boards mentioned above.
|Top view of the Techart B32 board. It has a
RS232 connection, and various jumper switches. It has an onboard 5V regulator, so you can
feed in the 12V for programming and get the needed 5V from that supply.
But the real strength is the connections below the board to connect to the breadboard.
|Bottom view of the Techart B32 board. In this configuration the board can plug into a breadboard using two converter connectors. This allows all the CPU pins to be available to be bread boarded to the peripherals. I greatly appreciated the flexibility and expandability. See their connections options page for more details. I went with their "Style M" option on both sides of the B32 board so it could plug directly into the breadboard.|
|This is a another version of the Techart B32 with the connectors coming out the side instead of the bottom. This allows the board to be mounted vertically to the breadboard.|
|The B32 mounted on my breadboard. RS232 cable is connected (upper left in gray). The red and black wires are the 12V connections.|
I think C is the way to go. C will be the most concise and allows you to get to the CPU and ports easily. But the problem is that I have done a quite few languages but never gotten into C. I used to write large programs in assembler and I didnt want to return there again. This is suppose to be fun!
Looking at Karl Lunts SBasic, it looked interesting. Already there were articles and source code in SBasic for several of the peripherals that I wanted to do. You can do assembler inside the language if need be so you should not be limited. It just takes away some of the pain of coding. The unanswered question is will the code be tight enough to do the job in the 32kb of flash. But at least it will get me going and so far is working for me.
Now what about the basic shape of the robot? For our project needed to be no more than 12 inches cubed (Fire Fighting requirement). Reading through Jones and Flynns book "Mobile Robots," they gave various solutions, but for what I wanted to do it was hard to beat the round robot with the wheels in the center. It is the tried and true approach with the easiest movement calculations. It allows you to make tighter turns, turning in its own radius if need be.
Next time I will concentrate on powering up the B32 for the first time. I will show you how to power the B32 up and load and debug programs with and without the BDM module. We will look at the B32s memory locations and its various power up modes.
Jones and Flynns book "Mobile Robots" - Can get it at Amazon.com
Motorola will also allow you to order printed documentation online at http://design-Net.com/home2/lit_ord.html where you will find a form to fill out your name and address, then a spot on the bottom for document numbers. The following are the documents that you might be interested in
CPU12RM/AD The CPU12 Reference Manual (Must Have)
MC68HC912B32ECD 68HC912B32 Electrical Characteristics
MC68HC912B32TSD 68HC912B32 Technical Summary (Must Have)
Motorola manual for their evaluation board (Must have)
SRS List It is a very helpful group to belong to. Many various questions are submitted and answered by SRS members. I have found it helpful in learning what others are doing and the answers to the questions. To subscribe do the following:
Send mail to email@example.com with the subject line:
Motorola 68HC12 email list - Deals with 68HC12 issues. Mostly engineers dealing with "real life" issues and not robotic hobbyist. I find it interesting but not nearly as useful as the SRS group.
To subscribe send an E-mail message to the Majordomo program (firstname.lastname@example.org). No subject is needed, but in the body of the message the following text string:
Technological Arts Adapt Technological Arts just started this month two email list servers for those with the 68HC11 and 68HC12 boards. To subscribe to the groups send an email to the following address (no subject line or text in message needed):
email@example.com (for the 68HC11)
firstname.lastname@example.org (for the 68HC12)
An Overview of the 68HC12
The 68HC12 Analog to Digital Module
Programming the 68HC12
The 68HC12 Timer Module
68HC812A4 Development Board
The 68HC912B32: An Overview
The Basics - Microcontrollers (part 1)
The Basics - Microcontrollers (part 2)
The 68HC912B32 PWM Module
The Vice-Prez Sezl, The Need for Speed
The Vice-Prez Sez
Here are links and instructions for getting 68HC12 resources
as12 assembler is available from Karl Lunt, and is the freeware assembler for the HC12 family.
SBasic is Karl Lunts version of BASIC for the 68HC12. This is a good high level language.
Robotic and Microcontrollers Products is my page that allows you to order the SRS 68HC812A4 Development board, as well as my BDM12 interface board, and the new 68HC912B32 development board.
Imagecraft has a great C compiler for the 68HC12. The compiler runs around $150, but is a great bargin if you would like to write software in C for the HC12.
You can get online versions of the 68HC12 documentation from Motorolas website. Here are the files to grab. You can also get printed versions as described below.
CPU12RM-AD Index is an index to a series of .PDF files that create the Motorola CPU12 Reference Manual. This describes the instruction set and programming model for the chip. It is definitely a must have. There is also an Online Version at CPU12RM-AD or http://www.mcu.motsps.com/lit/manuals/cpu12/outline1.html
a4.pdf is the .PDF file of the 68HC812A4 Technical Summary that contains information specific to the 68HC812A4 version of the chip. This is the one with 4k of EEPROM, 1k RAM, and tons of I/O. This explains all of the systems on the chip, where the registers are, etc. You should definitely have one of these if you are using the 68HC812A4.
(250K bytes) is a PDF file with the electrical characteristics of the 68HC812A4. Timing diagrams, electrical capacities and absolutes, accuracies, etc.
b32ts.pdf is the .PDF file of the 68HC912B32 Technical Summary that contains information specific to the 68HC912B32 version of the chip. This is the one with 32k of Flash, 768 bytes EEPROM, 1k RAM, and still lots of I/O. This explains all of the systems on the chip, where the registers are, etc. You should definitely have one of these if you are using the 68HC912B32.
(272K bytes) is a PDF file with the electrical characteristics of the 68HC912B32. Timing diagrams, electrical capacities and absolutes, accuracies, etc.
Motorola will also allow you to order printed documentation online at http://design-net.com/home2/lit_ord.html where you will find a form to fill out your name and address, then a spot on the bottom for document numbers. The following are the documents that you might be interested in
|CPU12RM/AD||The CPU12 Reference Manual (Must Have)|
|MC68HC812A4EC/D||68HC812A4 Electrical Characteristics|
|MC68HC812A4PP/D||68HC812A4 Product Preview (Not worth the effort!)|
|MC68HC812A4TS/D||68HC812A4 Technical Summary (Must Have)|
|MC68HC912B32ECD||68HC912B32 Electrical Characteristics|
|MC68HC912B32PPD||68HC912B32 Product Preview (Not worth the effort!)|
|MC68HC912B32TSD||68HC912B32 Technical Summary (Must Have)