Shop OBEX P1 Docs P2 Docs Learn Events
communication between two stamps — Parallax Forums

communication between two stamps

ArchiverArchiver Posts: 46,084
edited 2003-07-21 19:02 in General Discussion
I just wanted to know how I would go about getting a stamp to loop
through a series of SERIN's - say on four pins - and then to branch
when one of those pins received data.

Thanks

Paul

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-07-21 16:36
    There is a problem with this approach.
    When the BS2 is doing 'SERIN' on one pin,
    it will ignore signals being recieved
    on the next pin, until the one SERIN is
    completed.

    What you could do is use the 'FPIN' option.
    When the SERIN command runs in the BS2, it
    will make the FPIN signal an output. You
    can send this to the remote port as an
    'CTS' signal. When the remote port recieves
    this, it should send the byte, which the
    BS2 is now ready to receive. See the
    BS2 Programming Manual 2.0c, pg 289.

    Combine this with a timeout, so if the
    remote device does not have any data
    the BS2 will not hang, and you can now
    sample 4 ports. The data will 'sit'
    in the remote device until the BS2
    signals it is ready to receive it.

    This does take 8 pins (4 rx, and 4 FPIN)
    but it gets around the SERIN limitation
    of the BS2.

    So:
    LoopTop:
    SERIN P0\P1, Baud1, Skip1, 500, [noparse][[/noparse]MyByte1]
    GOSUB Byte1Read
    Skip1:
    SERIN P2\P3, Baud1, Skip2, 500, [noparse][[/noparse]MyByte2]
    GOSUB Byte2Read
    Skip2:
    SERIN P4\P5, Baud1, Skip3, 500, [noparse][[/noparse]MyByte3]
    GOSUB Byte3Read
    Skip3:
    SERIN P6\P7, Baud1, Skip4, 500, [noparse][[/noparse]MyByte1]
    GOSUB Byte4Read
    Skip4:
    GOTO LoopTop

    END

    Note you WILL have to have some kind of
    RS232 driver on the 'FPIN' signals, if
    you are talking to a PC, anyway.

    Also, turn on Hardware Handshake on the
    PC.
    --- In basicstamps@yahoogroups.com, "justforgoyourmove" <pjw24@c...>
    wrote:
    > I just wanted to know how I would go about getting a stamp to loop
    > through a series of SERIN's - say on four pins - and then to branch
    > when one of those pins received data.
    >
    > Thanks
    >
    > Paul
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-21 18:38
    In your sample code should the label to branch to on time out come
    after the time because the compiler is complaining that it expected
    a label there?

    Thanks - you've been very helpful

    Paul
    --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    wrote:
    > There is a problem with this approach.
    > When the BS2 is doing 'SERIN' on one pin,
    > it will ignore signals being recieved
    > on the next pin, until the one SERIN is
    > completed.
    >
    > What you could do is use the 'FPIN' option.
    > When the SERIN command runs in the BS2, it
    > will make the FPIN signal an output. You
    > can send this to the remote port as an
    > 'CTS' signal. When the remote port recieves
    > this, it should send the byte, which the
    > BS2 is now ready to receive. See the
    > BS2 Programming Manual 2.0c, pg 289.
    >
    > Combine this with a timeout, so if the
    > remote device does not have any data
    > the BS2 will not hang, and you can now
    > sample 4 ports. The data will 'sit'
    > in the remote device until the BS2
    > signals it is ready to receive it.
    >
    > This does take 8 pins (4 rx, and 4 FPIN)
    > but it gets around the SERIN limitation
    > of the BS2.
    >
    > So:
    > LoopTop:
    > SERIN P0\P1, Baud1, Skip1, 500, [noparse][[/noparse]MyByte1]
    > GOSUB Byte1Read
    > Skip1:
    > SERIN P2\P3, Baud1, Skip2, 500, [noparse][[/noparse]MyByte2]
    > GOSUB Byte2Read
    > Skip2:
    > SERIN P4\P5, Baud1, Skip3, 500, [noparse][[/noparse]MyByte3]
    > GOSUB Byte3Read
    > Skip3:
    > SERIN P6\P7, Baud1, Skip4, 500, [noparse][[/noparse]MyByte1]
    > GOSUB Byte4Read
    > Skip4:
    > GOTO LoopTop
    >
    > END
    >
    > Note you WILL have to have some kind of
    > RS232 driver on the 'FPIN' signals, if
    > you are talking to a PC, anyway.
    >
    > Also, turn on Hardware Handshake on the
    > PC.
    > --- In basicstamps@yahoogroups.com, "justforgoyourmove"
    <pjw24@c...>
    > wrote:
    > > I just wanted to know how I would go about getting a stamp to
    loop
    > > through a series of SERIN's - say on four pins - and then to
    branch
    > > when one of those pins received data.
    > >
    > > Thanks
    > >
    > > Paul
  • ArchiverArchiver Posts: 46,084
    edited 2003-07-21 19:02
    You are correct. Usually I insure the code I
    post is compileable and runnable. Just this
    once, I didn't check it through the compiler,
    sigh.

    --- In basicstamps@yahoogroups.com, "justforgoyourmove" <pjw24@c...>
    wrote:
    > In your sample code should the label to branch to on time out come
    > after the time because the compiler is complaining that it expected
    > a label there?
    >
    > Thanks - you've been very helpful
    >
    > Paul
    > --- In basicstamps@yahoogroups.com, "Allan Lane" <allan.lane@h...>
    > wrote:
    > > There is a problem with this approach.
    > > When the BS2 is doing 'SERIN' on one pin,
    > > it will ignore signals being recieved
    > > on the next pin, until the one SERIN is
    > > completed.
    > >
    > > What you could do is use the 'FPIN' option.
    > > When the SERIN command runs in the BS2, it
    > > will make the FPIN signal an output. You
    > > can send this to the remote port as an
    > > 'CTS' signal. When the remote port recieves
    > > this, it should send the byte, which the
    > > BS2 is now ready to receive. See the
    > > BS2 Programming Manual 2.0c, pg 289.
    > >
    > > Combine this with a timeout, so if the
    > > remote device does not have any data
    > > the BS2 will not hang, and you can now
    > > sample 4 ports. The data will 'sit'
    > > in the remote device until the BS2
    > > signals it is ready to receive it.
    > >
    > > This does take 8 pins (4 rx, and 4 FPIN)
    > > but it gets around the SERIN limitation
    > > of the BS2.
    > >
    > > So:
    > > LoopTop:
    > > SERIN P0\P1, Baud1, Skip1, 500, [noparse][[/noparse]MyByte1]
    > > GOSUB Byte1Read
    > > Skip1:
    > > SERIN P2\P3, Baud1, Skip2, 500, [noparse][[/noparse]MyByte2]
    > > GOSUB Byte2Read
    > > Skip2:
    > > SERIN P4\P5, Baud1, Skip3, 500, [noparse][[/noparse]MyByte3]
    > > GOSUB Byte3Read
    > > Skip3:
    > > SERIN P6\P7, Baud1, Skip4, 500, [noparse][[/noparse]MyByte1]
    > > GOSUB Byte4Read
    > > Skip4:
    > > GOTO LoopTop
    > >
    > > END
    > >
    > > Note you WILL have to have some kind of
    > > RS232 driver on the 'FPIN' signals, if
    > > you are talking to a PC, anyway.
    > >
    > > Also, turn on Hardware Handshake on the
    > > PC.
    > > --- In basicstamps@yahoogroups.com, "justforgoyourmove"
    > <pjw24@c...>
    > > wrote:
    > > > I just wanted to know how I would go about getting a stamp to
    > loop
    > > > through a series of SERIN's - say on four pins - and then to
    > branch
    > > > when one of those pins received data.
    > > >
    > > > Thanks
    > > >
    > > > Paul
Sign In or Register to comment.