How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and Cons

How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and ConsWeChat SearchHow to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and ConsTechnical Training

RS485 is one of the most common buses, and almost every industrial control device uses it, which we are quite familiar with. We all know that RS485 is a half-duplex communication, and its internal source in the CPU is serial communication. Serial communication distinguishes between transmission TX and reception RX. If TX and RX are transmitted simultaneously on the same pair of differential signal lines, direction control is required. If the timing of direction control is incorrect, data transmission will encounter issues.

For example, in Figures 1 and 2 below, after the TX signal from the CPU is sent, the direction pin is pulled low about 100 µs later, switching to the receiving state. However, the slave replies with an RX signal 60 µs after the TX signal has finished sending. Since the RS485 chip is still in sending state at this moment, the received data will be ignored, which manifests as data loss at the system level.

How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and Cons

Figure 1 RS485 Interface Circuit

Some readers might recall that if the slave replies a bit slower and does not respond so quickly, this problem would not exist. However, the slave is generally the customer’s machine, and we can hardly request others to change their response time. For example, when the Mitsubishi FX3U PLC acts as a slave, it only takes 60 µs from the master sending data to the slave replying. Some control boards even have a reply time of less than 10 µs.

The goal of studying the direction switching of RS485 is: the RS485 bus should be in the receiving state when idle, and if there is data sent from the master, the direction pin should be pulled high and switched back to receiving state promptly after sending is complete.

How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and Cons

Figure 2 Situation Where Direction Switching Time is Too Long

1. RS485 Direction Switching Solutions

Most low-cost RS232-RS485 converters use this method. The specific implementation method is: using the serial port’s transmission signal TX as the input to an inverter, and the output of the inverter is used to control the RS485 transceiver’s send/receive control pin. At the same time, pull-up/pull-down resistors are added to the A/B output terminals of the RS485 transceiver, as shown in Figure 3.

How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and Cons

Figure 3 Automatic Switching Circuit Using Inverter

In idle state, the serial port’s transmission signal TXD is high, and after passing through the inverter, outputs low, putting the 485 chip in receiving state. Meanwhile, due to the pull-up/pull-down resistors, the RS485 bus is in A high and B low state. When sending data, the low bit on the TXD signal line controls the 485 chip to enter sending state, sending that bit out. The high bit keeps the 485 chip in receiving state, and due to the pull-up/pull-down resistors, the bus remains in A high and B low state, indicating a high level is sent.

In simple terms, this circuit means that when sending a low level, the 485 chip is in sending state, while sending a high level, the 485 chip is in receiving state.

Advantages:

Only an inverter needs to be added; no software intervention is required. The inverter can be implemented using a transistor, making it very low cost (a few cents);

Disadvantages:

Since pull-up/pull-down resistors cannot be selected too small, otherwise it will affect the normal sending data level. Therefore, this switching mode has weak driving capability when sending high levels, and theoretically, I require the direction pin to switch direction before the data. However, due to the inverter, the time to reach the chip is prolonged, arriving later than the data, making it easy to lose packets at higher speeds. If multiple slaves need to be driven, it will be inadequate, and the driving capability is too weak, allowing only short-distance transmission; furthermore, the transmission speed cannot be too fast, generally using 9600 bps.

2. RS485 Direction Switching Solutions

Using software to control direction:

Most products with built-in RS485 on the market adopt this type of solution, as shown in Figure 4 with the RS_EN pin. The specific implementation is: in idle state, RS_EN is low, and the MCU is in receiving state. Before preparing to send data, the MCU will pull RS_EN high, U1 is in sending state, and after sending is complete, RS_EN returns to low, and U1 is in receiving state.

How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and Cons

Figure 4 Using Software to Control Direction Switching

The key to this solution is that the software needs to master the timing of the RS_EN pin’s high and low levels. Suppose after sending data, it does not switch to receiving state in time, and at this moment, the slave replies with data; this will cause packet loss, leading to the situation shown in Figure 2 at the beginning of the article. Unfortunately, the levels of software engineers vary greatly, especially after running operating systems (Linux, Windows, etc.), making it very difficult to control the timing of the direction pin accurately.

Advantages:

No additional hardware costs are needed, and the driving capability of the RS485 is unaffected.

Disadvantages:

It relies on software to control the direction pin. If a complex operating system is running, the priority of controlling the pin may not be high enough, or the software may not be optimized well, leading to untimely switching of the direction pin, resulting in data loss. Additionally, whether packet loss occurs also depends on the slave’s response time, and the testing process may not necessarily reveal this.

3. RS485 Direction Switching Solutions

Using a flip-flop to control direction:

To overcome the shortcomings of inverter switching, an automatic switching technique controlled by RS flip-flops has emerged, as shown in Figure 5. The key to this circuit is the charging and discharging circuit composed of diodes, resistors, and capacitors between the inverter and the RS flip-flop.

In idle state, the 485 chip remains in receiving state. When a low-level start bit is sent on the TXD signal line, the inverter outputs high, quickly charging the capacitor through the diode, making the R end of the RS flip-flop high and the S end low, triggering the flip-flop to output high, putting ISL3152E in sending state; when the TXD signal line transitions to high level, the inverter outputs low, and the capacitor discharges slowly through the resistor, temporarily keeping the R end in high level state, along with the S end being high, keeping the output of the flip-flop in the previous high state, with the 485 chip still in sending state.

