Page 67 - The Unofficial Guide to Lego Mindstorms Robots
P. 67
56
Access Memory (RAM). As its name implies, ROM canno t be written. It is programmed at the factory and cannot be changed.
R AM, 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 circumstance s, 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 import antly, the ROM routines know how
to receive code from the IR port a nd place it in RAM.
Firmware
One of the first things you have to do with your RCX is download the firmware. The firmw are 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
re cognize 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
fi rmware 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 wa y for programs to be downloaded,
stored, started, and stopped.
The actual robot programs are not H8 machine code. They are defined at a higher leve l called bytecode. Whereas the H8
machine instructions a re very rudimentary, such as "move this value to register 1," bytecode instructions are more powerful,
su ch as "turn output 2 on with full power." The firmware interprets the bytecode and performs the appropriate action.
About Spirit.ocx
O n 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
th e RCX.
T he 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 down load
th e programs to the RCX.
Spirit.ocx is a regular ActiveX control , which means its functions are accessible from programming languages like Visual
B asic and Visual C++.