Time synchronization system and method based on CANXL and Ethernet message conversion

By adopting a time synchronization system based on CANXL and Ethernet message conversion in vehicle networks, the seamless time synchronization problem across Ethernet and CAN type networks is solved, achieving higher time synchronization accuracy and lower network load.

CN119544128APending Publication Date: 2025-02-28CHONGQING CHANGAN AUTOMOBILE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311122607.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-31
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

The prior art is difficult to achieve seamless time synchronization across Ethernet and CAN type networks, resulting in limited synchronization accuracy of the entire vehicle network.

Method used

The time synchronization system based on CANXL and Ethernet packet conversion is adopted. Through the coordinated work of the main clock node, edge gateway and edge devices, the conversion and transmission of Ethernet time synchronization packets are realized, ensuring seamless communication and time synchronization between the CANXL network and the Ethernet network.

Benefits of technology

Improve the accuracy of time synchronization, reduce the processing load of edge gateways, eliminate errors in the time synchronization process, and achieve seamless overall time synchronization between CANXL network and Ethernet network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544128A_ABST
    Figure CN119544128A_ABST
Patent Text Reader

Abstract

The invention relates to a time synchronization system and method based on CANXL and Ethernet message conversion, the system comprises a main clock node, an edge gateway and an edge device, the edge gateway fills an Ethernet MAC frame into a data segment of a CANXL message; after receiving the CANXL message, the edge equipment screens the message according to the ID, processes the message, extracts an Ethernet MAC frame and records a timestamp at a receiving moment, the Ethernet MAC frame is processed by a protocol stack to obtain a feedback message, fills a data segment of the CANXL message, packs the feedback message into the CANXL message and sends the CANXL message, and the timestamp at a sending moment is marked at a corresponding position of the message; and the edge gateway unpacks to obtain an Ethernet MAC frame and sends the Ethernet MAC frame back to the master clock node through the Ethernet, and the edge device calculates frequency deviation and propagation delay with the master clock node according to a time synchronization protocol and adjusts a clock of the edge device to complete synchronization with the master clock node. According to the invention, the time synchronization precision can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of vehicle communication, and in particular relates to a time synchronization system and method based on CANXL and Ethernet message conversion. Background Art

[0002] With the development of technologies related to intelligent connected vehicles, the controllers and sensors carried in vehicles are becoming more and more diverse. In order to meet the requirements of high data bandwidth, the current vehicle network mostly uses Ethernet as the backbone network, but some safety-related or cost-sensitive edge networks are still mainly based on CAN type buses, including CAN and CANFD. Communication across these two types of networks usually requires specific data signal level analysis in the gateway and then reassembly of the message to send to the target network. This process is bound to increase the load on the gateway CPU and increase communication delays to a certain extent.

[0003] On the other hand, in order to ensure the stability of the overall system control of the vehicle, different controllers, actuators and sensors in the vehicle network need to maintain relatively accurate time synchronization. For the Ethernet part, high-precision time synchronization can be achieved through the standard gPTP (Generalized Precision Time Protocol) Ethernet time synchronization protocol or other derivative synchronization algorithms (such as patent document CN113037415A). However, for CAN type networks, although there are time synchronization protocols for the CAN network itself, due to the differences in network physical media and protocols, seamless synchronization across Ethernet and CAN cannot be achieved. The existing practice is usually that an edge gateway node synchronizes the gateway itself with the master clock in the Ethernet through Ethernet, and then uses the time obtained after the gateway synchronization as a reference to perform time synchronization in the CAN network through the CAN bus time synchronization protocol (such as patent document CN113422665B); or introduces additional CAN / Ethernet conversion equipment (such as patent document CN217935627U). However, whether it is gateway processing or network conversion equipment, the process of parsing the time synchronization message, implementing synchronization, and then synchronizing the reference time to the CAN bus will inevitably introduce a lag in the synchronization of the devices in the CAN bus, causing errors in the time synchronization of the devices, leading to a bottleneck in improving the synchronization accuracy of the entire vehicle network.

[0004] Therefore, it is necessary to develop a new time synchronization system and method based on CANXL and Ethernet message conversion. Summary of the invention

[0005] The object of the present invention is to provide a time synchronization system and method based on CANXL and Ethernet message conversion, which can effectively improve the accuracy of time synchronization.

