rs232

17
RS232

Upload: chris-mcandrew

Post on 18-Nov-2014

614 views

Category:

Documents


4 download

DESCRIPTION

An introduction to RS232

TRANSCRIPT

Page 1: RS232

RS232

Page 2: RS232

RS-232 standards (EIA-232) are defined by EIA/TIA (Electronic Industries Alliance /Telecommunications Industry Association). RS-232 defines both the physical and electrical characteristics of the interface. RS-232 is practically identical to ITU V.24 (signal description and names) and V.28 (electrical). RS232 is an Active LOW voltage driven interface and operates at +12V to -12V where: Signal = 0 (LOW) > +3.0V Signal = 1 (HIGH) < -3.0V

DB9 and DB25 Male and Female Pin Numbering These diagrams show the male (grey background) and female (black background) pin numbering for DB9 and DB25 sub-miniature connectors. Generally Pin 1 is marked on the front of the connector right next to the pin - though you may need a magnifying glass to read it. Some manufacturers mark each pin number on the plastic housing at the rear of the connector. The male connector has the pins sticking out!

DB25: View looking into male connector

DB25: View looking into female connector

Page 3: RS232

DB9 Male and Female

DB9: View looking into male connector

DB9: View looking into female connector

Page 4: RS232

RS232 on DB25 (RS-232C) The RS-232 DB25 connector is capable of supporting two separate connections - each with its own optional clock when used in Synchronous mode or Bit-Synchronous mode. If you are using the interface purely for Asynchronous communications then you only need those marked with (ASYNC) below or you can use even fewer (if you understand what is happening). The column marked Dir shows the signal direction with respect to the DTE. Pin No.

Name Dir Notes/Description

1 - - Protective/shielded ground 2 TD OUT Transmit Data (a.k.a TxD, Tx) (ASYNC) 3 RD IN Receive Data (a.k.a RxD, Rx) (ASYNC) 4 RTS OUT Request To Send (ASYNC) 5 CTS IN Clear To Send (ASYNC) 6 DSR IN Data Set Ready (ASYNC) 7 SGND - Signal Ground 8 CD IN Carrier Detect (a.k.a DCD). 9 - - Reserved for data set testing. 10 - - Reserved for data set testing. 11 - - Unassigned 12 SDCD IN Secondary Carrier Detect. Only needed if second channel being used. 13 SCTS IN Secondary Clear to send. Only needed if second channel being used. 14 STD OUT Secondary Transmit Data. Only needed if second channel being used. 15 DB OUT Transmit Clock (a.k.a TCLK, TxCLK). Synchronous use only. 16 SRD IN Secondary Receive Data. Only needed if second channel being used. 17 DD IN Receive Clock (a.k.a. RCLK). Synchronous use only. 18 LL - Local Loopback 19 SRTS OUT Secondary Request to Send. Only needed if second channel being used. 20 DTR OUT Data Terminal Ready. (ASYNC) 21 RL/SQ - Signal Quality Detector/Remote loopback 22 RI IN Ring Indicator. DCE (Modem) raises when incoming call detected used for auto

answer applications. 23 CH/CI OUT Signal Rate selector. 24 DA - Auxiliary Clock (a.k.a. ACLK). Secondary Channel only. 25 - - Unassigned

Page 5: RS232

RS232 on DB9 (EIA/TIA 574)

Pin No.

Name Dir Notes/Description

1 DCD IN Data Carrier Detect. Raised by DCE when modem synchronized. 2 RD IN Receive Data (a.k.a RxD, Rx). Arriving data from DCE. 3 TD OUT Transmit Data (a.k.a TxD, Tx). Sending data from DTE. 4 DTR OUT Data Terminal Ready. Raised by DTE when powered on. In auto-answer mode

raised only when RI arrives from DCE. 5 SGND - Ground 6 DSR IN Data Set Ready. Raised by DCE to indicate ready. 7 RTS OUT Request To Send. Raised by DTE when it wishes to send. Expects CTS from DCE. 8 CTS IN Clear To Send. Raised by DCE in response to RTS from DTE. 9 RI IN Ring Indicator. Set when incoming ring detected - used for auto-answer

application. DTE raised DTR to answer.

Page 6: RS232

RS232 on RJ45 (RS-232D) More properly EIA/TIA - 561. Use when connecting to or from a serial port with an 8 position Modular Jack (RJ45). If you are cross-connecting from a DB9 or a DB25 use the signal names to cross connect the appropriate connections.

Pin No.

Name Notes/Description

1 DSR/RI Data set Ready/ring indicator

2 DCD Data Carrier Detect

3 DTR Data Terminal Ready 4 SGND Signal Ground 5 RD Receive Data

6 TD Transmit Data 7 CTS Clear to Send 8 RTS Request to Send

Note: Pin 1 is a multi-function pin sharing with DSR (Data Set Ready) and RI (Ring Indicator). This means it is impossible to differentiate between an incoming ring signal and when the modem has finally connected and synched up. With local (null modem connections) or if the modem is run in auto-answer mode this is not normally a problem. If used with a modem and the DTE (the computer end) wants to control the connection the problem is more real. DSR would normally indicate the 'connected and synched-up' state following DTR from the DTE. DCD will indicate that a carrier has been received but does not indicate synchronization of both ends. In most cases however CTS (Clear To Send) in response to RTS (Request To Send) will not normally be returned until an end-to-end connection is available.

