Resistance matching method and device of CAN bus, controller, system, medium and product
By automatically identifying terminal nodes, dynamically establishing communication links, and adjusting closed-loop resistors, adaptive impedance matching of the CAN bus is achieved, solving the dynamic adaptability problem of impedance matching in traditional methods and improving signal integrity and system reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GREE ELECTRIC APPLIANCE INC OF ZHUHAI
- Filing Date
- 2026-02-09
- Publication Date
- 2026-05-01
AI Technical Summary
Existing impedance matching methods for CAN buses cannot dynamically adapt to factors such as changes in cable impedance, temperature drift, and aging during long-term operation, resulting in decreased signal integrity and cumbersome operation, which increases construction time and maintenance costs.
By automatically identifying terminal nodes, dynamically establishing communication links, quantitatively evaluating communication quality, and adjusting matching resistors in a closed loop, adaptive impedance matching is achieved. Programmable digital potentiometers and digital switches are used to dynamically adjust the resistance value, ensuring that the impedance at both ends of the CAN bus matches the characteristic impedance of the communication cable.
It effectively suppresses signal reflection, improves signal integrity, ensures the stability of high-speed and long-distance communication, reduces error rate and maintenance costs, and improves system reliability and deployment efficiency.
Smart Images

Figure CN121967119A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of control, and more particularly to a resistor matching method, apparatus, controller, system, medium, and product for a CAN bus. Background Technology
[0002] In building automation systems, the CAN (Controller Area Network) bus has become one of the mainstream communication technologies for connecting various intelligent nodes such as air conditioning controllers, power meters, and sensors due to its high reliability, strong anti-interference capability, and high real-time performance. However, the physical layer design of the CAN bus must comply with the ISO 11898-2 standard, which explicitly requires that terminating resistors matching the characteristic impedance of the communication cable be connected at both ends of the bus to achieve impedance matching and avoid data transmission errors caused by signal reflection. Summary of the Invention
[0003] One technical problem this disclosure aims to solve is to provide a resistance matching method, apparatus, controller, system, medium, and product for a CAN bus that can achieve adaptive impedance matching and reduce data transmission errors caused by signal reflection.
[0004] According to one aspect of this disclosure, a resistor matching method for a control area network (CAN) bus is proposed, executed by a resistor matching device of a first controller, comprising: responding to a second controller self-identifying as a terminal node and connecting a first resistor, and mutually recognizing with the second controller; performing multi-dimensional evaluation of the communication quality of the CAN bus; when the communication quality of the CAN bus is less than a quality threshold, determining the impedance deviation rate of the CAN bus based on the evaluation parameters of the communication quality; and adjusting the resistance value of the first resistor and the resistance value of the second resistor of the first controller based on the impedance deviation rate, so that the communication quality of the CAN bus is less than or equal to the quality threshold.
[0005] In some embodiments, the communication quality evaluation parameters include bit error rate and packet loss rate. The impedance deviation rate includes a first impedance deviation rate corresponding to the bit error rate and a second impedance deviation rate corresponding to the packet loss rate. Adjusting the resistance value of the first resistor and the resistance value of the second resistor of the first controller based on the impedance deviation rate to make the communication quality of the CAN bus less than or equal to a quality threshold includes: determining the adjustment step size of the resistance value of the first resistor and the resistance value of the second resistor based on the threshold range corresponding to the first impedance deviation rate and the second impedance deviation rate; and adjusting the resistance value of the first resistor and the resistance value of the second resistor based on the adjustment step size to make the first impedance deviation rate less than the first threshold and the second impedance deviation rate less than the second threshold.
[0006] In some embodiments, determining the adjustment step size of the resistance value of the first resistor and the resistance value of the second resistor based on the threshold range corresponding to the first impedance deviation rate and the second impedance deviation rate includes: when both the first impedance deviation rate and the second impedance deviation rate are less than or equal to a third threshold, determining the adjustment step size as a first step size, where the third threshold is greater than the first threshold and the second threshold; when the first impedance deviation rate is greater than the third threshold and less than or equal to a fourth threshold, or when the second impedance deviation rate is greater than the third threshold and less than or equal to the fourth threshold, determining the adjustment step size as a second step size, where the second step size is greater than the first step size; and when both the first impedance deviation rate and the second impedance deviation rate are greater than the fourth threshold, determining the adjustment step size as a third step size, where the third step size is greater than the second step size.
[0007] In some embodiments, mutual recognition with the second controller includes: receiving a first message sent by the second controller; verifying the first message and sending a second message to the second controller; and in response to the second controller verifying the second message, receiving a third message sent by the second controller to complete mutual recognition.
[0008] In some embodiments, an alarm is triggered in response to mutual recognition with multiple second controllers to adjust the number of second controllers to one.
[0009] In some embodiments, the multi-dimensional evaluation of the communication quality of the CAN bus includes: sending multiple frames of fourth messages to the second controller; in response to the second controller verifying each frame of the fourth message in the multiple frames of fourth messages, receiving a fifth message sent by the second controller for each frame of the fourth message; and performing a multi-dimensional evaluation of the communication quality of the CAN bus based on the multiple frames of fourth messages and the multiple frames of fifth messages.
[0010] In some embodiments, the multi-dimensional evaluation of the communication quality of the CAN bus based on multiple fourth and fifth frames includes: determining whether each fifth frame in the multiple fifth frames is an erroneous frame; counting the number of erroneous frames and the number of frames not returned corresponding to the multiple fourth frames; calculating the bit error rate based on the number of erroneous frames; and calculating the packet loss rate based on the number of frames not returned.
[0011] In some embodiments, each frame of the fourth message includes a first message sequence number, a random number, a check value, and a first timestamp, and each frame of the fifth message includes a corresponding frame of the fourth message, a second timestamp, and a second message sequence number. Determining whether each frame of the fifth message is an erroneous frame includes: for each frame of the fifth message, determining whether the first message sequence number and the second message sequence number match; determining whether the message content has been tampered with based on the random number and the check value; determining whether there is a return timeout based on the difference between the first timestamp and the second timestamp; and determining that the fifth message is an erroneous frame if the first message sequence number and the second message sequence number do not match, or the message content has been tampered with, or there is a return timeout.
[0012] According to a second aspect of this disclosure, a resistor matching device for a control local area network (CAN) bus is also proposed, located in a first controller, comprising: an authentication module configured to mutually recognize a second controller as a terminal node and connect a first resistor in response to the second controller's self-identification; an evaluation module configured to perform multi-dimensional evaluation of the communication quality of the CAN bus; a communication quality determination module configured to determine the impedance deviation rate of the CAN bus based on the evaluation parameters of the communication quality when the communication quality of the CAN bus is less than a quality threshold; and an adjustment module configured to adjust the resistance value of the first resistor and the resistance value of the second resistor of the first controller based on the impedance deviation rate, so that the communication quality of the CAN bus is less than or equal to the quality threshold.
[0013] According to a third aspect of this disclosure, a resistor matching device for controlling a local area network (CAN) bus is also proposed, located in a first controller, comprising: a processor; and a memory coupled to the processor for storing instructions, which, when executed by the processor, cause the processor to perform the CAN bus resistor matching method as described above.
[0014] According to a fourth aspect of this disclosure, a first controller is also provided, comprising: a resistor matching device for the CAN bus of claim 9 or 10; a DIP switch electrically connected to the resistor matching device and configured to detect the type of the first controller; a matching resistor access circuit electrically connected to the resistor matching device and the CAN bus and configured to adjust the resistance accessed to the CAN bus; and a CAN transceiver electrically connected to the resistor matching device and the CAN bus and configured to interact with a second controller.
[0015] In some embodiments, the matching resistor connection circuit includes: a digital potentiometer connected to a first line of the CAN bus and configured to adjust the resistance value; and a digital switch connected to a second line of the CAN bus and configured to control the switching on and off of the digital potentiometer and the CAN bus.
[0016] According to a fifth aspect of this disclosure, a resistor matching system for a CAN bus is also proposed, comprising: the first controller described above; and a plurality of second controllers, wherein the plurality of second controllers includes a terminal node and a plurality of intermediate nodes.
[0017] According to the sixth aspect of this disclosure, a building automation system is also proposed, comprising: the aforementioned CAN bus resistor matching system.
[0018] According to the seventh aspect of this disclosure, a computer-readable storage medium is also provided, on which computer instructions are stored, wherein the computer instructions, when executed by a processor, implement the above-described CAN bus resistor matching method.
[0019] According to the eighth aspect of this disclosure, a computer program product is also proposed, comprising: computer instructions that, when executed by a processor, implement the above-described CAN bus resistor matching method.
[0020] In this embodiment, by automatically identifying terminal nodes, dynamically establishing communication links, quantitatively evaluating communication quality, and adjusting the matching resistor in a closed loop, adaptive impedance matching is achieved. This effectively solves the problems of traditional fixed 120Ω terminal resistors being unable to adapt to cable impedance deviations, temperature drift, and aging during long-term operation. It can effectively suppress signal reflection, significantly improve signal integrity, and ensure the stability of high-speed and long-distance communication, which is of great significance for improving system reliability and deployment efficiency.
[0021] Other features and advantages of this disclosure will become clear from the following detailed description of exemplary embodiments with reference to the accompanying drawings. Attached Figure Description
[0022] The accompanying drawings, which form part of this specification, illustrate embodiments of this disclosure and, together with the specification, serve to explain the principles of this disclosure.
[0023] This disclosure will become clearer with reference to the accompanying drawings and the following detailed description, wherein:
[0024] Figure 1 This is a schematic flowchart illustrating some embodiments of the CAN bus resistance matching method disclosed herein;
[0025] Figure 2 The following are schematic flowcharts illustrating other embodiments of the CAN bus resistance matching method disclosed herein;
[0026] Figure 3 Block diagrams of some embodiments of the resistor matching device for the CAN bus of this disclosure;
[0027] Figure 4 Block diagrams of some embodiments of the electronic devices disclosed herein;
[0028] Figure 5 Block diagrams of some embodiments of the first controller of this disclosure;
[0029] Figure 6 The diagram shows the structure of some embodiments of the matching resistor connection circuit of this disclosure.
[0030] Figure 7 This is a schematic diagram of the structure of some embodiments of the CAN bus resistor matching system disclosed herein. Detailed Implementation
[0031] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present disclosure.
[0032] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.
[0033] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this disclosure or its application or use.
[0034] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0035] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.
[0036] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0037] To make the objectives, technical solutions, and advantages of this disclosure clearer, the following detailed description is provided in conjunction with specific embodiments and the accompanying drawings.
[0038] Temperature drift and cable aging are factors that directly cause changes in the characteristic impedance of the CAN bus cable itself. While complex topology itself does not change the impedance of individual cables, it will cause equivalent impedance distortion and discontinuity in the entire communication link. The combination of these three factors will cause the actual impedance of the bus to deviate significantly from the standard value, which is the key reason why fixed terminating resistors cannot be adapted to impedance matching.
[0039] Currently, the characteristic impedance requirement for standard CAN bus communication cables is 120Ω ± 10%, which is between 108Ω and 132Ω. However, the terminating resistor in building automation systems is usually a fixed value of 120Ω, and its configuration generally relies on manual operation. Mainstream controllers typically use DIP switches or jumpers to connect and disconnect the 120Ω terminating resistor.
[0040] The aforementioned single-resistance matching method is clearly unable to dynamically adapt to real-world factors such as cable impedance changes, temperature drift, aging, and complex topologies, especially in high-speed or long-distance scenarios, leading to a decline in signal integrity. Furthermore, this manual method of directly connecting the matching resistor requires installers to adjust each device individually during system commissioning. This is particularly problematic in large buildings involving dozens or even hundreds of nodes, making the operation cumbersome and error-prone, resulting in extended construction periods and increased maintenance costs.
[0041] This disclosure provides a resistor matching method for a CAN bus, which can effectively solve the problems of traditional fixed 120Ω terminating resistors being unable to adapt to cable impedance deviations, temperature drift, and aging during long-term operation. The solution of this disclosure will be described below with reference to specific embodiments.
[0042] like Figure 1 As shown, Figure 1 This is a flowchart illustrating some embodiments of the CAN bus resistance matching method disclosed herein. Figure 1 The resistor matching method of the CAN bus is executed by the resistor matching device of the first controller, which is the first node, i.e. the first end controller. The resistor matching device is the main control board, the main control chip or the main control unit. The resistor matching method of the CAN bus includes steps S11-S14.
[0043] In step S11, in response to the second controller self-identifying as a terminal node and connecting to the first resistor, mutual recognition is performed with the second controller.
[0044] The second controller is another controller connected to the CAN bus, excluding the first controller.
[0045] After the system powers on, it enters the initialization phase. The first controller and each of the second controllers detect their own roles via a DIP switch, for example, a single-position DIP switch. When the DIP switch is "ON", the system is identified as a terminal node; when it is "OFF", the system is identified as an intermediate node.
[0046] The first resistor of the second controller is connected to or disconnected from the CAN bus via a digital switch. Terminal nodes are connected to the CAN bus via digital switches; for example, the initial connection resistor is 120Ω. Intermediate nodes' resistors are disconnected from the CAN bus via digital switches. In some embodiments, the resistance value is adjusted by a programmable digital potentiometer. This potentiometer has a total resistance range covering 1kΩ, supports resolutions of 1024 levels or higher, receives control commands via an IIC digital interface, and configures the internal resistor network to the tap position corresponding to 120Ω.
[0047] In some embodiments, the terminal node actively occupies the CAN bus, for example, by sending a bus occupancy request frame to the first node. After successful occupancy, the first controller and the second controller complete bidirectional mutual recognition based on the self-identification message and the acknowledgment message, verify the integrity of the bus link between the two, and identify whether the DIP switch configuration is incorrect, thereby facilitating the subsequent resistor matching process.
[0048] In step S12, the communication quality of the CAN bus is evaluated from multiple dimensions.
[0049] After mutual recognition is completed, the first node evaluates the communication quality of the CAN bus from multiple dimensions, achieving accurate perception of the communication status and improving the accuracy of communication quality assessment.
[0050] In step S13, if the communication quality of the CAN bus is less than the quality threshold, the impedance deviation rate of the CAN bus is determined based on the evaluation parameters of the communication quality.
[0051] If the communication quality is poor, it indicates that the resistance values connected to both ends of the CAN bus do not match the characteristic impedance of the communication cable. Therefore, it is necessary to determine the impedance deviation rate of the CAN bus.
[0052] For example, the impedance deviation rate is defined to characterize the degree of deviation between the actual resistance value of the matching resistor and the standard impedance. , Impedance deviation rate =120Ω (standard characteristic impedance of CAN bus). This represents the actual parallel resistance value of the matching resistors at the beginning and end of the circuit. Due to the adoption of a double-ended symmetrical matching architecture, = = , Match the resistance value at the first end. The end-matching resistor value.
[0053] In some embodiments, an impedance deviation rate is used to establish a quantitative correlation between the resistance value and the communication quality, thereby eliminating signal reflection.
[0054] In step S14, based on the impedance deviation rate, the resistance values of the first resistor and the second resistor of the first controller are adjusted so that the communication quality of the CAN bus is less than or equal to the quality threshold.
[0055] In this step, the resistance values at both ends of the CAN bus are dynamically adjusted according to the impedance deviation rate. For example, the master control unit of the first controller sends a control command to the digital interface of the first programmable digital potentiometer of the first controller, so that the first programmable digital potentiometer configures its internal resistance network to the tap position corresponding to the control command. The master control unit of the first controller sends a control command to the master control unit of the second controller, and the master control unit of the second controller continues to send a control command to the digital interface of the second programmable digital potentiometer of the second controller, so that the second programmable digital potentiometer configures its internal resistance network to the tap position corresponding to the control command, so that the communication quality of the CAN bus meets the quality requirements. At this time, it is indicated that the resistance values connected at both ends of the CAN bus match the characteristic impedance of the communication cable.
[0056] In the above embodiments, by automatically identifying terminal nodes, dynamically establishing communication links, quantitatively evaluating communication quality, and adjusting the matching resistor in a closed loop, adaptive impedance matching is achieved. This effectively solves the problems of traditional fixed 120Ω terminal resistors being unable to adapt to cable impedance deviations, temperature drift, and aging during long-term operation. It can effectively suppress signal reflection, significantly improve signal integrity, and ensure the stability of high-speed and long-distance communication, which is of great significance for improving system reliability and deployment efficiency.
[0057] In some embodiments, the communication quality evaluation parameters include bit error rate and packet loss rate. The impedance deviation rate includes a first impedance deviation rate corresponding to the bit error rate and a second impedance deviation rate corresponding to the packet loss rate. Adjusting the resistance value of a first resistor and the resistance value of a second resistor of the first controller based on the impedance deviation rate to make the communication quality of the CAN bus less than or equal to a quality threshold includes: determining the adjustment step size of the resistance values of the first resistor and the second resistor based on the threshold range corresponding to the first and second impedance deviation rates; and adjusting the resistance values of the first resistor and the second resistor based on the adjustment step size to make the first impedance deviation rate less than a first threshold and the second impedance deviation rate less than a second threshold. The first threshold and the second threshold can be the same or different.
[0058] The correlation between communication quality indicators and impedance deviation rate δ conforms to industrial measurement patterns, namely, the bit error rate increases exponentially with impedance deviation rate δ, and the packet loss rate increases linearly with impedance deviation rate δ. In some embodiments, a first impedance deviation rate is obtained based on the bit error rate, the base bit error rate, the error amplification factor, and the deviation sensitivity factor; a second impedance deviation rate is obtained based on the packet loss rate and the packet loss factor.
[0059] Specifically, the correlation formulas between the first impedance deviation rate, the second impedance deviation rate, and the communication quality indicators are as follows:
[0060]
[0061]
[0062] Through calculation, we obtain:
[0063]
[0064]
[0065] The first impedance deviation rate, For bit error rate, , The base error rate under ideal matching is negligible; This is the error amplification factor; when the bus length is ≤100m, =0.01; The deviation sensitivity coefficient is at a baud rate of 2 Mbps. =0.15, The second impedance deviation rate, For packet loss rate, The packet loss coefficient, =0.005.
[0066] In this embodiment, based on the threshold range corresponding to the first impedance deviation rate and the second impedance deviation rate, the step size is determined in stages, and then the resistance values at both ends of the CAN bus are adjusted based on the step size, so that the first impedance deviation rate is less than the first threshold and the second impedance deviation rate is less than the second threshold, that is, the communication quality meets the quality requirements. At this time, it is shown that the characteristic impedance of the CAN bus ends connected to the communication cable is matched. Through the staged decision, the accuracy and efficiency of the adjustment can be taken into account.
[0067] In some embodiments, determining the adjustment step size of the resistance value of the first resistor and the resistance value of the second resistor based on the threshold range corresponding to the first impedance deviation rate and the second impedance deviation rate includes: when both the first impedance deviation rate and the second impedance deviation rate are less than or equal to a third threshold, determining the adjustment step size as a first step size, where the third threshold is greater than the first threshold and the second threshold; when the first impedance deviation rate is greater than the third threshold and less than or equal to a fourth threshold, or when the second impedance deviation rate is greater than the third threshold and less than or equal to the fourth threshold, determining the adjustment step size as a second step size, where the second step size is greater than the first step size; and when both the first impedance deviation rate and the second impedance deviation rate are greater than the fourth threshold, determining the adjustment step size as a third step size, where the third step size is greater than the second step size.
[0068] For example, the third threshold is 5%, the fourth is 10%, when ≤5% and ≤5%, that is Within the range of 114Ω to 126Ω, fine-tuning is performed in 1Ω increments until... ≤0.1% and ≤0.05%. When 5% < ≤10% or 5% ≤10%, that is Within the range of 108Ω~114Ω or 126Ω~132Ω, use a 2Ω step adjustment. Extend the adjustment range to 110Ω~130Ω. First... Once the resistance drops below 5%, switch the adjustment step size to 1Ω. >10% and >10%, that is <108Ω or >132Ω, using a 5Ω step size for rapid approximation, first... Pull back to the 110Ω~130Ω range, and then reduce the step size according to the above steps.
[0069] Recalculate after each adjustment. , and This forms a closed-loop verification process to ensure the effectiveness of the adjustments.
[0070] In this embodiment, when adjusting the resistance values at both ends of the CAN bus, a large step size is used to quickly approach the reasonable range for large deviations, and a small step size is used to accurately converge for small deviations, avoiding the problem of "slow or overshooting" with a single step size; adapting to the rule that the larger the impedance deviation rate, the faster the communication quality deteriorates, prioritizing the control of large deviation risks, and then refining the adjustment; reducing the number of adjustments and bus overhead, reducing the hardware computing power burden, avoiding closed-loop oscillation, and balancing adjustment efficiency and accuracy.
[0071] In some embodiments, mutual recognition with the second controller includes: receiving a first message sent by the second controller; verifying the first message and sending a second message to the second controller; and in response to the second controller verifying the second message, receiving a third message sent by the second controller to complete mutual recognition.
[0072] For example, a terminal node actively occupies the CAN bus by sending a bus occupancy request frame to the head node using a unique ID (Identifier). Upon successful occupancy, it sends a self-identification message. The data segment of this self-identification message may include a node identifier and an encrypted verification code. The head node continuously listens for the self-identification message. Upon receiving the self-identification message from the terminal node, it verifies the verification code. If the verification passes, it sends an acknowledgment message to the terminal node. After receiving the acknowledgment message, the terminal node sends back a response frame, completing the two-way mutual recognition.
[0073] If the reconnection mechanism is activated within the scheduled time, it can be initiated. However, if multiple reconnection attempts fail, an alarm will be triggered. For example, if two-way mutual recognition is not completed within 100 seconds, the reconnection mechanism will be activated. If two-way mutual recognition is still not completed after three reconnection attempts, an alarm will be triggered.
[0074] In the above embodiments, the terminal node actively sends a self-identification message, and the first node achieves bidirectional mutual recognition by receiving and verifying the message, establishing a reliable communication link, which facilitates subsequent multi-dimensional evaluation of the communication quality of the CAN bus.
[0075] In some embodiments, an alarm is triggered in response to mutual recognition with multiple second controllers to adjust the number of second controllers to one.
[0076] For example, if the first node receives mutual recognition requests from two or more terminal nodes, it indicates an error in the DIP switch configuration in the link. This triggers an alarm and reports the terminal node IDs to the visualization development platform, allowing manual adjustment of the incorrectly configured intermediate nodes. Since the CAN bus only requires resistors at both ends, redundant terminal nodes with incorrectly configured DIP switches need to be adjusted to intermediate nodes, ensuring that the CAN bus physical layer design complies with the ISO 11898-2 standard. In this embodiment, the system automatically detects and determines the number of terminal resistor configurations, enabling precise location and alarm of misconfigured devices. It supports remote monitoring and status reporting, giving the system self-diagnostic capabilities, thereby reducing error rates and maintenance costs.
[0077] In some embodiments, the multi-dimensional evaluation of the communication quality of the CAN bus includes: sending multiple frames of fourth messages to the second controller; in response to the second controller verifying each frame of the fourth message in the multiple frames of fourth messages, receiving a fifth message sent by the second controller for each frame of the fourth message; and performing a multi-dimensional evaluation of the communication quality of the CAN bus based on the multiple frames of fourth messages and the multiple frames of fifth messages.
[0078] For example, the first node sends 100 CAN test messages, with message IDs dynamically generated from the node identifier and sequence number to ensure uniqueness. After receiving the CAN test messages, the terminal nodes verify them. If the verification passes, parameters are added to the data segment of the CAN test message as a return message. Before sending the return message, the terminal nodes can occupy the bus to avoid collisions. By analyzing multiple CAN test messages and multiple return messages, the communication quality of the CAN bus can be evaluated from multiple dimensions, accurately determining the communication quality and facilitating subsequent resistor adjustments at both ends of the CAN bus.
[0079] In some embodiments, the multi-dimensional evaluation of the communication quality of the CAN bus based on multiple fourth and fifth frames includes: determining whether each fifth frame in the multiple fifth frames is an erroneous frame; counting the number of erroneous frames and the number of frames not returned corresponding to the multiple fourth frames; calculating the bit error rate based on the number of erroneous frames; and calculating the packet loss rate based on the number of frames not returned.
[0080] For example, the number of erroneous frames and non-returned frames in a 100-frame test can be counted to calculate the bit error rate and packet loss rate.
[0081] Specifically, Of which, the total number of frames sent ( The number of test messages continuously sent by the first node is 100 frames. The bit error rate is determined by calculating the ratio of the number of erroneous frames to the total number of frames sent.
[0082] The total number of frames sent ( ) represents the total number of test messages continuously sent by the first node, for example, 100 frames; the number of frames not received ( ) = Total number of frames sent ( - Number of successfully received return frames () ),in, The number of valid return frames received by the first node within the specified timeout period (≤100ms).
[0083] For example, when the bit error rate exceeds 0.1% or the packet loss rate exceeds 0.05%, the system initiates a dynamic adjustment process for the matching resistor.
[0084] In the above embodiments, the communication quality of the CAN bus can be determined by calculating the bit error rate and packet loss rate. By periodically detecting the communication quality of the CAN bus, a data basis can be provided for subsequent adjustment of the resistor value, thereby achieving adaptive impedance matching.
[0085] In some embodiments, each frame of the fourth message includes a first message sequence number, a random number, a check value, and a first timestamp, and each frame of the fifth message includes a corresponding frame of the fourth message, a second timestamp, and a second message sequence number. Determining whether each frame of the fifth message is an erroneous frame includes: for each frame of the fifth message, determining whether the first message sequence number and the second message sequence number match; determining whether the message content has been tampered with based on the random number and the check value; determining whether there is a return timeout based on the difference between the first timestamp and the second timestamp; and determining that the fifth message is an erroneous frame if the first message sequence number and the second message sequence number do not match, or the message content has been tampered with, or there is a return timeout.
[0086] For example, the data segment of the CAN test message sent by the first node includes a message sequence number, a hardware random number, a CRC32 checksum, and a transmission timestamp, which can be at the microsecond level of precision. The terminal node verifies the frame format and data integrity of the received CAN test message. If the verification passes, the terminal node adds a receiving timestamp to the data segment of the CAN test message to form a return message, and uses the reversed sequence number as the return identifier, transmitting it back to the first node via the CAN bus. This reversed sequence number is a logically reversed identifier; for example, if the original sequence number is 1 / 2 / 3, the return sequence number is 100 / 99 / 98; or if the original sequence number is N, the return sequence number = total number of frames - N + 1. Alternatively, a fixed offset value (such as the original sequence number + 1000) can be added to the original sequence number as the return identifier.
[0087] After receiving the returned message, the first node compares the returned sequence number with the original sequence number to determine if they match. This allows the first node to quickly identify the frame as the returned frame of the corresponding test message, achieving rapid pairing of the original and returned frames. Simultaneously, it performs an initial frame correspondence check to avoid confusion with other messages on the bus, improving the efficiency of the first node's evaluation. It also verifies the random number and CRC32 value to check for data tampering; calculates the difference between the sending and receiving timestamps to determine if the delay exceeds 100μs; and considers any frame as an erroneous frame if it meets any error type. Then, the number of erroneous frames and non-returned frames in the 100-frame test are counted, and the bit error rate and packet loss rate are calculated.
[0088] In this embodiment, by continuously sending test messages, the communication quality is quantitatively evaluated from multiple dimensions such as sequence number matching, data verification, timing delay, bit error rate and packet loss rate, so as to achieve accurate perception of the communication status.
[0089] The specific implementation of the resistance matching method of this disclosure will now be described in conjunction with the accompanying drawings.
[0090] like Figure 2 As shown, Figure 2 The following is a flowchart illustrating some other embodiments of the CAN bus resistance matching method disclosed herein, including steps S21-S215.
[0091] In step S21, each node reads the DIP switch status. If the status is OFF, then step S22 is executed; if the status is ON, then step S23 is executed.
[0092] In step S22, the node is identified as an intermediate node, and the matching resistor is disconnected.
[0093] In step S23, the node is identified as a terminal node, and a matching resistor is connected with an initial resistance value of 120Ω.
[0094] The above steps S21-S23 realize the self-identification of nodes, automatically identify terminal nodes through the DIP switch status and complete the initial matching resistor value setting.
[0095] In step S24, the terminal node sends a self-identification message.
[0096] In step S25, the first node receives and verifies the message. If the verification fails, step S26 is executed; if the verification succeeds, step S28 is executed.
[0097] In step S26, the reconnection mechanism is activated to determine whether the number of reconnections is greater than 3. If so, step S27 is executed; otherwise, step S25 is executed.
[0098] In step S27, an alarm is triggered.
[0099] In step S28, determine whether the number of terminal nodes is 1. If it is not 1, proceed to step S29. If it is 1, proceed to step S210.
[0100] In step S29, an alarm is triggered and node information is uploaded.
[0101] Steps S24-S29 above enable bidirectional mutual recognition between nodes. The terminal node actively sends a self-identification message, and the first node achieves bidirectional mutual recognition by receiving and verifying the message.
[0102] In step S210, the first node sends 100 test frames.
[0103] In step S211, it is determined whether the bit error rate is greater than 0.1% or the packet loss rate is greater than 0.05%. If so, step S212 is executed; otherwise, the system enters the stable operation phase.
[0104] After the system reaches a stable operating phase, the first node automatically sends 50 simplified test frames every 10 minutes to periodically check the communication quality. If the bit error rate... or packet loss rate If the signal increases, the adjustment process will be automatically triggered; if the adjustment fails three times in a row, an alarm message will be sent to the monitoring system and the alarm indicator light will be illuminated.
[0105] In step S212, the impedance deviation rate is calculated.
[0106] In step S213, the resistance values at both ends of the CAN bus are dynamically adjusted in graded steps based on the impedance deviation rate.
[0107] In step S214, the first node sends the step size and adjustment instructions to the terminal node.
[0108] In step S215, the matching resistors of the first node and the terminal node are adjusted, and then step S210 is executed.
[0109] Steps S210-S215 implement dynamic communication evaluation and precise adjustment of the matching resistor. After the first node sends a test message and the terminal node returns it, the first node evaluates the communication quality based on sequence number matching, data verification, timing delay, bit error rate, and packet loss rate. The matching resistor value is adjusted in stages according to the impedance deviation rate, and combined with periodic detection for dynamic adjustment, achieving adaptive impedance matching and improving system reliability and deployment efficiency.
[0110] In the above embodiments, a complete hardware and software collaborative closed-loop mechanism is formed by automatically identifying terminal nodes and setting initial matching resistor values through DIP switch status, establishing communication links through bidirectional node mutual recognition, evaluating communication quality by judging the accuracy of multi-dimensional test messages, and achieving precise resistance adjustment using a precision digital potentiometer. The system eliminates the need for manual measurement of bus length or configuration of terminal resistors, possessing plug-and-play capability and significantly reducing deployment complexity and error rates. Simultaneously, this mechanism effectively adapts to cable impedance deviations, temperature drift, and aging effects during long-term operation, achieving adaptive impedance matching. In complex topologies and long-distance communication scenarios such as large-scale building automation and industrial automation, it significantly improves communication stability and system reliability. This technology can greatly shorten system deployment cycles, reduce error rates and maintenance costs, and promote the development of building automation systems towards intelligence and maintenance-free operation, demonstrating significant technological advancement and broad engineering application value.
[0111] In some embodiments, the system supports manual intervention by the host computer, which can force the start of adjustment or read real-time resistance and communication status parameters to meet debugging and maintenance needs.
[0112] The above is an introduction to the resistance matching method of the CAN bus. Below, we will further introduce the resistance matching device of the CAN bus with reference to the attached diagram. The resistance matching device of the CAN bus is located in the first controller, i.e., the first node.
[0113] Figure 3 The diagram shows some embodiments of a resistor matching device for a CAN bus disclosed herein, which may be a main control board, a main control chip, or a main control unit, including an authentication module 31, an evaluation module 32, a communication quality determination module 33, and an adjustment module 34.
[0114] The authentication module 31 is configured to mutually recognize the second controller in response to the second controller automatically recognizing it as a terminal node and connecting to the first resistor. The evaluation module 32 is configured to perform a multi-dimensional evaluation of the communication quality of the CAN bus. The communication quality determination module 33 is configured to determine the impedance deviation rate of the CAN bus based on the communication quality evaluation parameters when the communication quality of the CAN bus is less than a quality threshold. The adjustment module 34 is configured to adjust the resistance value of the first resistor and the resistance value of the second resistor of the first controller based on the impedance deviation rate, so that the communication quality of the CAN bus is less than or equal to the quality threshold.
[0115] In this embodiment, by automatically identifying terminal nodes, dynamically establishing communication links, quantitatively evaluating communication quality, and adjusting the matching resistor in a closed loop, adaptive impedance matching is achieved. This effectively solves the problems of traditional fixed 120Ω terminal resistors being unable to adapt to cable impedance deviations, temperature drift, and aging during long-term operation. It can effectively suppress signal reflection, significantly improve signal integrity, and ensure the stability of high-speed and long-distance communication, which is of great significance for improving system reliability and deployment efficiency.
[0116] In some embodiments, the communication quality evaluation parameters include bit error rate and packet loss rate, and the impedance deviation rate includes a first impedance deviation rate corresponding to the bit error rate and a second impedance deviation rate corresponding to the packet loss rate. The adjustment module 34 is configured to determine the adjustment step size of the resistance value of the first resistor and the resistance value of the second resistor based on the threshold range corresponding to the first impedance deviation rate and the second impedance deviation rate; and adjust the resistance value of the first resistor and the resistance value of the second resistor based on the adjustment step size so that the first impedance deviation rate is less than the first threshold and the second impedance deviation rate is less than the second threshold.
[0117] In this embodiment, based on the threshold range corresponding to the first impedance deviation rate and the second impedance deviation rate, the step size is determined in stages, and then the resistance values at both ends of the CAN bus are adjusted based on the step size, so that the first impedance deviation rate is less than the first threshold and the second impedance deviation rate is less than the second threshold, that is, the communication quality meets the quality requirements. At this time, it is shown that the characteristic impedance of the CAN bus ends connected to the communication cable is matched. Through the staged decision, the accuracy and efficiency of the adjustment can be taken into account.
[0118] In some embodiments, the adjustment module 34 is configured to: determine an adjustment step size of a first step size when both the first impedance deviation rate and the second impedance deviation rate are less than or equal to a third threshold, wherein the third threshold is greater than the first threshold and the second threshold; determine an adjustment step size of a second step size when the first impedance deviation rate is greater than the third threshold and less than or equal to a fourth threshold, or when the second impedance deviation rate is greater than the third threshold and less than or equal to the fourth threshold, wherein the second step size is greater than the first step size; and determine an adjustment step size of a third step size when both the first impedance deviation rate and the second impedance deviation rate are greater than the fourth threshold, wherein the third step size is greater than the second step size.
[0119] In this embodiment, when adjusting the resistance values at both ends of the CAN bus, a large step size is used to quickly approach the reasonable range for large deviations, and a small step size is used to accurately converge for small deviations, avoiding the problem of "slow or overshooting" with a single step size; adapting to the rule that the larger the impedance deviation rate, the faster the communication quality deteriorates, prioritizing the control of large deviation risks, and then refining the adjustment; reducing the number of adjustments and bus overhead, reducing the hardware computing power burden, avoiding closed-loop oscillation, and balancing adjustment efficiency and accuracy.
[0120] In some embodiments, the authentication module 31 is configured to receive a first message sent by the second controller; verify the first message and send a second message to the second controller; and in response to the second controller verifying the second message, receive a third message sent by the second controller to complete mutual recognition.
[0121] In this embodiment, bidirectional mutual recognition is achieved by receiving and verifying messages, establishing a reliable communication link, which facilitates subsequent multi-dimensional evaluation of the communication quality of the CAN bus.
[0122] In some embodiments, the authentication module 31 is further configured to trigger an alarm in response to mutual recognition with multiple second controllers, so as to adjust the number of second controllers to one. In this embodiment, the number of terminal resistor configurations is automatically detected and determined to achieve accurate location and alarm of misconfigured devices.
[0123] In some embodiments, the evaluation module 32 is configured to send multiple frames of fourth messages to the second controller; in response to the second controller verifying each frame of the fourth message in the multiple frames of fourth messages, receive a fifth message sent by the second controller for each frame of the fourth message; and perform a multi-dimensional evaluation of the communication quality of the CAN bus based on the multiple frames of fourth messages and the multiple frames of fifth messages.
[0124] In this embodiment, the communication quality of the CAN bus is evaluated from multiple dimensions, which can accurately determine the communication quality and facilitate the subsequent adjustment of the resistance values of the nodes at both ends of the CAN bus.
[0125] In some embodiments, the evaluation module 32 is configured to determine whether each fifth message in the multi-frame fifth message is an erroneous frame; count the number of erroneous frame messages and the number of non-returned frame messages corresponding to the multi-frame fourth messages; calculate the bit error rate based on the number of erroneous frame messages; and calculate the packet loss rate based on the number of non-returned frame messages.
[0126] In the above embodiments, the communication quality of the CAN bus can be determined by calculating the bit error rate and packet loss rate. By periodically detecting the communication quality of the CAN bus, a data basis can be provided for subsequent adjustment of the resistor value, thereby achieving adaptive impedance matching.
[0127] In some embodiments, each frame of the fourth message includes a first message sequence number, a random number, a check value, and a first timestamp, and each frame of the fifth message includes a corresponding frame of the fourth message, a second timestamp, and a second message sequence number. The evaluation module 32 is configured to, for each frame of the fifth message, determine whether the first message sequence number and the second message sequence number match; determine whether the message content has been tampered with based on the random number and the check value; determine whether there is a return timeout based on the difference between the first timestamp and the second timestamp; and determine that the fifth message is an erroneous frame if the first message sequence number and the second message sequence number do not match, or the message content has been tampered with, or there is a return timeout.
[0128] In this embodiment, by continuously sending test messages, the communication quality is quantitatively evaluated from multiple dimensions such as sequence number matching, data verification, timing delay, bit error rate and packet loss rate, so as to achieve accurate perception of the communication status.
[0129] It should be noted that the above modules are logical modules divided according to their specific functions, and are not used to restrict the specific implementation method. For example, they can be implemented in software, hardware, or a combination of software and hardware. In actual implementation, the above modules can be implemented as independent physical entities, or they can be implemented by a single entity (e.g., a processor (CPU or DSP, etc.), integrated circuit, etc.).
[0130] In some embodiments, the resistor matching device for the CAN bus can also be presented as an electronic device, for example, such as... Figure 4 As shown, Figure 4 This is a block diagram of some embodiments of the electronic device disclosed herein. The electronic device 4 includes a memory 41 and a processor 42. The memory 41 may be a disk, flash memory, or any other non-volatile storage medium. The memory is used to store instructions in the above embodiments. The processor 42 is coupled to the memory 41 and may be implemented as one or more integrated circuits, such as a microprocessor or microcontroller. The processor 42 is used to execute the instructions stored in the memory.
[0131] In some embodiments, the processor 42 is coupled to the memory 41 via a BUS bus 4. The electronic device 4 can also be connected to an external storage device 45 via a storage interface 44 to access external data, and can also be connected to a network or another computer system (not shown) via a network interface 46. Further details are omitted here.
[0132] In this embodiment, the electronic device stores data instructions in a memory and processes the instructions through a processor, which can effectively adapt to cable impedance deviation, temperature drift and aging effects during long-term operation, and achieve adaptive impedance matching.
[0133] Figure 5The diagram below shows some embodiments of the first controller disclosed herein. The first controller includes a CAN bus resistor matching device 51 as described in the above embodiments. The CAN bus resistor matching device is, for example, a high-performance microcontroller that supports high-speed communication and real-time response. It also includes a DIP switch 52, a matching resistor access circuit 53, and a CAN transceiver 54.
[0134] The resistor matching device 51 has been described in detail in the above embodiments and will not be further elaborated here. The DIP switch 52 is electrically connected to the resistor matching device and is configured to detect the type of the first controller; the matching resistor access circuit 53 is electrically connected to the resistor matching device and the CAN bus and is configured to adjust the resistance connected to the CAN bus; the CAN transceiver 54 is electrically connected to the resistor matching device and the CAN bus and is configured to interact with the second controller.
[0135] In this embodiment, the hardware structure of the first controller relies on the main control chip and CAN transceiver, combined with a DIP switch and a matching resistor connected to the circuit, which facilitates integration with the software program to achieve adaptive matching of the CAN bus impedance.
[0136] In some embodiments, the matching resistor connection circuit includes: a digital potentiometer connected to a first line of the CAN bus and configured to adjust the resistance value; and a digital switch connected to a second line of the CAN bus and configured to control the switching on and off of the digital potentiometer and the CAN bus.
[0137] In this embodiment, the matching resistor access circuit realizes the on / off function through a digital switch, so that the digital potentiometer can be connected to or disconnected from the CAN bus. For example, the total resistance range of the digital potentiometer covers 1kΩ, supports a resolution of 1024 levels or more, and receives control commands through the IIC digital interface.
[0138] like Figure 6 As shown, Figure 6 This is a schematic diagram of some embodiments of the matching resistor connection circuit disclosed herein. The matching resistor connection circuit includes a digital potentiometer 61 and a digital switch 62. The digital potentiometer 61 is a programmable digital potentiometer, with one end connected to the CAN_H line and the other end connected to the CAN_L line via the digital switch 62, forming a series matching structure. The digital potentiometer 61 receives control commands from the main control unit through the IIC digital interface, and the digital switch 62 implements the on / off function through the GPIO (General Purpose Input / Output) interface.
[0139] In some embodiments, a CAN bus resistor matching system is protected, the CAN bus resistor matching system including the first controller described above, and further including a plurality of second controllers, the plurality of second controllers including a terminal node and a plurality of intermediate nodes.
[0140] The second controller also includes a main control unit, a DIP switch, a matching resistor connection circuit, and a CAN transceiver. The main control unit in the second controller is used to receive instructions from the first controller and send instructions to the DIP switch, the matching resistor connection circuit, and the CAN transceiver.
[0141] like Figure 7 As shown, Figure 7 This diagram illustrates the structure of some embodiments of the CAN bus resistor matching system disclosed herein. Multiple controllers, such as controller 1…controller N, are connected to the CAN bus, where controller 1 is the first node and controller N is the terminal node. Each controller includes a controller main board, a DIP switch, a matching resistor connection circuit, and a CAN transceiver. The controller main board and the CAN transceiver can interact via UART (Universal Asynchronous Receiver / Transmitter).
[0142] This system relies on a hardware architecture and employs a software-built closed-loop mechanism. Its core software component focuses on constructing a closed-loop control system encompassing "automatic identification—two-way mutual recognition—multi-dimensional evaluation—closed-loop adjustment." Specifically, it achieves adaptive impedance matching through a combination of hardware and software, eliminating the need for manual bus length measurement or terminating resistor configuration. This plug-and-play capability significantly reduces deployment complexity and error rates. Furthermore, this mechanism effectively adapts to cable impedance deviations, temperature drift, and aging effects during long-term operation, achieving adaptive impedance matching. In complex topologies and long-distance communication scenarios such as large-scale building automation and industrial automation, it significantly improves communication stability and system reliability, demonstrating outstanding technological advancement and broad engineering application value.
[0143] In other embodiments, a building automation system is protected, which includes the CAN bus resistor matching system described in the above embodiments, and can promote the development of building automation systems towards intelligence and maintenance-free operation.
[0144] In other embodiments, this application provides a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implement the steps of the methods described above. Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable non-transitory storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0145] In some embodiments, a computer program product is protected, comprising a computer program or instructions that, when executed by a processor, implement the methods described above. The computer program product includes a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from ROM. When the computer program is executed by a CPU, it performs the functions defined in the methods of embodiments of this disclosure.
[0146] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0147] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0148] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0149] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0150] This concludes the detailed description of the present disclosure. To avoid obscuring the concept of the disclosure, some details known in the art have not been described. Those skilled in the art will fully understand how to implement the technical solutions disclosed herein based on the above description.
[0151] The methods and apparatus of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.
[0152] While specific embodiments of this disclosure have been described in detail by way of example, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of this disclosure. Those skilled in the art should understand that modifications can be made to the above embodiments without departing from the scope and spirit of this disclosure. The scope of this disclosure is defined by the appended claims.
Claims
1. A resistor matching method for a control local area network (CAN) bus, executed by a resistor matching device of a first controller, comprising: In response to the second controller recognizing itself as a terminal node and connecting to the first resistor, mutual recognition is established with the second controller; The communication quality of the CAN bus is evaluated from multiple dimensions. If the communication quality of the CAN bus is less than a quality threshold, the impedance deviation rate of the CAN bus is determined based on the evaluation parameters of the communication quality. Based on the impedance deviation rate, the resistance values of the first resistor and the second resistor of the first controller are adjusted so that the communication quality of the CAN bus is less than or equal to the quality threshold.
2. The resistance matching method according to claim 1, wherein, The communication quality evaluation parameters include bit error rate and packet loss rate. The impedance deviation rate includes a first impedance deviation rate corresponding to the bit error rate and a second impedance deviation rate corresponding to the packet loss rate. Based on the impedance deviation rate, adjusting the resistance value of the first resistor and the resistance value of the second resistor of the first controller to make the communication quality of the CAN bus less than or equal to the quality threshold includes: Based on the threshold ranges corresponding to the first impedance deviation rate and the second impedance deviation rate, the adjustment step size of the resistance value of the first resistor and the resistance value of the second resistor is determined. Based on the adjustment step size, the resistance values of the first resistor and the second resistor are adjusted so that the first impedance deviation rate is less than a first threshold and the second impedance deviation rate is less than a second threshold.
3. The resistance matching method according to claim 2, wherein, Based on the threshold ranges corresponding to the first impedance deviation rate and the second impedance deviation rate, determining the adjustment step size of the resistance values of the first resistor and the second resistor includes: When both the first impedance deviation rate and the second impedance deviation rate are less than or equal to the third threshold, the adjustment step size is determined to be the first step size, and the third threshold is greater than the first threshold and the second threshold. If the first impedance deviation rate is greater than the third threshold and less than or equal to the fourth threshold, or if the second impedance deviation rate is greater than the third threshold and less than or equal to the fourth threshold, the adjustment step size is determined to be the second step size, which is greater than the first step size. If both the first impedance deviation rate and the second impedance deviation rate are greater than the fourth threshold, the adjustment step size is determined to be the third step size, which is greater than the second step size.
4. The resistance matching method according to claim 1, wherein, Mutual recognition with the second controller includes: Receive the first message sent by the second controller; After verifying the first message, a second message is sent to the second controller. In response to the second controller verifying the second message, a third message sent by the second controller is received to complete the mutual recognition.
5. The resistance matching method according to claim 1, further comprising: In response to mutual recognition with multiple second controllers, an alarm is triggered to adjust the number of second controllers to one.
6. The resistance matching method according to claim 1, wherein, A multi-dimensional evaluation of the communication quality of the CAN bus includes: Send multiple frames of fourth messages to the second controller; In response to the second controller verifying each of the fourth frames in the multi-frame fourth messages, the system receives the fifth message sent by the second controller for each of the fourth frames. Based on the multiple frames of fourth and fifth messages, the communication quality of the CAN bus is evaluated from multiple dimensions.
7. The resistance matching method according to claim 6, wherein, Based on the multiple frames of fourth and fifth messages, a multi-dimensional evaluation of the communication quality of the CAN bus is performed, including: Determine whether each of the five frames in the multi-frame fifth message is an erroneous frame; Count the number of erroneous frames and the number of frames not returned corresponding to the fourth message of the multiple frames; Calculate the bit error rate based on the number of erroneous frame packets; The packet loss rate is calculated based on the number of frames that were not returned.
8. The resistance matching method according to claim 7, wherein, Each frame's fourth message includes a first message sequence number, a random number, a checksum, and a first timestamp. Each frame's fifth message includes a corresponding frame's fourth message, a second timestamp, and a second message sequence number. Determining whether each frame's fifth message is an erroneous frame includes: For the fifth message of each frame, determine whether the sequence number of the first message and the sequence number of the second message match; Based on the random number and the check value, determine whether the message content has been tampered with; Based on the difference between the first timestamp and the second timestamp, determine whether there is a timeout for the return transmission; If the sequence number of the first message and the sequence number of the second message do not match, or the message content is tampered with, or there is a timeout during the return transmission, the fifth message is determined to be an error frame.
9. A resistor matching device for controlling a local area network (CAN) bus, located in a first controller, comprising: The authentication module is configured to mutually recognize the second controller in response to the second controller automatically recognizing it as a terminal node and connecting to the first resistor; The evaluation module is configured to perform a multi-dimensional evaluation of the communication quality of the CAN bus; A communication quality determination module is configured to determine the impedance deviation rate of the CAN bus based on evaluation parameters of the communication quality when the communication quality of the CAN bus is less than a quality threshold. The adjustment module is configured to adjust the resistance value of the first resistor and the resistance value of the second resistor of the first controller based on the impedance deviation rate, so that the communication quality of the CAN bus is less than or equal to the quality threshold.
10. A resistor matching device for controlling a local area network (CAN) bus, located in a first controller, comprising: processor; as well as A memory coupled to the processor is used to store instructions that, when executed by the processor, cause the processor to perform the CAN bus resistor matching method as described in any one of claims 1 to 8.
11. A first controller, comprising: The resistor matching device for the CAN bus as described in claim 9 or 10; A DIP switch, electrically connected to the resistor matching device, is configured to detect the type of the first controller; A matching resistor access circuit, electrically connected to the resistor matching device and the CAN bus, is configured to adjust the resistance connected to the CAN bus; The CAN transceiver, electrically connected to the resistor matching device and the CAN bus, is configured to interact with the second controller.
12. The first controller according to claim 11, wherein, The matching resistor connection circuit includes: A digital potentiometer, connected to the first line of the CAN bus, is configured to adjust the resistance value; A digital switch, connected to the second line of the CAN bus, is configured to control the digital potentiometer to be switched on and off from the CAN bus.
13. A resistor matching system for a CAN bus, comprising: The first controller as described in claim 11 or 12; Multiple second controllers, including one terminal node and multiple intermediate nodes.
14. A building automation system, comprising: The resistor matching system for the CAN bus as described in claim 13.
15. A computer-readable storage medium having stored thereon computer instructions, wherein, When executed by the processor, the computer instruction implements the resistance matching method for the CAN bus as described in any one of claims 1 to 8.
16. A computer program product comprising: Includes computer instructions that, when executed by a processor, implement the resistance matching method for the CAN bus as described in any one of claims 1 to 8.