Shop OBEX P1 Docs P2 Docs Learn Events
Servo Controller Board problems — Parallax Forums

Servo Controller Board problems

neuromitneuromit Posts: 7
edited 2008-09-27 22:22 in BASIC Stamp
I've been trying to go through the Servo Controller Manual, to control multiple servos at the same time.

I'm starting with one servo and when I figure that one out I'll move to the others...

I've tried running the code in the manual that lets you get the Baud Rate of your PSC
' {$STAMP BS2}
' {$PBASIC 2.5}
Sdat            PIN     15                     ' Serial Data I/O pin
Baud            CON     396                    ' Constant for 2400 baud
buff            VAR     Byte(3)                ' temporary variable

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

GOSUB FindPSC



But when I try to compile I get: Error: Can't create (null). I can't find any documentation about what this means....

Not getting the baud rate really isn't my problem but when I try to switch between two servo positions and then query the servo location the servo just stays in one place:

Here is the code:


' {$STAMP BS2}
' {$PBASIC  2.5}
ch    VAR  Byte
pw    VAR  Word
ra    VAR  Byte
x     VAR  Byte
Buff VAR   Byte(3)
Sdat CON   15
baud CON   396

Init:
  ra =    15: ch = 0
DO
  DEBUG "Running Loop", CR

  pw = 1240

  DEBUG "1 "
  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]"!SCRSP", ch, CR]
    SERIN Sdat, Baud, 1000, Init,[noparse][[/noparse]STR Buff\3]
    DEBUG "Servo ", DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR
  NEXT

  pw = 260

  DEBUG "2", CR
  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]"!SCRSP", ch, CR]
    SERIN Sdat, Baud, 1000, Init,[noparse][[/noparse]STR Buff\3]
    DEBUG "Servo ", DEC buff(0), " ", HEX2 buff(1), " :", HEX2 buff(2), CR
  NEXT

LOOP




My output is: Running Loop followed with 1, I never see 2

ALso I never get output that says were my servo is....

I'm really confused... I know I'm probably doing this wrong but I don't know why...

Comments

  • ZootZoot Posts: 2,227
    edited 2008-09-26 20:34
    Program 1: replace GOSUB FindPSC with GOTO FindPSC (otherwise you end up in an endless subroutine call/loop without a return and I'm sure this will crash).

    Program 2: looks OK. If you never get past 'debug "1"' then the program is probably timing out while waiting on the SERIN, or the program is resetting.

    Try the obvious first -- do you have enough power for the servos and the stamp? Do you have the jumper on the PSC set so that it responds to channels 0-15? Connection good between your Sdat stamp pin and the PSC serial pin?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • neuromitneuromit Posts: 7
    edited 2008-09-27 15:19
    So I changed pscIdentify.ps2 to:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    Sdat            PIN     14                     ' 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
    
    goto FindPSC
    
    


    Here is the output:
    DEBUG OUTPUT:     (Press [noparse][[/noparse]Control]-[noparse][[/noparse]C] to complete sequence)
    _____________________________________________________________________
    Finding PSC
    Finding PSC
    Finding PSC
    
    



    I'm pretty sure the PSC is connected to the Board of Education correctly b/c everytime a new "Finding PSC" shows up I get a blink from a green LED on the PSC...
    Also I know that the board is powered correctly as I have a 9v battery powering the BOE. I know that the Servos have 6V as I'm using a really high end powersupply to power the servos (its way overkill to use this power supply but I won't get into why i'm using it)....
  • neuromitneuromit Posts: 7
    edited 2008-09-27 15:20
    Could this be an issue with the Buad rate?
  • ZootZoot Posts: 2,227
    edited 2008-09-27 15:37
    The green light on the PSC just means that the serial line was driven low (either by the Stamp or the PSC) -- it does not necessarily mean they are communicating. But at least you're hooked up :-)

    Try this and see if you get a response.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    Sdat            PIN     14                     ' Serial Data I/O pin
    Baud            CON     396  + $8000                  ' Constant for 2400 baud open true
    buff            VAR     Byte(3)                ' temporary variable
    FindPSC:                                       ' Find and get the version
      DEBUG  "Finding PSC", CR                     ' number of the PSC.
      SEROUT Sdat, Baud, [noparse][[/noparse]"!SCVER?",CR]
      SERIN  Sdat, Baud, 500, FindPSC, [noparse][[/noparse]STR buff\3]
      DEBUG  "PSC ver: ", buff(0), buff(1), buff(2), CR
    
    DO:LOOP
    



    This should keep printing "finding psc" if it can't communicate with the psc, otherwise it should print the psc firmware revision number and stop.

    Also try to hitting the reset button on the PSC after powerup.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-09-27 16:15
    neromit -

    If Zoot's suggestion fails as well, try this:

    Debug "Starting"
    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


    goto FindPSC

    If "Starting" appears more than once, something is resetting the Stamp.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • neuromitneuromit Posts: 7
    edited 2008-09-27 17:17
    So i ran the code posted both by bruce and zoots, i thank you both for your help
    when I run the code posted by bruce, i get:
    DEBUG OUTPUT:     (Press [noparse][[/noparse]Control]-[noparse][[/noparse]C] to complete sequence)
    _____________________________________________________________________
    StartingFinding PSC
    Finding PSC
    Finding PSC
    Finding PSC
    
    
    




    So does this mean the PSC could be bad?
    Could this be a baud rate issue?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-09-27 17:34
    neromit -

    The last thing I would suspect would be a bad PSC. I don't know much about that but if they can be "strapped" for baud rate, make sure it is strapped correctly.

    Next to that I'd double check the wiring. Make sure Tx goes to Rx and Rx goes to Tx.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • ZootZoot Posts: 2,227
    edited 2008-09-27 19:58
    From the PSC manual. Unfortunately, note the last line in particular:
    manual said...
    Within the DEBUG window, you will see a series of “Finding PSC” messages. The Stamp should find the
    unit immediately. This is evidenced by the PSC replying with a number like “1.3”, which is it’s firmware
    version number. If after 3 or 4 messages the PSC has not been found, you should check that all the
    connections are proper and that power is applied. If the PSC fails to respond, you may momentarily push
    the Reset button on the PSC. If the PSC fails to respond, contact Parallax Technical Support at (916)

    624-8333.

    (Bruce --·there is only one data connection to a PSC -- serial i/o. Baud rate is changed via serial commands -- default 2400)


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • neuromitneuromit Posts: 7
    edited 2008-09-27 22:22
    So the PSC is bad... I had a jumper set to Vdd instead of Vin and I was putting 7 volts out to the PSC... I fixed the jumper got a new board and it worked! But I fried the first board. Anyway thanks for your help!
Sign In or Register to comment.