RJ45 Male Connector Pin Numbering

Page 7: RS232

RS232 DB25 NULL Modem Pinout Use when connecting two systems (e.g. PCs) via their DB25 interfaces without a modem (i.e. back-to-back). See the full signal names in the DB25 sections.

DB25 Signal DB25 Signal

3 RD 2 TD

2 TD 3 RD

20 DTR 6,8 DSR, DCD

6,8 DSR, DCD 20 DTR

4 RTS 5 CTS

5 CTS 4 RTS

7 SGND 7 SGND

Page 8: RS232

RS232 DB9 NULL Modem Pinout

Use when connecting two systems, for example two PCs, via their DB9 interfaces without a modem. Typically called a back-to-back or NULL modem connection.

DB9 Signal DB9 Signal

2 RD 3 TD

3 TD 2 RD

1,4,6 DSR, DCD, DTR 1,4,6 DSR, DCD, DTR

7,8 RTS,CTS 7,8 RTS,CTS

5 SGND 5 SGND

Null Modem with Loopback Handshake

Null Modem with Full Handshake

Page 9: RS232

RS232 DB9 and DB25 Loopback Pinout

Loopback is a method of testing the RS232 connector and interface circuitry to ensure it is functioning correctly, that is, in layman's jargon - it ain't broke! Data is sent and received on the same RS232 connector - which may be either DB9 or DB25. The test normally consists of using some program to transmit data. The program then checks to ensure exactly the same data was received. If this test is performed using two systems and it fails the question is - which end has the problem? Loopback testing gives you a binary result - it works, in which case these end under test is good, or it does not, in which case the end under test is broken. Pinouts are shown for both DB9 and DB25. The loopback is normally constructed in the DB shell or using a diagnostic light-box.

DB9 Loopback DB9 Signal Loopback

to Signal

2 RD 3 TD

3 TD 2 RD

4 DTR 6,1 DSR, DCD

7 RTS 8 CTS

5 SGND 5 SGND

Page 10: RS232

DB25 Loopback

DB25 Signal Loopback to

Signal

3 RD 2 TD

2 TD 3 RD

4 RTS 5 CTS

5 CTS 4 RTS

7 SGND 7 SGND

20 DTR 6,8 DSR, DCD

NOTE: For the sake of simplicity this loopback will only work for the primary channel. By looping the primary channel clocks (15 and 17) both synchronous and asynchronous capabilities can be tested. If only asynchronous tests are being performed omit this.

Page 11: RS232

RS232 DB9 NULL Modem Pinout on CAT5

This is in response to a number of recent emails asking how to wire both ends of a DB9 connection using cat5(e) cable. This must not be confused with DB9 to RJ45 (RS232D). We have shown a null modem (back-to-back PCs) only configuration. And if you want to use cat5(e) with a real modem (a DB25 connector)? Our advice - don't. Warning: There is, as far as we know, no standard to cover the use of cat5(e) (8 conductor) wiring when used with two DB9 connectors. Any such wiring scheme is therefore non-standard - that includes the wiring scheme below. Specifically this means that both ends of the cable must be wired in the same way and that no assumptions can be made about how the other end is wired. You will have to manually inspect both ends of the connection. Damage can result from mis-matched wiring. A DB9 clearly has 9 connections and a cat5(e) cable has 8 conductors. RS232D has chosen to use Pin 1 as a multi-function pin (DSR/RI) to provide maximum flexibility with modems - in particular it allows for DCD which is a meaningful signal from a modem but not we suggest from a peer PC. We have chosen to use a minor variation on the normal DB9 Null modem pinout above - specifically we have allowed for RI which could be used from a peer PC to commence a transmission sequence. The colors used are unimportant but the suggested configuration is one way to provide the shortest use of the adjacent (twisted) pairs.

PC1 Peer PC2 Peer

DB9 Signal cat5(e) Colour

DB9 Signal cat5(e) Colour

2 RD Brown 3 TD Blue

3 TD Blue 2 RD Brown

4 DTR Green 6,1 DSR, DCD Brown-white

6,1 DSR, DCD Brown-white 4 DTR Green

7 RTS Blue-white 8 CTS Green-white

8 CTS Green-white 7 RTS Blue-white

5 SGND Orange 5 SGND Orange

9 RI Orange-white 9 RI Orange-white

Page 12: RS232

RS232 DB9 to DB25 Pinout

Use when connecting a DB9 (e.g. a PC) to a DB25 (e.g. a modem) interface. See the full signal names in the DB9 and DB25 section.

DB9 Signal DB25

1 DCD 8

2 RD 3

3 TD 2

4 DTR 20

5 SGND 7

6 DSR 6

7 RTS 4

8 CTS 5

9 RI 22

NOTE: Leave all pins not specified above unconnected.

Page 13: RS232

