A system and method for adaptively adjusting RS485 bus drive
By adaptively adjusting the RS485 bus driver system and dynamically adjusting the bias resistor, the risk of bit errors and drive loss caused by unreasonable bias resistor settings are solved, thereby improving system stability and anti-interference capability.
Patent Information
- Application Number
- CN202411129321.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-08-16
AI Technical Summary
In existing RS485 bus communication, improper setting of the bias resistor can lead to a small bias differential voltage, which may result in bit error risk or excessive drive complexity, causing unnecessary losses.
An adaptive adjustment RS485 bus drive system is adopted. Through the control unit, adjustment unit and acquisition unit of the host and slave, and using n bias resistor pairs and selection switches, the resistance values of the pull-up and pull-down resistors are dynamically adjusted according to the bus conditions. It is divided into two groups, which are suitable for cases with and without termination resistors. The differential bias voltage of the bus is acquired to ensure that the differential threshold voltage is greater than 200mV.
It enables adaptive adjustment of the bias resistor based on bus conditions, reducing labor costs, improving system stability and anti-interference capabilities, avoiding bit error risks, and reducing unnecessary drive losses.
Smart Images

Figure CN119066004B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of communication technology and relates to an adaptive adjustment technology for RS485 bus drivers, specifically a system and method for adaptively adjusting RS485 bus drivers. Background Technology
[0002] The RS485 bus transmission protocol is a serial bus communication protocol that uses a differential operating mode. Its balanced transmission and differential reception structure design enables it to suppress common-mode interference, thus maintaining high stability and reliability during data transmission. RS485 communication networks typically use a master-slave communication mode, where one master device drives multiple slave devices. For applications with signal reflection on the bus, termination resistors are usually added at the beginning and end of the bus. When the RS485 network is idle, all nodes are in listen / receive mode. In this situation, there are no active drivers on the network; all drivers are in a tri-state; and the line state is unknown when no device is driving the network. To maintain an appropriate idle voltage state, bias resistors must be used to force the data lines into an idle state. The bias resistors are typically a pull-up resistor on data line A connected to the power supply and a pull-down resistor on data line B connected to ground; generally, the pull-up and pull-down resistors have the same resistance value.
[0003] To ensure a reasonable idle bias voltage, existing technology typically uses relatively large pull-up and pull-down resistors when bias resistors are set at all nodes in the network. This is to ensure that the equivalent pull-up and pull-down resistor values are not too small when there are many nodes, thus preventing insufficient drive capability of the transceiver. The problem is that with the same pull-up and pull-down resistor configuration, when there are few nodes and termination resistors are present, the idle level may not meet the minimum differential input requirements of the transceiver, leading to bit error risk. When a bias resistor is set at only one node in the network, considering the termination resistor configuration at the end and the maximum number of nodes, the pull-up and pull-down resistors are generally set relatively small. In practical applications with few nodes or no termination resistors at the end, this results in an excessively large drive load, leading to unnecessary drive losses.
[0004] This invention provides a system and method for adaptively adjusting RS485 bus drivers to solve the above-mentioned technical problems. Summary of the Invention
[0005] The present invention aims to solve at least one of the technical problems existing in the prior art; to this end, the present invention proposes a system and adjustment method for adaptively adjusting RS485 bus driver, which is used to solve the technical problem in the prior art where unreasonable setting of bias resistor leads to small bias differential voltage, which has the risk of bit error or leads to excessively complex driving and unnecessary losses.
[0006] To achieve the above objectives, a first aspect of the present invention provides a system for adaptively adjusting an RS485 bus driver, comprising: a master unit and several slave units;
[0007] The host includes a control unit, an adjustment unit, an RS485 interface unit, and a data acquisition unit; the slave includes a control unit and an RS485 interface unit.
[0008] The control unit is used to adjust the bias resistors; the adjustment unit contains n pairs of bias resistors and n selection switches, used to adjust the resistance values of the n pairs of bias resistors; the acquisition unit is used to acquire the bus differential bias voltage when the bus is idle.
[0009] The host is located at the beginning of the main network and is equipped with an external termination resistor; the termination resistor of the end slave can be selected according to the signal wavelength and the length of the transmission line; the end slave refers to the slave set at the end of the main network.
[0010] Preferably, the system includes a master and M-1 slaves, wherein the maximum value of M, Mmax, is determined by the input impedance of the RS485 transceiver.
[0011] Preferably, the total number of bias resistor pairs is n, where n is an even number and the value of n is 4≤n≤Mmax; each bias resistor pair x includes a pull-up resistor Rux and a pull-down resistor Rdx; the pull-up resistor Rux and the pull-down resistor Rdx can be selected and switched by selecting a dual-channel switch Sx; the n bias resistor pairs are divided into two groups.
[0012] The total number of bias resistor pairs in this invention is even, and each pair of bias resistors corresponds to a dual-channel switch. The bias resistor pairs can be precisely controlled by the dual-channel selection switch, which is beneficial to improving the accuracy of bus adaptive control.
[0013] Preferably, dividing the n bias resistor pairs into two groups includes:
[0014] The first to n / 2 bias resistors are suitable for cases where termination resistors are provided at the end of the bus; according to the formula... The resistance value R of the bias resistor is calculated.
[0015] The n / 2+1 to nth bias resistors are applicable when no termination resistor is provided at the end of the bus; using the formula The resistance value R of the bias resistor is calculated.
[0016] Adjust the resistance value of the corresponding bias resistor pair according to the calculated bias resistor value;
[0017] Among them, V A V Bare the potentials of buses A and B, V A -V B and V T are the bias differential voltages, VCC is the bias power supply, and R IN is the input impedance of the transceiver; R T is the termination resistor; M is the total number of nodes, and its value is taken from the elements in the sequence {Mmax, Mmax / 2, …, Mmax / 2^(x - 1)}, where the value of x ranges from 1 to n / 2.
[0018] The present invention divides the bias resistor pairs into two groups. One group is applicable to the case where a termination resistor is set at the end, and the other group is applicable to the case where no termination resistor is set at the end, and can calculate the resistance value of the bias resistor according to the actual situation; it is beneficial to set bias resistors with different resistance values for different bus situations.
[0019] Preferably, the resistance values of the bias resistor pairs are Ru1 < Ru2 < … < Run; Rux = Rdx; [Ru1, Rd1] is the bias resistor pair with the minimum resistance value, and [Run, Rdn] is the bias resistor pair with the maximum resistance value; the bias differential threshold voltage VT is set to be greater than 200 mV.
[0020] The present invention sets the preset bias differential threshold voltage to be greater than 200 mV, which can ensure that there is enough margin for the bus idle voltage and improve the stability and anti-interference ability of the system.
[0021] The second aspect of the present invention provides an adjustment method for adaptively adjusting the RS485 bus drive, including:
[0022] Step S1: During initialization, the control unit controls the switch S1 of the first pair of bias resistor pairs Ru1 and Rd1 to close and records cur as 1, and the remaining switches are opened; where cur is the switch number corresponding to the bias resistor pair and is used to record the switches.
[0023] Step S2: When the host does not send a signal and the bus is idle, the acquisition unit acquires the differential bias voltage VS of the bus.
[0024] Step S3: The control unit determines whether the differential bias voltage VS is greater than the preset bias differential threshold voltage VT and whether the current switch record cur is less than n; if yes, the currently closed switch is opened, the switch of the next pair of bias resistor pairs is closed, and cur = cur + 1 is updated; repeat Step S2; if not, execute Step S4.
[0025] Step S4: Determine whether the differential bias voltage VS is less than or equal to the preset bias differential threshold voltage VT; if yes, the control unit controls the currently closed switch to open, closes the switch of the previous pair of bias resistor pairs, and transfers to the normal communication process; if not, the bias resistor adjustment ends and transfers to the normal communication process.
[0026] Compared with the prior art, the beneficial effects of the present invention are:
[0027] 1. The RS485 bus driver of the present invention includes a master and several slaves. The master is provided with a termination resistor at the beginning, and the slaves are provided with termination resistors at the end according to the actual situation. By setting the total number of bias resistor pairs to an even number, and each pair of bias resistors corresponding to a dual-channel switch, synchronous control of pull-up and pull-down resistors can be achieved. The bias resistor pairs are divided into two groups, one group is suitable for cases where termination resistors are provided at the end, and the other group is suitable for cases where termination resistors are not provided at the end. The bias resistor values can be calculated according to the actual situation. This is beneficial for setting different bias resistor values for different bus conditions.
[0028] 2. This invention sequentially adjusts and controls the bias resistors, collects the differential bias voltage when the bus is idle, and analyzes whether to switch to the normal communication process based on the differential control voltage, the preset differential bias threshold voltage, and the switch records. It can achieve adaptive adjustment of the bus according to the number of bus slaves and the setting of the end termination resistors, eliminating the need for technicians to adjust the bus and reducing labor costs. Furthermore, setting the preset differential bias threshold voltage to be greater than 200mV ensures that the bus idle voltage has sufficient margin, improving the system's stability and anti-interference capability. Attached Figure Description
[0029] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0030] Figure 1 This is a schematic diagram of the overall connection of the system of the present invention;
[0031] Figure 2 This is a schematic diagram of the internal structure of the adjustment unit of the present invention;
[0032] Figure 3 This is a schematic diagram illustrating the specific steps of the present invention. Detailed Implementation
[0033] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0034] Please see Figures 1-2 The first aspect of the present invention provides a system for adaptively adjusting RS485 bus drivers, comprising: a master and several slave devices;
[0035] The host includes a control unit, an adjustment unit, an RS485 interface unit, and a data acquisition unit; the slave includes a control unit and an RS485 interface unit.
[0036] The control unit is used to adjust the bias resistors; the adjustment unit contains n pairs of bias resistors and n selection switches, used to adjust the resistance values of the n pairs of bias resistors; the acquisition unit is used to acquire the bus differential bias voltage when the bus is idle.
[0037] The host is located at the beginning of the main network and is equipped with an external termination resistor; the termination resistor of the end slave can be selected according to the signal wavelength and the length of the transmission line; the end slave refers to the slave set at the end of the main network.
[0038] The system consists of one master and M-1 slaves, where the maximum value of M, Mmax, is determined by the input impedance of the RS485 transceiver.
[0039] The total number of bias resistor pairs is n, where n is an even number and the value of n is 4≤n≤Mmax; each bias resistor pair x includes a pull-up resistor Rux and a pull-down resistor Rdx; the pull-up resistor Rux and the pull-down resistor Rdx can be selected and switched by a dual-channel switch Sx, and the n bias resistor pairs are divided into two groups.
[0040] Figure 1 The mid-end slave is slave M-1. A termination resistor can be set at the end slave. Generally, when transmitting high-frequency signals, the signal wavelength is relatively short compared to the transmission line. The signal will form a reflected wave at the end of the transmission line, interfering with the original signal. Therefore, a termination resistor needs to be added at the end of the transmission line to prevent the signal from being reflected after reaching the end of the transmission line. This is not necessary for low-frequency signals.
[0041] In long-distance signal transmission, a terminating resistor is usually required at the receiving end to avoid signal reflection and echo. In summary, terminating resistors are generally not set when the communication speed is low or the communication distance is short. Conversely, when the communication distance is long and the communication speed is fast, and the signal quality requirements are high, a terminating resistor is usually set at the end of the slave device.
[0042] For example: The input impedance of the RS485 transceivers selected for all nodes of the system is 12 kΩ, so the maximum number of nodes is 32, including 1 master node and 31 slave nodes; the master node is set at the head end, and there is 1 termination resistor RT outside its RS485 interface unit, and RT is 120 Ω. The termination resistor of the slave node at the end can be selected and configured or not configured according to the actual situation on site.
[0043] The adjustment unit includes 8 bias resistor pairs and 8 selection switches S. Rux and Rdx can be selected and switched by selecting the dual switch Sx, where x ranges from 1 to 8, and the bias power supply VCC is set to 5 V.
[0044] The resistance values of the bias resistor pairs are Ru1 < Ru2 < … < Run; Rux = Rdx; [Ru1, Rd1] is the bias resistor pair with the minimum resistance value, and [Run, Rdn] is the bias resistor pair with the maximum resistance value; the bias differential threshold voltage VT is set to be greater than 200 mV.
[0045] The n bias resistor pairs are divided into two groups, including:
[0046] The 1st to n / 2th bias resistor pairs are applicable to the case where a termination resistor is set at the end of the bus; the bias resistor value R is calculated through the formula to obtain the bias resistor value R;
[0047] The (n / 2 + 1)th to nth bias resistor pairs are applicable to the case where no termination resistor is set at the end of the bus; the bias resistor value R is calculated through the formula to obtain the bias resistor value R;
[0048] Adjust the resistance values of the corresponding bias resistor pairs according to the calculated bias resistor values; where, where, V A and V B are the potentials of buses A and B, V A -V B and V T are the bias differential voltages, VCC is the bias power supply, R IN is the input impedance of the transceiver; R T is the termination resistor; M is the total number of nodes, and the value is taken from the elements in the sequence {Mmax, Mmax / 2, …, Mmax / 2^(x - 1)}, where x ranges from 1 to n / 2.
[0049] For example: Divide 8 bias resistor pairs into two groups. The 1st to 4th bias resistor pairs are applicable to the case where a termination resistor is set at the end of the bus; the bias resistor is calculated through the formula <
[0051] The value of M is determined based on the elements in {32,16,8,4} and the bias differential threshold voltage VT is 250mV.
[0052] [Ru1,Rd1],[Ru2,Rd2],[Ru3,Rd3],[Ru4,Rd4] form the first pair of bias resistors, corresponding to the case where there is a terminating resistor at the end. [Ru5,Rd5],[Ru6,Rd6],[Ru7,Rd7],[Ru8,Rd8] form the second pair of bias resistors, corresponding to the case where there is no terminating resistor at the end. Therefore, the bias resistors Ru1~Ru8 or Rd1~Rd8 are calculated to be 528Ω, 548Ω, 559Ω, 564Ω, 983Ω, 1056Ω, 1096Ω, and 1118Ω respectively.
[0053] Please see Figure 3 A second aspect of the present invention provides an adaptive adjustment method for RS485 bus driver, comprising:
[0054] Step S1: During initialization, the control unit controls the first pair of bias resistors Ru1 and Rd1 to close switch S1 and record cur as 1, while the remaining switches are open; wherein, the cur bias resistors are numbered to correspond to the switches and are used to record the switches;
[0055] Step S2: When the host does not send a signal and the bus is idle, the acquisition unit acquires the differential bias voltage VS of the bus;
[0056] Step S3: The control unit determines whether the differential bias voltage VS is greater than the preset differential bias threshold voltage VT, and whether the current switch record cur is less than n; if yes, then open the currently closed switch, close the switch of the next pair of bias resistors, and update cur = cur + 1; repeat step S2; if no, then execute step S4.
[0057] Step S4: Determine whether the differential bias voltage VS is less than or equal to the preset differential bias threshold voltage VT; if yes, the control unit controls the current closed switch to open and close the switch of the previous pair of bias resistors, and enters the normal communication process; if no, the bias resistor adjustment ends and enters the normal communication process.
[0058] For example: during initialization, the control unit controls the first pair of bias resistors, Ru1 and Rd1, to close switch S1 and record cur as 1, while switches S2 to S8 are opened.
[0059] The acquisition unit acquires the bias differential voltage VS; it determines whether VS is greater than VT and cur is less than 8. If yes, it opens S1 and closes S2; and sets cur = cur + 1 = 2, repeating the above steps; otherwise, it proceeds to the next step.
[0060] Determine if VS is less than or equal to VT; if yes, disconnect Scur, close Scur-1, and the bias resistor adjustment ends, then proceed to the normal communication process; otherwise, the bias resistor adjustment ends, and the normal communication process begins.
[0061] Some of the data in the above formula are calculated by removing dimensions and taking their numerical values. The formula is the closest to the real situation obtained by software simulation of a large amount of collected data. The preset parameters and preset thresholds in the formula are set by those skilled in the art according to the actual situation or obtained through simulation of a large amount of data.
[0062] The working principle of this invention: This invention adaptively adjusts the RS485 bus driver. The specific steps are as follows: Step S1: During initialization, the control unit controls the first pair of bias resistors Ru1 and Rd1 to close switch S1 and records cur as 1, while the remaining switches are open; wherein, the switch number corresponding to the bias resistor pair cur is used to record the switches; Step S2: When the host does not send a signal and the bus is idle, the acquisition unit acquires the differential bias voltage VS of the bus; Step S3: The control unit determines whether the differential bias voltage VS is greater than the preset differential bias threshold voltage VT, and whether the current switch record cur is less than n; if yes, the currently closed switch is opened, the switch of the next pair of bias resistors is closed, and cur = cur + 1 is updated; Step S2 is repeated; if no, Step S4 is executed; Step S4: Determine whether the differential bias voltage VS is less than or equal to the preset differential bias threshold voltage VT; if yes, the control unit controls the currently closed switch to open, the switch of the previous pair of bias resistors is closed, and the normal communication process is entered; if no, the bias resistor adjustment ends, and the normal communication process is entered.
[0063] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.
Claims
1. A system for adaptively adjusting RS485 bus driver, characterized in that, It includes: A host and several slave devices; The host includes a control unit, an adjustment unit, a RS485 interface unit, and a collection unit; the slave devices include a control unit and a RS485 interface unit; The control unit is used to adjust and control the bias resistors; The adjustment unit contains n pairs of bias resistors and n selection switches, and is used to adjust the resistance values of the n pairs of bias resistors; The collection unit is used to collect the bus differential bias voltage when the bus is idle; The host is located at the head of the total network, and a termination resistor is externally provided; the end of the last slave device can be selectively provided with a termination resistor according to the signal wavelength and the length of the transmission line; wherein, the last slave device refers to the slave device set at the end of the total network; The total number of the bias resistor pairs is n, n is an even number, and the value range of n is 4 ≤ n ≤ Mmax; each bias resistor pair x includes a pull-up resistor Rux and a pull-down resistor Rdx; the pull-up resistor Rux and the pull-down resistor Rdx can be selectively switched by selecting a dual-path switch Sx; and the n pairs of bias resistors are divided into two groups; wherein, Mmax is the maximum value of the total number of nodes M; The dividing the n pairs of bias resistors into two groups includes: The first to n / 2 bias resistors are suitable for cases where termination resistors are provided at the end of the bus; according to the formula... The resistance value R of the bias resistor is calculated. The n / 2+1 to nth bias resistors are applicable when no termination resistor is provided at the end of the bus; using the formula The resistance value R of the bias resistor is calculated. Among them, among them, , For bus A and B potentials, and VCC is the bias differential voltage, and VCC is the bias power supply. This refers to the input impedance of the transceiver. is the termination resistor; M is the total number of nodes, and its value is taken from the elements in the sequence {Mmax, Mmax / 2, ..., Mmax / 2^(x-1)}, where x ranges from 1 to n / 2.
2. The system for adaptively adjusting RS485 bus driver according to claim 1, characterized in that, Adjusting the resistance value of the corresponding bias resistor pair according to the calculated bias resistor resistance value; 3. The system for adaptively adjusting RS485 bus driver according to claim 1, characterized in that, The system includes one host and M - 1 slave devices, wherein, the maximum value Mmax of M is determined by the input impedance of the RS485 transceiver. The resistance values of the bias resistor pairs are Ru1 < Ru2 < … < Run; Rux = Rdx; [Ru1, Rd1] is the bias resistor pair with the minimum resistance value, and [Run, Rdn] is the bias resistor pair with the maximum resistance value; 4. A method for adaptively adjusting an RS485 bus driver, applied to a system for adaptively adjusting an RS485 bus driver as described in any one of claims 1-3, characterized in that, The bias differential threshold voltage VT is set to be greater than 200 mV. It includes: Step S1: During initialization, the control unit controls the switch S1 of the first pair of bias resistors Ru1 and Rd1 to close and records cur as 1, and the remaining switches are opened; wherein, cur is the switch number corresponding to the bias resistor pair and is used to record the switch; Step S2: When the host does not send a signal and the bus is idle, the collection unit collects the differential bias voltage VS of the bus; Step S3: The control unit judges whether the differential bias voltage VS is greater than the preset bias differential threshold voltage VT and whether the current switch record cur is less than n; if yes, the currently closed switch is opened, the switch of the next pair of bias resistors is closed, and cur = cur + 1 is updated; then step S2 is repeated; if not, step S4 is executed; [[ID=]]Step S4: Judges whether the differential bias voltage VS is less than or equal to the preset bias differential threshold voltage VT; if yes, the control unit controls to open the currently closed switch, close the switch of the previous pair of bias resistors, and transfer to the normal communication process; if not, the bias resistor adjustment ends and transfers to the normal communication process.
Citation Information
Patent Citations
Pull-up and pull-down resistance value adjusting circuit and electronic equipment
CN220087271U
Transmitter circuit
US20240120956A1