Maker Pro
Maker Pro

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

D

Dan Lenski

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
 
J

John Larkin

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


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
 
D

Dan Lenski

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

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...
 
Dan said:
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

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.
 
D

Dan Lenski

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.]

Wow, you designed those? Cool! :)
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.

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
*------------+
|
< R1 TTL
LEVEL
| |\ OUTPUT
+----------+------| |O-----*
| | |/
--- < R2 / \
|
| |
/// ///

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

Dan
 
J

Jim Thompson

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.]

Wow, you designed those? Cool! :)
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.

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
*------------+
|
< R1 TTL
LEVEL
| |\ OUTPUT
+----------+------| |O-----*
| | |/
--- < R2 / \
|
| |
/// ///

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

Dan

Naaah!

More like....

RS232
LEVEL
INPUT
*------------+
|
'HCT Inverter < R1 TTL
LEVEL
| |\ 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
 
D

Dan Lenski

Jim said:
Naaah!

More like....

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

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.
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.

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
 
A

Andrew Holme

Dan Lenski said:
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

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
 
J

Jim Thompson

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.

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.
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.

The "standard" that never was ;-)
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.
Yep.


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

That'll work just fine.

...Jim Thompson
 
D

Dan Lenski

Andrew said:
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:

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???
 
A

Andrew Holme

Dan Lenski said:
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???

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

Dan Lenski

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

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
 
A

Andrew Holme

Andrew Holme said:
Try enabling hardware handshaking in your terminal emulation software.
Both RTS and DTR should then be at +12V.
If you want a negative voltage, you have to program one of the handshakes
to be negative, or use the other data line.
 
A

Andrew Holme

Dan Lenski said:
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.
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.
 
D

Dan Lenski

Andrew said:
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.

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
 
T

Terran Melconian

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

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.
 
Jim said:
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.]

Wow, you designed those? Cool! :)
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.

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
*------------+
|
< R1 TTL
LEVEL
| |\ OUTPUT
+----------+------| |O-----*
| | |/
--- < R2 / \
|
| |
/// ///

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

Dan

Naaah!

More like....

RS232
LEVEL
INPUT
*------------+
|
'HCT Inverter < R1 TTL
LEVEL
| |\ 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

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
 
D

Dan Lenski

Terran said:
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.

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
 
D

Dan Lenski

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.

Isn't the input impedance of a CMOS gate *supposed* to be extremely
high?
The divider in the Maxim designs was needed to keep the gate voltage
within limits.

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

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.
Doesn't this simple voltage divider increase the quiescent current
drawn by the device significantly? Is that why the shutdown mode is
included?

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.
 
Top