[0006] In a first aspect, the time synchronization system based on CANXL and Ethernet message conversion of the present invention comprises a master clock node, an edge gateway and an edge device, wherein the master clock node is connected to the edge gateway via a backbone Ethernet; the edge device is connected to the edge gateway via a CANXL bus;

[0007] The master clock node sends an Ethernet time synchronization message according to the time synchronization protocol;

[0008] After receiving the Ethernet time synchronization message, the edge gateway fills the Ethernet MAC frame into the data segment of the CANXL message, sets the ID and DLC value of the CANXL message according to the destination MAC address and message length of the MAC frame, and then forwards it to the CANXL network;

[0009] After receiving the CANXL message sent by the edge gateway, the edge device filters the message according to the ID for processing, extracts the Ethernet MAC frame, and records the timestamp of the receiving time. The Ethernet MAC frame is processed by the protocol stack to obtain a feedback message, fills the feedback message into the data segment of the CANXL message, and packages it into the CANXL message format, sets the ID number and DLC value of the CANXL message, and sends the CANXL message. At the same time, the timestamp of the sending time is marked at the corresponding position of the message according to the provisions of the time synchronization protocol;

[0010] After receiving the feedback CANXL message, the edge gateway unpacks it to obtain the Ethernet MAC frame, and sends it back to the master clock node via Ethernet, so that the edge device and the master clock node can communicate directly via the Ethernet protocol;

[0011] The edge device calculates the frequency deviation and propagation delay with the master clock node according to the time synchronization protocol, and adjusts its own clock to complete synchronization with the master clock node.

[0012] Optionally, the master clock node includes a first Ethernet module and a first time synchronization protocol stack module connected to the first Ethernet module;

[0013] The first time synchronization protocol stack module is used to run the Ethernet time synchronization protocol;

[0014] The first Ethernet module is used to send Ethernet time synchronization messages.

[0015] Optionally, the edge gateway includes a first conversion module, and a second Ethernet module and a first CANXL controller respectively connected to the first conversion module;

[0016] When the second Ethernet module receives an Ethernet MAC frame of a time synchronization related type, the second Ethernet module sends the Ethernet MAC frame to the first conversion module for processing;

[0017] The first conversion module stores the content of the Ethernet MAC frame into the Ethernet receiving buffer, and then packages it frame by frame, fills it into the data segment of the CANXL message, and packages it into the CANXL message format; and reads the target MAC address of the Ethernet MAC frame and the message length in the message header; obtains the corresponding CANXL message ID number by table lookup according to the target MAC address, and calculates the DLC value of the CANXL message according to the message length. After setting the ID number and DLC, the CANXL message is sent to the CANXL sending buffer of the first conversion module, and sent to the CANXL bus network through the first CANXL controller;

[0018] After receiving the CANXL message sent back by the edge device, the first CANXL controller filters it through the first conversion module, only processes the message sent by the edge device, then unpacks the CANXL message to obtain the Ethernet MAC frame, and sends it back to the master clock node via Ethernet to achieve the communication required for time synchronization.

[0019] Optionally, a first counter is provided in the first CANXL controller. When the first CANXL controller sends or receives a CANXL message, the first counter is sampled and generates a timestamp, and the timestamp is recorded in a designated register.

[0020] Optionally, the edge device includes a second conversion module, and a second CANXL controller and a second time synchronization protocol stack module respectively connected to the second conversion module;

[0021] When the second CANXL controller receives a CANXL message related to synchronization, it records the timestamp of the receiving time and stores it in a designated register for use by a subsequent time synchronization protocol, and transmits the CANXL message to the second conversion module;

[0022] The second conversion module stores the CANXL message into the CANXL receiving buffer, filters it according to the message ID number, only processes the message corresponding to the ID of the current node or the ID corresponding to the broadcast address, unpacks the filtered CANXL message, extracts the Ethernet MAC frame, stores it into the Ethernet sending buffer of the second conversion module, and transmits it to the second time synchronization protocol stack module for time synchronization operation;

[0023] The second time synchronization protocol stack module processes the received MAC frame message to obtain a corresponding feedback message in the Ethernet MAC frame format;

[0024] The second conversion module fills the feedback message in the Ethernet MAC frame format into the data segment of the CANXL message, packages it into the CANXL message format, and sets the ID number and DLC value of the CANXL message;

