RS-485 is a standard that was first adopted by the Electronics Industry Association. To date, this standard considers the electrical characteristics of various receivers and transmitters used in various balanced digital systems.
What is he like?
Among specialists, RS-485 is the name of a fairly popular interface that is actively used in various industrial process control systems to connect several controllers, as well as many other devices to each other. The main difference between this interface and the equally widespread RS-232 is that it provides for the combination of several types of equipment at the same time.
RS-485 provides high-speed information exchange between several devices through a single two-wire communication line in half-duplex mode. It is widely used in modern industry in the process of forming an automated process control system.
Range and speed
Using this standard, information is transmitted at a speed of up to 10 Mbit / s, while the maximum possible range will directly depend on how fast the data is transmitted. Thus, to ensure maximum speed, data can be transmitted no further than 120 meters, while at a speed of 100 kbit / s, information is transmitted more than 1200 meters.
Number of devices to be paired
The number of devices that the RS-485 interface can combine in itself will directly depend on which transceivers are used in the device. Each transmitter is designed for simultaneous control of 32 standard receivers, however, it must be understood that there are receivers whose input impedance is 50%, 25% or even an even smaller part of the standard, and in the case of using such equipment the total number of devices will increase accordingly.
Connectors and Protocols
The RS-485 cable does not standardize any particular format of information frames or the exchange protocol. In the predominant majority of cases, exactly the same frames that RS-232 uses are used for data transmission , that is, data bits, stop and start bits, as well as parity bits, if necessary.
The work of the exchange protocols in most modern systems is carried out on the basis of the “master-slave” principle, that is, some device in the network is the master and takes the initiative to exchange sending requests between all slave devices that differ by logical addresses. The most popular protocol to date is Modbus RTU.
It is worth noting that the RS-485 cable also does not have any specific type of connectors or wiring, that is, there may be terminal connectors, DB9 and others.
Connection
Most often, with the use of this interface, a local network is found that combines several transceivers simultaneously.
When connecting RS-485, you need to correctly combine the signal circuits, usually called A and B. In this case, the polarity reversal is not so scary, just the connected devices will not work.
Useful Tips
Using the RS-485 interface, you should consider several features of its work:
- The most optimal medium for signal transmission is a twisted pair cable.
- The ends of the cable must be drowned out using specialized terminal resistors.
- A network that uses a standard or USB RS-485 should be laid without any branches on the bus topology.
- Devices must be connected to the cable with wires of the shortest possible length.
In this case, the most optimal solution for laying the RS-485 interface is twisted pair, since it differs in minimally spurious signal emission and also has very good protection against interference. If the equipment will work in conditions of too high external noise, it is better to use cables with shielded twisted pair cable, while the cable shield is combined with protective ground.
Matching
Using terminal resistors, standard or USB RS-485 provides full matching of the open end of the cable with the subsequent line, completely eliminating the possibility of signal reflection.
The nominal resistance of the resistors is corresponding to the wave impedance of the cable and for those cables that are based on twisted pair, in the predominant majority of cases is approximately 100-120 Ohms. For example, the currently quite popular UTP-5 cable, which is actively used in the process of laying Ethernet, has a wave impedance of 100 Ohms. For other cable options, some other rating may be used.
Resistors, if necessary, can be soldered to the contacts of the cable connectors in the end devices. Rarely, resistors are installed in the device itself, as a result of which it is necessary to install jumpers to connect the resistor. In this case, if the device is turned off, the line is completely mismatched. And in order to ensure the normal operation of the rest of the system, you need to connect a matching stub.
Signal levels
The RS-485 port uses a balanced data transmission scheme, that is, the voltage levels on the signal circuits A and B will change in antiphase.
Using the sensor, a signal level of 1.5 V should be provided at full load, and also not more than 6 V if the device is idling. The voltage level is measured differentially, each signal wire is relative to another.
Where the receiver is located, the minimum level of the received signal in any case should be at least 200 mV.
Bias
In the event that there is no signal on the signal circuits, a slight bias occurs, which ensures the protection of the receiver from false alarms.
Experts recommend offsetting a little more than 200 mV, since this value is appropriate for the zone of inaccuracy of the input signal according to the standard. In this case, circuit A is pulled to the positive pole of the source, while circuit B is pulled to the common.
Example
In accordance with the necessary bias and voltage of the power source, the values of the resistors are calculated . For example, if you need to get a bias of 250 mV when using terminal resistors R T = 120 Ohm, while the source has a voltage of 12 V. Given that in this case two resistors are connected in parallel to each other and do not take into account load on the receiver side, the bias current is 0.0042 A, while the total bias circuit resistance is 2857 Ohms. R cm in this case will be approximately 1400 Ohms, so you need to choose some nearest denomination.
An example will be a 1.5 kΩ resistor designed for bias, as well as an external 12 volt resistor. In addition, in our system there is an isolated output of the controller power supply, which is a leading link in its segment of the circuit.
Of course, there are many other options for implementing bias that use the RS-485 converter and other elements, but in any case, when placing the bias circuits, you need to take into account that the node that will provide it will periodically turn off or even eventually can be completely removed from the network.
If bias is present, then in this case the potential of circuit A at completely idle is positive with respect to circuit B, which is a guideline if a new device is connected to the cable without marking the wires.
Incorrect wiring and distortion
Implementation of the above recommendations allows for the normal transmission of electrical signals to various points in the network if the RS-485 protocol is used as the basis. If at least one of the requirements is not met, signal distortion will occur. The most noticeable distortions begin to appear if the data exchange rate exceeds 1 Mbps, but in fact, even at lower speeds, it is highly recommended not to neglect these recommendations, even if the network "is working fine".
How to program?
In the process of programming various applications working with devices using the RS-485 splitter and other devices with this interface, several important points must be taken into account. We list them:
- Before the delivery of the parcel begins, you must necessarily activate the transmitter. Despite the fact that according to the information of certain sources, the issuance can be carried out immediately after switching on, some experts recommend initially holding a pause, which in time will be equal to the transmission speed of one frame. In this case, the correct reception program will have time to completely determine the transient errors, carry out the normalization procedure, and prepare for subsequent data reception.
- After the last byte of data has been issued, it is also recommended to pause before disconnecting the RS-485 device. In particular, this is due to the fact that two registers are often present simultaneously in the serial port controller, the first of which is a parallel input and is intended for receiving data, while the second is a shift output and is used for serial output. Any interruptions in the transmission by the controller are generated in the event of an empty input register, when information has already been provided to the shift register, but has not yet been issued. For this reason, after the broadcast is interrupted, it is necessary to withstand a certain pause before turning off the transmitter, which should be approximately 0.5 bits longer than the frame. For more accurate calculations, it is recommended that you study the technical documentation of the used serial port controller in detail.
- Since the transmitter, receiver, and, possibly, the RS-485 converter are connected to a single line, the own receiver will also perceive the transmission carried out by its own transmitter. It often happens that in systems characterized by random access to the line, this feature is used in the process of checking the absence of a collision between two transmitters. In standard systems operating in accordance with the master-slave principle, it is recommended that the interrupt from the receiver be completely closed during transmission.
Bus format configuration
This interface provides for the possibility of combining devices in the "bus" format, when all devices are combined using a single pair of wires. In this case, the communication line must be coordinated by the terminal resistors of the two ends.
To ensure coordination in this case, resistors are installed, characterized by a resistance of 620 ohms. They are always installed on the first and last device connected to the line. In the predominant majority of modern devices, there is also a built-in terminating resistance, which, if necessary, can be included in the line by installing a special jumper on the device board.
Since the jumpers are initially installed in the delivery state, you must first remove them from all devices, respectively, except for the first and last connected to the line. In repeaters-converters of the S2000-PI model, for each individual output, the matching resistance is switched on with a switch, while the S2000-KS and S2000-K devices are characterized by an integrated matching resistance, as a result of which there is no jumper necessary for its connection.
In order to provide a longer communication line, it is recommended to use specialized repeaters-repeaters equipped with fully automatic switching of the direction of transmission.
Star format configuration
Any branches in the RS-485 line are undesirable, because in this case a sufficiently strong distortion of the signal appears, however, from a practical point of view, they can be tolerated if a small branch length is present. In this case, the installation of terminating resistors on individual branches is not required.
In the RS-485 distribution system, which is controlled from the remote control, if the latter and the devices are connected to the same line, but are powered from different sources, it will be necessary to combine the 0 V circuits of all devices and the remote control in order to ensure equalization of their potentials. If this requirement is not met, then in this case, the remote control may have unstable communication with devices. If a cable with several twisted pairs of wires is used, then in this case a completely free pair can be used if necessary for the potential equalization circuit. Among other things, it is also envisaged the possibility of using shielded twisted pair if there is no grounding of the screen.
What to consider?
In the predominant majority, the current that flows through the potential equalization wire is quite small, however, if the 0 V devices or the power sources themselves are connected to several local grounding buses, the potential difference between the various 0 V circuits can be several units, and in some cases even tens of volts, while the current flowing along the potential equalization circuit can be quite significant. This is a common reason that there is an unstable connection between the remote control and devices, as a result of which they can even fail.
It is for this reason that it is necessary to exclude the possibility of grounding a 0 V circuit or, as a maximum, grounding this circuit at some specific point. It is also necessary to take into account the possibility of the relationship between 0 V and the protective earth circuit present in the equipment used in the OPS system.
At facilities that are characterized by a rather severe electromagnetic environment, it is possible to connect this network via a shielded twisted-pair cable. In this case, a lower limit range may be present, since the cable capacity is higher.