RS232 DB9 to DB25 NULL Modem Pinout

Use when connecting two systems (e.g. PCs) when one has a DB9 interface and the other a DB25 interface without a modem. Typically called a back-to-back or NULL modem connection. See the full signal names in the DB9 and DB25 sections.

DB9 Signal DB25 Signal

2 RD 2 TD

3 TD 3 RD

4 DTR 6,8 DSR, DCD

6,1 DSR, DCD 20 DTR

7 RTS 5 CTS

8 CTS 4 RTS

5 SGND 7 SGND

9 RI 22 RI

NOTE: Leave all pins not specified above unconnected.

Page 14: RS232

Half duplex RS232 spy / monitor / sniffer cable It is not difficult to monitor half duplex RS232 serial communication between two devices with a PC. To do this you need the RS232 monitor cable which is displayed in the next picture. Two DB9 connectors are wired straight through. The spy computer is connected to the third connector. This monitor cable taps communication from two sources on only one RS232 receiver port. This means that if the two devices happen to talk simultaneously, the monitored information will be garbage. In most circumstances communication protocols work half duplex, in which case this RS232 cable will work without problems. Otherwise you need the full duplex RS232 monitor cable which is discussed here also. Half duplex RS232 spy / monitor / sniffer cable

Connector 1 Connector 2 Spy Function 1 1 - Carrier detect 2 2 2 via R1 Rx Rxspy 3 3 2 via D1 Tx Rxspy 4 4 - Data terminal ready 5 5 5 Signal ground 6 6 - Data set ready 7 7 - Request to send 8 8 - Clear to send 9 9 - Ring indicator - - 1 + 4 + 6 DTR CD + DSR - - 7 + 8 RTS CTS

Page 15: RS232

The electronic diagram looks simple and strange at the same time with one diode and one resistor. The functionality is however straight forward. The spy computer is attached to the connector in the right bottom. The female connector at the left is attached to the spied computer and the male connector at the right to the attached device. When an RS232 port is in an idle state, it will be in the so-called marking state with a negative voltage at the transmit output. Assume the computer connected to the left port is sending data and the peripheral device at the right side is idle. At that moment the RS232 signal level on line 3 will change. When the voltage of this line changes to a higher value, current will flow through the diode to the spy computer. We assume the attached device is in an idle state. Therefore, the voltage at line 2 is something like -12 Volt, while at the other end of the resistor +12 Volt is applied. Simple mathematics learns that a current of approximately 11 mA (=24 Volt/2200 Ohm) flows through the resistor. This is no problem because most RS232 driver IC's are capable to deliver at least 45 mA. Because the voltage drop over the diode is only 0.7 Volt—independent of the current through the diode—the spy computer will see on its RS232 port (almost) the same voltage levels as present on the transmit port of the sending computer and data from the sending computer to the peripheral device is successfully captured. In the second situation the computer has finished sending data and waits for an answer from the device at the male connector. The RS232 signal level at line 2 will go to positive values. The diode will block current to line 3 so the spy computer effectively only sees the data coming from the peripheral device. Now the spy computer will be able to pick-up the data send from the device back to the computer. In the diagram for the half duplex monitor cable some shorts have been made between pins of the connector of the spying computer. These shorts loopback the handshaking signals of the computer. In most cases these shorts won't be necessary, but if the spy monitoring software uses handshaking, this will prevent the monitor software from blocking. You don't need expensive software to use this RS232 spy cable. A simple serial terminal emulator like the HyperTerminal program present on all Windows based computers is enough to spy your communications. The only thing you need to do is changing the baudrate and start and stop bits settings from the terminal emulation program to the settings used on the line to monitor.

Page 16: RS232

Full duplex RS232 spy / monitor / sniffer cable As already discussed, it is not possible to monitor a full duplex RS232 communication with only one spy port. For this purpose the full duplex monitor cable can be used. This cable connects to two serial ports on the spy computer where each ports taps one direction of the communication. You could open two sessions of a terminal emulation program on your computer, but often better is to use one of the specialized RS232 monitor software products. In that way the two communication streams are merged in one screen which makes it easier to analyze the sequence of the communications. Full duplex RS232 spy / monitor / sniffer cable

Page 17: RS232

Connector 1 Connector 2 Spy port 1 Spy port 2 Description 1 1 - - Carrier detect 2 2 2 - Rx Rx1 3 3 - 2 Tx Rx2 4 4 - - Data terminal ready 5 5 5 5 Signal ground 6 6 - - Data set ready 7 7 - - Request to send 8 8 - - Clear to send 9 9 - - Ring indicator - - 1 + 4 + 6 - DTR CD + DSR - - 7 + 8 - RTS CTS - - - 1 + 4 + 6 DTR CD + DSR - - - 7 + 8 RTS CTS

The diagram of the full duplex RS232 monitor cable is actually simpler than the diagram of the half duplex monitor cable. This is because no special circuitry is necessary to combine two communication lines on one input. Just to be sure, all handshake signals on both spy connectors have been looped back. This prevents the software from blocking input in case it checks the CTS, DSR or CD inputs.