Datasheet
Chapter 4: Navigation Tips · Page 145
Figure 4-2 The Servo Control Loop
The FOR...NEXT loop's EndValue is the number of 1/41 second increments the servo
will run. Every time through the loop takes about 24.6 ms, so 41 times through the 24.6
ms loop takes about 41 × 0.0246 ≈ 1 second. Increasing the
FOR...NEXT loop's
EndValue argument to 82 would make the servos run for twice the time, about 2 seconds.
Half a second of servo rotation would be an
EndValue of 20, and so on.
Sensors will change the effective PAUSE time. When the effective PAUSE time has
changed, it will take some experimenting to re-tune the FOR...NEXT loop EndValues to
get the servo rotation times you want.
The servos have to turn opposite directions to make the SumoBot roll forward. If this
seems counterintuitive, look at the SumoBot's right side. That wheel has to turn clockwise
to make the SumoBot roll forward. Now look at the SumoBot's left side. That wheel has to
turn counterclockwise to make the SumoBot roll forward.
Applying the same train of though for rolling backward, the right servo has to turn
counterclockwise, and the left servo has to turn clockwise. By rotating both servos the same
direction, you can either make the SumoBot rotate right or left. To make the SumoBot rotate
left, both wheels must turn clockwise. To make the SumoBot rotate right, both wheels must
turn counterclockwise.
The graph in Figure 4-3 shows how you can use the
PULSOUT command's Duration
argument to control the servo's speed and direction. Recall that the
PULSOUT Duration
argument has units of 2 µs. A pulse width of 1300 µs, equal to a
PULSOUT Duration of
650, is full speed clockwise. A
Duration of 850 (1700 µs) is full speed
counterclockwise. A
Duration of 750 (1500 µs) yields no rotation.