Although RS-485 communication has been around for a while, if you’re just getting started, you may find the following information helpful.
The four parts that must be set up for an RS-485 network to a PC serial interface are:
- PC serial interface.
- Device configuration.
- Communication software.
WiringThe best approach is to simply wire in a “daisy chain,” starting from the PC interface, running one wire pair (half-duplex) or two pairs (full-duplex) of wires to the terminals on the first device, then to the terminals on the next device, and so on down the line. If the PC is physically located in the middle of the run, then start at the device on one end of the run, wire toward the PC and then continue on to the other end of the run.
Remember that a maximum number of devices (usually 32) can be addressed on each RS-485 network, and the maximum wire length is generally 4,000'. To minimize the effect of noise, use twisted pairs as in Category 3 or Category 5 cable, minimize wire lengths and avoid running parallel to power cables or near noisy devices (motors, relays, fluorescent lights, etc.). You also should avoid a long segment of wire branching off from the main run to one or more devices. It is better to simply extend the main run and double back.
Common Wiring QuestionsWhat is the difference between half-duplex and full-duplex?
In order to transmit, you need a pair of wires: one wire to transmit and one for a return, forming a circuit path. In half=duplex, each device must alternate using the wiring pair to talk or listen, but not both at the same time. In full-duplex, a second pair is used, allowing devices to talk and listen at the same time. On the device, if only a pair of terminals is available (for instance, Data + and Data -), then it is most likely a half-duplex device.
Do I need a terminating resistor?
At low data rates and short runs, the wire resistance (assuming 24 AWG diameter wire or smaller) often is sufficient to cause settling on the bus between transmissions. As the length of the run increases or in a noisy environment, adding a 100 W resistor across the terminals of the devices at each end of a run (not at every device) may improve settling time and allow faster rates. Bear in mind that the terminating resistors electrically load the bus and may decrease the maximum length of your run, the number of devices allowed and the data transmission speed.
What are ground terminals for?
Most RS-485 interfaces - but not all - provide a ground or “GND” terminal. This is used to connect to a similar “GND” terminal on other communicating devices. This terminal does not carry data or signal but rather is intended to reference the data lines and remove common mode voltages. Without a reference voltage, the data lines may maintain relative (data transmission level) voltage levels between them, but their absolute voltages can drift out of electrical tolerance limits for the device. This can happen especially near high frequency, switched higher voltage loads such as a variable frequency driven AC motor.
PC Serial InterfaceThe pasta plant chose a National Instruments’ PCI-8433/4 PCI card interface that installed inside the computer. Other common options are USB-based RS-485 interfaces and RS-485 to RS-232 converters. Regardless of the interface, expect to install a driver provided by the manufacturer to make the device show up on the computer as a serial port. On Windows-based operating systems such as Windows XP look in the Device Manager under Ports (COM and LPT).
Configure the DevicesDepending on your device, this is usually done via the front panel menus. Assign a unique address (1 to 31) to the device and use the same serial settings on all devices. You may also need to enable serial communication on the device.
The most common serial settings are:
Most common is RTU mode; this may or may not be configurable.
- Baud Rate. How fast
bits travel on the wires such as 9600 bps (bits per second).
- Data Bits. 8-bit
(text) is most common, but 7-bit binary is also used.
- Parity. One bit can be
set aside as a check bit (even or odd) or no parity used.
- Stop Bit.This determines
how many bits (0,1,2) are used to signal the end of a transmission.
- Flow Control. Commonly unused in RS-485 networks
Communication SoftwareOn a desktop PC, almost any software development environment includes tools for communicating through a serial port. A terminal emulator like Hyperterminal on Windows OS) can be useful in taking the first steps. Many manufacturers provide free software with their devices that can be helpful for starting out.
A basic PC-based program consists of these steps:
- Setting Up the Serial Port. This is usually done once at the beginning of the session. Use the same serial settings (baud rate, etc) on your PC as the other devices.
- Transmit a Data Request. This often is done by sending a formatted string of text to the serial port, usually including the device address, a command, a device register and/or data. Consult your device manual.
- Wait for a Reply. RS-485 communication usually requires the bus to be quiet for a specified period of time between communications. Wait times between transmission and reply are on the order of 10-100ms.
- Receive a Reply. Interpret the string of text received at the serial report to extract data, configuration values, etc.
- Close the Port. After setting up the serial port in step 1, steps 2-4 can be repeated as many times as needed for a session. When the session is complete, issue a command to close the serial port so it is available to other applications.