Time synchronization method and related equipment
By using a timer to capture the moment of the transition signal in the communication system, time synchronization between the master node and the slave node is achieved, which solves the high-cost problem in the existing technology and achieves low-cost, high-precision time synchronization effect.
Patent Information
- Application Number
- CN202310348027.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2024-10-01
AI Technical Summary
Existing time synchronization protocols require dedicated hardware, resulting in high deployment costs and difficulty in achieving high-precision time synchronization in a cost-effective manner.
By using the bus architecture between the master node and the slave node in the communication system, the timer is used to capture the moment of the transition signal to achieve time synchronization. There is no need to encapsulate the message, which reduces the hardware requirements. The transition signal is used for time synchronization, simplifying the process. .
It achieves low-cost, high-precision time synchronization, reduces the cost of time synchronization, and improves the efficiency and accuracy of time synchronization.
Smart Images

Figure CN118740302A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a time synchronization method and related equipment. Background Art
[0002] Synchronization is generally divided into clock synchronization, phase synchronization and time synchronization. Clock synchronization, also known as frequency synchronization, means that different signals have the same number of pulses in the same time interval. Phase synchronization means that two signals have the same frequency, and the start and end time of each pulse are also the same. Time synchronization means that two signals have the same frequency, the same phase, and the order in which the pulses appear is also the same.
[0003] Current time synchronization protocols include precision time protocol (PTP) and generalized PTP (gPTP). PTP and gPTP greatly improve the time synchronization capability of the network by combining software and hardware. PTP uses protocol messages to transmit synchronization information, supports Ethernet, Internet Protocol version 4 (IPv4) and Internet Protocol version 6 (IPv6) message transmission, and can achieve microsecond accuracy, which can be applied to synchronization in telecommunications, measurement and industrial control fields. gPTP is mainly used for time synchronization of nodes in local area networks, and can achieve sub-microsecond time accuracy, which is used in measurement and control systems.
[0004] However, these protocols require dedicated hardware implementation and have high deployment costs. Summary of the invention
[0005] The present application provides a time synchronization method and related equipment to solve the problem of high cost of high-precision time synchronization.
[0006] The first aspect provides a time synchronization method. The method is applied to a master node in a communication system. The communication system is a bus architecture, the communication system includes a master node and at least one slave node, the master node and the at least one slave node are connected through a bus, the master node includes a first master timer, the first master timer connects the master sending channel between the master node and the bus, and the slave node includes a first slave timer, the first slave timer connects the slave receiving channel between the slave node and the bus. The moment when the signal passes through the main sending channel is closer to the actual sending moment, so the first master timer is connected to the main sending channel, and a more accurate sending moment can be obtained. Similarly, the moment when the signal passes through the slave receiving channel is closer to the actual receiving moment, so the first slave timer is connected to the slave receiving channel, and a more accurate receiving moment can be obtained.
[0007] The method includes: the master node sends a jump signal to the bus through the main sending channel, the jump signal is used to trigger the first master timer to record the current count value when passing through the main sending channel, and is used to trigger the first slave timer to record the current count value when passing through the slave receiving channel, the count value recorded by the first master timer is used to calculate the sending time of the master node sending the jump signal, and the count value recorded by the first slave timer is used to calculate the receiving time of the slave node receiving the jump signal. After the master node obtains the sending time, it sends the sending time to the bus, so that after the slave node obtains the sending time, it synchronizes with the master node according to the sending time and the receiving time.
[0008] By sending a jump signal to trigger the timer to record the time of receiving and sending the jump signal, the time obtained by hardware is more accurate, and the jump signal does not need to be encapsulated in the message format, making the implementation of time synchronization more concise and efficient. In addition, the timer and node are basic hardware in the device, and no dedicated hardware is required to achieve time synchronization, so the time synchronization solution provided by this application can be widely used on devices in the network at low cost.
[0009] Time synchronization can specifically include frequency deviation measurement, delay measurement, and synchronizing the time of the master node to the slave node based on the frequency deviation and delay. During the frequency deviation measurement stage and the delay measurement, the slave node can calculate the frequency deviation and delay based on the sending time of the jump signal sent by the master node and the receiving time of the jump signal received by the slave node. Among them, the frequency deviation is the ratio between the frequency of the slave node and the frequency of the master node, which can be the ratio of the frequency of the slave node to the frequency of the master node, or the ratio of the frequency of the master node to the frequency of the slave node. The frequency deviation is used for frequency synchronization between the master node and the slave node. The delay is the length of time it takes for the signal to propagate on the bus between the master node and the slave node.
[0010] In a possible implementation, after obtaining the frequency deviation through frequency deviation measurement and obtaining the delay through delay measurement, the time of the master node can be synchronized to the slave node through the following method: the master node sends a first preview frame to the bus, and the first preview frame carries the first time. Then, the master node sends a second preview frame to the bus at the first time, and the second preview frame is used to trigger the first slave timer to record the first count value when passing through the slave receiving channel. Among them, the first count value is used to calculate the second time when the first slave timer receives the second preview frame, so that the slave node synchronizes time with the master node according to the first time, the second time, the frequency deviation and the delay. By carrying the sending time of the next preview frame in the preview frame, and the preview frame itself can also trigger the timer of the slave node to record the count value when the preview frame is received, the master node does not need to send other additional messages to inform the slave node of the sending time of the preview frame, which can reduce the number of interactions between the master node and the slave node, thereby improving the efficiency of time synchronization.
[0011] In a possible implementation, when measuring the frequency deviation, the master node sends at least two jump signals to the bus at different times, so that the frequency deviation can be calculated based on the sending time and receiving time of the two jump signals. Specifically, the jump signal includes a first jump signal and a second jump signal, the sending time includes a third time when the master node sends the first jump signal, and the receiving time includes a fourth time when the slave node receives the first jump signal; the sending time includes a fifth time when the master node sends the second jump signal, and the receiving time includes a sixth time when the slave node receives the second jump signal. The master node sends the sending time to the bus, including: the master node sends the third time and the fifth time to the bus, so that after the slave node obtains the third time and the fifth time, the frequency deviation of the slave node relative to the master node is calculated according to the third time, the fourth time, the fifth time and the sixth time. The third moment and the fifth moment obtained based on the first master timer capturing the jump signal are the precise moments when the master node sends the jump signal, and the fourth moment and the sixth moment obtained based on the first slave timer capturing the jump signal are the precise moments when the slave node receives the jump signal (relative to the slave node itself), thereby obtaining a precise frequency deviation based on the third moment to the sixth moment. The frequency deviation is used to synchronize the frequency between the master node and the slave node, thereby improving the accuracy of time synchronization.
[0012] The frequency deviation may be calculated by dividing the difference between the sixth moment and the fourth moment by the difference between the fifth moment and the third moment.
[0013] In a possible implementation, before the master node sends a jump signal to the bus through the main sending channel, it also includes: the master node sends a first control signal to the bus, and the first control signal is used to instruct the slave node to configure the first slave timer to the input capture mode, so that the first slave timer can be triggered by the edge of the signal received from the receiving channel to record the count value. In the bus architecture, when the bus is connected to multiple slave nodes, the communication connection between the master node and the slave node is point-to-multipoint, and the first control signal can control multiple slave nodes to enter the frequency deviation measurement mode to avoid interference caused by occupying the bus during measurement, thereby improving the frequency deviation measurement efficiency.
[0014] In a possible implementation, when measuring the delay, the master node sends a jump signal to the slave node to obtain the sending time of the master node sending the jump signal and the receiving time when the slave node receives the jump signal. The slave node also needs to send a jump signal to the master node to obtain the sending time of the slave node sending the jump signal and the receiving time of the master node receiving the jump signal, and then the delay between the master node and the slave node can be obtained based on these moments. Specifically, the jump signal includes a third jump signal, the sending time includes the seventh moment when the master node sends the third jump signal, and the receiving time includes the eighth moment when the slave node receives the third jump signal. The master node also includes a second master timer, and the second master timer is connected to the main receiving channel between the master node and the bus. The slave node also includes a second slave timer, and the second slave timer is connected to the slave sending channel between the slave node and the bus. The method also includes: the master node receives the fourth jump signal sent by the slave node to the bus through the main receiving channel, the fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel, and is used to trigger the second master timer to record the current count value when passing through the main receiving channel, the count value recorded by the second slave timer is used to calculate the ninth moment when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth moment when the master node receives the fourth jump signal; the master node sends the tenth moment to the bus, so that the slave node obtains the delay of the signal propagating between the master node and the slave node according to the seventh moment, the eighth moment, the ninth moment and the tenth moment. The seventh moment to the tenth moment are all moments with higher precision obtained based on the timer, so the accuracy of the delay obtained based on the seventh moment to the tenth moment is also higher, thereby improving the accuracy of time synchronization.
[0015] The delay can be specifically obtained by calculating the frequency deviation between the slave node and the master node according to the seventh moment, the eighth moment, the ninth moment and the tenth moment. The delay can be obtained by subtracting the second difference from the first difference, the first difference is the difference obtained by subtracting the seventh moment from the tenth moment, and the second difference is the difference after the frequency deviation is adjusted. Assuming that the frequency deviation is the ratio of the frequency of the slave node to the frequency of the master node, the second difference is specifically the difference between the ninth moment and the eighth moment divided by the frequency deviation.
[0016] In one possible implementation, before the master node sends a jump signal to the bus through the main sending channel, it also includes: the master node sends a second control signal to the bus, and the second control signal is used to instruct the slave node to configure the first slave timer to an input capture mode, so that the first slave timer can be triggered by the edge of the signal received from the receiving channel to record the count value, and to configure the second slave timer to an output capture mode, so that the second slave timer can be triggered by the edge of the signal sent from the sending channel to record the count value.
[0017] The second aspect provides a time synchronization method. The method is applied to a slave node in a communication system, the communication system includes a master node and at least one slave node, the master node and at least one slave node are connected through a bus, the master node includes a first master timer, the first master timer is connected to the master sending channel between the master node and the bus, and the slave node includes a first slave timer, the first slave timer is connected to the slave receiving channel between the slave node and the bus. The method includes: the slave node receives a jump signal sent by the master node to the bus through the slave receiving channel, the jump signal is used to trigger the first master timer to record the current count value when passing through the main sending channel, and is used to trigger the first slave timer to record the current count value when passing through the slave receiving channel, the count value recorded by the first master timer is used to calculate the sending time of the master node sending the jump signal, and the count value recorded by the first slave timer is used to calculate the receiving time of the slave node receiving the jump signal; the slave node receives the sending time sent by the master node to the bus; the slave node synchronizes time with the master node according to the sending time and the receiving time.
[0018] In one possible implementation, the sending time and the receiving time are used to calculate the frequency deviation or delay, the frequency deviation is the ratio of the frequency of the slave node to the frequency of the master node, and the delay is the length of time the signal propagates between the master node and the slave node. The method also includes: the slave node receives a first preview frame sent by the master node to the bus, the first preview frame carries a first time, and the first time indicates the time when the master node sends the second preview frame; the slave node receives a second preview frame sent by the master node to the bus at the first time, the second preview frame is used to trigger the first slave timer to record a first count value when passing through the slave receiving channel, and the first count value is used to calculate the second time when the first slave timer receives the second preview frame; the slave node synchronizes time with the master node based on the first time, the second time, the frequency deviation and the delay.
[0019] In one possible implementation, the jump signal includes a first jump signal and a second jump signal, the sending time includes a third time when the master node sends the first jump signal, and the receiving time includes a fourth time when the slave node receives the first jump signal; the sending time includes a fifth time when the master node sends the second jump signal, and the receiving time includes a sixth time when the slave node receives the second jump signal; the sending time when the slave node receives the sending time sent by the master node to the bus includes: the third time and the fifth time when the slave node receives the sending time sent by the master node to the bus; the slave node synchronizes time with the master node according to the sending time and the receiving time, including: the slave node calculates the frequency deviation of the slave node relative to the master node according to the third time, the fourth time, the fifth time and the sixth time.
[0020] In a possible implementation, before the slave node receives a jump signal sent by the master node to the bus through a slave receiving channel, it also includes: the slave node receives a first control signal sent by the master node to the bus; the slave node configures the first slave timer to an input capture mode according to the first control signal, so that the first slave timer can be triggered by the edge of the signal received from the slave receiving channel to record the count value.
[0021] In one possible implementation, the jump signal includes a third jump signal, the sending moment includes the seventh moment when the master node sends the third jump signal, and the receiving moment includes the eighth moment when the slave node receives the third jump signal; the master node also includes a second master timer, the second master timer is connected to the main receiving channel between the master node and the bus, the slave node also includes a second slave timer, the second slave timer is connected to the slave sending channel between the slave node and the bus, and the method also includes: the slave node sends a fourth jump signal to the bus through the slave sending channel, the fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel, and is used to trigger the second master timer to record the current count value when passing through the main receiving channel, the count value recorded by the second slave timer is used to calculate the ninth moment when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth moment when the master node receives the fourth jump signal; the slave node receives the sending moment sent by the master node to the bus includes: the tenth moment when the slave node receives the sending moment sent by the master node to the bus. The slave node synchronizes time with the master node according to the sending time and the receiving time, including: the slave node obtains the delay of the signal propagating between the master node and the slave node according to the seventh time, the eighth time, the ninth time and the tenth time.
[0022] In a possible implementation, before the slave node receives the jump signal sent by the master node to the bus through the slave receiving channel, it also includes: the slave node receives a second control signal sent by the master node to the bus; the slave node configures the first slave timer to an input capture mode according to the second control signal, so that the first slave timer can be triggered by the edge of the signal received from the receiving channel to record the count value, and configures the second slave timer to an output capture mode, so that the second slave timer can be triggered by the edge of the signal sent from the sending channel to record the count value.
[0023] The third aspect provides a device. The device is applied to a master node in a communication system, the communication system includes a master node and at least one slave node, the master node and the at least one slave node are connected through a bus, the master node includes a first master timer, the first master timer is connected to the master transmission channel between the master node and the bus, the slave node includes a first slave timer, the first slave timer is connected to the slave receiving channel between the slave node and the bus. The device includes a transceiver module and a processing module. Among them, the transceiver module is used to send a jump signal to the bus through the main transmission channel, the jump signal is used to trigger the first master timer to record the current count value when passing through the main transmission channel, and is used to trigger the first slave timer to record the current count value when passing through the slave receiving channel, and the count value recorded by the first slave timer is used to calculate the receiving time when the slave node receives the jump signal. The processing module is used to calculate the sending time when the device sends the jump signal according to the count value recorded by the first master timer. The transceiver module is used to send the sending time to the bus, so that after the slave node obtains the sending time, it synchronizes time with the master node according to the sending time and the receiving time.
[0024] In one possible implementation, the sending time and the receiving time are used to calculate the frequency deviation or delay, the frequency deviation is the ratio of the frequency of the slave node to the frequency of the master node, and the delay is the length of time the signal takes to propagate between the master node and the slave node; the transceiver module is used to send a first preview frame to the bus, the first preview frame carries a first time; the transceiver module is used to send a second preview frame to the bus at a first time, the second preview frame is used to trigger the first slave timer to record a first count value when passing through the slave receiving channel, and the first count value is used to calculate the second time when the first slave timer receives the second preview frame, so that the slave node is synchronized with the master node according to the first time, the second time, the frequency deviation and the delay.
[0025] In one possible implementation, the jump signal includes a first jump signal and a second jump signal, the sending moment includes a third moment when the master node sends the first jump signal, and the receiving moment includes a fourth moment when the slave node receives the first jump signal; the sending moment includes a fifth moment when the master node sends the second jump signal, and the receiving moment includes a sixth moment when the slave node receives the second jump signal; the transceiver module is used to send the third moment and the fifth moment to the bus, so that after the slave node obtains the third moment and the fifth moment, the frequency deviation of the slave node relative to the master node is calculated according to the third moment, the fourth moment, the fifth moment and the sixth moment.
[0026] In one possible implementation, the transceiver module is used to send a first control signal to the bus before sending a jump signal to the bus, and the first control signal is used to instruct the slave node to configure the first slave timer to an input capture mode so that the first slave timer can be triggered by the edge of the signal received from the receiving channel to record the count value.
[0027] In a possible implementation, the jump signal includes a third jump signal, the sending moment includes the seventh moment when the master node sends the third jump signal, and the receiving moment includes the eighth moment when the slave node receives the third jump signal; the master node also includes a second master timer, the second master timer is connected to the main receiving channel between the master node and the bus, and the slave node also includes a second slave timer, the second slave timer is connected to the slave sending channel between the slave node and the bus: a transceiver module, used to receive a fourth jump signal sent by the slave node to the bus through the main receiving channel, the fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel, and is used to trigger the second master timer to record the current count value when passing through the main receiving channel, the count value recorded by the second slave timer is used to calculate the ninth moment when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth moment when the master node receives the fourth jump signal; a transceiver module, used to send the tenth moment to the bus, so that the slave node obtains the delay of the signal propagating between the master node and the slave node according to the seventh moment, the eighth moment, the ninth moment and the tenth moment.
[0028] In one possible implementation, the transceiver module is used to send a second control signal to the bus before sending a jump signal to the bus, and the second control signal is used to instruct the slave node to configure the first slave timer to an input capture mode so that the first slave timer can be triggered by the edge of the signal received from the receiving channel to record the count value, and to configure the second slave timer to an output capture mode so that the second slave timer can be triggered by the edge of the signal sent from the sending channel to record the count value.
[0029] A fourth aspect provides a device. The device is applied to a slave node in a communication system, the communication system includes a master node and at least one slave node, the master node and the at least one slave node are connected through a bus, the master node includes a first master timer, the first master timer is connected to the master sending channel between the master node and the bus, and the slave node includes a first slave timer, the first slave timer is connected to the slave receiving channel between the slave node and the bus. The device includes a transceiver module and a processing module. The transceiver module is used to receive a jump signal sent by the master node to the bus through the slave receiving channel, the jump signal is used to trigger the first master timer to record the current count value when passing through the main sending channel, and is used to trigger the first slave timer to record the current count value when passing through the slave receiving channel, the count value recorded by the first master timer is used to calculate the sending time of the master node sending the jump signal, and the count value recorded by the first slave timer is used to calculate the receiving time of the slave node receiving the jump signal. The transceiver module is used to receive the sending time sent by the master node to the bus; the processing module is used to synchronize time with the master node according to the sending time and the receiving time.
[0030] In a possible implementation, the sending time and the receiving time are used to calculate the frequency deviation or delay, the frequency deviation is the ratio between the frequency of the slave node and the frequency of the master node, and the delay is the length of time the signal propagates between the master node and the slave node. The transceiver module is used to receive the first notice frame sent by the master node to the bus, the first notice frame carries the first time, and the first time indicates the time when the master node sends the second notice frame. The transceiver module is used to receive the second notice frame sent by the master node to the bus at the first time, the second notice frame is used to trigger the first slave timer to record the first count value when passing through the slave receiving channel, and the first count value is used to calculate the second time when the first slave timer receives the second notice frame. The processing module is used to synchronize time with the master node according to the first time, the second time, the frequency deviation and the delay.
[0031] In a possible implementation, the jump signal includes a first jump signal and a second jump signal, the sending moment includes a third moment when the master node sends the first jump signal, and the receiving moment includes a fourth moment when the slave node receives the first jump signal; the sending moment includes a fifth moment when the master node sends the second jump signal, and the receiving moment includes a sixth moment when the slave node receives the second jump signal. The transceiver module is specifically used to receive the third moment and the fifth moment sent by the master node to the bus. The processing module is specifically used to calculate the frequency deviation of the slave node relative to the master node according to the third moment, the fourth moment, the fifth moment and the sixth moment.
[0032] In a possible implementation, the transceiver module is used to receive a first control signal sent by the master node to the bus before receiving a jump signal sent by the master node through a slave receiving channel. The processing module is used to configure the first slave timer to an input capture mode according to the first control signal, so that the first slave timer can be triggered by the edge of the signal received from the slave receiving channel to record the count value.
[0033] In a possible implementation, the jump signal includes a third jump signal, the sending moment includes the seventh moment when the master node sends the third jump signal, and the receiving moment includes the eighth moment when the slave node receives the third jump signal. The master node also includes a second master timer, the second master timer is connected to the master receiving channel between the master node and the bus, and the slave node also includes a second slave timer, the second slave timer is connected to the slave sending channel between the slave node and the bus. A transceiver module is used to send a fourth jump signal to the bus through the slave sending channel, the fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel, and is used to trigger the second master timer to record the current count value when passing through the main receiving channel, the count value recorded by the second slave timer is used to calculate the ninth moment when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth moment when the master node receives the fourth jump signal. The transceiver module is specifically used to receive the tenth moment when the master node sends the bus. The processing module is specifically used to obtain the delay of the signal propagating between the master node and the slave node according to the seventh moment, the eighth moment, the ninth moment and the tenth moment.
[0034] In a possible implementation, the transceiver module is used to receive a second control signal sent by the master node to the bus before receiving a jump signal sent by the master node through a slave receiving channel. The processing module is used to configure the first slave timer to an input capture mode according to the second control signal, so that the first slave timer can be triggered by the edge of the signal received from the slave receiving channel to record the count value, and configure the second slave timer to an output capture mode, so that the second slave timer can be triggered by the edge of the signal sent from the slave sending channel to record the count value.
[0035] A fifth aspect provides a communication system, which includes a bus, and a device as in the third aspect or any possible implementation of the third aspect connected to the bus, and a device as in the fourth aspect or any possible implementation of the fourth aspect connected to the bus.
[0036] A sixth aspect provides an electronic device. The electronic device includes a processor and a memory, the processor is coupled to the memory, and the processor is configured to execute the time synchronization method in the first aspect or any possible implementation of the first aspect, or the time synchronization method in the second aspect or any possible implementation of the second aspect based on instructions stored in the memory.
[0037] The seventh aspect provides a computer-readable storage medium, comprising instructions, which, when the computer-readable storage medium is run on a computer, enables the computer to execute the steps of the time synchronization method in the first aspect or any possible implementation of the first aspect, or the steps of the time synchronization method in the second aspect or any possible implementation of the second aspect.
[0038] The eighth aspect provides a computer program product comprising instructions, which, when executed by an electronic device, causes the electronic device to perform the steps of the time synchronization method in the first aspect or any possible implementation of the first aspect, or the steps of the time synchronization method in the second aspect or any possible implementation of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 A schematic diagram of the structure of the communication system provided for this application;
[0040] Figure 2 A flow chart of a frequency deviation measurement method provided in this application;
[0041] Figure 3 A flowchart of a delay measurement method provided in this application;
[0042] Figure 4 A flowchart of a time synchronization method provided by this application;
[0043] Figure 5 A flowchart of another time synchronization method provided by this application;
[0044] Figure 6 A schematic diagram of the structure of a device provided in this application;
[0045] Figure 7 A schematic diagram of the structure of an electronic device provided in this application. DETAILED DESCRIPTION
[0046] The present application provides a time synchronization method and related equipment to achieve high-precision time synchronization at low cost.
[0047] In the present application, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that there are three relationships. For example, A and / or B means: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c means: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple. In addition, in the embodiments of the present application, the words "first", "second" and the like do not limit the quantity and execution order.
[0048] In the various embodiments of the present application, unless otherwise specified or provided for in any logical conflict, the terms and / or descriptions between the different embodiments are consistent and may be referenced to each other, and the technical features in the different embodiments may be combined to form new embodiments according to their inherent logical relationships.
[0049] The bus architecture network has the characteristics of simple structure, low cost and high reliability, and is widely used in scenarios such as campus, vehicle, industrial automation and building automation. The bus architecture network is a broadcast network that uses a bus as the transmission medium. Multiple nodes are connected to the bus through interfaces, and multiple nodes share the bus for communication. That is, the information sent by any node connected to the bus is transmitted from the sending node along the bus to both ends and is received by all other nodes connected to the bus.
[0050] Time synchronization refers to the process of adjusting the time, frequency and phase of each node in the communication system. In a communication system, time synchronization between nodes is of great significance for precise control of nodes, status monitoring and accurate communication between nodes.
[0051] Current clock synchronization protocols include automotive open system architecture (AUTOSAR) and gPTP. AUTOSAR obtains timestamps from the application layer, which has the problem of inaccurate timestamps, resulting in low time synchronization accuracy. gPTP is used for Ethernet time synchronization and requires dedicated hardware to achieve time synchronization, which is costly.
[0052] In order to solve the above technical problems, the present application provides the following embodiments to achieve high-precision time synchronization at low cost.
[0053] like Figure 1 As shown, Figure 1 A schematic diagram of the structure of the communication system provided for this application. In the present embodiment, the communication system includes a bus and a plurality of nodes. The plurality of nodes are connected to the bus, and the plurality of nodes communicate with each other through the bus. Among them, the bus can be a single pair of cables or multiple pairs of cables, which is not limited here. The bus can be a CAN bus, a CAN-FD bus, a CAN-XL bus, an Ethernet bus or other buses, etc.
[0054] In industrial automation scenarios, nodes can include industrial equipment such as controllers, sensors, servers, industrial robots, robotic arms, switches or IO devices. In vehicle scenarios, nodes can include electronic control units (ECUs), sensors, cameras, multi-domain controllers (MDCs), telematics boxes (T-Boxes), cockpit domain controllers (CDCs), vehicle gateways, vehicle control units (VCUs), battery management system controllers (BMSs), thermal management systems (TMSs), power distribution units and other electronic components inside vehicles.
[0055] The multiple nodes may include a master node and at least one slave node. Figure 1 The number of slave nodes in is only an example and should not be construed as a limitation of the present application. Among them, the master node has higher time accuracy than the slave node. The master node is a time source node, and the slave node needs to synchronize its own time with the time of the master node. Among them, the master node can be selected from multiple nodes through the best master clock algorithm (BMCA) or specified by configuration. The master node is used to instruct the slave node to measure and calculate the frequency deviation and delay between the master node and the slave node, and complete the time synchronization between the master node and the slave node based on the frequency deviation and delay.
[0056] The master node includes a first master timer and a master communication interface. The master node is connected to the bus through the master communication interface. The first master timer connects the master transmission channel between the master communication interface and the bus, and the master transmission channel is a channel for the master node to send signals to the bus. The slave node includes a first slave timer and a slave communication interface. The slave node is connected to the bus through the slave communication interface. The first slave timer connects the slave receiving channel between the slave node and the bus, and the slave receiving channel is a channel for the slave node to receive signals from the bus.
[0057] The first master timer is used to capture the signal sent through the main transmission channel to obtain the transmission time of the signal. The moment when the signal passes through the main transmission channel is closer to the actual transmission time, so the first master timer is connected to the main transmission channel, which can obtain a more accurate transmission time. In addition, the first master timer captures the physical signal, which also makes the transmission time obtained by the first master timer more accurate. The first slave timer is used to capture the signal received through the slave receiving channel to obtain the reception time of the signal. The moment when the signal passes through the slave receiving channel is closer to the actual reception time, so the first slave timer is connected to the slave receiving channel, which can obtain a more accurate reception time. In addition, the first slave timer captures the physical signal, which also makes the reception time obtained by the first slave timer more accurate. Thus, high-precision time synchronization can be achieved based on precise moments.
[0058] Specifically, the master node can send a jump signal to the bus through the main transmission channel. The jump signal has a jump edge and can be detected by the timer. The jump signal can be a single-bit signal, such as a signal corresponding to 1. The jump signal can also be a multi-bit signal, such as a signal corresponding to multiple consecutive bits of 1. The multiple bits can be 2 bits, 3 bits, 4 bits, 8 bits or 16 bits, etc., to improve the stability of the jump signal. Even if there is loss and interference during the propagation process, it can be stably transmitted to each slave node and detected by the slave node's timer. The jump signal is relatively simple, does not need to be encapsulated through the protocol stack, has low hardware requirements, and occupies a shorter time on the bus, which can improve the efficiency of time synchronization.
[0059] When the transition signal passes through the main transmission channel, it can trigger the first master timer to record the current count value, that is, the first master timer can capture the edge of the transition signal in the main transmission channel, and record the count value corresponding to the first master timer when the edge of the transition signal is captured. When the transition signal propagates to the slave node and passes through the slave receiving channel, it can trigger the first slave timer to record the current count value, that is, the first slave timer can capture the edge of the transition signal in the slave receiving channel, and record the count value corresponding to the first slave timer when the edge of the transition signal is captured.
[0060] The count value recorded by the first master timer can be used to calculate the sending time when the master node sends the jump signal. For example, the time when the first master timer is started is the initial time T1, and the frequency of the clock signal input to the first master timer is f1, then the time interval between two adjacent counts of the first master timer is 1 / f1, that is, the counting cycle of the first master timer is 1 / f1, then according to the count value c1 recorded when the first master timer captures the jump signal and the counting cycle of the first master timer, the time interval relative to the initial time T1 when the first master timer captures the jump signal can be obtained, and then according to the initial time T1 and the time interval relative to the initial time T1 when the first master timer captures the jump signal, the time when the first master timer captures the jump signal can be calculated, that is, the sending time when the master node sends the jump signal. The master node, for example, includes a master processor (not shown). When the first master timer captures a jump signal, it records the current count value c1 and sends an interrupt signal to the master processor. The master processor responds to the interrupt signal and obtains the count value c1 recorded by the first master timer. Then, based on the initial time T1, the count value c1 recorded by the first master timer and the count period 1 / f1 of the first master timer, the master node calculates the sending time of the jump signal.
[0061] Of course, the register size of the first master timer is limited, and overflow may occur. Then the master node may also include a master counter, which can be used to count the number of overflows of the first master timer, and the counting cycle of the master counter is the overflow cycle of the first master timer. The master counter can be a software counter or a hardware counter, which is not limited here. When the first master timer captures the jump signal, it records the current count value c1 and sends an interrupt signal to the main processor. The main processor responds to the interrupt signal interrupt, and the main processor obtains the count value c1 recorded by the first master timer and the count value c2 of the master counter, and then calculates the sending time of the master node sending the jump signal according to the initial time T1, the count value c1 recorded by the first master timer, the counting cycle 1 / f1 of the first master timer, the count value c2 of the master counter and the counting cycle of the master counter.
[0062] Optionally, an external high-speed clock may be used to provide a clock signal for the first master timer, thereby improving the accuracy and stability of the first master timer, and further improving the accuracy of the sending time obtained based on the count value of the first master timer.
[0063] The count value recorded by the first slave timer can be used to calculate the receiving time when the slave node receives the jump signal. For example, the time when the first slave timer is started is the initial time T2, and the frequency of the clock signal input to the first slave timer is f2, then the time interval between two adjacent counts of the first slave timer is 1 / f2, that is, the counting cycle of the first slave timer is 1 / f2, then according to the count value recorded when the first slave timer captures the jump signal and the counting cycle of the first slave timer, the time interval relative to the initial time T2 when the first slave timer captures the jump signal can be obtained, and then according to the initial time T2 and the time interval relative to the initial time T2 when the first slave timer captures the jump signal, the time when the first slave timer captures the jump signal can be calculated, that is, the receiving time when the slave node receives the jump signal. The slave node, for example, includes a slave processor (not shown in the figure). When the first slave timer captures the jump signal, it records the current count value c3 and sends an interrupt signal to the slave processor. The slave processor responds to the interrupt signal and obtains the count value c3 recorded by the first master timer. Then, the reception time of the slave node receiving the jump signal is calculated based on the initial time T2, the count value c3 recorded by the first slave timer and the count period 1 / f2 of the first slave timer.
[0064] Of course, the register size of the first slave timer is limited, and overflow may occur. Then the slave node may also include a slave counter, which can be used to count the number of overflows of the first slave timer, and the counting period of the slave counter is the overflow period of the first slave timer. The slave counter can be a software counter or a hardware counter, which is not limited here. When the first slave timer captures the jump signal, it records the current count value c3 and sends an interrupt signal to the slave processor. The slave processor responds to the interrupt signal interrupt, obtains the count value c3 recorded by the first slave timer and the count value c4 of the slave counter, and then calculates the sending time of the master node sending the jump signal according to the initial time T2, the count value c3 recorded by the first slave timer, the counting period 1 / f2 of the first slave timer, the count value c4 of the slave counter and the counting period of the slave counter.
[0065] In this embodiment, since the first master timer is connected to the main transmission channel between the master node and the bus, the moment corresponding to the jump signal captured by the first timer is used as the transmission moment of the master node sending the jump signal, the transmission moment is obtained based on the triggering of the hardware by the jump signal, and the jump signal in the main transmission channel is captured, which can improve the accuracy of the transmission moment obtained by the master node. Similarly, the reception moment of the jump signal received by the slave node based on the first slave timer also has high accuracy. The counting accuracy of the timer is positively correlated with the accuracy and frequency of the clock signal. The counting accuracy of the timer can be improved by controlling the frequency of the clock signal input to the timer. When the frequency of the clock signal input to the timer reaches 1MHz, the counting accuracy of the timer can reach the microsecond level. When the frequency of the clock signal input to the timer is greater than 1MHz, the counting accuracy of the timer can reach the sub-microsecond level, so that a high-precision timestamp (sending time and receiving time) can be obtained based on the timer. In addition, the timer is a universal and inexpensive hardware, and no special hardware is required. While a high-precision timestamp can be obtained based on the timer, the cost required for time synchronization can also be reduced.
[0066] Since the master node and at least one slave node are based on bus communication, when the number of slave nodes is greater than or equal to 2, the master node can achieve time synchronization in a point-to-multipoint manner, and the time synchronization efficiency is high. Specifically, the jump signal sent by the master node can be received by all slave nodes connected to the bus, so all slave nodes receive the same jump signal sent by the master node respectively, and the first slave timer of each slave node respectively records the corresponding count value when receiving the jump signal, thereby obtaining the moment of receiving the jump signal respectively. For the sake of simplicity in description, this application takes one of the multiple slave nodes as an example for explanation, and the same applies to other slave nodes.
[0067] The edge of the above-mentioned jump signal can refer to the rising edge of the jump signal, or it can refer to the falling edge of the jump signal. The edge that triggers the first master timer and the first slave timer to record the count value is the same, so that the time calculated based on the count value is more accurate. That is, the first master timer is configured to be triggered by the rising edge of the jump signal to record the current count value, and the first slave timer is configured to be triggered by the rising edge of the jump signal to record the current count value. Alternatively, the first master timer is configured to be triggered by the falling edge of the jump signal to record the current count value, and the first slave timer is configured to be triggered by the falling edge of the jump signal to record the current count value.
[0068] The master node also includes a second master timer, which is connected to the master receiving channel between the master node and the bus. The second master timer is used to capture the jump signal sent from the slave node to the bus, and record the count value when the jump signal is received, and the count value is used to calculate the receiving time when the master node receives the jump signal. The slave node also includes a second slave timer, which is connected to the slave sending channel between the slave node and the bus. The second slave timer is used to capture the jump signal sent from the slave node to the bus, and record the count value when the jump signal is sent, and the count value is used to calculate the sending time when the slave node sends the jump signal.
[0069] The moment when the signal passes through the main receiving channel is closer to the actual receiving moment, so the second master timer is connected to the main receiving channel to obtain a more accurate receiving moment. In addition, the second master timer captures the physical signal, which also makes the receiving moment obtained by the second master timer more accurate. The moment when the signal passes through the slave sending channel is closer to the actual sending moment, so the second slave timer is connected to the slave sending channel to obtain a more accurate sending moment. In addition, the second slave timer captures the physical signal, which also makes the sending moment obtained by the second slave timer more accurate.
[0070] Thus, through the timer, the time when the master node / slave node sends and receives the jump signal can be accurately obtained, and then, based on the time when the master node and the slave node send and receive the jump signal, time synchronization can be performed with high precision.
[0071] In the present application, the time synchronization process between the master node and the slave node may specifically include three stages: frequency deviation measurement, delay measurement and time synchronization. The three stages are described below respectively.
[0072] like Figure 2 As shown, Figure 2 This is a flow chart of a frequency deviation measurement method provided by the present application. This embodiment is implemented based on the above communication system, and this embodiment includes the following steps:
[0073] S201: The master node configures the first master timer to an output capture mode.
[0074] The first master timer is connected to the main sending channel between the main node and the bus. The first master timer is configured in output capture mode. The first master timer can capture the signal sent to the bus through the main sending channel, that is, the first master timer can be triggered by the edge of the signal propagated in the main sending channel to record the current count value, and send an interrupt request to the main processor to request the main processor to calculate the corresponding time according to the count value recorded by the first master timer.
[0075] S202: The master node sends a first control signal to the bus, where the first control signal is used to instruct the slave node to configure the first slave timer to an input capture mode.
[0076] The first control signal is used to instruct all slave nodes connected to the bus to enter a frequency deviation measurement mode. The frequency deviation measurement mode specifically includes an interaction process between a slave node and a master node, configuration of a timer by a slave node, and calculation of a frequency deviation between the slave node and the master node by a frequency deviation algorithm.
[0077] Frequency deviation refers to the ratio between the frequency of the clock signal of the slave node and the frequency of the clock signal of the master node. The clock signal is obtained by multiplying or dividing the frequency output by the crystal oscillator. The frequency output by the crystal oscillator is related to factors such as the operating temperature and the performance of the crystal oscillator itself (such as frequency and stability). Due to the different performance and operating temperature of the crystal oscillators in different nodes, the frequency output by the crystal oscillators of different nodes may also be different. Therefore, to achieve time synchronization, it is necessary to first obtain the frequency deviation of the slave node relative to the master node, and be able to correct the frequency of the slave node based on the frequency deviation to improve the accuracy of the slave node's time.
[0078] The first control signal may be a broadcast message, carrying information such as the identification of the slave node or the delay measurement sequence, etc. The first control signal may also be a set of binary sequences instead of a message, and the slave node may identify the binary sequence and enter the frequency deviation measurement mode.
[0079] S203: The slave node configures the first slave timer to an input capture mode according to the first control signal.
[0080] After receiving the first control signal, each slave node connected to the bus configures the first slave timer to the input capture mode in response to the first control signal. The first slave timer is a timer used to detect the slave receiving channel between the slave node and the bus. When the first slave timer is configured to the input capture mode, the first slave timer can capture the signal received through the slave receiving channel, that is, the first timer can be triggered by the edge of the signal propagated from the receiving channel to record the current count value, and send an interrupt request to the slave processor to request the slave processor to calculate the corresponding time according to the count value recorded by the first slave timer.
[0081] S204: the master node sends a first hopping signal to the bus through the main sending channel. The first hopping signal is used to trigger the first master timer to record the current count value when passing through the main sending channel. The count value is used to calculate the third time when the master node sends the first hopping signal.
[0082] In this embodiment, the master node sends a first jump signal to the bus to trigger the first master timer of the master node to record the count value when capturing the jump signal, so that the third time when the master node sends the first jump signal can be obtained based on the count value. The corresponding time obtained based on the count value can refer to the relevant description above, which will not be repeated here.
[0083] S205: The slave node receives a first hopping signal transmitted on the bus through a slave receiving channel. The first hopping signal is used to trigger a first slave timer to record a current count value when passing through the slave receiving channel. The count value is used to calculate a fourth moment when the slave node receives the first hopping signal.
[0084] The slave node receives the first jump signal propagated on the bus. When the first jump signal passes through the slave receiving channel, the edge of the first jump signal can be captured by the first slave timer. The first slave timer is triggered by the edge of the first jump signal to record the current count value, and sends an interrupt request to the slave processor to request the slave processor to calculate the fourth time when the slave node receives the first jump signal according to the count value recorded by the first slave timer. The corresponding time obtained based on the count value can be referred to the relevant description above, which will not be repeated here.
[0085] S206: The master node sends the third time to the bus.
[0086] The master node sends the third time to the bus via a broadcast frame, so that all slave nodes connected to the bus can receive the third time when the master node sends the first jump signal.
[0087] S207: The master node sends a second hopping signal to the bus through the main sending channel. The second hopping signal is used to trigger the first master timer to record the current count value when passing through the main sending channel. The count value is used to calculate the fifth time when the master node sends the second hopping signal.
[0088] S208: The slave node receives a second hopping signal transmitted on the bus through a slave receiving channel. The second hopping signal is used to trigger the first slave timer to record the current count value when passing through the slave receiving channel. The count value is used to calculate the sixth moment when the slave node receives the second hopping signal.
[0089] S209: The master node sends the fifth time to the bus.
[0090] The master node sends the fifth time to the bus via a broadcast frame, so that all slave nodes connected to the bus can receive the fifth time when the master node sends the first jump signal.
[0091] S210: The slave node calculates the frequency deviation between the slave node and the master node according to the third moment, the fourth moment, the fifth moment and the sixth moment.
[0092] After the slave node obtains the third moment and the fifth moment, the frequency deviation between the slave node and the master node can be calculated by combining the fourth moment and the sixth moment obtained by itself. It can be considered that the time interval between the master node sending the first jump signal and the second jump signal is theoretically equal to the time interval between the slave node receiving the first jump signal and the second jump signal. Since the frequencies of the crystal oscillators of the master node and the slave node may be different, the time interval between the sending of the first jump signal and the second jump signal recorded by the master node (the difference between the fifth moment and the third moment) may be different from the time interval between the receiving of the first jump signal and the second jump signal recorded by the slave node (the difference between the sixth moment and the fourth moment). For example, if the frequency of the crystal oscillator of the slave node is greater than the frequency of the crystal oscillator of the master node, the difference between the sixth moment and the fourth moment will be greater than the difference between the fifth moment and the third moment. Conversely, if the frequency of the crystal oscillator of the slave node is less than the frequency of the crystal oscillator of the master node, the difference between the sixth moment and the fourth moment will be less than the difference between the fifth moment and the third moment. Therefore, the frequency deviation of the slave node relative to the master node can be obtained by comparing the difference between the sixth moment and the fourth moment with the difference between the fifth moment and the third moment.
[0093] The calculation formula of frequency deviation ratio (FDR) is as follows:
[0094] FDR=(T k S n -T k S n-1 ) / (TM n -TM n-1 ) (1)
[0095] In formula (1), TM n At the fifth moment when the master node sends the second hopping signal to the bus, TM n-1 is the third moment when the master node sends the first jump signal to the bus, T k S n is the sixth moment when the second hopping signal is received from node k, T k S n-1 is the fourth moment when the slave node k receives the first jump signal. The slave node k is any one of the at least one slave node connected to the bus.
[0096] When the jump signal is transmitted in the bus, there will be interference delay due to signal attenuation and possible signal interference. Since this interference delay always exists during multiple communications, it can be offset when calculating the relative time interval of the slave node in formula (1), as shown in the following formula, where ΔT d represents the interference delay under a specific communication distance d,
[0097] FDR=((T kS n +ΔT d )-(T k S n-1 +ΔT d )) / (TM n -TM n-1 )
[0098] =(T k S n -T k S n-1 ) / (TM n -TM n-1 )
[0099] Therefore, the frequency deviation calculation between the master and slave nodes is not affected by signal attenuation and fixed interference in the bus network, and the calculation accuracy is extremely high.
[0100] In this embodiment, the timestamp is obtained by sending a jump signal without encapsulating a message, which is more concise and has higher efficiency. The timer of each node connects the sending channel and the receiving channel to detect and capture the signal sent from the node transmitted by the sending channel, and detect and capture the signal received from the bus transmitted by the receiving channel. On the one hand, the moment when the signal is transmitted in the transceiver channel is closer to the real transceiver moment; on the other hand, the physical signal is detected by hardware such as a timer, and the moment obtained based on the count value of the timer can better reflect the real moment when the node sends and receives the signal, which is more accurate than the application layer to obtain the system time; on the other hand, the accuracy of the timer is positively correlated with the accuracy of the clock signal provided to the timer, so a high-precision clock signal can be input to the timer to ensure the accuracy of the transceiver moment obtained based on the count value of the timer. In addition, the timer is a general device in electronic devices and has a low cost. Therefore, the moment obtained based on the count value of the timer is highly accurate and precise. Furthermore, based on the high-precision and high-accuracy moment, a high-precision frequency deviation can be calculated.
[0101] exist Figure 2 In an embodiment, after obtaining the third moment and before sending the second hopping signal, the master node broadcasts the third moment through the bus. After the master node obtains the fourth moment, the master node broadcasts the fourth moment through the bus. That is, the master node broadcasts the third moment and the fourth moment respectively through two broadcast frames. In another implementation, the master node may not broadcast the third moment after obtaining the third moment and before sending the second hopping signal, but after the master node obtains the fourth moment, broadcast the third moment and the fifth moment through the bus using the same broadcast frame, or broadcast the difference between the fifth moment and the third moment through the bus using a broadcast frame, so as to reduce the number of messages that need to be transmitted on the bus and improve the delay measurement efficiency.
[0102] like Figure 3 As shown, Figure 3 A schematic diagram of a delay measurement method provided in this application. This embodiment includes the following steps:
[0103] S301: The master node configures the first master timer to an output capture mode, and the second master timer to an input capture mode.
[0104] In the delay measurement mode, the master node needs to configure the first master timer as output capture mode and the second master timer as input capture mode. The first timer is used to capture the signal propagated in the main transmission channel between the master node and the bus. The second timer is used to capture the signal propagated in the main receiving channel between the master node and the bus.
[0105] S302: The master node sends a second control signal to the bus, where the second control signal is used to instruct the slave node to configure the first slave timer to an input capture mode and to configure the second slave timer to an output capture mode.
[0106] The master node sends a second control signal to the bus, and the second control signal is used to instruct the slave node to enter the delay measurement mode. The delay measurement mode specifically includes the interaction process between the slave node and the master node, the configuration of the timer by the slave node, and the use of the delay algorithm by the slave node to calculate the delay between the slave node and the master node. Delay refers to the time required for a signal to propagate from the master node to the slave node through the bus. The delay between the master node and the slave node is related to factors such as the distance between the two and the rate of the bus.
[0107] The delay measurement process requires the slave node to send a jump signal to the bus. When the number of slave nodes connected to the bus is multiple, the master node can instruct multiple slave nodes to perform delay measurement in an orderly manner through a second control signal. For example, the second control signal can carry the identifier of one of the multiple slave nodes, instructing the slave node to perform delay measurement with the master node, and the other slave nodes are silent to avoid interference caused by other slave nodes competing for the bus during the delay measurement process. After each delay measurement of a slave node is completed, a second control signal carrying the identifier of the slave node that has not been measured in this round is sent. For another example, the second control signal can carry the delay measurement order of multiple slave nodes, instructing the slave node to perform delay measurement in a specified order, and the slave node remains silent during the measurement window of other slave nodes. For another example, the slave node is configured with a number. After receiving the second control signal, each slave node performs delay measurement with the master node in the order of numbers from large to small or from small to large.
[0108] The second control signal may be a broadcast message, carrying information such as the identification of the slave node or the delay measurement order. The second control signal may also be a set of binary sequences instead of a message, and the slave node may identify the binary sequence and enter the delay measurement mode. In this case, the binary sequences corresponding to the first control signal and the second control signal are different.
[0109] S303: The slave node configures the first slave timer to an input capture mode and the second slave timer to an output capture mode according to the second control signal.
[0110] In the delay measurement mode, the slave node receives the jump signal from the master node and sends the jump signal to the master node. Therefore, the slave node responds to the second control signal, configures the first slave timer to the input capture mode, and configures the second slave timer to the output capture mode. The first slave timer is connected to the slave receiving channel between the slave node and the bus, and the slave receiving channel is used to receive signals from the bus, so that the first slave timer can capture the signal propagated from the receiving channel. That is, the first slave timer can be triggered by the edge of the signal propagated from the receiving channel to record the current count value, and send an interrupt request to the slave processor to request the slave processor to calculate the corresponding time when the first slave timer captures the signal according to the count value recorded by the first slave timer. The second slave timer is connected to the slave sending channel between the slave node and the bus, and the slave sending channel is used to send signals from the node to the bus, so that the second slave timer can capture the signal propagated from the sending channel. That is, the second slave timer can be triggered by the edge of the signal propagated from the sending channel to record the current count value, and send an interrupt request to the slave processor to request the slave processor to calculate the corresponding time when the second slave timer captures the signal according to the count value recorded by the second slave timer.
[0111] S304: the master node sends a third hopping signal to the bus through the main sending channel. The third hopping signal is used to trigger the first master timer to record the current count value when passing through the main sending channel. The count value is used to calculate the seventh time when the master node sends the third hopping signal.
[0112] S305: The slave node receives the third hopping signal propagated on the bus through the slave receiving channel. The third hopping signal is used to trigger the first slave timer to record the current count value when passing through the slave receiving channel. The count value is used to calculate the eighth moment when the slave node receives the third hopping signal.
[0113] S306: The slave node sends a fourth hopping signal to the bus through the slave sending channel. The fourth hopping signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel. The count value is used to calculate the ninth time when the slave node sends the fourth hopping signal.
[0114] The fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave transmission channel, and is used to trigger the second master timer to record the current count value when passing through the master reception channel. The count value recorded by the second slave timer is used to calculate the ninth moment when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth moment when the master node receives the fourth jump signal.
[0115] S307: The master node receives the fourth hopping signal transmitted on the bus through the main receiving channel. The fourth hopping signal is used to trigger the second master timer to record the current count value when passing through the main receiving channel. The count value is used to calculate the tenth moment when the master node receives the fourth hopping signal.
[0116] S308: The master node sends the seventh moment and the tenth moment, or the difference between the tenth moment and the seventh moment to the bus.
[0117] The master node can send the seventh moment and the tenth moment, or the difference between the tenth moment and the seventh moment, to the slave node through the bus in the same frame, which can reduce the number of interactions between the master node and the slave node, thereby improving the delay measurement efficiency.
[0118] Of course, the master node can also send the seventh moment and the tenth moment to the slave node through the bus through two frames. The master node can send the seventh moment to the bus after obtaining the seventh moment, and send the tenth moment to the bus after obtaining the tenth moment. Alternatively, the master node can send the seventh moment and the tenth moment through two frames after obtaining the seventh moment and the tenth moment.
[0119] S309: The slave node calculates the time delay between the slave node and the master node according to the difference between the seventh moment and the tenth moment, or between the tenth moment and the seventh moment, and the eighth moment and the ninth moment.
[0120] The difference between the tenth moment and the seventh moment includes the delay of the third jump signal propagating from the master node to the slave node, the processing delay from the slave node receiving the third jump signal to sending the fourth jump signal, and the delay of the fourth jump signal propagating from the slave node to the master node. The distance between the master node and the slave node remains unchanged, so it can be considered that the delay of the third jump signal propagating from the master node to the slave node is equal to the delay of the fourth jump signal propagating from the slave node to the master node. The difference between the tenth moment and the seventh moment, minus the difference between the ninth moment and the eighth moment and divided by 2, can be considered as the delay required for the signal to propagate from the master node to the slave node through the bus, or the delay required for the signal to propagate from the slave node to the master node.
[0121] Since there may be a frequency deviation between the slave node and the master node, and the difference between the tenth moment and the seventh moment is obtained based on the frequency of the master node, and the difference between the ninth moment and the eighth moment is obtained based on the frequency of the slave node, the difference between the ninth moment and the eighth moment may be deviated relative to the master node. In order to further improve the accuracy of the delay, the difference between the ninth moment and the eighth moment can be corrected using the frequency deviation of the slave node relative to the master node, and corrected to the difference between the ninth moment and the eighth moment obtained based on the frequency of the master node.
[0122] Therefore, the corrected delay calculation formula is as follows:
[0123] d′ p2p =((TM n -TM n-1 )-(T k S n -T k S n-1 ) / FDRk) / 2
[0124] Among them, d′ p2p is the corrected delay, TM n The tenth moment obtained by the master node, TM n-1 is the seventh moment obtained by the master node, T k S n is the ninth time obtained from node k, T k S n-1 is the eighth time obtained from the slave node k. FDRk is the frequency deviation of the slave node k relative to the master node. The slave node k is any slave node among the slave nodes connected to the bus.
[0125] After S308, S302-S309 are repeated until all slave nodes complete this round of delay measurement.
[0126] In another implementation, after S302, the slave node may send a third transition signal to the bus through the slave transmission channel. When the slave node sends the third transition signal, the third transition signal triggers the second slave timer to record the current count value when passing through the slave transmission channel, and the count value is used to calculate the seventh moment when the slave node sends the third transition signal. When the master node receives the third transition signal, the third transition signal triggers the second master timer to record the current count value when passing through the main receiving channel, and the count value is used to calculate the eighth moment when the master node receives the third transition signal. Then, the master node sends a fourth transition signal to the bus through the main transmission channel. When the master node sends the fourth transition signal, the fourth transition signal triggers the first master timer to record the current count value when passing through the main transmission channel, and the count value is used to calculate the ninth moment when the master node sends the fourth transition signal. When the slave node receives the fourth transition signal, the fourth transition signal triggers the first slave timer to record the current count value when passing through the slave receiving channel, and the count value is used to calculate the tenth moment when the slave node receives the fourth transition signal. Then, the master node sends the eighth moment and the ninth moment, or the difference between the ninth moment and the eighth moment, to the bus. After the slave node receives the eighth moment and the ninth moment, or the difference between the ninth moment and the eighth moment from the bus, it calculates the delay between the slave node and the master node in combination with the seventh moment and the tenth moment. After completing the delay measurement of the slave node, the master node sends a second control signal, the second control signal includes the identifier of the slave node that has not yet performed the delay measurement, to indicate that the delay measurement is performed between the slave node and the master node, and the delay measurement process is similar to the above delay measurement process until all slave nodes complete the round of delay measurement.
[0127] The delay between the slave node and the master node needs to be corrected by the frequency deviation between the slave node and the master node. Therefore, the master node and the slave node can first perform frequency deviation measurement, and then perform delay measurement, so as to use the frequency deviation to correct the delay. Of course, it is also possible to first perform delay measurement, and then perform frequency deviation measurement, and after obtaining the frequency deviation, use the frequency deviation to correct the delay. There is no restriction here.
[0128] In this embodiment, the timestamp is obtained by sending a jump signal, and there is no need to encapsulate the message, which is more concise and has higher efficiency. The timer of each node connects the sending channel and the receiving channel to detect and capture the signal sent from the node transmitted by the sending channel, and detect and capture the signal received from the bus transmitted by the receiving channel. On the one hand, the moment when the signal is transmitted in the transceiver channel is closer to the real transceiver moment; on the other hand, the physical signal is detected by hardware such as a timer, and the moment obtained based on the count value of the timer can better reflect the real moment when the node sends and receives the signal, which is more accurate than the application layer to obtain the system time; on the other hand, the accuracy of the timer is positively correlated with the accuracy of the clock signal provided to the timer, so a high-precision clock signal can be input to the timer to ensure the accuracy of the transceiver moment obtained based on the count value of the timer. In addition, the timer is a general device in electronic devices and has a low cost. Therefore, the moment obtained based on the count value of the timer is highly accurate and precise. Furthermore, based on the high-precision and high-accuracy moment, a high-precision delay can be calculated.
[0129] After each slave node obtains the frequency offset and delay between itself and the master node, the slave node can synchronize time with the master node. Figure 4 As shown, Figure 4 A flowchart of a time synchronization method provided in this application.
[0130] S401: The master node sends a first preview frame to the bus, where the first preview frame carries a first time.
[0131] In this embodiment, the master node informs the slave node in advance of the sending time of the next notice frame sent by the master node through the notice frame. The first time is the time for sending the next notice frame predicted by the master node.
[0132] The first preview frame is a broadcast frame, and all slave nodes connected to the bus can receive the first preview frame and obtain the first time therefrom.
[0133] S402: Receive a first preview frame from a node, and obtain a first time from the first preview frame.
[0134] S403: The master node sends a second announcement frame to the bus at the first moment.
[0135] S404: The slave node receives a second notice frame, the second notice frame is used to trigger the first slave timer to record a first count value when passing through the slave receiving channel, and the first count value is used to calculate a second time when the first slave timer receives the second notice frame.
[0136] When a frame is transmitted in a transmission medium, there are also transition edges, such as rising edges and falling edges. Therefore, when the second notice frame passes through the slave receiving channel, it can also be captured by the first slave timer and trigger the recording of the first count value at that time. Then the slave node can calculate the second time when the slave node receives the second notice frame based on the first count value. The method of calculating the time based on the count value can be referred to the relevant description above, which will not be repeated here.
[0137] S405: The slave node performs time synchronization with the master node according to the first moment, the frequency deviation and the delay at the second moment.
[0138] Taking the master node time as a reference, the time when the slave node receives the second preview frame is the first time plus the delay. That is,
[0139] Tn abs =T Mn +d′ p2p
[0140] Among them, Tn abs is the time when the slave node receives the second preview frame with reference to the master node’s time, T Mn The first time when the master node sends the second preview frame, d′ p2p The delay between the master node and the slave node.
[0141] Therefore, for the time after the slave node receives the second preview frame, the time synchronized to the master node should be:
[0142] T abs S k =Tn abs +(T k S x -T k S y ) / FDR k
[0143] Among them, T abs S k is a certain moment after the slave node k is synchronized with the master node, T k S y is the second time obtained from node k (obtained from the clock of node k itself, which is a time that is not time synchronized), T k S x is a certain time after the slave node k receives the second preview frame (based on the clock of the slave node k itself, which is a time that is not time synchronized), FDR k is the frequency deviation of slave node k relative to the master node.
[0144] In this embodiment, by carrying the sending time of the next preview frame in the preview frame, and the preview frame itself can also trigger the timer of the slave node to record the count value when the preview frame is received, the master node does not need to send other additional messages to inform the slave node of the sending time of the preview frame, which can reduce the number of interactions and improve the efficiency of time synchronization. For example, the second preview frame can also carry the sending time of the next preview frame (the third preview frame). When the slave node receives the third preview frame, it can perform time synchronization based on the time of receiving the third preview frame and the sending time carried in the second preview frame. The third preview frame can also carry the sending time of the next preview frame (the fourth preview frame)... and so on.
[0145] Of course, in another implementation, time synchronization can also be performed in the following manner. Figure 5 As shown, Figure 5 A flowchart of another time synchronization method provided by the present application.
[0146] S501: the master node sends a fifth hopping signal to the bus via the main sending channel. The fifth hopping signal is used to trigger the first master timer to record the current count value when passing through the main sending channel. The count value is used to calculate the first time when the master node sends the fifth hopping signal.
[0147] S502: The slave node receives a fifth hopping signal, where the fifth hopping signal is used to trigger a first slave timer to record a current count value when passing through a slave receiving channel, where the count value is used to calculate a second time when the slave node receives the fifth hopping signal.
[0148] S503: The master node sends the first time to the bus.
[0149] S504: The slave node performs time synchronization with the master node according to the first time, the second time, the frequency offset and the delay.
[0150] In this embodiment, the timer of each node is connected to the sending channel and the receiving channel to detect and capture the signal transmitted from the node by the sending channel, and to detect and capture the signal received from the bus by the receiving channel. On the one hand, the moment when the signal is transmitted in the transceiver channel is closer to the real transceiver moment; on the other hand, the physical signal is detected by hardware such as the timer, and the moment obtained based on the count value of the timer can better reflect the real moment when the node transmits and receives the signal, which is more accurate than the application layer to obtain the system time; on the other hand, the accuracy of the timer is positively correlated with the accuracy of the clock signal provided to the timer, so a high-precision clock signal can be input to the timer to ensure the accuracy of the transceiver moment obtained based on the count value of the timer. In addition, the timer is a general-purpose device in electronic devices and has a low cost. Therefore, the moment obtained based on the count value of the timer is highly accurate and precise. Furthermore, based on the high-precision and high-accuracy moments, frequency deviations and delays, high-precision time synchronization can be performed.
[0151] Based on the same inventive concept, the present application also provides a device. Figure 6 As shown, Figure 6 A schematic diagram of the structure of a device provided in the present application. The device 600 includes a transceiver module 601 and a processing module 602. The device 600 can be a master node / slave node in the above-mentioned communication system, or a hardware unit or functional module in the master node / slave node. The above-mentioned hardware unit is, for example, a chip such as a microcontroller unit (MCU) or a system-on-chip (SoC). The communication system includes a master node and at least one slave node, the master node and at least one slave node are connected through a bus, the master node includes a first master timer, the first master timer connects the main sending channel between the master node and the bus, and the slave node includes a first slave timer, the first slave timer connects the slave receiving channel between the slave node and the bus. The device includes a transceiver module and a processing module.
[0152] When the device is applied to the master node, the transceiver module 601 is used to send a jump signal to the bus through the main sending channel. The jump signal is used to trigger the first master timer to record the current count value when passing through the main sending channel, and is used to trigger the first slave timer to record the current count value when passing through the slave receiving channel. The count value recorded by the first slave timer is used to calculate the receiving time when the slave node receives the jump signal. The processing module 602 is used to calculate the sending time when the device sends the jump signal according to the count value recorded by the first master timer. The transceiver module 601 is used to send the sending time to the bus, so that after the slave node obtains the sending time, it synchronizes time with the master node according to the sending time and the receiving time.
[0153] In one possible implementation, the sending time and the receiving time are used to calculate the frequency deviation or delay, the frequency deviation is the ratio of the frequency of the slave node to the frequency of the master node, and the delay is the length of time it takes for the signal to propagate between the master node and the slave node; the transceiver module 601 is used to send a first preview frame to the bus, the first preview frame carries a first time; the transceiver module 601 is used to send a second preview frame to the bus at a first time, the second preview frame is used to trigger the first slave timer to record a first count value when passing through the slave receiving channel, and the first count value is used to calculate the second time when the first slave timer receives the second preview frame, so that the slave node is synchronized with the master node based on the first time, the second time, the frequency deviation and the delay.
[0154] In one possible implementation, the jump signal includes a first jump signal and a second jump signal, the sending moment includes a third moment when the master node sends the first jump signal, and the receiving moment includes a fourth moment when the slave node receives the first jump signal; the sending moment includes a fifth moment when the master node sends the second jump signal, and the receiving moment includes a sixth moment when the slave node receives the second jump signal; the transceiver module 601 is used to send the third moment and the fifth moment to the bus, so that after the slave node obtains the third moment and the fifth moment, the frequency deviation of the slave node relative to the master node is calculated according to the third moment, the fourth moment, the fifth moment and the sixth moment.
[0155] In one possible implementation, the transceiver module 601 is used to send a first control signal to the bus before sending a jump signal to the bus, and the first control signal is used to instruct the slave node to configure the first slave timer to an input capture mode so that the first slave timer can be triggered by the edge of the signal received from the receiving channel to record the count value.
[0156] In a possible implementation, the jump signal includes a third jump signal, the sending moment includes the seventh moment when the master node sends the third jump signal, and the receiving moment includes the eighth moment when the slave node receives the third jump signal; the master node also includes a second master timer, the second master timer is connected to the main receiving channel between the master node and the bus, and the slave node also includes a second slave timer, the second slave timer is connected to the slave sending channel between the slave node and the bus: the transceiver module 601 is used to receive the fourth jump signal sent by the slave node to the bus through the main receiving channel, the fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel, and is used to trigger the second master timer to record the current count value when passing through the main receiving channel, the count value recorded by the second slave timer is used to calculate the ninth moment when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth moment when the master node receives the fourth jump signal; the transceiver module 601 is used to send the tenth moment to the bus, so that the slave node obtains the delay of the signal propagating between the master node and the slave node according to the seventh moment, the eighth moment, the ninth moment and the tenth moment.
[0157] In one possible implementation, the transceiver module 601 is used to send a second control signal to the bus before sending a jump signal to the bus, and the second control signal is used to instruct the slave node to configure the first slave timer to an input capture mode so that the first slave timer can be triggered by the edge of the signal received from the receiving channel to record the count value, and to configure the second slave timer to an output capture mode so that the second slave timer can be triggered by the edge of the signal sent from the sending channel to record the count value.
[0158] When the device is applied to a slave node, the transceiver module 601 is used to receive a jump signal sent by the master node to the bus through a slave receiving channel, the jump signal is used to trigger the first master timer to record the current count value when passing through the main sending channel, and is used to trigger the first slave timer to record the current count value when passing through the slave receiving channel, the count value recorded by the first master timer is used to calculate the sending time of the master node sending the jump signal, and the count value recorded by the first slave timer is used to calculate the receiving time of the slave node receiving the jump signal; the transceiver module 601 is used to receive the sending time sent by the master node to the bus; the processing module 602 is used to synchronize time with the master node according to the sending time and the receiving time.
[0159] In one possible implementation, the sending time and the receiving time are used to calculate the frequency deviation or delay, the frequency deviation is the ratio of the frequency of the slave node to the frequency of the master node, and the delay is the duration of the signal propagation between the master node and the slave node: the transceiver module 601 is used to receive the first preview frame sent by the master node to the bus, the first preview frame carries the first time, and the first time indicates the time when the master node sends the second preview frame; the transceiver module 601 is used to receive the second preview frame sent by the master node to the bus at the first time, the second preview frame is used to trigger the first slave timer to record the first count value when passing through the slave receiving channel, and the first count value is used to calculate the second time when the first slave timer receives the second preview frame; the processing module 602 is used to synchronize time with the master node according to the first time, the second time, the frequency deviation and the delay.
[0160] In one possible implementation, the jump signal includes a first jump signal and a second jump signal, the sending moment includes a third moment when the master node sends the first jump signal, and the receiving moment includes a fourth moment when the slave node receives the first jump signal; the sending moment includes a fifth moment when the master node sends the second jump signal, and the receiving moment includes a sixth moment when the slave node receives the second jump signal; the transceiver module 601 is specifically used to receive the third moment and the fifth moment sent by the master node to the bus; the processing module 602 is specifically used to calculate the frequency deviation of the slave node relative to the master node based on the third moment, the fourth moment, the fifth moment and the sixth moment.
[0161] In one possible implementation, the transceiver module 601 is used to receive a first control signal sent by the master node to the bus before receiving a jump signal sent by the master node through a slave receiving channel; the processing module 602 is used to configure the first slave timer to an input capture mode according to the first control signal, so that the first slave timer can be triggered by the edge of the signal received from the slave receiving channel to record the count value.
[0162] In a possible implementation, the jump signal includes a third jump signal, the sending moment includes the seventh moment when the master node sends the third jump signal, and the receiving moment includes the eighth moment when the slave node receives the third jump signal; the master node also includes a second master timer, the second master timer is connected to the main receiving channel between the master node and the bus, and the slave node also includes a second slave timer, the second slave timer is connected to the slave sending channel between the slave node and the bus; the transceiver module 601 is used to send a fourth jump signal to the bus through the slave sending channel, the fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel, and is used to trigger the second master timer to record the current count value when passing through the main receiving channel, the count value recorded by the second slave timer is used to calculate the ninth moment when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth moment when the master node receives the fourth jump signal; the transceiver module 601 is specifically used to receive the tenth moment when the master node sends the bus; the processing module 602 is specifically used to obtain the delay of the signal propagation between the master node and the slave node according to the seventh moment, the eighth moment, the ninth moment and the tenth moment.
[0163] In one possible implementation, the transceiver module 601 is used to receive a second control signal sent by the master node to the bus before receiving a jump signal sent by the master node through a slave receiving channel; the processing module 602 is used to configure the first slave timer to an input capture mode according to the second control signal, so that the first slave timer can be triggered by the edge of the signal received from the slave receiving channel to record the count value, and to configure the second slave timer to an output capture mode, so that the second slave timer can be triggered by the edge of the signal sent from the slave sending channel to record the count value.
[0164] like Figure 7 As shown, Figure 7 The electronic device 700 includes a processor 701 and a memory 702 , wherein the processor 701 is coupled to the memory 702 , and the processor 701 is configured to execute the time synchronization method in any embodiment based on the instructions stored in the memory 702 .
[0165] The present application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer, implements the steps of the time synchronization method of any of the above method embodiments.
[0166] The present application also provides a computer program product comprising instructions, which, when executed by an electronic device, enables the electronic device to execute the steps of the time synchronization method in any of the above embodiments.
[0167] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0168] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical or other forms.
[0169] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0170] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0171] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the technical solution of the present application can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A time synchronization method, characterized in that: The method is applied to a master node in a communication system, the communication system comprising the master node and at least one slave node, the master node and the at least one slave node being connected via a bus, the master node comprising a first master timer, the first master timer being connected to a master sending channel between the master node and the bus, the slave node comprising a first slave timer, the first slave timer being connected to a slave receiving channel between the slave node and the bus; The method comprises: The master node sends a jump signal to the bus through the master sending channel, the jump signal is used to trigger the first master timer to record the current count value when passing through the master sending channel, and is used to trigger the first slave timer to record the current count value when passing through the slave receiving channel, the count value recorded by the first master timer is used to calculate the sending time when the master node sends the jump signal, and the count value recorded by the first slave timer is used to calculate the receiving time when the slave node receives the jump signal; The master node sends the sending time to the bus, so that after the slave node obtains the sending time, it performs time synchronization with the master node according to the sending time and the receiving time.
2. The method according to claim 1, characterized in that The sending time and the receiving time are used to calculate the frequency deviation or delay, the frequency deviation is the ratio between the frequency of the slave node and the frequency of the master node, and the delay is the time length for the signal to propagate between the master node and the slave node, and the method further includes: The master node sends a first preview frame to the bus, where the first preview frame carries a first time; The master node sends a second preview frame to the bus at the first moment, and the second preview frame is used to trigger the first slave timer to record a first count value when passing through the slave receiving channel, and the first count value is used to calculate the second moment when the first slave timer receives the second preview frame, so that the slave node is time synchronized with the master node according to the first moment, the second moment, the frequency deviation and the delay.
3. The method according to claim 1 or 2, characterized in that: The hopping signal includes a first hopping signal and a second hopping signal, the sending time includes a third time when the master node sends the first hopping signal, and the receiving time includes a fourth time when the slave node receives the first hopping signal; the sending time includes a fifth time when the master node sends the second hopping signal, and the receiving time includes a sixth time when the slave node receives the second hopping signal; The master node sends the sending time to the bus, including: The master node sends the third moment and the fifth moment to the bus, so that after the slave node obtains the third moment and the fifth moment, it calculates the frequency deviation of the slave node relative to the master node according to the third moment, the fourth moment, the fifth moment and the sixth moment.
4. The method according to claim 3, characterized in that Before the master node sends a jump signal to the bus through the main sending channel, the method further includes: The master node sends a first control signal to the bus, where the first control signal is used to instruct the slave node to configure the first slave timer to an input capture mode so that the first slave timer can be triggered by an edge of a signal received by the slave receiving channel to record a count value.
5. The method according to any one of claims 1 to 4, characterized in that The hopping signal includes a third hopping signal, the sending time includes a seventh time when the master node sends the third hopping signal, and the receiving time includes an eighth time when the slave node receives the third hopping signal; the master node also includes a second master timer, and the second master timer is connected to a master receiving channel between the master node and the bus, and the slave node also includes a second slave timer, and the second slave timer is connected to a slave sending channel between the slave node and the bus, and the method also includes: The master node receives a fourth jump signal sent by the slave node to the bus through the master receiving channel, the fourth jump signal is used to trigger the second slave timer to record a current count value when passing through the slave sending channel, and is used to trigger the second master timer to record a current count value when passing through the master receiving channel, the count value recorded by the second slave timer is used to calculate a ninth time when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate a tenth time when the master node receives the fourth jump signal; The master node sends the tenth time to the bus, so that the slave node obtains the delay of the signal propagating between the master node and the slave node according to the seventh time, the eighth time, the ninth time and the tenth time.
6. The method according to claim 5, characterized in that Before the master node sends a jump signal to the bus through the main sending channel, the method further includes: The master node sends a second control signal to the bus, and the second control signal is used to instruct the slave node to configure the first slave timer to an input capture mode so that the first slave timer can be triggered by the edge of the signal received by the slave receiving channel to record the count value, and to configure the second slave timer to an output capture mode so that the second slave timer can be triggered by the edge of the signal sent by the slave sending channel to record the count value.
7. A time synchronization method, characterized in that: The method is applied to a slave node in a communication system, wherein the communication system comprises the master node and at least one slave node, the master node and the at least one slave node are connected via a bus, the master node comprises a first master timer, the first master timer is connected to a master sending channel between the master node and the bus, and the slave node comprises a first slave timer, the first slave timer is connected to a slave receiving channel between the slave node and the bus; The method comprises: The slave node receives a jump signal sent by the master node to the bus through the slave receiving channel, the jump signal is used to trigger the first master timer to record a current count value when passing through the master sending channel, and is used to trigger the first slave timer to record a current count value when passing through the slave receiving channel, the count value recorded by the first master timer is used to calculate a sending time when the master node sends the jump signal, and the count value recorded by the first slave timer is used to calculate a receiving time when the slave node receives the jump signal; The slave node receives the sending time sent by the master node to the bus; The slave node performs time synchronization with the master node according to the sending time and the receiving time.
8. The method according to claim 7, characterized in that The sending time and the receiving time are used to calculate the frequency deviation or delay, the frequency deviation is the ratio between the frequency of the slave node and the frequency of the master node, and the delay is the time length for the signal to propagate between the master node and the slave node, and the method further includes: The slave node receives a first preview frame sent by the master node to the bus, where the first preview frame carries a first time, and the first time indicates a time when the master node sends a second preview frame; The slave node receives the second notice frame sent by the master node to the bus at the first time, the second notice frame is used to trigger the first slave timer to record a first count value when passing through the slave receiving channel, and the first count value is used to calculate a second time when the first slave timer receives the second notice frame; The slave node performs time synchronization with the master node according to the first time, the second time, the frequency offset and the time delay.
9. The method according to claim 7 or 8, characterized in that: The hopping signal includes a first hopping signal and a second hopping signal, the sending time includes a third time when the master node sends the first hopping signal, and the receiving time includes a fourth time when the slave node receives the first hopping signal; the sending time includes a fifth time when the master node sends the second hopping signal, and the receiving time includes a sixth time when the slave node receives the second hopping signal; The slave node receives the sending time sent by the master node to the bus, including: The slave node receives the third time and the fifth time sent by the master node to the bus; The slave node performing time synchronization with the master node according to the sending time and the receiving time includes: The slave node calculates the frequency deviation of the slave node relative to the master node according to the third moment, the fourth moment, the fifth moment and the sixth moment.
10. The method according to claim 9, characterized in that Before the slave node receives the jump signal sent by the master node to the bus through the slave receiving channel, the method further includes: The slave node receives a first control signal sent by the master node to the bus; The slave node configures the first slave timer to an input capture mode according to the first control signal, so that the first slave timer can be triggered by an edge of a signal received by the slave receiving channel to record a count value.
11. The method according to any one of claims 7 to 10, characterized in that The hopping signal includes a third hopping signal, the sending time includes a seventh time when the master node sends the third hopping signal, and the receiving time includes an eighth time when the slave node receives the third hopping signal; the master node also includes a second master timer, and the second master timer is connected to a master receiving channel between the master node and the bus, and the slave node also includes a second slave timer, and the second slave timer is connected to a slave sending channel between the slave node and the bus, and the method also includes: The slave node sends a fourth jump signal to the bus through the slave sending channel, the fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel, and is used to trigger the second master timer to record the current count value when passing through the master receiving channel, the count value recorded by the second slave timer is used to calculate the ninth time when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth time when the master node receives the fourth jump signal; The slave node receives the sending time sent by the master node to the bus, including: The slave node receives the tenth time sent by the master node to the bus; The slave node performing time synchronization with the master node according to the sending time and the receiving time includes: The slave node obtains the time delay of the signal propagating between the master node and the slave node according to the seventh moment, the eighth moment, the ninth moment and the tenth moment.
12. The method according to claim 11, characterized in that Before the slave node receives the jump signal sent by the master node to the bus through the slave receiving channel, the method further includes: The slave node receives a second control signal sent by the master node to the bus; The slave node configures the first slave timer to an input capture mode according to the second control signal so that the first slave timer can be triggered by the edge of the signal received by the slave receiving channel to record the count value, and configures the second slave timer to an output capture mode so that the second slave timer can be triggered by the edge of the signal sent by the slave sending channel to record the count value.
13. A device, characterized in that: The device is applied to a master node in a communication system, the communication system comprising the master node and at least one slave node, the master node and the at least one slave node being connected via a bus, the master node comprising a first master timer, the first master timer being connected to a master sending channel between the master node and the bus, the slave node comprising a first slave timer, the first slave timer being connected to a slave receiving channel between the slave node and the bus; The device comprises: a transceiver module, configured to send a jump signal to the bus through the master sending channel, wherein the jump signal is used to trigger the first master timer to record a current count value when passing through the master sending channel, and is used to trigger the first slave timer to record a current count value when passing through the slave receiving channel, wherein the count value recorded by the first slave timer is used to calculate a receiving time when the slave node receives the jump signal; a processing module, configured to calculate a sending time of the jump signal sent by the device according to the count value recorded by the first main timer; The transceiver module is used to send the sending time to the bus, so that after the slave node obtains the sending time, it performs time synchronization with the master node according to the sending time and the receiving time.
14. The device according to claim 13, characterized in that The sending time and the receiving time are used to calculate the frequency deviation or delay, the frequency deviation is the ratio between the frequency of the slave node and the frequency of the master node, and the delay is the time length for the signal to propagate between the master node and the slave node; The transceiver module is used to send a first notice frame to the bus, where the first notice frame carries a first time; The transceiver module is used to send a second notice frame to the bus at the first moment, the second notice frame is used to trigger the first slave timer to record a first count value when passing through the slave receiving channel, and the first count value is used to calculate the second moment when the first slave timer receives the second notice frame, so that the slave node is time synchronized with the master node according to the first moment, the second moment, the frequency deviation and the delay.
15. The device according to claim 13 or 14, characterized in that The hopping signal includes a first hopping signal and a second hopping signal, the sending time includes a third time when the master node sends the first hopping signal, and the receiving time includes a fourth time when the slave node receives the first hopping signal; the sending time includes a fifth time when the master node sends the second hopping signal, and the receiving time includes a sixth time when the slave node receives the second hopping signal; The transceiver module is used to send the third moment and the fifth moment to the bus, so that after the slave node obtains the third moment and the fifth moment, it calculates the frequency deviation of the slave node relative to the master node according to the third moment, the fourth moment, the fifth moment and the sixth moment.
16. The device according to claim 15, characterized in that The transceiver module is used to send a first control signal to the bus before sending a jump signal to the bus, and the first control signal is used to instruct the slave node to configure the first slave timer to an input capture mode so that the first slave timer can be triggered by the edge of the signal received by the slave receiving channel to record the count value.
17. The device according to any one of claims 13 to 16, characterized in that The hopping signal includes a third hopping signal, the sending time includes a seventh time when the master node sends the third hopping signal, and the receiving time includes an eighth time when the slave node receives the third hopping signal; the master node also includes a second master timer, and the second master timer is connected to a master receiving channel between the master node and the bus, and the slave node also includes a second slave timer, and the second slave timer is connected to a slave sending channel between the slave node and the bus: The transceiver module is used to receive a fourth jump signal sent by the slave node to the bus through the master receiving channel, the fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel, and is used to trigger the second master timer to record the current count value when passing through the master receiving channel, the count value recorded by the second slave timer is used to calculate the ninth time when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth time when the master node receives the fourth jump signal; The transceiver module is used to send the tenth moment to the bus, so that the slave node obtains the delay of the signal propagating between the master node and the slave node according to the seventh moment, the eighth moment, the ninth moment and the tenth moment.
18. The device according to claim 17, characterized in that The transceiver module is used to send a second control signal to the bus before sending a jump signal to the bus, and the second control signal is used to instruct the slave node to configure the first slave timer to an input capture mode so that the first slave timer can be triggered by the edge of the signal received by the slave receiving channel to record the count value, and to configure the second slave timer to an output capture mode so that the second slave timer can be triggered by the edge of the signal sent by the slave sending channel to record the count value.
19. A device, characterized in that: The device is applied to a slave node in a communication system, wherein the communication system comprises the master node and at least one slave node, the master node and the at least one slave node are connected via a bus, the master node comprises a first master timer, the first master timer is connected to a master sending channel between the master node and the bus, and the slave node comprises a first slave timer, the first slave timer is connected to a slave receiving channel between the slave node and the bus; The device comprises: a transceiver module, configured to receive, through the slave receiving channel, a jump signal sent by the master node to the bus, the jump signal being used to trigger the first master timer to record a current count value when passing through the master sending channel, and being used to trigger the first slave timer to record a current count value when passing through the slave receiving channel, the count value recorded by the first master timer being used to calculate a sending time when the master node sends the jump signal, and the count value recorded by the first slave timer being used to calculate a receiving time when the slave node receives the jump signal; The transceiver module is used to receive the sending time sent by the master node to the bus; A processing module is used to perform time synchronization with the master node according to the sending time and the receiving time.
20. The device according to claim 19, characterized in that The sending time and the receiving time are used to calculate the frequency deviation or delay, the frequency deviation is the ratio between the frequency of the slave node and the frequency of the master node, and the delay is the time length for the signal to propagate between the master node and the slave node: The transceiver module is used to receive a first notice frame sent by the master node to the bus, the first notice frame carries a first time, and the first time indicates a time when the master node sends a second notice frame; The transceiver module is used to receive the second notice frame sent by the master node to the bus at the first time, the second notice frame is used to trigger the first slave timer to record a first count value when passing through the slave receiving channel, and the first count value is used to calculate a second time when the first slave timer receives the second notice frame; The processing module is used to perform time synchronization with the master node according to the first moment, the second moment, the frequency offset and the time delay.
21. The device according to claim 19 or 20, characterized in that The hopping signal includes a first hopping signal and a second hopping signal, the sending time includes a third time when the master node sends the first hopping signal, and the receiving time includes a fourth time when the slave node receives the first hopping signal; the sending time includes a fifth time when the master node sends the second hopping signal, and the receiving time includes a sixth time when the slave node receives the second hopping signal; The transceiver module is specifically used to receive the third moment and the fifth moment sent by the master node to the bus; The processing module is specifically used to calculate the frequency deviation of the slave node relative to the master node according to the third moment, the fourth moment, the fifth moment and the sixth moment.
22. The device according to claim 21, characterized in that The transceiver module is used to receive a first control signal sent by the master node to the bus before receiving the jump signal sent by the master node through the slave receiving channel; The processing module is used to configure the first slave timer to an input capture mode according to the first control signal, so that the first slave timer can be triggered by an edge of a signal received by the slave receiving channel to record a count value.
23. The device according to any one of claims 13 to 22, characterized in that The hopping signal includes a third hopping signal, the sending time includes a seventh time when the master node sends the third hopping signal, and the receiving time includes an eighth time when the slave node receives the third hopping signal; the master node also includes a second master timer, the second master timer is connected to a master receiving channel between the master node and the bus, and the slave node also includes a second slave timer, the second slave timer is connected to a slave sending channel between the slave node and the bus; The transceiver module is used to send a fourth jump signal to the bus through the slave sending channel, the fourth jump signal is used to trigger the second slave timer to record the current count value when passing through the slave sending channel, and is used to trigger the second master timer to record the current count value when passing through the master receiving channel, the count value recorded by the second slave timer is used to calculate the ninth time when the slave node sends the fourth jump signal, and the count value recorded by the second master timer is used to calculate the tenth time when the master node receives the fourth jump signal; The transceiver module is specifically used to receive the tenth moment sent by the master node to the bus; The processing module is specifically used to obtain the delay of the signal propagating between the master node and the slave node according to the seventh moment, the eighth moment, the ninth moment and the tenth moment.
24. The device according to claim 23, characterized in that The transceiver module is used to receive a second control signal sent by the master node to the bus before receiving the jump signal sent by the master node through the slave receiving channel; The processing module is used to configure the first slave timer to an input capture mode according to the second control signal, so that the first slave timer can be triggered by the edge of the signal received by the slave receiving channel to record the count value, and to configure the second slave timer to an output capture mode, so that the second slave timer can be triggered by the edge of the signal sent by the slave sending channel to record the count value.
25. A communication system, characterized in that: The system comprises a bus, and the device according to any one of claims 13 to 18 connected to the bus, and the device according to any one of claims 19 to 24 connected to the bus.
26. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the processor is coupled to the memory, and the processor is configured to execute the time synchronization method according to any one of claims 1 to 12 based on instructions stored in the memory.
Citation Information
Cited By
Timestamp synchronization method and device
CN120415621A
