Extreme MINDSTORMS: An Advanced Guide to LEGO MINDSTORMS

Extreme MINDSTORMS: An Advanced Guide to LEGO MINDSTORMS

by Michael Gasperi, Ralph Hempel, Luis Villa, Dave Baum

Three MINDSTORMS experts have joined with the maintainer of the legOS HOWTO to produce the book that all advanced users of LEGO MINDSTORMS have been waiting for. Each author has written material based on his specialty. Dave Baum shows you how to take Not Quite C (NQC) to its limits. Ralph Hempel explains the ins and outs of pbForth


Three MINDSTORMS experts have joined with the maintainer of the legOS HOWTO to produce the book that all advanced users of LEGO MINDSTORMS have been waiting for. Each author has written material based on his specialty. Dave Baum shows you how to take Not Quite C (NQC) to its limits. Ralph Hempel explains the ins and outs of pbForth. Michael Gasperi teaches you how to build numerous custom sensors with simple, systematic instructions. Luis Villa show you how (and when) to upgrade MINDSTORMS' built-in operating system to take advantage of the extra power of legOS, a complete C environment for the RCX.

Extreme MINDSTORMS: An Advanced Guide to LEGO MINDSTORMS starts with an overview of the RCX firmware and includes a whole chapter on RCX 2.0. Next, the book concentrates on the steps needed to build Seeker, a light-seeking robot, and to program it in NQC. Later chapters extend Seeker's functionality using pbForth and legOS. The book concludes with two chapters on building both custom passive and custom powered sensors. These sensors can take LEGO MINDSTORMS to levels impossible to achieve with just the parts supplied in the box or available through normal channels.

Product Details

Publication date:
Edition description:
Product dimensions:
7.52(w) x 9.25(h) x 0.03(d)

Read an Excerpt

Chapter 1: Extreme MINDSTORMS

IN 1949, GoDTFRED KIRK CHRISTIANSEN began producing the early forerunners of LEGO bricks-Automatic Binding Bricks. A few years later they became known as "LEGO bricks," and in 1958 they took on the stud-and-tube design that has remained to this day. Throughout the 1960s and 1970s the bricks started appearing in new sizes and shapes, along with some decidedly non-bricklike pieces, such as hinges and wheels.

In 1977, LEGO launched the Expert Builder series of sets (later renamed to TECHNIC). Featuring gears, axles, beams, bushings, and even universal joints, these sets could create models that actually worked. Helicopters had adjustable rotors, cars had rack-and-pinion steering, and engines had pistons that moved. These sets brought a new level of engineering sophistication to the LEGO universe. Over the years, new elements continued to be introduced: spring-loaded shock absorbers, pneumatic pistons and valves, and numerous structural and connector pieces. All of these pieces interlocked with one another making LEGO the most versatile construction system in the world. In the fall of 1998, LEGO released the first MINDSTORMS set-the Robotics Invention System (RIS 1.0). To some, this was just another step in a journey that had started nearly 50 years earlier. To others, however, this was a revolution. There were still all of those familiar beams, bricks, and gears. But there was also the RCXLEGO's programmable brick that allowed models not just to move, but to sense and respond to their environment. RIS 1.0 became an instant hit and was one of the hottest selling toys for the 1998 Christmas season. More surprisingly, a significant portion of the"kids" playing with MINDSTORMS were adults.

It seemed to be a long-overdue merging of construction toy and computer. Actually, the idea of merging LEGO with computers wasn't new. For years, researchers at the MIT Media Lab (htt p : / /www. med ia. m it . ed a /) , sponsored in part by LEGO, had been experimenting with programmable toys and the educational opportunities they presented. In the course of this work, several different programmable bricks were developed. LEGO decided to make a commercial product based on the research and the RCX was redesigned from the ground up. Even so, the early programmable bricks from MIT could certainly be considered ancestors of today's MINDSTORMS sets.

The Hackers Step In

