[Home]

[Challenge]

[RcxCC]

[Robots]

[Tips]

[Links]

Lego Robots Tips and Tricks

Sensors

Putting light and touch sensors on one input

It is easy to put touch and light sensors on one sensor input. In this case better set the sensor mode to raw. In nqc this can be done as follows:
   SetSensor(SENSOR_2,_SENSOR_CFG(SENSOR_TYPE_LIGHT, SENSOR_MODE_RAW));
Now a value below 100 is a touch sensor event. Values above this correspond to light levels (the higher the darker).

Using the IR port for proximity detection

It turns out that the light sensor is very sensitive to the infra-red light produced by the the IR port on the robot. To uses this, mount the light sensor above the IR port, pointing forward. Now regularly send messages. When there is a wall close in front of the robot, you can notice this by high intensity changes in the reading of the light sensor (preferably in raw mode). The closer you get, the higher the fluctuations become. After a bit of tuning you can rather accurately predict the distance. Here is a simple nqc program to demonstrate how this works. Thanks to Dave Chen and Simen Svale Skogsrud for finding out about this.

Design

Front and back

All designs that come with Lego MindStorms use the IR-port side of the RCX as the front. This is not a good idea because you normally add a lot of stuff at the front, making the IR-port almost invisible. Also, for balance reasons, it is good to put the motors under the middle of the RCX. Finally, if you use a swivelling wheel, put it at the back, not at the front. Pulling a swivelling wheel gives a much straighter motion than pushing it.

Drive-Steer mechanism

This mechanism is based on the adder-subtractors of Leo and Alex . It must be driven by two motors; one connected to one of the four gears on one side, and the other connected to one of the three gears on the other side. One motor makes the wheels move in the same direction. The other sterrs by making the wheels move in opposite direction. My design is acccording to me stronger than the other ones. More pictures can be found here.

Double motor power

If you need extra motor power, and you have enough motors, connect two together. You can out them both on the same output to drive them simultaneously. This is especially good for heavy robots or if you want your robots to go fast. I assume you can do the same with three or more motors, but I am not sure how many you can connect to one output.

Bumpers

Here is bumper I designed that uses only one touch sensor. Instructions for building it can be found here.

Internals

Free memory

After loading the firmware, it seems that there is about 6K of memory available for programs. You can use the RCX Command Center to free this memory when required.

Programming with SPIRIT.OCX

Using the joystick

Here is an example program (in Delphi 3) of how you can use the joystick to steer the RCX. It comes with full source and is freeware. It is a simplified stand-alone version of the joystick window in my RCX Command Center version 2.0.

Registering SPIRIT.OCX

If you don't want to install the lego software on your system but still use programs like the RCX Command Center you must register the OCX. Copy the spirit.ocx file from the lego Cdrom to you harddisk and use the Run command in the windows Start menu to execute
   REGSVR32.EXE spirit.ocx
This will register the ocx on your machine. (You might need to specify the path of the ocx in the above command.)

Bugs

There is a bug in the OCX: When polling the mode of a sensor (e.g. Poll(11,0)) you don't get the right mode but 32* the mode.

There is another bug in the polling command. Polling the watch gives you the total time in minutes, and not divided in hours and minutes as the doc suggests.