|
Lego Robots Tips and Tricks
SensorsPutting light and touch sensors on one inputIt 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 detectionIt 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.DesignFront and backAll 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
Double motor power
Bumpers
InternalsFree memoryAfter 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.OCXUsing the joystickHere 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.OCXIf 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 executeREGSVR32.EXE spirit.ocxThis will register the ocx on your machine. (You might need to specify the path of the ocx in the above command.) BugsThere 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. |