Shop OBEX P1 Docs P2 Docs Learn Events
servo help again — Parallax Forums

servo help again

science_geekscience_geek Posts: 247
edited 2008-08-26 01:53 in Propeller 1
i am trying to get a servo to move with a potentiometer, i have the pot test code from the tutorials and am using the object servo from pe kit in a previous forum, here is the code, i cant figure out what is going wrong with it, heres my main code

CON
··
· _clkmode = xtal1 + pll16x················· ' System clock → 80 MHz
· _xinfreq = 5_000_000
··
OBJ
··
· servo: "servo"
··
··
PUB Init
·'Configure counter module.
· ctra[noparse][[/noparse]30..26] := %01000···················· ' Set mode to "POS detector"
· ctra[noparse][[/noparse]5..0] := 17·························· ' Set APIN to 17 (P17)
· frqa := 1································· ' Increment phsa by 1 for each clock tick
· main······································ ' Call the Main method
PUB Main | time
'' Repeatedly takes and displays P17 RC decay measurements.
· repeat
···· ' Charge RC circuit.
···· dira[noparse][[/noparse]17] := outa[noparse][[/noparse]17] := 1·············· ' Set pin to output-high
···· waitcnt(clkfreq/100_000 + cnt)········· ' Wait for circuit to charge
·····
···· ' Start RC decay measurement.· It's automatic after this...
···· phsa~·································· ' Clear the phsa register
···· dira[noparse][[/noparse]17]~······························ ' Pin to input stops charging circuit
········· time := (phsa - 624) #> 0··· 'variable to send over
···· servo.start(14, time/100, 10 )
···· waitcnt(clkfreq/10 + cnt)·
Sign In or Register to comment.