[0025] The second CANXL controller sends the CANXL message output by the second conversion module to the CANXL network, and records the hardware timestamp of the sending time, and marks the hardware timestamp of the sending time at the corresponding position of the CANXL message according to the requirements of the time synchronization protocol.

[0026] Optionally, a second counter is provided in the second CANXL controller. When the second CANXL controller sends or receives a CANXL message, the second counter is sampled and generates a timestamp, and the timestamp is recorded in a designated register.

[0027] Optionally, the master clock node is a vehicle-mounted central processing unit, or a GNSS unit.

[0028] Optionally, the edge device includes one or more of a vehicle-mounted sensor, an actuator, and a controller.

[0029] In a second aspect, a time synchronization method based on CANXL and Ethernet message conversion according to the present invention adopts a time synchronization system based on CANXL and Ethernet message conversion according to the present invention, and the method comprises the following steps:

[0030] S1: The master clock node sends an Ethernet time synchronization message according to the time synchronization protocol;

[0031] S2: After receiving the Ethernet time synchronization message, the edge gateway fills the Ethernet MAC frame into the data segment of the CANXL message;

[0032] S3: Set the ID and DLC value of the CANXL message according to the destination MAC address and message length of the Ethernet MAC frame and forward it to the CANXL network;

[0033] S4: After receiving the CANXL message, the edge device filters the message according to the ID, extracts the Ethernet MAC frame, and records the receiving time stamp;

[0034] S5: The Ethernet MAC frame is processed by the protocol stack to obtain a feedback message, the feedback message is filled into the data segment of the CANXL message, the package is packaged into the CANXL message format, and the ID number and DLC value of the CANXL message are set;

[0035] S6: The edge device sends a CANXL message and marks the timestamp of the sending time at the corresponding position of the message according to the provisions of the time synchronization protocol;

[0036] S7: After receiving the CANXL message, the edge gateway unpacks it to extract the Ethernet MAC frame and sends it back to the master clock node via Ethernet;

[0037] S8: Repeat steps S2 to S7 until the edge device can calculate the frequency deviation and propagation delay from the master clock node based on the timestamp information in the communication process and according to the time synchronization protocol, and adjust its own clock to complete synchronization with the master clock node.

[0038] The present invention has the following advantages:

[0039] (1) The present invention replaces CAN or CANFD with CANXL as the vehicle-mounted edge network, and introduces a message conversion module in the edge gateway and edge device. In addition to ensuring the time synchronization requirements between itself and the master clock node, the edge gateway does not need to perform time synchronization of the CANXL network as the master clock. It only converts and encapsulates the Ethernet MAC frame message related to time synchronization received from the backbone Ethernet into the form of a CANXL message, adds different message IDs and DLC values ​​according to the destination MAC address and message length, and then forwards it to the CANXL network. After the edge device on the CANXL network obtains the message, the conversion module first filters out the message with the ID matching the node and unpacks it to obtain the Ethernet frame content, and then directly gives feedback based on the relevant Ethernet time synchronization protocol stack. The content fed back by the protocol stack is also in the Ethernet MAC frame format, and then is encapsulated into a CANXL message through the conversion module and sent out. After receiving the feedback CANXL message, the edge gateway also unpacks the MAC frame to send it back to the Ethernet network. In this way, the CANXL bus is used as the physical layer carrier, so that the nodes in the CANXL network and the nodes in the Ethernet network can communicate directly through the Ethernet protocol (such as gPTP), thereby enabling the CANXL network and the Ethernet network to complete the overall time synchronization task seamlessly.

[0040] (2) The present invention not only reduces the processing load of the edge gateway (the edge gateway does not need to be used as a reference clock to perform synchronization management of the CAN network), but also eliminates the errors caused by the process of synchronizing the edge gateway with the master clock in the Ethernet and then performing CAN network time synchronization, which can effectively improve the accuracy of time synchronization.

[0041] (3) As far as time synchronization is concerned, its accuracy depends largely on the accuracy of the timestamp recorded when each synchronization node sends and receives messages. Different from the conventional hardware timestamp of Ethernet, the time when the CAN type bus controller sends and receives messages is usually recorded by software timestamp, which is affected by factors such as operating system scheduling and is often less accurate than the hardware timestamp. Therefore, the present invention adds a hardware timestamp function to the CANXL controller. Specifically, an additional 64-bit counter is added to the CANXL controller. When the CANXL controller sends or receives a CANXL message, the counter will be sampled and generate a timestamp recorded in the specified register. The software can obtain the corresponding timestamp by reading the contents of the register. This function improves the accuracy of the timestamp recorded by the CANXL controller when sending and receiving messages, thereby further improving the time synchronization accuracy within the vehicle network environment.

