Shop OBEX P1 Docs P2 Docs Learn Events
problem with basic stamp 2 carrier board — Parallax Forums

problem with basic stamp 2 carrier board

ArchiverArchiver Posts: 46,084
edited 2002-09-22 14:50 in General Discussion
Hi I've got code like so:
(i'm using a basic stamp 2 chip on a standard bs2 carrier board).

d var byte
serin 16, 16624, [noparse][[/noparse]dec d]
if d = 10 then getReading
serin 16, 16624, [noparse][[/noparse]dec d]
if d = 20 then getSecondSensor


getFirstSensor:
i var byte
for i = 1 to 5
serout 16, 16624, [noparse][[/noparse]26] 'just a dummyvalue for test purposes
pause 1000
next


getSecondSensor:
j var byte
for j = 1 to 5
serout 16, 16624, [noparse][[/noparse]36] 'just a dummyvalue for test purposes
pause 1000
next

On the PC side I've got a VB application using (MSCOMM32.ocx) that
sends 10 out to the serial port, reads 5 numbers from the serial
port , sends 20 and tries to read 5 again.
However, I can only receive 26 5 times in my VB app. After sending
20, my app just freezes - it enters an infinte loop waiting for the 5
36's which never come.

Does anyone know what's wrong ? Is it beacuse of the limitation of
the stamp 2 carrier board as opposed to the board of education for
example - it can't support runtime serial communication through
serout as mentioned in the stamp manual under serin and serout.

Thanks,

Jim

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-09-22 14:44
    Hi Jim,

    there appears to be a number of errors in what you have listed here.
    Firstly, line 3 says to go to "getReading" I am assuming this line
    should read "getFirstSensor".

    I would suggest something like:


    d var byte
    i var byte
    main:
    serin 16, 16624, [noparse][[/noparse]dec d]
    if d = 10 then getFirstSensor
    if d = 20 then getSecondSensor
    GOTO main

    getFirstSensor:
    for i = 1 to 5
    serout 16, 16624, [noparse][[/noparse]26] 'just a dummyvalue for test purposes
    pause 1000
    next
    GOTO main


    getSecondSensor:
    for i = 1 to 5
    serout 16, 16624, [noparse][[/noparse]36] 'just a dummyvalue for test purposes
    pause 1000
    next
    END


    An IF-THEN statement works as a GOTO statement, this means that at
    the end of "getFirstSensor" and "getSecondSensor" code sections there
    needs to be a GOTO to tell the code where to go once it has finished
    the 5 FOR-NEXT commands. With your code, I would expect it to finish
    the 5 FOR-NEXT commands then drop into the "getSecondSensor" code and
    then just stop as it has nowhere to go.

    I have also removed the second "serin 16, 16624, [noparse][[/noparse]dec d]" statement
    as it is not really necessary. By sending the it back to "main", the
    code will receive the 20, and go to "getSecondSensor". Once it has
    finished will END.

    I have also removed the J variable as it is not required.

    Hope this helps.

    Cheers
    Col

    --- In basicstamps@y..., "jamesryfler" <jamesryfler@y...> wrote:
    > Hi I've got code like so:
    > (i'm using a basic stamp 2 chip on a standard bs2 carrier board).
    >
    > d var byte
    > serin 16, 16624, [noparse][[/noparse]dec d]
    > if d = 10 then getReading
    > serin 16, 16624, [noparse][[/noparse]dec d]
    > if d = 20 then getSecondSensor
    >
    >
    > getFirstSensor:
    > i var byte
    > for i = 1 to 5
    > serout 16, 16624, [noparse][[/noparse]26] 'just a dummyvalue for test
    purposes
    > pause 1000
    > next
    >
    >
    > getSecondSensor:
    > j var byte
    > for j = 1 to 5
    > serout 16, 16624, [noparse][[/noparse]36] 'just a dummyvalue for test
    purposes
    > pause 1000
    > next
    >
    > On the PC side I've got a VB application using (MSCOMM32.ocx) that
    > sends 10 out to the serial port, reads 5 numbers from the serial
    > port , sends 20 and tries to read 5 again.
    > However, I can only receive 26 5 times in my VB app. After sending
    > 20, my app just freezes - it enters an infinte loop waiting for the
    5
    > 36's which never come.
    >
    > Does anyone know what's wrong ? Is it beacuse of the limitation of
    > the stamp 2 carrier board as opposed to the board of education for
    > example - it can't support runtime serial communication through
    > serout as mentioned in the stamp manual under serin and serout.
    >
    > Thanks,
    >
    > Jim
  • ArchiverArchiver Posts: 46,084
    edited 2002-09-22 14:50
    Where is the rest of the code between the getFirsSensor and getSecondSensor
    and at the end?

    Also, I don't see any getReading label.

    Right now, it looks like you have a single pass program. As soon as it
    finishes the getFirstSensor loop, it falls through to the getSecondSensor
    loop and then gets the last statement and ends.

    I think you intended to get back to the top after finishing the
    getFirstSensor and getSecondSensor loops.

    You might want to change getFirstSensor and getSecondSensor to subroutines
    with a return at the end of each, then just call them from the first part of
    the program. You will also need a goto to complete the program.

    Original Message
    From: jamesryfler [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=IA-cHyPLYicOvJljEe5HTEasr6f-FFL5yy5fKsCEgoW5gChzJqD3UEcpdsTNUWTl_av5-zCJsVLXOTn9rSSIrSB4]jamesryfler@y...[/url
    Sent: Sunday, September 22, 2002 5:54 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] problem with basic stamp 2 carrier board


    Hi I've got code like so:
    (i'm using a basic stamp 2 chip on a standard bs2 carrier board).

    d var byte
    serin 16, 16624, [noparse][[/noparse]dec d]
    if d = 10 then getReading
    serin 16, 16624, [noparse][[/noparse]dec d]
    if d = 20 then getSecondSensor


    getFirstSensor:
    i var byte
    for i = 1 to 5
    serout 16, 16624, [noparse][[/noparse]26] 'just a dummyvalue for test purposes
    pause 1000
    next


    getSecondSensor:
    j var byte
    for j = 1 to 5
    serout 16, 16624, [noparse][[/noparse]36] 'just a dummyvalue for test purposes
    pause 1000
    next

    On the PC side I've got a VB application using (MSCOMM32.ocx) that
    sends 10 out to the serial port, reads 5 numbers from the serial
    port , sends 20 and tries to read 5 again.
    However, I can only receive 26 5 times in my VB app. After sending
    20, my app just freezes - it enters an infinte loop waiting for the 5
    36's which never come.

    Does anyone know what's wrong ? Is it beacuse of the limitation of
    the stamp 2 carrier board as opposed to the board of education for
    example - it can't support runtime serial communication through
    serout as mentioned in the stamp manual under serin and serout.

    Thanks,

    Jim



















    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/



    This e-mail message may contain legally privileged and/or confidential
    information. If you are not the intended recipient(s), or the employee
    or agent responsible for delivery of this message to the intended
    recipient(s), you are hereby notified that any dissemination,
    distribution or copying of this e-mail message is strictly prohibited.
    If you have received this message in error, please immediately notify
    the sender and delete this e-mail message from your computer.




    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.