Single bus baud rate adaptation method based on can-fd and can
Patent Information
- Application Number
- CN202310556766.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-17
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2043-05-17
AI Technical Summary
[0003]在储能领域,对储能电站系统而言,装机容量是变化的,随着装机容量的改变,储能电站系统控制子节点的个数和现场总线的长度和所处环境也会随着变化,导致现场总线无法保持一个稳定且高速的传输数据的状态
[0036]本发明利用主设备和从设备上配置有CAN控制器和CAN-FD控制器的特点,利用一个稳定的CAN通信调节高速CAN-FD控制器的数据段波特率,提高了通信效率。
Smart Images

Figure CN116610602B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of information processing technology, and mainly relates to a single-bus baud rate adaptive method based on CAN-FD and CAN. Background Technology
[0002] Currently, with the increasing number of electronic devices applied in vehicles, users' demands for vehicle network data transmission rates and bandwidth are also increasing exponentially. As one of the hottest technological developments in the field of automation, fieldbus has become an important support for distributed control systems to achieve reliable and real-time data communication between nodes. CAN bus is one of the most widely used open fieldbuses, initially applied in automotive electronics and, with technological advancements, widely used in marine, aviation, medical, and industrial control fields. However, traditional CAN bus has limitations in transmission bandwidth and data payload. According to the CAN 2.0 protocol, the effective payload of each CAN message frame is only 8 bytes, and the maximum CAN bus speed is limited to 1 Mbit / s, reaching its limit in terms of transmission efficiency and reliability. Therefore, to meet the requirements of high bandwidth, high throughput, high reliability, strong compatibility, and low cost for automotive buses, the new CAN FD bus has emerged.
[0003] In the field of energy storage, the installed capacity of energy storage power station systems is variable. As the installed capacity changes, the number of control sub-nodes of the energy storage power station system, the length of the fieldbus, and the environment also change, causing the fieldbus to be unable to maintain a stable and high-speed data transmission state.
[0004] Therefore, this invention is based on the CAN-FD bus protocol (ISO 11898-2:2016) and utilizes the feature of the processor having multiple CAN controllers. Each control unit in a CAN bus uses both CAN and CAN-FD controllers. The low-speed CAN controller is used to adjust the CAN-FD communication rate in real time. A higher transmission rate is used in applications with fewer nodes, shorter bus length, and better environment; while a lower transmission rate is used in applications with more nodes, longer bus length, and worse environment. This allows for real-time adjustment of the CAN-FD communication rate in changing bus environments, which is an innovative approach. Summary of the Invention
[0005] The purpose of this invention is to provide a single-bus baud rate adaptive method based on CAN-FD and CAN.
[0006] In a first aspect, the present invention provides a single-bus baud rate adaptive method based on CAN-FD and CAN, comprising the following steps:
[0007] Step 1: Each control node of a CAN bus has one master device and n slave devices, where n ≥ 1; the master device and slave devices are configured with one CAN controller and one CAN-FD controller;
[0008] Preferably, the CAN controller can be configured from another CAN-FD controller of the same type as the CAN-FD controller currently configured in the device.
[0009] Step 2, Initialization
[0010] Set the CAN controller baud rate to f0, where 50kbps < f0 ≤ 250kbps;
[0011] The arbitration segment baud rate f1 and data segment baud rate f2 of the CAN-FD controller are initialized to the CAN controller's baud rate f0;
[0012] Configure the frame ID of the master device CAN controller to ID0 and the frame ID of the master device CAN-FD controller to FD_ID0; set the frame IDs of the slave device CAN controllers to ID1 to IDn respectively, and set the frame IDs of the slave device CAN-FD controllers to FD_ID1 to FD_IDn respectively.
[0013] Configure the master device's CAN-FD filter to only receive frame messages with identifiers FD_ID1 to FD_IDn, and the master device's CAN filter to only receive frame messages with identifiers ID1 to IDn; configure the slave device's CAN-FD filter to only receive frame messages with identifier FD_ID0, and the slave device's CAN filter to only receive frame messages with identifier ID0, to prevent erroneous frames from appearing on the CAN bus due to rate mismatch, which would affect communication efficiency;
[0014] Step 3: Adaptively update the baud rate f2 of the CAN-FD controller data segment for both the master and slave devices:
[0015] The adaptive update process of the CAN-FD controller data segment baud rate f2 of the master device is as follows:
[0016] A-1. The master device CAN controller sends handshake frames via broadcast and records the number of slave devices. Each slave device responds with a handshake response frame after receiving the handshake frame. If a slave device responds with a handshake response frame, it is determined that the device is online. If a slave device does not respond with a handshake response frame to the master device, it is determined that the slave device is offline.
[0017] A-2. Specify the baud rate status flag of the data segment of all CAN-FD controllers on the CAN bus as an indeterminate state;
[0018] A-3. The main device CAN-FD controller determines whether the current CAN-FD data segment baud rate status flag is in a definite state. If the CAN-FD data segment baud rate status flag is in an indefinite state, then proceed to step A-4; if the CAN-FD data segment baud rate status flag is in a definite state, then proceed to step A-6.
[0019] A-4. The master device CAN-FD controller receives the baud rate switching response frame sent by the slave device and determines whether all online slave devices have replied with the baud rate switching response frame.
[0020] If all responses are received, the baud rate of the master device's CAN-FD controller data segment is updated to f2 = f2 + F1, where F1 is a preset value. The master device's CAN controller sends a CAN-FD data segment baud rate switching command via broadcast, causing the slave device's CAN-FD controller data segment baud rate to switch to the updated CAN-FD controller data segment baud rate f2, and then returns to step A-3.
[0021] If the master device cannot receive at least one baud rate switching response frame from a slave device, then update the baud rate of the data segment of the master device's CAN-FD controller, f2 = f2 - F1; at this point, it is determined that all CAN-FD controllers on the CAN bus use the communication rate of arbitration segment f0 and data segment f2, and then proceed to step A-5;
[0022] A-5. The CAN-FD data segment baud rate status flag is updated to the confirmed state. The master device CAN controller sends a CAN-FD data segment baud rate switching command via broadcast, causing the slave device CAN-FD controller to switch the data segment baud rate to f2, and then returns to step A-3.
[0023] A-6. The master and slave devices communicate using the CAN-FD controller according to the arbitration segment baud rate f0 and the updated data segment baud rate f2.
[0024] A-7. During the communication process between the master device and the online slave device in CAN-FD, if the communication between the master device and a certain slave device fails more than a specified number of times, or if the number of online slave devices changes or the field CAN bus environment changes, then the current data segment baud rate f2 of the CAN-FD controller is considered inapplicable. It is necessary to switch the CAN-FD data segment baud rate and repeat operation steps A-1 to A-7 to continue data communication with the new baud rate.
[0025] The adaptive update process of the CAN-FD controller data segment baud rate f2 of the slave device is as follows:
[0026] B-1. The CAN controller of the device determines whether it has received a handshake frame from the master device. If it has, the CAN controller of the device replies with a handshake response frame to the CAN controller of the master device. If it has not received, proceed to step B-2.
[0027] B-2. The slave device's CAN controller determines whether it has received a CAN-FD data segment baud rate switching command from the master device's CAN controller. If it has, the slave device updates the CAN-FD data segment baud rate to the master device's specified value, and the slave device's CAN-FD controller replies with a baud rate switching response frame to the master device's CAN-FD controller. If it has not received a baud rate switching response frame, it continues to communicate with the master device using CAN-FD at the current baud rate.
[0028] Secondly, the present invention provides a data communication method in which a master device and a slave device communicate using a CAN-FD controller according to an arbitration segment baud rate f0 and a data segment baud rate f2; the data segment baud rate f2 is adaptively updated using the above method.
[0029] Thirdly, the present invention provides a single-bus baud rate adaptive system for implementing the above method, comprising:
[0030] The initialization module sets the CAN controller baud rate of the master and slave devices to f0, where 50kbps < f0 ≤ 250kbps; the arbitration segment baud rate f1 and data segment baud rate f2 of the CAN-FD controllers of the master and slave devices are initialized to the CAN controller baud rate f0.
[0031] The master device baud rate adaptive update module adaptively updates the baud rate f2 of the CAN-FD controller data segment of the master device.
[0032] The slave device baud rate adaptive update module adaptively updates the baud rate f2 of the CAN-FD controller data segment of the slave device.
[0033] Fourthly, the present invention provides an embedded readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the above-described method.
[0034] Fifthly, the present invention provides an embedded device, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement the above-described method.
[0035] The beneficial effects of this invention are:
[0036] This invention utilizes the features of CAN controllers and CAN-FD controllers configured on the master and slave devices, and improves communication efficiency by adjusting the data segment baud rate of the high-speed CAN-FD controller through stable CAN communication.
[0037] Because it uses low-speed CAN to control the baud rate of the CAN-FD data segment, it can avoid the failure of high-speed CAN-FD communication caused by changes in the number of slave devices or increased interference in the field bus. The master device can maintain contact with the slave device through the low-speed CAN controller to prevent the slave device from losing control. Furthermore, it can send relevant commands through the CAN controller to change the CAN-FD communication rate, continue to maintain a high communication rate in the current environment, and improve the anti-interference capability of the entire bus. Attached Figure Description
[0038] Figure 1 It is a single-bus network topology based on CAN-FD and CAN.
[0039] Figure 2 This is a list of commonly used CAN-FD data segment baud rates.
[0040] Figure 3 This is the processing flowchart for the main equipment.
[0041] Figure 4 This is a flowchart of the equipment's processing flow. Detailed Implementation
[0042] The present invention will be further described below with reference to the accompanying drawings.
[0043] like Figure 1 As shown, Figure 1 This is a topology diagram of CAN-FD and CAN single-bus communication networks. Figure 1 The CAN bus shown has one master device and n slave devices. Both the master and slave devices have a CAN controller, and a CAN-FD controller is connected to the CAN bus via transceivers. Each end of the CAN bus has a 120-ohm terminating resistor to ensure a 60-ohm bus termination resistance. Communication between the master and slave devices is primarily via high-speed CAN-FD communication. During communication, the number of slave devices (n) may change, leading to a change in the bus length. This means the current CAN-FD data segment baud rate may not be suitable for the changed CAN bus, requiring real-time adjustments to the CAN-FD data segment baud rate. Commonly used CAN-FD data segment baud rates are as follows: Figure 2As shown. This invention utilizes the fact that both the master and slave devices possess CAN controllers. During system initialization, the baud rate of all CAN controllers on the CAN bus is kept consistent with the baud rate of the CAN-FD controller data segment, and is set to a relatively low baud rate, such as 125kbps. The theoretical communication distance can reach 1000m. The master device controls the baud rate of the CAN-FD data segment of all slave devices by sending commands through the CAN controller, achieving CAN-FD baud rate adaptation.
[0044] like Figure 3 As shown, Figure 3 Here is the flowchart for the master device's baud rate adaptive process:
[0045] Step 1: After the master device is powered on, the CAN controller baud rate is initialized to 125kbps, the CAN-FD controller arbitration segment baud rate is initialized to 125kbps, and the data segment baud rate is 125kbps. The frame ID of the master device's CAN controller is set to ID0, and the frame ID of the CAN-FD controller is set to FD_ID0. Configure the master device's CAN-FD filter to only receive frame messages with identifiers from FD_ID1 to FD_IDn, and the CAN filter to only receive frame messages with identifiers from ID1 to IDn, to prevent erroneous frames from appearing on the CAN bus due to rate mismatch, which would affect communication efficiency.
[0046] Step 2: The master device CAN controller sends handshake frames via broadcast and records the number of slave devices. Each slave device responds with a handshake response frame after receiving the handshake frame. If a slave device responds with a handshake response frame, it is determined that the device is online. If a slave device does not respond with a handshake response frame to the master device, it is determined that the slave device is offline.
[0047] Step 3: Specify the baud rate status flag of the data segment of all CAN-FD controllers on the CAN bus as indeterminate;
[0048] Step 4: The main device CAN-FD controller determines whether the current CAN-FD data segment baud rate status flag is in a definite state. If the CAN-FD data segment baud rate status flag is in an indefinite state, proceed to step 5; if the CAN-FD data segment baud rate status flag is in a definite state, proceed to step 7.
[0049] Step 5: The master device CAN-FD controller receives the baud rate switching response frame sent by the slave device and determines whether all online slave devices have replied with the baud rate switching response frame.
[0050] If all responses are received, then update the baud rate of the CAN-FD controller data segment on the main device: f2 = f2 + F1, where F1 is a preset value (for reference only). Figure 2(Upgrade to a higher baud rate than the current baud rate), the master device CAN controller broadcasts a CAN-FD data segment baud rate switching command, causing the slave device CAN-FD controller data segment baud rate to switch to the updated CAN-FD controller data segment baud rate f2, and then returns to step 4;
[0051] If the master device fails to receive at least one baud rate switching response frame from a slave device, then update the baud rate of the master device's CAN-FD controller data segment: f2 = f2 - F1 (refer to...). Figure 2 (The baud rate is reduced to the previous baud rate below the current baud rate); at this point, it is determined that all CAN-FD controllers on the CAN bus use the communication rate of arbitration segment f0 and data segment f2, and then step 6 is executed;
[0052] Step 6: The CAN-FD data segment baud rate status flag is updated to the confirmed state. The master device CAN controller sends a CAN-FD data segment baud rate switching command via broadcast, causing the slave device CAN-FD controller to switch the data segment baud rate to f2, and then returns to step 4.
[0053] Step 7: The master and slave devices communicate using the CAN-FD controller according to the arbitration segment baud rate f0 and the updated data segment baud rate f2;
[0054] Step 8: During the communication process between the master device and the online slave device in CAN-FD, if the master device and a certain slave device fail to communicate more than a specified number of times, or if the number of online slave devices changes or the field CAN bus environment changes, then the current data segment baud rate f2 of the CAN-FD controller is considered inapplicable. It is necessary to switch the CAN-FD data segment baud rate and repeat steps 2 to 8 to continue data communication with the new baud rate.
[0055] like Figure 4 As shown, Figure 4 Here is the flowchart for device baud rate adaptation:
[0056] Step 1: After the slave device is powered on, the CAN controller baud rate is initialized to 125kbps, the CAN-FD controller arbitration segment baud rate is initialized to 125kbps, and the data segment baud rate is temporarily set to 125kbps. The slave device's CAN controller frame IDs are set to ID1 to IDn, and the CAN-FD controller frame IDs are set to FD_ID1 to FD_IDn. Configure the slave device's CAN-FD filter to only receive frames with the identifier FD_ID0, and the CAN filter to only receive frames with the identifier ID0, to prevent erroneous frames from appearing on the CAN bus due to rate mismatch, which would affect communication efficiency.
[0057] Step 2: The master device and slave device communicate using CAN-FD at a determined baud rate;
[0058] Step 3: The device's CAN controller determines whether it has received a handshake frame from the master device. If it has, the device's CAN controller replies with a handshake response frame to the master device's CAN controller. If it has not received, proceed to step 4.
[0059] Step 4: The slave device's CAN controller determines whether it has received a CAN-FD data segment baud rate switching command from the master device's CAN controller. If it has, the slave device updates the CAN-FD data segment baud rate to the master device's specified value, and the slave device's CAN-FD controller replies with a baud rate switching response frame to the master device's CAN-FD controller. If it has not received a baud rate switching response frame, it continues to communicate with the master device using CAN-FD at the current baud rate.
[0060] In summary, this invention provides a single-bus baud rate adaptive method based on CAN-FD and CAN. Those skilled in the art only need to perform initialization work on the master and slave devices. The CAN controller baud rate of both the master and slave devices is initialized to 125kbps (a lower rate to ensure stable communication). The arbitration segment baud rate of the CAN-FD controller of both the master and slave devices is initialized to 125kbps, consistent with the CAN controller baud rate. The data segment baud rate is temporarily set to 125kbps. The frame ID of the master device's CAN controller is configured to ID0, and the frame ID of the CAN-FD controller is configured to FD_ID. 0; Set the CAN controller frame IDs of the slave devices to ID1 to IDn, and the CAN-FD controller frame IDs to FD_ID1 to FD_IDn; Configure the master device's CAN-FD filter to only receive frame messages with identifiers FD_ID1 to FD_IDn, and the CAN filter to only receive frame messages with identifiers ID1 to IDn; Configure the slave device's CAN-FD controller filter to only receive frame messages with identifier FD_ID0, and the CAN controller filter to only receive frame messages with identifier ID0, to prevent erroneous frames from appearing on the CAN bus due to rate mismatch, which would affect communication efficiency. After the initialization is complete, the master device can... Figure 3The process determines the appropriate communication rate for the current bus environment. The master CAN controller broadcasts handshake frames. Each slave device responds with a handshake acknowledgment frame upon receiving the handshake frame. If a slave device responds with a handshake acknowledgment frame, it is considered online; otherwise, it is considered offline. The master CAN-FD controller switches the baud rate of the data segment to 125kbps from the commonly used baud rate list for CAN-FD data segments. The master CAN controller broadcasts a CAN-FD data segment baud rate switching command, instructing slave devices to switch their data segment baud rates. Upon receiving the command from the master device, the slave device reinitializes the CAN-FD controller to the rate specified by the master device and responds with a baud rate switching acknowledgment frame via the CAN-FD controller. The master device judges the baud rate switching response frame received by the CAN-FD controller. If all online slave devices reply with a baud rate switching response frame, it reads the next higher baud rate from the agreed list of commonly used baud rates for the CAN-FD data segment and repeats the above operation until the master device can no longer receive baud rate switching response frames from one or more online devices. If the master device cannot receive baud rate switching response frames from one or more online devices, it reads the baud rate lower than the current baud rate from the list of commonly used baud rates for the CAN-FD data segment, assuming it is f0. It determines that this baud rate is the data segment rate of all CAN-FD controllers on the CAN bus is f0. At this point, it is determined that all CAN-FD controllers on the CAN bus use an arbitration segment rate of 125kbps and a data segment rate of f0, thus completing high-speed CAN-FD communication with the slave devices.
[0061] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.
Claims
1. A single-bus baud rate adaptive method based on CAN-FD and CAN, characterized in that, Includes the following steps: Step 1: Each control node of a CAN bus has one master device and n slave devices, where n≥1; the master device and slave devices are configured with one CAN controller and one CAN-FD controller; Step 2, Initialization Set the CAN controller baud rate to f0, where 50kbps < f0 ≤ 250kbps; The arbitration segment baud rate f1 and data segment baud rate f2 of the CAN-FD controller are initialized to the CAN controller's baud rate f0; Step 3: Adaptively update the baud rate f2 of the CAN-FD controller data segment for both the master and slave devices: The adaptive update process of the CAN-FD controller data segment baud rate f2 of the master device is as follows: A-1. The master device CAN controller sends handshake frames via broadcast and records the number of slave devices. Each slave device responds with a handshake response frame after receiving the handshake frame. If the device responds with a handshake response frame, then the device is considered online. If a slave device does not respond to the master device with a handshake response frame, it is determined that the slave device is offline. A-2. Specify the baud rate status flag of the data segment of all CAN-FD controllers on the CAN bus as an indeterminate state; A-3. The main device CAN-FD controller determines whether the current CAN-FD data segment baud rate status flag is in a definite state. If the CAN-FD data segment baud rate status flag is in an indefinite state, then proceed to step A-4; if the CAN-FD data segment baud rate status flag is in a definite state, then proceed to step A-6. A-4. The master device CAN-FD controller receives the baud rate switching response frame sent by the slave device and determines whether all online slave devices have replied with the baud rate switching response frame. If all responses are received, the baud rate of the master device's CAN-FD controller data segment is updated to f2 = f2 + F1, where F1 is a preset value. The master device's CAN controller sends a CAN-FD data segment baud rate switching command via broadcast, causing the slave device's CAN-FD controller data segment baud rate to switch to the updated CAN-FD controller data segment baud rate f2, and then returns to step A-3. If the master device cannot receive at least one baud rate switching response frame from a slave device, then update the baud rate of the master device's CAN-FD controller data segment f2 = f2 - F1; at this point, it is determined that all CAN-FD controllers on the CAN bus use the communication rate of arbitration segment f0 and data segment f2, and then proceed to step A-5; A-5. The CAN-FD data segment baud rate status flag is updated to the confirmed state. The master device CAN controller sends a CAN-FD data segment baud rate switching command via broadcast, causing the slave device CAN-FD controller to switch the data segment baud rate to f2, and then returns to step A-3. A-6. The master and slave devices communicate using the CAN-FD controller according to the arbitration segment baud rate f0 and the updated data segment baud rate f2. A-7. During the communication process between the master device and the online slave device in CAN-FD, if the communication between the master device and a certain slave device fails more than a specified number of times, or if the number of online slave devices changes or the field CAN bus environment changes, then the current data segment baud rate f2 of the CAN-FD controller is considered inapplicable. It is necessary to switch the CAN-FD data segment baud rate and repeat operation steps A-1 to A-7 to continue data communication with the new baud rate. The adaptive update process of the CAN-FD controller data segment baud rate f2 of the slave device is as follows: B-1. The CAN controller of the device determines whether it has received a handshake frame from the master device. If it has, the CAN controller of the device replies with a handshake response frame to the CAN controller of the master device. If it has not received, proceed to step B-2. B-2. The slave device's CAN controller determines whether it has received the CAN-FD data segment baud rate switching command from the master device's CAN controller. If it has, the slave device updates the CAN-FD data segment baud rate to the value specified by the master device, and the slave device's CAN-FD controller replies with a baud rate switching response frame to the master device's CAN-FD controller. If no data is received, continue data communication with the master device using CAN-FD at the current baud rate.
2. The single-bus baud rate adaptive method based on CAN-FD and CAN according to claim 1, characterized in that, The CAN controller described in step 1 is configured from a single CAN-FD controller.
3. The single-bus baud rate adaptive method based on CAN-FD and CAN according to claim 1, characterized in that, In step 2, the frame ID of the master device CAN controller is set to ID0, and the frame ID of the master device CAN-FD controller is set to FD_ID0; the frame IDs of the slave device CAN controllers are set to ID1 to IDn respectively, and the frame IDs of the slave device CAN-FD controllers are set to FD_ID1 to FD_IDn respectively. Configure the master device's CAN-FD filter to only receive frame messages with identifiers FD_ID1 to FD_IDn, and the master device's CAN filter to only receive frame messages with identifiers ID1 to IDn; configure the slave device's CAN-FD filter to only receive frame messages with identifier FD_ID0, and the slave device's CAN filter to only receive frame messages with identifier ID0, to prevent erroneous frames from appearing on the CAN bus due to rate mismatch, which would affect communication efficiency.
4. A data communication method, characterized in that... The master device and the slave device communicate using a CAN-FD controller according to the arbitration segment baud rate f0 and the data segment baud rate f2; the data segment baud rate f2 is adaptively updated using the method described in any one of claims 1-3.
5. A single-bus baud rate adaptive system implementing the method of any one of claims 1-3, characterized in that... include: Initialize the module to set the CAN controller baud rate of the master and slave devices to f0, where 50kbps < f0 ≤ 250kbps; The arbitration segment baud rate f1 and data segment baud rate f2 of the CAN-FD controllers of the master and slave devices are initialized to the baud rate f0 of the CAN controller; The master device baud rate adaptive update module adaptively updates the baud rate f2 of the CAN-FD controller data segment of the master device. The slave device baud rate adaptive update module adaptively updates the baud rate f2 of the CAN-FD controller data segment of the slave device.
6. An embedded readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of any one of claims 1-3.
7. An embedded device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-3.
Citation Information
Patent Citations
Baud rate measuring method and device for CAN FD with two communication speed rates
CN106941399A
Communication method and corresponding system and device
CN110365564A