Sensor time synchronization method and system in a local area network
By connecting the domain controller to the sensor's I/O ports and processing time synchronization messages, the problem of insufficient timestamp accuracy in multi-sensor systems is solved, achieving microsecond-level time synchronization and improving the accuracy of data fusion and judgment.
Patent Information
- Application Number
- CN202510503284.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2045-04-22
AI Technical Summary
In multi-sensor systems, existing technologies cannot achieve accurate fusion and joint judgment of data from multiple sensors at the same time, resulting in insufficient timestamp accuracy and the inability to achieve accurate data synchronization.
The domain controller controls the I/O port to output a preset level and sends a time synchronization message to the sensor. The sensor records the timestamp and calculates the time compensation value to achieve sensor time synchronization and reduce the time error to the microsecond level.
It improves the timestamp accuracy of sensor data, enables accurate fusion and joint judgment of multi-sensor data, and is easy to deploy and implement.
Smart Images

Figure CN120049992B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic digital data processing, and more particularly to a sensor time synchronization method and system in a local area network. Background Technology
[0002] Currently, advanced driver assistance systems (ADAS) rely on multiple sensors to perceive the surrounding environment and make safe driving decisions. Time synchronization is a prerequisite for multi-sensor data fusion. In complex multi-sensor systems, each sensor may operate according to its own clock reference and have different sampling frequencies. This can lead to asynchronous sampling data, affecting the accuracy and effectiveness of data fusion. Time synchronization can unify data from different sensors to the same timestamp, thereby achieving precise data fusion and providing strong support for subsequent decision-making and analysis.
[0003] In related technologies, most sensor systems are time-calibrated through gateways. However, network congestion often results in non-fixed delays at the millisecond level. Consequently, the time error between sensors is at the millisecond level. When multiple sensors need to collect data at the same time simultaneously, the timestamp accuracy of the data is insufficient, making it impossible to achieve accurate data fusion and joint judgment at the same moment. Summary of the Invention
[0004] This application provides a sensor time synchronization method and system in a local area network, which solves the problem in the prior art that when multiple sensors need to collect data at the same time, the timestamp accuracy of the data is insufficient, making it impossible to achieve accurate data fusion and joint judgment at the same time. It can reduce the time error to the microsecond level, improve the time accuracy, and the hardware deployment is simple and highly feasible.
[0005] In a first aspect, this application provides a sensor time synchronization method in a local area network (LAN), applied to a LAN system, the LAN system including a domain controller and multiple sensors, the domain controller being connected to each of the sensors via control lines, the method comprising:
[0006] When sensor time synchronization is triggered, the domain controller controls the I / O port to output a first preset level and transmits it to each of the sensors, and sends a time synchronization message to each of the sensors. The time synchronization message includes the local time of the domain controller.
[0007] When each of the sensors detects the first preset level, the first timestamp corresponding to the current time is recorded;
[0008] When each of the sensors receives the time synchronization message, a second timestamp corresponding to the current time is recorded, and a time compensation value is calculated based on the second timestamp and the first timestamp.
[0009] Each of the sensors adds its corresponding time compensation value to the local time to obtain the system time after time synchronization.
[0010] Optionally, after each of the sensors adds its corresponding time compensation value to the local time to obtain the synchronized system time, the method further includes:
[0011] Each of the sensors sends a response message to the domain controller;
[0012] After receiving the response messages sent by each of the sensors, the domain controller controls the I / O port to output a second preset level to end the sensor time synchronization. The second preset level is a different rising and falling edge level than the first preset level.
[0013] Optionally, prior to triggering sensor time synchronization, the method further includes:
[0014] The domain controller controls the I / O port to output the second preset level and transmit it to each of the sensors.
[0015] Optionally, calculating the time compensation value based on the second timestamp and the first timestamp includes:
[0016] The difference between the second timestamp and the first timestamp is determined as the time compensation value.
[0017] Optionally, calculating the time compensation value based on the second timestamp and the first timestamp includes:
[0018] The difference between the first timestamp and the second timestamp is calculated, and the difference is superimposed with a pre-stored correction coefficient to obtain a time compensation value. The pre-stored correction coefficient is the sum of the inherent delays inside the sensor.
[0019] Optionally, after recording the first timestamp corresponding to the current time, the method further includes:
[0020] If the time synchronization message is not received within the preset time window, the first timestamp is deleted, and a timeout message is sent to the domain controller, so that the domain controller can re-control the level of the I / O port and resend the time synchronization message.
[0021] Optionally, after each of the sensors sends a response message to the domain controller, the method further includes:
[0022] If the domain controller does not receive response messages from each of the sensors, it will re-control the level of the I / O port and resend the time synchronization message.
[0023] Secondly, this application also provides a sensor time synchronization system in a local area network, including a domain controller and multiple sensors:
[0024] The domain controller is configured to, upon triggering sensor time synchronization, control the I / O port to output a first preset level and transmit it to each of the sensors, and to send a time synchronization message to each of the sensors, wherein the time synchronization message includes the local time of the domain controller;
[0025] Each of the sensors is configured to record a first timestamp corresponding to the current time when the first preset level is detected, and to record a second timestamp corresponding to the current time when the time synchronization message is received. The sensors are configured to calculate a time compensation value based on the second timestamp and the first timestamp, and to add the corresponding time compensation value to the local time to obtain the synchronized system time.
[0026] Thirdly, this application also provides a sensor time synchronization device in a local area network, the device comprising:
[0027] One or more processors;
[0028] Storage device for storing one or more programs.
[0029] When the one or more programs are executed by the one or more processors, the one or more processors implement the sensor time synchronization method in the local area network described in this application.
[0030] Fourthly, this application also provides a storage medium for storing computer-executable instructions, which, when executed by a computer processor, are used to perform the sensor time synchronization method in a local area network described in this application.
[0031] In this application, upon triggering sensor time synchronization, the domain controller controls the I / O port to output a first preset level, which is transmitted to each sensor. It also sends a time synchronization message to each sensor, including the domain controller's local time. When each sensor detects the first preset level, it records a first timestamp corresponding to the current time. When each sensor receives the time synchronization message, it records a second timestamp corresponding to the current time. A time compensation value is calculated based on the second and first timestamps. Each sensor adds its corresponding time compensation value to its local time to obtain the synchronized system time. This solution connects the domain controller and each sensor via control lines to achieve sensor time synchronization. It solves the problem in existing technologies where, when multiple sensors need to collect data at the same time, the timestamp accuracy is insufficient, making accurate data fusion and joint judgment impossible. It can reduce time errors to the microsecond level, improving time accuracy, and is easy to deploy and highly feasible. Attached Figure Description
[0032] Figure 1 A flowchart illustrating a sensor time synchronization method in a local area network provided in this application embodiment;
[0033] Figure 2 A flowchart of a sensor time synchronization method in a local area network that includes terminating sensor time synchronization is provided as an embodiment of this application;
[0034] Figure 3 A schematic diagram illustrating the timing of I / O port level changes provided in an embodiment of this application;
[0035] Figure 4 A flowchart illustrating a sensor time synchronization method in a local area network that includes calculating time compensation values, provided as an embodiment of this application;
[0036] Figure 5 A flowchart of another sensor time synchronization method in a local area network that includes calculating time compensation values, provided as an embodiment of this application;
[0037] Figure 6 A flowchart illustrating a sensor time synchronization method in a local area network that includes sending timeout messages, provided as an embodiment of this application;
[0038] Figure 7 A block diagram of a sensor time synchronization system in a local area network provided in this application embodiment;
[0039] Figure 8 This is a schematic diagram of a sensor time synchronization device in a local area network provided in an embodiment of this application. Detailed Implementation
[0040] The embodiments of this application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the embodiments of this application and are not intended to limit the scope of the embodiments. Furthermore, it should be noted that, for ease of description, only the parts relevant to the embodiments of this application are shown in the accompanying drawings, not the entire structure.
[0041] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0042] This application provides a sensor time synchronization method in a local area network, which can be applied to assisted driving scenarios such as intelligent driving vehicles, drones, and robots. In this sensor time synchronization method in a local area network, the execution entity for each step is a domain controller or a sensor.
[0043] Figure 1 A flowchart of a sensor time synchronization method in a local area network provided in this application embodiment is shown below. Figure 1 As shown, it specifically includes:
[0044] Step S101: When the sensor time synchronization is triggered, the domain controller controls the IO port to output a first preset level and transmits it to each sensor, and sends a time synchronization message to each sensor. The time synchronization message includes the local time of the domain controller.
[0045] The domain controller is responsible for collecting data from various sensors, processing and fusing it, and outputting the results. It connects to each sensor via control lines. When sensor time synchronization is triggered, the domain controller can control its I / O ports to output a first preset level and transmit it to each sensor, as well as send a time synchronization message. The I / O ports are input / output interfaces used for information exchange between the domain controller and the sensors. Sensor time synchronization can be triggered during initialization (system startup / sensor wake-up), in dynamic environments (real-time performance assurance under high-speed / complex road conditions), and during fault recovery (clock source switching / sensor restart). The first preset level represents the pre-set level state that the I / O port must switch to when sensor time synchronization is triggered; it can be either a low or high level. The time synchronization message is used to synchronize the clocks of each sensor in the network. This message is sent synchronously when the domain controller controls the I / O ports to output the first preset level, and it includes the domain controller's local time. The local time can be the time corresponding to when the domain controller controls the I / O ports to output the first preset level. For example, the first preset level is low level, and the current stage is the initialization stage. The sensor time synchronization is triggered. The domain controller controls the IO port to output a low level and transmits it to each sensor. When the domain controller controls the IO port to output a low level, the local time is 12:00. Then, a time synchronization message containing the local time is generated and sent to each sensor.
[0046] Step S102: When each sensor detects the first preset level, record the first timestamp corresponding to the current time; when each sensor receives the time synchronization message, record the second timestamp corresponding to the current time.
[0047] In this system, the first preset level is transmitted via the control line, while the time synchronization message is transmitted via the local area network (LAN). The physical transmission delay of the control line is much lower than the processing delay of the LAN, which can be accurate to the microsecond level. However, data is sent in byte form within the LAN, and the LAN is subject to congestion and other issues. Therefore, each sensor receives the time synchronization message after detecting the first preset level, meaning the second timestamp is greater than the first timestamp. A timestamp is a data format representing a specific point in time. For example, after the domain controller outputs a low level (first preset level) to the I / O port and sends a time synchronization message to each sensor, sensor A detects the low level at 12:00.000001 and records the timestamp corresponding to 12:00.000001. Sensor A receives the time synchronization message at 12:00.0002 and records the timestamp corresponding to 12:00.0002.
[0048] In one embodiment, after each sensor detects a first preset level, if other non-real-time tasks exist, the non-real-time tasks are paused, and the system time calibration task of the sensors is performed first.
[0049] Step S103: Calculate the time compensation value based on the second timestamp and the first timestamp. Each sensor adds its corresponding time compensation value to the local time of the domain controller in the time synchronization message to obtain the synchronized system time.
[0050] The time compensation value can be the time consumed when the time synchronization message is transmitted to the sensor via the local area network. This time compensation value can be calculated using the second timestamp and the first timestamp. Adding this time compensation value to the local time yields the system time after sensor synchronization. For example, sensor a calculates a time compensation value of 0.000199 seconds based on the second and first timestamps. The local time of the domain controller in the time synchronization message is 12:00. Adding the local time of the domain controller in the time synchronization message to this time compensation value gives the system time of sensor a after synchronization as 12:00.000199.
[0051] As described above, when sensor time synchronization is triggered, the domain controller controls the I / O port to output a first preset level, which is transmitted to each sensor. It also sends a time synchronization message to each sensor. The time synchronization message includes the domain controller's local time. When each sensor detects the first preset level, it records the first timestamp corresponding to the current time. When each sensor receives the time synchronization message, it records the second timestamp corresponding to the current time. A time compensation value is calculated based on the second and first timestamps. Each sensor adds its corresponding time compensation value to its local time to obtain the synchronized system time. This solution connects the domain controller and each sensor via control lines to achieve sensor time synchronization. It solves the problem in existing technologies where the timestamp accuracy of data is insufficient when multiple sensors need to collect data at the same time, making accurate data fusion and joint judgment impossible. It can reduce time errors to the microsecond level, improve time accuracy, and is easy to deploy and highly feasible.
[0052] Figure 2 A flowchart illustrating a sensor time synchronization method in a local area network that includes terminating sensor time synchronization, provided as an embodiment of this application, is shown below. Figure 2 As shown, it specifically includes:
[0053] Step S201: When the sensor time synchronization is triggered, the domain controller controls the I / O port to output a first preset level and transmits it to each sensor, and sends a time synchronization message to each sensor. The time synchronization message includes the local time of the domain controller.
[0054] Step S202: When each sensor detects the first preset level, record the first timestamp corresponding to the current time; when each sensor receives the time synchronization message, record the second timestamp corresponding to the current time.
[0055] Step S203: Calculate the time compensation value based on the second timestamp and the first timestamp. Each sensor adds its corresponding time compensation value to the local time of the domain controller in the time synchronization message to obtain the synchronized system time.
[0056] Step S204: Each sensor sends a response message to the domain controller. After receiving the response messages sent by each sensor, the domain controller controls the IO port to output a second preset level to end the sensor time synchronization. The second preset level is different from the first preset level in terms of rising and falling edge levels.
[0057] The response message is sent by the sensor after completing time synchronization, used to provide feedback to the domain controller on the sensor's time synchronization status. This response message can instruct the domain controller to output a second preset level through its I / O ports to end sensor time synchronization. The second preset level is a level different from the first preset level; for example, if the first preset level is low, the second preset level is high. Optionally, before triggering sensor time synchronization, the domain controller outputs the second preset level through its I / O ports to each sensor. For example, as shown... Figure 3 As shown, Figure 3 This is a schematic diagram of the timing of IO port level changes provided in an embodiment of this application. T0 is the moment when the domain controller pulls the level low and sends a time synchronization message. At this moment T0, the sensor synchronously detects the low level and records the corresponding timestamp. Before the moment T0, the domain controller controls the IO port to output a high level and transmit it to each sensor. T1 is the moment when the sensor receives the time synchronization message and performs time synchronization. Between T0 and T2, the IO port is always in a low level state. T2 is the moment when the domain controller receives the response message sent by each sensor and controls the IO port to return to a high level state.
[0058] Optionally, after each sensor sends an acknowledgment message to the domain controller, if the domain controller does not receive an acknowledgment message from any of the sensors, the I / O port level is readjusted and the time synchronization message is retransmitted. In another embodiment, after each sensor sends an acknowledgment message to the domain controller, if the domain controller does not receive an acknowledgment message from any one or more sensors, the I / O port level is readjusted and the time synchronization message is retransmitted.
[0059] As described above, after each sensor adds its corresponding time compensation value to the local time of the domain controller in the time synchronization message to obtain the synchronized system time, each sensor sends a response message to the domain controller. Upon receiving the response messages from each sensor, the domain controller controls the I / O port to output a second preset level to terminate the sensor time synchronization. The second preset level differs from the first preset level in terms of rising and falling edge levels. This scheme achieves sensor time synchronization by controlling the level state of the I / O port, reducing time errors to the microsecond level.
[0060] Figure 4 A flowchart illustrating a sensor time synchronization method in a local area network that includes calculating time compensation values, provided in an embodiment of this application, is shown below. Figure 4 As shown, it specifically includes:
[0061] Step S301: When the sensor time synchronization is triggered, the domain controller controls the IO port to output a first preset level and transmits it to each sensor, and sends a time synchronization message to each sensor. The time synchronization message includes the local time of the domain controller.
[0062] Step S302: When each sensor detects the first preset level, record the first timestamp corresponding to the current time; when each sensor receives the time synchronization message, record the second timestamp corresponding to the current time.
[0063] Step S303: The difference between the second timestamp and the first timestamp is determined as the time compensation value. Each sensor adds its corresponding time compensation value to the local time of the domain controller in the time synchronization message to obtain the system time after synchronization.
[0064] The first timestamp is the timestamp corresponding to the time when the sensor detects the first preset level. Since the physical transmission delay of the control line can be accurate to the microsecond level, this first timestamp can be equivalent to the timestamp corresponding to the time when the domain controller controls the I / O port to output the first preset level. When the domain controller controls the I / O port to output the first preset level, it immediately sends a time synchronization message. That is, the time when the domain controller sends the time synchronization message is the same as the time when it controls the I / O port to output the first preset level. This first timestamp can be equivalent to the time when the domain controller sends the time synchronization message. The difference between the second timestamp corresponding to the time when the sensor receives the time synchronization message and the first timestamp can be used to obtain the transmission time of the time synchronization message, i.e., the time compensation value. For example, the first timestamp of sensor a is the timestamp corresponding to 12:00.000001, and the second timestamp is the timestamp corresponding to 12:00.0002. The calculated difference between the second timestamp and the first timestamp is 0.000199 seconds. Therefore, the time compensation value for sensor a is 0.000199 seconds.
[0065] As described above, after recording the first and second timestamps, the difference between the second and first timestamps is determined as the time compensation value. Each sensor adds its corresponding time compensation value to the local time of the domain controller in the time synchronization message to obtain the synchronized system time. This scheme uses the difference between the second and first timestamps as the time compensation value, which can determine the time used for transmitting the time synchronization message.
[0066] Figure 5 A flowchart of another sensor time synchronization method in a local area network, including calculating time compensation values, provided in an embodiment of this application is shown below. Figure 5 As shown, it specifically includes:
[0067] Step S401: When the sensor time synchronization is triggered, the domain controller controls the IO port to output a first preset level and transmits it to each sensor, and sends a time synchronization message to each sensor. The time synchronization message includes the local time of the domain controller.
[0068] Step S402: When each sensor detects the first preset level, record the first timestamp corresponding to the current time; when each sensor receives the time synchronization message, record the second timestamp corresponding to the current time.
[0069] Step S403: Calculate the difference between the first timestamp and the second timestamp, and add the difference to the pre-stored correction coefficient to obtain the time compensation value. Each sensor adds its corresponding time compensation value to the local time of the domain controller in the time synchronization message to obtain the system time after time synchronization. The pre-stored correction coefficient is the sum of the inherent delays inside the sensor.
[0070] The pre-stored correction coefficient represents the sum of inherent delays within the sensor. These inherent delays can be fixed characteristics of the sensor itself, such as hardware response delay, interrupt handling delay, and communication parsing delay. Specifically, the hardware response delay is the response time of the sensor's hardware circuit when it detects a change in the I / O port level; the interrupt handling delay is the software processing time required for the sensor firmware to trigger an interrupt and record a timestamp after detecting a change in the I / O port level; and the communication parsing delay is the processing time required for the sensor to parse the content of the time synchronization message after receiving it. This pre-stored correction coefficient can be used to correct the difference between the first and second timestamps, making it closer to the true value. For example, if sensor a has a hardware response delay of 1 microsecond, an interrupt handling delay of 2 microseconds, and a communication parsing delay of 5 microseconds, then the sum of inherent delays within sensor a, i.e., the pre-stored correction coefficient, is 8 microseconds. The calculated difference between the first and second timestamps of sensor a is 199 microseconds. Adding this difference to the pre-stored correction coefficient yields a time compensation value of 207 microseconds.
[0071] As described above, after recording the first and second timestamps, the difference between the first and second timestamps is calculated. This difference is then added to a pre-stored correction coefficient to obtain the time compensation value. Each sensor adds its corresponding time compensation value to the local time of the domain controller in the time synchronization message to obtain the calibrated system time. The pre-stored correction coefficient represents the sum of the inherent delays within the sensors. This scheme improves the accuracy of the time compensation value by correcting the difference between the second and first timestamps using stored correction coefficients, making the calibrated system time closer to the true value.
[0072] Figure 6 A flowchart illustrating a sensor time synchronization method in a local area network that includes sending timeout messages, provided as an embodiment of this application, is shown below. Figure 6 As shown, it specifically includes:
[0073] Step S501: When the sensor time synchronization is triggered, the domain controller controls the IO port to output a first preset level and transmits it to each sensor, and sends a time synchronization message to each sensor. The time synchronization message includes the local time of the domain controller.
[0074] Step S502: When each sensor detects the first preset level, record the first timestamp corresponding to the current time. If no time synchronization message is received within the preset time window, delete the first timestamp and send an overdue message to the domain controller. This is used by the domain controller to re-control the level of the IO port and resend the time synchronization message.
[0075] The preset time window is a pre-set maximum allowable waiting time from when the sensor detects the first preset level until it receives the time synchronization message, preventing system congestion caused by indefinite waiting. This preset time window can be dynamically set according to network latency, clock accuracy, and system real-time requirements. If the sensor does not receive the time synchronization message from the domain controller within this preset time window, it deletes the first timestamp recorded when it detected the first preset level and sends a timeout message to the domain controller. Upon receiving this timeout message, the domain controller re-controls the I / O port level and resends the time synchronization message to each sensor. For example, with a preset time window of 50ms, after the sensor detects the first preset level and records the first timestamp corresponding to the current time, it waits for the time synchronization message from the domain controller. If it still does not receive the time synchronization message after 50ms, the sensor deletes the recorded first timestamp and sends a timeout message to the domain controller, causing the domain controller to re-control the I / O port level and resend the time synchronization message.
[0076] Step S503: When each sensor receives a time synchronization message, it records the second timestamp corresponding to the current time, calculates the time compensation value based on the second timestamp and the first timestamp, and adds the corresponding time compensation value to the local time of the domain controller in the time synchronization message to obtain the system time after synchronization.
[0077] As described above, when each sensor detects the first preset level, it records the first timestamp corresponding to the current time. If no time synchronization message is received within the preset time window, the first timestamp is deleted, and a timeout message is sent to the domain controller. This is used by the domain controller to re-control the I / O port level and resend the time synchronization message. This solution, by setting a reasonable time window for waiting for the time synchronization message, can prevent system blocking caused by infinite waiting.
[0078] Figure 7 This is a block diagram of a sensor time synchronization system in a local area network (LAN) provided in an embodiment of this application. This system is used to execute a sensor time synchronization method in a LAN provided in the above embodiment, and has corresponding functional modules and beneficial effects for executing the method. Figure 7 As shown, the system specifically includes a domain controller 101 and multiple sensors 102:
[0079] The domain controller 101 is used to control the I / O port to output a first preset level to each of the sensors when the sensor time synchronization is triggered, and to send a time synchronization message to each of the sensors, wherein the time synchronization message includes the local time of the domain controller.
[0080] Each of the sensors 102 is used to record a first timestamp corresponding to the current time when the first preset level is detected, and to record a second timestamp corresponding to the current time when the time synchronization message is received. The sensor calculates a time compensation value based on the second timestamp and the first timestamp, and adds the corresponding time compensation value to the local time to obtain the synchronized system time.
[0081] In this context, sensor 102 refers to multiple sensors.
[0082] As described above, when sensor time synchronization is triggered, the domain controller controls the I / O port to output a first preset level, which is transmitted to each sensor. It also sends a time synchronization message to each sensor. The time synchronization message includes the domain controller's local time. When each sensor detects the first preset level, it records the first timestamp corresponding to the current time. When each sensor receives the time synchronization message, it records the second timestamp corresponding to the current time. A time compensation value is calculated based on the second and first timestamps. Each sensor adds its corresponding time compensation value to its local time to obtain the synchronized system time. This solution connects the domain controller and each sensor via control lines to achieve sensor time synchronization. It solves the problem in existing technologies where the timestamp accuracy of data is insufficient when multiple sensors need to collect data at the same time, making accurate data fusion and joint judgment impossible. It can reduce time errors to the microsecond level, improving time accuracy. Furthermore, the hardware deployment is simple and highly feasible.
[0083] In one possible embodiment, each of the sensors 102 is specifically used for:
[0084] Send a response message to the domain controller;
[0085] The domain controller 101 is specifically used for:
[0086] After receiving the response messages sent by each of the sensors, the I / O port is controlled to output a second preset level to end the sensor time synchronization. The second preset level is a different rising and falling edge level than the first preset level.
[0087] In one possible embodiment, the domain controller 101 is further configured to:
[0088] The control I / O port outputs the second preset level and transmits it to each of the sensors.
[0089] In one possible embodiment, the compensation value calculation module 104 is specifically used for:
[0090] The difference between the second timestamp and the first timestamp is determined as the time compensation value.
[0091] In one possible embodiment, each of the sensors 102 is further used for:
[0092] The difference between the first timestamp and the second timestamp is calculated, and the difference is superimposed with a pre-stored correction coefficient to obtain a time compensation value. The pre-stored correction coefficient is the sum of the inherent delays inside the sensor.
[0093] In one possible embodiment, each of the sensors 102 is further used for:
[0094] If the time synchronization message is not received within the preset time window, the first timestamp is deleted, and a timeout message is sent to the domain controller, so that the domain controller can re-control the level of the I / O port and resend the time synchronization message.
[0095] In one possible embodiment, the domain controller 101 is further configured to:
[0096] If no response messages are received from the sensors, the level of the I / O port is recontrolled and the time synchronization message is resent.
[0097] Figure 8 A schematic diagram of a sensor time synchronization device in a local area network provided in this application embodiment is shown below. Figure 8 As shown, the device includes a processor 201, a memory 202, an input device 203, and an output device 204; the number of processors 201 in the device can be one or more. Figure 8 Taking a processor 201 as an example; the processor 201, memory 202, input device 203, and output device 204 in the device can be connected via a bus or other means. Figure 8 Taking a bus connection as an example, the memory 202, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions or modules corresponding to a sensor time synchronization method in a local area network according to an embodiment of this application. The processor 201 executes various functional applications and data processing of the device by running the software programs, instructions, and modules stored in the memory 202, thereby implementing the aforementioned sensor time synchronization method in the local area network. The input device 203 can be used to receive input digital or character information and generate key signal inputs related to user settings and function control of the device. The output device 204 may include a display screen or other display device.
[0098] This application embodiment also provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform a sensor time synchronization method in a local area network, the method comprising:
[0099] When sensor time synchronization is triggered, the domain controller controls the I / O port to output a first preset level and transmits it to each sensor, and sends a time synchronization message to each sensor. The time synchronization message includes the domain controller's local time.
[0100] When each sensor detects the first preset level, the first timestamp corresponding to the current time is recorded;
[0101] When each sensor receives a time synchronization message, it records the second timestamp corresponding to the current time and calculates the time compensation value based on the second timestamp and the first timestamp.
[0102] Each sensor adds its local time to its corresponding time compensation value to obtain the system time after time synchronization.
[0103] It is worth noting that in the embodiments of the sensor time synchronization method system in the above local area network, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this application.
[0104] Note that the above are merely preferred embodiments and the technical principles applied in this application. Those skilled in the art will understand that the embodiments of this application are not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the protection scope of the embodiments of this application. Therefore, although the embodiments of this application have been described in detail through the above embodiments, the embodiments of this application are not limited to the above embodiments. More other equivalent embodiments may be included without departing from the concept of the embodiments of this application, and the scope of the embodiments of this application is determined by the scope of the appended claims.
Claims
1. A sensor time synchronization method in a local area network (LAN), applied to a LAN system, the LAN system including a domain controller and multiple sensors, the domain controller being connected to each of the sensors via control lines, characterized in that, The method includes: The domain controller controls the I / O port to output a second preset level and transmit it to each of the sensors; When sensor time synchronization is triggered, the domain controller controls the I / O port to output a first preset level and transmits it to each of the sensors, and sends a time synchronization message to each of the sensors. The time synchronization message includes the local time of the domain controller. When each of the sensors detects the first preset level, the first timestamp corresponding to the current time is recorded; If the time synchronization message is not received within the preset time window, the first timestamp is deleted and an overdue message is sent to the domain controller, so that the domain controller can re-control the level of the IO port and resend the time synchronization message. When each of the sensors receives the time synchronization message, a second timestamp corresponding to the current time is recorded, and a time compensation value is calculated based on the second timestamp and the first timestamp. The calculation of the time compensation value based on the second timestamp and the first timestamp includes: calculating the difference between the first timestamp and the second timestamp, and superimposing the difference with a pre-stored correction coefficient to obtain the time compensation value. The pre-stored correction coefficient is the sum of the inherent delays inside the sensor. Each of the sensors adds its corresponding time compensation value to the local time to obtain the system time after time synchronization; Each of the sensors sends a response message to the domain controller; If the domain controller does not receive response messages from each of the sensors, it will re-control the level of the I / O port and resend the time synchronization message; After receiving the response messages sent by each of the sensors, the domain controller controls the I / O port to output a second preset level to end the sensor time synchronization. The second preset level is a different rising and falling edge level than the first preset level.
2. A sensor time synchronization system in a local area network, characterized in that, Includes a domain controller and multiple sensors: The domain controller is configured to, upon triggering sensor time synchronization, control the I / O port to output a first preset level for transmission to each of the sensors, and send a time synchronization message to each of the sensors, wherein the time synchronization message includes the local time of the domain controller. The domain controller is also configured to control the I / O port to output a second preset level for transmission to each of the sensors; and, if no response message is received from each of the sensors, re-control the level of the I / O port and resend the time synchronization message. After receiving the response messages sent by each of the sensors, the I / O port is controlled to output a second preset level to end the sensor time synchronization. The second preset level is a different rising and falling edge level than the first preset level. Each of the sensors is configured to record a first timestamp corresponding to the current time when it detects the first preset level; if the time synchronization message is not received within a preset time window, the first timestamp is deleted and a timeout message is sent to the domain controller, which is used by the domain controller to re-control the level of the I / O port and resend the time synchronization message; and when the time synchronization message is received, a second timestamp corresponding to the current time is recorded, a time compensation value is calculated based on the second timestamp and the first timestamp, and the local time is added to the corresponding time compensation value to obtain the synchronized system time. Each of the sensors is also configured to send an acknowledgment message to the domain controller. Specifically, each of the sensors is configured to calculate the difference between the first timestamp and the second timestamp, and to superimpose the difference with a pre-stored correction coefficient to obtain a time compensation value. The pre-stored correction coefficient is the sum of the inherent delays within the sensor.
3. A sensor time synchronization device in a local area network, the device comprising: One or more processors; A storage device for storing one or more programs that, when executed by one or more processors, cause the one or more processors to implement the sensor time synchronization method in a local area network as described in claim 1.
4. A storage medium storing computer-executable instructions, which, when executed by a computer processor, are used to perform the sensor time synchronization method in a local area network as described in claim 1.
Citation Information
Patent Citations
Clock synchronization method, apparatus and system, and chip
WO2023004576A1