Connect with us

really simple RS232-TTL converter... does it work?

Discussion in 'Electronic Design' started by Dan Lenski, Jan 19, 2007.

  1. Dan Lenski

    Dan Lenski Guest

    Hi all,
    I'm playing around with a wireless router that has a TTL-level serial
    port and trying to figure out an easy way to convert it to RS-232
    without having to wait for a Maxim IC to come in the mail. While
    hunting around for tricks to doing this, I came across one that seems
    really impressive:
    http://www.botkin.org/dale/rs232_interface.htm

    The "receive" portion seems straightforward: just use an n-type MOSFET
    and pull-up resistor to switch the TTL output between 0 and 5V.

    But the "transmit" portion seems a little dodgy: first, it relies on
    the computer always putting out +12V on the RTS pin, which apparently
    is the default state of that pin if you leave hardware flow control
    off. And secondly, it can can only transmit 0V or +12V. And according
    to the RS-232 standard, 0V is undefined (+-3V are the thresholds).

    The guy who came up with this says that it has worked with every
    laptop, desktop, and PDA serial port that he's tried. Kind of cool...
    so I guess that most computers interpret a 0V signal as a logical 1, as
    would be required to make this scheme work? Has anyone used this
    simple level converter? How'd it work for you?

    Thanks,
    Dan Lenski
     
  2. John Larkin

    John Larkin Guest


    Pure TTL out usually works, and just a series resistor for the input
    direction, to limit the current. Data isn't inverted, of course.

    John
     
  3. Dan Lenski

    Dan Lenski Guest

    Yeah, I've heard that. But the serial protocol is done in hardware on
    both ends (my computer, the system-on-a-chip in the router), so I
    couldn't use a non-inverting method. This trick with the MOSFETs does
    seem pretty good to me...
     
  4. Guest

    Unless you are driving a long line, I would avoid any 232 chip with a
    charge pump. They add jitter to the signal. [I've designed some of the
    Maxim parts, and trust me, it is something you check in the lab since
    the test engineer needs to know the limits of the jitter. I don't know
    if any datasheets show this.]

    The typical 232 receiver is just an inverter, a resistor divider, and a
    diode clamp. The -3V trip points doesn't have to be reached as the trip
    point of the inverter is above ground.
     
  5. Dan Lenski

    Dan Lenski Guest

    Wow, you designed those? Cool! :)
    Thanks, that's very good to know. So if I have this right, most
    computers just use a circuit like this as an RS232 receiver?

    RS232
    LEVEL
    INPUT
    *------------+
    |
    | |\ OUTPUT
    +----------+------| |O-----*
    | | |/
    | |
    /// ///

    If so, then I can certainly see how 0V/+12V works as "RS232" signaling.
    Why does RS232 use such goofy logic levels anyway?

    Dan
     
  6. Jim Thompson

    Jim Thompson Guest

    Naaah!

    More like....

    RS232
    LEVEL
    INPUT
    *------------+
    |
    | |\ OUTPUT
    +-----------------| |O-----*
    |/


    The MC1489 (my design) has a (floating-tub) input resistor into the
    base of an NPN transistor, with a large-value feedback resistor from
    output to provide a modicum of hysteresis.

    ...Jim Thompson
     
  7. Dan Lenski

    Dan Lenski Guest

    Well, that is indeed pretty rudimentary :) Can HCT logic handle the
    +-30V swing required by RS-232... or does nothing really put out more
    than +-12 V. RS232 seems to be the most obsolete non-standard thing.
    Which is a shame, since a serial console is a really handy thing to
    have for debugging.
    Cool! I looked up the datasheet, and I see that the input level
    threshold for your MC1489 is 1.4V going up, and 1.0V going down.
    Interesting. And I guess that means that TTL levels are safe to use
    with it.

    Thanks for all the help! I guess I'll just go with HCT inverters and
    be done with it!
    Dan
     
  8. Andrew Holme

    Andrew Holme Guest

    Using a P-channel MOSFET, you get a logic inversion, and the Tx data output
    swings negative. The negative supply may be taken from RTS, DTR, or even
    the other data line:


    +5V ----------.
    |
    |
    Logic out----||-+
    ||-> PMOS
    ||-+
    |
    |
    o------ RS232 Tx Data
    |
    |
    .-.
    | | R
    | |
    '-'
    |
    |
    '------- -ve
     
  9. Jim Thompson

    Jim Thompson Guest

    I don't anything anymore even puts out ±12V.

    To be totally Kosher I'd add Ge diodes from the inverter input to each
    rail to keep current out of the ESD diodes on the chip.
    The "standard" that never was ;-)
    That'll work just fine.

    ...Jim Thompson
     
  10. Dan Lenski

    Dan Lenski Guest

    Hmmm... I thought that RTS is held at +12V when not in use. If not, I
    don't understand how the circuit works that I linked to, since it uses
    N-channel MOSFETs.

    Now I'm really confused. I just measured the serial port on this
    computer and RTS is definitely -12V. So how was that circuit that I
    linked to supposed to work???
     
  11. Andrew Holme

    Andrew Holme Guest

    Try enabling hardware handshaking in your terminal emulation software. Both
    RTS and DTR should then be at +12V.
     
  12. Dan Lenski

    Dan Lenski Guest

    Aha, yes, I see that those signals are supposed to be "asserted /
    logical zero / +12 V" when hardware handshaking is in use. So hardware
    handshaking would have to be enabled (though not actually doing
    anything) in order to make that circuit work.

    Whereas your circuit would only work with hardware handshaking
    DISABLED, because it depends on having access to a negative voltage
    from the RTS.

    Dan
     
  13. Andrew Holme

    Andrew Holme Guest

    If you want a negative voltage, you have to program one of the handshakes
    to be negative, or use the other data line.
     
  14. Andrew Holme

    Andrew Holme Guest

    You're getting the idea, but that is not quite right. There are 3 signals
    you can get the negative voltage from. Only one of them needs to be
    negative. The others can be positive e.g. for supplying power to a
    microcontroller. I usually derive a negative voltage from the computer's
    transmit data output, and I draw a positive supply from both RTS and DTR.
     
  15. Dan Lenski

    Dan Lenski Guest

    Gotcha. So you enable hardware handshaking, thereby driving RTS and
    DTR positive, and draw positive supply from it? How much current can
    they source?

    One thing I still don't get: since RS232 is a full-duplex protocol, how
    can you derive a negative voltage from TX? When the computer isn't
    sending data, I understand that TX will idle at -12V, but isn't there a
    possibility that it will be switching between +12 and -12V rapidly
    when you're trying to use it as your negative supply?

    Dan
     
  16. Yup. In fact, 0 and 5 has worked fine on every computer I've ever used,
    including serial ports built in on motherboards, add-on PCI cards,
    laptops, and USB to RS232 converters. It's very convenient. It didn't
    work on a Palm handheld once; that required a proper negative voltage.

    I suppose it depends what you want it for. Obviously you don't want to
    send something like that to a customer, but for you own use it will very
    likely be adequate.
     
  17. Guest

    Actually, the other circuit is closer to what was used. Just going to
    the inverter gate with a resistor would cause the impedance to be very
    high as the input went between ground and the positive supply rail.

    The divider in the Maxim designs was needed to keep the gate voltage
    within limits. Actually, TI started to use those cheapie receivers,
    and we just copied them. The parts with automatic shutdown have an
    extra receiver that can sense if the input is at ground. The auto
    shutdown plus was a bit different, and I think really only done to
    prevent someone else from doing the design, i.e. create some prior art.


    If you sweep the input of the 232 chip, you should be able to find the
    kink in the impedance when you go beneath ground
     
  18. Dan Lenski

    Dan Lenski Guest

    Very good to know that 0/5V output works with most computers. I really
    like the scheme that Andrew Holme has come up with, since it still
    requires only a MOSFET and a resistor to output +5V and -12V logic
    levels, which should really, truly work with any RS-232 device.

    I think I'll give the HCT inverters a try first, since it's so
    ridiculously simple, and I imagine the worst I could do is blow up the
    inverter being used for the input.

    Dan
     
  19. Dan Lenski

    Dan Lenski Guest

    Isn't the input impedance of a CMOS gate *supposed* to be extremely
    high?
    Doesn't this simple voltage divider increase the quiescent current
    drawn by the device significantly? Is that why the shutdown mode is
    included?
     
  20. Guest

    That's the point. If you had a resistor in series with the gate,
    looking into the "port", you would see a high impedance. Once you hit
    the protection diodes, you would see roughly the series resistor.
    The current in the resistor comes from the transmitter, i.e. the "other
    guy."

    The shutdown mode first detects that nothing is connected to the
    receivers. If there is nothing connected to the port, then the on-board
    charge pumps (to create the voltages needed for transmitting) are just
    a waste of power, so turn them off.

    I think Dallas (prior to the Maxim buyout) did a chip that stole power
    from the "other guy's" transmitter. Mice did this all the time. The
    mice that connected to serial ports did this. Generally they would set
    two transmitters high and one transmitter low. The two high
    transmitters would be diode connected, then used to supply the plus
    rail to the mouse. The transmitter that was low would supply the
    negative rail to the mouse. There was never a standard as to how much
    juice you could steal out of the 232 transmitters, so mice were always
    operating in a dicey mode. Needless to say, good riddance to serial
    mice.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-