RS-232 transceiver, MAX232
Turns a 5 V UART into inverted +-7 V RS-232 levels and back, two channels each way, from one 5 V supply with its charge pump.
- 16 pins
- In 1 project
The RS-232 transceiver, MAX232 in brief
What it is, and where it sits on the bench.
The MAX232 is the chip between a microcontroller’s 5 V serial port and a real RS-232 port, the kind on old PCs, lab instruments and CNC controllers. RS-232 uses roughly -7 V for a 1 and +7 V for a 0, the opposite sense and many times the swing of a board’s logic. The MAX232 builds its own positive and negative supplies from 5 V with a charge pump and external capacitors, then gives two drivers that turn logic into line levels and two receivers that turn them back. In Mokxi both directions invert as they should, a driver puts out about 7 V either way behind 750 ohms, and a receiver switches with half a volt of hysteresis and reads an open input as idle. The model checks that both pump capacitors are wired; take one out and the chip says no C1/C2 and its output can no longer go negative.
- Family
- Clocks and links
- Pins
- 16
16 pins
Named as the editor names them, so a wire lands where you expect it.
VCC or GND.GND.How to connect an Arduino to RS-232 with a MAX232
In the loopback project the Uno’s TX, pin 1, feeds T1IN, and R1OUT comes back to pin 8, which the sketch reads with SoftwareSerial. VCC goes to 5 V and GND to ground. Two 1 µF capacitors make the charge pump work: one across C1+ and C1-, the other across C2+ and C2-. A jumper from T1OUT to R1IN is the loopback plug a technician pushes into a port to test it.
Every second the sketch prints "ping" and a count on Serial. The byte leaves through the driver at RS-232 levels, crosses the jumper, comes back through the receiver at logic levels and arrives on pin 8, where the sketch prints what came back. When you connect a real device instead, T1OUT goes to its receive line, its transmit line comes into R1IN, and the grounds are joined.
Pull the jumper and nothing returns: R1OUT stays high, because an open RS-232 input counts as idle. Remove C2 and there is no negative rail, so a mark is 0 V instead of -7 V.
The MAX232 is off below 4.5 V, so a 3.3 V board needs the MAX3232 instead, which is not on the Mokxi bench; on a 5 V board the wiring is the same as here.
#include <SoftwareSerial.h>
SoftwareSerial back(8, 9); // RX on pin 8 from R1OUT
void setup() {
Serial.begin(9600); // TX goes out through T1IN
back.begin(9600);
}Common RS-232 transceiver, MAX232 errors and fixes
Questions and answers
Why does RS-232 look upside down compared with a UART?
Because the standard defines it that way: an idle line, a logic 1, is a negative voltage, and a 0 is positive. The MAX232 inverts in both directions, so the bytes come out unchanged.
How many capacitors does a MAX232 need?
The real chip wants four 1 µF capacitors, two for the pump and two to hold its plus and minus rails. The simulation needs the two pump capacitors, C1 and C2, to make its rails.
Can two Arduinos talk through two MAX232 chips?
Yes. Cross T1OUT of each to R1IN of the other, as a null-modem cable does, and join the grounds; each board then sees the other’s bytes at its own logic levels.
Should I use a MAX232 or a MAX485?
Use the MAX232 to reach a device that already has an RS-232 port, point to point. Use the MAX485 for a long run or several devices on one twisted pair.
What is true about the RS-232 transceiver, MAX232, here
In its help article’s own words: what the simulation gets right, and where it stops.
Modeled
Both directions invert. A TTL high (a UART's idle) is a negative line and a TTL low a
positive one; the receivers turn them back. So two MAX232s, T1OUT of each to R1IN of
the other, carry a UART between two boards the way a null-modem cable does.
The levels. A driver puts out about +-7 V into the 3 to 7 kohm of a receiver (the TI sheet's typical 7 V into 3 kohm), behind 750 ohm, so a short to ground passes about 12 mA. A receiver is 5 kohm to ground, switches at 1.7 V going up and 1.2 V going down (0.5 V of hysteresis), and an open input reads as a mark: its output high.
The capacitors matter. The model looks for C1 between C1+ and C1- and C2 between
C2+ and C2-. Without C1 the positive rail is only about 4.3 V; without C2 there is no
negative rail at all, and a mark is 0 V instead of -7 V, which a real PC port may not
accept. The chip shows no C1/C2 when it runs without them.
Delays. A receiver's output follows half a microsecond after its input crosses, and a driver's edge lands a quarter of a microsecond late (half of its 30 V/us slew across the swing). At 115200 baud a bit is 8.7 us.
Not modeled
The charge pump is its averaged output, not a switching circuit: no ripple, no start-up
time, and the drivers' load does not pull VS+ and VS- down. What sits between the pump
pins is not checked, only that both are wired and not shorted together, and the two
reservoir capacitors on VS+ and VS- are not required. The supply current is not drawn
from VCC, the 120 kbit/s rate limit is not enforced, and nothing is damaged by +-30 V on
an input or a long short on an output. Below 4.5 V the chip is off: the MAX3232 is the
3.3 V part, and it is not simulated.
From MAX232 RS-232 transceiver, in full.
See the RS-232 transceiver, MAX232 in a project
One built-in project uses it. It opens in the editor, already wired.
The boards it is shown on
This board has a built-in project with the RS-232 transceiver, MAX232 in it.
Arduino libraries for the RS-232 transceiver, MAX232
Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the RS-232 transceiver, MAX232
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.