[0042] In summary, the present invention uses the new generation CAN communication protocol CANXL as the physical layer carrier, and converts Ethernet messages and CANXL messages through the conversion module in the edge gateway and edge device. At the same time, combined with the hardware timestamp function added in the CANXL controller, the high-precision time synchronization protocol based on Ethernet is extended and applied to the CANXL network, realizing the direct communication between the devices in the edge CAN type bus network and the backbone Ethernet master clock, thereby realizing seamless time synchronization across physical network types. Compared with the existing conventional practices, the synchronization accuracy of each node in the CANXL network can be improved from millimeter level to microsecond level accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0044] Figure 1 is a system architecture diagram of this embodiment;

[0045] Figure 2 is a flow chart of this embodiment;

[0046] Figure 3 This is a schematic diagram of the CANXL message package format in this embodiment;

[0047] Figure 4 is a schematic diagram of the structure of the first conversion module or the second conversion module in this embodiment;

[0048] Figure 5 This is the specific PTP time synchronization process involved in this embodiment;

[0049] In the figure: 1. master clock node, 11. first time synchronization protocol stack module, 12. first Ethernet module, 2. edge gateway, 21. first conversion module, 22. first CANXL controller, 23. second Ethernet module, 3. edge device, 31. second conversion module, 32. second time synchronization protocol stack module, 33. second CANXL controller. DETAILED DESCRIPTION

[0050] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.

[0051] like Figure 1 As shown, in this embodiment, a time synchronization system based on CANXL and Ethernet message conversion includes a master clock node 1, an edge gateway 2 and an edge device 3, wherein the master clock node 1 is connected to the edge gateway 2 via a backbone Ethernet; and the edge device 3 is connected to the edge gateway 2 via a CANXL bus. The master clock node 1 sends an Ethernet time synchronization message according to the time synchronization protocol. After receiving the Ethernet time synchronization message, the edge gateway 2 fills the Ethernet MAC frame into the data segment of the CANXL message, and sets the ID and DLC value of the CANXL message according to the destination MAC address and message length of the MAC frame, and then forwards it to the CANXL network. After receiving the CANXL message sent by the edge gateway 2, the edge device 3 filters the message according to the ID for processing, extracts the Ethernet MAC frame, and records the timestamp of the receiving time. The Ethernet MAC frame is processed through the protocol stack to obtain a feedback message, fills the feedback message into the data segment of the CANXL message, and packages it into the CANXL message format, sets the ID number and DLC value of the CANXL message, and sends the CANXL message. At the same time, the timestamp of the sending time is marked at the corresponding position of the message according to the provisions of the time synchronization protocol. After receiving the feedback CANXL message, the edge gateway 2 unpacks it to obtain the Ethernet MAC frame, and sends it back to the master clock node 1 via Ethernet, so that the edge device 3 and the master clock node 1 can communicate directly via the Ethernet protocol. The edge device 3 calculates the frequency deviation and propagation delay with the master clock node 1 according to the time synchronization protocol, and adjusts its own clock to complete synchronization with the master clock node 1.

[0052] like Figure 1As shown, in this embodiment, the master clock node 1 includes a first Ethernet module 12 and a first time synchronization protocol stack module 11 connected to the first Ethernet module 12. The first time synchronization protocol stack module 11 is used to run the Ethernet time synchronization protocol. The first Ethernet module 12 is used to send Ethernet time synchronization messages.

[0053] like Figure 1 As shown, in this embodiment, the edge gateway 2 includes a first conversion module 21, and a second Ethernet module 23 and a first CANXL controller 22 respectively connected to the first conversion module 21. When the second Ethernet module 23 receives an Ethernet MAC frame of a time synchronization related type, the Ethernet MAC frame is handed over to the first conversion module 21 for processing. The first conversion module 21 stores the content of the Ethernet MAC frame into the Ethernet receiving buffer, and then packages it frame by frame, fills it into the data segment of the CANXL message, and packages it into the CANXL message format. The first conversion module 21 reads the target MAC address of the Ethernet MAC frame and the message length in the message header; obtains the corresponding CANXL message ID number by looking up the table according to the target MAC address, and calculates the DLC value of the CANXL message according to the message length. After setting the ID number and DLC, the CANXL message is sent to the CANXL sending buffer of the first conversion module 21, and sent to the CANXL bus network through the first CANXL controller 22. After receiving the CANXL message sent back by the edge device 3, the first CANXL controller 22 filters it through the first conversion module 21, only processes the message sent by the edge device 3, and then unpacks the CANXL message to obtain an Ethernet MAC frame, and sends it back to the master clock node 1 via Ethernet to achieve the communication required for time synchronization.

