How does RS485 communication realize sending and receiving control?
Features of RS485 communication interface from RenhotecIC
As a more commonly used communication method in the industrial field, the RS485 bus has the following characteristics:
The level between the transceiver output A and B is +2V ~ +6V, which is a logic "1"; it is -6V ~ -2V, which is a logic "0". The signal level is lower than that of RS232, and the interface chip is not easy to be damaged. Another "enable" control signal can put the transceiver in a high-impedance state and cut off the connection with the transmission line.
The input sensitivity of the receiver is 200mV. That is, the logic can be output when the level difference between the receiving terminals A and B is 200mV.
High transmission rate (10Mbps), transmission distance up to 1200m).
It has multi-site transmission capability, that is, up to 128 transceivers are allowed to be connected to the bus, and a device network can be established.
The common-mode voltage range of the RS485 transceiver is -7V ~ +12V. Only when this condition is met can the entire network work normally. When the common-mode voltage of the network line exceeds this range, it will affect the stability of the communication and even damage the interface.
Two, RS485 transceiver control method
RS485 is a half-duplex bus. In actual use, the host polling or token passing method is generally used to allocate bus control rights. RS485 devices need to switch the direction of sending and receiving. A more common method is that each RS485 device is in the receiving state at ordinary times, and only switches to the sending state when it has data to send, and then switches back to the receiving state after the data is sent.
The first type: program reversing control
The most commonly used RS485 transceiver switching method is program switching, that is, an I/O port of the MCU controls the transceiver enable pin of the RS485 transceiver device, and the RS485 transceiver device is in the receiving state at ordinary times, as shown in the figure below, here the 485 chip uses TI's SN65LBC184 has a maximum rate of 250Kbps. When there is data to be sent, the MCU puts the RS485 transceiver device pin (network RS485_EN2) in the sending state. After the data is sent, the RS485 transceiver device is switched back to the receiving state.
This method is simple and easy, and does not require additional costs. Many people will know this method and basically use it.
The second type: automatic reversing
However, when we use an industrial control motherboard or core board of a certain hardware platform for secondary development, because there are not enough I/O ports reserved on the industrial control motherboard or core board, the program commutation method of RS485 transceiver cannot be realized. In some specific cases, the underlying driver of the development platform is not open to the outside world, and it is difficult to carry out secondary development on the underlying layer. In this case, even if there are enough I/O ports, program switching cannot be realized. To this end, we need to adopt another kind of reversing technology, that is, automatic reversing technology. Automatic commutation actually means that the enable pin does not need a separate I/O port to control, but is controlled by the sending pin when sending data.
To achieve this method, you can enable an inverter there, as shown in the figure below, in the idle state, the serial port transmit signal TXD2 is high level, and output is low level after passing through the inverter, so SN65LBC184 is in the receiving state, and The RS485 bus is in the state of A high and B low due to the effect of pull-up and pull-down resistors. When sending data, the low-level bit on the TXD2 signal line controls the SN65LBC184 to enter the sending state and send the bit out. The high-level bit makes the SN65LBC184 in the receiving state, and the pull-down resistor on the RS485 bus puts the bus in the state of A high and B low, which means that the high level is sent.
The inverter can also be replaced by a triode. However, this method has limited driving capability when sending a high level, so it will limit the communication distance and is generally suitable for occasions where the distance is not far.
In fact, in order to save the trouble of control, you can also use a special 485 chip with AutoDirection function, such as MAX13487E, which saves the commonly used 485 enable signal, thus simplifying the design circuit.
Leave a Comment