
}
task heartbeatWatcher () {
while (true) {
if (missedBeats > 1) {
PlaySound (SOUND_DOWN);
stop messageWatcher;
Off(OUT_C);
until (armLock == 0);
Off(OUT_A);
until (Message () == HEARTBEAT_MESSAGE);
PlaySound(SOUND_UP);
missedBeats = 0;
start messageWatcher;
}
missedBeats = misse 1;
Wait(HEARTBEAT_TIME);
}
}
Don't Break That Arm
The
grab
and
release
tasks, as I said, have the ability to interrupt each other. They use a variable,
armLock
, to avoid potentially dangerous situations. For example, suppose that
release
is
running. It drives the arm motor in reverse until the arm is up and the limit touch sensor is pressed. Then the motor is run forward to release the touch sensor. Before the touch sensor is released,
however, suppose
grab
starts up. It stops
release
and runs the motor forward until the touch sensor is pressed. It's already pressed, so
grab
starts running the motor in reverse, waiting for the
touch sensor to be released. Since the arm is already at the top of its travel, running the arm motor in reverse creates pressure on the gears and will either break the arm apart or cause the gears to
skip.
Page 157
Using the
armLock
variable enables
grab
and
release
to complete the press-release cycle of the arm limit switch without being interrupted. Both
grab
and
release
wait for
armLock
to
be 0 before interrupting the other task, like this:
until (armLock == 0);
The
grab
and
release
tasks set
armLock
to 1 before doing the sensitive press-release cycle. This means Minerva should never break her own arm.
Stayin' Alive
The
heartbeatWatcher
task also deserves some mention. It adds one to the
missedBeats
variable just as often as it expects the remote to send a heartbeat. Remember that just as
heartbeatWatcher
is adding to
missedBeats
, the
messageWatcher
task is subtracting from
missedBeats
every time it hears the heartbeat message. If
missedBeats
is ever
greater than one,
heartbeatWatcher
shuts Minerva down. This shutdown is not as straightforward as you might think, however. First, a sound is played (the descending arpeggio). This lets
the human operator know that contact with the remote has been lost. Then
heartbeatWatcher
shuts down the
messageWatcher
task and turns off Minerva's drive motor:
PlaySound(SOUND_DOWN);
stop messageWatcher;
Off(OUT_C);
heartbeatWatcher
also wants to shut down Minerva's arm motor, but it respects the
armLock
variable so the arm is not left in an uncertain state:
until (armLock == 0);
Off(OUT_A);
Now
heartbeatWatcher
waits to regain the heartbeat signal from the remote. If it is regained,
heartbeatWatcher
plays another sound (the ascending arpeggio), resets
missedBeats
,
and starts up
messageWatcher
again:
Содержание 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 ...