Continuous rotation servo v2.0
Copyright © Parallax Inc. Parallax Continuous Rotation Servo (#900-00008) v2.0 7/9/2009 Page 3 of 6
BASIC Stamp Calibration Code - for all BS2 models
√ Connect the servo to BASIC Stamp 1/O pin P12, or update the ToServo PIN declaration.
√ Run the program, and gently twist the potentiometer adjustment screw until the servo does not
turn or vibrate.
NOTE: Calibrating the servo may take some patience. The potentiometer is very
sensitive so a very light touch will be required.
' {$STAMP BS2}
' {$PBASIC 2.5}
#SELECT $Stamp
#CASE BS2, BS2E, BS2PE ' PULSOUT Duration units are 2 us for these models
Center CON 750
#CASE BS2SX, BS2P, BS2PX ' PULSOUT Duration units are 0.8 us for these models
Center CON 1875
#ENDSELECT
ToServo PIN 12 ' connect servo to I/O pin P12, or change it here
DO
PULSOUT ToServo, Center ' ToServo pin outputs 1.5 ms pulse
PAUSE 20 ' refresh pulse every 20 milliseconds
LOOP
Propeller Chip Calibration Code – for P8X32A
√ Download and unzip the Propeller code file from the 900-00008 product page.
√ Connect the servo line to pin 0.
√ Run the program CenterServo.spin, and gently twist the potentiometer adjustment screw until
the servo does not turn or vibrate.
NOTE: Calibrating the servo may take some patience. The
potentiometer is very sensitive so a very light touch will be required.
CenterServo.spin
CON
_clkmode = xtal1 + pll16x ' System clock → 80 MHz
_xinfreq = 5_000_000
PUB CenterServo | tInc, tc, tHa, t
ctra[30..26] := %00100 ' Configure Counter A to NCO
ctra[8..0] := 0
frqa := 1
dira[0]~~
' Set up cycle and high times
tInc := clkfreq/1_000_000
tC := tInc * 21_500
tHa := tInc * 1500
t := cnt ' Mark counter time
repeat ' Repeat PWM signal
phsa := -tHa ' Set up the pulse
t += tC ' Calculate next cycle repeat
waitcnt(t) ' Wait for next cycle