28125 Parallax Inc, 28125 Datasheet - Page 96

TEXT ROBOTICS

28125

Manufacturer Part Number
28125
Description
TEXT ROBOTICS
Manufacturer
Parallax Inc
Datasheet

Specifications of 28125

Title
Robotics with the Boe-Bot
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
FOR…NEXT to Control Servo Run Time
Hopefully, by now you fully understand that pulse width controls the speed and direction
of a Parallax Continuous Rotation servo. It’s a pretty simple way to control motor speed
and direction. There is also a simple way to control the amount of time a motor runs, and
that’s with a
Here is an example of a
Let’s figure out the exact length of time this code would cause the servo to turn. Each
time through the loop, the
for 20 ms, and it takes around 1.3 ms for the loop to execute.
One time through the loop = 1.7 ms + 20 ms + 1.3 ms = 23.0 ms.
Since the loop executes 100 times, that’s 23.0 ms times 100.
Let’s say you want the servo to run for 4.6 seconds. Your
execute twice as many times:
Example Program: ControlServoRunTimes.bs2
' Robotics with the Boe-Bot - ControlServoRunTimes.bs2
' Run the P13 servo at full speed counterclockwise for 2.3 s, then
' run the P12 servo for twice as long.
FOR counter = 1 TO 100
NEXT
FOR counter = 1 TO 200
NEXT
Enter, save, and run ControlServoRunTimes.bs2.
Verify that the P13 servo turns counterclockwise for about 2.3 seconds, followed
by the P12 servo turning for twice as long
time
PULSOUT 13, 850
PAUSE 20
PULSOUT 13, 850
PAUSE 20
=
=
FOR…NEXT
=
100
. 2
100
30
×
×
s
. 0
23
0230
0 .
ms
loop.
FOR…NEXT
s
PULSOUT
loop that will make the servo turn for a few seconds:
command lasts for 1.7 ms, the
FOR…NEXT
PAUSE
loop will have to
command lasts

Related parts for 28125