RS485 communication supervision and error correction method and system

Through the Hanming code encoding error correction method, the communication error problem caused by environmental interference in RS485 communication is solved, real-time correction of bit errors, reducing bit error rate, and improving communication reliability.

CN120342547APending Publication Date: 2025-07-18ZHENGZHOU BEIBO ELECTRONICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510500954.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-21
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

In multi-point communication, the RS485 communication protocol is susceptible to environmental interference, resulting in communication errors, resulting in communication failure and affecting the operation of the equipment.

Method used

The Hanming code encoding error correction method is adopted. The sender encodes the source code and the receiver decodes it. The Hanming code uses Hanming code to correct a bit error, reduce the bit error rate, and improve communication reliability.

Benefits of technology

Correct one-bit errors in communication in real time, reduce bit error rates, improve communication reliability, and reduce economic losses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120342547A_ABST
    Figure CN120342547A_ABST
Patent Text Reader

Abstract

The invention discloses an RS485 communication supervision and error correction method and system, the system comprises a power conversion circuit, a microprocessor processing circuit and a 485 communication transmit-receive circuit which are matched with a circuit, and the microprocessor processing circuit and the 485 communication transmit-receive circuit are both electrically connected with the power conversion circuit; the power conversion circuit comprises a power conversion chip U1. According to the method, RS485 data receiving and transmitting are completed in real time, necessary measures are taken, a Hamming code encoding error correction method is adopted, a sender encodes a source code, a receiver decodes the source code, real-time correction of a one-bit error can be guaranteed, the error rate is reduced, the communication reliability is improved, a layer of protection is added for RS485 network communication, and economic losses are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of RS485 communication, and particularly to an RS485 communication supervision and error correction method and system. Background Art

[0002] The RS485 communication protocol is a multi-point communication protocol that allows multiple devices to communicate on the same bus, and each device can send and receive data. The RS485 communication protocol uses differential signal transmission, which has the characteristics of high speed, long distance, and strong reliability, and can achieve long-distance data transmission.

[0003] In the specific implementation process, the RS485 bus will be affected by various environmental interferences and communication errors will occur, resulting in communication failures and affecting the operation of the device.

[0004] The present invention adopts a new processing method, the Hamming code encoding and error correction method. The sender encodes the source code, and the receiver decodes it, which can ensure the real-time correction of one error, reduce the bit error rate, and improve the reliability of communication. It adds a layer of protection to the RS485 network communication, reduces economic losses. In view of the above situation, the present application proposes an RS485 communication supervision and error correction method and system. Summary of the Invention

[0005] The purpose of the present invention is to solve the problems existing in the prior art, and to propose an RS485 communication supervision and error correction method and system.

[0006] To achieve the above object, the present invention adopts the following technical solutions:

[0007] On the one hand, an RS485 communication supervision and error correction system is provided, including a power conversion circuit, a microprocessor processing circuit, and a 485 communication transceiver circuit. The microprocessor processing circuit and the 485 communication transceiver circuit are both electrically connected to the power conversion circuit;

[0008] The power conversion circuit includes a power conversion chip U1. The pin 3 of the power conversion chip U1 is electrically connected to the pin 2 of the terminal block CN1, capacitors C1, C2, and is connected to the power supply +5V; the pin 2 of the power conversion chip U1 is connected to capacitors C3, C4, and outputs a 3.3V voltage VCC; the other ends of capacitors C1, C2, C3, C4, and the pin 1 of the power conversion chip U1 are all grounded;

[0009] The microprocessor processing circuit includes a microprocessor U2. Pin 1 of the microprocessor U2 is connected to pins 2 and 3 of the RS485 chip U3. Pin 2 of the microprocessor U2 is connected to pin 4 of the RS485 chip U3. Pin 3 of the microprocessor U2 is connected to pin 1 of the RS485 chip U3. Pin 4 of the microprocessor U2 is connected to a resistor R1, a capacitor C7, and pin 4 of a terminal block P1. Pin 5 of the microprocessor U2 is connected to X1 and a capacitor C5. Pin 6 of the microprocessor U2 is connected to X1 and a capacitor C6. Pin 8 of the microprocessor U2 is connected to a capacitor C8. Pin 18 of the microprocessor U2 is connected to a resistor R3. The other end of the resistor R3 is connected to pin 2 of P1. The other ends of the capacitors C5, C6, C8, C7, pin 7 of the microprocessor U2, and pin 3 of P1 are all grounded. Pin 9 of the microprocessor U2, pin 1 of P1, and the other end of the resistor R1 are all connected to a 3.3V voltage VCC;

