
The 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 cross-compilation step is a little different, too, because RCX programs are bytecode
rather than machine code. But it's still cross-compilation: the end result is bytecode rather
than H8 machine code.
A Day in the 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 program to bytecode.
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.
Page 58
NQC Overview
Where does NQC fit in? NQC is a replacement for the software on the PC, both RCX Code and
Spirit.ocx.
NQC source code is stored in simple text files, just like C, C++, or Java source code.
NQC compiles these source files to bytecode and can download them to the RCX using the IR tower. NQC is a good way to overcome the limitations of RCX Code. But because it produces
bytecode programs, it's still subject to the limitations of the firmware's bytecode interpreter.
Because NQC talks to the IR tower directly, without depending on
Spirit.ocx,
it is very portable. NQC runs on MacOS (using MPW), Linux, and of course Windows 95, 98, and NT. RCX Code,
by contrast, only runs on Windows.
∗
NQC was developed by Dave Baum, who maintains the official web site at
http://www.enteract.com/~dbaum/lego/nqc/.
His web site also includes pithy documentation for the language.
If you're using NQC on Windows, you might want to also use RCX Command Center (RcxCC). RcxCC is a Windows application that wraps around NQC. It provides a syntax-colored program
editor, push-button compilation and downloading, real-time control of the RCX, and a host of other useful features. Although NQC is fairly easy to use all by itself, RcxCC gives you an even
smoother ride. See the "Online Resources" at the end of this chapter for a URL and more information.
This chapter covers the important commands of NQC. If you have a background in C programming, the syntax and control structures will look familiar. If you don't have a background in C, don't
worry: NQC is easy to learn. I've included lots of example programs to demonstrate how things work. I won't cover NQC exhaustively; several excellent web pages detail the entire language. See
the "Online Resources" section at the end of this chapter for details.
main
NQC programs are organized into one or more
tasks.
A task is simply some set of instructions that execute in order. A task is analogous to a
thread
in other programming environments. A single
program may consist of several tasks that execute at the same time.
Tasks have names. Every program should have a special tasks called
main
. When the
Run
button is pressed, the RCX begins the program by running
main
. If you define other tasks, you have to
explicitly start and stop them. The
main
task is the only one that is automatically run by the RCX. I'll explain more about starting and stopping tasks later.
∗
As this book goes to press, a standalone MacOS version of NQC is being released in beta test form. Now you can run NQC on MacOs without MPW.
Summary of Contents for MINDSTORMS Robots
Page 22: ...Page 18 The back tread wheels are anchored to the shafts with the 16t gears ...
Page 23: ...Page 19 Page 20 Next start building support for the drive motors ...
Page 26: ...Page 23 The touch sensors are attached only by the shaft that runs through them ...
Page 41: ...Page 41 ...
Page 43: ...Next build the support for the light sensor ...
Page 80: ...Page 85 Make sure the bump on the long pin is up against the 4u beam ...
Page 82: ......
Page 84: ...Page 89 ...
Page 85: ...Step 14 is similar to Step 11 take a deep breath and go slowly ...
Page 87: ...Page 91 ...
Page 88: ...Page 92 Make sure that the two sides are at the same angle They should mirror each other ...
Page 89: ...Page 93 Page 94 ...
Page 90: ...Structural Support Page 95 ...
Page 91: ...Idler Wheel Page 96 ...
Page 92: ...Page 97 Drive Motor ...
Page 93: ...While you re putting the motor in hold on to the worm gear so it doesn t slip off Page 98 ...
Page 94: ...Grabber Arm Motor ...
Page 95: ...Page 99 ...
Page 96: ...Page 100 RCX Attach the RCX on both sides as shown Page 101 ...
Page 158: ......
Page 159: ...Page 175 The 16t gears are nestled inside the tread wheels ...
Page 160: ...Page 176 ...
Page 161: ...Page 177 Attach the motors to output A and output C as shown Page 178 ...