RS485 automatic test circuit for industrial computer and method thereof
By designing the RS485 automatic testing circuit for industrial computers, the MCU module and the automated test module are used to realize automatic mode switching and data consistency judgment of the RS485 transceiver module, the problem of complex operation and inefficiency in the traditional RS485 testing method is solved, and an efficient and automated testing process is realized.
Patent Information
- Application Number
- CN202411665097.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-11
AI Technical Summary
The traditional RS485 test method requires multiple PCs to manually select and configure the serial port mode, which is complex and inefficient, making it difficult to meet the needs of modern industrial production lines for efficient and automated testing.
An RS485 automatic testing circuit for industrial computers is designed, including an MCU module, a transceiver control module, an RS485 transceiver module and an automated test module. The MCU module automatically generates and sends transceiver control instructions to realize automatic mode switching of the RS485 transceiver module, and the data transmission status is monitored in real time through the automated test module to automatically judge the consistency between the received data and the sent data.
It greatly improves the degree of automation and efficiency of tests, reduces the risk of manual intervention and configuration errors, and realizes rapid fully automated testing, meets the needs of industrial production lines for efficient and accurate testing, while improving the reliability and consistency of the system.
Smart Images

Figure CN119597555A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of RS485 automatic testing for industrial computers, and in particular to a circuit and method for automatically testing RS485 for industrial computers. Background Art
[0002] At present, in the field of industrial computers, RS485 testing usually requires multiple PCs to support RS485 mode serial ports for transmission testing, and each time the test is performed, the RS485 mode of the corresponding serial port must be manually selected and configured. This traditional testing method is not only cumbersome and requires manual intervention, but also prone to configuration errors during operation, and greatly increases the complexity and workload of the test, resulting in excessive time consumption and serious impact on test efficiency. Especially in the case of large-scale batch testing, it cannot meet the needs of modern industrial production lines for efficient and automated testing. Summary of the invention
[0003] In order to solve the problem of manual selection of serial port mode, complex operation and low efficiency in the traditional RS485 test process that relies on multiple PCs, the present application provides an RS485 automatic test circuit and method for industrial computers.
[0004] The invention discloses an RS485 automatic test circuit for an industrial computer. The RS485 automatic test circuit for an industrial computer comprises an MCU module, a transceiver control module, an RS485 transceiver module and an automatic test module. The data transmission end of the MCU module is connected to the data transmission end of the RS485 transceiver module. The RS485 data transmission end is connected to a test terminal via an RS485 bus. The enable signal output end of the MCU module is connected to the enable signal input end of the transceiver control module. The mode switching signal output end of the transceiver control module is connected to the mode switching signal input port of the RS485 transceiver module so that the RS485 transceiver module switches to a receiving state or a sending state. The data monitoring end of the automatic test module is connected to the RS485 bus so as to analyze whether the received data is consistent with the sent data.
[0005] By adopting the above technical solution, by introducing MCU module, transceiver control module, RS485 transceiver module and automated test module, the traditional method of manually configuring serial ports and transmitting tests on multiple PCs is replaced. In the traditional method, the test requires multiple PCs to cooperate with each other, and each test requires manual selection and configuration of RS485 mode, which is not only complicated to operate, but also prone to configuration errors and low test efficiency. In this technical solution, the MCU module can control the transceiver control module to realize the automatic mode switching of the RS485 transceiver module by automatically generating and sending transceiver control instructions, so that it can automatically switch between the receiving and sending states without manual intervention. In addition, the automated test module is directly connected to the RS485 bus, monitors and analyzes the transmission status of the data in real time, and automatically determines whether the received data is consistent with the sent data. This solution not only saves the manual operation steps of multiple PCs in the traditional method, but also significantly reduces the risk of configuration errors, reduces manual workload, avoids cumbersome configuration operations, and greatly improves the automation and efficiency of the test. Especially in large-scale batch testing scenarios, this solution can achieve fast fully automated testing, significantly reduce testing time, meet the needs of industrial production lines for efficient and accurate testing, and improve the reliability and consistency of the system.
[0006] Preferably, the transceiver control module includes a MOS tube Q1 and a resistor R20, the first end of the resistor R20 is connected to the power supply, the second end of the resistor R20 is connected to the first conduction end of the MOS tube Q1, the second conduction end of the MOS tube Q1 is grounded, the controlled end of the MOS tube Q1 is connected to the enable signal output end of the MCU module, and the common node between the second end of the resistor R20 and the MOS tube Q1 is connected to the mode switching signal input port of the RS485 transceiver module.
[0007] By adopting the above technical solution, the combination of MOS tube Q1 and resistor R20 can ensure that the RS485 transceiver module can quickly switch between different modes, ensure the efficient execution of the transceiver control of the communication interface, thereby improving the working stability and communication efficiency of the test circuit and reducing the necessity of human intervention.
[0008] Preferably, the RS485 transceiver module includes an RS485 transceiver chip U2, pin 1 of the RS485 transceiver chip U2 serves as a first data sending end connected to the data transmission end of the MCU module, pin 4 of the RS485 transceiver chip U2 serves as a first data receiving end connected to the data transmission end of the MCU module, pin 6 of the RS485 transceiver chip U2 serves as a second data receiving end connected to the RS485 bus, and pin 7 of the RS485 transceiver chip U2 serves as a second data sending end connected to the RS485 bus.
[0009] By adopting the above technical solution, the connection between the pins of the RS485 transceiver chip U2 and the data transmission end of the MCU module and the RS485 bus can be made more accurate and reasonable, ensuring that data sending and receiving are executed synchronously, thereby improving the reliability of data transmission and avoiding communication errors caused by improper connection.
[0010] Preferably, the RS485 transceiver chip U2 is an SP485 chip.
[0011] By adopting the above technical solution, the SP485 chip can be used as the RS485 transceiver module, so that the entire RS485 communication system has high compatibility, low power consumption and stronger anti-interference ability, thereby improving the overall reliability and stability of automated testing.
[0012] Preferably, the RS485 bus includes a first differential signal line and a second differential signal line, the first differential signal line is provided with a resistor R1, the resistor R1 is connected to pin 7 of the RS485 transceiver chip U2, the second differential signal line is provided with a resistor R8, the resistor R8 is connected to pin 6 of the RS485 transceiver chip U2, and the first differential signal line and the second differential signal line are connected via a resistor R7.
[0013] By adopting the above technical solution, the connection between the differential signal line and the resistor on the RS485 bus can be utilized to effectively reduce signal reflection and interference, ensure the integrity and stability of data transmission, thereby improving the anti-interference ability of communication and the accuracy of data transmission, and ensuring the test accuracy in industrial environments.
[0014] Preferably, the RS485 transceiver module is connected to an electrostatic protection module, and the electrostatic protection module includes a TVS diode D1, a first end of the TVS diode D1 is connected to pin 7 of the RS485 transceiver chip U2, a second end of the TVS diode D1 is connected to pin 6 of the RS485 transceiver chip U2, and a third end of the TVS diode D1 is grounded.
[0015] By adopting the above technical solution, the RS485 transceiver module can be protected from electrostatic discharge through the TVS diode D1, effectively preventing the communication chip from being damaged by electrostatic discharge, thereby improving the anti-static ability of the test circuit in a complex industrial environment, extending the service life of the system and ensuring the continuity and stability of communication.
[0016] An automatic test method for RS485 of an industrial computer is applied to an automatic test circuit for RS485 of an industrial computer. The automatic test method for RS485 of an industrial computer includes:
[0017] Based on the communication requirements, initialize the communication interface of the MCU module to configure the corresponding serial port communication parameters;
[0018] Based on the serial communication parameters configured by the communication interface, send the corresponding transceiver control instruction to the transceiver control module so that the RS485 transceiver module switches to the corresponding transceiver state;
[0019] When it is detected that the RS485 transceiver module switches to the sending state, a synchronization condition matching the automatic test module is set to perform a data transmission operation;
[0020] Wait to receive the first communication data sent by the test terminal. If it has been received, control the automated test module to determine whether the first communication data is consistent with the second communication data sent by the MCU module. If they are consistent, record the communication test passing and generate the corresponding test results. If they are inconsistent, generate an error report and record the test failure information.
[0021] By adopting the above technical solution, unlike the traditional manual operation, the method first automatically initializes the communication interface of the MCU module based on the communication requirements, and configures the serial port communication parameters that meet the test requirements. Subsequently, the system generates the transceiver control instructions based on these parameters, and automatically controls the RS485 transceiver module to switch to the appropriate transceiver state, avoiding the steps of manual switching required in traditional tests. When the RS485 transceiver module switches to the sending state, the system automatically sets the synchronization conditions that match the automated test module to ensure the timing and parameter consistency of the data transmission, thereby ensuring the accuracy and reliability of the data transmission. At the same time, the system automatically waits for the first communication data sent by the test terminal, and monitors the consistency of the data with the second communication data sent by the MCU module in real time through the automated test module. Once the data is confirmed to be consistent, the system automatically records the passing result of the communication test; if inconsistency is detected, the system generates an error report and records the test failure information. Through these automated operations, the technical solution greatly reduces manual intervention, realizes the automation and efficiency of the entire test process, greatly improves the efficiency and accuracy of the RS485 test, is particularly suitable for large-scale industrial test scenarios, and meets the high requirements of modern industry for automated testing.
[0022] Preferably, the industrial computer RS485 automatic testing method further comprises the following steps:
[0023] Determining whether the communication process is terminated according to the test result or the test failure information;
[0024] If the communication process has ended, the MCU module is controlled to perform a cleanup operation, which includes sending a buffer cleanup instruction to release the occupied communication buffer space.
[0025] By adopting the above technical solution, it is possible to promptly determine whether the communication process has ended based on the test results or failure information, and automatically perform cache cleanup operations to ensure the timely release of the communication cache, thereby improving the transmission efficiency during the next communication, avoiding communication errors caused by cache overflow, and improving the operating stability of the system.
[0026] Preferably, the step of setting a synchronization condition matching the automated test module and performing a data transmission operation includes:
[0027] Generate corresponding synchronization configuration instructions according to the serial port communication parameters, wherein the synchronization configuration instructions are used to match the communication parameters of the MCU module with the communication parameters of the automated test module;
[0028] If the communication parameters of the MCU module match the communication parameters of the automated test module successfully, the automated test module is controlled to send a synchronization verification request signal to verify the timing synchronization of the communicating parties in data transmission;
[0029] If the MCU module receives a synchronization confirmation signal from the automated test module, it starts to execute the data transmission operation.
[0030] By adopting the above technical solution, it is possible to ensure that the communication parameters of the MCU module and the automated test module match by generating synchronization configuration instructions, perform synchronization verification while ensuring that the parameters are consistent, and then ensure the timing synchronization of data transmission, thereby improving the stability and reliability of the data transmission process and avoiding timing errors during the communication process.
[0031] Preferably, the serial port communication code of the MCU module is designed and written by an IAR development tool to implement the configuration of serial port communication parameters and the control of data sending and receiving operations.
[0032] By adopting the above technical solution, the serial communication code of the MCU module can be designed and written using the IAR development tool to ensure the accurate configuration of the serial communication parameters and the automatic control of data transmission and reception operations, thereby improving the development efficiency and code stability, and improving the reliability of the entire test circuit.
[0033] In summary, the present application includes at least one of the following beneficial technical effects:
[0034] 1. By introducing the MCU module, the transceiver control module, the RS485 transceiver module and the automated test module, the traditional method of manually configuring the serial port and transmitting the test on multiple PCs is replaced. In the traditional method, the test requires multiple PCs to cooperate with each other, and the RS485 mode needs to be manually selected and configured for each test. Not only is the operation complicated, but also configuration errors are prone to occur, and the test efficiency is low. In this technical solution, the MCU module can control the transceiver control module to realize the automatic mode switching of the RS485 transceiver module by automatically generating and sending transceiver control instructions, so that it can automatically switch between the receiving and sending states without manual intervention. In addition, the automated test module is directly connected to the RS485 bus, monitors and analyzes the transmission status of the data in real time, and automatically determines whether the received data is consistent with the sent data. This solution not only saves the manual operation steps of multiple PCs in the traditional method, but also significantly reduces the risk of configuration errors, reduces the manual workload, avoids cumbersome configuration operations, and greatly improves the automation and efficiency of the test. Especially in large-scale batch testing scenarios, this solution can achieve fast fully automated testing, significantly reduce testing time, meet the needs of industrial production lines for efficient and accurate testing, and improve the reliability and consistency of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a flowchart of an RS485 automatic test circuit for an industrial computer in one embodiment of the present application.
[0036] Figure 2 This is a partial circuit diagram between an RS485 transceiver module and an RS485 bus for an RS485 automatic test circuit of an industrial computer in one embodiment of the present application. ;
[0037] Figure 3 It is a partial circuit diagram of a transceiver control module for an industrial computer RS485 automatic test circuit in one embodiment of the present application;
[0038] Figure 4 It is a partial circuit diagram of an electrostatic protection module for an RS485 automatic test circuit of an industrial computer in one embodiment of the present application;
[0039] Figure 5 This is a flow chart of an automatic RS485 test method for industrial computers in one embodiment of the present application;
[0040] Figure 6 This is another implementation flow chart of an automatic RS485 test method for industrial computers in one embodiment of the present application;
[0041] Figure 7This is a flowchart for implementing step S40 in an RS485 automatic testing method for an industrial computer in an embodiment of the present application;
[0042] Figure 8 This is a flowchart of the RS485 automatic testing method for industrial computers that belongs to the prior art;
[0043] Fig. 9 It is a flowchart of an automatic testing method for RS485 of an industrial computer in one embodiment of the present application;
[0044] Fig.10 This is a specific pin operation principle block diagram of an industrial computer RS485 automatic testing method in one embodiment of the present application. DETAILED DESCRIPTION
[0045] The present application is further described in detail below in conjunction with the accompanying drawings.
[0046] In one embodiment, if Figure 1 As shown, the present application discloses an RS485 automatic test circuit for industrial computers, which specifically includes the following steps:
[0047] The invention discloses an RS485 automatic test circuit for an industrial computer. The RS485 automatic test circuit for an industrial computer comprises an MCU module, a transceiver control module, an RS485 transceiver module and an automatic test module. The data transmission end of the MCU module is connected to the data transmission end of the RS485 transceiver module. The RS485 data transmission end is connected to a test terminal via an RS485 bus. The enable signal output end of the MCU module is connected to the enable signal input end of the transceiver control module. The mode switching signal output end of the transceiver control module is connected to the mode switching signal input port of the RS485 transceiver module so that the RS485 transceiver module switches to a receiving state or a sending state. The data monitoring end of the automatic test module is connected to the RS485 bus so as to analyze whether the received data is consistent with the sent data.
[0048] In the present embodiment, the port connection and control logic between the MCU module, the transceiver control module, the RS485 transceiver module and the automated test module form a complete automated test closed loop. First, the data transmission end of the MCU module is directly connected to the data transmission end of the RS485 transceiver module, ensuring that the MCU can perform data transmission and reception operations through the RS485 module. The data transmission end of the RS485 transceiver module is connected to the test terminal through the RS485 bus, thereby realizing the transmission of data between the MCU module and the test terminal. At the same time, the enable signal output end of the MCU module is connected to the enable signal input end of the transceiver control module, which is responsible for providing signal control and ensuring that the transceiver control module can receive the control signal sent by the MCU. The mode switching signal output end of the transceiver control module is connected to the mode switching signal input end of the RS485 transceiver module, which is used to automatically switch the state of the RS485 transceiver module according to the instruction sent by the MCU module, so that it can automatically switch between the receiving mode and the sending mode, avoiding the complexity of manual operation and possible errors. The automated test module is directly connected to the RS485 bus through its data monitoring terminal, so that it can monitor the data transmission on the RS485 bus in real time, analyze and determine whether the received data is consistent with the sent data. This connection relationship ensures that the signal transmission and control of each module can be performed automatically and efficiently, which not only reduces manual intervention, but also ensures the timing and consistency of the data transmission process. This control logic utilizes the automated instruction generation and execution of the MCU, the fast mode switching function of the transceiver control module, the bidirectional data transmission capability of the RS485 transceiver module, and the real-time data analysis of the automated test module to form an efficient and stable RS485 automated test system.
[0049] In summary, by introducing the MCU module, the transceiver control module, the RS485 transceiver module and the automated test module, the traditional method of manually configuring the serial port and transmitting the test on multiple PCs is replaced. In the traditional method, the test requires multiple PCs to cooperate with each other, and the RS485 mode needs to be manually selected and configured for each test, which is not only complicated to operate, but also prone to configuration errors and low test efficiency. In this technical solution, the MCU module can control the transceiver control module to realize the automatic mode switching of the RS485 transceiver module by automatically generating and sending transceiver control instructions, so that it can automatically switch between the receiving and sending states without manual intervention. In addition, the automated test module is directly connected to the RS485 bus, monitors and analyzes the transmission status of the data in real time, and automatically determines whether the received data is consistent with the sent data. This solution not only saves the manual operation steps of multiple PCs in the traditional method, but also significantly reduces the risk of configuration errors, reduces manual workload, avoids cumbersome configuration operations, and greatly improves the automation and efficiency of the test. Especially in large-scale batch testing scenarios, this solution can achieve fast fully automated testing, significantly reduce testing time, meet the needs of industrial production lines for efficient and accurate testing, and improve the reliability and consistency of the system.
[0050] Specifically, Figure 3 As shown, the transceiver control module includes a MOS tube Q1 and a resistor R20, a first end of the resistor R20 is connected to a power supply, a second end of the resistor R20 is connected to a first conduction end of the MOS tube Q1, a second conduction end of the MOS tube Q1 is grounded, a controlled end of the MOS tube Q1 is connected to an enable signal output end of the MCU module, and a common node between the second end of the resistor R20 and the MOS tube Q1 is connected to a mode switching signal input port of the RS485 transceiver module.
[0051] In this embodiment, the transceiver control module is composed of a MOS tube Q1 and a resistor R20, and the connection relationship and control logic thereof are closely matched to realize the automatic switching control of the RS485 transceiver module. The first end of the resistor R20 is connected to the power supply to ensure that a stable voltage source is provided for the circuit, and the second end thereof is connected to the first conduction end of the MOS tube Q1 to form a control of the conduction state of Q1. Under this configuration, the second conduction end of the MOS tube Q1 is directly grounded, providing a path so that Q1 can be effectively turned on or off under the action of the control signal. The controlled end of the MOS tube Q1 is connected to the enable signal output end of the MCU module, and the MCU controls the conduction of Q1 by sending an enable signal, thereby controlling the working mode of the transceiver module. In particular, the common node between the second end of the resistor R20 and the MOS tube Q1 is directly connected to the mode switching signal input port of the RS485 transceiver module, ensuring that when Q1 is controlled to be turned on, the potential change of the common node can drive the RS485 transceiver module to automatically switch between the sending and receiving states. Through this design, the MCU module can accurately control the switch state of the MOS tube, thereby flexibly controlling the mode switching of the RS485 transceiver module, avoiding traditional manual operation, and effectively preventing overcurrent damage to the MOS tube through the configuration of resistors, ensuring the stability and reliability of the circuit. This structural design ensures the continuity and stability of the signal transmission and mode switching process of each module, and realizes efficient automatic control.
[0052] In summary, the combination of MOS tube Q1 and resistor R20 can ensure that the RS485 transceiver module can quickly switch between different modes, ensure the efficient execution of the transceiver control of the communication interface, thereby improving the working stability and communication efficiency of the test circuit and reducing the necessity of human intervention.
[0053] Specifically, Figure 2 As shown, the RS485 transceiver module includes an RS485 transceiver chip U2, pin 1 of the RS485 transceiver chip U2 serves as a first data sending end connected to the data transmission end of the MCU module, pin 4 of the RS485 transceiver chip U2 serves as a first data receiving end connected to the data transmission end of the MCU module, pin 6 of the RS485 transceiver chip U2 serves as a second data receiving end connected to the RS485 bus, and pin 7 of the RS485 transceiver chip U2 serves as a second data sending end connected to the RS485 bus.
[0054] In the present embodiment, in the technical scheme, the RS485 transceiver module transmits data with the MCU module and the RS485 bus through the RS485 transceiver chip U2 to ensure the smooth progress of two-way communication. The pin 1 of the RS485 transceiver chip U2 is connected to the data transmission end of the MCU module, as the first data transmitting end, responsible for receiving the data signal sent by the MCU, and transmitting it to the external device through the RS485 bus. The pin 4 of U2 is connected to the data transmission end of the MCU module as the first data receiving end, for receiving the data signal from the RS485 bus, and transmitting it back to the MCU for processing. In terms of external communication, the pin 6 of the RS485 transceiver chip U2 is connected to the RS485 bus, as the second data receiving end, for receiving the data sent by the external device from the bus. Pin 7 is then connected to the RS485 bus as the second data transmitting end, responsible for sending the data from the MCU to the bus to communicate with other devices. Through this design, the RS485 transceiver chip U2 can play a key role in two-way communication. Its pins 1 and 4 are responsible for data exchange with the MCU module, while pins 6 and 7 are responsible for data transmission and reception with other devices on the RS485 bus, thus achieving reliable communication between the MCU and external devices. This connection logic ensures the stability and continuity of data transmission between the MCU module and external devices. At the same time, through the reasonable configuration of the RS485 transceiver chip, the efficiency and accuracy of the entire communication process are guaranteed.
[0055] To sum up, the connection between the pins of the RS485 transceiver chip U2 and the data transmission end of the MCU module and the RS485 bus can be made more accurate and reasonable, ensuring that data sending and receiving are executed synchronously, thereby improving the reliability of data transmission and avoiding communication errors caused by improper connection.
[0056] Specifically, Figure 2 As shown, the RS485 transceiver chip U2 is an SP485 chip.
[0057] In this embodiment, the application of the SP485 chip as the RS485 transceiver chip in this technical solution has many advantages and key roles. First, the SP485 chip is a differential transceiver designed for the RS485 / RS422 standard, with high anti-interference ability, and can maintain the stability of data transmission under electromagnetic interference and noise environment in industrial environment. This is especially important for the RS485 automatic test circuit of industrial computers, because in complex industrial environments, electromagnetic interference often leads to unstable communication, and the SP485 chip can ensure the reliability of data transmission through its strong anti-noise ability.
[0058] Secondly, the SP485 chip has the characteristics of low power consumption, which is particularly suitable for test systems that need to run continuously for a long time. Its low power mode can not only reduce the energy consumption of the system, but also reduce heat generation, thereby extending the service life of the entire system. In large-scale batch testing scenarios, the low power design can effectively reduce operating costs and improve the overall efficiency of the system.
[0059] In addition, the SP485 chip has high-speed data transmission capabilities, supporting a transmission rate of up to 10Mbps, which can meet the needs of high-speed communication. This is crucial for automated test systems because high-speed data transmission can greatly improve test efficiency, shorten test time, and thus improve the overall operating efficiency of the production line.
[0060] Finally, the SP485 chip also supports multi-point bus communication, allowing multiple devices to share the same RS485 bus. This means that in a test system, multiple test terminals can be connected to achieve complex multi-device communication and test functions, further enhancing the flexibility and expansion capabilities of the system. Overall, the advantages of the SP485 chip in anti-interference, low power consumption, high-speed transmission and multi-point communication make it an ideal choice for industrial computer RS485 automatic test circuits, ensuring the stable and efficient operation of the system in complex environments.
[0061] In summary, by using the SP485 chip as the RS485 transceiver module, the entire RS485 communication system can have high compatibility, low power consumption and stronger anti-interference ability, thereby improving the overall reliability and stability of automated testing.
[0062] Specifically, Figure 2 As shown, the RS485 bus includes a first differential signal line and a second differential signal line, the first differential signal line is provided with a resistor R1, the resistor R1 is connected to pin 7 of the RS485 transceiver chip U2, the second differential signal line is provided with a resistor R8, the resistor R8 is connected to pin 6 of the RS485 transceiver chip U2, and the first differential signal line and the second differential signal line are connected via a resistor R7.
[0063] In the present embodiment, in the technical scheme, the RS485 bus is composed of a first differential signal line and a second differential signal line, ensuring that data is transmitted in the form of a differential signal on the bus, thereby enhancing anti-interference ability and signal stability. The first differential signal line is connected to pin 7 of the RS485 transceiver chip U2 through a resistor R1, and the pin is used as the second data sending end, which is responsible for transmitting the data sent by the MCU module to an external device through the RS485 bus. The second differential signal line is connected to pin 6 of the RS485 transceiver chip U2 through a resistor R8, and the pin is used as the second data receiving end to receive data sent from an external device through the RS485 bus. Between the two differential signal lines, a resistor R7 is provided to connect, and the role of the resistor R7 is to act as a terminal matching resistor, reduce signal reflection, and ensure that the signal is stably transmitted on the bus. The use of differential signals transmits data through the voltage difference on the two signal lines, rather than a single-line voltage, so even in the long-distance transmission process, the effects of noise and interference on the two signal lines are often the same, and the differential voltage remains unchanged, thereby greatly improving the anti-interference ability of data transmission. The configuration of resistors R1, R8 and R7 not only effectively matches the line impedance and prevents signal reflection, but also ensures the stability and reliability of the entire RS485 communication system in an industrial environment. Through this configuration of differential signal lines, the RS485 bus can maintain good data transmission performance in a high-noise environment and meet the high requirements of industrial testing.
[0064] In summary, the connection of differential signal lines and resistors on the RS485 bus can be used to effectively reduce signal reflection and interference, ensure the integrity and stability of data transmission, thereby improving the anti-interference ability of communication and the accuracy of data transmission, and ensuring the test accuracy in industrial environments.
[0065] Specifically, Figure 4 As shown, the RS485 transceiver module is connected to an electrostatic protection module, and the electrostatic protection module includes a TVS diode D1. The first end of the TVS diode D1 is connected to pin 7 of the RS485 transceiver chip U2, the second end of the TVS diode D1 is connected to pin 6 of the RS485 transceiver chip U2, and the third end of the TVS diode D1 is grounded.
[0066] In the present embodiment, in the technical scheme, the RS485 transceiver module is connected with an electrostatic protection module to ensure the safety and stability of the communication circuit under high noise and high static electricity environment. The electrostatic protection module adopts a TVS diode D1, wherein the first end of D1 is connected to the pin 7 of the RS485 transceiver chip U2, and the pin is used as the second data sending end, which is responsible for sending data through the RS485 bus. The second end of D1 is connected to the pin 6 of U2, and the pin is used as the second data receiving end, which is responsible for receiving data from the RS485 bus. The third end of the TVS diode is grounded, providing an electrostatic discharge channel. When external static electricity or transient overvoltage acts on the RS485 bus, the TVS diode can be quickly turned on when the voltage exceeds its breakdown voltage, and the excessive voltage is discharged to the ground through its ground terminal, thereby protecting the pins of the RS485 transceiver chip from being damaged by overvoltage. Through this connection mode, the electrostatic protection module can monitor the voltage state of pins 7 and 6 in real time, and when an electrostatic discharge event occurs, the overvoltage is absorbed and discharged to the ground in time to avoid damage to the RS485 transceiver module and the entire communication circuit. This design not only improves the anti-static ability of the entire communication system, but also effectively extends the service life of the system, ensuring stable and reliable communication in complex industrial environments.
[0067] In summary, the TVS diode D1 can be used to provide electrostatic protection for the RS485 transceiver module, effectively preventing damage to the communication chip caused by electrostatic discharge, thereby improving the anti-static ability of the test circuit in a complex industrial environment, extending the service life of the system and ensuring the continuity and stability of communication.
[0068] Preferably, Figure 8 As shown, in the field of industrial computers, on the one hand, RS485 testing is performed through serial ports of multiple PCs that support RS485 mode, which greatly reduces the test efficiency; on the other hand, RS485 testing uses an independent small card solution to perform RS485 serial port testing. This solution can ensure stable and interference-free communication while keeping the cost low.
[0069] like Fig. 9As shown, this solution is small and flexible, plug-and-play, and does not require the selection of serial port mode. The serial port communication is stable, the number of tests exceeds 100,000 times, and there is no data packet loss or error. The cost of the whole solution is low, and the cost of the whole solution is about 7-8 RMB. The devices used in the RS485 communication circuit design are mainly single-chip microcomputer (MCU), IC (SP485) and MOSFET / ESD / connector, etc. The single-chip microcomputer serial port communication is generally TTL level, and RS485 communication is half-duplex communication, that is, data cannot be received at the same time when sending data, so we choose SP485 chip as RS485 transceiver; MCU serial port communication code design mainly uses IAR development tools (IAR EmbeddedWorkbench for STM8), and through the combination of automated interface testing tools, the data transmission and reception of RS485 serial port is realized to ensure the stability of serial port testing; such as Fig.10 As shown, the MCU-related serial port and GPIO are initialized. Then, before the MCU sends data to the RS485 serial port, a delay is set. The time setting must match the automated test tool. At this time, the automated test tool will analyze whether the received data is consistent with the sent data. If they are consistent, the serial port test is PASS; otherwise, FAIL.
[0070] like Figure 5 As shown, an automatic test method for RS485 of an industrial computer is applied to an automatic test circuit for RS485 of an industrial computer. The automatic test method for RS485 of an industrial computer includes:
[0071] S10. Initialize the communication interface of the MCU module based on the communication requirements to configure the corresponding serial port communication parameters;
[0072] In this embodiment, in order to ensure that the MCU module can effectively communicate data with the RS485 transceiver module and other external devices. The initialization process includes setting the serial port communication parameters of the MCU, such as baud rate, data bit, stop bit and check bit, etc. These parameters ensure the synchronization and consistency of the communicating parties at the physical level. For example, in different industrial applications, communication requirements may require high-speed transmission, so it is necessary to select an appropriate baud rate according to specific requirements. The initialized MCU module can process and transmit data accurately and ensure the stability and reliability of the entire communication system.
[0073] S20, based on the serial communication parameters configured by the communication interface, sending the corresponding transceiver control instruction to the transceiver control module, so that the RS485 transceiver module switches to the corresponding transceiver state;
[0074] In the present embodiment, a specific control instruction is sent by the MCU module to control the mode switching of the RS485 transceiver module. According to the current communication requirements, the MCU module can automatically generate and send a control signal to switch the RS485 transceiver module to a sending or receiving state. For example, when data needs to be sent, the MCU module generates a control instruction to enable the RS485 transceiver module to enter a sending mode; and when data needs to be received, the MCU module switches the RS485 module to a receiving mode through corresponding instructions. This automated switching method not only improves the efficiency of communication, but also reduces the necessity of manual intervention, ensuring the continuity and accuracy of the test process.
[0075] S30, when it is detected that the RS485 transceiver module switches to the sending state, a synchronization condition matching the automated test module is set to perform a data transmission operation;
[0076] In the present embodiment, the working state of the RS485 transceiver module is detected by the MCU, and when switched to the sending state, the synchronization conditions matching the automated test module are automatically set to ensure the timing synchronization of data transmission. The synchronization conditions include clock signals, data rates, etc., to ensure that the timing and parameters between the MCU module and the automated test module are consistent during data transmission. For example, when the MCU module is ready to send data, the synchronization parameters are adjusted according to the current baud rate and timing conditions to ensure that the automated test module can receive data in real time and verify it during data transmission. The automated operation of this synchronous setting significantly improves the reliability and accuracy of data transmission.
[0077] S40, waiting to receive the first communication data sent by the test terminal. If it has been received, control the automatic test module to determine whether the first communication data is consistent with the second communication data sent by the MCU module. If they are consistent, record the communication test passing and generate the corresponding test result. If they are inconsistent, generate an error report and record the test failure information.
[0078] In this embodiment, after sending the data of the MCU module, the system enters a waiting state and waits for the first communication data returned by the test terminal. The test terminal is responsible for transmitting the data back to the MCU module for data consistency verification. When the first communication data of the test terminal is received by the automated test module, the automated test module compares the data with the second communication data previously sent by the MCU to ensure that the two are completely consistent in content and format. If the comparison results are consistent, the system considers that this communication test is successful, records the test results through the automated test module, proves that the communication link is working properly, and generates a corresponding test pass report. If the comparison results are inconsistent, the system will generate an error report and record the information of the test failure. This process ensures the integrity and accuracy of the communication link. Through the real-time comparison of data by the automated test module, problems can be quickly detected and located, thereby ensuring the reliability of the data transmission process and avoiding communication errors caused by inconsistent data.
[0079] In summary, unlike traditional manual operations, this method first automatically initializes the communication interface of the MCU module based on communication requirements and configures serial port communication parameters that meet the test requirements. Subsequently, the system generates transceiver control instructions based on these parameters, and automatically controls the RS485 transceiver module to switch to the appropriate transceiver state, avoiding the steps of manual switching required in traditional tests. When the RS485 transceiver module switches to the sending state, the system automatically sets the synchronization conditions that match the automated test module to ensure the timing and parameter consistency of data transmission, thereby ensuring the accuracy and reliability of data transmission. At the same time, the system automatically waits for the first communication data sent by the test terminal, and monitors the consistency of the data with the second communication data sent by the MCU module in real time through the automated test module. Once the data is confirmed to be consistent, the system automatically records the passing result of the communication test; if inconsistency is detected, the system generates an error report and records the test failure information. Through these automated operations, this technical solution greatly reduces manual intervention, realizes automation and efficiency of the entire test process, greatly improves the efficiency and accuracy of RS485 testing, is particularly suitable for large-scale industrial testing scenarios, and meets the high requirements of modern industry for automated testing.
[0080] Specifically, Figure 6 As shown, the industrial computer RS485 automatic testing method also includes the following steps:
[0081] S50, determining whether the communication process is terminated according to the test result or the test failure information;
[0082] In this embodiment, the MCU module can determine whether the current communication process has been completed through the test results or error reports generated by the automated test module. The test result is based on the consistency of the received data and the sent data. If they are consistent, the system considers that the test has passed; if they are inconsistent, the system records the error information and enters the corresponding error handling process. This process ensures the integrity of each communication test and can decide whether to continue other test tasks based on actual conditions. For example, in a batch test environment, this function can effectively help the system automatically process different batches of tests and determine whether each test needs further analysis or retesting.
[0083] S60: If the communication process has ended, control the MCU module to perform a cleanup operation, wherein the cleanup operation includes sending a buffer cleanup instruction to release the occupied communication buffer space.
[0084] In this embodiment, when the MCU module determines that the communication process is over, the system will automatically perform a cleanup operation to release the cache space used to temporarily store data. The cache space will store temporarily transmitted data during the communication process to ensure that the data will not be lost during the receiving and sending process. The cleanup operation sends a special instruction through the MCU module to ensure that the cache space is released in time to avoid communication errors caused by cache overflow or data conflicts. This ensures that the subsequent communication process can proceed smoothly and is not affected by the cache data of the previous test, thereby improving the stability and continuity of the system. For example, in a high-speed and large-volume test scenario, automatically cleaning the cache can not only improve the system response speed, but also effectively avoid the waste of storage resources.
[0085] To sum up, it is possible to promptly determine whether the communication process has ended based on the test results or failure information, and automatically perform cache cleaning operations to ensure the timely release of the communication cache, thereby improving the transmission efficiency during the next communication, avoiding communication errors caused by cache overflow, and improving the system's operating stability.
[0086] Specifically, Figure 7 As shown, the steps of setting the synchronization condition matching the automated test module and performing the data transmission operation include:
[0087] S401, generating a corresponding synchronization configuration instruction according to the serial port communication parameters, wherein the synchronization configuration instruction is used to match the communication parameters of the MCU module with the communication parameters of the automated test module;
[0088] In this embodiment, the MCU module generates specific synchronization configuration instructions according to the currently set serial port communication parameters (such as baud rate, data bit, stop bit, etc.), which are used to ensure that the communication parameters of the MCU and the automated test module are consistent during data transmission. This process can be achieved through an automated process to ensure the consistency of the communication configuration of both parties at the physical level and avoid data transmission errors caused by asynchronous communication parameters. For example, the baud rates of the MCU and the automated test module must match, otherwise it will cause incorrect data reception and even cause communication failure. Therefore, the synchronization configuration instructions generated by this step ensure that the two establish the same transmission environment before communication.
[0089] S402: If the communication parameters of the MCU module match the communication parameters of the automated test module successfully, the automated test module is controlled to send a synchronization verification request signal to verify the timing synchronization of the communicating parties in data transmission;
[0090] In this embodiment, after the communication parameters are successfully matched, the automated test module further confirms whether the timing of the two communicating parties is consistent by sending a synchronization verification request signal. The synchronization verification request signal is similar to a handshake protocol, which is used to ensure that the MCU and the automated test module not only agree on the communication parameters, but also keep synchronization in the time of data transmission. This step is very critical because even if the communication parameters match, if the timing is not synchronized, it may still cause data loss or errors. By sending a synchronization verification request signal, the automated test module can detect any timing deviation, thereby preventing possible transmission problems during the communication process in advance.
[0091] S403: If the MCU module receives a synchronization confirmation signal from the automatic test module, it starts to execute the data transmission operation.
[0092] In this embodiment, after the MCU module successfully receives the synchronization confirmation signal returned by the automated test module, it means that the communication parameters and timing of both parties have been fully synchronized, the communication environment is ready, and then the formal data transmission operation begins. At this time, the MCU sends the data to the automated test module through the RS485 interface, and starts to monitor the integrity and consistency of the data transmission at the same time. This synchronization confirmation mechanism ensures the accuracy of data transmission, especially in complex industrial environments. Matching the timing and parameters in advance can effectively reduce data transmission errors and packet loss, and improve the reliability of the entire communication process.
[0093] In summary, by generating synchronization configuration instructions, the communication parameters of the MCU module and the automated test module can be matched, and synchronization verification can be performed while ensuring the consistency of the parameters, thereby ensuring the timing synchronization of data transmission, thereby improving the stability and reliability of the data transmission process and avoiding timing errors during the communication process.
[0094] Specifically, the serial port communication code of the MCU module is designed and written by using an IAR development tool to implement the configuration of serial port communication parameters and the control of data sending and receiving operations.
[0095] In the present embodiment, developers use the professional integrated development environment (IDE) of IAR development tools to write and debug the serial communication code of MCU. IAR development tools provide rich debugging and optimization functions, so that developers can accurately set the serial communication parameters of MCU, such as baud rate, data bit, stop bit, etc., and ensure that these configurations can be efficiently executed in actual operation. Through IAR development tools, the generation and optimization process of code are greatly simplified, which can significantly improve development efficiency and reduce debugging time and error rate. In addition, IAR development tools support advanced code optimization functions, which can reduce code volume and resource occupation without sacrificing system performance, thereby improving the overall operation efficiency of the system. Through these designs, MCU can accurately and stably carry out data transceiver operation, ensure the reliability and stability of the communication process, especially in industrial automation test environment, the precise control of communication operation is crucial, and the test efficiency and accuracy of the system can be effectively improved.
[0096] In summary, IAR development tools can be used to design and write serial communication codes for MCU modules, ensuring accurate configuration of serial communication parameters and automatic control of data transmission and reception operations, thereby improving development efficiency and code stability, and improving the reliability of the entire test circuit.
[0097] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0098] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. An RS485 automatic test circuit for industrial computers, characterized in that: The RS485 automatic test circuit for industrial computers comprises an MCU module, a transceiver control module, an RS485 transceiver module and an automated test module. The data transmission end of the MCU module is connected to the data transmission end of the RS485 transceiver module, the data transmission end of the RS485 is connected to a test terminal via an RS485 bus, the enable signal output end of the MCU module is connected to the enable signal input end of the transceiver control module, the mode switching signal output end of the transceiver control module is connected to the mode switching signal input port of the RS485 transceiver module, so that the RS485 transceiver module switches to a receiving state or a sending state, and the data monitoring end of the automated test module is connected to the RS485 bus for analyzing whether the received data is consistent with the sent data.
2. The RS485 automatic test circuit for industrial computers according to claim 1, characterized in that: The transceiver control module includes a MOS tube Q1 and a resistor R20, wherein a first end of the resistor R20 is connected to a power supply, a second end of the resistor R20 is connected to a first conduction end of the MOS tube Q1, a second conduction end of the MOS tube Q1 is grounded, a controlled end of the MOS tube Q1 is connected to an enable signal output end of the MCU module, and a common node between the second end of the resistor R20 and the MOS tube Q1 is connected to a mode switching signal input port of the RS485 transceiver module.
3. The RS485 automatic test circuit for industrial computers according to claim 1, characterized in that: The RS485 transceiver module includes an RS485 transceiver chip U2, wherein pin 1 of the RS485 transceiver chip U2 serves as a first data sending end connected to the data transmission end of the MCU module, pin 4 of the RS485 transceiver chip U2 serves as a first data receiving end connected to the data transmission end of the MCU module, pin 6 of the RS485 transceiver chip U2 serves as a second data receiving end connected to the RS485 bus, and pin 7 of the RS485 transceiver chip U2 serves as a second data sending end connected to the RS485 bus.
4. The RS485 automatic test circuit for industrial computers according to claim 3 is characterized in that: The RS485 transceiver chip U2 is an SP485 chip.
5. The RS485 automatic test circuit for industrial computers according to claim 3 is characterized in that: The RS485 bus includes a first differential signal line and a second differential signal line. The first differential signal line is provided with a resistor R1, and the resistor R1 is connected to pin 7 of the RS485 transceiver chip U2. The second differential signal line is provided with a resistor R8, and the resistor R8 is connected to pin 6 of the RS485 transceiver chip U2. The first differential signal line and the second differential signal line are connected via a resistor R7.
6. The RS485 automatic test circuit for industrial computers according to claim 3 is characterized in that: The RS485 transceiver module is connected to an electrostatic protection module, which includes a TVS diode D1. The first end of the TVS diode D1 is connected to pin 7 of the RS485 transceiver chip U2, the second end of the TVS diode D1 is connected to pin 6 of the RS485 transceiver chip U2, and the third end of the TVS diode D1 is grounded.
7. An automatic test method for RS485 of an industrial computer, applied to an automatic test circuit for RS485 of an industrial computer as claimed in any one of claims 1 to 6, characterized in that: The RS485 automatic testing method for industrial computers includes: Based on the communication requirements, initialize the communication interface of the MCU module to configure the corresponding serial port communication parameters; Based on the serial communication parameters configured by the communication interface, send the corresponding transceiver control instruction to the transceiver control module so that the RS485 transceiver module switches to the corresponding transceiver state; When it is detected that the RS485 transceiver module switches to the sending state, a synchronization condition matching the automatic test module is set to perform a data transmission operation; Wait to receive the first communication data sent by the test terminal. If it has been received, control the automated test module to determine whether the first communication data is consistent with the second communication data sent by the MCU module. If they are consistent, record the communication test passing and generate the corresponding test results. If they are inconsistent, generate an error report and record the test failure information.
8. The RS485 automatic testing method for industrial computers according to claim 7, characterized in that: The industrial computer RS485 automatic testing method also includes the following steps: Determining whether the communication process is terminated according to the test result or the test failure information; If the communication process has ended, the MCU module is controlled to perform a cleanup operation, which includes sending a buffer cleanup instruction to release the occupied communication buffer space.
9. The RS485 automatic testing method for industrial computers according to claim 7, characterized in that: The steps of setting synchronization conditions matching the automated test module and performing data transmission operations include: Generate corresponding synchronization configuration instructions according to the serial port communication parameters, wherein the synchronization configuration instructions are used to match the communication parameters of the MCU module with the communication parameters of the automated test module; If the communication parameters of the MCU module match the communication parameters of the automated test module successfully, the automated test module is controlled to send a synchronization verification request signal to verify the timing synchronization of the communicating parties in data transmission; If the MCU module receives a synchronization confirmation signal from the automated test module, it starts to execute the data transmission operation.
10. The RS485 automatic testing method for industrial computers according to claim 7, characterized in that: The serial port communication code of the MCU module is designed and written by using the IAR development tool to realize the configuration of serial port communication parameters and the control of data sending and receiving operations.