
Page 49
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.
Figure 3-5.
The sensor watcher
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.
Page 50
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.
Содержание MINDSTORMS Robots
Страница 22: ...Page 18 The back tread wheels are anchored to the shafts with the 16t gears ...
Страница 23: ...Page 19 Page 20 Next start building support for the drive motors ...
Страница 25: ...Page 22 Attach the motor wires to output A and output C Next build the platform for the front bumpers ...
Страница 26: ...Page 23 The touch sensors are attached only by the shaft that runs through them ...
Страница 41: ...Page 41 ...
Страница 43: ...Next build the support for the light sensor ...
Страница 80: ...Page 85 Make sure the bump on the long pin is up against the 4u beam ...
Страница 82: ......
Страница 84: ...Page 89 ...
Страница 85: ...Step 14 is similar to Step 11 take a deep breath and go slowly ...
Страница 86: ...Page 90 Grabber Arm In Step 17 the half bushings go between the center block and the cams pear shaped pieces ...
Страница 87: ...Page 91 ...
Страница 88: ...Page 92 Make sure that the two sides are at the same angle They should mirror each other ...
Страница 89: ...Page 93 Page 94 ...
Страница 90: ...Structural Support Page 95 ...
Страница 91: ...Idler Wheel Page 96 ...
Страница 92: ...Page 97 Drive Motor ...
Страница 93: ...While you re putting the motor in hold on to the worm gear so it doesn t slip off Page 98 ...
Страница 94: ...Grabber Arm Motor ...
Страница 95: ...Page 99 ...
Страница 96: ...Page 100 RCX Attach the RCX on both sides as shown Page 101 ...
Страница 158: ......
Страница 159: ...Page 175 The 16t gears are nestled inside the tread wheels ...
Страница 160: ...Page 176 ...
Страница 161: ...Page 177 Attach the motors to output A and output C as shown Page 178 ...
Страница 162: ...The light sensor which is mounted on the bumper is attached to input 2 The touch sensor goes on input 1 Page 179 ...