Thursday, December 23, 2010

IC MAX232 FOR INTERFACING COMPUTER USING RS-232 WITH EXTERNAL HARDWARE(µc or µp)


From my previous article RS232 SERIAL COMMUNICATION STANDARD ,we know that RS232 serial is used to communicate external hardware like microprocessors and micro controllers with computer
Serial RS-232 communication works with voltages (between -15V ... -3V are used to transmit a binary '1' and +3V ... +15V to transmit a binary '0') . On the other hand, external interfacing hardware like microprocessors and microcontrollers of modern VLSI technology are made of TTL logic operates between 0V ... +5V (roughly 0V ... +0.8V referred to as low for binary '0', +2V ... +5V for high binary '1' ). Modern low-power logic operates in the range of 0V ... +3.3V or even lower.

So, the maximum RS-232 signal levels are far too high for today's TTL logic electronic hardwares, and the negative

RS-232 voltage can't be grokked at all by the TTL logic. Therefore, to receive serial data from an RS-232 interface the voltage has to be reduced, and the 0 and 1voltage levels inverted. In the other direction (sending data from some logic over RS-232) the low logic voltage has to be "bumped up", and a negative voltage has to be generated, too.

All this can be done with conventional analog electronics, e.g. a particular power supply and a couple of transistors or the once popular 1488 (transmitter) and 1489 (receiver) ICs. However, since more than a decade it has become standard in amateur electronics to do the necessary signal level conversion with an integrated circuit (IC) from the MAX232 family (typically a MAX232A or some clone). In fact, it is hard to find some RS-232 circuitry in amateur electronics without a MAX232A or some clone.

It should be noted that the MAX232(A) is just a driver/receiver. It does not generate the necessary RS-232 sequence of marks and spaces with the right timing, it does not decode the RS-232 signal, it does not provide a serial/parallel conversion. All it does is to convert signal voltage levels. Generating serial data with the right timing and decoding serial data has to be done by additional circuitry, e.g. by a 16550 UART or one of these small micro controllers (e.g. Atmel AVR, Microchip PIC) getting more and more popular.

The original manufacturer (and now some clone manufacturers, too) offers a large series of similar ICs, with different numbers of receivers and drivers, voltages, built-in or external capacitors, etc. E.g. The MAX232 and MAX232A need external capacitors for the internal voltage pump, while the MAX233 has these capacitors built-in. The MAX233 is also between three and ten times more expensive in electronic shops than the MAX232A because of its internal capacitors. It is also more difficult to get the MAX233 than the garden variety MAX232A.

A similar IC, the MAX3232 is nowadays available for low-power 3V logic.

MAX232(A) DIP Package

MAX232 Maxim IC
MAX232(A) DIP Package Pin Layout
NbrNamePurposeSignal VoltageCapacitor Value MAX232Capacitor Value MAX232A
1C1++ connector for capacitor C1capacitor should stand at least 16V1µF100nF
2V+output of voltage pump+10V, capacitor should stand at least 16V1µF to VCC100nF to VCC
3C1-- connector for capacitor C1capacitor should stand at least 16V1µF100nF
4C2++ connector for capacitor C2capacitor should stand at least 16V1µF100nF
5C2-- connector for capacitor C2capacitor should stand at least 16V1µF100nF
6V-output of voltage pump / inverter-10V, capacitor should stand at least 16V1µF to GND100nF to GND
7T2outDriver 2 outputRS-232
8R2inReceiver 2 inputRS-232
9R2outReceiver 2 outputTTL
10T2inDriver 2 inputTTL
11T1inDriver 1 inputTTL
12R1outReceiver 1 outputTTL
13R1inReceiver 1 inputRS-232
14T1outDriver 1 outputRS-232
15GNDGround0V1µF to VCC100nF to VCC
16VCCPower supply+5Vsee abovesee above

V+(2) is also connected to VCC via a capacitor (C3). V-(6) is connected to GND via a capacitor (C4). And GND(15) and VCC(16) are also connected by a capacitor (C5), as close as possible to the pins.

EQUIVALENT IC DIAGRAM:

MAX232 circuit diagram


A Typical Application

The MAX232(A) has two receivers (converts from RS-232 to TTL voltage levels) and two drivers (converts from TTL logic to RS-232 voltage levels). This means only two of the RS-232 signals can be converted in each direction. The old MC1488/1498 combo provided four drivers and receivers.

Typically a pair of a driver/receiver of the MAX232 is used for

  • TX and RX

and the second one for

  • CTS and RTS.

There are not enough drivers/receivers in the MAX232 to also connect the DTR, DSR, and DCD signals. Usually these signals can be omitted when e.g. communicating with a PC's serial interface. If the DTE really requires these signals either a second MAX232 is needed, or some other IC from the MAX232 family can be used (if it can be found in consumer electronic shops at all). An alternative for DTR/DSR is also given below.

Maxim's data sheet explains the MAX232 family in great detail, including the pin configuration and how to connect such an IC to external circuitry. This information can be used as-is in own design to get a working RS-232 interface. Maxim's data just misses one critical piece of information: How exactly to connect the RS-232 signals to the IC. So here is one possible example:

MAX232 to RS232 DB9 Connection as a DCE
MAX232 Pin Nbr.MAX232 Pin NameSignalVoltageDB9 Pin
7T2outRTSRS-2328
8R2inCTSRS-2327
9R2outCTSTTLn/a
10T2inRTSTTLn/a
11T1inTXTTLn/a
12R1outRXTTLn/a
13R1inTXRS-2323
14T1outRXRS-2322
15GNDGND05


In addition one can directly wire DTR (DB9 pin 4) to DSR (DB9 pin 6) without going through any circuitry. This gives automatic (brain dead) DSR acknowledgment of an incoming DTR signal.

Sometimes pin 6 of the MAX232 is hard wired to DCD (DB9 pin 1). This is not recommended. Pin 6 is the raw output of the voltage pump and inverter for the -10V voltage. Drawing currents from the pin leads to a rapid breakdown of the voltage, and as a consequence to a breakdown of the output voltage of the two RS-232 drivers. It is better to use software which doesn't care about DCD, but does hardware-handshaking via CTS/RTS only.

The circuitry is completed by connecting five capacitors to the IC as it follows. The MAX232 needs 1.0µF capacitors, the MAX232A needs 0.1µF capacitors. MAX232 clones show similar differences. It is recommended to consult the corresponding data sheet. At least 16V capacitor types should be used. If electrolytic or tantalic capacitors are used, the polarity has to be observed. The first pin as listed in the following table is always where the plus pole of the capacitor should be connected to.

MAX232(A) external Capacitors
Capacitor+ Pin- PinRemark
C113
C245
C3216
C4GND6This looks non-intuitive, but because pin 6 is
on -10V, GND gets the + connector, and not the -
C516GND

The 5V power supply is connected to

  • +5V: Pin 16
  • GND: Pin 15

2 comments:

  1. how max232 converts the voltage levels practically ???

    ReplyDelete
  2. how max232 convert voltage levels practically ??

    ReplyDelete