LEGO's software was intended to provide an intuitive introduction to programming. However, many of the MINDSTORMS users were experienced programmers who felt that LEGO's simple drag-and-drop environment was too limiting. LEGO was tight-lipped about the details of the RCX, but that didn't prevent me and others from taking matters into our own hands.

Several of us endeavored to unravel the secrets of the RCX and expand its capabilities. Our independent efforts may never have amounted to much if Russell Nelson had not created the LEGO-robotics mailing list. Russell also culled through all of the postings and collected the most interesting tidbits into his LEGO MINDSTORMS Intemals Web site (http: //www. crynwr. com/lego-robotics/). These two resources, the mailing list and the Web site, greatly facilitated our sharing of knowledge and allowed newcomers to also join in the adventure. Eventually, the LEGO-robotics mailing list was merged with the robotics forum at LUGNET (http: //www.lugnet. com/robotics/), run by Todd Lehman. LUGNET is the unofficial repository for all things LEGO and the robotics discussions can be particularly valuable to MINDSTORMS users. Kekoa Proudfoot was the first pioneer into RCX hacking and did a substantial amount of reverse engineering. He revealed many details about the hardware, published a list of bytecodes for the interpreter, and documented the System ROM (see Chapter 2 for more information). His RCX Internals Web site (http:// graphics . stanford. edu/-kekoa/rcx/) contains a wealth of valuable information about the inner workings of the RCX.

At about the same time, I was working towards creating a more "traditional" way of programming the RCX. Starting with old source code to a C preprocessor and a rudimentary understanding of the RCX bytecodes, NQC-the first unofficial programming language for MINDSTORMS-was born. Looking back, it was pretty crude. No local variables. No expressions. No functions. Just a preprocessor, tons of macros, and some code to send the resulting bytecodes over to the RCX. It was, however, a way to write an RCX program with text rather than with graphics; furthermore, it had a very C-like syntax. What started life as an interesting little hack so I could program the RCX from my PowerBook became a popular way for "advanced" users to play with MINDSTORMS. Features were gradually added to NQC to make it more powerful. However, since it relied on LEGO's standard firmware, there were always some fundamental limitations, such as a very small amount of storage for variables and no recursive functions. Other people were striving to break through those limitations by replacing the standard firmware. Starting with Kekoa's documentation for the inner workings of the RCX, Markus L. Noga created legOS (http: //www. noga. de/legOS/), the first replacement firmware for the RCX. This was no small task-writing embedded software is always a difficult business, and writing an operating system without complete documentation of the hardware or System ROM borders on masochism...

Meet the Author

Michael Gasperi has been an expert in LEGO Mindstorms sensors since they were first introduced in 1998. His popular web site and contributing chapters to Extreme Mindstorms (Apress, 2000) have guided many people through the process of building their own extensions to the kit.

Ralph Hempel is a professional engineer who specializes in embedded systems design. Ralph holds a degree in electrical engineering from the University of Waterloo in Canada. LEGO had been a part of Ralph's life since the late 1960s, but when he bought a set for his son Owen in 1997, the flame was rekindled. Besides building original Technic and Town models with his family, Ralph enjoys snowboarding, mountain biking, and playing blues harmonica.

Luis Villa is an undergraduate at Duke University studying computer science. He rediscovered LEGO and became an expert in LEGOS while preparing to become a teacher's assistant for a Duke course that used LEGO MINDSTORMS. Luis writes and maintains the legOS HOWTO, which can be found on the Web at http://legos.sourceforge.net/HOWTO. Besides maintaining the legOS HOWTO, Luis spends his spare time studying political theory and attending lots of Blue Devil basketball games.

Dave Baum is a principal staff engineer at Motorola. With the advent of LEGO MINDSTORMS, Baum was able to combine two of his favorite pastimes: programming and building with LEGO. He then developed Not Quite C (NQC), a powerful language for programming MINDSTORMS robots that has been widely accepted by advanced users. Visit Dave's personal website at BaumFamily.org/NQC.

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >