|
Introduction
RS-422 and RS-485 are hardware specifications. Software protocol
is not discussed in either specification. It is up to the
system designer to define a protocol suitable for their system.
This chapter we will not attempt to define a protocol standard,
but will explain some of the issues that should be considered
by the system designer, whether writing or purchasing software.
RS-422 Systems
RS-422 system software differs little from the familiar point-to-point
RS-232 communication systems. RS-422 is often used to simply
extend the distance between nodes over the capabilities of
RS-232. RS-422 can also be used as the master node in a four-wire
master-slave network described later in this chapter. When
selecting or writing software for RS-422 systems the designer
should be aware of the signals being used by the hardware
in the system. Many RS-422 systems do not implement the hardware
handshake lines often found in RS-232 systems due to the cost
of running additional conductors over long distances.
RS-485
Driver Control
The principle difference between RS-422 and RS-485 is that
the RS-485 driver can be put into a high impedance, tristate
mode, which allows other drivers to transmit over the same
pair of wires. There are two methods of tristating an RS-485
driver. The first method is to use a control line, often the
RTS handshake line, to enable and disable the driver. This
requires that the host software raise the RTS line before
beginning a transmission to enable the driver, then lower
the RTS line after the completion of the transmission. Since
only a single RS-485 driver can be enabled on a network at
one time it is important that the driver is disabled as quickly
as possible after transmission to avoid two drivers trying
to control the lines simultaneously, a condition called line
contention. Under some operating systems it can be difficult
to lower RTS in a timely manner and this method of driver
control should be avoided altogether.
The second method of RS-485 driver control
we refer to as Automatic Send Data Control. This type of control
involves special circuitry that senses when data is being
transmitted and automatically enables the driver as well as
disabling the driver within one character length of the end
of transmission. This is the preferred method of driver control
since it reduces software overhead and the number of potential
pitfalls for the programmer.
RS-485
Receiver Control
The RS-485 receiver also has an enable signal. Since RS-485
systems using a two-wire configuration connect the driver
to receiver in a loopback fashion, this feature is often used
to disable the receiver during transmission to prevent the
echo of local data. Another approach is to leave the RS-485
receiver enabled and monitor the loopback data for errors
which would indicate that line contention has occurred. Although
a good loopback signal does not guaranty data integrity it
does offer a degree of error detection.
Master-Slave
Systems
A master-slave type system has one node that issues commands
to each of the "slave" nodes and processes responses. Slave
nodes will not typically transmit data without a request from
the master node, and do not communicate with each other. Each
slave must have a unique address so that it can be addressed
independent of other nodes. These type systems can be configured
as two-wire or four-wire. Four-wire systems often use an RS-422
master (the driver is always enabled) and RS-485 slaves to
reduce system complexity.
Four Wire Master-Slave Systems
This configuration reduces software complexity at the host since
the driver and receiver are always enabled, at the expense of
installing two extra conductors in the system. The Master node
simply prefixes commands with the appropriate address of the
slave. There is no data echo or turn around delays to consider.
Since each of the slave transmitters share the same pair of
wires, care must be taken that the master never requests data
from multiple nodes simultaneously or data collisions will result.
Two Wire
Master-Slave Systems
Two wire configurations add a small amount of complexity to
the system. The RS-485 driver must be tristated when not in
use to allow other nodes to use the shared pair of wires.
The time delay between the end of a transmission and the tristate
condition becomes a very important parameter in this type
system. If a slave attempts to reply before the master has
tristated the line, a collision will occur and data will be
lost. The system designer must know the response time or turn
around delay of each of the slave nodes and assure that the
master will tristate its driver within that amount of time.
B&B Electronics' Automatic Send Data control circuits tristate
the driver within one character length of the end of a transmission.
Multi-Master
RS-485 Systems
Each node in a multi-master type RS-485 system can initiate
its own transmission creating the potential for data collisions.
This type system requires the designer to implement a more
sophisticated method of error detection, including methods
such as line contention detection, acknowledgement of transmissions
and a system for resending corrupted data.
Systems
with Port Powered Converters
RS-232 to RS-422 or RS-485 converters that derive their power
from the RS-232 port are becoming more common in data systems.
A good programming practice is to set unused handshake outputs
to a high voltage state in systems using any type of RS-232
to RS-422 or RS-485 converter. This will assure the best possible
operating conditions for all converters used.
|