EasyManua.ls Logo

Parallax Boe-Bot - Page 97

Parallax Boe-Bot
360 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2: Your Boe-Bot’s Servo Motors · Page 83
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
counter VAR Byte
FOR counter = 1 TO 100
PULSOUT 13, 850
PAUSE 20
NEXT
FOR counter = 1 TO 200
PULSOUT 12, 850
PAUSE 20
NEXT
END
Let’s say you want to run both servos, the P13 servo at a pulse width of 850 and the P12
servo at a pulse width of 650. Now, each time through the loop, it will take:
1.7ms Servo connected to P13
1.3 ms Servo connected to P12
20 ms Pause duration
1.6 ms Code overhead
--------- ------------------------------
24.6 ms Total
If you want to run the servos for a certain amount of time, you can calculate it like this:
Number of pulses = Time s / 0.0246s = Time / 0.0246
Lets’ say we want to run the servos for 3 seconds. That’s
Number of pulses = 3 / 0.0246 = 122
Now, you can use the value 122 in the
EndValue of the FOR…NEXT loop, and it will look
like this:
FOR counter = 1 TO 122
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
NEXT

Table of Contents

Other manuals for Parallax Boe-Bot