Shop OBEX P1 Docs P2 Docs Learn Events
BS2 serial port with flow control? — Parallax Forums

BS2 serial port with flow control?

firestorm.v1firestorm.v1 Posts: 94
edited 2010-09-24 17:42 in BASIC Stamp
Hey all, it's been a while since I've posted but this time I got a doozy of a question.

I'm working with the BS2 and a Seagate Dockstar using a Prolific PL2303 USB to serial adaptor and I've already tested that the BS2 is able to send and receive data with the Dockstar via the cable.

My issue is that of flow control. Using the BS2 as a platform, the device will be pretty simple codewise. The basic theory is that it will start off at a dead stop and upon receiving a control character "either f s r c w (Forward Stop Reverse clockWise Counterclockwise)" will then continue to carry out that command, e.g. if the BS2 gets "f" it will continue to move forward until a stop or other command is issued.

The problem is that if I put a "DEBUGIN" or SERIN command, the BS2 will jump forward then stop. If I implemented some kind of RTS/CTS handshake (through the use of a MAX232) would I then be able to signal the BS2 to read the serial port, only if there is a keystroke?

I am envisioning the following:
(CTS from BS2 low)
(RTS from DS low)
BS2 happily chugging forward.
Key entered on PC (through linux minicom which supports hardware flow control)
RTS on PC goes high, BS2 raises CTS then reads serial port for "s"
RTS on PC goes low
CTS on BS2 goes low
BS2 halts (the stop command has been received).

If the RTS never goes high, the last received command "F" forward should keep going without stopping to read the serial port.

Is something like this feasible? I would imagine that I would need to run the RTS and the CTS through the MAX232 to protect the BS2 from the +12V of the serial port, but before I go building a complete serial port for this (the RTS and the CTS lines are tied to reset on the BS2's serial programming port, making it not usable.) I want to know if it's possible to code flow control into a BS2 in order for this to happen.

I welcome your suggestions, Thank you!

PS Love the new forum look.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-09-24 07:58
    It would help if we could see your code.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2010-09-24 16:11
    Hey Franklin:

    That's the thing. I haven't started code dev yet as I was looking to see if anyone else had done anything like this before.

    I'd rather make an inquiry now than spend several weeks in development to find that it's not possible.

    Thank you.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-24 16:36
    You will need to process RTS "manually" within your BS2 code. The built-in SERIN flow control can provide CTS when the BS2 actually executes the SERIN and is waiting for something to be transmitted. Whether you need an RS232 level converter depends on how strictly your PC serial port obeys the RS232 requirements. The Stamp Manual shows how to use an I/O pin for RS232 input using a 22K resistor and many serial ports will accept a +5V / 0V signal instead of RS232 voltage levels. If not, then you'll need something like a MAX232 to do the voltage conversion.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2010-09-24 16:56
    Hey Mike, thank you for the information.

    Just to make sure that I'm thinking right, the BS2 should be able to skip over the SERIN if the RTS (from the PC) is low?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-09-24 17:40
    Yes, but you have to program that logic. You'd have an IF statement that checks the I/O pin used for RTS and does a GOTO somewhere if RTS false, otherwise it falls through to the SERIN statement.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2010-09-24 17:42
    Thank you Mike.

    The logic isn't a problem. Now I can start with coding knowing that what I'm doing is feasible.

    Thank you so much for your help!
Sign In or Register to comment.