Serial Comm Ports for ever and ever… (Part 3)

Part 12345678

Some of you may want to interface their custom Arduino based serial comm port. It is not as trivial as you may think! In reallity, a “low” logical level (0 V) must generate a -3 to -15 Volts signal on the Tx (Transmit) pin of the communication line! And a “high” logical level (5 V) must generate a +3 to +15 Volts signal on the Rx (Receive) pin of the communication line. See illustration below:

The reason for that is related to the need for rejecting noise and avoiding attenuation problems. In fact the interface circuitry cares about edges detection, not for for absolute levels.
Building an interface from scratch may be a little bit tedious! You would need a voltage boster, a voltage inverter, a line driver, comparators, etc. It is time to use the magic MAX232! I do not how many of these chips are in operation? As far as I remember, almost all the equipment I had a chance to open was fitted with this IC. And if you ask kindly, Maxim-Dallas will send you a couple of samples, for free.

Here is the MAX232 circuit:

But there are many others from the same family, which cover various needs depending on power supply, supply current, inputs and outputs, package, etc. Download data sheet here.

The only required external components are four equal capacitors (0.1 to 1.0 µF) which are used for the charge pump (booster and inverter). This also means that this circuit can be used as a source of symetric voltages (unregulated, very low power).

The only last be not least required hardware is the RS232 connector. In 99% cases, you will need a 9 pins sub-D connector; older systems require 25 pins sub-D connectors. Keep in mind that drivers have male connectors while remote controlled equipment have female connectors. Here is the pin out for the 9 pins connector:

Pin Signal Signal   
 #  Name   Description
 1   CD    Carrier Detect  
 2   RXD   Receive Data  
 3   TXD   Transmit Data  
 4   DTR   Data Terminal Ready  
 5   GND   Signal Ground / Common  
 6   DSR   Data Set Ready  
 7   RTS   Request To Send  
 8   CTS   Clear To Send  
 9   RI    Ring Indicator

For more information related to RS232 connections, I suggest that you check this site.

This is a suggestion for testing the serial communication firmware.

In addition to the USB cable that connects to Arduino, you need to plug an extra serial cable to a spare serial port or to a serialUSB converter. Then use an hyperterminal which echoes what it gets (Polling mode).

And now has come the great time for testing the whole system. What would you send as a message: “Hello world!” ? My favourite is 0x55! which turns to 1010101 in binary and looks like :

-----------     ---     ---     ---     ---     ----------mark
           |Sta| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |Sto|
            ---     ---     ---     ---     ---           space/break

in digital. Very handy for scoping signal.

Next post on same subject

One Comment

  1. junglepig says:

    At top of this post, note that low TTL 0V translates to a positive 3-15 V RS-232 signal, while a high TTL 5V translates to a negative 3-15 V RS-232 signal.

Leave a Reply

You must be logged in to post a comment.