RS232,
RS422, RS423 and RS485 are serial communication methods for computers and devices. RS232
is without doubt the best known interface, because this serial
interface is implemented on almost all computers available today. But
some of the other interfaces are certainly interesting because they can
be used in situations where RS232 is not appropriate. We will concentrate on the RS485 interface here.
RS232 is an interface to connect one DTE, data terminal equipment to one DCE, data communication equipment
at a maximum speed of 20 kbps with a maximum cable length of 50
feet. This was sufficient in the old days where almost all computer
equipment were connected using modems, but soon after people started to
look for interfaces capable of one or more of the following:
Connect DTE's directly without the need of modems
Connect several DTE's in a network structure
Ability to communicate over longer distances
Ability to communicate at faster communication rates
RS485 is the most versatile communication standard in
the standard series defined by the EIA, as it performs well on all four
points. That is why RS485 is currently a widely used
communication interface in data acquisition and control applications
where multiple nodes communicate with each other.
Differential signals with RS485: Longer distances and higher bit rates
One of the main problems with RS232 is the lack
of immunity for noise on the signal lines. The transmitter and receiver
compare the voltages of the data- and handshake lines with one common
zero line. Shifts in the ground level can have disastrous effects.
Therefore the trigger level of the RS232 interface is
set relatively high at ±3 Volt. Noise is easily picked up and
limits both the maximum distance and communication speed. With RS485
on the contrary there is no such thing as a common zero as a signal
reference. Several volts difference in the ground level of the RS485 transmitter and receiver does not cause any problems. The RS485 signals are floating and each signal is transmitted over a Sig+ line and a Sig- line. The RS485 receiver compares the voltage difference between both lines, instead of the absolute voltage level
on a signal line. This works well and prevents the existence of ground
loops, a common source of communication problems. The best results are
achieved if the Sig+ and Sig- lines are twisted. The image below explains why.
Noise in straight and twisted pair cables
In the picture above, noise is generated by magnetic fields from the
environment. The picture shows the magnetic field lines and the noise
current in the RS485
data lines that is the result of that magnetic field. In the straight
cable, all noise current is flowing in the same direction, practically
generating a looping current just like in an ordinary transformer. When
the cable is twisted, we see that in some parts of the signal lines the
direction of the noise current is the oposite from the current in other
parts of the cable. Because of this, the resulting noise current is
many factors lower than with an ordinary straight cable.
Shielding—which is a common method to prevent noise in RS232 lines—tries to keep hostile magnetic fields away from the signal lines. Twisted pairs in RS485
communication however adds immunity which is a much better way to fight
noise. The magnetic fields are allowed to pass, but do no harm. If high
noise immunity is needed, often a combination of twisting and shielding
is used as for example in STP, shielded twisted pair and FTP, foiled twisted pair networking cables.
Differential signals and twisting allows RS485 to communicate over much longer communication distances than achievable with RS232. With RS485 communication distances of 1200 m are possible.
Differential signal lines also allow higher bit rates than possible with non-differential connections. Therefore RS485 can overcome the practical communication speed limit of RS232. Currently RS485 drivers are produced that can achieve a bit rate of 35 mbps.
Characteristics of RS485 compared to RS232, RS422 and RS423
Characteristics of RS232, RS422, RS423 and RS485
RS232
RS423
RS422
RS485
Differential
no
no
yes
yes
Max number of drivers Max number of receivers
1 1
1 10
1 10
32 32
Modes of operation
half duplex full duplex
half duplex
half duplex
half duplex
Network topology
point-to-point
multidrop
multidrop
multipoint
Max distance (acc. standard)
15 m
1200 m
1200 m
1200 m
Max speed at 12 m Max speed at 1200 m
20 kbs (1 kbs)
100 kbs 1 kbs
10 Mbs 100 kbs
35 Mbs 100 kbs
Max slew rate
30 V/μs
adjustable
n/a
n/a
Receiver input resistance
3..7 kΩ
≧ 4 kΩ
≧ 4 kΩ
≧ 12 kΩ
Driver load impedance
3..7 kΩ
≧ 450 Ω
100 Ω
54 Ω
Receiver input sensitivity
±3 V
±200 mV
±200 mV
±200 mV
Receiver input range
±15 V
±12 V
±10 V
–7..12 V
Max driver output voltage
±25 V
±6 V
±6 V
–7..12 V
Min driver output voltage (with load)
±5 V
±3.6 V
±2.0 V
±1.5 V
What does all the information in this table tell us? First of all we see that the speed of the differential interfaces RS422 and RS485 is far superior to the single ended versions RS232 and RS423. We also see that there is a maximum slew rate defined for both RS232 and RS423.
This has been done to avoid reflections of signals. The maximum slew
rate also limits the maximum communication speed on the line. For both
other interfaces—RS422 and RS485—the slew rate is indefinite. To avoid reflections on longer cables it is necessary to use appropriate termination resitors.
We also see that the maximum allowed voltage levels for all interfaces
are in the same range, but that the signal level is lower for the
faster interfaces. Because of this RS485
and the others can be used in situations with a severe ground level
shift of several volts, where at the same time high bit rates are
possible because the transition between logical 0 and logical 1 is only a few hundred millivolts.
Interesting is, that RS232 is the only
interface capable of full duplex communication. This is, because on the
other interfaces the communication channel is shared by multiple
receivers and—in the case of RS485—by multiple senders. RS232
has a separate communication line for transmitting and receiving
which—with a well written protocol—allows higher effective data rates
at the same bit rate than the other interfaces. The request and
acknowledge data needed in most protocols does not consume bandwidth on
the primary data channel of RS232.
Network topology with RS485
Network topology is probably the reason why RS485 is now the favorite of the four mentioned interfaces in data acquisition and control applications. RS485
is the only of the interfaces capable of internetworking multiple
transmitters and receivers in the same network. When using the default RS485
receivers with an input resistance of 12 kΩ it is possible to
connect 32 devices to the network. Currently available high-resistance RS485 inputs allow this number to be expanded to 256. RS485
repeaters are also available which make it possible to increase the
number of nodes to several thousands, spanning multiple kilometers. And
that with an interface which does not require intelligent network
hardware: the implementation on the software side is not much more
difficult than with RS232. It is the reason why RS485 is so popular with computers, PLCs, micro controllers and intelligent sensors in scientific and technical applications.
RS485 network topology
In the picture above, the general network topology of RS485 is shown. N nodes are connected in a multipoint RS485
network. For higher speeds and longer lines, the termination
resistances are necessary on both ends of the line to eliminate
reflections. Use 100 Ω resistors on both ends. The RS485
network must be designed as one line with multiple drops, not as a
star. Although total cable length maybe shorter in a star
configuration, adequate termination is not possible anymore and signal
quality may degrade significantly.
RS485 functionality
And now the most important question, how does RS485 function in practice? Default, all the senders on the RS485
bus are in tri-state with high impedance. In most higher level
protocols, one of the nodes is defined as a master which sends queries
or commands over the RS485 bus. All other nodes
receive these data. Depending of the information in the sent data, zero
or more nodes on the line respond to the master. In this situation,
bandwidth can be used for almost 100%. There are other implementations
of RS485 networks where every node can start a data
session on its own. This is comparable with the way ethernet networks
function. Because there is a chance of data collosion with this
implementation, theory tells us that in this case only 37% of the
bandwidth will be effectively used. With such an implementation of a RS485
network it is necessary that there is error detection implemented in
the higher level protocol to detect the data corruption and resend the
information at a later time.
There is no need for the senders to explicity turn the RS485 driver on or off. RS485
drivers automatically return to their high impedance tri-state within a
few microseconds after the data has been sent. Therefore it is not
needed to have delays between the data packets on the RS485 bus.
RS485 is used as the electrical layer for many well known interface standards, including Profibus and Modbus.
Therefore RS485 will be in use for many years in the future.
QUICK REFERENCE for RS485, RS422, RS232 and RS423
INTRODUCTION
Line drivers and receivers are commonly used to exchange data between
two or more points (nodes) on a network. Reliable data communications
can be difficult in the presence of induced noise, ground level differences,
impedance mismatches, failure to effectively bias for idle line conditions,
and other hazards associated with installation of a network.
The connection between two or more elements (drivers and receivers) should
be considered a transmission line if the rise and/or fall time is less than
half the time for the signal to travel from the transmitter to the receiver.
Standards have been developed to insure compatibility between units provided
by different manufacturers, and to allow for reasonable success in transferring
data over specified distances and/or data rates. The Electronics Industry
Association (EIA) has produced standards for RS485, RS422, RS232, and RS423
that deal with data communications. Suggestions are often made to deal with
practical problems that might be encountered in a typical network. EIA standards
where previously marked with the prefix "RS" to indicate recommended standard;
however, the standards are now generally indicated as "EIA" standards to
identify the standards organization. While the standards bring uniformity
to data communications, many areas are not specifically covered and remain
as "gray areas" for the user to discover (usually during installation) on
his own.
SINGLE-ENDED DATA TRANSMISSION
Electronic data communications between elements will generally fall into two broad
categories: single-ended and differential. RS232 (single-ended) was
introduced in 1962, and despite rumors for its early demise, has
remained widely used through the industry. The specification allows for
data transmission from one transmitter to one receiver at relatively
slow data rates (up to 20K bits/second) and short distances (up to
50Ft. @ the maximum data rate).
Independent channels are established for two-way (full-duplex)
communications. The RS232 signals are represented by voltage levels
with respect to a system common (power / logic ground). The "idle"
state (MARK) has the signal level negative with respect to common, and
the "active" state (SPACE) has the signal level positive with respect
to common.
RS232 has numerous handshaking lines (primarily used with modems), and
also specifies a communications protocol. In general if you are not
connected to a modem the handshaking lines can present a lot of
problems if not disabled in software or accounted for in the hardware
(loop-back or pulled-up). RTS (Request to send) does have some utility
in certain applications.
RS423 is another single ended specification with enhanced operation
over RS232; however, it has not been widely used in the industry.
DIFFERENTIAL DATA TRANSMISSION
When communicating at high data rates, or over long distances in real world
environments, single-ended methods are often inadequate. Differential
data transmission (balanced differential signal) offers superior
performance in most applications. Differential signals can help nullify
the effects of ground shifts and induced noise signals that can appear
as common mode voltages on a network.
RS422 (differential) was designed for greater distances
and higher Baud rates than RS232. In its simplest form, a pair of
converters from RS232 to RS422 (and back again) can be used to form an
"RS232 extension cord." Data rates of up to 100K bits / second and
distances up to 4000 Ft. can be accommodated with RS422. RS422 is also
specified for multi-drop (party-line) applications where only one
driver is connected to, and transmits on, a "bus" of up to 10
receivers.
While a multi-drop "type" application has many desirable
advantages, RS422 devices cannot be used to construct a truly
multi-point network. A true multi-point network consists of multiple
drivers and receivers connected on a single bus, where any node can
transmit or receive data.
"Quasi" multi-drop networks (4-wire) are often constructed
using RS422 devices. These networks are often used in a half-duplex
mode, where a single master in a system sends a command to one of
several "slave" devices on a network. Typically one device (node) is
addressed by the host computer and a response is received from that
device. Systems of this type (4-wire, half-duplex) are often
constructed to avoid "data collision" (bus contention) problems on a
multi-drop network (more about solving this problem on a two-wire
network in a moment).
RS485 meets the requirements for a truly multi-point
communications network, and the standard specifies up to 32 drivers and
32 receivers on a single (2-wire) bus. With the introduction of
"automatic" repeaters and high-impedance drivers / receivers this
"limitation" can be extended to hundreds (or even thousands) of nodes
on a network. RS485 extends the common mode range for both drivers and
receivers in the "tri-state" mode and with power off. Also, RS485
drivers are able to withstand "data collisions" (bus contention)
problems and bus fault conditions.
To solve the "data collision" problem often present in
multi-drop networks hardware units (converters, repeaters,
micro-processor controls) can be constructed to remain in a receive
mode until they are ready to transmit data. Single master systems (many
other communications schemes are available) offer a straight forward
and simple means of avoiding "data collisions" in a typical 2-wire,
half-duplex, multi-drop system. The master initiates a communications
request to a "slave node" by addressing that unit. The hardware detects
the start-bit of the transmission and automatically enables (on the
fly) the RS485 transmitter. Once a character is sent the hardware
reverts back into a receive mode in a few microseconds.
Any number of characters can be sent, and the transmitter will
automatically re-trigger with each new character (or in many cases a
"bit-oriented" timing scheme is used in conjunction with network
biasing for fully automatic operation, including any Baud rate and/or
any communications specification, eg. 9600,N,8,1). Once a "slave" unit
is addressed it is able to respond immediately because of the fast
transmitter turn-off time of the automatic device. It is NOT necessary
to introduce long delays in a network to avoid "data collisions."
Because delays are NOT required, networks can be constructed, that will
utilize the data communications bandwidth with up to 100% through put.
Below are the specifications for RS232, RS423, RS422, and RS485.
SPECIFICATIONS
SPECIFICATIONS
RS232
RS423
RS422
RS485
Mode of Operation
SINGLE -ENDED
SINGLE -ENDED
DIFFERENTIAL
DIFFERENTIAL
Total Number of Drivers and Receivers on One Line (One driver
active at a time for RS485 networks)
1 DRIVER 1 RECVR
1 DRIVER 10 RECVR
1 DRIVER 10 RECVR
32 DRIVER 32 RECVR
Maximum Cable Length
50 FT.
4000 FT.
4000 FT.
4000 FT.
Maximum Data Rate (40ft. - 4000ft. for RS422/RS485)
20kb/s
100kb/s
10Mb/s-100Kb/s
10Mb/s-100Kb/s
Maximum Driver Output Voltage
+/-25V
+/-6V
-0.25V to +6V
-7V to +12V
Driver Output Signal Level (Loaded Min.)
Loaded
+/-5V to +/-15V
+/-3.6V
+/-2.0V
+/-1.5V
Driver Output Signal Level (Unloaded Max)
Unloaded
+/-25V
+/-6V
+/-6V
+/-6V
Driver Load Impedance (Ohms)
3k to 7k
>=450
100
54
Max. Driver Current in High Z State
Power On
N/A
N/A
N/A
+/-100uA
Max. Driver Current in High Z State
Power Off
+/-6mA @ +/-2v
+/-100uA
+/-100uA
+/-100uA
Slew Rate (Max.)
30V/uS
Adjustable
N/A
N/A
Receiver Input Voltage Range
+/-15V
+/-12V
-10V to +10V
-7V to +12V
Receiver Input Sensitivity
+/-3V
+/-200mV
+/-200mV
+/-200mV
Receiver Input Resistance (Ohms), (1 Standard
Load for RS485)
3k to 7k
4k min.
4k min.
>=12k
RS485 en de afsluitweerstanden
Wanneer kleine hoeveelheden data met informatie moeten getransfereerd worden over langere
afstanden dan is een RS-485 interface een goede keuze.
Een RS-485 interface is een elektrische specificatie voor een meerpunt schakeling
die gebruik maakt van een symmetrisch netwerk.
RS-485 laat het gebruik van meerdere zenders en ontvangers op een netwerk (bus) toe.
Het specificatie document (TIA/EIA-485-A) definieert de elektrische karakteristieken van de
bus en van de zender en ontvangers.
In het document staan suggesties voor het afsluiten en bedraden van het netwerk, maar hoe
de pin's zijn aangesloten of welk software protocol er wordt gebruikt is vrij te kiezen.
Een RS-485 netwerk kan over 256 stations beschikken indien er gebruik gemaakt wordt van ontvangers
met een hoge weerstand.
De lengte van het netwerk kan tot 1200 meter bedragen bij dataoverdracht snelheden tot 10 Mbps.
Voor langere afstanden kan er gebruik gemaakt worden van versterkers die het signaal regenereren
en zo een nieuw RS-485 netwerk beginnen.
De RS-485 specificatie zegt niets over het te gebruiken protocol, in de praktijk wordt er veel gebruik gemaakt van een protocol dat vertrouwd is met dat van de UART die in een PC zit.
In de handel zijn er verschillende soorten RS-485 omzetters te verkrijgen, voor microcontrollers
kan je een RS-485 transceiver aansluiten aan de seriële poort.
De meeste netwerken maken gebruik van een extra signaal voor controle van de transceiver.
Aan de zijde van de PC kan men hiervoor gebruik maken van het RTS signaal.
De reden waarom RS-485 netwerken over zo een grote lengte communiceren is omdat de ontvangers
het verschil meten in spanning tussen de twee geleiders van de kabel.
De meeste storingen die op de geleiders voorkomt is voor beide gelijk, hierdoor verandert het spanningsverschil
tussen de geleiders niet. Deze storingen oefenen daarom geen invloed op de ontvanger waardoor een goede
werking van het netwerk is verzekerd.
Van een common-mode spanning (zoals bij RS232) is er ook geen sprake dit omdat de retour via de tweede
geleider loopt.
Voor de zender moet het spanningsverschil minstens 1,5 V zijn, zodat de interface een
voldoende tolerantie heeft voor niet gemeenschappelijke ruis en verzwakking.
In een knooppunt moet de bedrading zo kort mogelijk gehouden worden.
In de meeste gevallen wordt een getwiste (twisted-pair) afgeschermde kabel gebruikt omdat deze goede eigenschappen
heeft om ruis te voorkomen.
De datasheets van interface chips geven de niet inverse lijn de naam Line A en de inverse lijn
de naam Line B. Wanneer spanning op Line A meer dan 200mV groter is dan deze van Line B dan de is uitgang
van de ontvanger hoog. In het omgekeerde geval is de uitgang van de ontvanger laag.
Indien het verschil tussen Line A en Line B minder dan 200 mV is, dan is de status van de uitgang
ongedefinieerd.
De figuur toont een voorbeeld van een mogelijk RS-485 netwerk.
Afsluitweerstanden RS485 netwerk
In het begin van het netwerk staan drie weerstanden twee van 470 ohm en een van 120 ohm.
Deze weerstanden zorgen ervoor dat de status van de lijn behouden blijft wanneer er geen driver actief is.
De afsluitweerstanden.
Aan het begin en het einde van een RS-485 netwerk moet een afsluitweerstand geplaatst worden.
De afsluitweerstanden reduceren reflecties in de kabel die ervoor kunnen zorgen dat de ontvanger
een logische toestand verkeerd ontvangt en moeten dus steeds geplaatst worden! De waarde voor de
afsluitweerstand is voor een RS-485 netwerk tussen de 100 en 150 ohm. Voor de DCIBUS die op een baudrate
werkt van 115200 Hz is 120 ohm als waarde voor de afsluitweerstand een goede keus.
Plaats alleen aan het begin en het einde van het netwerk een afsluitweerstand, meerdere weerstanden
hebben geen nut en leggen het netwerk eigenlijk in kotsluiting waardoor de componenten voor de transmissie
overbelast worden.
De RS-485 specificatie raad een 100 ohm weestand (0.5 W) aan in serie met de massa bij
iedere knoop in het netwerk. Indien de spanning van de massa op twee knopen verschilt dan
zullen de weerstanden de stroom beperken.