[0010] The RS485 circuit includes an RS485 chip U3 and a terminal block CN2. Pin 1 of the RS485 chip U3 is connected to pin 3 of the microprocessor U2. Pins 3 and 2 of the RS485 chip U3 are connected to pin 1 of the microprocessor U2. Pin 4 of the RS485 chip U3 is connected to pin 2 of the microprocessor U2. Pin 8 of the RS485 chip U3 is connected to a 3.3V voltage VCC and a capacitor C9. Pin 7 of the RS485 chip U3 is connected to a resistor R4. The other end of the resistor R4 is connected to pin 1 of CN2. Pin 6 of the RS485 chip U3 is connected to a resistor R5. The other end of the resistor R5 is connected to pin 2 of CN2. Pin 5 of the RS485 chip U3 and the other end of the capacitor C9 are grounded.

[0011] Preferably, the model of the power conversion chip U1 is LT1117CST3.3, and pin 2 of the power conversion chip U1 outputs 3.3V direct current.

[0012] Preferably, the model of the microprocessor circuit chip U2 is STM8S003F3P6, and the model of the RS485 chip U3 is MAX3485ESA.

[0013] Preferably, pin 2 of the power connector CN1 is electrically connected to a 5V direct current power supply, and the capacitors C1, C2, C3, and C4 are all filter capacitors.

[0014] On the other hand, an RS485 communication supervision and error correction method is provided. The specific method is as follows: Before data transmission, the source code is encoded using Hamming code. Hamming code can correct one-bit errors. k redundant bits are added to a data of length m to form a codeword of n = m + k bits. Then, k correction factors generated by k supervision relations are used to detect and correct errors. In order to correct one-bit errors, the data length and the number of redundant bits must satisfy the following formula:

[0015] 2 k ≥m + k + 1

[0016] In the formula, m is the data length, and k is the number of Hamming code check bits.

[0017] For the sender, each time a byte is sent, it will be divided into the high 4 bits and the low 4 bits. Here, m = 4. First, take the low 4 bits as an information source code, and the 4-bit information source code is represented by a7, a6, a5, a4; add 3 check codes k = 3, and the 3-bit check codes are represented by r3, r2, r1. The check code k is represented by the following encoding equation:

[0018]

[0019] Form a 7-bit sequential codeword: a7, a6, a5, r3, a4, r2, r1. The RS485 is configured for 7-bit communication and can be sent out; similarly, take the high 4 bits as an information source code and send it out according to the same processing method, so that a complete 8-bit byte is all sent out.

[0020] Preferably, for the RS485 data receiver, after each frame of data is received, for the 7-bit codeword: a7, a6, a5, r3, a4, r2, r1, the correction factors S1, S2, S3 are calculated through the following supervision equation:

[0021]

[0022] Error correction is based on Table 1 as follows:

[0023] Table 1 Error correction factor error judgment basis

[0024] <![CDATA[S3S2S1]]> 0 0 0 Error-free 0 0 1 <![CDATA[r1 is incorrect, invert r1]]> 0 1 0 <![CDATA[r2 is incorrect, invert r2]]> 0 1 1 <![CDATA[a4 is incorrect, take the inverse of a4]]> 1 0 0 <![CDATA[r3 is incorrect, invert r3 <!-- 2 -->]]> 1 0 1 <![CDATA[Invert a5 which is incorrect]]> 1 1 0 <![CDATA[Invert a6 as it is incorrect]]> 1 1 1 <![CDATA[Invert a7 which is incorrect]]>

