CN111308922A - Method for preventing CAN bus from sending error frame and CAN bus equipment - Google Patents

Method for preventing CAN bus from sending error frame and CAN bus equipment Download PDF

Info

Publication number
CN111308922A
CN111308922A CN201910696131.0A CN201910696131A CN111308922A CN 111308922 A CN111308922 A CN 111308922A CN 201910696131 A CN201910696131 A CN 201910696131A CN 111308922 A CN111308922 A CN 111308922A
Authority
CN
China
Prior art keywords
power supply
supply voltage
bus
controller
voltage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910696131.0A
Other languages
Chinese (zh)
Other versions
CN111308922B (en
Inventor
曾佳兴
陈茹涛
张鹏
柯金铃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiamen Yaxon Networks Co Ltd
Original Assignee
Xiamen Yaxon Networks Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiamen Yaxon Networks Co Ltd filed Critical Xiamen Yaxon Networks Co Ltd
Priority to CN201910696131.0A priority Critical patent/CN111308922B/en
Publication of CN111308922A publication Critical patent/CN111308922A/en
Application granted granted Critical
Publication of CN111308922B publication Critical patent/CN111308922B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • G05B19/042Programme control other than numerical control, i.e. in sequence controllers or logic controllers using digital processors
    • G05B19/0423Input/output
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/20Pc systems
    • G05B2219/21Pc I-O input output
    • G05B2219/21063Bus, I-O connected to a bus

Abstract

The invention discloses a method for preventing a CAN bus from sending error frames and CAN bus equipment, which monitor the state of power supply voltage in an interruption mode, wherein when the power supply voltage is lower than a set voltage threshold, interruption is triggered, and the power supply voltage is scanned to obtain a waveform curve of the power supply voltage; comparing the waveform curve of the power supply voltage with the calibration model, and judging whether the waveform curve of the power supply voltage contains abnormal waveforms; and when the waveform curve of the power supply voltage contains abnormal waveforms, the CAN data is cut off from being transmitted. The method CAN make quick response to the fluctuation of the power supply and timely control the working states of the CAN transceiver and the controller, thereby avoiding the CAN error frame generated by the fluctuation of the power supply in the running process of the equipment and avoiding the occurrence of error control events.

Description

Method for preventing CAN bus from sending error frame and CAN bus equipment
Technical Field
The invention relates to the technical field of CAN bus anti-interference, in particular to a method for preventing CAN bus from sending error frame error and CAN bus equipment.
Background
The CAN bus is used as a backbone network of the current automobile communication network, and the communication reliability of the CAN bus needs to be ensured, so that the occurrence of error frames is reduced. The existing design is mainly based on the reliability of a hardware circuit, a filtering and isolating circuit is added on a power supply, and an isolating circuit is added on a digital communication interface, so that the stability of the circuit is enhanced; the common mode rejection device and the filter circuit are added on the CAN bus, so that the anti-interference capability of the CAN bus is enhanced; the existing design belongs to a passive response design, and a basic principle block diagram of a method for preventing a CAN bus from sending error frames is shown in figure 1.
Disclosure of Invention
In view of the above-mentioned defects of the prior art, an object of the present invention is to provide a method for preventing a CAN bus from sending an error frame and a CAN bus device, which CAN actively respond to power supply fluctuation and timely control the operating states of a CAN transceiver and a controller, thereby preventing the device from generating a CAN error frame due to power supply fluctuation during the operation process and avoiding an error control event.
In order to achieve the above object, the present invention provides a method for preventing error frame sending of a CAN bus, comprising the following steps:
setting a first mark and a second mark, marking the first mark and the second mark as invalid when the power supply voltage is normal, and establishing a power supply voltage model base, wherein the power supply voltage model base comprises a plurality of calibration models of the power supply voltage, and the calibration models comprise abnormal fluctuation types;
when the power supply voltage is lower than a set voltage threshold value, triggering interruption, marking the first mark as effective, and scanning the power supply voltage to obtain a waveform curve of the power supply voltage;
comparing the waveform curve of the power supply voltage with a calibration model in a power supply voltage model library, and judging whether the waveform curve of the power supply voltage contains abnormal fluctuation or not;
when the waveform curve of the power supply voltage contains abnormal fluctuation, marking the second mark as effective;
when the first flag and the second flag are simultaneously marked as valid, transmission of CAN data is turned off.
Further, the turning off the transmission of the CAN data includes: and closing the data interface of the CAN application layer, controlling the control end of the CAN transceiver through the output end after proper time delay, and turning off the CAN transceiver.
The invention also provides CAN bus equipment for preventing the CAN bus from generating error frames, which comprises a main electric state detection unit, an AD acquisition unit, a controller and a CAN transceiver unit;
the main electric state detection unit is used for detecting whether the power supply voltage is lower than a set voltage threshold value or not and outputting a comparison signal;
the AD sampling unit is used for scanning the power supply voltage to obtain a continuous sampling signal;
the CAN transceiver unit is used for transmitting CAN data;
the interrupt input end of the controller is connected with the output of the main electric state detection unit, and when the power supply voltage is lower than a set voltage threshold value, the output of the main electric state detection unit triggers interrupt; the input end of the controller is connected with the output end of the AD acquisition unit and receives continuous sampling signals; the controller is connected with the CAN transceiver unit through a serial port;
the controller performs the steps of:
when the output of the main electric state detection unit is triggered and interrupted, the continuous sampling signal of the power supply voltage is quickly read, and the waveform curve of the power supply voltage is obtained;
comparing the waveform curve of the power supply voltage with a calibration model of the power supply voltage, and judging whether the waveform curve of the power supply voltage contains abnormal fluctuation or not;
and when the waveform curve of the power supply voltage contains abnormal fluctuation, the CAN data output is turned off.
Further, the main power state monitoring unit comprises a voltage comparator, and when the power supply voltage of the equipment is lower than a comparison voltage threshold value, the output state of the voltage comparator is inverted to trigger interruption.
Further, the AD sampling unit includes an analog-to-digital conversion device, and the analog-to-digital conversion device periodically collects the power supply voltage to obtain a continuous sampling sequence of the power supply voltage.
Furthermore, the AD sampling unit is a voltage division circuit, the power supply voltage is input to the analog input end of the controller after being reduced by the voltage division circuit, and the controller rapidly scans the analog input end through an internal program to obtain a continuous sampling sequence of the power supply voltage.
Further, the sample period of the sequence of consecutive samples is less than 1 millisecond.
Further, the sampling duration of the continuous sampling sequence is not less than 50 milliseconds.
Further, the controller stores a power supply model library, the power supply model library comprises a plurality of power supply voltage calibration models, and the abnormal type of the power supply voltage is judged by comparing a power supply voltage curve with the power supply voltage calibration models.
Further, turning off the CAN data output includes the steps of: the controller MCU immediately closes the CAN application layer data interface in the internal program, controls the enabling pin of the CAN transceiver through the output end after proper time delay, and turns off the CAN transceiver.
Compared with the prior art, the invention has the advantages that: the state of a main power supply is monitored in real time, and a judgment strategy combining interrupt response and AD detection is adopted to carry out active response and control the working states of a CAN transceiver and a controller in time, so that the CAN error frame generated by power supply fluctuation in the operation process of equipment is avoided, and the occurrence of error control events is avoided.
Drawings
FIG. 1 is a schematic block diagram of a prior art CAN bus circuit;
FIG. 2 is a schematic block diagram of a CAN bus circuit with error frame protection for CAN bus according to a preferred embodiment of the present invention;
FIG. 3 is a functional block diagram of the interrupt response of the present invention;
FIG. 4 is a collection schematic block diagram of the present invention;
FIG. 5 is a model of the vehicle power snap calibration of the present invention;
FIG. 6 is a model of the present invention for calibrating the power supply at the instant of starting the vehicle.
Detailed Description
To further illustrate the various embodiments, the invention provides the accompanying drawings. The accompanying drawings, which are incorporated in and constitute a part of this disclosure, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the embodiments. Those skilled in the art will appreciate still other possible embodiments and advantages of the present invention with reference to these figures. Elements in the figures are not drawn to scale and like reference numerals are generally used to indicate like elements.
The invention will now be further described with reference to the accompanying drawings and detailed description.
Example one
The invention discloses a method for preventing a CAN bus from sending error frames, which controls the state of a CAN transceiver of CAN gateway equipment by monitoring the voltage state of a power supply of the equipment in real time and avoids the equipment from sending error frames due to unstable power supply.
As shown in fig. 2, the embodiment of the present invention is a CAN bus gateway of a vehicle, where the CAN gateway includes a controller MCU, a main electrical state detection unit, an AD acquisition unit, and a CAN transceiver, and the CAN gateway is powered by a vehicle-mounted battery and communicates with a vehicle-mounted CAN terminal node through a CAN bus.
The input of main electric state detection unit is connected with the battery, the output of main electric state detection unit is connected with the interrupt input INT of controller MCU, the input of AD acquisition unit is connected with the battery, the output of AD acquisition unit is connected with the input ADC of controller MCU, the controller and CAN transceiver are connected through serial ports, and simultaneously, the controller is connected with the control end STB of CAN transceiver through a general purpose input/output end GPIO, and the control end STB is used for controlling the enabling and the shutoff of CAN transceiver.
In the controller MCU, flags Flag1 and Flag2 are set, and in the present embodiment, when the power supply voltage is normal, Flag1 is set to invalid (Flag1 is 0) and Flag2 is set to invalid (Flag2 is 0).
In this embodiment, the main electric state detection unit is a voltage comparator circuit, when the power supply voltage is lower than the threshold voltage of the voltage comparator (for example, the normal power supply voltage of the automobile battery is 12.5V, the threshold voltage of the voltage comparator is set to 10.0V, when the power supply voltage is less than 10.0V), the state of the voltage comparator is reversed, the interrupt is triggered, when the interrupt is triggered, the Flag1 of the controller is marked as valid (Flag1 is 1), and the power supply interrupt response schematic diagram is as shown in fig. 3. In other embodiments, the voltage comparator circuit may be a more integrated circuit employing a supply voltage monitoring chip.
After the Flag1 is valid, the controller MCU triggers the ADC fast scanning mode, acquires the power supply voltage in real time through the AD acquisition unit, obtains the fluctuation curve of the power supply voltage by adopting a filtering algorithm, compares the fluctuation curve with a power supply calibration model of a vehicle power supply model library, judges the fluctuation of the power supply voltage, and accurately filters the normal power supply fluctuation; if the controller MCU judges that the fluctuation curve of the current power supply voltage contains abnormal fluctuation, the Flag2 is marked as effective, and the power supply AD scanning principle block diagram is shown in FIG. 4.
And the controller MCU triggers the ADC fast scanning mode to obtain a continuous sampling sequence of the power supply voltage, wherein the sampling period of the continuous sampling sequence is less than 1 millisecond, and the sampling duration of the continuous sampling sequence is not less than 50 milliseconds. Thereby accurately representing the fluctuation curve of the power supply voltage.
In a preferred embodiment of this embodiment, the AD acquisition unit is an independent analog-to-digital converter, and the analog-to-digital converter converts the power supply voltage into a digital signal and sends the digital signal to an input terminal of the controller MCU, where the input terminal may be a single pin or multiple pins, depending on whether the analog-to-digital converter adopted by the AD acquisition unit outputs in series or in parallel.
The analog-to-digital converter obtains continuous sampling signals of the power supply voltage through scanning (periodic sampling), the controller reads the continuous sampling signals of the power supply voltage, and the fluctuation curve of the power supply voltage is obtained through a filtering algorithm.
In other embodiments, the AD acquisition unit may also be an analog-to-digital conversion unit in the controller MCU, where the analog-to-digital conversion unit corresponds to an analog input end of the controller MCU.
The voltage of the storage battery is reduced by the voltage dividing circuit and then is input into the analog input end of the controller MCU, the controller MCU can rapidly scan the analog input end through an internal program, a continuous sampling signal is obtained through the analog-to-digital conversion unit, and then a fluctuation curve of the power supply voltage is obtained by adopting a filtering algorithm.
FIGS. 5 and 6 are two typical calibration models of power supply voltage, wherein FIG. 5 is a vehicle power supply instantaneous interruption calibration model, and the power supply voltage is a continuous drop and belongs to abnormal fluctuation; fig. 6 is a power supply calibration model at the moment of starting an automobile, wherein the power supply voltage fluctuates in a small range and returns to normal after lasting for a period of time, and the power supply voltage is normal in power supply fluctuation.
The controller can compare the acquired power supply voltage fluctuation curve with the calibration model of the power supply voltage through waveform fitting or other modes, and can accurately judge the current abnormal type of the power supply voltage.
When the Flag1 and the Flag2 are marked as valid at the same time, the controller MCU immediately turns off the data interface of the CAN application layer in the internal program, controls the pin STB of the CAN transceiver through the GPIO input/output terminal after a proper delay, and turns off the CAN transceiver, i.e., prevents the power supply of the system from continuously deteriorating to a level that cannot support the normal operation of the entire system, and the device continues to transmit data (error frames) to the CAN bus.
In the embodiment, the state of the main power supply is monitored in real time, and the judgment strategy combining interrupt response and AD detection is adopted to perform active response and control the working states of the CAN transceiver and the controller in time, so that the CAN error frame generated by power supply fluctuation in the operation process of the equipment is avoided, and the error control event is avoided.
While the invention has been particularly shown and described with reference to a preferred embodiment, it will be understood by those skilled in the art that various changes in form and detail may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. A method for preventing error frames sent by a CAN bus is characterized by comprising the following steps:
setting a first mark and a second mark, marking the first mark and the second mark as invalid when the power supply voltage is normal, and establishing a power supply voltage model base, wherein the power supply voltage model base comprises a plurality of calibration models of the power supply voltage, and the calibration models comprise abnormal fluctuation types;
when the power supply voltage is lower than a set voltage threshold value, triggering interruption, marking the first mark as effective, and scanning the power supply voltage to obtain a waveform curve of the power supply voltage;
comparing the waveform curve of the power supply voltage with a calibration model in a power supply voltage model library, and judging whether the waveform curve of the power supply voltage contains abnormal fluctuation or not;
when the waveform curve of the power supply voltage contains abnormal fluctuation, marking the second mark as effective;
when the first flag and the second flag are simultaneously marked as valid, transmission of CAN data is turned off.
2. The method of claim 1 for preventing error frames from being sent out by the CAN bus, wherein: the turning off the transmission of the CAN data includes: and closing the data interface of the CAN application layer, controlling the control end of the CAN transceiver through the output end after proper time delay, and turning off the CAN transceiver.
3. The utility model provides a CAN bus equipment that prevents that CAN bus from sending frame error, its characterized in that: the system comprises a main electric state detection unit, an AD acquisition unit, a controller and a CAN transceiver unit;
the main electric state detection unit is used for detecting whether the power supply voltage is lower than a set voltage threshold value or not and outputting a comparison signal;
the AD sampling unit is used for scanning the power supply voltage to obtain a continuous sampling signal;
the CAN transceiver unit is used for transmitting CAN data;
the interrupt input end of the controller is connected with the output of the main electric state detection unit, and when the power supply voltage is lower than a set voltage threshold value, the output of the main electric state detection unit triggers interrupt; the input end of the controller is connected with the output end of the AD acquisition unit and receives continuous sampling signals; the controller is connected with the CAN transceiver unit through a serial port;
the controller performs the steps of:
when the output of the main electric state detection unit is triggered and interrupted, the continuous sampling signal of the power supply voltage is quickly read, and the waveform curve of the power supply voltage is obtained;
comparing the waveform curve of the power supply voltage with a calibration model of the power supply voltage, and judging whether the waveform curve of the power supply voltage contains abnormal fluctuation or not;
and when the waveform curve of the power supply voltage contains abnormal fluctuation, the CAN data output is turned off.
4. The CAN-bus device of claim 3, wherein: and the main electric state monitoring unit comprises a voltage comparator, and when the power supply voltage of the equipment is lower than a comparison voltage threshold value, the output state of the voltage comparator is inverted to trigger interruption.
5. The CAN-bus device of claim 3, wherein: the AD sampling unit comprises an independent analog-to-digital conversion device, and the analog-to-digital conversion device periodically collects power supply voltage to obtain a continuous sampling sequence of the power supply voltage.
6. The CAN-bus device of claim 3, wherein: the AD sampling unit is an analog-digital conversion unit integrated with the controller, the power supply voltage is input to the analog input end of the controller after being subjected to voltage reduction, and the controller rapidly scans the analog input end through an internal program to obtain a continuous sampling sequence of the power supply voltage.
7. The CAN-bus device of claim 5 or 6, wherein: the sample period of the sequence of consecutive samples is less than 1 millisecond.
8. The CAN-bus device of claim 5 or 6, wherein: the sample duration of the continuous sequence of samples is not less than 50 milliseconds.
9. The CAN-bus device of claim 3, wherein: the controller stores a power supply voltage calibration model, and judges the abnormal type of the power supply voltage by comparing a power supply voltage curve with the power supply voltage calibration model.
10. The CAN-bus device of claim 3, wherein: turning off the CAN data output comprises the following steps: the controller MCU immediately closes the CAN application layer data interface in the internal program, controls the enabling pin of the CAN transceiver through the output end after proper time delay, and turns off the CAN transceiver.
CN201910696131.0A 2019-07-30 2019-07-30 Method for preventing CAN bus from sending error frame and CAN bus equipment Active CN111308922B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910696131.0A CN111308922B (en) 2019-07-30 2019-07-30 Method for preventing CAN bus from sending error frame and CAN bus equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910696131.0A CN111308922B (en) 2019-07-30 2019-07-30 Method for preventing CAN bus from sending error frame and CAN bus equipment

Publications (2)

Publication Number Publication Date
CN111308922A true CN111308922A (en) 2020-06-19
CN111308922B CN111308922B (en) 2021-01-15

Family

ID=71157954

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910696131.0A Active CN111308922B (en) 2019-07-30 2019-07-30 Method for preventing CAN bus from sending error frame and CAN bus equipment

Country Status (1)

Country Link
CN (1) CN111308922B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101494571A (en) * 2009-01-22 2009-07-29 上海华魏自动化设备有限公司 CAN bus self detection recovery device and method
CN103259686A (en) * 2013-05-31 2013-08-21 浙江大学 CAN bus network fault diagnosis method based on disperse error events
CN103475523A (en) * 2013-09-10 2013-12-25 浙江大学 CAN bus analysis system with bus error analysis function
US8699356B2 (en) * 2010-12-20 2014-04-15 Deere & Company Method and system for diagnosing a fault or open circuit in a network
CN104298224A (en) * 2014-09-12 2015-01-21 中国第一汽车股份有限公司 Automatic vehicle-mounted electronic control unit CAN bus communication testing device and system
CN108776302A (en) * 2018-02-01 2018-11-09 哈尔滨理工大学 Motor bench experimental provision based on CAN bus and load control method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101494571A (en) * 2009-01-22 2009-07-29 上海华魏自动化设备有限公司 CAN bus self detection recovery device and method
US8699356B2 (en) * 2010-12-20 2014-04-15 Deere & Company Method and system for diagnosing a fault or open circuit in a network
CN103259686A (en) * 2013-05-31 2013-08-21 浙江大学 CAN bus network fault diagnosis method based on disperse error events
CN103475523A (en) * 2013-09-10 2013-12-25 浙江大学 CAN bus analysis system with bus error analysis function
CN104298224A (en) * 2014-09-12 2015-01-21 中国第一汽车股份有限公司 Automatic vehicle-mounted electronic control unit CAN bus communication testing device and system
CN108776302A (en) * 2018-02-01 2018-11-09 哈尔滨理工大学 Motor bench experimental provision based on CAN bus and load control method

Also Published As

Publication number Publication date
CN111308922B (en) 2021-01-15

Similar Documents

Publication Publication Date Title
CN109116085B (en) Automobile quiescent current monitoring system and method
US6677759B2 (en) Method and apparatus for high-voltage battery array monitoring sensors network
EP3623197B1 (en) Power-down detection circuit and control method
CN112034818B (en) Controller fault analysis method and system
CN110769446B (en) Intelligent monitoring system and method for 5G communication base station
CN110954849A (en) Abnormity detection system and method for electrical equipment and monitoring terminal
CN101604851B (en) Monitoring system and method of storage battery LVD value
CN111308922B (en) Method for preventing CAN bus from sending error frame and CAN bus equipment
CN110376931A (en) A kind of functional safety current output module of high diagnosis coverage rate
CN218830444U (en) CMOS image sensor tester
CN115560801A (en) Intelligent substation equipment operation and maintenance management and control system
CN106058650A (en) Vehicle-mounted centralized-control intelligent power distribution device
CN115598513A (en) Fault diagnosis method, fault diagnosis device, electronic device and storage medium
CN115166333A (en) Hall device based data processing method and device and Hall current sensor
CN201355444Y (en) Engineering machinery remote monitoring device with communication cable detection function
CN114035555A (en) PLC controller fault detection system
CN211698653U (en) Power-on self-checking system and robot
CN209821303U (en) Lightning protection equipment detecting system
CN112824127B (en) Multi-path acquisition temperature limit protection device and method for train storage battery box
CN111668931A (en) Power distribution operation and maintenance system and power distribution operation and maintenance method
CN110967634A (en) Temperature detection circuit, temperature detection method and battery management system
CN215575347U (en) Slope intelligent monitoring equipment fault self-diagnosis circuit
CN217769604U (en) Signal twin device
CN216057255U (en) Hard disk video recorder with built-in temperature and humidity detection function
CN217689808U (en) Remote fault diagnosis system for automobile

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant