Shop OBEX P1 Docs P2 Docs Learn Events
serin/serout — Parallax Forums

serin/serout

ArchiverArchiver Posts: 46,084
edited 2003-07-17 17:29 in General Discussion
Hello everyone. I'm having some trouble with getting a BS2 and BS2SX
to communicate using serin and serout. I programed each with the
example code from the BS2 manual(v1.9 page 318) and then I hooked
them together, but it didn't work. I eventually want to be able to
communicate wirelessly with the HP-900 series transmitter and
reciever from Linx Technologies. Does anyone know what I'm doing
wrong? Thanks.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-01-01 05:19
    if you,re using the same baudmode calculation for both stamps then there is
    a problem.
    check out the v.2 manual for the correct bs2sx
    calc.

    ian
    Original Message
    From: sethjaredjeromiejohnson <sjohns10@h...>
    To: basicstamps@yahoogroups.com <basicstamps@yahoogroups.com>
    Date: Tuesday, January 01, 2002 9:19 AM
    Subject: [noparse][[/noparse]basicstamps] serin/serout


    >Hello everyone. I'm having some trouble with getting a BS2 and BS2SX
    >to communicate using serin and serout. I programed each with the
    >example code from the BS2 manual(v1.9 page 318) and then I hooked
    >them together, but it didn't work. I eventually want to be able to
    >communicate wirelessly with the HP-900 series transmitter and
    >reciever from Linx Technologies. Does anyone know what I'm doing
    >wrong? Thanks.
    >
    >
    >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/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-01-01 22:56
    Hi,
    Like Ian said, check the baud rate table in the manual. Also, double
    check your connections to make sure they are correct. A note of
    caution. If you plan on writing your own codes to network both
    stamps, put a 1 K resistor in between the pins that are used
    as "communication ports". If you have flow control line, the same
    must be done. Otherwise, you might end up burning one or both of your
    Stamps. Like Jon says to everyone, it is cheap insurance.

    Regards,
    RP

    --- In basicstamps@y..., "sethjaredjeromiejohnson" <sjohns10@h...>
    wrote:
    > Hello everyone. I'm having some trouble with getting a BS2 and
    BS2SX
    > to communicate using serin and serout. I programed each with the
    > example code from the BS2 manual(v1.9 page 318) and then I hooked
    > them together, but it didn't work. I eventually want to be able to
    > communicate wirelessly with the HP-900 series transmitter and
    > reciever from Linx Technologies. Does anyone know what I'm doing
    > wrong? Thanks.
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-22 21:56
    I currently have a BS2P40 talking to a BS2SX. The BS2P40 request
    data from the BS2sx, and the sx sends one byte of data. I am using
    flow control and my commands look like this:

    BS2P40
    serout 12\13, 16624,[noparse][[/noparse]dec y]
    &
    serin 12\13, 16624, [noparse][[/noparse]dec order]

    BS2SX
    Await_Instruction:
    serin 6\7, 16624,[noparse][[/noparse]dec Instruction]
    Branch Instruction,[noparse][[/noparse]Await_Instruction,Check_swr]
    &
    serout 6\7, 16624, [noparse][[/noparse]dec order]

    I want to send 3 more numbers across now. How can I send four
    numbers at once, or do I have to stack serin/serout commands. The
    following does not seem to work.

    Serout 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]

    &

    Serin 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-22 22:06
    For jcfjr

    You can serout:

    serout 0, N9600, [noparse][[/noparse]"a", "b", "c"]

    but in order to receive it you have to write serin 0, N9600, [noparse][[/noparse]str namestr\3]

    namestr would have to be declared as namestr var byte(3)

    Sid


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 06:31
    I currently have a BS2P40 talking to a BS2SX. The BS2P40 requests
    data from the BS2sx, and the sx sends one byte of data. I am using
    flow control and my commands look like this:

    BS2P40
    Send request for data-
    serout 12\13, 16624,[noparse][[/noparse]dec y]
    & wait for data-
    serin 12\13, 16624, [noparse][[/noparse]dec order]

    BS2SX
    Await_Instruction:
    serin 6\7, 16624,[noparse][[/noparse]dec Instruction]
    Branch Instruction,[noparse][[/noparse]Await_Instruction,Check_swr]
    & send data-
    serout 6\7, 16624, [noparse][[/noparse]dec order]

    I want to send 3 more numbers across now. How can I send four
    numbers at once, or do I have to stack serin/serout commands. The
    following does not seem to work.

    Serout 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]

    &

    Serin 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]

    Any help would be appreciated!

    Jim
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 16:19
    The dec modifier is problematic, because the length of data sent can
    be one, two or three bytes. (e.g., "1", "12" or "123"). The SEROUT
    needs punctuation, so that the SERIN can tell when one number ends
    and the next begins.

    Serout 12\13, 16624,[noparse][[/noparse]dec order,tab,dec swr(1),tab,dec swr(2),tab,dec swr(3)]

    &

    Serin 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]

    Alternatively, they could all be sent and received using the DEC3
    modifier, always 3 bytes, and the whole string is always 12 bytes:

    Serout 12\13, 16624,[noparse][[/noparse]dec3 order,dec3 swr(1),dec3 swr(2),dec3 swr(3)]

    &

    Serin 12\13, 16624,[noparse][[/noparse]dec3 order,dec3 swr(1),dec3 swr(2),dec3 swr(3)]

    But that is limited to numbers (0-999).

    if the numbers are always bytes (0-255), you could send them as just
    4 bytes, which is much faster:

    Serout 12\13, 16624,[noparse][[/noparse]order,swr(1),swr(2),swr(3)]

    &

    Serin 12\13, 16624,[noparse][[/noparse]order,swr(1),swr(2),swr(3)]

    -- regards,
    Tracy Allen
    electronically monitored ecosystems
    mailto:tracy@e...
    http://www.emesystems.com



    >I currently have a BS2P40 talking to a BS2SX. The BS2P40 requests
    >data from the BS2sx, and the sx sends one byte of data. I am using
    >flow control and my commands look like this:
    >
    >BS2P40
    >Send request for data-
    >serout 12\13, 16624,[noparse][[/noparse]dec y]
    >& wait for data-
    >serin 12\13, 16624, [noparse][[/noparse]dec order]
    >
    >BS2SX
    >Await_Instruction:
    > serin 6\7, 16624,[noparse][[/noparse]dec Instruction]
    > Branch Instruction,[noparse][[/noparse]Await_Instruction,Check_swr]
    >& send data-
    >serout 6\7, 16624, [noparse][[/noparse]dec order]
    >
    >I want to send 3 more numbers across now. How can I send four
    >numbers at once, or do I have to stack serin/serout commands. The
    >following does not seem to work.
    >
    >Serout 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]
    >
    >&
    >
    >Serin 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]
    >
    >Any help would be appreciated!
    >
    >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/
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 17:17
    Steve,

    Thank you for the advice. In the meantime, I have proven you are right. swr
    is only a one digit number, that I only want to display, not calculate. So I
    have gotten around it with strings.

    serout 6\7, 16624, [noparse][[/noparse]dec order,str swr\4]

    I will try your suggestion and see if I can deal with numbers, but after
    studying yours, I am sure yours will work also.

    Thanks again.

    Jim


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-23 17:22
    Jim-

    I think the problem may be you're SEROUTing an unbroken stream of
    ASCII numbers which the SERIN is unable to separate into distinct
    representations of variable values.

    For instance, if order = 1, swr(1) = 234, swr(2) = 56, swr(3) = 78,
    the SEROUT will send "12345678". The SERIN will unsuccessfully
    attempt to assign 12345678 to order, leaving nothing from the input
    stream for the other variables.

    Try using constant length DEC representations or delimiters to break
    the data stream up into its logical pieces:

    Serout 12\13, 16624,[noparse][[/noparse]dec2 order,dec3 swr(1),dec3 swr(2),dec3 swr(3)]
    Serin 12\13, 16624,[noparse][[/noparse]dec2 order,dec3 swr(1),dec3 swr(2),dec3 swr(3)]

    or

    Serout 12\13, 16624,[noparse][[/noparse]dec order, ",", dec swr(1), ",", dec swr(2), ",", dec
    swr(3), ","]
    Serin 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]

    Regards,

    Steve

    jcfjr007 wrote:

    > ...How can I send four numbers at once, or do I have to stack
    > serin/serout commands. The following does not seem to work.
    >
    > Serout 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]
    >
    > &
    >
    > Serin 12\13, 16624,[noparse][[/noparse]dec order,dec swr(1),dec swr(2),dec swr(3)]
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-17 16:19
    Is there a difference between

    SEROUT DOUT, Baud, [noparse][[/noparse]d0, d1, d2, d3, d4, d5, d6, d7] versus

    SEROUT DOUT, Baud, [noparse][[/noparse]d0]
    SEROUT DOUT, Baud, [noparse][[/noparse]d1]
    etc. to
    SEROUT DOUT, Baud, [noparse][[/noparse]d7}?

    I have another BS2 expecting 8 bytes of data (using SERIN DIN, Baud,
    [noparse][[/noparse]d0, d1, d2, d3, d4, d5, d6, d7] and was wondering if 8 separate
    SEROUT can send data without timing issues.

    Can someone please help?
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-17 17:12
    They will function the same, but the second version, with its multiple
    calls to the SEROUT function, will consume quite a bit more EEPROM
    space. You can verify this with the Memory Map tool in the editor.

    -- Jon Williams
    -- Parallax

    Original Message
    From: yellowniter [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=26nJg6Qqwgs3VLO-kpV_KdVOh3Fo_WzrCP-lWpHvoXbJvsNL8D4RKMl5Kp9kPkpEFQ2GzuFfCHoJO1DddSTEgw]yellowniter@y...[/url
    Sent: Thursday, July 17, 2003 10:19 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Serin/Serout


    Is there a difference between

    SEROUT DOUT, Baud, [noparse][[/noparse]d0, d1, d2, d3, d4, d5, d6, d7] versus

    SEROUT DOUT, Baud, [noparse][[/noparse]d0]
    SEROUT DOUT, Baud, [noparse][[/noparse]d1]
    etc. to
    SEROUT DOUT, Baud, [noparse][[/noparse]d7}?

    I have another BS2 expecting 8 bytes of data (using SERIN DIN, Baud,
    [noparse][[/noparse]d0, d1, d2, d3, d4, d5, d6, d7] and was wondering if 8 separate
    SEROUT can send data without timing issues.

    Can someone please help?


    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 message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-17 17:29
    The major difference is that there will be
    command interpretation time between bytes
    in the second instance.
    (You can do the same thing, with less
    use of EEPROM, with a FOR loop)

    So if your goal was to put additional
    space between the bytes, so the receiving
    BS2 has more time, yes, that should work.

    For this to work, however, you must
    insure somehow that the receiving BS2 is
    waiting on 'd0' when the transmitting BS2
    starts sending 'd0'.

    --- In basicstamps@yahoogroups.com, "yellowniter" <yellowniter@y...>
    wrote:
    > Is there a difference between
    >
    > SEROUT DOUT, Baud, [noparse][[/noparse]d0, d1, d2, d3, d4, d5, d6, d7] versus
    >
    > SEROUT DOUT, Baud, [noparse][[/noparse]d0]
    > SEROUT DOUT, Baud, [noparse][[/noparse]d1]
    > etc. to
    > SEROUT DOUT, Baud, [noparse][[/noparse]d7}?
    >
    > I have another BS2 expecting 8 bytes of data (using SERIN DIN,
    Baud,
    > [noparse][[/noparse]d0, d1, d2, d3, d4, d5, d6, d7] and was wondering if 8 separate
    > SEROUT can send data without timing issues.
    >
    > Can someone please help?
Sign In or Register to comment.