Page 239 - The Ultimate Palm Robot
P. 239
Color profile: Generic CMYK printer profile
Composite Default screen
Bots / The Ultimate Palm Robot/ Mukhar & Johnson / 222880-6 / Chapter 8
222 The Ultimate Palm Robot
vector[aGP_RFX_TIMER_1] {
mSRV1REV, mSRV2FOR, mSRV1REV, mSRV2FOR, mTIM2
}
vector[aGP_RFX_TIMER_2] {
mSRV1FOR, mSRV2REV, mSRV1FOR, mSRV2REV, mTIM1
}
After entering and saving the program above, you would compile it with
the leaf command in the Console application.
leaf "to_fro.leaf"
If the command is successful, a BAG file will be created in the \aUSER di-
rectory (for a PC) or as a memo in the MemoPad (for a PDA). The code is
downloaded to the BrainStem with the batch command:
batch "to_fro.bag"
After the code has been downloaded to the BrainStem, we need to kick off
the first reflex. This can be done by sending a command from the Console
application to the BrainStem. Enter the following in the Console input area,
and send it to the BrainStem by pressing Enter:
2 38 20 0
The first number is the BrainStem module ID. The next number, 38, is the
command to start a reflex. The value 20 is the reflex ID. The command can
send 1 or 2 bytes of data to the reflex; in this case, we have nothing to send, so
the final parameter is 0. Executing the command should start the servos; after
about two seconds, the servos will reverse. This will continue until you power
off the BrainStem.
Just as with the programs we saw in the first part of the chapter, we can set
the BrainStem to automatically start a reflex program. To do that, we need to
create a reflex with index 127. Add this reflex vector to the to_fro.leaf program:
vector[aGP_RFX_BOOT] {
mTIM1
}
P:\010Comp\Bots\880-6\ch08.vp
Monday, May 12, 2003 1:16:47 PM