Access Memory (RAM). As its name implies, ROM cannot be written. It is programmed at the factory and cannot be changed. RAM, on the other hand, can be written and read as many times as
you want, with one catch: it needs power. If you take the batteries out of your RCX, the contents of the RAM are erased. Under normal circumstances, however, the batteries preserve the contents
of the RAM.
When you first get your RCX, it has some stuff in ROM and an empty RAM. The RCX's ROM routines know a little bit about the RCX's hardware. These routines can run the motors or access the
sensors. Most importantly, the ROM routines know how to receive code from the IR port and place it in RAM.
Firmware
One of the first things you have to do with your RCX is download the firmware. The firmware is, essentially, an operating system for your RCX. The routines in ROM know how to download a
set of firmware from the IR port and store it in RAM. The firmware is capable of more than just processing the ROM routines. It shows a clock on the display of the RCX. It can recognize an
respond to the View button. Most importantly, it can receive robot programs over the IR port and run them.
Although at first it sounds like the firmware and the robot programs are the same kind of animal, this is not the case. The firmware is actual Hitachi H8 machine code. Together with the H8
machine code in ROM, the firmware defines an operating system for the RCX. It provides access to the RCX's inputs and outputs. It also provides a way for programs to be downloaded, stored,
started, and stopped.
The actual robot programs are not H8 machine code. They are defined at a higher level called bytecode. Whereas the H8 machine instructions are very rudimentary, such as "move this value to
register 1," bytecode instructions are more powerful, such as "turn output 2 on with full power." The firmware interprets the bytecode and performs the appropriate action.
About Spirit.ocx
On the PC side, a piece of software called Spirit.ocx handles interaction with the RCX via the IR link. Spirit.ocx can execute bytecode commands on the RCX, download new programs to the
RCX, download firmware to the RCX, and receive data from the RCX.
The RCX Code programming environment sits on top of Spirit.ocx. It provides the click-and-drag programming environment that you're already familiar with. RCX Code converts these graphic
programs into bytecode and uses Spirit.ocx to download the programs to the RCX.
Spirit.ocx is a regular ActiveX control, which means its functions are accessible from programming languages like Visual Basic and Visual C++.
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-compiling 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 contain embedded systems. Modern cars contain
dozens of embedded systems, as well.
The usual way to develop software for a chip like the Hitachi H8 would be to use a cross
compiler 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 place the
machine code on some 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.
Page 56
Page 57
Need help?
Do you have a question about the MINDSTORMS Robots and is the answer not in the manual?
Questions and answers