PDA

View Full Version : PSC Not Communicating With BS2



dabears
05-05-2006, 02:25 PM
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, ["!SCVER?",CR]
SERIN Sdat, Baud, 500, FindPSC, [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

Bruce Bates
05-05-2006, 03:12 PM
Joe -

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 -->

dabears
05-06-2006, 12:12 AM
OK,

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

allanlane5
05-06-2006, 12:25 AM
Looks like your SERIN is repeatedly timing out, and going back to the start of your program. 1/2 second may not be long enough for the entire message to come back from the PSC.

And you DID connect a ground wire between your BS2 and your·PSC, right?

Chris Savage
05-06-2006, 12:44 AM
Joe,

·· 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 (mailto:csavage@parallax.com)

dabears
05-06-2006, 02:20 AM
Cool That Worked! Thanks, I now cant seem to get both motors to run in parrellel with the code below;

'{$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, ["!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
· FOR x = 0 TO 4
··· PAUSE·· 1000
··· SEROUT· Sdat, Baud+$8000, ["!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
··· SERIN·· Sdat, Baud, 1500, Init, [STR Buff\3]
··· DEBUG "Servo", DEC buff(0), "· ", HEX2 buff(1), " :", HEX2 buff(2), CR
· NEXT
· RETURN

ANY Thoughts?

Joe

allanlane5
05-06-2006, 02:46 AM
Umm, that code looks like it's only targeting one motor.

dabears
05-06-2006, 02:56 AM
I have the the motors on ch 1 and ch 3...

Ryan Clarke
05-06-2006, 02:59 AM
Take a look at your code again, and consider the following:

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 (mailto:RClarke@Parallax.com)

Post Edited (Ryan Clarke (Parallax)) : 5/5/2006 8:53:37 PM GMT

Ryan Clarke
05-06-2006, 03:00 AM
I also do not understand why you are looping...

Ryan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support

RClarke@Parallax.com (mailto:RClarke@Parallax.com)