Introduction to RS 422 & RS 485 Preface: Are you an electronics amateur, or a future professional, designing an electronics application? If it consists of several units in different places, you probably need a way for them to communicate with each other. Maybe you are interested in data transfer related topics of microprocessor and computer applications? Or, are you interested in RS 232, RS 422 and RS 485, transfer protocols, and related areas? Then, this article is right for you. Thanks to: Jan Rehak, for persuading me long enough so I have finally understood how the world works, sat down to the computer and, after a long struggle, spitted out these few lines. Otherwise, I would probably end up at the very bottom of the electronics' moral hell and stayed there for ever and ever. Amen. Once again, you can thank Jan Rehak, called Fredy, for the existence of this article. Don't ever promise him writing something because it will stay with you like Kain's sign until you do it. No Guarantee: This article is based on info, which I have acquired about a year ago when we were working on a project utilizing a RS 485 bus, as well as on my personal experience in this area. It is possible that you will find discrepancies, or other errors. I will be grateful for an e-mail, which I will append to this article. Chapter 1: What is RS 422, RS 485, comparison with RS 232. RS 232 is well-known due to popularity of today's PC's, unlike the RS422 and RS 485. These are used in industry for control systems and data transfers (small volumes, NO hundreds of Mb/s). So, what is the main difference between RS 232 and RS 422 & 485? The RS 232 signals are represented by voltage levels with respect to ground. There is a wire for each signal, together with the ground signal (reference for voltage levels). This interface is useful for point-to-point communication at slow speeds. For example, port COM1 in a PC can be used for a mouse, port COM2 for a modem, etc. This is an example of point-to-point communication: one port, one device. Due to the way the
signals are connected, a common ground is required. This implies limited cable length - about 30 to 60 meters maximum. (Main problems are interference and resistance of the cable.) Shortly, RS 232 was designed for communication of local devices, and supports one transmitter and one receiver. RS 422 & 485 uses a different principle: Each signal uses one twistedpair (TP) line - two wires twisted around themselves. We're talking 'Balanced data transmission', or 'Differential voltage transmission'. Simply, let's label one of the TP wires 'A' and the other one 'B'. Then, the signal is inactive when the voltage at A is negative and the voltage at B is positive. Otherwise, the signal is active, A is positive and B is negative. Of course, the difference between the wires A and B matters. For RS 422 & 485 the cable can be up to 1200 meters (4000 feet) long, and commonly available circuits work at 2.5 MB/s transfer rate. What is the difference between RS 422 and RS 485? Electrical principle is the same: both use differential transmitters with alternating voltages 0 and 5V. However, RS 422 is intended for point-to-point communications, like RS 232. RS 422 uses two separate TP wires, data can be transferred in both directions simultaneously. RS 422 is often used to extend a RS 232 line, or in industrial environments. RS 485 is used for multipoint communications: more devices may be connected to a single signal cable - similar to e.g. ETHERNET networks, which use coaxial cable. Most RS 485 systems use Master/Slave architecture, where each slave unit has its unique address and responds only to packets addressed to this unit. These packets are generated by Master (e.g. PC), which periodically polls all connected slave units. This article will mainly cover the Master/Slave architecture because it is sufficient for 95% of applications. In special cases (security systems,...), an improved version of multiprocessor communication is used. This system uses only a single line for bidirectional communication; however, there is no Master. All units announce a packet transmission of a specified length, and at the same time listen whether the data has been successfully transmitted. If it's not the case, they stop communicating and listen for what has happened. At this time, urgent packets can be transmitted over the line. This system is ideal for devices, that need to immediately transfer some very important and up-to-date data, without waiting for Master to give them a chance to do so. On the other side, useful data transfer is less effective (about 30% less effective than the
first system). In Master/Slave architecture, slave never starts the communication. It is critical for Master to send correct addresses. RS 485 exists in two versions: 1 TwistedPair or 2 TwistedPairs. Single TwistedPair RS 485 In this version, all devices are connected to a single TwistedPair. Thus, all of them must have drivers with tri-state outputs (including the Master). Communication goes over the single line in both directions. It is important to prevent more devices from transmitting at once (software problem). Double TwistedPair RS 485 Here, Master does not have to have tri-state output, since Slave devices transmit over the second twistedpair, which is intended for sending data from Slave to Master. This solution often allows to implement multipoint communication in systems, which were originally designed (HW as well as SW) for RS232. Of course, Master software needs to be modified, so that Master periodically sends query packets to all Slave devices. Increased data throughput is evident in large volumes. Sometimes you can see a RS 485 system in a point-to-point system. It is virtually identical to RS 422; the high impedance state of the RS 485 output driver is not used. The only difference in hardware of the RS 485 and RS 422 circuits is the ability to set the output to high impedance state. Chapter 2: Balanced differential signals First, let's talk about advantages and disadvanteges of RS 422/485. For a basic RS 422/485 system, we need an I/O driver with differential outputs and an I/O receiver with differential inputs. Noise and interference is introduced into the line; however, since the signal is transferred via a twisted pair of wires, the voltage difference (between A and B) of this interference is almost zero. Due to the differential function of the RS 422/485 input amplifier of the receiver, this interference is eliminated. The same is true for crosstalk from neighboring lines, as well as for any other source of interference, as long as the absolute maximum voltage ratings of the receiver circuits are not exceeded. Differential inputs ignore different earth potentials of the transmitter and the receiver. This is very important for communications of diverse systems, where great problems would otherwise arise - e.g. different power sources, etc. TwistedPair cables, together with correct terminations (to eliminate reflections), allow data transfer rate of over 10Mbit/s with cables up to 1 km long. However, all of these advantages come at a cost. RS 422/485 circuits are more complex, and thus more expensive. Higher data transfer speeds
require correctly connected and matched terminations, which can be a problem in systems where the number of connected devices changes. And, of course, TwistedPair cables are required. In a RS 232 unbalanced data transmission system, each signal is represented by a voltage level with respect to ground. For example, the TxD signal of a PC COMx port is negative when idle, and switches between positive and negative level when transmitting data. Amplitude ranges between -15 to -5V in negative state, and between +5 to +15V in positive state. In a balanced differential system, the transmitter generates a voltage between 2 to 7V (approx.) between the A and B outputs. Although the transmitter and the receiver are connected with a ground wire (GND) as well, it is never used to determine logic levels at the AB wires. This implies already mentioned tolerance of different ground potentials of the transmitter and the receiver. RS 485 transmitters have an Enable input, allowing to set the outputs to high impedance state, allowing several devices to share a single TP. RS 422 transmitters usually don't provide such input. Voltage level of most commonly sold transmitters is 0 and 5V. When idle, there is +5V on B and 0V on A. RS422/485 receivers react to voltage difference betweeen the A and B inputs. If Vab is greater than 200mV, a logic level is defined on the receiver output. For Vab less than 200mV, the logic level is opposite.
Picture shows a simplified schematics of receiver input connections for a twisted pair line, and a graph of level determination. EIA STANDARD RS 422 & RS 485 There are two standards describing Balanced interface circuits: EIA-RS 422 (international standard ITU-T V.11) defines point-to-point interfaces with up to 10 receivers for a single transmitter. The limiting parameter is the receiver input impedance Ri=4kOhm. 10 receivers + termination resistor 100 Ohm give the maximum transmitter load. EIA-RS 485 (ISO 8482) defines the input impedance of RS 485 circuits Ri = 12kOhm. Then, up to 32 transmitters, receivers, or combination, can be connected to a single line. Since the data transfer is bidirectional, the line needs to have a terminating resistor at both ends.
This picture compares the standards RS 485 and RS 422, summarizes individual values and shows connections of termination resistors. Ground potential difference between different devices is +- 7V max, according to EIA-RS 422. EIA-RS 485 defines maximum voltage range at the receiver input (ground potential difference + alternating signal voltage) from -7V to +12V. RS 422/482 circuits have a short-circuit protection. Point-to-point (EIA-RS 422) defines short circuit as a current greater than 150mA, between A and B or against the ground. Multipoint (EIA-RS 485) defines short circuit as current greater than 150mA against the ground, or more than 250 ma between A and B. Ground connection for RS 422/485
For correct operation of the transmitter and the receiver, a return signal path between the grounding of individual devices is required. It may be realised either by a third wire, or by grounding each device (third pole in the mains socket). If a third (ground) wire is used, resistors (approx. 1kOhm) should be connected in series to eliminate unwanted currents resulting from ground potential differences. Click Here to Visit our Sponsor Chapter 3: Terminations, capacities, cable lengths, data transfer speed RS 422/485 line termination is essential, especially for faster data transfer rates and long cables. Main reasons for correct termination are reflections at the ends of the line, and the minimum transmitter load requirement. For RS 422, the termination is fairly simple (see picture comparing RS 422 and RS 485). A terminating resistor of 100Ohm is connected to the end of the line. If there are more RS 422 receivers connected to the line, the resistor can be a little bigger. The value can be calculated since the input impedance of the receivers is known. For RS 485, the termination is somewhat more complex (again, see the comparison picture). Since each device communicates bidirectionally (single TP version), we are unable to determine where is the transmitter and where is the receiver - this changes constantly, according to which device transmits at the moment. So, both ends of the line have to be terminated with a 100Ohm terminator. However, it is not that easy. Since all device have tri-state outputs, situations occur (very often - every time the transmitting device or data direction changes), when all transmitters are in high impedance state, and the line, due to termination resistors, is in undefined state (Vab%lt;200mV). It is, however, desirable to define idle state in this situation (Vab<-200mV). The comparison picture shows a circuit solving this problem with termination resistor values. The values are calculated to allow maximum number of devices (32) with input impedances 12kOhm to be connected
to a single line. It is important that there are only two Rt resistors at the end of the cable (they may be inside the last device connected). Maximum data transfer speeds Graph showing the dependence of transfer speed on several basic conditions. 1) Maximum data transfer rate over short distances, where the line influence can be neglected, is determined by the output parameters of the transmitter. The duration of the rising and falling edges matters. Standard assumes speed of 10Mbit/s; today's fastest chips, e.g. SN76ALS176, can achieve up to 25 MBit/s. 2) When the line length exceeds 10m, we have to take into consideration losses caused by capacities and the so-called skin effect, when the current begins to flow only on the surface of the conductors. The rule for standart TP cables says, that data transfer speed (Mbit/s) multiplied by cable length (m) is less than 10^8. So, for example, if a cable is 100m long, we get maximum data transfer speed of 1Mbit/s. 3) Last limitation applies to very long cables. Speed is limited by the ohmic resistance of the line, and following the signal loss. Maximum cable length is determined by its resistance, which should be less than the line impedance - 100Ohm. Standard TP cable, diameter 2x0.6mm has a resistance of arround 100W/Km. Capacity of the cable needs to be considered as well. This table is for orientation only, but still very useful: Data transfer speed 1200bd 2400bd 4800bd 9600bd 19200bd 38400bd 57600bd 115200bd
Max. cable capacity 250nF 120nF 60nF 30nF 15nF 750pF 500pF 250pF Chapter 4: Protocols, software This chapter is short because software is custom-designed for each individual application, including the transfer protocols. RS 422, as a point-to-point connection, operates similarly to the RS 232 serial port. However, there are certain things software needs to take into account. First, the communication media (TP line) needs to be assigned to individual stations, so that there are no collisions and that responses are fast enough. We have to be aware of the fact, that only a single channel is available for communication. It has to transfer both data and the bit and byte synchronisation. For transferring of individual bits, one of the data network modulations can be used, e.g. coding NRZ, NRZI, phase modulation NRZ, or differential phase modulation. These modulations are not covered in this article, they are a topic of network and protocol theory. For byte synchronisation, several options are available. Maybe the simplest is to reserve one byte to be a sync character. Software then needs to convert data bytes equal to the sync byte to a sequence of different bytes. Or, protocols SLDC/HLDC, suitable for high-speed transfers, may be used. When an application requires only slower data transfer rates (115200bd, or up to 2Mb/s with special UART circuits), we can take advantage of the RS 232 format for both bit and byte synchronisation. This solution saves a lot of effort, especially when a PC is used as Master, and Slave is equipped with a microcontroller containing its own UART, e.g. 8051 compatibles. From a network point of view, the RS 485 incorporates a bus topology. Since Slave stations have no means of starting the communication without a risk of collision, they need to be assigned a 'right to transmit' by the Master station. Assignment is done centrally via pooling, where the central (Master) station periodically asks all Slaves whether they have data to transmit. If so, the questioned station sends the data immediately; otherwise, it replies with a confirmation packet only, or does not reply at all. This method is good for Multipoint systems with
smaller number of Slave stations (approx. up to 100). For more stations, the reply would become too slow. Of course, individual system requirements need to be considered. Mentioned 100 stations is for an "on-line" system, where stations have to interactively react to user requests, thus the reply delay needs to be less than 0.5 sec (considered for 115200bd data transfer rate, which is seldom available in industrial environments). Of course, in systems where the Master has no priority function, or due to other factors (e.g. large number of stations with low frequency of data transfers), different access methods may be used. For example, the random access method ALOHA. Here, any station sends its data regardless of the transfer channel status. If a collision occurs, the station does not receive a confirmation, and repeats transmission. However, this method utilises on average only about 18% of available bandwidth, and with larger volumes of data the throughput decreases rapidly due to larger number of collisions. With RS 485, where transmitters can at the same time "listen" for the channel status, the ALOHA method can be improved by a "carrier" (data activity) detection. In this case, stations begin transmission only if the channel is idle. Both methods essentially require a transfer protocol with error detection. In any data transfer, including the RS 485, there is no way to 100% guarantee that a transmitted packet has been successfully received. Especially with the ALOHA methods, collisions may occur; interference, cable length, etc. causes errors too. It is advisable for the communication software to take such situations into consideration. In the central assignment method it is useful for slave stations to send a reply packet with information of last packet received. Several options are available, choice depends on individual use. Chapter 5: More than 32 nodes, handy tips, recommended parts In case an application requires more than 32 devices, there are basically two options. The simpler is to use transmitters with 4 times the input impedance (48k), allowing to connect up to 128 devices at the same time; these are commonly available nowadays. In this case, we have to adapt the whole termination system. The other option is to use a RS 485 repeater. Such a device has two TP ports. When data appear on one of them, the repeater sends them to the other port, and vice versa. In this way, we can connect another 31 (or 127) stations. Data activity detection
can be very simple, using the RS 485 definition - Vab>200mV; or, such a repeater may incorporate its own processor and work as a router as well - like in computer networks. One of the last things I'll mention are commonly available parts for RS 422/485. I have had personal experience with circuits made by MAXIM; they make about ten versions - differences are in speed (0.25 or 2.5 Mbit/s), operation type (half/full duplex), number of devices (32, 128), and in several other parameters. They are labeled MAX481, 485, 487, 491 and so on. Another manufacturer is National Semiconductors, label DS3695A. I assume that every major manufacturer offers some circuits for RS 422/485; however, I don't know any details. Some info in this article comes from excellent publication by Texas Instruments, who make a whole family of RS 422/485 circuits labelled SN 7517X, where X is one- or two-digit type specification. Several hints: Don't know which wire is A and B? When idle, B is more positive than A. You don't always have to use TP cables. For small distances and low speeds, common telephone cables are good enough. Termination is not critical for small distances and low speeds - works fine with MAX circuits. In Czech Republic, MAX487 is available at Starmans Electronic, or Spezial electronics for less than 100 KPhi (approx. $4). For other countries, please contact your local electronic components dealer. Final words The decision of suitability or unsuitability of RS 422/485 for your application is up to you. I hope that this article has provided you with enough basic info. If you are interested in further details, I recommend especially [1], as well as datasheets by MAXIM. If you are in the process of deciding which type of communication to use in your project, then I hope that this article has brought an inspiration and perhaps saved a lot of time and effort. Of course, if you are interested, you can contact me via e-mail. Literature:
[1] Texas Instruments u Data Transmission design 96 Seminar manual (SLLDE01A) Texas Instruments u Data Transmission design Seminar 97 (SLLDE01B) [2] Josef Pupesetaman u DatovTheta so/otoo a slupesetaby (nakladatelstvo/o +VUT 1994) [3] Zdenook Rosa u Principy Phiinnosti a technicktheta vybaveni pophio/otaphiov^2ch so/oto/o (Systemkonzult) Abbreviations: TP TwistedPair - Two identical wires wrapped around each other. RS232/RS422/RS485 에대해서 마이크로프로세서는주변장치를통해서외부와정보를교환할수있으며일반적으로정보를외부와교환하는방법으로는병렬통신과직렬통신 2 가지로나눌수가있다. 일반적으로컴퓨터내의장치와정보교환을할때는통상적으로고속의통신속도를필요로하여한꺼번에많은정보를처리할수있는병렬통신방식을주로쓴다. 이는대량의정보를빠른시간에한꺼번에처리함으로써컴퓨터의성능을향상시킬수가있기때문인데이러한방법의대표적인것이마이크로프로세서자체의정보처리량을증가시키는것이며이것은데이터비트수로써나타난다. (80286 은 16 비트의외부데이터비트, 80386, 80486 은 32 비트의외부테이터비트, 비록내부에서는 32 비트로동작되지만 64 비트의외부데이터비트를갖는펜티엄계열를보아도알수있다.) 그외 HDD, FDD, VIDEO 카드등이대표적인병렬통신방식을사용하는장치라하겠다. 하지만모든경우에병렬통신방식을사용할수는없다. 그이유는통신거리의제한성, 구현상의기술적인어려움과비용이너무비싸다는데있다. 또한어플리케이션자체가고속의통신속도를필요로하지않을경우도많다. 이러한이유로컴퓨터가외부와의통신을할때는직렬통신방식을많이사용한다. 직렬통신방식이란데이터비트를 1 개의비트단위로외부로송수신하는방식으로써구현하기가쉽고, 멀리갈수가있고, 기존의통신선로 ( 전화선등 ) 를쉽게활용할수가있어비용의절감이크다는장점이있다. 직렬통신의대표적인것으로모뎀, LAN, RS232 및 X.25 등이있다. 하지만크게직렬통신을구분하면비동기식방식과동기식방식 2 가지로나누어진다. 많은사람들이비동기식통신방식을 RS232 로알고있는데실질적으로 RS232 라는것은비동기식통신콘트롤러에서나오는디지털신호를외부와인터페이스시키는전기적인신호방식의하나일뿐이다. 일반적으로 RS232 를비동기식통신방식으로인식하고있는것도큰무리는없다. 비동기식통신방식을지원하는대표적인콘트롤러는 NS 사의 16C450 과 16C550 이며그외호환되는콘트롤러가다수의회사에서생산되지만성능상의차이는없고호환은되지않지만비동기통신의기능을갖는콘트롤러는수십가지의종류가있다. 비동기식통신콘트롤러를일반적으로 UART(Universal Asynchronous Receiver/ TransmItter) 라부른다.
UART 에서나오는신호는보통 TTL 신호레벨을갖기때문에노이즈에약하고통신거리에제약이있다. 이러한 TTL 신호를입력받아노이즈에강하고멀리갈수있게해주는인터페이스 IC 를 LINE DRIVER/RECEIVER 라부르며이중대표적인것이 RS232, RS422 및 RS485 가있다. 이들인터페이스방식의특성은아래표에나타나있다. Specification RS232C RS423 RS422 RS485 동작모드 Single-Ended Single-Ended Differential Differential 최대 Driver/Receiver 수 1 Driver 1 Receiver 1 Driver 10 Receivers 1 Driver 10 Receivers 32 Drivers 32 Receivers 최대통달거리 약 15 m 약 1.2 km 약 1.2 km 약 1.2 km 최고통신속도 20 Kb/s 100 Kb/s 10 Mb/s 10 Mb/s 지원전송방식 Full Duplex Full Duplex Full Duplex Half Duplex 최대출력전압 ±25V ±6V -0.25V to +6V -7V to +12V 최대입력전압 ±15V ±12V -7V to +7V -7V to +12V 위의표에서알수있듯이 RS-232 과 RS-423(Single-Ended 통신방식 ) 통신방식은 RS422 와 RS485 에비해서통신속도가늦고통신거리가짧은단점이있으나동작모드에서알수있듯이하나의신호전송에하나의전송선로가필요하기때문에비용절감의장점이있다.(RS422 인경우하나의신호전송에 2 개의전송선로가필요함 ) 위의인터페이스방식중 RS232, RS422 및 RS485 에대해서각자설명하겠다. 현재의 RS422 또는 RS485 칩의경우위의표에나와있는 Driver 와 Receiver 의수보다도훨씬많이지원하고있으며 RS485 인경우최대 256 의노드를갖는칩도있다. RS232 에대한설명 RS232C 는 EIA(Electronic Industries Association) 에의해규정되어졌으며그내용은데이터단말기 (DTE: Data Terminal Equipment) 와데이터통신기 (DCE: Data Communication Equipment) 사이의인터페이스에대한전기적인인수, 컨트롤핸드쉐이킹, 전송속도, 신호대기시간, 임피던스인수등를정의하였으나전송되는데이터의포맷과내용은지정하지않으며 DTE 간의인터페이스에대한내용도포함하지않는다. 같은규격이 CCITT(Consultative Committee for International Telegraph and Telephony) 에서도 CCITT V.24 에서 DTE 와 DCE 간의상호접속회로의정의, 핀번호와회로의의미에대해서규정을하고있다. 여기서는자세한기술적인내용의기술은피하고필요한내용만간략하게기술하겠다. RS232 에서일반적인내용은위에서충분히기술되어있으며기본적으로알아야할내용은코넥터의사양, RS232 신호선과케이블연결결선도이다. 이들의내용은아래와같다. 코넥터사양
신호선에대한설명 TXD - Transmit Data 비동기식직렬통신장치가외부장치로정보를보낼때직렬통신데이터가나오는신호선이다. RXD - Receive Data 외부장치에서들어오는직렬통신데이터를입력받는신호선이다 RTS - Ready To Send 컴퓨터와같은 DTE 장치가모뎀또는프린터와같은 DCE 장치에게데이터를받을준비가됐음을나타내는신호선이다. CTS - Clear To Send 모뎀또는프린터와같은 DCE 장치가컴퓨터와같은 DTE 장치에게데이터를받을준비가됐음을나타내는신호선이다. DTR - Data Terminal Ready 컴퓨터또는터미널이모뎀에게자신이송수신가능한상태임을알리는신호선이며일반적으로컴퓨터등이전원인가후통신포트를초기화한후이신호를출력시킨다. DSR - Data Set Ready 모뎀이컴퓨터또는터미널에게자신이송수신가능한상태임을알려주는신호선이며일반적으로모뎀에전원인가후모뎀이자신의상태를파악한후이상이없을때이신호를출력시킨다. DCD - Data Carrier Detect 모뎀이상대편모뎀과전화선등을통해서접속이완료되었을때상대편모뎀이캐리어신호를보내오며이신호를검출하였음을컴퓨터또는터미널에알려주는신호선이다. RI - Ring Indicator 상대편모뎀이통신을하기위해서먼저전화를걸어오면전화벨이울리게된다. 이때이신호를모뎀이인식하여컴퓨터또는터미널에알려주는신호선이며일반적으로컴퓨터가이신호를받게되면전화벨신호에응답하는프로그램을인터럽터등을통해서호출하게된다.
결선도 DTE to DCE 9 Wire Cables DTE to DCE 8 Wire Cables DTE to DTE 3 Wire Cables DTE to DTE 7 Wire Cables RS422 에대한설명 RS422 는 EIA 에의해서전기적인사양이규정되어있으나물리적인코넥터및핀에대한사양은아직규정되어있지않다. 앞으로나오는이들의내용은시스템베이스에서규정하여사용하는사양이니이에대해서오해가없으면한다. RS422 에서는 Point To Point 모드와 Multi-Drop 모드두가지가있다. Point To Point 모드인경우 RS232 와신호선당 2 개의라인이필요한것만빼고사용하는방법에있어서별다른필요가없다. 하지만 Multi-Drop 모드인경우는사용법이좀복잡하다. Multi-Drop 의자세한내용에대해서는다음란에서다루고먼저코넥터의사양, RS422 신호선과케이블결선도에대해서먼저설명하겠다. 코넥터사양
( ) 안의신호선은시스템베이스의제품중 MULTI-1 모델에만적용됨. 신호선에할당된핀번호는시스템베이스제품에만적용되며다른제품과틀릴수있음. 일반적으로사용되는신호선은 TXD+, TXD-, RXD+ 및 RXD- 이고나머지신호선은거의사용되지않는다. 신호선에대한설명신호선에대한설명은 RS232 와별차이가없고다만물리적으로하나의신호선에두개의라인이필요한데그들의표현은신호선명뒤에 + 와 - 로써구분표기한다. 즉, 예를들면 RS232 의 TXD 신호선이 RS422 에서는 TXD+ 와 TXD-로나누어질뿐이다. 결선도 <Point to Point 모드결선도 > <Multi-Drop 모드결선도 > DTE to DTE 2 Twisted Pair Cables * GND 는연결하지않아도됨. * + 신호선은 + 신호선과 - 신호선은 - 신호선과연결됨에유의바람.
RS422 Multi-Drop 모드에대한설명 Multi-Drop 모드가사용되는시스템은하나의마스터에여러개의슬레이브가연결되어마스터가어떤슬레이브와통신을할것인지를결정하고해당슬레이브를호출하면호출된슬레이브가응답을하는체제로구성되어진다. ( 앞쪽의 Multi-Drop 모드결선도참조 ) 이때, 하나의마스터에최대 10 개까지의슬레이브가연결될수가있고이때마스터는 Point To Point 모드로설정되어있어도상관이없으나슬레이브는반드시 Multi-Drop 모드로설정이되어져있어야한다. 여기서주의하여야할내용은모든슬레이브의 TX 신호라인을정보를출력시킬때만공동 TXD 라인에접속시켜야만하며그렇지않고하나의슬레이브가계속 TX 신호라인을공동 TXD 라인에접속시키면마스터에의해서호출된다른슬레이브가정보를출력시켜도계속접속된슬레이브때문에공동 TXD 라인에전기적인충돌이발생되어마스터로정보가전달되지않는다. 즉동시에 2 개이상의슬레이브가공동 TXD 라인에접속하면않되는것을반드시지켜야만한다. TX 신호선과공동 TXD 라인에 TX 신호선을접속또는단락시켜주는개폐신호사이에는 S/W 또는 H/W 에의한적절한타이밍의조절이필요한데일반적으로 S/W 에의한방법을많이사용한다. 우선 TX 신호선과개폐신호사이의관계를알아보는것이중요한데이들간에필요한타이밍정보를아래그림을통해서알아보자. 먼저슬레이브가마스트로데이터를출력하기전 ( 슬레이브측의 UART TXD 신호선 ) 먼저개폐신호를출력시켜야한다.( 슬레이브측의 RS422 개폐신호 (Logic "1" 이면접속 Logic "0" 이면단락 ) 를참조 ) 즉, TXD 라인을통해서출력하는첫번째데이터 "A" 의스타트비트가출력되기전최소한 RS422 드라이버칩이개폐신호를받고접속되는데걸리는시간인 Driver Enable to Output High Delay Time(tZH) 이나 Driver Enable to Output Low Delay Time(tZL) 이전에 RS422 개폐신호를접속하는상태로출력시켜야만한다.(Logic "1" 상태 ) 여기서 tzh 와 tzl 의수치는칩제조회사마다약간씩틀리나보통수십에서수백 ns 사이의값이다. 하지만이수치값이최소수치이기때문에정확하게지킬필요는없고여유있게주면된다. 즉, S/W 에서먼저 RS422 개폐신호를접속상태로출력시키고난후 TXD 라인에데이터를출력시키며 TXD 라인에마지막데이터의스톱비트까지출력되고난것을확인후개폐신호를단락상태로출력시키면된다.( 그림상에서
데이터 "B" 의스톱비트가출력된후 RS422 개폐신호가단락상태 (Logic "0") 로전환되는것을보면알수가있다.) 위그림에서알수있드시 RS422 개폐신호가접속상태일때슬레이브측의 RS422 칩의출력단인 TXD+ 와 TXD-출력단에신호가출력되어 ( 데이터 "A", "B") 마스터측의 UART RXD 입력단에신호가입력됨을알수가있고 ( 데이터 "A", "B") RS422 개폐신호가단락상태일때슬레이브측의 TXD+ 와 TXD-출력단이플로팅 (Hi-Z) 상태가되어신호가출력되지않아 ( 데이더 "C") 마스터측의 UART RXD 입력단에아무신호가입력되지않음을알수가있다 TXD+ 와 TXD-신호는공동 TXD 라인에접속시서로반대의상태를갖고출력되고단락시동시에플로팅상태임을그림을통해알수있다. 일반적으로 RS422 개폐신호는 RTS 나 DTR 신호중하나를사용하며시스템베이스의경우는대부분 RTS 신호를사용한다. 사실 TXD 신호선을 S/W 에의해서접속또는단락하는것자체에별문제는없으나프로그래머입장에서는까다롭고귀찮은일임에틀림없다. 이러한불편함을해소하가위해서나온방법이 TXD 신호선에서데이터가나올때만 H/W 가이를감지하여자동으로접속또는단락동작을자동으로하는것이다. 이방법은프로그래머에게편리함과다른 S/W 와의호환성유지 (Multi-Drop 용의 S/W 가아닌경우 ) 에유용하다라고는하겠으나전세계적으로그러한기능을제공하는칩및제품은없다. 다만시스템베이스의 MULTI-1 모델중일부분의모델에서만 H/W 에의한자동개폐가가능하니폐사에문의하여사용하면되겠다. RS485 에대한설명 RS485 는 EIA 에의해서전기적인사양이규정되어있으나물리적인코넥터및핀에대한사양은아직규정되어있지않다. 앞으로나오는이들의내용은시스템베이스에서규정하여사용하는사양이니이에대해서오해가없으면한다. RS485 인경우 RS232 나 RS422 처럼 Full Duplex 가아닌 Half Duplex 전송방식만지원하기때문에 RS422 의 Multi-Drop 모드의슬레이브처럼 RS485 의모든마스터는 TXD 신호를멀티포인트버스 (RS485 의모든마스터가공유하는신호라인을그렇게부른다.) 에접속또는단락시켜야만할뿐만아니라 RXD 신호역시모드에따라서는접속, 단락의제어를하여야한다. RS485 에서는 Echo 모드와 Non Echo 모드두가지가있다. 이들에대한자세한내용에대해서는다음란에서다루고먼저코넥터의사양, RS485 신호선과케이블결선도에대해서먼저설명하겠다. 코넥터사양
신호선에할당된핀번호는시스템베이스제품에만적용되며다른제품과틀릴수있음. 신호선에대한설명신호선에대한설명은 RS232 와별차이가없고다만물리적으로하나의신호선에두개의라인이필요한데그들의표현은신호선명뒤에 + 와 - 로써구분표기한다. 하지만 UART 의 TXD, RXD 신호선이멀티포인트버스에의하여공동으로사용하게됨에유의하여야한다. 즉하나의마스터는멀티포인트버스를출력이면출력, 입력이면입력으로구분하여사용할수밖에없다. 결선도 RS485 Echo, Non Echo 모드에대한설명멀티포인트버스를사용하는시스템은하나의버스에여러개의마스터가연결되어사용한다. 이때문에하나의마스터가다른마스터와통신을할경우에는반드시출력개폐를하여야만한다. 이것의원리는 RS422 의 Multi-Drop 모드와동일하니그쪽을살펴보시기바람. 하지만동시에여러개의마스터가출력을하여데이터가충돌하는현상이발생하기때문에이러한문제는 S/W 에의하여
해결되어야한다. 이렇게충돌여부를확인하는방법중하나가자기가보낸정보를자기가받아보아충돌여부를확인하는것인데이것을 RS485 Echo 모드라부른다. 즉, 어떤마스터가멀티포인트버스에예를들어 "ABC" 라는데이터를보내면이것이자동적으로되돌아오므로 (Echo) 이것을읽어와 "ABC" 여부를확인하여동일한정보가아니거나들어온데이터의수가틀리면충돌한것으로보고적절한시간의지연을거쳐다시출력시켜정확한값이되돌아올때까지되풀이하면된다. 이때마스터의 RXD 신호선은항상멀티포인트버스에접속되어있어자신의데이터뿐만아니라다른어느마스터가보내는데이터를받을수가있다. 이러한데이터를자신에게필요한정보인지를판단하는것은 S/W 에의해서결정된다. 위의내용을요약하면 RS485 Echo 모드는마스터의 RXD 신호선은항상멀티포인터버스에접속되어있고 TXD 신호선은데이터를출력할때만멀티포인터버스에접속시키야하고나머지는반드시단락시켜야한다. 만약단락시키지않으면 RS422 의 Multi-Drop 모드와같이다른마스터가데이터를보내도충돌이발생하여절대로올바른송수신이발생할수가없다. 위의 RS485 Echo 모드에서자기가보낸데이터가자기자신에게되돌아오는기능을없앤것이 RS485 Non Echo 모드이다. RS485 Non Echo 모드는 TXD 신호선을멀티포인트버스에접속시키면그즉시 RXD 신호선이멀티포인트버스에서단락되고, TXD 신호선을멀티포인트버스에서단락시키면그즉시 RXD 신호선이멀티포인트버스에접속하게된다. 멀티포인터버스에접속및단락할때필요한타이밍관계는 RS422 Multi-Drop 에대한설명에서자세하게다루었기때문에더이상언급하지않겠다. 일반적으로 RS485 개폐신호는 RTS 나 DTR 신호중하나를사용하며시스템베이스의경우는대부분 RTS 신호를사용한다.