LEGO MINDSTORMS Robots Manual page 49

Unofficial guide
Table of Contents

Advertisement

Figure 3-5 shows a hypothetical graph of the light sensor value, along with the times when the dark and bright commands will be executed. Nothing happens until the sensor value enters either the
dark or bright value ranges.
Remember that the RCX runs some tasks at the same time. If the dark commands and bright commands both take a while to execute, it's possible they may overlap. If the light sensor reading gets
into the bright range and abruptly drops back into the dark range, the dark commands will start running while the bright commands are still in progress. You should be aware of this possibility and
structure your code to deal with it. In Trusty's program, the dark and bright commands both execute quickly so they won't overlap.
Ambient Light
You have to be careful with the light sensor; its value depends on all the light it receives. This includes the reflected light from the red light that's part of the sensor as well as room light and
sunlight.∗ In a line-following robot like Trusty, you really want to measure only the reflected light. In this case, it's in your interests to block out the room lighting, sunlight, light from your kid
brother's flashlight, and anything else distracting. The light level that's present in a certain place is called the ambient light. In a robot like Trusty, you might try surround the light sensor with dark
bricks to block out the ambient light. This can improve the accuracy of your sensor measurements. In this particular case, I didn't think it was necessary, but you might like to give it a whirl.
∗ The light sensor is even sensitive to the infrared light that is produced from the IR port.
Where's That Red Light Coming From, Anyhow?
Isn't it odd that the light sensor, an input device, has a red light on it? How did that happen?
And how is that possible with only two wires connecting the sensor to the RCX?
The basic role of the RCX's inputs is to measure the value of the sensor. For certain types of
sensors, like the light sensor, the RCX also provides power to the sensor. It does this by
very quickly alternating between providing power and taking a measurement. The RCX
sends power to the light sensor for about 3 ms (thousandths of a second) and takes a
measurement for about .1 ms. It repeats this cycle over and over. (These timings only apply
to the standard firmware. In an alternate firmware such as legOS, the timings are entirely
different.) Inside the light sensor, an electronic circuit smooths out the pulses and provides
steady power to the red light.
Figure 3-5.
The sensor watcher
Page 49
Page 50

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