Shop OBEX P1 Docs P2 Docs Learn Events
serial pins — Parallax Forums

serial pins

cplattcplatt Posts: 55
edited 2008-11-11 16:50 in BASIC Stamp
Sorry for the ignorance here.

I understand how to serially communicate using serin with the stamp via the com port on the BOE and pin16. The my stamp basically listens every half second for the PC to send something.

I would like to add an additional pin somehow for data control. (sorry I do not know this term) so instead of constantly listening, the PC sends a message "wake up you stamp here comes a message", and the stamp says "ok I am ready to receive it".

I assume I have to get into the DB9 connector somehow to run a shunt to another pin on the BOE, there is a lot of info in the stamp manual but it is not so clear to me.

Any links would be greatly appreciated.

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2008-11-11 15:37
    Hi, because the PC can react quicker than the Stamp I think it is best for the Stamp to send a "wake up" to the PC saying "hey I'm ready for data".

    If you are using the programming port and P16 you could do

    SEROUT tx,baud,[noparse][[/noparse]"Rdy"]

    SERIN rx,baud,timeout_value,timeout_label,[noparse][[/noparse]DataIn]

    and have the PC look for the Rdy signal

    If you are using a line driver such as the Max232 you could attach a third wire to the CTS line for a hardwired flow control and do

    HIGH CTS

    SERIN rx,baud,timeout_value,timeout_label,[noparse][[/noparse]DataIn]

    LOW CTS

    and have the PC look for the·CTS line going high

    Jeff T.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-11-11 15:43
    The BS2 can only recieve serial data when it's "waiting" in a SERIN statement. However, the SERIN statement does have a time-out parameter, so your program can continue after a delay waiting in the SERIN statement.

    The PC will buffer up anything sent from the BS2, so one way is to have the BS2 periodically send a "!" (or some signal character) just before it does your time-out SERIN to notify the PC it's ready for data, if any.

    I suppose you COULD use the "RTS" signal from the PC, IF you can get control of the signal separately from the 'standard serial port' useage. Under VB6, you could do this with the RTSEnable method of the MSCOMM control. I've done this under RealBASIC by opening the COM port -- but I don't have that code handy right now.

    And you would need to add a wire from the RTS signal to some I/O pin of the BS2 (through a 22 Kohm resistor -- the PC drives this pin with +-3 volts to +-10 volts, the 22 Kohm resistor will protect the BS2).
  • cplattcplatt Posts: 55
    edited 2008-11-11 16:50
    Thank you guys that is very helpful...I forgot to say I am using a USB BOE so there is probably no way to get hardware control from the PC at least. Software control sounds like the way to go, I need to learn about the time-out parameter and may come back to this thread. What I am trying to avoid is the stamp always listening for the PC's transmission, yet missing it if the PC sends in between the listening loop of the stamp. Maybe creative software control will help with this with your suggestions...(?)
Sign In or Register to comment.