Shop OBEX P1 Docs P2 Docs Learn Events
BS2px can't find PSC — Parallax Forums

BS2px can't find PSC

RickyCRickyC Posts: 26
edited 2006-09-29 05:04 in BASIC Stamp
Hello, as I am new on stamp. Can anybody tell me why I always get error " undefind label " message for FindPSC on line SERIN? Thks,
Ricky

' {$STAMP BS2px}
' {$PBASIC 2.5}
' {$PORT COM6}
Sdat····· PIN···· 15
Baud····· CON···· 84
buff····· VAR···· Byte(3)
· DEBUG·· "Finding PSC",CR
· SEROUT Sdat, Baud+84, [noparse][[/noparse]"!SCVER?",CR]
· SERIN· Sdat, Baud+84,FindPSC,[noparse][[/noparse]STR buff\3]
· DEBUG·· "PSC ver: ", buff(0), buff(1), buff(2),CR
· STOP

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-09-28 08:58
    RickyC -

    I guess the best answer is because you copied the program incorrectly from the manual. Here's what it should look like:

    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    ' {$PORT COM6}

    Sdat PIN 15
    Baud CON 84
    buff VAR Byte(3)

    FindPSC:
    DEBUG "Finding PSC",CR
    SEROUT Sdat, Baud+84, [noparse][[/noparse]"!SCVER?",CR]
    SERIN Sdat, Baud+84,FindPSC,[noparse][[/noparse]STR buff\3]
    DEBUG "PSC ver: ", buff(0), buff(1), buff(2),CR
    STOP


    Just as a matter of information, I suspect your baudmode is incorrect.

    Regards,

    Bruce Bates

    Post Edited (Bruce Bates) : 9/28/2006 9:11:52 AM GMT
  • RickyCRickyC Posts: 26
    edited 2006-09-28 08:58
    I can run the program as below but only got "Finding PSC" on debug window repeatedly and no ver. read.
    Ricky

    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    ' {$PORT COM6}
    Sdat PIN 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
  • RickyCRickyC Posts: 26
    edited 2006-09-28 09:10
    I can find ver: 1.4 on debug window now. just change "Baud con 1646"
    Thks,
    Ricky
  • RickyCRickyC Posts: 26
    edited 2006-09-28 09:22
    Thks Bruce, Yes I just copy from the manual as I am new on programing. I just change the baud rate to 1646 and that works now. But I write another code program and save in .bpx file that will come up error message of " undefined label" on line SERIN. I don't know why?

    Ricky
    Bruce Bates said...
    RickyC -

    I guess the best answer is because you copied the program incorrectly from the manual. Here's what it should look like:

    ' {$STAMP BS2px}
    ' {$PBASIC 2.5}
    ' {$PORT COM6}

    Sdat PIN 15
    Baud CON 84
    buff VAR Byte(3)

    FindPSC:
    DEBUG "Finding PSC",CR
    SEROUT Sdat, Baud+84, [noparse][[/noparse]"!SCVER?",CR]
    SERIN Sdat, Baud+84,FindPSC,[noparse][[/noparse]STR buff\3]
    DEBUG "PSC ver: ", buff(0), buff(1), buff(2),CR
    STOP


    Just as a matter of information, I suspect your baudmode is incorrect.

    Regards,

    Bruce Bates

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-09-28 09:35
    Ricky -

    I answered this question for you 10 minutes ago. The label "FindPSC" is missing, as it states. I even went so far as to copy the program and insert it in the correct place. See the above message, as it appears there as well.

    If you're asking why it's there, you may want to consult the PBASIC Reference Guide or the PBASIC Help File for the proper syntax for the SERIN command. Either/both can be downloaded for FREE from the Parallax web site "Downloads Section".

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • RickyCRickyC Posts: 26
    edited 2006-09-28 09:52
    Yes, Bruce

    I am·checking·on reference manual now.

    bst rgds,

    Ricky
    Bruce Bates said...
    Ricky -

    I answered this question for you 10 minutes ago. The label "FindPSC" is missing, as it states. I even went so far as to copy the program and insert it in the correct place. See the above message, as it appears there as well.

    If you're asking why it's there, you may want to consult the PBASIC Reference Guide or the PBASIC Help File for the proper syntax for the SERIN command. Either/both can be downloaded for FREE from the Parallax web site "Downloads Section".

    Regards,

    Bruce Bates

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-09-28 11:18
    Ricky -

    I just reaized there is one more typo in the program you entered. This show s why a copy-and-paste approach is much better than hand coding examples. The revised program is below with both necessary changes noted ('·^^^^^ ).

    Sdat PIN 15
    Baud CON 84
    buff VAR Byte(3)

    FindPSC:
    '^^^^^
    DEBUG "Finding PSC",CR
    SEROUT Sdat, Baud+84, [noparse][[/noparse]"!SCVER?",CR]
    SERIN Sdat, Baud+84, 500, FindPSC, [noparse][[/noparse]STR buff\3]
    '······························· ^^^
    DEBUG "PSC ver: ", buff(0), buff(1), buff(2),CR
    STOP

    =====

    My apologies for not catching that the first time around.

    Regards,

    Bruce Bates
  • RickyCRickyC Posts: 26
    edited 2006-09-29 05:04
    Bruse, thks,I tried your new program and still found not work untill change·Baud to 1646 beause PSC's defaut rate is 2400. After that I tried·some·code files and that can control·servoes now.·I still have some problem on controlling PSC via PSCI. If you have such knowledge, pls teach me. Thks,·
    Ricky
    ·
    Bruce Bates said...
    Ricky -

    I just reaized there is one more typo in the program you entered. This show s why a copy-and-paste approach is much better than hand coding examples. The revised program is below with both necessary changes noted ('·^^^^^ ).

    Sdat PIN 15
    Baud CON 84
    buff VAR Byte(3)

    FindPSC:
    '^^^^^
    DEBUG "Finding PSC",CR
    SEROUT Sdat, Baud+84, [noparse][[/noparse]"!SCVER?",CR]
    SERIN Sdat, Baud+84, 500, FindPSC, [noparse][[/noparse]STR buff\3]
    '······························· ^^^
    DEBUG "PSC ver: ", buff(0), buff(1), buff(2),CR
    STOP

    =====

    My apologies for not catching that the first time around.

    Regards,

    Bruce Bates
Sign In or Register to comment.