PSC code help, anyone??
Can somebody help to make this simple servo movement with PSC?
' {$STAMP BS2sx}
' {$PBASIC 2.5}
counter VAR Byte
FOR counter = 1 TO 100
PULSOUT 12, 1250
PAUSE 20
NEXT
FOR counter = 1 TO 100
PULSOUT 12, 2500
PAUSE 20
NEXT
END
' {$STAMP BS2sx}
' {$PBASIC 2.5}
counter VAR Byte
FOR counter = 1 TO 100
PULSOUT 12, 1250
PAUSE 20
NEXT
FOR counter = 1 TO 100
PULSOUT 12, 2500
PAUSE 20
NEXT
END
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I have all the documentation, problem is that when I try to make that same thing with PSC, servo just starts spinning and never change direction or stop.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
' {$STAMP BS2sx}
' {$PBASIC 2.5}
ch VAR Byte
pw VAR Word
ra VAR Byte
sDat CON 15
Baud CON 1021
counter VAR Byte
ra = 1
ch = 1
FOR counter = 1 TO 100
pw = 1250
SEROUT sDat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
PAUSE 20
NEXT
FOR counter = 1 TO 200
pw = 2500
SEROUT sDat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
PAUSE 20
NEXT
END
You’re treating the PSC as if it was a serial servo, but it is not. Your code is sending the command to move to one position 100 times, and then sending the command to move to another position 200 times. You don’t need to refresh the PSC every 20 mS like a servo. The PSC keeps itself refreshed. You simply send a command and when ready send another. The thing is the pulse value you are sending is outside the range of the PSC. The PSC uses values from 500 to 1000 where 750 is the center point. The values you are sending are for a BS2sx using PULSOUT directly to a servo. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
It works! Thanks so much for your help!
Demo