CN109802878A - A kind of CAN device and CAN bus baud rate automatic matching method and device - Google Patents
A kind of CAN device and CAN bus baud rate automatic matching method and device Download PDFInfo
- Publication number
- CN109802878A CN109802878A CN201910252841.4A CN201910252841A CN109802878A CN 109802878 A CN109802878 A CN 109802878A CN 201910252841 A CN201910252841 A CN 201910252841A CN 109802878 A CN109802878 A CN 109802878A
- Authority
- CN
- China
- Prior art keywords
- pulse width
- time
- width time
- baud rate
- bus
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 33
- 230000006870 function Effects 0.000 claims description 51
- 238000012163 sequencing technique Methods 0.000 claims description 18
- 238000004891 communication Methods 0.000 abstract description 32
- 238000010586 diagram Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000005587 bubbling Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 125000004122 cyclic group Chemical group 0.000 description 2
- 230000002349 favourable effect Effects 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000005070 sampling Methods 0.000 description 2
- 238000004590 computer program Methods 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Landscapes
- Dc Digital Transmission (AREA)
Abstract
The invention discloses a kind of CAN devices and CAN bus baud rate automatic matching method, comprising the following steps: uninterruptedly captures pulse width time by the PWM input capture mode of first timer within the preset time;The minimum pulse width time in the pulse width time and memory that capture each time is ranked up by ranking method, the minimum pulse width time in memory is updated, obtains the final minimum pulse width time;The baud rate of CAN device is calculated according to the minimum pulse width time, and the baud rate and CAN bus baud rate are subjected to Auto-matching.A kind of CAN device provided by the invention and CAN bus baud rate automatic matching method, the baud rate of CAN bus can fast and accurately be obtained and matched, and the communication of original system is not affected in matching process, effectively improve matched precision and matched speed, to effectively improve the matched efficiency of baud rate, and then effectively improve the communication efficiency between CAN bus and CAN device.
Description
Technical Field
The invention relates to the technical field of field bus communication, in particular to a method and a device for automatically matching Baud rates of CAN equipment and a CAN bus.
Background
The CAN is a short name for Controller Area Network (CAN), and a CAN bus protocol has become a standard bus of an automobile computer control system and an embedded industrial control area network. Various operating systems have integrated many board-level support packages themselves, and many vendors have provided corresponding board-level drivers, as well as support for the CAN bus protocol, as well as support for CAN device drivers in the form of character devices. However, the baud rate of the CAN bus is not unique, and when the baud rate of the CAN bus is not matched with that of a certain CAN device, normal communication cannot be performed. The CAN equipment bottom driver provided by a manufacturer generally only supports the receiving and sending functions and does not provide the self-adaptive function when the baud rates are not matched, so that when the baud rates of a CAN bus and connected CAN equipment are not matched, message receiving or sending is interrupted wrongly, and the CAN equipment cannot operate normally.
The existing CAN bus baud rate matching method measures rectangular wave time of a CAN bus through an input capturing and timer module, then according to each 5 continuous bits with the same value of the CAN bus, the characteristic of 1 supplementary bit CAN be inserted into a bit stream, 1-5 times baud rate values are calculated, and then the baud rates are tested one by one, and correct baud rates are screened out for automatic matching.
The CAN bus baud rate matching is carried out by using the existing CAN bus baud rate matching method, and the following problems exist:
the process of obtaining the correct baud rate by measurement is slower, so that the matching speed is slower; the matching precision is low, the bus message needs to be tested, and the communication of the original system is easily interfered when the matching is carried out.
Disclosure of Invention
The method for automatically matching the baud rate of the CAN equipment and the CAN bus CAN quickly and accurately obtain the baud rate of the CAN bus and match the baud rate without testing bus messages, does not interfere with the communication of an original system in the matching process, and effectively improves the matching precision and the matching speed, so that the baud rate matching efficiency is effectively improved, and the communication efficiency between the CAN bus and the CAN equipment is effectively improved.
In order to achieve the above object, in one aspect, an embodiment of the present invention provides an automatic matching method for a baud rate of a CAN device and a CAN bus, including the following steps:
continuously capturing pulse width time in a preset time through a PWM input capturing mode of a first timer;
sequencing the pulse width time captured each time and the minimum pulse width time in the memory by a sequencing method, and updating the minimum pulse width time in the memory to obtain the final minimum pulse width time;
and calculating the corresponding baud rate according to the minimum pulse width time, and automatically matching the baud rate with the CAN bus baud rate.
Further, the capturing the pulse width time without interruption in the PWM input capturing mode of the first timer within the preset time includes:
configuring a preset time by inputting a timer interrupt function in a second timer, wherein the preset time is 31.2 milliseconds; capturing pulse times without interruption by inputting a capture interrupt function in a PWM input capture mode of the first timer.
Furthermore, the first timer and the second timer are self-contained in a microcontroller, and the microcontroller is arranged in the CAN equipment.
Further, the sorting the pulse width time captured each time and the minimum pulse width time in the memory, and updating the minimum pulse width time in the memory to obtain the final minimum pulse width time includes:
capturing pulse width time by inputting a capture interrupt function;
reading the minimum pulse width time in the memory;
judging whether the minimum pulse width time is larger than the captured pulse width time or not;
if not, the capture interruption function is quitted;
if yes, storing the pulse width time in a memory, updating the pulse width time to be the minimum pulse width time, and quitting capturing an interrupt function after the updating is finished; after exiting the capture interrupt function, return to the step "capture pulse width time by input capture interrupt function".
Further, the calculating the baud rate of the CAN device according to the minimum pulse width time includes:
and calculating the reciprocal of the minimum pulse width time, wherein the reciprocal is the baud rate of the CAN equipment.
On the other hand, a second embodiment of the present invention provides an automatic matching device for a baud rate of a CAN device and a CAN bus, including a capture module, an update module and a matching module; wherein,
the capture module is used for capturing the pulse width time uninterruptedly in a PWM input capture mode of the first timer within a preset time;
the updating module is used for sequencing the pulse width time captured each time and the minimum pulse width time in the memory by a sequencing method, and updating the minimum pulse width time in the memory to obtain the final minimum pulse width time;
and the matching module is used for calculating the corresponding baud rate according to the minimum pulse width time and automatically matching the baud rate with the CAN bus baud rate.
Further, the capturing module comprises means for:
configuring a preset time by inputting an interrupt function in a second timer, wherein the preset time is 31.2 milliseconds; the pulse time is captured by inputting a capture interrupt function in a PWM input capture mode of the first timer.
Furthermore, the first timer and the second timer are self-contained in a microcontroller, and the microcontroller is arranged in the CAN equipment.
Further, the update module includes:
capturing pulse width time by inputting a capture interrupt function;
reading the minimum pulse width time in the memory;
judging whether the minimum pulse width time is larger than the captured pulse width time or not;
if not, the capture interruption function is quitted;
if yes, storing the pulse width time in a memory, updating the pulse width time to be the minimum pulse width time, and quitting capturing an interrupt function after the updating is finished;
after exiting the capture interrupt function, return to the step "capture pulse width time by input capture interrupt function".
Further, the matching module comprises:
and calculating the reciprocal of the minimum pulse width time, wherein the reciprocal is the baud rate of the CAN equipment, and the baud rate is automatically matched with the baud rate of the CAN bus.
The method for automatically matching the baud rate of the CAN equipment and the CAN bus CAN quickly and accurately obtain the baud rate of the CAN bus and match the baud rate, does not interfere with the communication of an original system in the matching process, and effectively improves the matching precision and the matching speed, so that the baud rate matching efficiency is effectively improved, and the communication efficiency between the CAN bus and the CAN equipment is further effectively improved.
Drawings
FIG. 1 is a schematic flow chart of a method for automatically matching a Baud rate of a CAN device and a CAN bus according to the present invention;
FIG. 2 is a schematic diagram illustrating the interrupt function processing flow of the timer according to the present invention;
FIG. 3 is a schematic diagram illustrating the operation of the PWM input capture mode of the timer provided by the present invention;
fig. 4 is a schematic structural diagram of an automatic matching device for the baud rate of the CAN device and the CAN bus provided by the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The first embodiment of the present invention:
please refer to fig. 1.
The embodiment of the invention provides a method for automatically matching the Baud rate of a CAN device and a CAN bus, which comprises the following steps:
s1, capturing the pulse width time uninterruptedly in a PWM input capturing mode of a first timer in preset time;
s2, sequencing the pulse width time captured each time and the minimum pulse width time in the memory by a sequencing method, and updating the minimum pulse width time in the memory to obtain the final minimum pulse width time;
and S3, calculating the corresponding baud rate according to the minimum pulse width time, and automatically matching the baud rate with the CAN bus baud rate.
In the embodiment of the present invention, it CAN be understood that, according to the frame structure characteristics of the CAN bus, the baud rate of the current CAN device communication is calculated within the maximum frame time, and when the baud rate of the CAN bus is automatically matched, only the initialization of the CAN bus module of the microprocessor needs to be started, the frequency division parameter and the sampling parameter are set, and the actual baud rate of the current CAN device communication is output on the bus without the step of trial and error.
According to the embodiment of the invention, the pulse width time is captured uninterruptedly in the preset time, so that the capture of the minimum pulse width time can be ensured; by adopting the PWM input capture mode of the first timer, the pulse width time can be automatically captured by hardware, and errors caused by software processing delay are effectively avoided; the method comprises the steps of sequencing the pulse width time captured each time and the minimum pulse width time in a memory by a sequencing method to obtain the minimum pulse width time in a frame time, calculating the baud rate of the CAN equipment by the minimum pulse width time according to the frame structure characteristics of the CAN bus without calculating a bus message, and effectively reducing the calculation amount of the baud rate, so that the efficiency of obtaining the communication baud rate of the current CAN equipment CAN be improved, the matching speed and accuracy of the CAN equipment and the CAN bus baud rate CAN be effectively improved, and the communication of an original system cannot be interfered in the matching process.
As a specific implementation manner of the embodiment of the present invention, capturing a pulse width time without interruption in a PWM input capture mode of a first timer within a preset time includes:
configuring a preset time by inputting a timer interrupt function into a second timer, wherein the preset time is 31.2 milliseconds; the pulse time is captured without interruption by configuring the input capture interrupt function in the PWM input mode of the first timer.
In the embodiment of the present invention, according to the frame structure characteristics of the CAN bus, the longest frame length is an extended data frame, and when 8 bytes of data are transmitted and a total of 28 padding bits in the most extreme case occur, the frame length may be 156 bits. The maximum CAN bus communication system frame time is therefore (1/5000) × 156 ═ 0.0312 seconds, i.e. 31.2 milliseconds. Due to the nature of the CAN bus, a normally operating system must have a pulse width of only one bit at least once in a complete frame of data. The preset time is set to be 31.2 milliseconds in the second timer, the input capture interrupt function is set in the first timer, the pulse width time is captured continuously within 31.2 milliseconds, and the minimum pulse width time in the frame time can be obtained.
It can be understood that, referring to fig. 3, the PWM input capture mode of the first timer according to the embodiment of the present invention operates as follows: the time value of T1 is collected firstly and stored in a memory, then the time value of T2 is collected and stored in the memory, the time value of T2 is completed, the time value of T1 is read in the capture interrupt function, and the reciprocal of the time value of T1 is N times of the baud rate of the system.
And repeating the steps, collecting time values of T1, T3, T5 and T7 in the frame time, taking the minimum value in the timing interruption function by using a bubbling method, and finally obtaining the time value of T5, wherein the obtained time value of T5 is one time of the baud rate of the system, the time values of T1 and T7 are two times of the baud rate of the system, and the time value of T3 is three times of the baud rate of the system.
As a specific implementation manner of the embodiment of the present invention, the first timer and the second timer are provided in a microcontroller, and the microcontroller is disposed in the CAN device.
Referring to fig. 2, sorting the pulse width time captured each time and the minimum pulse width time in the memory, and updating the minimum pulse width time in the memory to obtain the final minimum pulse width time includes:
capturing pulse width time by inputting a capture interrupt function;
reading the minimum pulse width time in the memory;
judging whether the minimum pulse width time is larger than the captured pulse width time;
if not, the capture interruption function is quitted;
if yes, storing the pulse width time in a memory, updating the pulse width time to be the minimum pulse width time, and quitting capturing the interrupt function after the updating is finished;
after exiting the capture interrupt function, return to the step "capture pulse width time by input capture interrupt function".
In the embodiment of the invention, each time the capture is completed, the first timer generates an interrupt, the pulse width time captured each time and the minimum pulse width time in the memory are sequenced by a bubble sequencing method, the minimum pulse width time in the memory is updated, the next capture is performed, and the first timer and the second timer stop working until 31.2 milliseconds later, so that the capture of the minimum pulse width time is completed.
As a specific implementation manner of the embodiment of the present invention, calculating the baud rate of the current CAN device communication according to the minimum pulse width time includes:
and calculating the reciprocal of the minimum pulse width time, wherein the reciprocal is the baud rate of the current CAN equipment communication.
In the embodiment of the present invention, it CAN be understood that, according to the frame structure characteristics of the CAN bus, the last bit of the CRC (cyclic redundancy check) segment is a delimiter which is a recessive level, the ACK (acknowledgement) segment located after the CRC segment includes a one-bit ACK slot and a one-bit ACK delimiter, and for a normal communication system, the ACK slot must be a recessive level, so the ACK slot must be a dominant level. Therefore, the CRC section and the ACK section CAN definitely have the condition that a recessive level and a dominant level exist at the same time, the time width of the rectangular wave at the position is measured, the minimum pulse width time is obtained by capture, namely the bit time is obtained, and the reciprocal of the bit time is the baud rate of the communication of the current CAN equipment.
The embodiment of the invention has the following beneficial effects:
the embodiment of the invention captures the pulse width time through the PWM input capture mode of the first timer, can realize the automatic capture of the pulse width time through hardware, avoids the error caused by software processing delay, effectively improves the precision of the captured minimum pulse width time, and is favorable for improving the precision of baud rate matching; by utilizing the characteristics of the CAN bus frame structure, the captured time is set as the maximum value of the CAN bus communication system frame time in the second timer, the pulse width time captured each time and the minimum pulse width time in the memory are sequenced by a bubble sequencing method to obtain the minimum pulse width time, the time of the minimum unit bit of the CAN bus frame structure is obtained according to the minimum pulse width time, different baud rates are not required to be tested for many times, the baud rate of the current CAN device communication CAN be quickly and accurately obtained, the matching speed and the matching precision of the CAN device and the CAN bus baud rate are favorably improved, the condition of interfering the original system communication CAN be effectively avoided, and the communication efficiency between the CAN bus and the CAN device CAN be effectively improved.
Second embodiment of the invention:
please refer to fig. 4.
The embodiment of the invention provides an automatic matching device for the baud rate of CAN equipment and a CAN bus, which comprises a capturing module 101, an updating module 102 and a matching module 103; wherein,
the capturing module 101 is configured to capture a pulse width time continuously within a preset time;
the updating module 102 is configured to sort the pulse width time captured each time and the minimum pulse width time in the memory, and update the minimum pulse width time in the memory to obtain a final minimum pulse width time;
and the matching module 103 is used for calculating the corresponding baud rate according to the minimum pulse width time and automatically matching the baud rate with the baud rate of the CAN bus.
In the embodiment of the present invention, it CAN be understood that, according to the frame structure characteristics of the CAN bus, the baud rate of the current CAN device communication is calculated within the maximum frame time, and when the baud rate of the CAN bus is automatically matched, only the initialization of the CAN bus module of the microprocessor needs to be started, the frequency division parameter and the sampling parameter are set, and the actual baud rate of the current CAN device communication is output on the bus without the step of trial and error.
According to the embodiment of the invention, the pulse width time is captured uninterruptedly in the preset time, so that the capture of the minimum pulse width time can be ensured; by adopting the PWM input capture mode of the first timer, the pulse width time can be automatically captured by hardware, and errors caused by software processing delay are effectively avoided; the method comprises the steps of sequencing the pulse width time captured each time and the minimum pulse width time in the memory by a sequencing method to obtain the minimum pulse width time in the frame time, calculating the baud rate of the current CAN equipment communication by the minimum pulse width time according to the frame structure characteristics of the CAN bus, and effectively reducing the calculation amount of the baud rate, thereby improving the efficiency of obtaining the baud rate of the current CAN equipment and further effectively improving the matching speed and accuracy of the CAN equipment and the CAN bus baud rate.
As a specific implementation manner of the embodiment of the present invention, the capturing module 101 includes:
configuring a preset time by inputting an interrupt function in a second timer, wherein the preset time is 31.2 milliseconds; the pulse time is captured by inputting a capture interrupt function in the first timer.
In the embodiment of the present invention, according to the frame structure characteristics of the CAN bus, the longest frame length is an extended data frame, and when 8 bytes of data are transmitted and a total of 28 padding bits in the most extreme case occur, the frame length may be 156 bits. The maximum CAN bus communication system frame time is therefore (1/5000) × 156 ═ 0.0312 seconds, i.e. 31.2 milliseconds. Due to the nature of the CAN bus, a normally operating system must have a pulse width of only one bit at least once in a complete frame of data. The preset time is set to be 31.2 milliseconds in the second timer, the input capture interrupt function is set in the first timer, and the pulse width time is captured continuously within 31.2 milliseconds, so that the minimum pulse width time can be obtained.
It can be understood that, referring to fig. 3, the PWM input capture mode of the first timer according to the embodiment of the present invention operates as follows: the time value of T1 is collected firstly and stored in a memory, then the time value of T2 is collected and stored in the memory, the time value of T2 is completed, the time value of T1 is read in the capture interrupt function, and the reciprocal of the time value of T1 is N times of the baud rate of the system.
And repeating the steps, collecting time values of T1, T3, T5 and T7 in the frame time, taking the minimum value in the timing interruption function by using a bubbling method, and finally obtaining the time value of T5, wherein the obtained time value of T5 is one time of the baud rate of the system, the time values of T1 and T7 are two times of the baud rate of the system, and the time value of T3 is three times of the baud rate of the system.
As a specific implementation manner of the embodiment of the present invention, the first timer and the second timer are provided in a microcontroller, and the microcontroller is disposed in the CAN device.
As a specific implementation manner of the embodiment of the present invention, the updating module 102 includes:
capturing pulse width time by inputting a capture interrupt function;
reading the minimum pulse width time in the memory;
judging whether the minimum pulse width time is larger than the captured pulse width time;
if not, the capture interruption function is quitted;
if yes, storing the pulse width time in a memory, updating the pulse width time to be the minimum pulse width time, and quitting capturing the interrupt function after the updating is finished;
after exiting the capture interrupt function, return to the step "capture pulse width time by input capture interrupt function".
In the embodiment of the invention, each time the capture is completed, the first timer generates an interrupt, the pulse width time captured each time and the minimum pulse width time in the memory are sequenced by a bubble sequencing method, the minimum pulse width time in the memory is updated, the next capture is performed, and the first timer and the second timer stop working until 31.2 milliseconds later, so that the capture of the minimum pulse width time is completed.
As a specific implementation manner of the embodiment of the present invention, the matching module 103 includes:
and calculating the reciprocal of the minimum pulse width time, wherein the reciprocal is the baud rate of the CAN equipment, and automatically matching the baud rate with the baud rate of the CAN bus.
In the embodiment of the present invention, according to the frame structure characteristics of the CAN bus, the last bit of the CRC (cyclic redundancy check) segment is a delimiter and is a recessive level, the ACK (acknowledgement) segment located after the CRC segment includes a one-bit ACK slot and a one-bit ACK delimiter, the ACK delimiter must also be a recessive level, and for a normal communication system, the ACK slot must be acknowledged, so the ACK slot must be a dominant level. Therefore, under the condition that both recessive level and dominant level exist in CRC section and ACK section, the rectangular wave time width is measured, the minimum pulse width time CAN be captured, namely the bit time is obtained, and the reciprocal of the bit time is the baud rate of the current CAN equipment communication.
The embodiment of the invention has the following beneficial effects:
the embodiment of the invention captures the pulse width time through the PWM input capture mode of the first timer, can realize the automatic capture of the pulse width time through hardware, avoids the error caused by software processing delay, effectively improves the precision of the captured minimum pulse width time, and is favorable for improving the precision of baud rate matching; by utilizing the characteristics of the CAN bus frame structure, the captured time is set as the maximum value of the CAN bus communication system frame time in the second timer, the pulse width time captured each time and the minimum pulse width time in the memory are sequenced by a bubble sequencing method to obtain the minimum pulse width time, the time of the minimum unit bit of the CAN bus frame structure is obtained according to the minimum pulse width time, different baud rates are not required to be tested for many times, the baud rate of the current CAN device communication CAN be quickly and accurately obtained, the matching speed and the matching precision of the CAN device and the CAN bus baud rate are favorably improved, the condition of interfering the original system communication CAN be effectively avoided, and the communication efficiency between the CAN bus and the CAN device CAN be effectively improved.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, and the program can be stored in a computer readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), an electrical carrier signal, a telecommunication signal, a software distribution medium, and the like.
The foregoing is a preferred embodiment of the present invention, and it should be noted that it would be apparent to those skilled in the art that various modifications and enhancements can be made without departing from the principles of the invention, and such modifications and enhancements are also considered to be within the scope of the invention.
Claims (10)
1. A method for automatically matching the Baud rate of a CAN device and a CAN bus is characterized by comprising the following steps: the method comprises the following steps:
continuously capturing pulse width time in a preset time through a PWM input capturing mode of a first timer;
sequencing the pulse width time captured each time and the minimum pulse width time in the memory by a sequencing method, and updating the minimum pulse width time in the memory to obtain the final minimum pulse width time;
and calculating the baud rate of the CAN equipment according to the minimum pulse width time, and automatically matching the baud rate with the baud rate of the CAN bus.
2. The method of claim 1 for automatically matching a CAN device with a CAN bus baud rate, wherein: the method for capturing the pulse width time without interruption in the preset time through the PWM input capture mode of the first timer includes:
configuring a preset time by inputting a timer interrupt function in a second timer, wherein the preset time is 31.2 milliseconds; the pulse time is captured without interruption by the PWM input capture mode input capture interrupt function in the first timer.
3. The method of claim 2 for automatically matching a CAN device to a CAN bus baud rate, wherein: the first timer and the second timer are self-contained in a microcontroller, and the microcontroller is arranged in the CAN equipment.
4. The method of claim 1 for automatically matching a CAN device with a CAN bus baud rate, wherein: the sorting the pulse width time captured each time and the minimum pulse width time in the memory, and updating the minimum pulse width time in the memory to obtain the final minimum pulse width time includes:
capturing pulse width time by inputting a capture interrupt function;
reading the minimum pulse width time in the memory;
judging whether the minimum pulse width time is larger than the captured pulse width time or not;
if not, the capture interruption function is quitted;
if yes, storing the pulse width time in a memory, updating the pulse width time to be the minimum pulse width time, and quitting capturing an interrupt function after the updating is finished;
after exiting the capture interrupt function, return to the step "capture pulse width time by input capture interrupt function".
5. The method of claim 1 for automatically matching a CAN device with a CAN bus baud rate, wherein: the calculating the baud rate of the CAN equipment according to the minimum pulse width time comprises the following steps:
and calculating the reciprocal of the minimum pulse width time, wherein the reciprocal is the baud rate of the CAN equipment.
6. The utility model provides a CAN equipment and CAN bus baud rate automatic matching device which characterized in that: the device comprises a capturing module, an updating module and a matching module; wherein,
the capture module is used for capturing the pulse width time uninterruptedly in a PWM input capture mode of the first timer within a preset time;
the updating module is used for sequencing the pulse width time captured each time and the minimum pulse width time in the memory by a sequencing method, and updating the minimum pulse width time in the memory to obtain the final minimum pulse width time;
and the matching module is used for calculating the baud rate of the CAN equipment according to the minimum pulse width time and automatically matching the baud rate with the baud rate of the CAN bus.
7. The device of claim 6 for automatically matching the baud rate of the CAN device and the CAN bus, wherein: the capture module comprising:
configuring a preset time by inputting an interrupt function in a second timer, wherein the preset time is 31.2 milliseconds; the pulse time is captured by inputting a capture interrupt function in a PWM input capture mode of the first timer.
8. The device of claim 7 for automatically matching a CAN device to a CAN bus baud rate, wherein: the first timer and the second timer are self-contained in a microcontroller, and the microcontroller is arranged in the CAN equipment.
9. The device of claim 6 for automatically matching the baud rate of the CAN device and the CAN bus, wherein: the update module comprises:
capturing pulse width time by inputting a capture interrupt function;
reading the minimum pulse width time in the memory;
judging whether the minimum pulse width time is larger than the captured pulse width time or not;
if not, the capture interruption function is quitted;
if yes, storing the pulse width time in a memory, updating the pulse width time to be the minimum pulse width time, and quitting capturing an interrupt function after the updating is finished;
after exiting the capture interrupt function, return to the step "capture pulse width time by input capture interrupt function".
10. The device of claim 6 for automatically matching the baud rate of the CAN device and the CAN bus, wherein: the matching module comprises:
and calculating the reciprocal of the minimum pulse width time, wherein the reciprocal is the baud rate of the CAN equipment, and the baud rate is automatically matched with the baud rate of the CAN bus.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910252841.4A CN109802878A (en) | 2019-03-29 | 2019-03-29 | A kind of CAN device and CAN bus baud rate automatic matching method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910252841.4A CN109802878A (en) | 2019-03-29 | 2019-03-29 | A kind of CAN device and CAN bus baud rate automatic matching method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109802878A true CN109802878A (en) | 2019-05-24 |
Family
ID=66564352
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910252841.4A Pending CN109802878A (en) | 2019-03-29 | 2019-03-29 | A kind of CAN device and CAN bus baud rate automatic matching method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109802878A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111198555A (en) * | 2019-12-19 | 2020-05-26 | 潍柴动力股份有限公司 | CAN network sampling point detection method and device, storage medium and electronic equipment |
CN111431783A (en) * | 2020-04-02 | 2020-07-17 | 希尔塔(苏州)信息技术有限公司 | CAN bus baud rate self-adaption method |
CN111796579A (en) * | 2020-06-30 | 2020-10-20 | 东风电驱动系统有限公司 | CAN bus baud rate configuration method and system for vehicle remote monitoring terminal |
CN112069098A (en) * | 2020-09-14 | 2020-12-11 | 上海东软载波微电子有限公司 | Baud rate identification method and device |
CN112118075A (en) * | 2020-08-09 | 2020-12-22 | 东风电驱动系统有限公司 | CAN bus baud rate self-adaption method and device |
CN112751738A (en) * | 2020-12-29 | 2021-05-04 | 北京万集智能网联技术有限公司 | Baud rate self-adaption method and device, computer equipment and readable storage medium |
CN115643289A (en) * | 2022-10-17 | 2023-01-24 | 北京天融信网络安全技术有限公司 | Data transmission method, device, equipment and medium |
CN115643125A (en) * | 2022-08-17 | 2023-01-24 | 南斗六星系统集成有限公司 | Method and system for rapidly matching CAN baud rate |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040081079A1 (en) * | 2002-04-16 | 2004-04-29 | Robert Bosch Gmbh | Method for monitoring a communication media access schedule of a communication controller of a communication system |
CN104199298A (en) * | 2014-08-18 | 2014-12-10 | 广西师范大学 | Controller area network (CAN) bus Baud rate self-adapting method |
CN106941399A (en) * | 2017-03-15 | 2017-07-11 | 广州致远电子股份有限公司 | A kind of dual rate CAN FD baud rate measuring method and device |
CN107070743A (en) * | 2017-03-17 | 2017-08-18 | 广州致远电子股份有限公司 | A kind of CAN load factor detection method and device |
-
2019
- 2019-03-29 CN CN201910252841.4A patent/CN109802878A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040081079A1 (en) * | 2002-04-16 | 2004-04-29 | Robert Bosch Gmbh | Method for monitoring a communication media access schedule of a communication controller of a communication system |
CN104199298A (en) * | 2014-08-18 | 2014-12-10 | 广西师范大学 | Controller area network (CAN) bus Baud rate self-adapting method |
CN106941399A (en) * | 2017-03-15 | 2017-07-11 | 广州致远电子股份有限公司 | A kind of dual rate CAN FD baud rate measuring method and device |
CN107070743A (en) * | 2017-03-17 | 2017-08-18 | 广州致远电子股份有限公司 | A kind of CAN load factor detection method and device |
Cited By (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111198555A (en) * | 2019-12-19 | 2020-05-26 | 潍柴动力股份有限公司 | CAN network sampling point detection method and device, storage medium and electronic equipment |
CN111198555B (en) * | 2019-12-19 | 2021-06-22 | 潍柴动力股份有限公司 | CAN network sampling point detection method and device, storage medium and electronic equipment |
CN111431783B (en) * | 2020-04-02 | 2021-12-31 | 希尔塔(苏州)信息技术有限公司 | CAN bus baud rate self-adaption method |
CN111431783A (en) * | 2020-04-02 | 2020-07-17 | 希尔塔(苏州)信息技术有限公司 | CAN bus baud rate self-adaption method |
CN111796579A (en) * | 2020-06-30 | 2020-10-20 | 东风电驱动系统有限公司 | CAN bus baud rate configuration method and system for vehicle remote monitoring terminal |
CN112118075A (en) * | 2020-08-09 | 2020-12-22 | 东风电驱动系统有限公司 | CAN bus baud rate self-adaption method and device |
CN112118075B (en) * | 2020-08-09 | 2023-06-02 | 东风电驱动系统有限公司 | CAN bus baud rate self-adaption method and device |
CN112069098A (en) * | 2020-09-14 | 2020-12-11 | 上海东软载波微电子有限公司 | Baud rate identification method and device |
CN112069098B (en) * | 2020-09-14 | 2022-04-15 | 上海东软载波微电子有限公司 | Baud rate identification method and device |
CN112751738B (en) * | 2020-12-29 | 2022-07-05 | 北京万集智能网联技术有限公司 | Baud rate self-adaption method and device, computer equipment and readable storage medium |
CN112751738A (en) * | 2020-12-29 | 2021-05-04 | 北京万集智能网联技术有限公司 | Baud rate self-adaption method and device, computer equipment and readable storage medium |
CN115643125A (en) * | 2022-08-17 | 2023-01-24 | 南斗六星系统集成有限公司 | Method and system for rapidly matching CAN baud rate |
CN115643289A (en) * | 2022-10-17 | 2023-01-24 | 北京天融信网络安全技术有限公司 | Data transmission method, device, equipment and medium |
CN115643289B (en) * | 2022-10-17 | 2023-08-25 | 北京天融信网络安全技术有限公司 | Data transmission method, device, equipment and medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109802878A (en) | A kind of CAN device and CAN bus baud rate automatic matching method and device | |
US10986008B2 (en) | Abnormality detection in an on-board network system | |
US11296965B2 (en) | Abnormality detection in an on-board network system | |
CN109150680B (en) | Self-adaptive address-determining networking circuit and method suitable for RS485 bus | |
CN100365994C (en) | Method and system for regulating ethernet | |
CN102033141B (en) | Test system based on CAN (Controller Area Network) bus automobile instrument and method | |
CN108566312A (en) | Off-line checking method, device and computer readable storage medium | |
CN102035564A (en) | Transceiver | |
CN101404556A (en) | One-wire bus communication method | |
CN109495215B (en) | Communication method, system and device of half-duplex bus and readable storage medium | |
CN107748509B (en) | ASI communication slave machine implementation method based on single chip microcomputer transceiving control | |
CN109921915A (en) | Test the method, apparatus and electronic equipment of real-time clock module arousal function | |
CN110601945A (en) | Dual-redundancy CAN bus communication system and communication method | |
CN108282365A (en) | Vehicle configuration method, device, terminal, vehicle-mounted terminal and vehicle | |
CN111315026A (en) | Channel selection method, device, gateway and computer readable storage medium | |
CN106878112B (en) | Gateway controller, data transmission method and device | |
CN108038127A (en) | A kind of method, apparatus, terminal device and the storage medium of data synchronization | |
CN113033752B (en) | Communication fault detection method, master machine and slave machine | |
CN116232891A (en) | Whole-vehicle OTA parallel refreshing upgrading method, device, equipment and storage medium | |
CN114598602A (en) | Data acquisition method and device, computer equipment and computer readable storage medium | |
CN114326673A (en) | Vehicle remote diagnosis method and device, connector and storage medium | |
CN106708759B (en) | Method for controlling digital input/output interface and processor | |
CN113556210A (en) | Upper computer and method for establishing communication connection | |
CN118101536B (en) | Automatic port state detection system | |
CN113133010B (en) | Wireless networking method, device, terminal equipment and storage medium |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190524 |
|
RJ01 | Rejection of invention patent application after publication |