PULSOUT command hassles
Timmy
Posts: 10
g'day all,
having some hassles with pulsout which i am using to instruct my servo. I've included my code. The problem is, that the servo is moving to the far right and trying to go beyond, ie 2ms. If I remove the "pulse" variable from the PULSOUT command and replace it with an integer like 750, the pulsout command works fine. I am certain that you can use a variable label for the pulsewidth value in PULSOUT.
' {$STAMP BS2}
' {$PBASIC 2.5}
servo VAR OUT0
pulse VAR byte
pulse = 500
start:
pulse = 20 + pulse
PULSOUT servo, pulse
PAUSE 20
IF pulse >= 1000 THEN endseq
GOTO start
endseq:
END
having some hassles with pulsout which i am using to instruct my servo. I've included my code. The problem is, that the servo is moving to the far right and trying to go beyond, ie 2ms. If I remove the "pulse" variable from the PULSOUT command and replace it with an integer like 750, the pulsout command works fine. I am certain that you can use a variable label for the pulsewidth value in PULSOUT.
' {$STAMP BS2}
' {$PBASIC 2.5}
servo VAR OUT0
pulse VAR byte
pulse = 500
start:
pulse = 20 + pulse
PULSOUT servo, pulse
PAUSE 20
IF pulse >= 1000 THEN endseq
GOTO start
endseq:
END
Comments
i have solved my own problem, I set up a debug window and noticed that there was an overflow. Once I changed the variable from byte to word it worked.
cheers,
tim
Servo··· PIN··· 0
pulse··· VAR··· Word
Setup:
· LOW Servo
Main:
· FOR pulse = 500 TO 1000 STEP 20
··· PULSOUT Servo, pulse
··· PAUSE 20
· NEXT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax