PSC Code Snipit...
I have a program I like which drives the BOE bot.· It assumes the servos to be connection to the BOE Bot directly and uses the traditional·PULSOUT command in a loop.
I have moved the sevo connectors from the BOE Bot to my USB PSC and then connected the PSC to the BOE. They seem to be communicating fine.
However, I now need to convert the program loops··to send serial commands to the servos instead of the PULSEOUT.· I am looking for a sample code snipit.
In addition, I am looking for a largerly library of commands that can be sent to the PSC.· All I have are those identified in the 9 pages of initial instruction.· Any help?
Thanks!
ROB
I have moved the sevo connectors from the BOE Bot to my USB PSC and then connected the PSC to the BOE. They seem to be communicating fine.
However, I now need to convert the program loops··to send serial commands to the servos instead of the PULSEOUT.· I am looking for a sample code snipit.
In addition, I am looking for a largerly library of commands that can be sent to the PSC.· All I have are those identified in the 9 pages of initial instruction.· Any help?
Thanks!
ROB
Comments
·· You're in luck, since the PSC uses the same pulse values as the BS2.· Depending on how your code is structured you could simply send the data to the PSC instead of using PULSOUT, you would use SEROUT and format the command properly.· To optimize things though you should really only send out new data when there is a change.· That way your loop can be sped up by not having to keep updating anything.
·· Probably the easiest way to do this is to reformat your program so that it only calls the PSC subroutine once for each change in direction/speed, etc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Here's some example code I used to test it and·a picture of how its connected to my Boebot.
' {$STAMP BS2p}
' {$PBASIC 2.5}
Sdat PIN 15
Baud CON 1021
buff VAR Byte(3)
ra VAR Byte
pw VAR Word·· ' pulse width
ch VAR Byte·· ' channel
ra = 7
ch = 0 ' Servo connected to channel 0
FindPSC:·· ' read the firmware version
· DEBUG "Finding PSC", CR
· SEROUT Sdat, Baud+$8000, [noparse][[/noparse]"!SCVER?",CR]
· SERIN· Sdat, Baud, 500, FindPSC, [noparse][[/noparse]STR buff\3]
· DEBUG "PSC ver: ", buff(0), buff(1), buff(2), CR
TestPSC:·· ' move my servo mounted to the front of the Boebot
· DEBUG "Testing PSC"
· DO
··· pw = 1000· ' Left
··· SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
··· PAUSE 1000
··· pw = 750·· ' Center
··· SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
··· PAUSE 1000
··· pw = 500·· ' Right
··· SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
··· PAUSE 1000
· LOOP
Hope that helps!
Matt