[0025] After the receiver receives 2 frames of data after error correction, extract the low 4 bits and high 4 bits of the data byte, and synthesize a complete 8-bit byte data. After adding Hamming code error correction coding to the RS485 communication, the communication interference error is reduced, the bit error rate is lowered, and two-way half-duplex communication can also be realized.

[0026] Compared with the existing technology, the beneficial effects of the present invention are:

[0027] The present invention realizes real-time RS485 data transceiver, and takes necessary measures. By adopting the Hamming code encoding and error correction method, the sender encodes the source code and the receiver decodes it, which can ensure real-time correction of a single-bit error, reduce the bit error rate, improve the communication reliability, add a layer of protection to the RS485 network communication, and reduce economic losses. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is the circuit diagram of the power conversion circuit of a RS485 communication supervision and error correction method and system proposed by the present invention;

[0029] Figure 2 It is the circuit diagram of the microprocessor processing circuit of a RS485 communication supervision and error correction method and system proposed by the present invention;

[0030] Figure 3 It is the 485 communication circuit diagram of a RS485 communication supervision and error correction method and system proposed by the present invention; DETAILED DESCRIPTION OF THE INVENTION

[0031] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments.

[0032] Refer to Figures 1-3 , a RS485 communication supervision and error correction method and system, including a power conversion circuit, a microprocessor processing circuit, and a 485 communication transceiver circuit. The microprocessor processing circuit and the 485 communication transceiver circuit are both electrically connected to the power conversion circuit;

[0033] The power conversion circuit includes a power conversion chip U1. The pin 3 of the power conversion chip U1 is electrically connected to the pin 2 of the terminal block CN1, capacitors C1 and C2, and is connected to the power supply +5V; the pin 2 of the power conversion chip U1 is connected to capacitors C3 and C4, and outputs a 3.3V voltage VCC; the other ends of capacitors C1, C2, C3, C4, and the pin 1 of the power conversion chip U1 are all grounded;

[0034] The microprocessor processing circuit includes a microprocessor U2. The pin 1 of the microprocessor U2 is connected to pins 2 and 3 of the RS485 chip U3. The pin 2 of the microprocessor U2 is connected to pin 4 of the RS485 chip U3. The pin 3 of the microprocessor U2 is connected to pin 1 of the RS485 chip U3. The pin 4 of the microprocessor U2 is connected to a resistor R1, a capacitor C7, and is connected to pin 4 of the terminal block P1. The pin 5 of the microprocessor U2 is connected to X1 and a capacitor C5. The pin 6 of the microprocessor U2 is connected to X1 and a capacitor C6. The pin 8 of the microprocessor U2 is connected to a capacitor C8. The pin 18 of the microprocessor U2 is connected to a resistor R3. The other end of the resistor R3 is connected to pin 2 of P1. The other ends of the capacitors C5, C6, C8, C7, pin 7 of the microprocessor U2, and pin 3 of P1 are all grounded. The pin 9 of the microprocessor U2, pin 1 of P1, and the other end of the resistor R1 are all connected to the 3.3V voltage VCC;

[0035] The RS485 circuit includes an RS485 chip U3 and a terminal block CN2. The pin 1 of the RS485 chip U3 is connected to pin 3 of the microprocessor U2. The pins 3 and 2 of the RS485 chip U3 are connected to pin 1 of the microprocessor U2. The pin 4 of the RS485 chip U3 is connected to pin 2 of the microprocessor U2. The pin 8 of the RS485 chip U3 is connected to the 3.3V voltage VCC and is connected to a capacitor C9. The pin 7 of the RS485 chip U3 is connected to a resistor R4. The other end of the resistor R4 is connected to pin 1 of CN2. The pin 6 of the RS485 chip U3 is connected to a resistor R5. The other end of the resistor R5 is connected to pin 2 of CN2. The pin 5 of the RS485 chip U3 and the other end of the capacitor C9 are grounded.

