Download Print this page

Parallax Continuous Rotation Servo Manual page 7

Advertisement

FOR counter = 1 TO 100
PULSOUT servoPin, 750
PAUSE 20
NEXT
FOR counter = 1 TO 100
PULSOUT servoPin, 650
PAUSE 20
NEXT
END
For more examples with the BASIC Stamp 2, incl uding 2-wheeled robot maneuvers and ramping, see
Robotics with the Boe -Bot
www.parallax.com.
Propeller
P8X32A Application
The program below uses counter modules to rotate the servo first clockwise at full speed for 2 seconds,
then rests for 2 seconds, and rotates counterclockwise at full speed for another 2 seconds. This code can
also be downloaded from the 900-00008 product page.
{{ ServoContinuousRotation.spin
Turn Parallax Continuous Rotation Servo clockwise full speed for 21 sec.
hold still 2 sec, and then counterclockwise full speed for 2 sec. }}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
servoPin = 0
PUB CenterServo | tInc, tc, tCtr, tCw, tCcw, t
ctra[30..26] := %00100
ctra[8..0] := servoPin
frqa := 1
dira[servoPin]~~
tInc := clkfreq/1_000_000
tC
:= tInc * 21_500
tCtr := tInc * 1500
tCw := tInc * 1300
tCcw := tInc * 1700
t
:= cnt
repeat 100
phsa := -tCw
t += tC
waitcnt(t)
repeat 100
phsa := -tCtr
t += (tC + 200)
Copyright © Parallax Inc.
' Hold still for ~3 seconds
' Rotate clockwise for ~3 seconds
Chapter 4 , available for free downl oad from the 28132 product page at
' System clock → 80 MHz
' Using 5 MHz external crystal oscillator
' Servo signal to this I/O pin-change if needed
' Configure Counter A to NCO
' 1 μs increment
' Low pulse
' Center pulse = 1.5 ms
' Clockwise fast = 1.3 ms
' Counter-Clockwise fast = 1.7 ms
' Mark counter time
' Repeat PWM signal 100x
' Set up clockwise fast pulse
' Calculate next cycle repeat
' Wait for next cycle (20 ms)
' Repeat PWM signal 100x
' Set up the center pulse
' Calculate next cycle repeat
Parallax Continuous Rotation Servo (#900-00008)
v2.2 10/24/2011 Page 7 of 8

Advertisement

loading

This manual is also suitable for:

900-00008Rob-16048