Page 68 - The Unofficial Guide to Lego Mindstorms Robots
P. 68
57
Spruce Up That Resume
Writing programs for the RCX is an example of cross-compiling for an embedded system, a
phrase that is bound to sound good on your resume. Cross-compilin g means that you are
writing programs on one computer (your PC) that will run on another computer (the RCX).
An embedded system is a computer that is part of some other device. For example, microwave
ovens and mobile phones both co ntain embedded systems. Modern cars contain dozens of
e mbedded systems, as well.
The usual way to develop software for a chip like the Hitachi H8 would be to use a cross
c ompiler running on a PC. You would write source code (probably in C or assembly language)
on your PC and use the cross-compiler to create H8 machine code from the source. Then you
would probably use a special PC peripheral, called a burner, to pla ce the machine code on
so me sort of programmable memory chip.
The final step would be to physically place the memory chip in the embedded system.
When the embedded system boots up, the software you just wrote will run.
T he RIS software simplifies this process in two important ways. First, it provides a graphic
programming environment that's very accessible, particularly for people who haven't
programmed before. Second, programs are downloaded to the RCX over the IR link and
stored in RAM. This feature eliminates the complexity of dealing with memory chips and
burners yourself.
The cr oss-compilation step is a little different, too, because RCX programs are bytecode
ra ther than machine code. But it's still cross-compilation: the end result is bytecode rather
than H8 machine code.
A Day in th e Life of a Program
Let's examine the typical life of a robot program:
1. The program's life begins when you create something in RCX Code. RCX Code compiles your p rogram to byt ecode.
2. RCX Code uses Spirit.ocx to download the program to one of the RCX's five program slots. The compiled bytecode is
transferred to the RCX via the IR link.
3. The program is now available in RAM. When you run it, the firmware interprets the bytecode in your program and performs
the appropriate tasks.