[0054] In this embodiment, a first counter is provided in the first CANXL controller 22. When the first CANXL controller 22 sends or receives a CANXL message, the first counter is sampled and generates a timestamp, and the timestamp is recorded in a designated register.

[0055] like Figure 1As shown, in this embodiment, the edge device 3 includes a second conversion module 31, and a second CANXL controller 33 and a second time synchronization protocol stack module 32 respectively connected to the second conversion module 31. When receiving a CANXL message related to synchronization, the second CANXL controller 33 records the timestamp of the receiving time and stores it in a designated register for use by the subsequent time synchronization protocol, and transmits the CANXL message to the second conversion module 31. The second conversion module 31 stores the CANXL message in the CANXL receiving buffer, filters it according to the message ID number, only processes the message corresponding to the ID of the node or the ID corresponding to the broadcast address, unpacks the filtered CANXL message, extracts the Ethernet MAC frame, stores it in the Ethernet sending buffer of the second conversion module 31, and transmits it to the second time synchronization protocol stack module 32 for time synchronization operation. The second time synchronization protocol stack module 32 processes the received MAC frame message to obtain a corresponding feedback message in the Ethernet MAC frame format. The second conversion module 31 fills the feedback message in the Ethernet MAC frame format into the data segment of the CANXL message, packages it into the CANXL message format, and sets the ID number and DLC value of the CANXL message. The second CANXL controller 33 sends the CANXL message output by the second conversion module 31 to the CANXL network, and records the hardware timestamp of the sending time, and marks the hardware timestamp of the sending time at the corresponding position of the CANXL message according to the needs of the time synchronization protocol.

[0056] In this embodiment, a second counter is provided in the second CANXL controller 33. When the second CANXL controller 33 sends or receives a CANXL message, the second counter is sampled and generates a timestamp, and the timestamp is recorded in a designated register.

[0057] In this embodiment, the master clock node 1 is a vehicle-mounted central processing unit, or a GNSS unit.

[0058] In this embodiment, the edge device 3 includes one or more of a vehicle-mounted sensor, an actuator, and a controller.

[0059] like Figure 2 As shown, in this embodiment, a time synchronization method based on CANXL and Ethernet message conversion adopts the time synchronization system based on CANXL and Ethernet message conversion as described in this embodiment, and the method includes the following steps:

[0060] S1: Master clock node 1 sends Ethernet time synchronization message according to the time synchronization protocol;

[0061] S2: After receiving the Ethernet time synchronization message, the edge gateway 2 fills the Ethernet MAC frame into the data segment of the CANXL message;

[0062] S3: Set the ID and DLC value of the CANXL message according to the destination MAC address and message length of the Ethernet MAC frame and forward it to the CANXL network;

[0063] S4: After receiving the CANXL message, the edge device 3 filters the message according to the ID, extracts the Ethernet MAC frame, and records the receiving time stamp;

[0064] S5: The Ethernet MAC frame is processed by the protocol stack to obtain a feedback message, the feedback message is filled into the data segment of the CANXL message, the package is packaged into the CANXL message format, and the ID number and DLC value of the CANXL message are set;

[0065] S6: The edge device 3 sends a CANXL message, and at the same time marks the timestamp of the sending time at the corresponding position of the message according to the provisions of the time synchronization protocol;

[0066] S7: After receiving the CANXL message, the edge gateway 2 unpacks and extracts the Ethernet MAC frame, and sends it back to the master clock node 1 via Ethernet;

[0067] S8: Repeat steps S2 to S7 until the edge device 3 can calculate the frequency deviation and propagation delay with the master clock node 1 based on the timestamp information in the communication process and according to the time synchronization protocol, and adjust its own clock to complete synchronization with the master clock node 1.

