Chapter 2: Your Boe-Bot’s Servo Motors
· Page 89
PULSOUT 12, 650 ' P12 servo clockwise
PULSOUT 14, 650 ' P14 LED lights dimly
PAUSE 20
LOOP
P2.
First, calculate the number of loops needed to get the servos to run for three
seconds, for each combination of rotation. As given on page 79, the code
overhead is 1.6 ms.
Four combinations (1,2,3,4).
Each combination: Determine
PULSOUT
Duration
arguments:
1. Both counterclockwise: 12, 850 and 13, 850
2. Both clockwise: 12, 650 and 13, 650
3. 12 CW and 13 CCW: 12, 850 and 13, 650
4. 12 CCW and 13 CW: 12, 650 and 13, 850
Each combination: Calculate how long it will take for one loop:
1. one loop = 1.7 + 1.7 + 20 ms + 1.6 = 25.0 ms = 0.025 s
2. one loop = 1.3 + 1.3 + 20 ms + 1.6 = 24.2 ms = 0.0242 s
3. one loop = 1.7 + 1.3 + 20 ms + 1.6 = 24.6 ms = 0.0246 s
4. one loop = 1.3 + 1.7 + 20 ms + 1.6 = 24.6 ms = 0.0246 s
Each combination: Calculate number of pulses needed for 3 s of running:
1. number of pulses = 3 s / 0.025 s = 120
2. number of pulses = 3 s / 0.0242 s = 123.9 = 124
3. number of pulses = 3 s / 0.0246 s = 121.9 = 122
4. number of pulses = 3 s / 0.0246 s = 121.9 = 122
Now write four
FOR…NEXT
loops, using the number of pulses calculated for the
EndValue argument. Include the correct
PULSOUT
arguments for the
combination of rotation.
' Robotics with the Boe-Bot - Ch02Prj02_4RotationCombinations.bs2
' Move servos through 4 clockwise/counterclockwise rotation '
combinations.
'{$STAMP BS2}
'{$PBASIC 2.5}