RS485 bus automatic transmit-receive control device and computing device
By designing the gate signal control module and the receiving timing control module in the FPGA chip, the gate signal output of the RS485 interface is automatically controlled, which solves the problem that the RS485 bus interface needs to manually operate the gate control signal when sending and receiving data, and realizes the Automatic data transmission and reception improves the efficiency and reliability of data transmission.
Patent Information
- Application Number
- CN202411475216.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-10-22
AI Technical Summary
The existing RS485 bus interface requires manual operation of gate control signals when sending and receiving data, and cannot directly send and receive data like other serial ports, resulting in complex operation and low efficiency.
An RS485 bus automatic transmission and reception control device is designed, including a gate signal control module and a reception timing control module. The gate signal output of the RS485 interface is automatically controlled through the FPGA chip to realize automatic switching of data transmission and reception.
It realizes automatic data transmission and reception of the RS485 interface, simplifies the operation process, and improves the efficiency and reliability of data transmission.
Smart Images

Figure CN119172197A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to an RS485 bus automatic transceiver control device and a computing device. Background Art
[0002] RS485 bus interface is a communication interface widely used in industry. RS485 bus interface generally includes UART controller and RS485 transceiver. UART controller outputs RS485_tx signal, RS485_rx signal and RS485_de signal, and transmits these three signals to RS485 transceiver. The de signal is a selection control signal used to control the transmission and reception of data.
[0003] However, when sending and receiving data, it is necessary to pull the selection signal high when sending data and pull the selection signal low when receiving the signal. That is, the selection signal needs to be operated before sending and receiving data, and it is impossible to send and receive data directly like other serial ports. Summary of the invention
[0004] The present application provides an RS485 bus automatic transceiver control device and computing equipment, which can be used to automatically control the output of the selection signal of the RS485 bus interface by designing a selection signal control module, a receiving timing control module and a selector in an FPGA chip, thereby realizing automatic switching of data transmission and reception.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions: In a first aspect, the present application provides an RS485 bus automatic transceiver control device, wherein a first end of the control device is connected to a UART controller, a second end of the control device is connected to an RS485 transceiver, and the control device comprises: a strobe signal control module; The strobe signal control module is used to cache preset UART transmission signals in a cache array, wherein the last UART transmission signal in the cache array is used as an output; judging whether a first preset condition is met, the first preset condition is that the UART transmission signal sent by the UART controller changes from a high level to a low level, if the first preset condition is met, entering the RS485 receiving closed state, resetting the first counter, setting the RS485 receiving enable signal to a low level, switching to the strobe enable state, and then setting the strobe signal in the RS485 transceiver to a high level to receive the data packet sent by the UART controller; judging whether a second preset condition is met, the second preset condition is that the control device has completed receiving the data packet sent by the UART controller, if the second preset condition is met, entering the closed timing state; judging whether a third preset condition is met, the third preset condition is that in the closed timing state, the first count of the first counter exceeds the first preset count threshold, if the third preset condition is met, setting the strobe signal in the RS485 transceiver to a low level, and entering the RS485 receiving enable state. In some possible implementations, the selection signal control module is also used to reset the second counter after entering the RS485 reception enabled state; determine whether a fourth preset condition is met, and the fourth preset condition is that in the RS485 reception enabled state, the second count of the second counter exceeds a second preset count threshold; if the fourth preset condition is met, return to the initial idle state. In some possible implementations, the selection signal control module is further used to determine whether a first preset condition is met after entering the closed timing state, and if the first preset condition is met, enter the RS485 receiving closed state.
[0006] In some possible implementations, the selection signal control module is further used to determine whether a first preset condition is met after entering the RS485 reception enabled state, and if the first preset condition is met, enter the RS485 reception disabled state.
[0007] In some possible implementations, the control device further includes a receiving timing control module; The receiving timing control module is used to determine whether the control device has completed receiving the data packet sent by the UART controller according to the baud rate and the UART sending signal sent by the UART controller, and if the control device has completed receiving the data packet sent by the UART controller, send a data reception completion signal to the selection signal control module; The selection signal control module is specifically used to determine that the second preset condition is met after receiving the data reception completion signal.
[0008] In some possible implementations, the control device further includes: a selector; The strobe signal control module is specifically used to send an RS485 receiving enable signal to the selector; The selector is used to determine that the UART receive signal sent to the UART controller is a high level if the RS485 receive enable signal is a low level, and to determine that the UART receive signal sent to the UART controller is an RS485 receive signal if the RS485 receive enable signal is a high level, and to send the UART receive signal to the UART controller.
[0009] In some possible implementations, the selection signal control module is further used to send a signal via RS485 to transmit the data received from the UART controller to the RS485 transceiver.
[0010] In some possible implementations, the strobe signal control module is specifically configured to determine that the RS485 strobe signal is at a low level, and send a low-level RS485 strobe signal to the RS485 transceiver; The RS485 transceiver is used to start the data receiving mode according to the low level RS485 selection signal.
[0011] In a second aspect, the present application provides a computing device, including a memory and a processor; One or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the computing device executes the method as described in any one of the first aspects.
[0012] It can be seen from the above technical solution that the present application has at least the following beneficial effects: The present application provides an RS485 bus automatic transceiver control device, which includes: a selection signal control module, which is used to cache preset UART transmission signals in a cache array, wherein the last UART transmission signal in the cache array is used as an output; judging whether a first preset condition is met, if the first preset condition is met, entering the RS485 reception closed state, resetting the first counter, setting the RS485 reception enable signal to a low level, switching to the selection enable state, and then setting the selection signal in the RS485 transceiver to a high level to receive a data packet sent by the UART controller; then judging whether a second preset condition is met, if the second preset condition is met, entering the closed timing state; judging whether a third preset condition is met, if the third preset condition is met, setting the selection signal in the RS485 transceiver to a low level, entering the RS485 reception enable state, resetting the second counter, and in the RS485 reception enable state, if the second count of the second counter exceeds the second preset count threshold, returning to the initial idle state. In the present application, a strobe signal control module is designed in the FPGA chip to automatically control the output of the strobe signal of the RS485 bus interface, thereby realizing automatic switching of data transmission and reception.
[0013] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in this application does not imply that all features and advantages can be realized in any single embodiment. On the contrary, it is understood that the description of features or beneficial effects means that specific technical features, technical solutions or beneficial effects are included in at least one embodiment. Therefore, the description of technical features, technical solutions or beneficial effects in this specification does not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions and beneficial effects described in the present embodiment can also be combined in any appropriate manner. Those skilled in the art will understand that the embodiment can be realized without one or more specific technical features, technical solutions or beneficial effects of a specific embodiment. In other embodiments, additional technical features and beneficial effects can also be identified in a specific embodiment that does not embody all embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 A schematic diagram of an application scenario provided in an embodiment of the present application; Figure 2 A schematic diagram of an RS485 bus automatic transceiver control device provided in an embodiment of the present application; Figure 3 A schematic diagram of state switching in a strobe signal control module provided in an embodiment of the present application; Figure 4 A schematic diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0015] The terms "first", "second", "third", etc. in the specification of this application and the accompanying drawings are used to distinguish different objects rather than to limit a specific order.
[0016] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0017] At present, when sending and receiving data, it is necessary to pull the de signal high when sending data and pull the de signal low when receiving signals. That is, the de signal needs to be operated before sending and receiving data, and it is impossible to send and receive data directly like other serial ports.
[0018] In view of this, an embodiment of the present application provides an RS485 bus automatic switching device for transmitting and receiving, and the device includes: the selection signal control module, which is used to cache preset UART transmission signals in a cache array, wherein the last UART transmission signal in the cache array is used as an output; judging whether the first preset condition is met, if the first preset condition is met, entering the RS485 reception closed state, resetting the first counter, setting the RS485 reception enable signal to a low level, switching to the selection enable state, and then setting the selection signal in the RS485 transceiver to a high level to receive the data packet sent by the UART controller; then judging whether the second preset condition is met, if the second preset condition is met, entering the closed timing state; judging whether the third preset condition is met, if the third preset condition is met, setting the selection signal in the RS485 transceiver to a low level, entering the RS485 reception enable state, resetting the second counter, and in the RS485 reception enable state, if the second count of the second counter exceeds the second preset count threshold, returning to the initial idle state. In the present application, a strobe signal control module is designed in the FPGA chip to automatically control the output of the strobe signal of the RS485 bus interface, thereby realizing automatic switching of data transmission and reception.
[0019] In order to make the technical solution of the present application clearer and easier to understand, the application scenarios of the technical solution of the present application are introduced below in conjunction with the accompanying drawings. Figure 1 As shown, the figure is a schematic diagram of an application scenario provided by an embodiment of the present application.
[0020] As can be seen in the figure, in the application scenario, the first end of the control device 103 is connected to the second end of the UART controller 102, the second end of the control device 103 is connected to the first end of the RS485 transceiver 104, the first end of the UART controller 102 is connected to the host 101, and the second end of the RS485 transceiver 104 is connected to the RS485 cable 105; the UART controller 102 sends a UART send signal to the control device 103, the control device 103 sends an RS485 send signal and an RS485 selection signal to the RS485 transceiver 104, the RS485 transceiver 104 sends an RS485 receive signal to the control device 103, and the control device 103 sends a UART receive signal to the UART controller 102. The control device 103 also needs an external input baud rate, which can be input by the host 101 or in other ways.
[0021] Since in the prior art, when the host 101 transmits data through the UART controller 102 and the RS485 transceiver 104, it is necessary for the upper level to write code to control the high and low levels of the selection signal for sending and receiving data. Therefore, the present application sets a control device 103 between the UART controller 102 and the RS485 transceiver 104 to replace the upper level writing code to control the high and low levels of the selection signal to ensure smooth data transmission.
[0022] In order to make the technical solution of the present application clearer and easier to understand, the following describes an RS485 bus automatic transceiver control device provided by the present application embodiment in combination with the above application scenario. Figure 2 As shown, this figure is a schematic diagram of an RS485 bus automatic transceiver control device provided in an embodiment of the present application.
[0023] In the embodiment of the present application, the first end of the control device 103 is connected to the UART controller 102, and the second end of the control device 103 is connected to the RS485 transceiver 104. The control device 102 includes: a selection signal control module 201, a receiving timing control module 202 and a selector 203.
[0024] Wherein, the main function of the strobe signal control module 201 is to control the RS485 strobe signal to output a high level when sending data, and to control the RS485 strobe signal to output a low level when not sending data. The internal functions of the strobe signal control module 201 include the buffer transmission of the UART transmission signal, the RS485 start transmission detection, and the RS485 strobe signal control state machine.
[0025] The main function of the receiving timing control module 202 is to receive the UART transmission data, process the received data according to the received baud rate and the standard UART protocol, and send a data reception completion signal to the selection signal control module 201 after a packet of data is received.
[0026] The main function of the selector 203 is to select the RS485 receive signal as the UART receive signal output when the RS485 receive enable signal sent by the select signal control module 201 is high; if the RS485 receive enable signal sent by the select signal control module 201 is low, the selector 203 selects the high level "1" output.
[0027] The following is a detailed description of the implementation of the control device 103: The UART controller 102 sends a UART transmission signal to the control device 103, and the UART transmission signal is first cached in the cache array of the strobe signal control module 201. The cache array can cache preset data, and the last data of the cache array is transmitted to the RS485 transceiver as the RS485 transmission signal of the control device 103. In the embodiment of the present application, the preset number is 10, and the last data of the cache array is the 10th data. The purpose of caching 10 data is to reserve sufficient time for the strobe signal control module 201 to receive the UART transmission signal to prevent data loss.
[0028] The selection signal control module 201 determines whether the first preset condition is met, and the first preset condition is that the UART transmission signal sent by the UART controller 102 changes from a high level to a low level. If the first preset condition is met, the RS485 receiving closed state is entered, and a high-level RS485 selection signal is sent to the RS485 transceiver 104, and then the selection enable state is entered. The RS485 transceiver 104 starts the data transmission mode according to the high-level RS485 selection signal.
[0029] The selection signal control module 201 then determines whether a second preset condition is met, where the second preset condition is that the control device 103 has completed receiving the data packet sent by the UART controller 102. If the second preset condition is met, the selection enable state enters the closed timing state and resets the first counter.
[0030] The selection signal control module 201 then determines whether a third preset condition is met. The third preset condition is that in the closed timing state, the first count of the first counter exceeds the first preset count threshold. If the third preset condition is met, the RS485 reception enable state is entered, and a low-level RS485 selection signal is sent to the RS485 transceiver 104.
[0031] In an embodiment of the present application, the first preset counting threshold is set to 12. After the control device 103 sends data to the RS485 transceiver 104, in order to ensure that the data packet can be completely sent to the RS485 transceiver 104, the first counter starts counting when the timing state is turned off. When the first count exceeds the first preset counting threshold, it indicates that the data packet has been sent. Therefore, the selection signal control module 201 enters the RS485 receive enable state and sends a low-level RS485 selection signal to the RS485 transceiver 104.
[0032] After entering the RS485 receiving enabled state, reset the second counter; determine whether a fourth preset condition is met, the fourth preset condition being that in the RS485 receiving enabled state, the second count of the second counter exceeds a second preset count threshold, and if the fourth preset condition is met, return to the initial idle state.
[0033] In the embodiment of the present application, the second preset count threshold is set to 100, because the RS485 transceiver 104 sends the received data packet to the RS485 cable 105. After the RS485 cable 105 receives the data packet, the selection signal control module 201 switches to the RS485 reception enable state. In this way, when the RS485 cable 105 has data to be sent to the UART controller 102, the RS485 transceiver 104 starts the receive data mode according to the low-level RS485 selection signal, and can send it through the control device 103. If the second count of the second counter exceeds the second preset count threshold, and the RS485 cable 105 has no data to be sent to the UART controller 102, the selection signal control module 201 returns to the initial idle state.
[0034] The strobe signal control module 201 is further used to determine whether a first preset condition is satisfied after entering the closed timing state, and if the first preset condition is satisfied, enter the RS485 receiving closed state.
[0035] The strobe signal control module 201 is further used to determine whether a first preset condition is satisfied after entering the RS485 receiving enabled state, and if the first preset condition is satisfied, enter the RS485 receiving disabled state.
[0036] The receiving timing control module 202 is used to determine whether the control device 103 has completed receiving the data packet sent by the UART controller 102 based on the baud rate and the UART sending signal sent by the UART controller 102. If the control device 103 has completed receiving the data packet sent by the UART controller 102, a data reception completion signal is sent to the selection signal control module 201.
[0037] The receiving timing control module 202 processes the received data according to the standard UART protocol to determine the end time of a packet of data.
[0038] After receiving the data reception completion signal, the strobe signal control module 201 determines whether a second preset condition is met. If the second preset condition is met, the strobe signal control module 201 sends an RS485 reception enable signal to the selector 203 .
[0039] The selector 203 is used for, if the RS485 reception enable signal is at a low level, the UART reception signal sent to the UART controller 102 is at a high level, and if the RS485 reception enable signal is at a high level, the UART reception signal sent to the UART controller 102 is the RS485 reception signal.
[0040] In the embodiment of the present application, a schematic diagram is provided of a control device 103 switching different states in the strobe signal control module 201 according to different signal instructions, such as Figure 3 As shown, this figure is a schematic diagram of state switching in a selection signal control module provided in an embodiment of the present application.
[0041] As can be seen in the figure, the initial idle state switches to the RS485 receive closed state after the first preset condition is met, and the RS485 receive closed state switches to the strobe enabled state. When the second preset condition is met, it switches from the strobe enabled state to the closed timing state. If the first preset condition is met, it switches from the closed timing state to the RS485 receive closed state for a new round of data transmission.
[0042] If the third preset condition is met, the timing off state will be switched to the RS485 receive enabled state. After the fourth preset condition is met, it will switch to the initial idle state. If the first preset condition is met in the RS485 receive enabled state, it will switch to the RS485 receive off state for a new round of data transmission.
[0043] Among them, the first preset condition is that the UART sending signal sent by the UART controller 102 changes from a high level to a low level; the second preset condition is that the control device 103 has completed receiving the data packet sent by the UART controller 102; the third preset condition is that in the timing off state, the first count of the first counter exceeds the first preset count threshold, and the fourth preset condition is that in the RS485 reception enable state, the second count of the second counter exceeds the second preset count threshold.
[0044] The present application also provides a computing device. Figure 4As shown, this figure is a schematic diagram of a computing device provided in an embodiment of the present application, and the computing device 400 includes a bus 401, a processor 402, a communication interface 403 and a memory 404. The processor 402, the memory 404 and the communication interface 403 communicate with each other through the bus 401.
[0045] The bus 401 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0046] The processor 402 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0047] The communication interface 403 is used for communicating with the outside.
[0048] The memory 404 may include a volatile memory, such as a random access memory (RAM). The memory 404 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0049] The embodiment of the present application further provides a computer program product, which includes one or more computer instructions. When the computer instructions are loaded and executed on a computing device, the process or function described in the embodiment of the present application is generated in whole or in part.
[0050] The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer or data center to another website, computer or data center via wired (e.g., coaxial cable, optical fiber) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0051] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.
[0052] The above description is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application.
Claims
1. An RS485 bus automatic transceiver control device, characterized in that: The first end of the control device is connected to the UART controller, the second end of the control device is connected to the RS485 transceiver, and the control device includes: a strobe signal control module; The strobe signal control module is used to cache preset UART transmission signals in a cache array, wherein the last UART transmission signal in the cache array is used as an output; judging whether a first preset condition is met, the first preset condition is that the UART transmission signal sent by the UART controller changes from a high level to a low level, if the first preset condition is met, entering the RS485 receiving closed state, resetting the first counter, setting the RS485 receiving enable signal to a low level, switching to the strobe enable state, and then setting the strobe signal in the RS485 transceiver to a high level to receive the data packet sent by the UART controller; judging whether a second preset condition is met, the second preset condition is that the control device has completed receiving the data packet sent by the UART controller, if the second preset condition is met, entering the closed timing state; judging whether a third preset condition is met, the third preset condition is that in the closed timing state, the first count of the first counter exceeds the first preset count threshold, if the third preset condition is met, setting the strobe signal in the RS485 transceiver to a low level, and entering the RS485 receiving enable state.
2. The control device according to claim 1, characterized in that: The selection signal control module is also used to reset the second counter after entering the RS485 reception enable state; determine whether a fourth preset condition is met, and the fourth preset condition is that in the RS485 reception enable state, the second count of the second counter exceeds the second preset count threshold value. If the fourth preset condition is met, return to the initial idle state.
3. The control device according to claim 1, characterized in that: The selection signal control module is also used to determine whether a first preset condition is met after entering the closed timing state, and if the first preset condition is met, enter the RS485 receiving closed state.
4. The control device according to claim 1, characterized in that: The strobe signal control module is also used to determine whether a first preset condition is met after entering the RS485 reception enabled state, and if the first preset condition is met, enter the RS485 reception disabled state.
5. The control device according to claim 1, characterized in that: The control device also includes a receiving timing control module; The receiving timing control module is used to determine whether the control device has completed receiving the data packet sent by the UART controller according to the baud rate and the UART sending signal sent by the UART controller, and if the control device has completed receiving the data packet sent by the UART controller, send a data reception completion signal to the selection signal control module; The selection signal control module is specifically used to determine that the second preset condition is met after receiving the data reception completion signal.
6. The control device according to claim 1, characterized in that: The control device further comprises: a selector; The strobe signal control module is specifically used to send an RS485 receiving enable signal to the selector; The selector is used to determine that the UART receive signal sent to the UART controller is a high level if the RS485 receive enable signal is a low level, and to determine that the UART receive signal sent to the UART controller is an RS485 receive signal if the RS485 receive enable signal is a high level, and to send the UART receive signal to the UART controller.
7. The control device according to claim 1, characterized in that: The selection signal control module is also used to send a signal via RS485 to transmit the data received from the UART controller to the RS485 transceiver.
8. The control device according to claim 1, characterized in that: The strobe signal control module is specifically used to determine that the RS485 strobe signal is a low level, and send a low level RS485 strobe signal to the RS485 transceiver; The RS485 transceiver is used to start the data receiving mode according to the low level RS485 selection signal.
9. The control device according to claim 1, characterized in that: The strobe signal control module is specifically used to determine that the RS485 strobe signal is a high level, and sends a high level RS485 strobe signal to the RS485 transceiver; The RS485 transceiver is used to start the data transmission mode according to the high-level RS485 selection signal.
10. A computing device, characterized in that The computing device comprises the control device according to any one of claims 1 to 9, and further comprises a host; the host is connected to the control device.
Citation Information
Patent Citations
Multifunctional wireless Mesh gateway device for multi-RF (Radio Frequency) mine and control system thereof
CN101873240A
Method for building RS232-RS485 switching circuit based on discrete device
CN117909276A
High-reliability RS485 bus interface control system, computing chip and industrial computer
CN119449518A
RS485 communication interface converter
CN1649349A
RS485 circuit capable of automatically switching transceiving states
CN210137320U
