Controller and reversing circuit of RS485 transceiver
By using a hardware circuit design with switching units, pull-up units, and pull-down units in the RS485 transceiver, the problem of erroneous frames caused by poor RC parameter consistency in the prior art is solved, and low-cost, low-latency data transmission reliability is achieved.
Patent Information
- Application Number
- CN202423155134.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2034-12-20
AI Technical Summary
When using NAND gates and delay circuits to implement RS485 transceiver commutation, the RC parameters of the circuit are inconsistent, resulting in erroneous frames during data transmission.
The hardware circuit design employs a switching unit, a first pull-up unit, and a pull-down unit. Automatic switching of the RS485 transceiver is achieved through transistors and resistors, avoiding the use of NAND gates and delay circuits, thus ensuring reliable transmission of differential signals.
It achieves low-cost, low-latency automatic switching of RS485 transceivers, ensuring reliable data transmission, saving controller resources, and avoiding the occurrence of error frames.
Smart Images

Figure CN223567623U_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of protection circuit, in particular to a controller and a reversing circuit of RS485 transceiver. BACKGROUND
[0002] As one of common buses, RS485 has the maximum feature of needing to control data transmission direction. If the timing of controlling data transmission direction is not correct, data transmission will be wrong.
[0003] In the process of realizing the present application, the inventor found that at least the following problems exist in the prior art. CN204089768U, an automatic reversing circuit, as shown in Figure 1 and Figure 2 , uses NAND gate and delay circuit to realize interface conversion from UART (Universal Asynchronous Receiver / Transmitter) to RS485 and automatic control of RS485 transceiver direction. Although this method does not need to separately occupy IO resources of the controller to realize the control of sending and receiving, saves the resources of the controller, improves the software compatibility and reduces the development difficulty of embedded programs under the operating system, but in the process of using NAND gate and delay circuit to realize, it is necessary to select resistance and capacitance to control the discharge speed, so that a low-level start bit is enough to send the entire byte, resulting in very poor consistency of RC parameters of the circuit, which in turn will cause error frames when transmitting data. CONTENT OF THE UTILITY MODEL
[0004] Based on the above-mentioned deficiencies of the prior art, the present application provides a reversing circuit of a controller and RS485 transceiver to solve the problem of poor consistency of RC parameters of the circuit when reversing is realized by using NAND gate and delay circuit in the prior art, which will cause error frames when transmitting data.
[0005] In order to achieve the above-mentioned purpose, the present application provides the following technical solutions:
[0006] The first aspect of the present application provides a reversing circuit of RS485 transceiver, comprising: a switching unit, a first pull-up unit and a pull-down unit.
[0007] The input end of the switching unit is connected to a sending data input interface to receive a sending data input signal; the output end of the switching unit is respectively connected to a receiver output enable interface and a driver output enable interface of the RS485 transceiver.
[0008] The first end of the first pull-up unit is connected to an input power supply, and the second end of the first pull-up unit is connected to a differential signal positive terminal interface of the RS485 transceiver.
[0009] The first end of the pull-down unit is grounded, and the second end of the pull-down unit is connected to the differential signal negative terminal interface of the RS485 transceiver.
[0010] The driver input interface of the RS485 transceiver is grounded.
[0011] Optionally, in the commutation circuit of the RS485 transceiver, a filter unit is further included, a first end of the filter unit is connected to the power supply interface of the RS485 transceiver, and a second end of the filter unit is grounded.
[0012] Optionally, in the commutation circuit of the RS485 transceiver, the filter unit includes N capacitors, N being a positive integer.
[0013] The capacitors are connected to each other, one end after the connection serving as the first end of the filter unit, and the other end serving as the second end of the filter unit.
[0014] Optionally, in the commutation circuit of the RS485 transceiver, a second pull-up unit is further included, a first end of the second pull-up unit is connected to the input power supply, and a second end of the second pull-up unit is connected to the receiver input interface of the RS485 transceiver.
[0015] Optionally, in the commutation circuit of the RS485 transceiver, the second pull-up unit includes M first resistors, M being a positive integer.
[0016] The first resistors are connected to each other, one end after the connection serving as the first end of the second pull-up unit, and the other end serving as the second end of the second pull-up unit.
[0017] Optionally, in the commutation circuit of the RS485 transceiver, the switch unit includes a second resistor, a third resistor, and a transistor.
[0018] One end of the second resistor serves as the input end of the switch unit.
[0019] The other end of the second resistor is connected to the base of the transistor.
[0020] The emitter of the transistor is grounded.
[0021] The collector of the transistor is connected to one end of the third resistor, and the connection point serves as the output end of the switch unit.
[0022] The other end of the third resistor is connected to the input power supply.
[0023] Optionally, in the commutation circuit of the RS485 transceiver, the transistor is an NPN transistor.
[0024] Optionally, in the commutation circuit of the RS485 transceiver, the first pull-up unit comprises K fourth resistors, K being a positive integer.
[0025] The fourth resistors are connected between each other, one end of the connection being the first end of the first pull-up unit and the other end being the second end of the first pull-up unit.
[0026] Optionally, in the commutation circuit of the RS485 transceiver, the pull-down unit comprises X fifth resistors, X being a positive integer.
[0027] The fifth resistors are connected between each other, one end of the connection being the first end of the pull-down unit and the other end being the second end of the pull-down unit.
[0028] The second aspect of the application provides a controller, comprising at least: an RS485 transceiver provided with the commutation circuit of the RS485 transceiver according to any one of the first aspect.
[0029] The application provides a commutation circuit of an RS485 transceiver, comprising: a switch unit, a first pull-up unit and a pull-down unit; an input end of the switch unit is connected to a transmission data input interface to receive a transmission data input signal, and output ends of the switch unit are respectively connected to a receiver output enable interface and a driver output enable interface of the RS485 transceiver; a first end of the first pull-up unit is connected to an input power supply, and a second end of the first pull-up unit is connected to a differential signal positive end interface of the RS485 transceiver; a first end of the pull-down unit is grounded, and a second end of the pull-down unit is connected to a differential signal negative end interface of the RS485 transceiver; and a driver input interface of the RS485 transceiver is grounded, so that the transmission and reception of the RS485 transceiver can be automatically switched through a hardware circuit, the cost is low, the switching delay is small, the reliable transmission of data can be ensured, the controller resources are saved, and the problem that the RC parameter consistency is very poor when the existing commutation is realized by using NAND gates and delay circuits, which can cause error frames during data transmission, is solved. BRIEF DESCRIPTION OF DRAWINGS
[0030] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only embodiments of the application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of the provided drawings.
[0031] Figure 1 and Figure 2 The circuit diagram of the existing automatic commutation circuit provided in the embodiments of the application;
[0032] Figure 3A structure diagram of a commutation circuit of an RS485 transceiver provided by the embodiment of the present application is provided.
[0033] Figure 4 A circuit diagram of a switch unit provided by the embodiment of the present application is provided.
[0034] Figure 5 A circuit diagram of a first pull-up unit provided by the embodiment of the present application is provided.
[0035] Figure 6 A circuit diagram of a pull-down unit provided by the embodiment of the present application is provided.
[0036] Figure 7 Another structure diagram of a commutation circuit of an RS485 transceiver provided by the embodiment of the present application is provided.
[0037] Figure 8 A circuit diagram of a filter unit provided by the embodiment of the present application is provided.
[0038] Figure 9 Another structure diagram of a commutation circuit of an RS485 transceiver provided by the embodiment of the present application is provided.
[0039] Figure 10 A circuit diagram of a second pull-up unit provided by the embodiment of the present application is provided.
[0040] Figure 11 A circuit diagram of a commutation circuit of an RS485 transceiver provided by the embodiment of the present application is provided. DETAILED DESCRIPTION
[0041] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0042] In this application, the terms such as first and second are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between such entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or device. Without more limitations, the element defined by the statement "includes a" does not exclude the presence of additional identical elements in the process, method, article or device including the element.
[0043] First of all, it is pointed out that RS485 half-duplex asynchronous serial communication bus is a standard that defines the electrical characteristics of the driver and receiver in a balanced digital multipoint system. RS485 adopts differential signal transmission mode, that is, opposite signals are transmitted on two communication lines, and the actual transmitted data is determined by comparing the signal difference between the two lines.
[0044] The working principle of RS485 transceiver is as follows:
[0045] When transmitting data, the driver converts the single-chip microcomputer's transmission data input signal UART_TXD into a differential signal output to two communication lines. The differential signal is composed of two lines, which are A line and B line respectively. The A line is connected to the differential signal positive terminal interface of the RS485 transceiver, and the B line is connected to the differential signal negative terminal interface of the RS485 transceiver. The signal on the A line is opposite in phase to the signal on the B line.
[0046] When receiving data, the receiver converts the differential signal into a signal that can be processed by the receiving device, such as a TTL (Transistor-Transistor Logic) level signal, by comparing the signal difference between the A line and the B line.
[0047] Due to the use of differential signal transmission, the RS485 transceiver has strong anti-interference ability and can reliably transmit data over a long distance.
[0048] Based on the above, the embodiment of the present application provides a controller and a commutation circuit of an RS485 transceiver to solve the problem that the RC parameter consistency of the commutation circuit realized by using NAND gate and delay circuit is very poor, which can cause error frames when transmitting data.
[0049] Please refer to Figure 3 The commutation circuit of the RS485 transceiver mainly includes a switching unit 101, a first pull-up unit 102 and a pull-down unit 103.
[0050] The input end of the switch unit 101 is connected with a sending data input interface (UART_TXD in the figure) to receive a sending data input signal; the output end of the switch unit 101 is respectively connected with a receiver output enable interface (RE# pin in the figure) and a driver output enable interface (DE pin in the figure) of the RS485 transceiver; the first end of the first pull-up unit 102 is connected with an input power supply, and the second end of the first pull-up unit 102 is connected with a differential signal positive end interface (A pin in the figure) of the RS485 transceiver; the first end of the pull-down unit 103 is grounded, and the second end of the pull-down unit is connected with a differential signal negative end interface (B pin in the figure) of the RS485 transceiver; the driver input interface (D1 pin in the figure) of the RS485 transceiver is grounded.
[0051] In actual application, the RS485 transceiver mainly includes an RS485 chip, that is, the chip U1 in Figures 3 to 11 .
[0052] In some embodiments, as shown in Figure 4 , the switch unit can include a second resistor R3, a third resistor R4 and a triode T1.
[0053] Among them, one end of the second resistor R3 serves as the input end of the switch unit 101; the other end of the second resistor R3 is connected with the base of the triode T1; the emitter of the triode T1 is grounded; the collector of the triode T1 is connected with one end of the third resistor R4, and the connection point serves as the output end of the switch unit; the other end of the third resistor R4 is connected with an input power supply (VCC in the figure).
[0054] In actual application, the triode T1 can be an NPN triode; of course, it is not limited to this, and can be determined according to application environment and user demand, which are all within the protection scope of the present application.
[0055] It should be noted that the second resistor R3 in the switch unit 101 is a current-limiting resistor, which can play a current-limiting role, and the third resistor R4 is a pull-up resistor, which can pull up the collector voltage of the triode T1 to the input power supply voltage.
[0056] It also needs to be explained that since the base of the triode T1 is connected to the data sending input interface of the single-chip microcomputer through the second resistor R3, that is, the UART_TXD pin of the single-chip microcomputer, the data sending input signal is received; when the data sending input signal received by the base of the triode T1 is high, the triode T1 is turned on, the receiver output enable interface and the driver output enable interface of the RS485 transceiver are grounded, and the RS485 transceiver enters the receiving mode; when the data sending input signal received by the base of the triode T1 is low, the triode T1 is cut off, the receiver output enable interface and the driver output enable interface of the RS485 transceiver are connected to high, and the RS485 transceiver enters the sending mode.
[0057] In some embodiments, as shown in FIG. 1, the first pull-up unit 102 can include K fourth resistors R7, K being a positive integer. The fourth resistors R7 are connected between each other, one end of the connection being the first end of the first pull-up unit 102, and the other end being the second end of the first pull-up unit 102. Figure 5 For example, only one fourth resistor R7 is taken as an example. Figure 3
[0058] In some embodiments, as shown in FIG. 1, the first pull-up unit 102 can include K fourth resistors R7, K being a positive integer. The fourth resistors R7 are connected between each other, one end of the connection being the first end of the first pull-up unit 102, and the other end being the second end of the first pull-up unit 102.
[0059] It needs to be explained that by setting the fourth resistor R7, the voltage of the positive end interface of the differential signal of the RS485 transceiver can be pulled up to the input power voltage.
[0060] In some embodiments, as shown in FIG. 1, the first pull-up unit 102 can include K fourth resistors R7, K being a positive integer. The fourth resistors R7 are connected between each other, one end of the connection being the first end of the first pull-up unit 102, and the other end being the second end of the first pull-up unit 102. Figure 6 For example, only one fourth resistor R7 is taken as an example. Figure 4
[0061] In some embodiments, as shown in FIG. 1, the first pull-up unit 102 can include K fourth resistors R7, K being a positive integer. The fourth resistors R7 are connected between each other, one end of the connection being the first end of the first pull-up unit 102, and the other end being the second end of the first pull-up unit 102.
[0062] It needs to be explained that by setting the fourth resistor R7, the voltage of the positive end interface of the differential signal of the RS485 transceiver can be pulled up to the input power voltage.
[0063] It should be noted that when the RS485 transceiver enters the receiving mode, the differential signal positive terminal interface of the RS485 transceiver and the differential signal negative terminal interface of the RS485 transceiver enter the high resistance state, and under the action of the fourth resistor R7 and the fifth resistor R6, the differential logic between the differential signal positive terminal interface of the RS485 transceiver and the differential signal negative terminal interface of the RS485 transceiver is 1. When the RS485 transceiver enters the sending mode, since the driver input interface of the RS485 transceiver is grounded, the differential logic between the differential signal positive terminal interface of the RS485 transceiver and the differential signal negative terminal interface of the RS485 transceiver is 0, so that automatic switching of the RS485 transceiver in different states can be realized.
[0064] In some embodiments, as shown in Figure 7 The commutation circuit of the RS485 transceiver can further include a filter unit 104, a first end of the filter unit 104 being connected to a power supply interface (VCC pin in the figure) of the RS485 transceiver, and a second end of the filter unit 102 being grounded.
[0065] By setting the filter unit 104 at the power supply interface of the RS485 transceiver, the power supply interface of the RS485 transceiver can be filtered to reduce interference of interference signals on the power supply interface of the RS485 transceiver, thereby improving the working stability of the RS485 transceiver.
[0066] In actual application, as shown in Figure 8 The filter unit 104 can include N capacitors C1, N being a positive integer; the capacitors C1 are connected between each other, one end after connection being the first end of the filter unit 104, and the other end being the second end of the filter unit 104.
[0067] The connection mode between the capacitors C1 can be one of series connection, parallel connection or series-parallel connection. In actual application, the specific capacitance of the capacitor C1 can be set in combination with the interface requirements of the RS485 transceiver, which is not specifically limited in the present application and is within the protection scope of the present application.
[0068] In some embodiments, as shown in Figure 9 The commutation circuit of the RS485 transceiver further includes a second pull-up unit 105, a first end of the second pull-up unit 105 being connected to an input power supply, and a second end of the second pull-up unit 105 being connected to a receiver input interface (RO pin in the figure) of the RS485 transceiver.
[0069] In actual application, the receiver input interface of the RS485 transceiver is connected to the input power supply through the second pull-up unit 105, so that the receiver input interface of the RS485 transceiver can be pulled high at all times.
[0070] As Figure 10As shown, the second pull-up unit 105 can include: M first resistors R5, M being a positive integer; each first resistor R5 is connected between, one end after connection as the first end of the second pull-up unit 105, the other end as the second end of the second pull-up unit 105.
[0071] Wherein, the connection mode between each first resistor R5 can be one of series, parallel or series-parallel. In practice, the specific resistance value can be set in combination with the interface requirements of the RS485 transceiver, which is not limited in the present application, and is within the protection scope of the present application.
[0072] For example, the RS485 transceiver shown in the commutation circuit is used in the sending data process. That is, the data is represented on the UART_TXD pin of the single-chip microcomputer. Figure 11
[0073] Suppose the data to be sent is 0x12, expressed in binary as 0x00010010, the UART_TXD pin will be represented by high and low levels in turn 1 and 0. When UART_TXD sends 0, transistor T1 is not conductive, the driver output enable interface is high, and the RS485 transceiver enters the sending mode. The RS485 transceiver will react the level on the driver input interface to the RS485 transceiver differential signal positive interface and RS485 transceiver differential signal negative interface output. Because the driver input interface of the RS485 transceiver has been grounded, the RS485 transceiver differential signal positive interface and RS485 transceiver differential signal negative interface will transmit 0. Therefore, when the UART_TXD pin sends 0, the RS485 transceiver differential signal positive interface and RS485 transceiver differential signal negative interface send 0.
[0074] When UART_TXD sends 1, transistor T1 is conductive, the receiver input enable interface is low, and the RS485 transceiver enters the receiving mode. The RS485 transceiver differential signal positive interface and RS485 transceiver differential signal negative interface enter the high resistance state. Because the fourth resistor R7 pulls up the RS485 transceiver differential signal positive interface, and the fifth resistor R6 pulls down the RS485 transceiver differential signal negative interface, the RS485 transceiver differential signal positive interface and RS485 transceiver differential signal negative interface transmit 1. Therefore, when the UART_TXD pin sends 1, the RS485 transceiver differential signal positive interface and RS485 transceiver differential signal negative interface send 1.
[0075] Similarly, the RS485 transceiver shown in the commutation circuit is used in the sending data process. That is, the data is represented on the UART_TXD pin of the single-chip microcomputer. Figure 11 The RS485 transceiver shown in the switching circuit is used as an example. The single-chip microcomputer UART_RXD pin is used in the receiving data process, that is, the data is displayed on the UART_RXD pin. In the receiving data process, the UART_RXD pin is always kept at a high level. When the UART_TXD pin is at a high level, the RS485 transceiver receiver output enable interface is at a low level, becomes a receiving state, and the RS485 transceiver receiver input interface receives the data transmitted by the RS485 transceiver differential signal positive interface and the RS485 transceiver differential signal negative interface.
[0076] Based on the above principle, the RS485 transceiver switching circuit provided in the embodiment includes a switching unit 101, a first pull-up unit 102, and a pull-down unit 103. The input end of the switching unit 101 is connected to the sending data input interface to receive the sending data input signal. The output end of the switching unit 101 is connected to the RS485 transceiver receiver output enable interface and the driver output enable interface, respectively. The first end of the first pull-up unit 102 is connected to the input power supply. The second end of the first pull-up unit 102 is connected to the RS485 transceiver differential signal positive interface. The first end of the pull-down unit 103 is grounded. The second end of the pull-down unit 103 is connected to the RS485 transceiver differential signal negative interface. The RS485 transceiver driver input interface is grounded. The RS485 transceiver receiving and sending automatic switching can be realized through the hardware circuit. The cost is low, the switching delay is small, the reliable data transmission can be ensured, the controller resources are saved, and the problem that the RC parameter consistency is very poor when the switching is realized by using the NAND gate and the delay circuit is solved.
[0077] It is worth noting that the RS485 transceiver switching circuit provided in the present application uses a triode T1, a pull-up resistor, and a pull-down resistor to realize the receiving and sending switching. The NAND gate and the delay circuit (RC circuit) are not used. The problem of poor RC parameter consistency does not exist. The reliability of the output transmission can be ensured.
[0078] On the basis of the RS485 transceiver switching circuit provided in the above embodiment, optionally, another embodiment of the present application further provides a controller. The controller at least includes an RS485 transceiver. The RS485 transceiver is provided with the RS485 transceiver switching circuit as described in any of the above embodiments.
[0079] In actual application, after the RS485 transceiver switching circuit is set in the RS485 transceiver in the controller, the automatic switching of the receiving and sending data can be realized. The IO resources of the controller are avoided.
[0080] It should be noted that the controller can be a controller in a vehicle-mounted control system; of course, it is not limited to this, and any controller that needs to use the transceiving function is within the protection scope of the present application.
[0081] It should be noted that the related description of the reversing circuit of the RS485 transceiver can be referred to the above-mentioned corresponding embodiments, which will not be repeated here. And the related description of the controller can also be referred to the prior art, which will also not be repeated here.
[0082] The above description of disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A commutation circuit for an RS485 transceiver, characterized in that, include: Switch unit, first pull-up unit, and pull-down unit; The input terminal of the switching unit is connected to the transmit data input interface to receive transmit data input signals; the output terminal of the switching unit is connected to the receiver output enable interface and the driver output enable interface of the RS485 transceiver, respectively. The first end of the first pull-up unit is connected to the input power supply, and the second end of the first pull-up unit is connected to the differential signal positive terminal interface of the RS485 transceiver. The first end of the pull-down unit is grounded, and the second end of the pull-down unit is connected to the differential signal negative terminal interface of the RS485 transceiver. The driver input interface of the RS485 transceiver is grounded.
2. The commutation circuit of the RS485 transceiver according to claim 1, characterized in that, Also includes: A filtering unit, wherein the first end of the filtering unit is connected to the power interface of the RS485 transceiver, and the second end of the filtering unit is grounded.
3. The commutation circuit of the RS485 transceiver according to claim 2, characterized in that, The filtering unit includes N capacitors, where N is a positive integer; The capacitors are connected to each other, with one end of the connection serving as the first end of the filter unit and the other end serving as the second end of the filter unit.
4. The commutation circuit of the RS485 transceiver according to claim 1, characterized in that, Also includes: The second pull-up unit has its first end connected to the input power supply and its second end connected to the receiver input interface of the RS485 transceiver.
5. The commutation circuit of the RS485 transceiver according to claim 4, characterized in that, The second pull-up unit includes: M first resistors, where M is a positive integer; Each of the first resistors is connected, with one end of the connection serving as the first end of the second pull-up unit and the other end serving as the second end of the second pull-up unit.
6. The commutation circuit of the RS485 transceiver according to claim 1, characterized in that, The switching unit includes: a second resistor, a third resistor, and a transistor; One end of the second resistor serves as the input terminal of the switching unit; The other end of the second resistor is connected to the base of the transistor; The emitter of the transistor is grounded; The collector of the transistor is connected to one end of the third resistor, and the connection point serves as the output terminal of the switching unit. The other end of the third resistor is connected to the input power supply.
7. The commutation circuit of the RS485 transceiver according to claim 6, characterized in that, The transistor is an NPN transistor.
8. The commutation circuit of the RS485 transceiver according to claim 1, characterized in that, The first pull-up unit includes: K fourth resistors, where K is a positive integer; Each of the fourth resistors is connected, with one end of the connection serving as the first end of the first pull-up unit and the other end serving as the second end of the first pull-up unit.
9. The commutation circuit of the RS485 transceiver according to claim 1, characterized in that, The pull-down unit includes: X fifth resistors, where X is a positive integer; Each of the fifth resistors is connected, with one end of the connection serving as the first end of the pull-down unit and the other end serving as the second end of the pull-down unit.
10. A controller, characterized in that, At least including: An RS485 transceiver, wherein the RS485 transceiver is provided with a commutation circuit as described in any one of claims 1-9.