CAN communication voltage balancing method and system based on voltage difference detection and storage medium
Through pressure difference detection and current judgment, the pressure difference balance and circuit maintenance of the CAN communication circuit under different isolation states is achieved, which solves the chip damage caused by common mode signal interference, and improves the circuit safety and user experience.
Patent Information
- Application Number
- CN202411205328.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-24
AI Technical Summary
CAN communication circuits are prone to common mode signal interference in different isolation states, resulting in the risk of chip damage, especially when the isolation state of the other party's equipment cannot be predicted.
Through the method based on pressure differential detection, the common mode signal and ground current of the CAN communication bus are collected in real time, the signal size and flow direction are judged, and the voltage difference balance and circuit maintenance are carried out to ensure that the circuit operates safely under different isolation states.
It effectively reduces the risk of CAN communication circuit damage, improves the safety and user experience of the communication circuit, and ensures the stable operation of the circuit under different isolation states.
Smart Images

Figure CN119182686A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of CAN communication, and more specifically, to a CAN communication voltage balancing method, system and storage medium based on voltage difference detection. Background Art
[0002] CAN communication, the full name of which is Controller Area Network, is a serial communication protocol with the characteristics of high performance and strong reliability. It is widely used in distributed control systems in automobiles and industrial automation. The connection between the CAN communication chip and the ground level of the power supply where it is located indicates whether the CAN communication chip is in an isolated state. The ground level of the power supply is also called the power ground; the connection between the CAN communication chip and the power ground indicates a non-isolated state, and the disconnection between the CAN communication chip and the power ground indicates an isolated state.
[0003] At present, there are three main working conditions of CAN communication circuits: First, the CAN communication circuits of the communication devices at both ends are in non-isolated working conditions. Due to the noise interference of the power ground, the power ground of the communication devices at both ends will have inconsistent potentials, resulting in reflux current and generating common-mode signals. Since the CAN communication bus is subject to common-mode interference, there is a risk of damaging the CAN communication chip circuit. Second, the CAN communication circuits of the communication devices at both ends are in isolated working conditions. Since the reference ground levels of the transmitter and the receiver between the communication devices are not connected, that is, they are not grounded, there will also be common-mode signals, and there is a risk of damaging the CAN communication chip circuit. Third, one end of the communication devices at both ends is in isolated working conditions and the other end is in non-isolated working conditions. Since it is impossible to know whether the other device is in isolated working conditions before communication, it is impossible to set its own circuit working conditions before communication. If the default isolation or non-isolation working conditions are used, there will be a probability of generating common-mode signals, and there is also a risk of damaging the CAN communication chip circuit. Summary of the invention
[0004] In view of the above problems, the purpose of the present invention is to provide a CAN communication voltage balancing method, system and storage medium based on pressure difference detection, set the device itself to an isolated working condition, and balance the pressure difference by real-time acquisition of the common-mode signal of the CAN communication bus and timely discharge it according to the size of the common-mode signal; in addition, by acquiring the ground current of the CAN communication bus, it is determined whether the common-mode signal is discharged in time according to the direction and size of the current, and it is determined whether the circuit is set to open automatically, thereby effectively reducing the risk of damage to the CAN communication circuit and improving the safety of the communication circuit and the user experience.
[0005] A first aspect of the present invention provides a CAN communication voltage balancing method based on voltage difference detection, the method comprising:
[0006] Acquire first common mode voltage information and second common mode voltage information;
[0007] Calculating a difference between the first common-mode voltage information and the second common-mode voltage information to obtain first common-mode voltage difference information;
[0008] Determining whether the first common-mode pressure difference information exceeds a preset first difference threshold;
[0009] If yes, start the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information, and obtain the first loop voltage information and the second loop voltage information;
[0010] Determining first ground loop current information according to the first loop voltage information and the second loop voltage information;
[0011] Determining whether the first ground loop current information exceeds a preset first current threshold;
[0012] If yes, then set it to enter maintenance state;
[0013] If not, the working parameters of the pressure difference balancing task are set according to the first ground loop current information.
[0014] In this solution, starting the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information is specifically:
[0015] Determining whether the first common-mode voltage information is greater than the second common-mode voltage information;
[0016] If it is greater, the first switch information is sent to start the forward pressure difference balancing task;
[0017] If it is less than, the second switch information is sent to start the reverse pressure difference balancing task;
[0018] The pressure difference balancing task includes a forward pressure difference balancing task or a reverse pressure difference balancing task, and the turn-on pressure difference balancing task is to turn on a pressure difference balancing resistor.
[0019] In this solution, the first ground loop current information is determined according to the first loop voltage information and the second loop voltage information, specifically:
[0020] Acquire first resistance information and second resistance information;
[0021] Obtaining first operational amplifier voltage information according to the first loop voltage information and the first resistance information;
[0022] Calculate the difference between the second loop voltage information and the first operational amplifier voltage information to determine second difference information;
[0023] First ground loop current information is obtained according to the second difference information and the second resistance information.
[0024] In this solution, the working parameters of the pressure difference balancing task are set according to the first ground loop current information, specifically:
[0025] The working parameters of the pressure difference balancing task include the resistance value of the pressure difference balancing resistor;
[0026] According to the first ground loop current information, searching a preset resistance value correspondence table of the voltage difference balancing resistor to obtain first resistance value information;
[0027] The voltage difference balancing resistor is adjusted according to the first resistance information.
[0028] In this solution, the settings enter the maintenance state, specifically:
[0029] Send a disconnect signal and terminate the pressure difference balancing task;
[0030] Set and send the maintenance status flag.
[0031] This plan also includes:
[0032] Determining whether the first ground loop current information is lower than a preset second current threshold;
[0033] If yes, the adjustment operation of the working parameters of the pressure difference balancing task is skipped.
[0034] A second aspect of the present invention provides a CAN communication voltage balancing system based on pressure difference detection, including a CAN communication voltage balancing method program based on pressure difference detection, wherein the CAN communication voltage balancing method program based on pressure difference detection implements the following steps when executed by the processor:
[0035] Acquire first common mode voltage information and second common mode voltage information;
[0036] Calculating a difference between the first common-mode voltage information and the second common-mode voltage information to obtain first common-mode voltage difference information;
[0037] Determining whether the first common-mode pressure difference information exceeds a preset first difference threshold;
[0038] If yes, start the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information, and obtain the first loop voltage information and the second loop voltage information;
[0039] Determining first ground loop current information according to the first loop voltage information and the second loop voltage information;
[0040] Determining whether the first ground loop current information exceeds a preset first current threshold;
[0041] If yes, then set it to enter maintenance state;
[0042] If not, the working parameters of the pressure difference balancing task are set according to the first ground loop current information.
[0043] In this solution, starting the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information is specifically:
[0044] Determining whether the first common-mode voltage information is greater than the second common-mode voltage information;
[0045] If it is greater, the first switch information is sent to start the forward pressure difference balancing task;
[0046] If it is less than, the second switch information is sent to start the reverse pressure difference balancing task;
[0047] The pressure difference balancing task includes a forward pressure difference balancing task or a reverse pressure difference balancing task, and the turn-on pressure difference balancing task is to turn on a pressure difference balancing resistor.
[0048] In this solution, the first ground loop current information is determined according to the first loop voltage information and the second loop voltage information, specifically:
[0049] Acquire first resistance information and second resistance information;
[0050] Obtaining first operational amplifier voltage information according to the first loop voltage information and the first resistance information;
[0051] Calculate the difference between the second loop voltage information and the first operational amplifier voltage information to determine second difference information;
[0052] First ground loop current information is obtained according to the second difference information and the second resistance information.
[0053] A third aspect of the present invention provides a computer-readable storage medium, which includes a CAN communication voltage balancing method program based on pressure difference detection. When the CAN communication voltage balancing method program based on pressure difference detection is executed by a processor, the steps of the CAN communication voltage balancing method based on pressure difference detection as described in any one of the above items are implemented.
[0054] The present invention provides a CAN communication voltage balancing method, system and storage medium based on pressure difference detection. The method obtains common-mode pressure difference information and performs unidirectional suppression according to the common-mode pressure difference information to balance the common-mode pressure difference. Then, the current information of the CAN bus to the ground loop is obtained, and it is judged whether the interference signal existing in the CAN bus is effectively eliminated according to the flow direction and size of the current information, and the working condition of the anti-interference device is confirmed to determine whether the circuit is set to open automatically, so as to effectively reduce the risk of damage to the CAN communication circuit and improve the safety of the communication circuit and the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and should not be regarded as limiting the scope.
[0056] Figure 1 A flow chart of a CAN communication voltage balancing method based on voltage difference detection of the present invention is shown;
[0057] Figure 2 A flow chart for selecting a pressure difference balancing task provided by an embodiment of the present invention is shown;
[0058] Figure 3 A flowchart of obtaining first ground loop current information provided by an embodiment of the present invention is shown;
[0059] Figure 4 The block diagram of the CAN communication voltage balancing system based on voltage difference detection of the present invention is shown. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0061] Unless otherwise defined, all terms (including technical and scientific terms) used in the embodiments of the present invention have the same meanings as commonly understood by those of ordinary skill in the art to which the present invention belongs. It should also be understood that terms such as those defined in common dictionaries should be interpreted as having meanings consistent with their meanings in the context of the relevant technology, and should not be interpreted in an idealized or extremely formal sense, unless the embodiments of the present invention are clearly defined in this way.
[0062] The words "first", "second" and similar words used in the embodiments of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Words such as "one", "an" or "the" and similar words do not indicate a quantity limitation, but indicate the existence of at least one. Similarly, words such as "include" or "comprise" mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects.
[0063] "Connected" or "connected" and the like are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The steps preceding or following the method of the embodiment of the present invention are not necessarily performed in exact order. Instead, the various steps may be processed in reverse order or simultaneously. At the same time, other operations may be added to these processes, or one or more steps may be removed from these processes.
[0064] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0065] Figure 1 The flowchart of the CAN communication voltage balancing method based on voltage difference detection of the present invention is shown.
[0066] like Figure 1 As shown, the present invention discloses a CAN communication voltage balancing method based on voltage difference detection, and the method includes:
[0067] S102, obtaining first common mode voltage information and second common mode voltage information;
[0068] S104, calculating a difference between the first common mode voltage information and the second common mode voltage information to obtain first common mode voltage difference information;
[0069] S106, determining whether the first common-mode pressure difference information exceeds a preset first difference threshold;
[0070] S108: If yes, start the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information, and obtain the first loop voltage information and the second loop voltage information;
[0071] S110, determining first-to-ground loop current information according to the first loop voltage information and the second loop voltage information;
[0072] S112, determining whether the first ground loop current information exceeds a preset first current threshold;
[0073] S114, if yes, then set to enter maintenance state;
[0074] S116: If not, setting the working parameters of the pressure difference balancing task according to the first ground loop current information.
[0075] It should be noted that the first common-mode voltage information and the second common-mode voltage information are respectively the forward common-mode voltage signal and the reverse common-mode voltage signal of CAN communication, and the common-mode voltage signal is the voltage difference between the CAN communication chip circuit ground level and the power supply ground of the CAN communication device. The difference between the first common-mode voltage information and the second common-mode voltage information can obtain the common-mode voltage difference signal between the CAN communication chip circuit ground level and the power supply ground of the CAN communication device, which is the first common-mode voltage difference information. First, it is determined whether the first common-mode voltage difference information exceeds the preset first difference threshold. In practical applications, the first difference threshold is a preset fixed voltage value, usually a commonly used weak current voltage value such as 3.3 volts or 5 volts. When the first common-mode voltage difference information exceeds the preset first difference threshold, it indicates that the common-mode signal is too large, and the common-mode voltage difference needs to be balanced through a voltage difference balancing operation. In the present invention, the voltage difference balancing operation is set to a forward voltage difference balance or a reverse voltage difference balance according to the size relationship between the first common-mode voltage information and the second common-mode voltage information. Then, the first loop voltage information and the second loop voltage information are obtained; wherein the first voltage loop information and the second voltage loop information are the voltage values of the resistors connected to the positive and negative inputs of the current acquisition device, respectively. According to the first voltage loop information and the second voltage loop information, the first ground loop current information is obtained, and the first ground loop current information is the ground current value of the CAN bus, which can reflect the strength of the common mode interference. By judging whether the first ground loop current information exceeds the preset current threshold, the working state of the common mode interference protection device set in the CAN communication circuit can be detected. When the first ground loop current information exceeds the preset current threshold, it indicates that the common mode interference protection device is damaged. At this time, the CAN communication circuit is set to maintenance mode, and the communication and pressure difference balance operations are suspended; when the first ground loop current information does not exceed the preset current threshold, it indicates that the common mode interference protection device is in a normal working state, and the working parameters of the pressure difference balance are adjusted according to the first ground loop current information to adjust the effect of the pressure difference balance operation.
[0076] Figure 2 A flow chart for selecting a pressure difference balancing task provided by an embodiment of the present invention is shown.
[0077] According to an embodiment of the present invention, Figure 2 As shown, starting the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information is specifically as follows:
[0078] S202, determining whether the first common mode voltage information is greater than the second common mode voltage information;
[0079] S204, if it is greater than, sending the first switch information to start the forward pressure difference balancing task;
[0080] S206, if it is less than, sending the second switch information to start the reverse pressure difference balancing task;
[0081] The pressure difference balancing task includes a forward pressure difference balancing task or a reverse pressure difference balancing task, and the turn-on pressure difference balancing task is to turn on a pressure difference balancing resistor.
[0082] It should be noted that the first common-mode voltage information is the forward voltage difference between the CAN communication chip circuit ground level and the power ground of the CAN communication device, and the second common-mode voltage information is the reverse voltage difference between the CAN communication chip circuit ground level and the power ground of the CAN communication device. The voltage difference balance task is to hinder the common-mode voltage difference signal through the voltage difference balance resistor, which includes forward voltage difference balance and reverse voltage difference balance. When the first common-mode voltage information is greater than the second common-mode voltage information, it means that the forward voltage difference between the CAN communication chip circuit ground level and the power ground of the CAN communication device is higher than the reverse voltage difference, and the voltage difference balance resistor is required to hinder the forward voltage difference so that the forward voltage difference and the reverse voltage difference are balanced, which is the forward voltage difference balance operation. When the first common-mode voltage information is less than the second common-mode voltage information, it means that the reverse voltage difference between the CAN communication chip circuit ground level and the power ground of the CAN communication device is higher than the forward voltage difference, and the voltage difference balance resistor is required to hinder the reverse voltage difference so that the reverse voltage difference and the forward voltage difference are balanced, which is the reverse voltage difference balance operation.
[0083] Figure 3 A flow chart of obtaining first ground loop current information provided by an embodiment of the present invention is shown.
[0084] According to an embodiment of the present invention, Figure 3 As shown, the first ground loop current information is determined according to the first loop voltage information and the second loop voltage information, specifically:
[0085] S302, obtaining first resistance information and second resistance information;
[0086] S304, obtaining first operational amplifier voltage information according to the first loop voltage information and the first resistance information;
[0087] S306, calculating the difference between the second loop voltage information and the first operational amplifier voltage information to determine second difference information;
[0088] S308: Obtain first ground loop current information according to the second difference information and the second resistance information.
[0089] It should be noted that in an embodiment of the present invention, the current acquisition device is an operational amplifier circuit, the first voltage loop information is the voltage value of the first resistor connected to the positive pole of the operational amplifier to the ground, the second voltage loop information is the voltage value of the second resistor connected to the negative pole of the operational amplifier to the ground, and the first ground loop current information is the current value of the second resistor. According to the first resistance information and the first voltage loop information of the first resistor, the first operational amplifier voltage information, that is, the voltage value of the positive pole of the operational amplifier, can be obtained by the voltage divider theorem. Due to the electrical characteristics of the operational amplifier, the positive pole voltage value and the negative pole voltage value of the operational amplifier in normal operation are almost the same, therefore, the negative pole voltage value of the operational amplifier can be considered to be the same as the first operational amplifier voltage information. Then, the difference between the second loop voltage information and the first operational amplifier voltage information is calculated, that is, the voltage difference value across the second resistor, and the current value of the second resistor can be calculated by Ohm's theorem, therefore, the first ground loop current information is determined.
[0090] According to an embodiment of the present invention, the working parameters of the pressure difference balancing task are set according to the first ground loop current information, specifically:
[0091] The working parameters of the pressure difference balancing task include the resistance value of the pressure difference balancing resistor;
[0092] According to the first ground loop current information, searching a preset resistance value correspondence table of the voltage difference balancing resistor to obtain first resistance value information;
[0093] The voltage difference balancing resistor is adjusted according to the first resistance information.
[0094] It should be noted that, in an embodiment of the present invention, the resistance of the voltage difference balancing resistor is adjusted to adjust the blocking effect on the first common-mode voltage information or the second common-mode voltage information. When the common-mode interference is greater, the resistance value required to balance the voltage difference is greater. In an embodiment of the present invention, the first ground loop current information can reflect the strength of the common-mode interference. When the voltage difference balancing task is executed, the first resistance value information is obtained according to the first ground loop current information by querying the resistance value correspondence table of the voltage difference balancing resistor preset in the memory. Finally, the resistance value of the voltage difference balancing resistor is adjusted according to the first resistance value information to achieve the purpose of adjusting the voltage difference balancing effect.
[0095] According to an embodiment of the present invention, the setting enters the maintenance state, specifically:
[0096] Send a disconnect signal and terminate the pressure difference balancing task;
[0097] Set and send the maintenance status flag.
[0098] It should be noted that when it is determined to enter the maintenance state, it means that the common mode interference protection device is damaged. First, a disconnection signal is sent to disconnect the device communication bus at both ends of the CAN communication, and the differential pressure balance resistor is disconnected to terminate the differential pressure balance task. Then, by setting and sending the maintenance status flag information, a notification letter is sent to the user, indicating that there is a device damage in the CAN communication circuit, and maintenance or replacement operations need to be taken.
[0099] According to an embodiment of the present invention, it also includes:
[0100] Determining whether the first ground loop current information is lower than a preset second current threshold;
[0101] If yes, the adjustment operation of the working parameters of the pressure difference balancing task is skipped.
[0102] It should be noted that, in the embodiment of the present invention, the first ground loop current information can reflect the strength of the common mode interference. When the first ground loop current information is lower than the preset second current threshold, it means that the common mode interference signal is weak and does not affect the communication state of the CAN communication device. By skipping the adjustment operation of the working parameters of the pressure difference balancing task, the computing pressure of the processor is reduced.
[0103] It is worth mentioning that it also includes:
[0104] The voltage difference balancing resistor is composed of one or more resistors connected in series or in parallel;
[0105] The conduction condition of the resistor is selected by a preset conduction device to adjust the resistance value information of the voltage difference balancing resistor;
[0106] At least one of the resistors is a digitally adjustable resistor;
[0107] Data interaction is performed with the digitally adjustable resistor via preset communication instructions to obtain and adjust resistance information of the digitally adjustable resistor.
[0108] It should be noted that, as an implementation, the voltage difference balancing resistor is composed of one or more resistors connected in series or in parallel, and the on-off state of the resistor can be selected by a conductor to achieve the purpose of adjusting the resistance value of the voltage difference balancing resistor; wherein the conductor includes but is not limited to a switch circuit, an analog switch chip circuit, a gate chip circuit, etc. As an implementation, at least one of the resistors constituting the voltage difference balancing resistor is a digitally adjustable variable resistor. The resistance value of the digitally adjustable variable resistor is obtained or adjusted through a preset communication instruction to achieve the purpose of adjusting the resistance value of the voltage difference balancing resistor.
[0109] It is worth mentioning that it also includes:
[0110] Determining whether the first common-mode pressure difference information exceeds a preset second difference threshold;
[0111] If so, terminate the pressure difference balancing task.
[0112] It should be noted that in actual applications, overvoltage detection and protection operations are also set through software. When the first common-mode differential pressure information exceeds the preset second difference threshold, it means that the common-mode differential pressure signal is too large. If the differential pressure balancing operation is continued through the differential pressure balancing resistor, there is a risk of damaging the circuit. At this time, it is necessary to disconnect the differential pressure balancing resistor to terminate the differential pressure balancing task and protect the circuit.
[0113] It is worth mentioning that it also includes:
[0114] Obtain at least three most recent pieces of the first ground loop current information in the record, and record them as first current record information;
[0115] Fitting a current change curve according to the first current recording information, and obtaining slope information of the current change curve;
[0116] The frequency of pressure difference detection is adjusted according to the slope information.
[0117] It should be noted that the first ground loop current information is continuously collected and recorded according to a preset time period. According to at least three of the most recent first ground loop current information in the record, a current change curve is fitted, and the slope information of the fitting curve is obtained according to the fitting curve calculation. The change of the first ground loop current is determined according to the slope information. When it is determined by the slope change that the first ground loop current is in a stable state, the frequency of the pressure difference detection can be reduced to achieve the purpose of reducing the computing pressure of the processor; if the first ground loop current is in an unstable state, the frequency of the pressure difference detection is increased to increase the sensitivity of the pressure difference balance operation.
[0118] Figure 4 The block diagram of the CAN communication voltage balancing system based on voltage difference detection of the present invention is shown.
[0119] like Figure 4 As shown, the present invention discloses a CAN communication voltage balancing system 4 based on pressure difference detection, including a memory 41 and a processor 42, wherein the memory includes a CAN communication voltage balancing method program based on pressure difference detection, and the CAN communication voltage balancing method program based on pressure difference detection is executed by the processor to implement the following steps:
[0120] Acquire first common mode voltage information and second common mode voltage information;
[0121] Calculating a difference between the first common-mode voltage information and the second common-mode voltage information to obtain first common-mode voltage difference information;
[0122] Determining whether the first common-mode pressure difference information exceeds a preset first difference threshold;
[0123] If yes, start the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information, and obtain the first loop voltage information and the second loop voltage information;
[0124] Determining first ground loop current information according to the first loop voltage information and the second loop voltage information;
[0125] Determining whether the first ground loop current information exceeds a preset first current threshold;
[0126] If yes, then set it to enter maintenance state;
[0127] If not, the working parameters of the pressure difference balancing task are set according to the first ground loop current information.
[0128] It should be noted that the first common-mode voltage information and the second common-mode voltage information are respectively the forward common-mode voltage signal and the reverse common-mode voltage signal of CAN communication, and the common-mode voltage signal is the voltage difference between the CAN communication chip circuit ground level and the power supply ground of the CAN communication device. The difference between the first common-mode voltage information and the second common-mode voltage information can obtain the common-mode voltage difference signal between the CAN communication chip circuit ground level and the power supply ground of the CAN communication device, which is the first common-mode voltage difference information. First, it is determined whether the first common-mode voltage difference information exceeds the preset first difference threshold. In practical applications, the first difference threshold is a preset fixed voltage value, usually a commonly used weak current voltage value such as 3.3 volts or 5 volts. When the first common-mode voltage difference information exceeds the preset first difference threshold, it indicates that the common-mode signal is too large, and the common-mode voltage difference needs to be balanced through a voltage difference balancing operation. In the present invention, the voltage difference balancing operation is set to a forward voltage difference balance or a reverse voltage difference balance according to the size relationship between the first common-mode voltage information and the second common-mode voltage information. Then, the first loop voltage information and the second loop voltage information are obtained; wherein the first voltage loop information and the second voltage loop information are the voltage values of the resistors connected to the positive and negative inputs of the current acquisition device, respectively. According to the first voltage loop information and the second voltage loop information, the first ground loop current information is obtained, and the first ground loop current information is the ground current value of the CAN bus, which can reflect the strength of the common mode interference. By judging whether the first ground loop current information exceeds the preset current threshold, the working state of the common mode interference protection device set in the CAN communication circuit can be detected. When the first ground loop current information exceeds the preset current threshold, it indicates that the common mode interference protection device is damaged. At this time, the CAN communication circuit is set to maintenance mode, and the communication and pressure difference balance operations are suspended; when the first ground loop current information does not exceed the preset current threshold, it indicates that the common mode interference protection device is in a normal working state, and the working parameters of the pressure difference balance are adjusted according to the first ground loop current information to adjust the effect of the pressure difference balance operation.
[0129] According to an embodiment of the present invention, starting the voltage difference balancing task according to the first common-mode voltage information and the second common-mode voltage information is specifically:
[0130] Determining whether the first common-mode voltage information is greater than the second common-mode voltage information;
[0131] If it is greater, the first switch information is sent to start the forward pressure difference balancing task;
[0132] If it is less than, the second switch information is sent to start the reverse pressure difference balancing task;
[0133] The pressure difference balancing task includes a forward pressure difference balancing task or a reverse pressure difference balancing task, and the turn-on pressure difference balancing task is to turn on a pressure difference balancing resistor.
[0134] It should be noted that the first common-mode voltage information is the forward voltage difference between the CAN communication chip circuit ground level and the power ground of the CAN communication device, and the second common-mode voltage information is the reverse voltage difference between the CAN communication chip circuit ground level and the power ground of the CAN communication device. The voltage difference balance task is to hinder the common-mode voltage difference signal through the voltage difference balance resistor, which includes forward voltage difference balance and reverse voltage difference balance. When the first common-mode voltage information is greater than the second common-mode voltage information, it means that the forward voltage difference between the CAN communication chip circuit ground level and the power ground of the CAN communication device is higher than the reverse voltage difference, and the voltage difference balance resistor is required to hinder the forward voltage difference so that the forward voltage difference and the reverse voltage difference are balanced, which is the forward voltage difference balance operation. When the first common-mode voltage information is less than the second common-mode voltage information, it means that the reverse voltage difference between the CAN communication chip circuit ground level and the power ground of the CAN communication device is higher than the forward voltage difference, and the voltage difference balance resistor is required to hinder the reverse voltage difference so that the reverse voltage difference and the forward voltage difference are balanced, which is the reverse voltage difference balance operation.
[0135] According to an embodiment of the present invention, determining the first ground loop current information according to the first loop voltage information and the second loop voltage information is specifically:
[0136] Acquire first resistance information and second resistance information;
[0137] Obtaining first operational amplifier voltage information according to the first loop voltage information and the first resistance information;
[0138] Calculate the difference between the second loop voltage information and the first operational amplifier voltage information to determine second difference information;
[0139] First ground loop current information is obtained according to the second difference information and the second resistance information.
[0140] It should be noted that in an embodiment of the present invention, the current acquisition device is an operational amplifier circuit, the first voltage loop information is the voltage value of the first resistor connected to the positive pole of the operational amplifier to the ground, the second voltage loop information is the voltage value of the second resistor connected to the negative pole of the operational amplifier to the ground, and the first ground loop current information is the current value of the second resistor. According to the first resistance information and the first voltage loop information of the first resistor, the first operational amplifier voltage information, that is, the voltage value of the positive pole of the operational amplifier, can be obtained by the voltage divider theorem. Due to the electrical characteristics of the operational amplifier, the positive pole voltage value and the negative pole voltage value of the operational amplifier in normal operation are almost the same, therefore, the negative pole voltage value of the operational amplifier can be considered to be the same as the first operational amplifier voltage information. Then, the difference between the second loop voltage information and the first operational amplifier voltage information is calculated, that is, the voltage difference value across the second resistor, and the current value of the second resistor can be calculated by Ohm's theorem, therefore, the first ground loop current information is determined.
[0141] According to an embodiment of the present invention, the working parameters of the pressure difference balancing task are set according to the first ground loop current information, specifically:
[0142] The working parameters of the pressure difference balancing task include the resistance value of the pressure difference balancing resistor;
[0143] According to the first ground loop current information, searching a preset resistance value correspondence table of the voltage difference balancing resistor to obtain first resistance value information;
[0144] The voltage difference balancing resistor is adjusted according to the first resistance information.
[0145] It should be noted that, in an embodiment of the present invention, the resistance of the voltage difference balancing resistor is adjusted to adjust the blocking effect on the first common-mode voltage information or the second common-mode voltage information. When the common-mode interference is greater, the resistance value required to balance the voltage difference is greater. In an embodiment of the present invention, the first ground loop current information can reflect the strength of the common-mode interference. When the voltage difference balancing task is executed, the first resistance value information is obtained according to the first ground loop current information by querying the resistance value correspondence table of the voltage difference balancing resistor preset in the memory. Finally, the resistance value of the voltage difference balancing resistor is adjusted according to the first resistance value information to achieve the purpose of adjusting the voltage difference balancing effect.
[0146] According to an embodiment of the present invention, the setting enters the maintenance state, specifically:
[0147] Send a disconnect signal and terminate the pressure difference balancing task;
[0148] Set and send the maintenance status flag.
[0149] It should be noted that when it is determined to enter the maintenance state, it means that the common mode interference protection device is damaged. First, a disconnection signal is sent to disconnect the device communication bus at both ends of the CAN communication, and the differential pressure balance resistor is disconnected to terminate the differential pressure balance task. Then, by setting and sending the maintenance status flag information, a notification letter is sent to the user, indicating that there is a device damage in the CAN communication circuit, and maintenance or replacement operations need to be taken.
[0150] According to an embodiment of the present invention, it also includes:
[0151] Determining whether the first ground loop current information is lower than a preset second current threshold;
[0152] If yes, the adjustment operation of the working parameters of the pressure difference balancing task is skipped.
[0153] It should be noted that, in the embodiment of the present invention, the first ground loop current information can reflect the strength of the common mode interference. When the first ground loop current information is lower than the preset second current threshold, it means that the common mode interference signal is weak and does not affect the communication state of the CAN communication device. By skipping the adjustment operation of the working parameters of the pressure difference balancing task, the computing pressure of the processor is reduced.
[0154] It is worth mentioning that it also includes:
[0155] The voltage difference balancing resistor is composed of one or more resistors connected in series or in parallel;
[0156] The conduction condition of the resistor is selected by a preset conduction device to adjust the resistance value information of the voltage difference balancing resistor;
[0157] At least one of the resistors is a digitally adjustable resistor;
[0158] Data interaction is performed with the digitally adjustable resistor via preset communication instructions to obtain and adjust resistance information of the digitally adjustable resistor.
[0159] It should be noted that, as an implementation, the voltage difference balancing resistor is composed of one or more resistors connected in series or in parallel, and the on-off state of the resistor can be selected by a conductor to achieve the purpose of adjusting the resistance value of the voltage difference balancing resistor; wherein the conductor includes but is not limited to a switch circuit, an analog switch chip circuit, a gate chip circuit, etc. As an implementation, at least one of the resistors constituting the voltage difference balancing resistor is a digitally adjustable variable resistor. The resistance value of the digitally adjustable variable resistor is obtained or adjusted through a preset communication instruction to achieve the purpose of adjusting the resistance value of the voltage difference balancing resistor.
[0160] It is worth mentioning that it also includes:
[0161] Determining whether the first common-mode pressure difference information exceeds a preset second difference threshold;
[0162] If so, terminate the pressure difference balancing task.
[0163] It should be noted that in actual applications, overvoltage detection and protection operations are also set through software. When the first common-mode differential pressure information exceeds the preset second difference threshold, it means that the common-mode differential pressure signal is too large. If the differential pressure balancing operation is continued through the differential pressure balancing resistor, there is a risk of damaging the circuit. At this time, it is necessary to disconnect the differential pressure balancing resistor to terminate the differential pressure balancing task and protect the circuit.
[0164] It is worth mentioning that it also includes:
[0165] Obtain at least three most recent pieces of the first ground loop current information in the record, and record them as first current record information;
[0166] Fitting a current change curve according to the first current recording information, and obtaining slope information of the current change curve;
[0167] The frequency of pressure difference detection is adjusted according to the slope information.
[0168] It should be noted that the first ground loop current information is continuously collected and recorded according to a preset time period. According to at least three of the most recent first ground loop current information in the record, a current change curve is fitted, and the slope information of the fitting curve is obtained according to the fitting curve calculation. The change of the first ground loop current is determined according to the slope information. When it is determined by the slope change that the first ground loop current is in a stable state, the frequency of the pressure difference detection can be reduced to achieve the purpose of reducing the computing pressure of the processor; if the first ground loop current is in an unstable state, the frequency of the pressure difference detection is increased to increase the sensitivity of the pressure difference balance operation.
[0169] A third aspect of the present invention provides a computer-readable storage medium, which includes a CAN communication voltage balancing method program based on pressure difference detection. When the CAN communication voltage balancing method program based on pressure difference detection is executed by a processor, the steps of the CAN communication voltage balancing method based on pressure difference detection as described in any one of the above items are implemented.
[0170] The present invention provides a CAN communication voltage balancing method, system and storage medium based on pressure difference detection. The method obtains common-mode pressure difference information and performs unidirectional suppression according to the common-mode pressure difference information to balance the common-mode pressure difference. Then, the current information of the CAN bus to the ground loop is obtained, and it is judged whether the interference signal existing in the CAN bus is effectively eliminated according to the flow direction and size of the current information, and the working condition of the anti-interference device is confirmed to determine whether the circuit is set to open automatically, so as to effectively reduce the risk of damage to the CAN communication circuit and improve the safety of the communication circuit and the user experience.
[0171] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0172] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A CAN communication voltage balancing method based on voltage difference detection, characterized in that: The method comprises: Acquire first common mode voltage information and second common mode voltage information; Calculating a difference between the first common-mode voltage information and the second common-mode voltage information to obtain first common-mode voltage difference information; Determining whether the first common-mode pressure difference information exceeds a preset first difference threshold; If yes, start the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information, and obtain the first loop voltage information and the second loop voltage information; Determining first ground loop current information according to the first loop voltage information and the second loop voltage information; Determining whether the first ground loop current information exceeds a preset first current threshold; If yes, then set it to enter maintenance state; If not, the working parameters of the pressure difference balancing task are set according to the first ground loop current information.
2. The CAN communication voltage balancing method based on voltage difference detection according to claim 1 is characterized in that: The starting of the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information is specifically: Determining whether the first common-mode voltage information is greater than the second common-mode voltage information; If it is greater, the first switch information is sent to start the forward pressure difference balancing task; If it is less than, the second switch information is sent to start the reverse pressure difference balancing task; The pressure difference balancing task includes a forward pressure difference balancing task or a reverse pressure difference balancing task, and the turn-on pressure difference balancing task is to turn on a pressure difference balancing resistor.
3. The CAN communication voltage balancing method based on pressure difference detection according to claim 1 is characterized in that: The determining of the first ground loop current information according to the first loop voltage information and the second loop voltage information is specifically: Acquire first resistance information and second resistance information; Obtaining first operational amplifier voltage information according to the first loop voltage information and the first resistance information; Calculate the difference between the second loop voltage information and the first operational amplifier voltage information to determine second difference information; First ground loop current information is obtained according to the second difference information and the second resistance information.
4. The CAN communication voltage balancing method based on pressure difference detection according to claim 1 is characterized in that: The step of setting the working parameters of the pressure difference balancing task according to the first ground loop current information is specifically: The working parameters of the pressure difference balancing task include the resistance value of the pressure difference balancing resistor; According to the first ground loop current information, searching a preset resistance value correspondence table of the voltage difference balancing resistor to obtain first resistance value information; The voltage difference balancing resistor is adjusted according to the first resistance information.
5. The CAN communication voltage balancing method based on pressure difference detection according to claim 1 is characterized in that: The settings enter maintenance status, specifically: Send a disconnect signal and terminate the pressure difference balancing task; Set and send the maintenance status flag.
6. The CAN communication voltage balancing method based on pressure difference detection according to claim 1 is characterized in that: Also includes: Determining whether the first ground loop current information is lower than a preset second current threshold; If yes, the adjustment operation of the working parameters of the pressure difference balancing task is skipped.
7. A CAN communication voltage balancing system based on voltage difference detection, characterized in that: The system includes a memory and a processor, wherein the memory includes a CAN communication voltage balancing method program based on voltage difference detection, and the CAN communication voltage balancing method program based on voltage difference detection implements the following steps when executed by the processor: Acquire first common mode voltage information and second common mode voltage information; Calculating a difference between the first common-mode voltage information and the second common-mode voltage information to obtain first common-mode voltage difference information; Determining whether the first common-mode pressure difference information exceeds a preset first difference threshold; If yes, start the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information, and obtain the first loop voltage information and the second loop voltage information; Determining first ground loop current information according to the first loop voltage information and the second loop voltage information; Determining whether the first ground loop current information exceeds a preset first current threshold; If yes, then set it to enter maintenance state; If not, the working parameters of the pressure difference balancing task are set according to the first ground loop current information.
8. The CAN communication voltage balancing system based on pressure difference detection according to claim 7 is characterized in that: The starting of the voltage difference balancing task according to the first common mode voltage information and the second common mode voltage information is specifically: Determining whether the first common-mode voltage information is greater than the second common-mode voltage information; If it is greater, the first switch information is sent to start the forward pressure difference balancing task; If it is less than, the second switch information is sent to start the reverse pressure difference balancing task; The pressure difference balancing task includes a forward pressure difference balancing task or a reverse pressure difference balancing task, and the turn-on pressure difference balancing task is to turn on a pressure difference balancing resistor.
9. The CAN communication voltage balancing system based on voltage difference detection according to claim 7, characterized in that: The determining of the first ground loop current information according to the first loop voltage information and the second loop voltage information is specifically: Acquire first resistance information and second resistance information; Obtaining first operational amplifier voltage information according to the first loop voltage information and the first resistance information; Calculate the difference between the second loop voltage information and the first operational amplifier voltage information to determine second difference information; First ground loop current information is obtained according to the second difference information and the second resistance information.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer-readable storage medium includes a CAN communication voltage balancing method program based on pressure difference detection. When the CAN communication voltage balancing method program based on pressure difference detection is executed by a processor, the steps of the CAN communication voltage balancing method based on pressure difference detection as described in any one of claims 1 to 6 are implemented.
