Resistance matching method, device and system of CAN communication system
By dynamically adjusting the resistance value in the CAN communication system, the common mode interference problem caused by signal reflection in CAN bus communication is solved, and the adaptive matching of the resistance value is achieved, and the communication quality and system stability are improved.
Patent Information
- Application Number
- CN202310524479.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-09
- Publication Date
- 2024-11-12
AI Technical Summary
During the CAN bus communication process, common mode interference is caused by signal reflection, resulting in communication failure or device damage, and the prior art cannot adaptively match the resistance value of the communication device, affecting the communication quality.
By using a transmit resistance array and a receive resistance array in the CAN communication system, it is determined whether the preset conditions are met based on the voltage value of the transmission end of the CAN bus, and the resistance value is dynamically adjusted to achieve adaptive matching of the resistance value and ensure communication quality.
It effectively improves the communication quality of the CAN communication system, avoids communication failure and device damage caused by signal reflection, ensures the best matching of resistance values, and improves the stability and reliability of the system.
Smart Images

Figure CN118944996A_ABST
Abstract
Description
Background Art
[0002] In the actual communication process of the Controller Area Network (CAN) bus, due to the reflection of the signal during transmission, if it exceeds the CAN communication standard, it will introduce common mode interference, causing communication failure at the least, or even damage the device at the worst.
[0003] To ensure the correct communication of the CAN bus, a matching resistor needs to be added to each communication device in the CAN communication network. The resistance value of the matching resistor of the communication device needs to be selected based on the actual situation, which is related to many factors, such as the actual network wiring and the length of the communication line, the impedance of the communication line, etc. The resistor cannot be adaptively matched during the CAN communication process.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The present disclosure provides a resistance matching method, device and system for a CAN communication system, which can at least achieve adaptive matching of resistance values for communication equipment during CAN communication to improve communication quality.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0007] According to one aspect of the present disclosure, a resistance matching method for a CAN communication system is provided. The CAN communication system includes a CAN bus, at least one transmitting resistor array and at least one receiving resistor array. The transmission end of the CAN bus is connected in parallel to at least one transmitting device and at least one receiving device. The transmitting device is connected in parallel to the transmitting resistor array, and the receiving device is connected in parallel to the receiving resistor array. The method includes:
[0008] Enable the transmitting resistor array to a first initial resistance value, and enable the receiving resistor array to a second initial resistance value;
[0009] Collecting the voltage value of the transmission end of the CAN bus;
[0010] If the voltage value at the transmission end of the CAN bus does not meet the preset condition, the resistance value of the sending resistor array is fixed to the first initial resistance value, and the receiving resistor array is controlled to switch from the currently connected second initial resistance value to the first receiving resistance value.
[0011] In a possible embodiment, the voltage value of the transmission end of the CAN bus includes: a first voltage value of the first transmission end and a second voltage value of the second transmission end, and the first voltage value is greater than or equal to the second voltage value;
[0012] The method further comprises:
[0013] If the ratio of the number of the first voltage values collected within the first voltage range to the total number of collected values within the preset time period is not less than a first preset ratio threshold, and the ratio of the number of the second voltage values collected within the second voltage range to the total number of collected values within the preset time period is not less than a second preset ratio threshold, it is determined that the voltage value of the transmission end of the CAN bus meets the preset condition; or,
[0014] If the ratio of the number of voltage differences between the first voltage value and the second voltage value in the third voltage range to the total number of acquisitions within the preset time period is not less than a third preset ratio threshold, it is determined that the voltage value at the transmission end of the CAN bus meets the preset condition.
[0015] In a possible embodiment, controlling the receiving resistor array to switch from the currently connected second initial resistance value to the connected first receiving resistance value includes:
[0016] If the voltage difference between the first voltage value and the second voltage value is smaller than the lower limit of the third preset range, the receiving resistor array is controlled to switch from the currently connected second initial resistance value to a first receiving resistance value greater than the second initial resistance value.
[0017] In a possible embodiment, the first transmission end and the second transmission end are differential transmission lines.
[0018] When there is no communication or communication and a first signal is transmitted on the CAN bus, the first voltage range and the second voltage range are both centered around 2.5V, and when there is communication and a second signal is transmitted on the CAN bus, the first voltage range is centered around 3.5V and the second voltage range is centered around 1.5V; or,
[0019] When there is no communication or communication and a first signal is transmitted on the CAN bus, the third voltage range of the voltage difference is centered around 0V, and when there is communication and a second signal is transmitted on the CAN bus, the third voltage range of the voltage difference is centered around 2V.
[0020] In a possible embodiment, a sampling rate for collecting the voltage value of the transmission end of the CAN bus is greater than twice a corresponding communication frequency of the CAN bus.
[0021] In a possible embodiment, the receiving device connected in parallel with the receiving resistor array is a receiving device farthest from the sending device, and the method further includes:
[0022] Collecting a voltage value at the transmission end of the CAN bus after switching to the first receiving resistance value;
[0023] If the voltage value at the transmission end of the CAN bus does not meet the preset condition and the resistance values in the receiving resistor array have not all been switched, the resistance value of the sending resistor array is fixed to the first initial resistance value, the receiving resistor array is controlled to switch to the unswitched resistance value, and it is re-determined whether the voltage value at the transmission end of the CAN bus meets the preset condition.
[0024] In a possible embodiment, the method further includes:
[0025] If the voltage value of the transmission end of the CAN bus does not meet the preset condition, and the resistance values in the receiving resistor array are all switched, then determining whether the resistance values of the sending resistor array are all switched;
[0026] If the resistance values of the sending resistor array have not all been switched, the sending resistor array is controlled to switch from the currently connected first initial resistance value to the first sending resistance value, the receiving resistor array is controlled to be enabled to the second initial resistance value, and it is re-determined whether the voltage value of the transmission end of the CAN bus meets the preset condition.
[0027] In a possible embodiment, the CAN communication system includes a plurality of receiving devices, each of the receiving devices is connected in parallel with a receiving resistor array, so that the receiving resistor array with the second initial resistance value is the receiving device farthest from the sending device;
[0028] The method further comprises:
[0029] If the voltage value at the transmission end of the CAN bus does not meet the preset condition, the resistance value of the sending resistor array is fixed to the first initial resistance value, and based on the distance between each of the receiving devices and the sending device, the resistance value of the receiving resistor array of each of the receiving devices is switched in a preset order, and it is re-determined whether the voltage value at the transmission end of the CAN bus meets the preset condition.
[0030] In a possible embodiment, the method further includes:
[0031] If the voltage value of the transmission end of the CAN bus does not meet the preset condition, and the resistance values in the multiple receiving devices are all switched, then determining whether the resistance values of the sending resistor array are all switched;
[0032] If the resistance values of the sending resistor array have not all been switched, the sending resistor array is controlled to switch from the currently connected first initial resistance value to the first sending resistance value, and the farthest receiving resistor array is controlled to switch to the second initial resistance value, and it is re-determined whether the voltage value of the transmission end of the CAN bus meets the preset condition.
[0033] In a possible embodiment, the method further includes:
[0034] If the resistance values of the sending resistor array and the receiving resistor array are all switched, and the voltage value of the transmission end of the CAN bus still does not meet the preset conditions, the resistance value with the best performance is determined based on the resistance value of the resistor array corresponding to the voltage value of the transmission end of the CAN bus.
[0035] In a possible embodiment, the voltage value of the transmission end of the CAN bus includes: a first voltage value of the first transmission end and a second voltage value of the second transmission end, and the first voltage value is greater than or equal to the second voltage value;
[0036] Determining the resistance value with the best performance according to the resistance value of the resistance array corresponding to the voltage value of the transmission end of the CAN bus includes:
[0037] Record the resistance value of each group of receiving resistor arrays and transmitting resistor arrays, and the corresponding voltage value of the transmission end of the CAN bus within a preset time length;
[0038] The resistance values of the receiving resistor array and the transmitting resistor array corresponding to the maximum value of the voltage difference between the first voltage value and the second voltage value in the third voltage range within the preset time period are used as the resistance values with optimal performance.
[0039] In a possible embodiment, the method further includes:
[0040] After the receiving resistor array is switched to the first receiving resistor value, a voltage value of the transmission end of the CAN bus is collected;
[0041] If the voltage value at the transmission end of the CAN bus meets the preset condition, the first initial resistance value and the first receiving resistance value are determined to be the resistance values with the best performance of the CAN communication system.
[0042] In a second aspect, an embodiment of the present disclosure provides a resistance matching device for a CAN communication system, wherein the CAN communication system includes a CAN bus, at least one transmitting resistor array and at least one receiving resistor array, wherein a transmitting end of the CAN bus is connected in parallel to at least one transmitting device and at least one receiving device, wherein the transmitting device is connected in parallel to the transmitting resistor array, and the receiving device is connected in parallel to the receiving resistor array;
[0043] Among them, the resistance matching device of the CAN communication system includes a controller, which is used to enable the sending resistor array to a first initial resistance value and enable the receiving resistor array to a second initial resistance value; collect the voltage value of the transmission end of the CAN bus; if the voltage value of the transmission end of the CAN bus does not meet the preset conditions, fix the resistance value of the sending resistor array to the first initial resistance value, and control the receiving resistor array to switch from the currently connected second initial resistance value to the first receiving resistance value.
[0044] In a third aspect, an embodiment of the present disclosure provides a CAN communication system, including a CAN bus, at least one transmitting resistor array and at least one receiving resistor array;
[0045] The transmission end of the CAN bus is connected in parallel with at least one transmitting device and at least one receiving device, wherein the transmitting device is connected in parallel with the transmitting resistor array, and the receiving device is connected in parallel with the receiving resistor array: and
[0046] A control unit is connected in parallel to the transmission end of the CAN bus, and is used to execute the method described in any one of the first aspects.
[0047] In a possible embodiment, the control unit is used to control the switching of resistance values in the sending resistor array and the receiving resistor array;
[0048] The transmitting resistor array or the receiving resistor array includes a plurality of resistors and a plurality of switches, and the plurality of switches are electrically connected to the control unit; and the resistance values of the plurality of resistors are different.
[0049] The embodiments of the present disclosure provide a resistance matching method, device and system for a CAN communication system. The CAN communication system includes a CAN bus, at least one transmitting resistor array and at least one receiving resistor array. The transmission end of the CAN bus is connected in parallel with at least one transmitting device and at least one receiving device. The transmitting device is connected in parallel with the transmitting resistor array, and the receiving device is connected in parallel with the receiving resistor array. The matching method includes: enabling the transmitting resistor array to be a first initial resistance value, enabling the receiving resistor array to be a second initial resistance value, collecting the voltage value of the transmission end of the CAN bus to determine whether it meets a preset condition, fixing the resistance value of the transmitting resistor array, and adjusting the resistance value of the receiving resistor array to achieve adaptive adjustment of the resistance value in the resistor array until the voltage value meets the preset condition, and adaptively adjusting the resistance value with the best signal quality according to the voltage value to improve the communication quality.
[0050] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0052] Figure 1 A schematic diagram showing the structure of a CAN communication system in an embodiment of the present disclosure is shown;
[0053] Figure 2 A structural schematic diagram of another CAN communication system in an embodiment of the present disclosure is shown;
[0054] Figure 3 A schematic diagram showing the structure of a resistor array in an embodiment of the present disclosure is shown;
[0055] Figure 4 A schematic diagram showing the structure of another resistor array in an embodiment of the present disclosure is shown;
[0056] Figure 5 One of the flowcharts showing a resistance matching method of a CAN communication system in an embodiment of the present disclosure;
[0057] Figure 6 A second flowchart showing a resistance matching method for a CAN communication system in an embodiment of the present disclosure is shown;
[0058] Figure 7 A third flowchart showing a resistance matching method for a CAN communication system according to an embodiment of the present disclosure;
[0059] Figure 8 A schematic structural diagram of a resistance matching device for a CAN communication system in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0060] The preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0061] The terms "first" and "second" in this document are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0062] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or mutual communication; it can be a direct connection, or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0063] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or reference letters in different examples, and this repetition is for the purpose of simplification and clarity, which itself does not indicate the relationship between the various embodiments and / or settings discussed.
[0064] In order to ensure the correct communication of the CAN bus, a matching resistor needs to be added to each communication device in the CAN communication network. The resistance value of the matching resistor of the communication device needs to be selected according to the actual situation, which is related to many factors, such as the actual network wiring and the length of the communication line, the impedance of the communication line, etc. However, in the related technology, the resistor cannot be adaptively matched during the CAN communication process.
[0065] In order to solve the technical problem, the present disclosure provides a resistance matching method, device and system for a CAN communication system. The CAN communication system includes a CAN bus, at least one transmitting resistor array and at least one receiving resistor array. The transmission end of the CAN bus is connected in parallel with at least one transmitting device and at least one receiving device. The transmitting device is connected in parallel with the transmitting resistor array, and the receiving device is connected in parallel with the receiving resistor array. The matching method includes: enabling the transmitting resistor array to be a first initial resistance value, enabling the receiving resistor array to be a second initial resistance value, determining whether the voltage value of the transmission end of the CAN bus meets a preset condition by collecting the voltage value, fixing the resistance value of the transmitting resistor array, and adjusting the resistance value of the receiving resistor array. The resistance matching method for the CAN communication system of the embodiment of the present invention can adaptively adjust the voltage value according to the voltage value to obtain the optimal resistance value when the voltage value meets the preset condition, thereby improving the communication quality.
[0066] In order to facilitate an overall understanding of the technical solution provided by the embodiment of the present disclosure, the CAN communication system in this example is described in detail below in conjunction with the accompanying drawings and embodiments.
[0067] Figure 1 A schematic diagram of the structure of a CAN communication system in an embodiment of the present disclosure is shown. Figure 1 As shown, the CAN communication system 100 specifically includes: a CAN bus 101 , a transmitting resistor array 102 , a receiving resistor array 103 , a control unit 104 , a transmitting device 105 and a receiving device 106 .
[0068] The transmission end of the CAN bus 101 is connected in parallel with a transmitting device 105 and a receiving device 106, wherein the transmitting device 105 is connected in parallel with the transmitting resistor array 102, and the receiving device 106 is connected in parallel with the receiving resistor array 103: and
[0069] The control unit 104 is connected in parallel to the transmission end of the CAN bus 101, and is used to enable the transmitting resistor array 102 to be a first initial resistance value, enable the receiving resistor array 103 to be a second initial resistance value, and collect the voltage value of the transmission end of the CAN bus 1011. If the voltage value of the transmission end of the CAN bus 101 does not meet the preset condition, the resistance value of the transmitting resistor array 102 is fixed to the first initial resistance value, and the receiving resistor array 103 is controlled to switch from the currently connected second initial resistance value to the first receiving resistance value.
[0070] The control unit 104 may be a microcontroller unit (MCU), which may collect the voltage value of the transmission end of the CAN bus 101 through analog to digital converter (ADC) hardware.
[0071] Figure 1 The transmitting resistor array and receiving resistor array included in the CAN communication system 100 are only exemplary, and may also include multiple transmitting resistor arrays and multiple receiving resistor arrays.
[0072] For example, the CAN communication system 100 includes one transmitting device and multiple receiving devices, the transmitting device transmits a resistor array in parallel, and each receiving device receives a resistor array in parallel; or, the CAN communication system 100 includes multiple transmitting devices and multiple receiving devices, each transmitting device transmits a resistor array in parallel, and each receiving device receives a resistor array in parallel.
[0073] Figure 2 FIG. 4 shows a schematic diagram of the structure of another CAN communication system in an embodiment of the present disclosure. Figure 2As shown, the CAN communication system 100 specifically includes: a CAN bus 101 , a transmitting resistor array 102 , a receiving resistor array 103 , a control unit 104 , a transmitting device 105 , a receiving device 106 , a receiving resistor array 201 and a receiving device 202 .
[0074] The transmission end of the CAN bus 101 is composed of two differential transmission lines, namely a first transmission end 111 and a second transmission end 112. The first transmission end 111 may be CANH, and the second transmission end 112 may be CANL. All nodes on the CAN bus 101 may be connected to the two differential transmission lines.
[0075] In a possible embodiment, when the communication process involves one transmitting device and multiple receiving devices, the receiving resistor array may be connected in parallel to only one receiving device in the CAN communication system 100 .
[0076] Further, Figure 1 and Figure 2 The control unit 104 is also used to control the switching of the resistance values in the sending resistor array 102 and the receiving resistor array 103.
[0077] The transmitting resistor array 102 or the receiving resistor array 103 includes a plurality of resistors and a plurality of switches, the plurality of switches are electrically connected to the control unit 104, and the resistance values of the plurality of resistors are different. The control unit 104 switches the resistance values in the resistor array by controlling the on and off of the switches. The two ends of the resistor array are connected in parallel to the first transmission end 111 and the second transmission end 112.
[0078] Specifically, Figure 3 A schematic diagram of the structure of a sending or receiving resistor array in an embodiment of the present disclosure is shown. Figure 3 The example includes 4 resistors and 4 switches.
[0079] Alternatively, a single-pole multi-throw switch can be used to simultaneously connect four resistors, and the control unit 101 can be used to control the switch to implement switching of the resistance values in the resistor array, thereby saving the use of switches and wiring.
[0080] In one embodiment, the switch may include a transistor, such as an NMOS transistor, a PMOS transistor, etc.
[0081] Exemplarily, the resistor array may include a plurality of resistors and a plurality of metal-oxide-semiconductor field-effect transistors (MOSFETs), which may be referred to as MOS tubes for short. Figure 4 FIG. 4 shows a schematic diagram of the structure of another resistor array in an embodiment of the present disclosure. Figure 4As shown, an example is given in which four resistors and four PMOS tubes are included, namely: Q1, Q2, Q3 and Q4.
[0082] The drain of each MOS tube is connected to one end of a resistor, the other end of the resistor is connected to the first transmission end 111, the source of each MOS tube is connected to the second transmission end 112, the gate of the MOS tube is electrically connected to the control unit 104 as a control end, and the control unit 104 controls the on and off of the corresponding MOS tube through the general purpose input output (GPIO), Q1 is connected to GPIO1, Q2 is connected to GPIO2, Q3 is connected to GPIO3, and Q4 is connected to GPIO4. The control unit 104 controls the switching of the resistance value in the resistor array by controlling the on and off of the MOS tube. After the MOS tube is turned on, it is purely resistive and is more suitable as a switch in the resistance matching method of the CAN communication system disclosed in the present invention.
[0083] The following is an explanation of the resistance matching method of the CAN communication system in the present disclosure in combination with specific embodiments. The resistance matching method of the CAN communication system in the present disclosure can be implemented by a control unit, that is, the control unit can execute each step of the resistance matching method of the CAN communication system in the present disclosure. In this case, the resistance matching method of the CAN communication system can be included in the control unit.
[0084] Figure 5 FIG. 1 is a flowchart showing a resistance matching method for a CAN communication system in an embodiment of the present disclosure; Figure 5 As shown, the resistance matching method of the CAN communication system in the present disclosure includes the following steps:
[0085] S502: enabling the transmitting resistor array to have a first initial resistance value, and enabling the receiving resistor array to have a second initial resistance value.
[0086] In a possible embodiment, the resistance values of the sending and receiving resistor arrays can be preset when the sending device and the receiving device start communicating, or the resistance value enabled when the sending device and the receiving device start communicating can be calculated by theoretical calculation.
[0087] The specific values of the first initial resistance value and the second initial resistance value may be the same or different.
[0088] Specifically, Figure 4 For example, the sending resistor array and the receiving resistor array each include 4 resistors, and the control unit controls the switching of the resistor values in the resistor array through MOS tubes. The resistance values of the 4 resistors in the resistor array are: 60Ω, 120Ω, 240Ω and 360Ω respectively.
[0089] For example, if the first initial resistance value and the second initial resistance value are both 120Ω, the control unit turns on the MOS tube connected to the resistor with a resistance value of 120Ω, and enables the resistance values in the resistor array to be 120Ω.
[0090] S504: Collecting the voltage value of the transmission end of the CAN bus.
[0091] In a possible embodiment, a transmitting resistor array, a receiving resistor array, a transmitting device and a receiving device are connected in parallel on the transmitting end of the CAN bus. The voltage value of the transmitting end of the CAN bus can reflect the communication quality between the transmitting device and the receiving device. The voltage value of the transmitting end of the CAN bus can be collected to judge the communication quality between the transmitting device and the receiving device.
[0092] Exemplarily, the transmission end of the CAN bus is composed of two differential transmission lines, namely a first transmission end and a second transmission end. The first transmission end may be CANH, and the second transmission end may be CANL.
[0093] Collecting the voltage value of the transmission end of the CAN bus may include collecting a first voltage value of the first transmission end CANH and a second voltage value of the second transmission end CANL.
[0094] Furthermore, the voltage value of the transmission end of the CAN bus is collected, which can be used to calculate the voltage difference between the first voltage value of the first transmission end CANH and the second voltage value of the second transmission end CANL.
[0095] S506: If the voltage value at the transmission end of the CAN bus does not meet the preset condition, the resistance value of the sending resistor array is fixed to the first initial resistance value, and the receiving resistor array is controlled to switch from the currently connected second initial resistance value to the first receiving resistance value.
[0096] In a possible embodiment, the voltage value at the transmission end of the CAN bus can reflect the communication quality between the sending device and the receiving device. If the voltage value at the transmission end of the CAN bus does not meet the preset conditions, it means that the first initial resistance value and the second initial resistance value are not the optimal matching resistance when the sending device and the receiving device communicate, and the resistance value needs to be adjusted.
[0097] First, the first initial resistance value of the sending resistor array is fixed, and the receiving resistor array is switched from the currently connected second initial resistance value to the first receiving resistance value.
[0098] Whether the voltage value at the transmission end of the CAN bus meets the preset conditions can be explained by the following two examples, including:
[0099] Example 1: If the ratio of the number of first voltage values collected within the first voltage range within the preset time period to the total number of collections is not less than a first preset ratio threshold, and the ratio of the number of second voltage values collected within the second voltage range within the preset time period to the total number of collections is not less than a second preset ratio threshold, then the voltage value at the transmission end of the CAN bus meets the preset conditions.
[0100] For example, when the first transmission terminal CANH and the second transmission terminal CANL do not communicate or communicate and transmit a first signal (for example, signal 1), the theoretical values of CANH and CANL are both 2.5V. When the first transmission terminal CANH and the second transmission terminal CANL communicate and transmit a second signal (for example, signal 0), the theoretical voltage value of CANH is 3.5V, and the theoretical voltage value of CANL is 1.5V.
[0101] Based on this, in one embodiment, the preset duration is set to a time period, and the collected first voltage value and second voltage value are recorded. When the first transmission terminal CANH and the second transmission terminal CANL communicate and transmit the second signal (for example, signal "0"), the first voltage range is 3.5V±(3.5×5%)V, and the second voltage range is 1.5V±(1.5×5%)V as an example; when the first transmission terminal CANH and the second transmission terminal CANL do not communicate or communicate and transmit the first signal (for example, signal "1"), the first voltage range is 2.5V±(2.5×5%)V, and the second voltage range is 2.5V±(2.5×5%)V as an example. The first preset ratio threshold can be set to 95%, and the second preset ratio threshold can be set to 95%. The above values are only examples, and the present invention is not limited thereto. The first and second voltage ranges can be different, and the first and second preset ratio thresholds can also be different.
[0102] Within the preset time length, the first voltage value of the first transmission end CANH collected satisfies the first voltage range for a number greater than or equal to 95%, and the second voltage value of the second transmission end CANL collected satisfies the second voltage range for a number greater than or equal to 95%, indicating that the voltage values of the transmission ends (CANH and CANL) of the CAN bus meet the preset conditions and meet the expected effects.
[0103] Furthermore, it is possible to determine whether the first transmission end CANH and the second transmission end CANL are communicating and what the transmitted data is through the signal transmitted on the CAN bus. If the first transmission end CANH and the second transmission end CANL of the CAN bus are not communicating or are communicating and the transmitted data is the first signal (for example, the transmitted data is 1), then the first voltage range of the collected first voltage value and the second voltage range of the second voltage value are 2.5V±(2.5×5%)V; if the transmitted data is the second signal (for example, the transmitted data is 0), then the first voltage range of the collected first voltage value should be 3.5V±(3.5×5%)V, and the second voltage range of the second voltage value is 1.5V±(1.5×5%)V.
[0104] Example 2: If the ratio of the number of voltage differences between the first voltage value and the second voltage value in the third voltage range to the total number of acquisitions within the preset time period is not less than the third preset ratio threshold, it is determined that the voltage value of the transmission end of the CAN bus meets the preset conditions.
[0105] Specifically, the voltage difference between the first voltage value and the second voltage value can be used to determine whether the voltage value of the transmission end of the CAN bus meets the preset condition. When the first transmission end CANH and the second transmission end CANL are not communicating or are communicating and the transmitted data is a first signal (for example, the transmitted data is 1), the theoretical value of the voltage difference between the first transmission end CANH and the second transmission end CANL should be 0V. When the first transmission end CANH and the second transmission end CANL are communicating and the transmitted data is a second signal (for example, the transmitted data is 0), the theoretical value of the voltage difference between the first transmission end CANH and the second transmission end CANL should both be 2V.
[0106] Based on this, the preset time length is set to a time period, the collected first voltage value and the second voltage value are recorded, and the voltage difference is determined. When the first transmission terminal CANH and the second transmission terminal CANL communicate and transmit the second signal (for example, transmission 0), the third voltage range of the voltage difference between CANH and CANL is 2V±(2×5%)V, and when the first transmission terminal CANH and the second transmission terminal CANL do not communicate or transmit and the first signal (for example, transmission 1) is transmitted, the third voltage range of the voltage difference between CANH and CANL is centered on 0V, and the specific range can be ±0.3V.
[0107] Within the preset time, the ratio of the number of the collected voltage differences between CANH and CANL in the third voltage range to the total number of collections is greater than or equal to 95%, indicating that the voltage value of the transmission end of the CAN bus meets the preset conditions and meets the expected effect.
[0108] It should be noted that the above two examples may not be based on the preset time length, but may be based on the preset number of collection times. By pre-setting the collection of the voltage value of the transmission end of the CAN bus 1000 times, it is determined whether the voltage value of the transmission end of the CAN bus meets the preset conditions.
[0109] In a possible embodiment, the sampling rate at which the control unit collects the voltage value of the transmission end of the CAN bus is greater than twice the corresponding communication frequency of the CAN bus.
[0110] Exemplarily, the frequency of CAN communication is approximately 250kHz to 1M / s. The control unit 104 can sample the voltage values of CANH and CANL at the transmission ends of the CAN bus through the ADC module. The sampling rate of the ADC can reach 2M / s (2M times per second), and the sampling rate can be set to 4 times or 8 times the communication frequency.
[0111] The ADC hardware can be configured in continuous sampling mode. In continuous sampling mode, the sampling time and sampling channel of the ADC are fixed, and multiple sampling and conversion are completed in one trigger. After each conversion is completed, the conversion result is stored in a register, which can be specifically stored in, for example, the ADC_RDATA register.
[0112] After being stored in the ADC_RDATA register, the ADC module can generate an End Of Convert (EOC) signal to notify the Direct Memory Access (DMA) to read the ADC conversion result from the ADC_RDATA register to the array.
[0113] Furthermore, by changing the sampling time configuration of the ADC channel, the ADC can be sampled at different sampling frequencies.
[0114] In step S506, after determining whether the voltage value of the transmission end of the CAN bus meets the preset condition, if the preset condition is met, the first initial resistance value and the second initial resistance value can be directly used as the optimal matching resistance of the CAN communication system.
[0115] If the voltage value at the transmission end of the CAN bus does not meet the preset condition, the resistance value in the resistance array needs to be adjusted. Specific ways to adjust the receiving resistance array include the following.
[0116] Exemplarily, the adjustment can be made according to the relationship between the voltage difference and the third preset range, and the speed of obtaining the most matching resistance value of the CAN communication system can be improved. It is worth noting that when the voltage difference between CANH and CANL does not meet the preset conditions, the resistance value of the receiving resistor array is adjusted. It can be adjusted according to certain rules, as long as omissions and duplications can be avoided, and the direction of adjusting the resistance value is not limited. It can be adjusted from small to large, or it can be adjusted from large to small.
[0117] Exemplarily, if the voltage difference between the first voltage value of the first transmission terminal CAH and the second voltage value of the second transmission terminal CHL is less than the lower limit value of the third preset range (for example, 2v-2×5%v), the receiving resistor array is controlled to switch from the currently connected second initial resistance value to the first receiving resistance value greater than the second initial resistance value.
[0118] In one embodiment, if the voltage difference between the first voltage value of the first transmission terminal CAH and the second voltage value of the second transmission terminal CHL is greater than the upper limit value of the third preset range (for example, 2v+2×5%v), the receiving resistor array is controlled to switch from the currently connected second initial resistance value to the first receiving resistance value which is smaller than the second initial resistance value.
[0119] In other embodiments, when the voltage difference between the first transmission terminal CAH and the second transmission terminal CAL is less than the lower limit value of the third preset range (for example, 2v-2×5%v), adjustment must be made, but when the voltage difference is greater than the upper limit value of the third preset range (for example, 2v+2×5%v), it is acceptable.
[0120] The adjustment can also be performed in a traversal manner, where all resistance values in the resistance array are adjusted once to avoid omission and duplication, and a resistance value is selected from which the voltage value at the transmission end of the CAN bus meets a preset condition.
[0121] Furthermore, the CAN communication system in the embodiments of the present disclosure is described through the following situations.
[0122] Case 1: The CAN communication system includes one transmitting device and multiple receiving devices. The transmitting device is connected in parallel with the transmitting resistor array, and the receiving resistor array is connected in parallel only on the receiving device farthest from the transmitting device.
[0123] Case 2: The CAN communication system includes one transmitting device and one receiving device. The transmitting device is connected in parallel with a transmitting resistor array, and the receiving device is connected in parallel with a receiving resistor array.
[0124] Case 3: The CAN communication system includes one transmitting device and multiple receiving devices. The transmitting device is connected to a transmitting resistor array in parallel, and each receiving device is connected to a receiving resistor array in parallel.
[0125] Case 4: The CAN communication system includes multiple transmitting devices and multiple receiving devices. The transmitting devices are connected to a transmitting resistor array in parallel, and each receiving device is connected to a receiving resistor array in parallel.
[0126] Case 5: The CAN communication system includes multiple transmitting devices and one receiving device. The transmitting device is connected to a transmitting resistor array in parallel, and each receiving device is connected to a receiving resistor array in parallel.
[0127] For Case 1 and Case 2, both essentially include only one transmitting resistor array and one receiving resistor array. After enabling the first initial resistance value and the second initial resistance value and collecting the voltage value of the transmission end of the CAN bus, if the voltage value of the transmission end of the CAN bus does not meet the preset conditions, the specific method of adjusting the resistance value can be the same.
[0128] For cases 4 and 5, according to the traversal adjustment method in the above content, or according to the voltage difference, the resistance value is adjusted to find the resistance value that makes the voltage value of the transmission end of the CAN bus meet the preset conditions. The multiple sending devices in cases 4 and 5 can be regarded as a whole, and only one sending device is allowed to communicate outward at the same time. The positions of multiple sending devices are located in one place, so that the receiving device farthest from the sending device can determine the receiving device according to any sending device. The method of adjusting the resistance value in cases 4 and 5 can be based on the sending device that communicates with the receiving device at a certain moment. It can be understood that: when sending device A is sending signals outward and communicating with the receiving device, sending device A is adjusted, and the remaining sending devices are not communicating at this moment, then the resistance values in the resistor arrays at both ends of the remaining sending devices are not adjusted.
[0129] Based on this, for the above-mentioned cases 1, 2 and 3, the specific methods of adjusting the resistance are divided into two examples for explanation.
[0130] Example 1: When the CAN communication system is in Case 1 or Case 2, there is only one receiving resistor array.
[0131] After adjusting the second initial resistance value to the first receiving resistance value, the voltage value of the transmission end of the CAN bus after switching to the first receiving resistance value is collected. If the voltage value of the transmission end of the CAN bus does not meet the preset conditions and the resistance values in the receiving resistor array have not all been switched, the resistance value of the fixed sending resistor array is the first initial resistance value, the receiving resistor array is controlled to switch to the unswitched resistance value, and it is re-determined whether the voltage value of the transmission end of the CAN bus meets the preset conditions.
[0132] Furthermore, if the voltage value at the transmission end of the CAN bus does not meet the preset conditions and all the resistance values in the receiving resistor array are switched, it is determined whether all the resistance values of the sending resistor array are switched. If all the resistance values of the sending resistor array are switched, the sending resistor array is controlled to switch from the currently connected first initial resistance value to the first sending resistance value, the receiving resistor array is controlled to be enabled to the second initial resistance value, and it is re-determined whether the voltage value at the transmission end of the CAN bus meets the preset conditions.
[0133] Exemplarily, in the embodiment, taking the resistor array including 4 resistors with different resistance values as an example, after the second initial resistance value of 120Ω is adjusted to the first receiving resistance value, the first receiving resistance value is 240Ω, and the re-collected voltage value of the transmission end of the CAN bus has not yet met the preset condition, the resistance value of 240Ω in the receiving resistor array is further adjusted to 60Ω. If the voltage value of the transmission end of the CAN bus meets the preset condition at this time, the first initial resistance value of 120Ω and the receiving resistance of 60Ω in the receiving resistor array can be used as the optimal resistance value of the CAN communication system to enable the sending device and the receiving device to communicate.
[0134] If the voltage value of the transmission end of the CAN bus still does not meet the preset condition after all four resistance values in the receiving resistance array are adjusted, the first initial resistance value of 120Ω in the sending resistance array is adjusted to the first sending resistance value of 240Ω, and the resistance value of the receiving resistance array is adjusted to 120Ω. The subsequent adjustment process repeats the above steps until the voltage value of the transmission end of the CAN bus meets the preset condition. After each adjustment of the resistance value in the resistance array, the collected voltage value of the transmission end of the CAN bus needs to be recorded.
[0135] Example 2: When the CAN communication system is in case 3, case 3 includes 1 transmitting device and 3 receiving devices, the transmitting device is connected in parallel with a transmitting resistor array, and the receiving device is connected in parallel with a receiving resistor array.
[0136] For ease of understanding, the three receiving devices connected in parallel are the first receiving resistor array, the second receiving resistor array and the third receiving resistor array, so that the receiving resistor array with the second initial resistance value is the receiving resistor array farthest from the sending device. Here, the receiving resistor array farthest from the sending device can be the first receiving resistor array.
[0137] If the voltage value at the transmission end of the CAN bus does not meet the preset conditions, the resistance value of the fixed sending resistor array is set to the first initial resistance value, and based on the distance between each receiving device and the sending device, the resistance value of the receiving resistor array of each receiving device is switched in a preset order to re-judge whether the voltage value at the transmission end of the CAN bus meets the preset conditions.
[0138] Furthermore, if the voltage value at the transmission end of the CAN bus does not meet the preset conditions and the resistance values in multiple receiving devices are all switched, it is determined whether the resistance values of the sending resistor array are all switched. If the resistance values of the sending resistor array are not all switched, the sending resistor array is controlled to switch from the currently connected first initial resistance value to the first sending resistance value, and the farthest receiving resistor array is controlled to switch to the second initial resistance value, and it is re-determined whether the voltage value at the transmission end of the CAN bus meets the preset conditions.
[0139] Exemplarily, in the embodiment, taking the resistor array including 4 resistors with different resistance values as an example, after the second initial resistance value of 120Ω in the first receiving resistor array is adjusted to the first receiving resistance value, the first receiving resistance value is 240Ω, and the re-collected voltage value of the transmission end of the CAN bus has not yet met the preset condition, then the resistance value of 240Ω in the first receiving resistor array is further adjusted to 60Ω. If the voltage value of the transmission end of the CAN bus meets the preset condition at this time, the first initial resistance value of 120Ω and the receiving resistance of 60Ω in the first receiving resistor array can be used as the optimal resistance value of the CAN communication system, so that the sending device and the receiving device can communicate.
[0140] If the voltage value at the transmission end of the CAN bus still does not meet the preset conditions after all four resistance values in the receiving resistance array are adjusted, all resistance values in the first receiving resistance array are cut off, and the resistance values in the receiving resistance array are adjusted one by one in order from far to near according to the distance from the sending device, so that the receiving device with the third receiving resistance array connected in parallel at both ends is closest to the sending device. After the adjustment of the first receiving resistance array is completed, the resistance value in the second receiving resistance array is enabled to be 120Ω, and adjusted according to the above steps.
[0141] If the resistance values in the three receiving resistor arrays have been adjusted, the voltage value at the transmission end of the CAN bus still does not meet the preset conditions. The first initial resistance value of 120Ω in the transmission resistor array is adjusted to the first transmission resistance value of 240Ω. Starting from the first receiving resistor array, the resistance values in the receiving resistor array are re-adjusted. The subsequent adjustment process repeats the above steps until the voltage value at the transmission end of the CAN bus meets the preset conditions. After each adjustment of the resistance value in the resistor array, the collected voltage value at the transmission end of the CAN bus needs to be recorded.
[0142] The above two examples only include the case where there is one transmitting device. If there are multiple transmitting devices, a transmitting resistor array is connected in parallel at both ends of each transmitting device, and the resistance value of all transmitting resistor arrays is enabled to be 120Ω. Adjustments are made in a traversal manner to select the resistance value with the best performance.
[0143] Furthermore, if the resistance values of the sending resistor array and the receiving resistor array are all switched, and the voltage value at the transmission end of the CAN bus still does not meet the preset conditions, the resistance value with the best performance is determined based on the resistance value of the resistor array corresponding to the voltage value at the transmission end of the CAN bus.
[0144] The specific method for determining the resistance value with optimal performance can be: recording the resistance values of each group of receiving resistor arrays and transmitting resistor arrays, and the corresponding voltage value at the transmission end of the CAN bus within a preset time length, and taking the resistance value of the receiving resistor array and the transmitting resistor array corresponding to the maximum value of the voltage difference between the first voltage value and the second voltage value in the third voltage range within the preset time length as the resistance value with optimal performance.
[0145] For example, if there are 16 groups of recorded voltage values of the transmission end of the CAN bus, 1000 voltage values of the transmission end of the CAN bus are collected within a preset time. By processing the 16 groups, each group of 1000 voltage values of the transmission end of the CAN bus, if the number of voltage differences in one group within the third voltage range reaches 90%, and the number of voltage differences in the third voltage range is the largest among the 16 groups, the resistance value of this group of receiving resistor arrays and transmitting resistor arrays can be used as the resistance value with the best performance.
[0146] For example, a CAN communication system includes a transmitting device and multiple receiving devices, a transmitting resistor array is connected in parallel at both ends of the transmitting device, and a receiving resistor array is connected in parallel at both ends of the receiving device farthest from the transmitting device. Figure 6 FIG. 2 shows a second flow chart of a resistance matching method for a CAN communication system in an embodiment of the present disclosure. Figure 6 As shown, the specific steps include:
[0147] S602: enabling a transmitting resistor array to have a first initial resistance value, and enabling a receiving resistor array to have a second initial resistance value.
[0148] S604: Collect the voltage value of the transmission end of the CAN bus.
[0149] S606: Determine whether the voltage value of the transmission end of the CAN bus meets a preset condition; if not, execute step S608; if it meets the preset condition, execute step S610.
[0150] S608: Keep the enabled resistance value of the transmitting resistor array connected in parallel at both ends of the transmitting device unchanged, and control the receiving resistor array to switch from the currently enabled resistance value to other resistance values that have not been enabled in the receiving resistor array.
[0151] In a possible embodiment, the other resistance values that have not been enabled in S608 refer to: resistance values in the receiving resistance array that have not been enabled when the sending resistance array is enabled as the current resistance value. When the sending resistance array has adjusted the resistance value, other resistance values in the receiving resistance array except the currently connected resistance value can be understood as other resistance values that have not been enabled.
[0152] S610: Whether the voltage values of the transmitting end of the CAN bus corresponding to all the resistance values in the receiving resistance array when the sending resistance array enables the current resistance value are recorded; if not, return to execute S604; if so, execute step S612.
[0153] In a possible embodiment, the "no" situation indicates that the voltage value at the transmission end of the CAN bus when each resistance value enabled in the receiving resistance array is not fully recorded, that is, it can be understood that not all resistance values in the receiving resistance array have been enabled, and there are still unenabled resistances.
[0154] S612: Determine whether the voltage value of the transmission end of the CAN bus when each resistance value in the transmission resistance array is enabled is fully recorded; if not, execute step S614; if yes, execute step S616.
[0155] S614: Control the sending resistor array to switch from the currently connected resistance value to other resistance values that have not been enabled, and return to execute S604.
[0156] In a possible embodiment, the other resistance values that have not been enabled in S614 may be understood as: the resistance values that have not been enabled in the sending resistance array.
[0157] S616: Determine the resistance value with the best performance according to the resistance value of the resistor array corresponding to the voltage value of the transmission end of the CAN bus.
[0158] Through the above Figure 6 In the process shown, the receiving resistor array is connected in parallel only at two ends of the receiving device farthest from the transmitting device, which can reduce the cost and simplify the overall circuit structure.
[0159] Furthermore, a CAN communication system includes a transmitting device and multiple receiving devices, a transmitting resistor array is connected in parallel at both ends of the transmitting device, and a receiving resistor array is connected in parallel at both ends of each receiving device.
[0160] Figure 7 FIG. 3 shows a flowchart of a resistance matching method for a CAN communication system in an embodiment of the present disclosure. Figure 7 As shown, the specific steps include:
[0161] S702: enabling a transmitting resistor array to have a first initial resistance value, and enabling a receiving resistor array of a receiving device that is farthest from the transmitting device to have a second initial resistance value.
[0162] S704: Collect the voltage value of the transmission end of the CAN bus.
[0163] S706: Determine whether the voltage value of the transmission end of the CAN bus meets a preset condition; if not, execute step S708; if it meets the preset condition, execute step S710.
[0164] S708: Keep the resistance value of the transmitting resistor array enabled in parallel at both ends of the transmitting device unchanged, and switch the resistance value of each receiving resistor array according to a preset sequence.
[0165] In a possible embodiment, the resistance values in the enabled receiving resistor arrays, that is, the receiving resistor arrays of the receiving devices farthest from the sending device, are adjusted in sequence. If all the resistance values in the receiving resistor arrays of the receiving devices farthest from the sending device are matched with the resistance values in the sending resistor arrays, and none of them can make the voltage value of the transmission end of the collected CAN bus meet the preset conditions, then according to the distances between each receiving device and the sending device, the receiving resistor arrays are selected in sequence in the order of the distances from the sending device from far to near.
[0166] For example, if there are three receiving resistor arrays, the receiving resistor array of the receiving device farthest from the transmitting device is the first receiving resistor array, the second farthest is the second receiving resistor array, and the closest is the third receiving resistor array. Specifically, it can be understood that after all the resistance values in the first receiving resistor array are enabled, all the resistors in the first receiving resistor array are disconnected, the second receiving resistor array is selected, and one resistance value in the second receiving resistor array is enabled, until all the resistance values in the three receiving resistor arrays are enabled.
[0167] The preset order can be understood as: first adjust the resistance values in the enabled receiving resistor array in turn, and after all resistance values are enabled, select the next farthest receiving resistor array according to the distance from the sending device, and adjust the resistance values in the next farthest receiving resistor array in turn, and so on.
[0168] S710: Determine whether the voltage values of the transmission end of the CAN bus corresponding to all the resistance values in each receiving resistor array when the current resistance value of the transmitting resistor array is enabled have been recorded; if not, return to execute S704; if so, execute step S712.
[0169] S712: Determine whether the voltage value of the transmission end of the CAN bus when each resistance value in the transmission resistance array is enabled is fully recorded; if not, execute step S714; if yes, execute step S716.
[0170] S714: Control the sending resistor array to switch from the currently connected resistance value to other resistance values that have not been enabled, and return to execute S704.
[0171] S716: Determine the resistance value with the best performance according to the resistance value of the resistor array corresponding to the voltage value of the transmission end of the CAN bus.
[0172] Through the above implementation, it can be determined that there must be a suitable resistance value near the transmitting end of the sending device. At the same time, the receiving end of the receiving device can also adaptively match the resistance value with the best performance. By adaptively matching the resistance value with the best performance at both the transmitting end and the receiving end, the communication quality of the sending device and the receiving device during the communication process can be improved.
[0173] In addition, for the case of multiple receiving resistor arrays, after all the resistance values in the transmitting resistor array and the first receiving resistor array are enabled, the first receiving resistor array can be enabled as a resistance value with better performance, the transmitting resistor array can be enabled as a first initial resistance value, and the second receiving resistor array can be enabled as a second initial resistance value, and it is re-determined whether the voltage at the transmission end of the CAN bus meets the preset conditions until the optimal resistance value of each resistor array is determined.
[0174] It should be noted that, in the resistance matching method of the CAN communication system disclosed in the present invention, two resistors connected in parallel at both ends of the sending device can be enabled together, and the optimal solution can be found by combining multiple resistors. This method can be used when the optimal solution determined by a single resistance value is significantly different from the expected effect. For example, by processing the voltage values of the transmission ends of 16 groups, each with 1,000 CAN buses, if one group has the largest number of voltage differences within the third voltage range, which only reaches 70%, and is significantly different from the preset preset ratio threshold, then the optimal resistance value that makes the voltage value of the transmission end of the CAN bus meet the preset conditions can be determined by combining multiple resistors.
[0175] The optimal resistance value is determined by combining multiple resistors. The optimal resistance value can be determined preferentially within the range of a preset ranking of the voltage differences within the third voltage range. For example, if the voltage differences within the third voltage range are ranked in the top 3, then the group of resistors whose number reaches 70% within the third voltage range is matched with another resistor to determine the optimal resistance value that makes the voltage value at the transmission end of the CAN bus meet the preset conditions.
[0176] Furthermore, variable resistors can also be connected in parallel at both ends of the sending device and the receiving device. In the process of adjusting the resistance value so that the voltage value at the transmission end of the CAN bus meets the preset conditions, the resistance can be initially enabled to be 120Ω, and the resistance value can be adjusted at intervals of preset resistance values. The specific adjustment method is to first keep the resistance value enabled at both ends of the sending device unchanged, and adjust the resistance value at both ends of the receiving device.
[0177] The resistance matching method of the CAN communication system provided in the embodiment of the present disclosure can adaptively adjust the enabled resistance value in the resistor array connected in parallel at both ends of the sending device and the receiving device by judging the voltage value of the transmission end of the CAN communication. During the adjustment process, issues such as the network wiring and the length of the communication line, the impedance of the communication line, etc. have been taken into consideration, which can ensure that the voltage value of the transmission end of the CAN communication meets the preset conditions, thereby improving the communication quality between the sending device and the receiving device.
[0178] Based on the same inventive concept, a resistance matching device for a CAN communication system is also provided in an embodiment of the present disclosure. Since the principle of solving the problem in the embodiment of the device is similar to that in the above-mentioned method embodiment, the implementation of the embodiment of the device can refer to the implementation of the above-mentioned method embodiment, and the repeated parts will not be repeated.
[0179] The CAN communication system includes a CAN bus, at least one transmitting resistor array and at least one receiving resistor array. The transmission end of the CAN bus is connected in parallel with at least one transmitting device and at least one receiving device. The transmitting device is connected in parallel with the transmitting resistor array, and the receiving device is connected in parallel with the receiving resistor array.
[0180] Figure 8 A schematic diagram showing the structure of a resistance matching device for a CAN communication system according to an embodiment of the present disclosure is shown. Figure 8 As shown, the device 80 includes:
[0181] Controller 801, controller 801 is used to enable the sending resistor array to the first initial resistance value and the receiving resistor array to the second initial resistance value; collect the voltage value of the transmission end of the CAN bus; if the voltage value of the transmission end of the CAN bus does not meet the preset condition, fix the resistance value of the sending resistor array to the first initial resistance value, and control the receiving resistor array to switch from the currently connected second initial resistance value to the first receiving resistance value.
[0182] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".
[0183] The present disclosure also provides an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the method in the present disclosure embodiment by executing the executable instructions. The electronic device may be a microcontroller.
[0184] The embodiment of the present disclosure also provides a computer-readable storage medium, which stores a computer program, and the computer-readable storage medium stores a program product capable of implementing the above-mentioned method of the present disclosure. The computer program is suitable for being loaded by the processor and executing the resistance matching method of the CAN communication system provided by each step in any of the above-mentioned embodiments. For details, please refer to the implementation method provided by each step in any of the above-mentioned embodiments, which will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in the present disclosure, please refer to the description of the method embodiment of the present disclosure. As an example, the computer program can be deployed to be executed on a computer device, or on multiple computer devices located at one location, or on multiple computer devices distributed in multiple locations and interconnected by a communication network.
[0185] The computer-readable storage medium may be a resistance matching device of the CAN communication system provided in any of the aforementioned embodiments or an internal storage unit of the computer device, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc. equipped on the computer device. Further, the computer-readable storage medium may also include both an internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0186] The present disclosure also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in any of the above-mentioned optional modes.
[0187] The terms "first", "second", etc. in the specification, claims, and drawings of the embodiments of the present disclosure are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other step units inherent to these processes, methods, devices, products, or equipment.
[0188] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in this description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.
[0189] The method and related apparatus provided by the embodiments of the present disclosure are described with reference to the method flow chart and / or structural diagram provided by the embodiments of the present disclosure. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable application display device to generate a machine, so that the instructions executed by the processor of the computer or other programmable application display device generate instructions for implementing the process in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable application display device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable application display device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0190] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The description and examples are to be regarded as exemplary only, and the true scope of the present disclosure is indicated by the appended claims.
Claims
1. A resistance matching method for a CAN communication system, characterized in that: The CAN communication system comprises a CAN bus, at least one transmitting resistor array and at least one receiving resistor array, the transmitting end of the CAN bus is connected in parallel to at least one transmitting device and at least one receiving device, the transmitting device is connected in parallel to the transmitting resistor array, and the receiving device is connected in parallel to the receiving resistor array, and the method comprises: Enable the transmitting resistor array to a first initial resistance value, and enable the receiving resistor array to a second initial resistance value; Collecting the voltage value of the transmission end of the CAN bus; If the voltage value at the transmission end of the CAN bus does not meet the preset condition, the resistance value of the sending resistor array is fixed to the first initial resistance value, and the receiving resistor array is controlled to switch from the currently connected second initial resistance value to the first receiving resistance value.
2. The method according to claim 1, characterized in that The voltage value of the transmission end of the CAN bus includes: a first voltage value of the first transmission end and a second voltage value of the second transmission end, the first voltage value being greater than or equal to the second voltage value; The method further comprises: If the ratio of the number of the first voltage values collected within the first voltage range to the total number of collected values within the preset time period is not less than a first preset ratio threshold, and the ratio of the number of the second voltage values collected within the second voltage range to the total number of collected values within the preset time period is not less than a second preset ratio threshold, it is determined that the voltage value of the transmission end of the CAN bus meets the preset condition; or, If the ratio of the number of voltage differences between the first voltage value and the second voltage value in the third voltage range to the total number of acquisitions within the preset time period is not less than a third preset ratio threshold, it is determined that the voltage value at the transmission end of the CAN bus meets the preset condition.
3. The method according to claim 2, characterized in that The controlling the receiving resistor array to switch from the currently connected second initial resistance value to the connected first receiving resistance value includes: If the voltage difference between the first voltage value and the second voltage value is smaller than the lower limit of the third preset range, the receiving resistor array is controlled to switch from the currently connected second initial resistance value to a first receiving resistance value greater than the second initial resistance value.
4. The method according to claim 2, characterized in that: The first transmission end and the second transmission end are differential transmission lines, When there is no communication or communication and a first signal is transmitted on the CAN bus, the first voltage range and the second voltage range are both centered around 2.5V, and when there is communication and a second signal is transmitted on the CAN bus, the first voltage range is centered around 3.5V and the second voltage range is centered around 1.5V; or, When there is no communication or communication and a first signal is transmitted on the CAN bus, the third voltage range of the voltage difference is centered around 0V, and when there is communication and a second signal is transmitted on the CAN bus, the third voltage range of the voltage difference is centered around 2V.
5. The method according to claim 1, characterized in that The sampling rate of the voltage value of the transmission end of the CAN bus is greater than twice the corresponding communication frequency of the CAN bus.
6. The method according to claim 1, characterized in that The receiving device connected in parallel with the receiving resistor array is the receiving device farthest from the transmitting device, and the method further includes: Collecting a voltage value at the transmission end of the CAN bus after switching to the first receiving resistance value; If the voltage value at the transmission end of the CAN bus does not meet the preset condition and the resistance values in the receiving resistor array have not all been switched, the resistance value of the sending resistor array is fixed to the first initial resistance value, the receiving resistor array is controlled to switch to the unswitched resistance value, and it is re-determined whether the voltage value at the transmission end of the CAN bus meets the preset condition.
7. The method according to claim 6, characterized in that The method further comprises: If the voltage value of the transmission end of the CAN bus does not meet the preset condition, and the resistance values in the receiving resistor array are all switched, then determining whether the resistance values of the sending resistor array are all switched; If the resistance values of the sending resistor array have not all been switched, the sending resistor array is controlled to switch from the currently connected first initial resistance value to the first sending resistance value, the receiving resistor array is controlled to be enabled to the second initial resistance value, and it is re-determined whether the voltage value of the transmission end of the CAN bus meets the preset condition.
8. The method according to claim 1, characterized in that The CAN communication system comprises a plurality of receiving devices, each of the receiving devices is connected in parallel with a receiving resistor array, so that the receiving resistor array with the second initial resistance value is the receiving device farthest from the sending device; The method further comprises: If the voltage value at the transmission end of the CAN bus does not meet the preset condition, the resistance value of the sending resistor array is fixed to the first initial resistance value, and based on the distance between each of the receiving devices and the sending device, the resistance value of the receiving resistor array of each of the receiving devices is switched in a preset order, and it is re-determined whether the voltage value at the transmission end of the CAN bus meets the preset condition.
9. The method according to claim 8, characterized in that The method further comprises: If the voltage value of the transmission end of the CAN bus does not meet the preset condition, and the resistance values in the multiple receiving devices are all switched, then determining whether the resistance values of the sending resistor array are all switched; If the resistance values of the sending resistor array have not all been switched, the sending resistor array is controlled to switch from the currently connected first initial resistance value to the first sending resistance value, and the farthest receiving resistor array is controlled to switch to the second initial resistance value, and it is re-determined whether the voltage value of the transmission end of the CAN bus meets the preset condition.
10. The method according to any one of claims 1 to 9, characterized in that: The method further comprises: If the resistance values of the sending resistor array and the receiving resistor array are all switched, and the voltage value of the transmission end of the CAN bus still does not meet the preset conditions, the resistance value with the best performance is determined based on the resistance value of the resistor array corresponding to the voltage value of the transmission end of the CAN bus.
11. The method according to claim 10, characterized in that The voltage value of the transmission end of the CAN bus includes: a first voltage value of the first transmission end and a second voltage value of the second transmission end, the first voltage value being greater than or equal to the second voltage value; Determining the resistance value with the best performance according to the resistance value of the resistance array corresponding to the voltage value of the transmission end of the CAN bus includes: Record the resistance value of each group of receiving resistor arrays and transmitting resistor arrays, and the corresponding voltage value of the transmission end of the CAN bus within a preset time length; The resistance values of the receiving resistor array and the transmitting resistor array corresponding to the maximum value of the voltage difference between the first voltage value and the second voltage value in the third voltage range within the preset time period are used as the resistance values with optimal performance.
12. The method according to claim 1, characterized in that The method further comprises: After the receiving resistor array is switched to the first receiving resistor value, a voltage value of the transmission end of the CAN bus is collected; If the voltage value at the transmission end of the CAN bus meets the preset condition, the first initial resistance value and the first receiving resistance value are determined to be the resistance values with the best performance of the CAN communication system.
13. A resistance matching device for a CAN communication system, characterized in that: The CAN communication system comprises a CAN bus, at least one transmitting resistor array and at least one receiving resistor array, the transmitting end of the CAN bus is connected in parallel to at least one transmitting device and at least one receiving device, the transmitting device is connected in parallel to the transmitting resistor array, and the receiving device is connected in parallel to the receiving resistor array; Among them, the resistance matching device of the CAN communication system includes a controller, which is used to enable the sending resistor array to a first initial resistance value and enable the receiving resistor array to a second initial resistance value; collect the voltage value of the transmission end of the CAN bus; if the voltage value of the transmission end of the CAN bus does not meet the preset conditions, fix the resistance value of the sending resistor array to the first initial resistance value, and control the receiving resistor array to switch from the currently connected second initial resistance value to the first receiving resistance value.
14. A CAN communication system, characterized in that: It includes a CAN bus, at least one transmitting resistor array and at least one receiving resistor array; The transmission end of the CAN bus is connected in parallel with at least one transmitting device and at least one receiving device, wherein the transmitting device is connected in parallel with the transmitting resistor array, and the receiving device is connected in parallel with the receiving resistor array: and A control unit, connected in parallel to the transmission end of the CAN bus, is used to execute the method according to any one of claims 1 to 12.
15. The system according to claim 14, characterized in that The control unit is used to control the switching of resistance values in the sending resistor array and the receiving resistor array; The transmitting resistor array or the receiving resistor array includes a plurality of resistors and a plurality of switches, and the plurality of switches are electrically connected to the control unit; and the resistance values of the plurality of resistors are different.