[0068] In this embodiment, the master clock node 1 needs to be able to run relevant Ethernet time synchronization protocols, including but not limited to IEEE 1588PTP (Precision Time Protocol) protocol, IEEE 802.1AS gPTP protocol, AUTOSAR Ethernet time synchronization protocol, etc.

[0069] The following uses the gPTP protocol as an example for explanation.

[0070] 1. When time synchronization needs to be initiated, the master clock node 1 needs to send a time synchronization message via Ethernet according to the gPTP protocol.

[0071] 2. Edge Gateway 2 needs to support both CANXL and Ethernet. The Ethernet MAC frame header will indicate the frame type (such as Figure 3 As shown in the second line of FIG, when the edge gateway 2 receives a message of a frame type related to time synchronization (for example, in the gPTP protocol, the frame type = 0x88F7), the message is handed over to the first conversion module 21 for processing. The structure of the first conversion module 21 is as follows Figure 4As shown, it first stores the complete Ethernet MAC frame content into the Ethernet receive buffer, and then sends it into the packet one by one, filling it into the data segment of the CANXL message, such as Figure 3 As shown, it is packaged into the CANXL message format.

[0072] 3. In addition, the first conversion module 21 will read the target MAC address of the processed Ethernet MAC frame and the message length in the gPTP message header. First, according to the target MAC address, the corresponding CANXL message ID number is obtained by table lookup, as shown in Table 1, which is specifically implemented by the lookup table or decoder in the first conversion module 21 and can be configured by the user. Then, the DLC (Data Length Code) value of the CANXL message is calculated according to the message length in the gPTP message header, specifically: DLC = gPTP message length + 18 bytes (the MAC frame header and trailer contain the target MAC address, source MAC address, frame type and frame detection, a total of 18 bytes). Finally, after setting the above ID number and DLC, the CANXL message is sent to the CANXL send buffer of the first conversion module 21, and sent to the CANX bus network through the first CANXL controller 22.

[0073] Table 1: Example table of CANXL ID number and MAC address corresponding to edge device 3

[0074]

[0075] 4. When the edge device 3 receives the relevant CANXL message through the second CANXL controller 33, the second CANXL controller 33 will record the timestamp of the time when the message is received and store it in the designated register for use by the subsequent time synchronization protocol, and transmit the message to the second conversion module 31. The second conversion module 31 also first stores the message in the CANXL receiving buffer, and then filters it according to the message ID number, and only processes the message corresponding to the ID of the node or the ID corresponding to the broadcast address. Taking the corresponding relationship in Table 1 as an example, the second conversion module 31 in the sensor 1 only processes the message with an ID of 0x601 or 0x6ff. Then, the filtered message is unpacked to extract the data segment content, that is, the complete Ethernet MAC frame message, which is stored in the Ethernet sending buffer of the second conversion module 31, and then transmitted to the second time synchronization protocol stack module 32 (in this embodiment, that is, the gPTP protocol stack) for further time synchronization operations;

[0076] 5. After the gPTP protocol stack processes the received Ethernet MAC frame, it will obtain a feedback message in the corresponding Ethernet MAC frame format. The second conversion module 31 will refill the data segment of the CANXL message and package it into the CANXL message format. In addition, the ID number corresponding to the message sent by this node is set as shown in Table 1. For example, the ID of the message sent by sensor 1 is set to 0x604. At the same time, according to the message length information in the gPTP message header in the feedback message, the corresponding DLC ​​value is set for the message;

[0077] 6. The second CANXL controller 33 sends the prepared message to the CANXL network. At the same time, the hardware timestamp of the sending time is recorded. According to the requirements of the time synchronization protocol, the sending time timestamp can be marked at the corresponding position of the message. Taking the gPTP protocol as an example, the timestamp can be marked at the corresponding position of the message according to the requirements. Figure 3 The location shown in the "precise timestamp";

[0078] 7. After the edge gateway 2 receives the message sent back by the edge device 3 through the first CANXL controller 22, it is also filtered by the first conversion module 21 according to the relationship shown in Table 1, and only the message sent by the edge device (i.e. 0x604, 0x605, 0x606 in the table) is processed. Then the CANXL message is unpacked to obtain the Ethernet MAC frame, and sent back to the master clock node 1 through Ethernet to achieve the communication required for time synchronization;

[0079] 8. According to the specific time synchronization protocol, repeat the message conversion and communication process described in 2 to 7 multiple times until the edge device 3 calculates the frequency deviation and propagation delay with the master clock according to the protocol, and then adjusts its own clock to complete synchronization with the master clock.

[0080] In this embodiment, the complete PTP time synchronization process needs to repeat the message forwarding and communication described in steps S2 to S7 multiple times, such as Figure 5 The specific implementation is described as follows:

[0081] 1) The master clock node 1 sends a Sync message to the edge device 3 and records the sending time t1. After the slave clock receives the Sync message, it records the receiving time t2;

