PSC Not Communicating With BS2
dabears
Posts: 4
I need help, I bought a PSC to control a few servo motors and I followed the code instructions and I get an error at (PIN) if I try the test code below;
'{$STAMP BS2}
Sdat CON 15 ' Serial Data I/O pin
Baud CON 396 ' Constant for 2400 baud
buff VAR Byte(3) ' temporary variable
FindPSC: ' Find and get the version
DEBUG "Finding PSC", CR ' number of the PSC.
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
STOP
I then changed it to (CON) but still no communication. The red light is on but no green. I tried the reset but no change. I'm in·a bind any help would be great.
Joe
'{$STAMP BS2}
Sdat CON 15 ' Serial Data I/O pin
Baud CON 396 ' Constant for 2400 baud
buff VAR Byte(3) ' temporary variable
FindPSC: ' Find and get the version
DEBUG "Finding PSC", CR ' number of the PSC.
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
STOP
I then changed it to (CON) but still no communication. The red light is on but no green. I tried the reset but no change. I'm in·a bind any help would be great.
Joe
Comments
Make the very beginning of your program look like this:
'{$STAMP BS2}
'{$PBASIC 2.5}
and you should be fine.
The PIN directive came about in PBASIC Revision 2.5
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
I made the change but I still get the;
Finding PSC
Finding PSC
Finding PSC
" "
And no response back! I have the serial in P15.
Joe
And you DID connect a ground wire between your BS2 and your·PSC, right?
·· Are you using a BS2 or another version of the BASIC Stamp?· How is the PSC connected to the BASIC Stamp?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
'{$STAMP BS2}
'{$PBASIC 2.5}
ch······· VAR Byte
pw······· VAR Word
ra······· VAR Byte
x········ VAR Byte
Buff····· VAR Byte(3)
Sdat····· PIN 15······································· ' Serial Data I/O pin
baud····· CON 396····································· ' Constant for 2400 baud
Init:
· ra = 15: ch = 1
· ra = 15: ch = 3
DO
· pw = 1200: GOSUB WRservo
· pw = 240: GOSUB WRservo
LOOP
WRservo:
· SEROUT· Sdat, Baud+$8000, [noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
· FOR x = 0 TO 4
··· PAUSE·· 1000
··· SEROUT· Sdat, Baud+$8000, [noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
··· SERIN·· Sdat, Baud, 1500, Init, [noparse][[/noparse]STR Buff\3]
··· DEBUG "Servo", DEC buff(0), "· ", HEX2 buff(1), " :", HEX2 buff(2), CR
· NEXT
· RETURN
ANY Thoughts?
Joe
If I have a var named x, what value will x hold if I do this-
x = 1
x = 3
Now, at this point what is the value of x?
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
Post Edited (Ryan Clarke (Parallax)) : 5/5/2006 8:53:37 PM GMT
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com