900-00008

Copyright © Parallax Inc. Parallax Continuous Rotation Servo (#900-00008) v2.2 10/24/2011 Page 4 of 8
Calibration – "Center" the Servo
The servo has a pot entiometer access port, right above the plac e where the cable attaches to the case.
The port allows the user to adjust the servo to hold completely still when receiving a 1.5 ms pulse width.
This is the value in the "center" of the range of control pulses the servo will accept.
To center the servo, program your host device to deliver a 1.5 ms pulse, continually refreshed ever y
20 ms. S ample calibration code is giv en below f or all BASIC Stamp model s, Spin for the Propeller
P8X32A microcontroller, and SX/B for the SX chip. All are avail able for downl oad from th e 900-00008
product page at www.parallax.com.
Connect the servo to your microcontroller's I/O pin. The example programs below specify an I/O pin.
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.
' CenterParallaxCrServo.bs2
' {$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 signal pin to Propeller I/O pin P0.
Run the program CenterParallaxServo.spin, and gently twist the potentiometer adjustment screw
until the servo does not turn or vibrate.
NOTE: Calibrating the servo m ay take some p atience.
The potentiometer is very sensitive so a very light touch will be required.
{{ CenterParallaxServo.spin
For centering Parallax Continuous Rotation Servo
or holding Parallax Standard Servo at 90° position.
Sends a 1.5 ms pulse approx every 20 ms }}
CON
_clkmode = xtal1 + pll16x ' System clock 80 MHz
_xinfreq = 5_000_000 ' Using 5 MHz external crystal oscillator
servoPin = 0 ' Servo signal to this I/O pin-change if needed
PUB CenterServo | tInc, tc, tHa, t
Copyright © Parallax Inc. Parallax Continuous Rotation Servo (#900-00008) v2.2 10/24/2011 Page 5 of 8
ctra[30..26] := %00100 ' Configure Counter A to NCO
ctra[8..0] := servoPin
frqa := 1
dira[servoPin]~~
' 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
Communication Protocol
The Parallax Continuous Rotation Servo is controlled through pulse width modulation. Rotational speed
and direction are determi ned by the d uration of a high pulse, i n the 1.3– -1.7 ms range. In order for
smooth rotation, the servo needs a 20 ms pause between pulses. Below is a sample timing diagram for a
centered servo:
As the length of the pulse decreases from 1.5 ms, th e servo will gradually rotate faster in th e clockwise
direction, as can be seen in the figure below:
Likewise, as the length of the pulse increases from 1.5 ms, the servo will gradually rotate faster in the
counter-clockwise direction, as can be seen in the figure below:
Copyright © Parallax Inc. Parallax Continuous Rotation Servo (#900-00008) v2.2 10/24/2011 Page 6 of 8
Voltage and RPM: Maximum RPM will vary with input voltage; 50 RP M @ 5 V is typical. Using
regulated Vdd as the sup ply source will reduce fluct uations in RPM for a given pulse width that might
otherwise occur with unregulated battery supplies.
BASIC Stamp
®
Programming Examples
PBASIC has a PULSO UT command that sets the I/O
Pin
to an output and sends a pulse of the specified
Duration
. Since the servo needs this pulse refreshed every 20 ms for continuous operation, the PULSOUT
command is put in a coun ted FOR…NEXT loop to su stain continuous operation for the speci fied number
of cycles.
PULSOUT
Pin
,
Duration
Different BASIC Stamp m odules use different units for the P ULSOUT command's
Duration
argument.
When adapting BS2 code to another BASIC Stamp model, you may need to make adjustments. The table
below lists the PULSOUT ranges for each BASIC Stamp microcontroller. See the BASIC Stamp Manual or
BASIC Stamp Editor Help for more information.
BASIC Stamp Model
1.3 ms
(Full speed clockwise)
1.5 ms
(Center, no rotation)
1.7 ms
(Full speed counterclockwise)
BS1
130 150 170
BS2, BS2e, BS2pe
650 750 850
BS2sx, BS2p, BS2px
1625 1875 2125
The example shown below for a BASIC Stamp 2 causes a servo connected to BASIC Stamp 1/0 pin 12 to
first rotate full-speed counterclockwise for about 3 seconds, hold still f or about 3 seconds, and then
rotate counterclockwise for about 3 seconds.
' RotateParallaxCrServo.bs2
' {$STAMP BS2}
' {$PBASIC 2.5}
counter VAR Word
servoPin PIN 12 ' change I/O pin for servo signal here
FOR counter = 1 TO 100 ' Rotate counterclockwise for ~3 seconds
PULSOUT servoPin, 850
PAUSE 20
NEXT

900-00008

Mfr. #:
Manufacturer:
Parallax
Description:
AC, DC & Servo Motors ROTATION SERVO S148 FUTABA
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet