Shop OBEX P1 Docs P2 Docs Learn Events
Interfacing RS232 devices — Parallax Forums

Interfacing RS232 devices

Eric AdamsEric Adams Posts: 11
edited 2005-04-22 18:43 in BASIC Stamp
Got a question concerning the input to the stamp from a RS232 (+12/-12) devices.· When I want the stamp to monitor an incomming RS232 signal from a device such as a·DCE from a peripheral what do I have to do to get this +12/-12 volt signal from destroying the stamps input pin.· The stamp cannot take this voltage so there has to be a way to protect the input pin. Any ideas will be greatly appreciated.
Thanks

Comments

  • steve_bsteve_b Posts: 1,563
    edited 2005-04-22 10:36
    I think the standard method is to just limit hte current that would normally hit your stamp pin. This is done with a 22kohm resistor!

    If you go through the Pbasic help file (hint hint) under serin/serout, I believe they have circuit examples indicating the resistor on the incoming rs232 line.
    The outgoing line doesn't need the resistor...but not it only outputs TTL level logic; HOWEVER, this is almost enough on the majority of systems....But you may need a MAX232 type chip to convert TTL to rs232 levels.

    If you are running wires through questionable domains....you might want to optically isolate your stamp. Just a thought!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve
    http://ca.geocities.com/steve.brady@rogers.com/index.html
    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-04-22 13:21
    Yes, using a 22 Kohm resistor in series to connect the +-12 volt signal through the resistor to the BS2 pin actually works. What is happening is that the BS2 has built-in pin protection diodes on each I/O pin. These 'clip' the incoming signal so that the pin sees·0 to 5 volts -- converting the -12 to +12 to a 0 to 5 volt signal.

    Now the protection diodes can only conduct a certain amount of current -- thus the 22 Kohm resistor drops the current enough so that the protection diodes can operate happily.

    Note the physical pins 1 through 4 on the BS2 have a transistor-based RS-232 reciever-driver on them. The TX signal from the PC is used to provide the voltage for the 'RX' signal coming back. You can use this port with the SEROUT 16, 84+16384, [noparse][[/noparse]"Hi"] keyword. Note it is using the 'pseudo' port 16 -- which tells the BS2 to use the built-in programming port on pins 1..4.

    If you want more serial ports than that, a MAX232 chip will allow you to 'send' +-12 volt signals. But if all you want to do is recieve, the 22 Kohm resistor approach works well.
  • Eric AdamsEric Adams Posts: 11
    edited 2005-04-22 18:43
    Thanks for the information and the great explanations.· This group is great
Sign In or Register to comment.