[0082] 2) After the master clock node sends the Sync message, it immediately sends a Follow_Up message carrying t1;

[0083] 3) The slave clock sends a Delay_Req message to the master clock node and records the sending time t3;

[0084] 4) After receiving the Delay_Req message, the master clock node records the receiving time t4 and replies with a Delay_Resp message carrying t4;

[0085] 5) So far, the slave clock has obtained four timestamps from t1 to t4. Assuming that the network communication delay is symmetrical, the path delay delay = [(t2-t1) + (t4-t3)] / 2 can be calculated. The offset of the slave clock relative to the master clock is offset = [(t2-t1) - (t4-t3)] / 2. Based on this offset, the slave clock can correct the deviation between the master clock node and complete time synchronization.

[0086] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.

Claims

1. A time synchronization system based on CANXL and Ethernet message conversion, comprising a master clock node (1), an edge gateway (2) and an edge device (3), characterized in that: The master clock node (1) is connected to the edge gateway (2) via a backbone Ethernet; the edge device (3) is connected to the edge gateway (2) via a CANXL bus; The master clock node (1) sends an Ethernet time synchronization message according to a time synchronization protocol; After receiving the Ethernet time synchronization message, the edge gateway (2) fills the Ethernet MAC frame into the data segment of the CANXL message, sets the ID and DLC value of the CANXL message according to the destination MAC address and message length of the MAC frame, and then forwards it to the CANXL network; After receiving the CANXL message sent by the edge gateway (2), the edge device (3) filters the message according to the ID for processing, extracts the Ethernet MAC frame, and records the timestamp of the receiving time. The Ethernet MAC frame is processed by the protocol stack to obtain a feedback message, and the feedback message is filled into the data segment of the CANXL message, which is packaged into the CANXL message format, and the ID number and DLC value of the CANXL message are set, and the CANXL message is sent. At the same time, the timestamp of the sending time is marked at the corresponding position of the message according to the provisions of the time synchronization protocol; After receiving the feedback CANXL message, the edge gateway (2) unpacks it to obtain an Ethernet MAC frame, and sends it back to the master clock node (1) via Ethernet, so that the edge device (3) and the master clock node (1) can communicate directly via the Ethernet protocol; The edge device (3) calculates the frequency deviation and propagation delay with the master clock node (1) according to the time synchronization protocol, and adjusts its own clock to complete synchronization with the master clock node (1).

2. The time synchronization system based on CANXL and Ethernet message conversion according to claim 1 is characterized in that: The master clock node (1) comprises a first Ethernet module (12) and a first time synchronization protocol stack module (11) connected to the first Ethernet module (12); The first time synchronization protocol stack module (11) is used to run the Ethernet time synchronization protocol; The first Ethernet module (12) is used to send Ethernet time synchronization messages.

3. The time synchronization system based on CANXL and Ethernet message conversion according to claim 1 is characterized in that: The edge gateway (2) comprises a first conversion module (21), and a second Ethernet module (23) and a first CANXL controller (22) respectively connected to the first conversion module (21); When the second Ethernet module (23) receives an Ethernet MAC frame of a time synchronization related type, the Ethernet MAC frame is handed over to the first conversion module (21) for processing; The first conversion module (21) stores the Ethernet MAC frame content into the Ethernet receiving buffer, and then packages it frame by frame, fills it into the data segment of the CANXL message, and packages it into the CANXL message format; Read the target MAC address of the Ethernet MAC frame and the message length in the message header; Obtaining the corresponding CANXL message ID number by table lookup according to the target MAC address, and calculating the DLC value of the CANXL message according to the message length, and after setting the ID number and the DLC, sending the CANXL message to the CANXL sending buffer of the first conversion module (21), and sending it to the CANXL bus network through the first CANXL controller (22); After receiving the CANXL message sent back by the edge device (3), the first CANXL controller (22) filters it through the first conversion module (21), only processes the message sent by the edge device (3), then unpacks the CANXL message to obtain an Ethernet MAC frame, and sends it back to the master clock node (1) via Ethernet, thereby achieving the communication required for time synchronization.