[0036] The model of the power conversion chip U1 is LT1117CST3.3, and the pin 2 of the power conversion chip U1 outputs 3.3V direct current. The model of the microprocessor circuit chip U2 is STM8S003F3P6, and the model of the RS485 chip U3 is MAX3485ESA. The pin 2 of the power connector CN1 is electrically connected to a 5V DC power supply, and the capacitors C1, C2, C3, and C4 are all filter capacitors.

[0037] The present invention can complete real-time RS485 data communication, improve reliability and stability, and has an error correction function for communication errors.

[0038] Working principle: When in use, the 5V DC power supply is converted into 3.3V direct current through the power conversion circuit to provide power for the system circuit.

[0039] When sending data, the source code is encoded before data transmission. Hamming code is used for encoding, and Hamming code can correct one-bit errors. In a data of length m, k redundant bits are added to form a codeword of n = m + k bits, and then k correction factors generated by k supervision relations are used to detect and correct errors. In order to correct one-bit errors, the data length and the number of redundant bits must satisfy formula (1).

[0040] 2 k ≥m + k + 1 (1)

[0041] In formula (1), m is the data length and k is the number of Hamming code check bits.

[0042] At the sender side, each time a byte is sent, it will be divided into the upper 4 bits and the lower 4 bits. Here, m = 4. First, take the lower 4 bits as an information source code, and the 4-bit information source code is represented by a7, a6, a5, a4; 3 check codes are added, k = 3, and the 3-bit check codes are represented by r3, r2, r1. The check code k is represented by the encoding equation (2).

[0043]

[0044] Form a 7-bit sequential codeword: a7 a6 a5 r3 a4 r2 r1. The RS485 is configured for 7-bit communication and can be sent out; similarly, take the upper 4 bits as an information source code and send it out according to the same processing method. In this way, a complete 8-bit byte is all sent out.

[0045] When receiving data, at the data receiver side, each time a frame of data is received completely, for the 7-bit codeword: a7 a6 a5 r3 a4 r2 r1, the correction factors S1, S2, S3 are calculated through the supervision equation (3).

[0046]

[0047] Error correction is based on Table 1 as follows:

[0048] Table 1 Error correction factor error judgment basis

[0049] <![CDATA[S3S2S1]]> 0 0 0 Error-free 0 0 1 <![CDATA[r1 is incorrect, invert r1]]> 0 1 0 <![CDATA[r2 is incorrect, take the inverse of r2]]> 0 1 1 <![CDATA[Invert a4 which is incorrect]]> 1 0 0 <![CDATA[r3 is incorrect, take the inverse of r3]]> 1 0 1 <![CDATA[a5 is incorrect, invert a5 <!-- 4 -->]]> 1 1 0 <![CDATA[Invert a6, which is incorrect]]> 1 1 1 <![CDATA[Invert a7 which is incorrect]]>

[0050] After the receiver receives 2 frames of data after error correction, extract the lower 4 bits and the upper 4 bits of the data byte to synthesize a complete 8-bit byte data; after adding Hamming code error correction coding to the RS485 communication, the communication interference errors are reduced, the bit error rate is lowered, and two-way half-duplex communication can also be achieved.

[0051] The above are only the preferred specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention, according to the technical solution of the present invention and its inventive concept, making equivalent substitutions or changes should be covered by the protection scope of the present invention.

Claims

