Servo Shake
Jeff K
Posts: 2
I'm working through the "What's a Microcontroller" book, and I just wrapped up the potentiometer chapter.· One of the last programs controls a servo position by turning the pot.· Code is:
DO
· HIGH 7
· PAUSE 100
· RCTIME 7, 1, time
· DEBUG HOME, DEC5 time
· time = time */ 233
· time = time + 500
· PULSOUT 14, time
LOOP
My scale is .911 based on earlier tests.
It works fine, but the horn shakes (moves a very very short distance clockwise and counterclockwise repeatedly) at most midpoints along the pot.· Occasionally I can find a place where it sits still.·
I think it's because the time to discharge the capacitor on 7 isn't constant even when the pot is steady.· Or maybe the pot isn't so great and it lets a slight variation in current through?· Could that be right?· The debug line shows a constant number, but I thought it might be a rounding thing...
Thanks!
·
DO
· HIGH 7
· PAUSE 100
· RCTIME 7, 1, time
· DEBUG HOME, DEC5 time
· time = time */ 233
· time = time + 500
· PULSOUT 14, time
LOOP
My scale is .911 based on earlier tests.
It works fine, but the horn shakes (moves a very very short distance clockwise and counterclockwise repeatedly) at most midpoints along the pot.· Occasionally I can find a place where it sits still.·
I think it's because the time to discharge the capacitor on 7 isn't constant even when the pot is steady.· Or maybe the pot isn't so great and it lets a slight variation in current through?· Could that be right?· The debug line shows a constant number, but I thought it might be a rounding thing...
Thanks!
·
Comments
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
lastTime = 0
DO
HIGH 7
PAUSE 50
RCTIME 7, 1, time
DEBUG HOME, DEC5 time
time = time */ 233
time = time + 500
DEBUG CR, DEC5 time
IF ABS(time - lastTime) > 12 THEN
PULSOUT 14, time
ENDIF
lastTime = time
LOOP
Did the trick!
Rich H