Home » Unlabelled » Serial Programming/MAX232 Driver Receiver
Selasa, 19 April 2011
Serial Programming/MAX232 Driver Receiver
This module is primary of interest for people building their own electronics with an RS-232 interface. Off-the-shelf computers with RS-232 interfaces already contain the necessary electronics, and there is no need to add the circuitry as described here.
Serial RS-232 (V.24) communication works with voltages (between -15V ... -3V are used to transmit a binary '1' and +3V ... +15V to transmit a binary '0') which are not compatible with today's computer logic voltages. On the other hand, classic TTL computer logic operates between 0V ... +5V (roughly 0V ... +0.8V referred to aslowfor binary '0', +2V ... +5V forhighbinary '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 computer logic electronics, and the negative RS-232 voltage can't be grokked at all by the computer logic. Therefore, to receive serial data from an RS-232 interface the voltage has to be reduced, and the0and1voltage 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 oftransistorsor 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.
The MAX232 fromMaximwas the first IC which in one package contains the necessary drivers (two) and receivers (also two), to adapt the RS-232 signal voltage levels to TTL logic. It became popular, because it just needs one voltage (+5V) and generates the necessary RS-232 voltage levels (approx. -10V and +10V) internally. This greatly simplified the design of circuitry. Circuitry designers no longer need to design and build a power supply with three voltages (e.g. -12V, +5V, and +12V), but could just provide one +5V power supply, e.g. with the help of a simple 78x05 voltage converter.
The MAX232 has a successor, the MAX232A. The ICs are almost identical, however, the MAX232A is much more often used (and easier to get) than the original MAX232, and the MAX232A only needs external capacitors 1/10th the capacity of what the original MAX232 needs.
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 a16550 UARTor one of these small micro controllers (e.g.Atmel AVR,Microchip PIC) getting more and more popular.
The MAX232 and MAX232A were once rather expensive ICs, but today they are cheap. It has also helped that many companies now produce clones (ie.Sipex). These clones sometimes need different external circuitry, e.g. the capacities of the external capacitors vary. It is recommended to check the data sheet of the particular manufacturer of an IC instead of relying on Maxim's original data sheet.
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.
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 sheetexplains 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 Name
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
This looks non-intuitive, but because pin 6 is on -10V, GND gets the + connector, and not the -
With the rise of mobile phones so calleddata cablesfor these phones have also become popular. These are cables to connect the mobile phone to a serial interface of a computer. The interesting thing is that modern mobile phones work with 3.3V logic, and older phones with 5V logic on their data buses. So these data cables must and do convert the phone logic voltage levels to and from RS232 voltage levels.
No-name data cables have become rather cheap (as opposite to original phone-brand data cables). The cheap cables with their voltage converters can be used as an alternative to home-made MAX232-based circuitry. The advantage is that the cables occupy much less space (the converter is usually inside the RS232 plug). Such a cable also saves the effort to solder a circuitry board. Another advantage, which can also be a disadvantage of such a data cable is that they usually take their power from the RS232 connector. This saves an external power supply, but can also cause problems, because the RS232 interface is not designed to power some logic and the DTE might not provide enough power. Another disadvantage is that many of these cables just support RX and TX (one receiver, one driver), and not two drivers/receivers as the MAX232. So there is no hardware handshake possible. Finally, when using such a cable it should be made sure that they convert to the desired voltage (3.3V or 5V).
^There are also data cables forUSBports, but these are of no interest here.
^Some data cables are powered by the phone and not via the RS232 interface. In such a case an external power supply is still needed, to replace the one from the phone.
USB to Serial interface cables often have two components: a USB transciever that outputs serial data; and a voltage shifter to produce standards-compliant RS-232 voltages. It is often possible to throw away (ignore, desolder, cut-out) the USB part of these cables, connect an external 5V power source (or abuse the RS-232 interface) to replace the power coming from the USB bus and to just use the RS-232 level-shifter. All this is probably as much work as using a MAX232A, although you get one RS-232 connector for free.
If you consider a USB cable, it is also worthwhile to consider using USB directly, instead of RS-232. Many USB transceiver chips can be integrated directly into circuits, eliminating the need for voltage-shifting components. Parts such as theFTDIFT232BM even have an input allowing designers to select 5V or 3.3V output levels. Most of these USB transceiver chips are available as surface-mount components only. But some vendors offer DIP-sized preassembled modules, often at competitive prices, and often with free or cheap drivers or driver development environments.
ATexas Instruments MAX232 (not A)second-source. TheNindicates the package (plastic dip), and not any special electric characteristics. This is a non-A MAX232, therefore it needs at least 1µF capacitors. In can sometimes be found rather cheap. TI also offers MAX3232s and a number of other RS-232 drivers/receivers, like MC148x.
The LT1181A from Linear Technologyis very similar to the MAX232A. It has the exact same pin-layout, also uses 0.1µF capacitors, and can in general replace a MAX232A. However, for the hobbyist it is typically a little bit more difficult to get one, and they tend to be slightly more expensive than the original Maxim MAX232A.
The Intersil HIN202is yet another IC very similar to the MAX232A. It also has the same pin-layout (DIL package), uses 0.1 µF capacitors and can replace a MAX232A. The HIN202 is especially interesting when more I/O lines are needed (four pairs), since the manufacturer specifies that two HIN202's can share a single V+ and a single V- capacitor. So the resulting circuit saves two capacitors.
The MC1488/MC1489 ICs have already been mentioned. However, they are no real alternative to a MAX232 these days. A combo of these ICs has twice as many drivers/receivers, but the MC1488 driver requires a +12V, -12V power supply, and the MC1489 receiver a +5V power supply. That makes three power supplies instead of one for the MAX232. It is recommended to either use several MAX232s, or another IC from the MAX family if more drivers/receivers are needed, like the MAX238