1. An RS485 communication supervision and error correction system, characterized in that It includes a power conversion circuit, a microprocessor processing circuit, and a 485 communication transceiver circuit. The microprocessor processing circuit and the 485 communication transceiver circuit are both electrically connected to the power conversion circuit; The power conversion circuit includes a power conversion chip U1. The pin 3 of the power conversion chip U1 is electrically connected to the pin 2 of the terminal block CN1, capacitors C1 and C2, and is connected to the power supply +5V. The pin 2 of the power conversion chip U1 is connected to capacitors C3 and C4 and outputs a 3.3V voltage VCC. The other ends of capacitors C1, C2, C3, and C4 and the pin 1 of the power conversion chip U1 are all grounded; The microprocessor processing circuit includes a microprocessor U2. The pin 1 of the microprocessor U2 is connected to the pins 2 and 3 of the RS485 chip U3. The pin 2 of the microprocessor U2 is connected to the pin 4 of the RS485 chip U3. The pin 3 of the microprocessor U2 is connected to the pin 1 of the RS485 chip U3. The pin 4 of the microprocessor U2 is connected to a resistor R1, a capacitor C7, and is connected to the pin 4 of the terminal block P1. The pin 5 of the microprocessor U2 is connected to X1 and a capacitor C5. The pin 6 of the microprocessor U2 is connected to X1 and a capacitor C6. The pin 8 of the microprocessor U2 is connected to a capacitor C8. The pin 18 of the microprocessor U2 is connected to a resistor R3. The other end of the resistor R3 is connected to the pin 2 of P1. The other ends of capacitors C5, C6, C8, and C7, the pin 7 of the microprocessor U2, and the pin 3 of P1 are all grounded. The pin 9 of the microprocessor U2, the pin 1 of P1, and the other end of the resistor R1 are all connected to the 3.3V voltage VCC; The RS485 circuit includes an RS485 chip U3 and a terminal block CN2. The pin 1 of the RS485 chip U3 is connected to the pin 3 of the microprocessor U2. The pins 3 and 2 of the RS485 chip U3 are connected to the pin 1 of the microprocessor U2. The pin 4 of the RS485 chip U3 is connected to the pin 2 of the microprocessor U2. The pin 8 of the RS485 chip U3 is connected to the 3.3V voltage VCC and is connected to a capacitor C9. The pin 7 of the RS485 chip U3 is connected to a resistor R4. The other end of the resistor R4 is connected to the pin 1 of CN2. The pin 6 of the RS485 chip U3 is connected to a resistor R5. The other end of the resistor R5 is connected to the pin 2 of CN2. The pin 5 of the RS485 chip U3 and the other end of the capacitor C9 are grounded.

2. The RS485 communication supervision and error correction method and system according to claim 1, characterized in that The model of the power conversion chip U1 is LT1117CST3.3, and the pin 2 of the power conversion chip U1 outputs 3.3V direct current.

3. The RS485 communication supervision and error correction method and system according to claim 1, wherein, The model of the microprocessor circuit chip U2 is STM8S003F3P6, and the model of the RS485 chip U3 is MAX3485ESA.

4. A method and system for RS485 communication supervision and error correction according to claim 1, characterized in that, The pin 2 of the power connector CN1 is electrically connected to a 5V DC power supply, and capacitors C1, C2, C3, and C4 are all filter capacitors.

5. A method for RS485 communication supervision and error correction, characterized in that, The specific method is as follows: Before data transmission, the source code is encoded using Hamming code. Hamming code can correct one-bit errors. k redundant bits are added to a data of length m to form a codeword of n = m + k bits. Then, k correction factors generated by k supervision relations are used to detect and correct errors. To be able to correct one-bit errors, the data length and the number of redundant bits must satisfy the following formula: 2 k ≥ m + k + 1 In the formula, m is the data length, and k is the number of Hamming code check bits. At the sender side, each time a byte is sent, it will be divided into the high 4 bits and the low 4 bits. Here, m = 4. First, take the low 4 bits as an information source code, and the 4-bit information source code is represented by a7, a6, a5, a4. Add 3 check codes, k = 3, and the 3-bit check codes are represented by r3, r2, r1. The check code k is represented by the following encoding equation: Form a 7-bit sequential codeword: a7, a6, a5, r3, a4, r2, r1. Configure RS485 for 7-bit communication and it can be sent out. Similarly, take the high 4 bits as an information source code and send it out according to the same processing method. In this way, a complete 8-bit byte is all sent out.

6. A method for RS485 communication supervision and error correction according to claim 5, characterized in that, At the RS485 data receiver side, after each frame of data is received, for the 7-bit codeword: a7, a6, a5, r3, a4, r2, r1, calculate the correction factors S1, S2, S3 through the following supervision equation: After the receiver receives 2 frames of data after error correction, extract the low 4 bits and the high 4 bits of the data byte and synthesize a complete 8-bit byte data.