Multitasking - LEGO MINDSTORMS Robots Manual

Unofficial guide
Table of Contents

Advertisement

Of course, you haven't actually built anything useful. But it's a good demonstration of the
efficiency of these motors. The shaft on the second motor turns at nearly the same speed as
the first motor, which means very little energy is lost in converting mechanical energy to
electrical energy and vice versa.
If you have a choice of motors, you'll probably always use a geared motor. It is more efficient, more convenient, and less bulky than the standard motor. The micro motor is hard to find and not
strong enough for most tasks.
How can you get more motors? RIS comes with two motors, but there are three outputs on the RCX. You can get another motor in the RoboSports expansion set, but it'll cost you $50.
You can order extra motors from the LEGO Shop-at-Home service, one of The LEGO Group's best-kept secrets. This service is available in the United States at (800) 835-4386. They have a
variety of sets and spare parts—the item numbers for the motors are as follows:
• Standard motor, item 5114
• Micro motor, item 5119
• Geared motor, item 5225
• Train motor, item 5300
You can also order the first three motors from Pitsco LEGO DACTA: (800) 362-4308.
For more information on extra parts and ordering, see Appendix A.

Multitasking

Don't be fooled by the simplicity of the RIS programming environment—it hides some pretty messy details. Hank's simple program demonstrates a powerful feature of the RCX software:
multitasking. This is a term from the computer world—it just means that the RCX can do more than one thing at a time. Each of the two instruction sequences hanging off the touch sensor
watchers is a separate task, and they can actually execute at the same time. To see this in action, touch one of Hank's bumpers to trigger the first task, then touch the other bumper shortly
afterward. (To really see this effect, you could try putting in longer delay times in Hank's program.)
The sensor watchers in RCX Code exhibit another interesting property. If you trigger a sensor watcher, the code for that watcher begins executing. If you trigger the same sensor watcher again,
while the watcher code is still executing, the watcher code starts over again from the beginning.
The relationship between the programs you create in RCX Code and the tasks that run on the RCX is not always clear. Tasks and subroutines are declared explicitly in NQC, one of the alternate
programming environments for the RCX. See Chapter 4, Not Quite C, for details.
Figure 2-15 shows how the multitasking nature of the RCX can get you into trouble. The figure shows an alternate program for Hank. At first glance, it makes sense. The main program starts
Hank moving forward. When one of the bumpers is touched, the robot backs up, waits, turns, waits, and starts going forward.
Page 36

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MINDSTORMS Robots and is the answer not in the manual?

Questions and answers

Table of Contents