Shop OBEX P1 Docs P2 Docs Learn Events
PSC Not Communicating With BS2 — Parallax Forums

PSC Not Communicating With BS2

dabearsdabears Posts: 4
edited 2006-05-05 20:00 in BASIC Stamp
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

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-05-05 08:12
    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 -->
  • dabearsdabears Posts: 4
    edited 2006-05-05 17:12
    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
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-05-05 17:25
    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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-05 17:44
    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
  • dabearsdabears Posts: 4
    edited 2006-05-05 19:20
    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, [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
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-05-05 19:46
    Umm, that code looks like it's only targeting one motor.
  • dabearsdabears Posts: 4
    edited 2006-05-05 19:56
    I have the the motors on ch 1 and ch 3...
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2006-05-05 19:59
    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

    Post Edited (Ryan Clarke (Parallax)) : 5/5/2006 8:53:37 PM GMT
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2006-05-05 20:00
    I also do not understand why you are looping...

    Ryan

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

    RClarke@Parallax.com
Sign In or Register to comment.