After the capacitor discharges for a certain period, the R end voltage drops to low level, causing the flip-flop output to go low, putting the 485 chip back to receiving state. By selecting the resistor and capacitor values, we can control the discharge speed, ensuring that a low-level start bit is sufficient for the entire byte to be sent. This type of solution has very poor parameter consistency, and it is mostly used by those who are bold enough.

How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and Cons

Figure 5 Using Flip-Flop to Switch Direction

Advantages:

No software intervention is needed for direction switching, and the driving capability is strong (depending on the RS485 chip).

Disadvantages:

1. Increased number of components;

2. Different baud rates require matching different RC parameters;

3. Issues such as temperature, aging, and consistency can lead to changes in RC parameters, causing switching time confusion and resulting in packet loss.

4. RS485 Direction Switching Solutions

MAX13487 chip:

To overcome the uncertainty of software involvement in direction control, Maxim Integrated released the first RS485 chip that claims to support automatic direction switching, as shown in Figure 6. Compared to other RS485 chips, the /RE pin of MAX16487 has two functions:

(1) When /RE is low, it opens the RO direction to receive data.

(2) When RE is high, the chip enters automatic direction switching mode.

Generally, we connect /RE to high level, i.e., automatic switching mode.

How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and Cons

Figure 6 Internal Block Diagram of MAX13487

Since Maxim has not disclosed the internal logic principles, only describing that there is an internal state machine, we can only speculate about its working principle externally:

1. In idle mode, the data flow direction is RO direction; this is state 1;

2. When there is data to be sent from the serial port, the start bit being low level passes through the logic function D, and A

4. After a series of logical operations (with RI and DI as inputs, but the internal principle is unknown); the state machine detects that data transmission is complete, and the chip switches to receiving state 1.

Advantages:

Automatic direction switching by the chip, no software intervention needed, strong driving capability, high communication rate, and MAX13488 claims to reach up to 16 Mbps, comparable to the performance of ordinary RS485 chips.

Disadvantages:

Price is more than twice that of ordinary RS485 chips.

5. RS485 Direction Switching Solutions

Zhou Ligong Chip RSM(3)485PHT:

Zhou Ligong has integrated three related functional modules of RS485: DC power supply, isolation, and RS485 chip into one chip. Due to the lack of internal information, we cannot ascertain its internal logic functions. Official data claims that the maximum speed can reach 500 Kbps, which is sufficient for general applications.

Advantages:

Automatic direction switching by the chip, no software intervention needed, strong driving capability, high communication rate, and the integration of DC power supply, isolation, and RS485 chip functions saves board space.

Disadvantages:

The price is higher than building RS485 circuits with discrete components, and once damaged, the entire unit needs to be replaced.

How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and Cons

Figure 7 RSM(3)485PHT Circuit Diagram

6. Conclusion

We have provided five methods for automatic direction switching of RS485: Inverter Method, Software Control Method, Flip-Flop Method, Maxim MAX13488 Chip, Zhou Ligong RSM(3)485PHT.

The inverter method has weak driving capability and low speed, suitable only for debugging scenarios with low requirements; it should be chosen cautiously in industrial control situations.

The software control method has high requirements for software, especially for chips with operating systems, where controlling timing is quite challenging.

The flip-flop method is only suitable for constant baud rates and low-speed situations due to poor parameter consistency.

The solutions provided by Maxim and Zhou Ligong have already been chip-ified, verified by extensive market testing, and endorsed by large companies, ensuring reliability and temperature stability, thus recommended as a priority.

Disclaimer: This article is reproduced from the internet, and the copyright belongs to the original author: Creative Stack. If there are any copyright issues, please contact us promptly for deletion. Thank you!

HISTORY/Previous Recommendations

2021 Electrical Engineer Beginner Examination Question Bank Complete Version (with Answers)

Three Must-Have Tools for Electricians, Easily Accessible via WeChat!

“The Path of a Ten-Year Veteran Electrician,” Secrets to Earning Over Ten Thousand a Month!

Which of the Five Major Electrical Drafting Software (CAD, Eplan, CADe_simu…) Do You Pick?

The Latest Electrical Version CAD Drawing Software, with Detailed Installation Tutorial!

The Latest Electrical Drawing Software EPLAN, with Detailed Installation Tutorial!

Common Issues for Beginners Using S7-200 SMART Programming Software (with Download Links)

Comprehensive Electrical Calculation EXCEL Sheets, Automatically Generated! No Need to Ask for Electrical Calculations!

Bluetooth Headphones, Electrician/PLC Introductory Books Available for Free? Come Claim Your Electrical Gifts!

PLC Programming Basics: Ladder Diagrams and Control Circuits (with 1164 Practical Mitsubishi PLC Cases)

If You Still Can’t Understand Electrical Diagrams? Basic Electrical Diagram Reading Skills and Simulation Software Available for Quick Hands-On Practice!

12 Free Electrical Video Courses, 10GB Software/Electronic Book Resources, 30 Days of Free Live Electrical Courses Available!

Don’t forget to like + view!

How to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and ConsHow to Design RS485 Direction Switching Circuits? 5 Solutions with Pros and Cons Click “Read the Original” to Learn PLC/Electrician Courses for Free!

Leave a Comment