Shop OBEX P1 Docs P2 Docs Learn Events
Beginner Serial Communication and Pin Out Question — Parallax Forums

Beginner Serial Communication and Pin Out Question

ArchiverArchiver Posts: 46,084
edited 2002-03-22 23:47 in General Discussion
I already have written a program in visual basic 6 on a PC that sends
various characters or character strings through the serial port. How
would i, depending on specific information sent, activate a pin and
make it output voltage until it reads in a second specific character
telling it to shut off. I am junior in high school who has just
purcahsed this BS2p24 and am very interested in these types of
things. I only know how to do very basic things so far, like blinking
an LED. I am hoping through perhaps these responses i will be able to
advance my understanding of this fine machine. Thanks a lot for your
help and time.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-03-22 19:29
    Hi,
    If you look closely at the description of SERIN in the Help menu of
    your Stamp Editor, you will find that you can wait for the occurence
    of ANY character before clocking in any other data. If you are not
    worried about TIME, you could configure SERIN to wait until the
    character before THE CHARACTER IN QUESTION is sent to the Stamp and
    clock in *only* THE CHARACTER IN QUESTION. After that you can do the
    on/off control
    Radu
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-22 21:53
    --- In basicstamps@y..., "raducu80" <raducu80@y...> wrote:
    > Hi,
    > If you look closely at the description of SERIN in the Help menu of
    > your Stamp Editor, you will find that you can wait for the
    occurence
    > of ANY character before clocking in any other data. If you are not
    > worried about TIME, you could configure SERIN to wait until the
    > character before THE CHARACTER IN QUESTION is sent to the Stamp and
    > clock in *only* THE CHARACTER IN QUESTION. After that you can do
    the
    > on/off control
    > Radu


    Thanks a lot for your help Radu, i will take a closer look at the
    information you have mentioned, if anyone else has any other input i
    would love to hear it.
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-22 22:00
    Sorry to sound like a broken record, but...

    The single best reference I have found for all things related to serial
    communication is:

    "The Serial Port Complete," by Jan Axelson.

    Trust me, you need this book. It covers serial comms between PC's,
    from PC's to microcontrollers, and between microcontrollers. Most of
    her microcon examples are based on the Stamp, and all include source
    code.

    Good luck!

    peter
  • ArchiverArchiver Posts: 46,084
    edited 2002-03-22 23:47
    >If you look closely at the description of SERIN in the Help menu of
    >your Stamp Editor, you will find that you can wait for the occurence
    >of ANY character before clocking in any other data. If you are not
    >worried about TIME, you could configure SERIN to wait until the
    >character before THE CHARACTER IN QUESTION is sent to the Stamp and
    >clock in *only* THE CHARACTER IN QUESTION. After that you can do the
    >on/off control
    >Radu

    One trick that I'm using that seems to be working is getting 2 stamps
    to talk to each other using the programming connector (one of the
    stamps is inside the IFI Robot Controller and its the only "real"
    port on the stamp I can get to).

    Basically, I have a stamp acting as a peripheral processor for the
    IFI's stamp, and it sends packets over the serial line on a fairly
    regular basis. When the IFI stamp wants to grab a packet, it reads
    bytes from the programming serial port.

    To sync them, each packet starts with a $FF header, and no byte in
    the fixed length packet can be $FF. The IFI Stamp does a serin with
    a WAIT($FF), then reads in the data.

    If the IFI Stamp starts reading in the middle of a packet, the start
    and stop bits will ensure there is a 10 sequence in the bitstream,
    and it won't see a $FF until the next packet comes in.

    I think there is one pathological situation where it might see a
    spurious $FF, let's see:

    start bits are 0's, stop bits are 1's, so

    start 0 1 1 1 1 1 1 stop

    might be interpreted as a $FF if the serin interpreted the first data
    0 as the start bit, and thinks the stop bit is a data bit (which
    it'll interpret as a 1). This is complicated by the fact that the
    interbyte sending delays imposed by the stamp (several bits worth at
    9600 baud) will appear to be stop bits. But that's low probability
    and can be caught by including a checksum (as long as it is not
    allowed to be $FF, of course). It might be possible to deal with
    this by using non-inverted logic, or alternately by using $00 as the
    "start" byte.

    In my particular application I'm sending a packet of 8 nybbles with
    the 1111 value being illegal, so I'll never have to worry about such
    a misframing. My peripheral stamp is doing it's thing, sending out
    about 50 packets a second, and the IFI stamp can read as many of them
    as it wants.

    If anyone else has been playing with getting stamps talking to each
    other using the programming connectors, I'd be obliged for any tips
    and cautions you might want to offer.

    Best,R
    --

    Woodhead's Law: "The further you are from your server, the more likely
    it is to crash."
Sign In or Register to comment.