4. The time synchronization system based on CANXL and Ethernet message conversion according to claim 3 is characterized in that: The first CANXL controller (22) is provided with a first counter. When the first CANXL controller (22) sends or receives a CANXL message, the first counter is sampled and generates a timestamp, and the timestamp is recorded in a designated register.

5. The time synchronization system based on CANXL and Ethernet message conversion according to claim 1 is characterized in that: The edge device (3) comprises a second conversion module (31), and a second CANXL controller (33) and a second time synchronization protocol stack module (32) respectively connected to the second conversion module (31); When receiving a CANXL message related to synchronization, the second CANXL controller (33) records a timestamp of the receiving time and stores it in a designated register for use by a subsequent time synchronization protocol, and transmits the CANXL message to the second conversion module (31); The second conversion module (31) stores the CANXL message into the CANXL receiving buffer, filters the message according to the message ID number, only processes the message corresponding to the ID of the current node or the ID corresponding to the broadcast address, unpacks the filtered CANXL message, extracts the Ethernet MAC frame, stores it into the Ethernet sending buffer of the second conversion module (31), and transmits it to the second time synchronization protocol stack module (32) for time synchronization operation; The second time synchronization protocol stack module (32) processes the received MAC frame message to obtain a corresponding feedback message in an Ethernet MAC frame format; The second conversion module (31) fills the feedback message in the Ethernet MAC frame format into the data segment of the CANXL message, packages it into the CANXL message format, and sets the ID number and DLC value of the CANXL message; The second CANXL controller (33) sends the CANXL message output by the second conversion module (31) to the CANXL network, and records a hardware timestamp at the time of sending, and marks the hardware timestamp at the time of sending at a corresponding position of the CANXL message according to the requirements of the time synchronization protocol.

6. The time synchronization system based on CANXL and Ethernet message conversion according to claim 5 is characterized in that: The second CANXL controller (33) is provided with a second counter. When the second CANXL controller (33) sends or receives a CANXL message, the second counter is sampled and generates a timestamp, and the timestamp is recorded in a designated register.

7. The time synchronization system based on CANXL and Ethernet message conversion according to claim 1 is characterized in that: The master clock node (1) is a vehicle-mounted central processing unit, or a GNSS unit.

8. The time synchronization system based on CANXL and Ethernet message conversion according to claim 1 is characterized in that: The edge device (3) includes one or more of a vehicle-mounted sensor, an actuator and a controller.

9. A time synchronization method based on CANXL and Ethernet message conversion, characterized in that: The time synchronization system based on CANXL and Ethernet message conversion as claimed in any one of claims 1 to 8 is adopted, and the method comprises the following steps: S1: The master clock node (1) sends an Ethernet time synchronization message according to the time synchronization protocol; S2: After receiving the Ethernet time synchronization message, the edge gateway (2) fills the Ethernet MAC frame into the data segment of the CANXL message; S3: Set the ID and DLC value of the CANXL message according to the destination MAC address and message length of the Ethernet MAC frame and forward it to the CANXL network; S4: After receiving the CANXL message, the edge device (3) filters the message according to the ID, extracts the Ethernet MAC frame, and records the receiving time stamp; S5: The Ethernet MAC frame is processed by the protocol stack to obtain a feedback message, the feedback message is filled into the data segment of the CANXL message, the package is packaged into the CANXL message format, and the ID number and DLC value of the CANXL message are set; S6: The edge device (3) sends a CANXL message and marks the timestamp of the sending time at the corresponding position of the message according to the provisions of the time synchronization protocol; S7: After receiving the CANXL message, the edge gateway (2) unpacks and extracts the Ethernet MAC frame, and sends it back to the master clock node (1) via Ethernet; S8: Repeat steps S2 to S7 until the edge device (3) can calculate the frequency deviation and propagation delay with the master clock node (1) based on the timestamp information in the communication process and according to the time synchronization protocol, and adjust its own clock to complete synchronization with the master clock node (1).

Citation Information

Patent Citations

  • TSN network clock synchronization method, system and device based on vehicle-mounted Ethernet transmission

    CN113037415A

  • A method and system for time synchronization of in-vehicle systems based on IPC mechanism

    CN113422665B

  • CAN-to-Ethernet equipment with time synchronization function

    CN217935627U