28.01.2013 Views

Build Your Own Combat Robot

Build Your Own Combat Robot

Build Your Own Combat Robot

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 12: <strong>Robot</strong> Brains 263<br />

space in which programs can fit. The concept is different than how regular PCs refer<br />

to memory. In Table 12-1, all the values shown are in kilobytes, except for the<br />

Basic Stamp 1—which has only 256 bytes of programming space. To some people,<br />

this doesn’t sound like a lot, but 256 bytes represents quite a lot of programming<br />

space in a microcontroller.<br />

Some microcontrollers execute one command at a time, and some can execute<br />

multiple commands at the same time. For some applications, such as controlling<br />

16 different R/C servos in an animatronics movie puppet, being able to execute<br />

multiple commands simultaneously, or multitasking, can be helpful.<br />

The microcontroller used in your bot can be either a small circuit board that<br />

connectors plug into, or a large integrated circuit. One of the common sizes for the<br />

microcontrollers is the 24-pin dual inline pin (DIP) socket. Basic Stamp started<br />

with this size, and several different companies have made Basic Stamp variants<br />

that are pin-for-pin, identical.<br />

Unfortunately, no one programming language can be used to program all<br />

microcontrollers. Many of the languages are based on the popular Basic programming<br />

language or the C programming language. If you know how to program in<br />

either of these languages, you should be able to program one of these<br />

microcontrollers.<br />

Basic and C are called high-level languages, and they are easy to learn and understand<br />

when compared to using the assembly language. A compiler compiles (or<br />

converts) the high-level language into a low level language that the<br />

microcontroller actually understands. For example, here is a simple instruction<br />

written in Basic that is easy to understand:<br />

X = Y + Z<br />

If this is written in assembly language, it would look like this:<br />

MOVF Y,0<br />

ADDWF Z,0<br />

MOVWF X,0<br />

This isn’t easy to understand. The preceding assembly language example will<br />

be different from microcontroller to microcontroller, but the Basic language will be<br />

the same regardless of the microcontroller.<br />

When you get started in the world of microcontroller programming—or, as the<br />

electrical engineers like to call it, programming embedded controllers—pick something<br />

you like and stick with it until you master it. Interfacing a microcontroller<br />

with the outside world is the same regardless of which microcontroller you choose.<br />

Master the interfacing techniques on one microcontroller before you move on to<br />

another type of microcontroller.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!