Edge computing device clock synchronization method and system for intelligent manufacturing
Through the combination of distributed networks and Kalman filters, the problem of insufficient clock synchronization accuracy of edge computing devices is solved, high-precision clock synchronization and stable collaborative work are achieved, adapting to complex environments, reducing communication overhead, and supporting large-scale deployment.
Patent Information
- Application Number
- CN202510269040.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-07
- Publication Date
- 2025-07-08
AI Technical Summary
In the intelligent manufacturing industry, the clock synchronization accuracy of edge computing devices is difficult to meet the high-precision requirements. Especially in complex industrial Internet of Things environments, the NTP protocol is easily affected, and the PTP protocol is limited in synchronization accuracy in wireless networks.
The distributed network architecture is adopted to elect the master node through the main node election rules, clock calibration is used using the stopwatch sensor, and network delay and time offset are calculated in combination with the Kalman filter to realize clock synchronization of edge computing devices.
Improve the accuracy of clock synchronization of edge computing devices, adapt to complex environments, reduce communication overhead, support large-scale deployment, improve system reliability and collaboration capabilities, and ensure device operation stability.
Smart Images

Figure CN120281418A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent manufacturing, and particularly to a method and system for clock synchronization of edge computing devices for intelligent manufacturing. Background Art
[0002] There are a large number of edge computing devices in the intelligent manufacturing industry, such as various industrial sensors. Clock synchronization is a key technology for collaborative work among edge computing devices. In high-precision industrial Internet of Things scenarios, the requirements for clock synchronization are extremely high, often requiring an error of ten milliseconds or even microseconds.
[0003] Regarding the clock synchronization of edge computing devices in the intelligent manufacturing industry, traditionally, there are the NTP (Network Time Protocol) protocol and the PTP (Precision Time Protocol) protocol; although the NTP protocol can improve accuracy through various algorithms, the synchronization accuracy of the NTP protocol is vulnerable to influence in a complex industrial Internet of Things environment and is difficult to meet the high-precision synchronization requirements; the PTP protocol has the advantages of easy operation, small occupied frequency band, portability, etc., but its performance is limited in a wireless network environment and is easily affected by interference, affecting the synchronization accuracy.
[0004] Therefore, how to provide a method and system for clock synchronization of edge computing devices for intelligent manufacturing to improve the accuracy of clock synchronization of edge computing devices has become an urgent technical problem to be solved. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a method and system for clock synchronization of edge computing devices for intelligent manufacturing to improve the accuracy of clock synchronization of edge computing devices.
[0006] In a first aspect, the present invention provides a method for clock synchronization of edge computing devices for intelligent manufacturing, including the following steps:
[0007] Step S1: Set a master node election rule. When a distributed network composed of several nodes starts, based on the master node election rule, elect a master node from each node in the distributed network, and the remaining nodes are slave nodes; the master node is an edge computing device or a cloud node; the slave node is an edge computing device;
[0008] Step S2: The master node and each slave node perform initialization operations;
[0009] Step S3: The master node performs clock calibration operations through a stopwatch sensor;
[0010] Step S4: The master node periodically sends synchronization requests to each slave node, receives the delayed responses fed back by each slave node, records the timestamp when the master node sends the synchronization request as t1, the timestamp when the slave node receives the synchronization request as t2, the timestamp when the slave node sends the delayed response as t3, and the timestamp when the master node receives the delayed response as t4, and calculates time parameters including network delay and time offset based on t1, t2, t3, and t4;
[0011] Step S5: The master node inputs the time parameters into the local master Kalman filter to calculate the Kalman gain, and synchronizes the Kalman gain to each slave node;
[0012] Step S6: Each slave node inputs the received Kalman gain into the local slave Kalman filter to compensate the local clock, and then synchronizes with the clock of the master node.
[0013] Further, the specific content of step S1 is as follows:
[0014] Set a master node election rule. When the distributed network composed of several nodes starts, the master node is elected from each node in the distributed network based on the master node election rule, and the master node is online-checked. If the node is online, the master node election is completed, and the remaining nodes are used as slave nodes; if the node is offline, the master node is elected from the remaining nodes based on the master node election rule until the master node election is completed;
[0015] Each slave node maintains a heartbeat connection with the master node. When the heartbeat connection is disconnected for a preset duration, the election of the master node is triggered again;
[0016] The master node election rule is specifically as follows: Each node periodically calculates a performance index based on the current network resources and computing resources, stores the performance index, sorts each node based on the performance index, and elects the node with the strongest performance index as the master node; when no node stores the performance index, the master node is elected based on the order of the device serial numbers;
[0017] The master node is an edge computing device or a cloud node; the slave node is an edge computing device.
[0018] Further, the specific content of step S2 is as follows:
[0019] The master node initializes the reference clock, and the master node and each slave node initialize the clock frequency for identifying the length of 1 second, thereby completing the initialization operations of the master node and each slave node.
[0020] Further, the specific content of step S3 is as follows:
[0021] The stopwatch sensor generates several time points T0, T1, T2, …, Tn in real time, where T0 is the current time point, T1 is the first second in the future, and T2 is the second second in the future;
[0022] The master node sends a clock calibration request to the stopwatch sensor to obtain T1 and T2;
[0023] The master node calculates the time error t based on the current time t of this node now , T1, and T2 error :
[0024] t error = t now -(T2 - T1);
[0025] The master node verifies t based on a preset error threshold. When t error is greater than the error threshold, a clock calibration operation is performed based on t error ; error
[0026] In step S4, the calculation formula for the network delay is:
[0027]
[0028] The calculation formula for the time offset is:
[0029]
[0030] where t delay represents the network delay; t offset represents the time offset.
[0031] Furthermore, in step S5, the calculation process for the predicted state value is:
[0032] x = Fy + Bu;
[0033] where x represents the predicted state value of the time parameter at time t; F represents the state transition matrix of the time parameter; y represents the transfer data of the predicted state value; B represents the control input matrix of the predicted state value; u represents the control vector;
[0034] The calculation process for the Kalman gain is:
[0035] K = P k H T / (HP k H T + R);
[0036] P k = FP k-1 F T + Q;
[0037] Among them, K represents the Kalman gain; P k represents the predicted covariance matrix at time k; H represents the observation matrix of the time parameter; T represents the transpose; R represents the observation noise covariance matrix of the time parameter; P k-1 represents the predicted covariance matrix at time k - 1; Q represents the process noise covariance matrix of the time parameter.
[0038] In a second aspect, the present invention provides an edge computing device clock synchronization system for intelligent manufacturing, including the following modules:
[0039] A master node election module, configured to set a master node election rule. When a distributed network composed of several nodes is started, a master node is elected from each node in the distributed network based on the master node election rule, and the remaining nodes are used as slave nodes; the master node is an edge computing device or a cloud node; the slave nodes are edge computing devices;
[0040] A node initialization module, configured to perform initialization operations on the master node and each slave node;
[0041] A clock calibration module, configured to perform clock calibration operations on the master node through a stopwatch sensor;
[0042] A time parameter calculation module, configured to the master node periodically sends synchronization requests to each slave node, receives delay responses fed back by each slave node, records the timestamp when the master node sends the synchronization request as t1, the timestamp when the slave node receives the synchronization request as t2, the timestamp when the slave node sends the delay response as t3, and the timestamp when the master node receives the delay response as t4, and calculates time parameters including network delay and time offset based on t1, t2, t3, and t4;
[0043] A Kalman gain synchronization module, configured to the master node inputs the time parameters into the local master Kalman filter to calculate the Kalman gain, and synchronizes the Kalman gain to each slave node;
[0044] A clock synchronization module, configured to each slave node inputs the received Kalman gain into the local slave Kalman filter to compensate the local clock, and then synchronize with the clock of the master node.
[0045] Further, the master node election module is specifically configured to:
[0046] Set a master node election rule. When a distributed network composed of several nodes starts, a master node is elected from each node in the distributed network based on the master node election rule, and the master node is online verified. If the node is online, the master node election is completed, and the remaining nodes are used as slave nodes; if the node is offline, a master node is elected from the remaining nodes based on the master node election rule until the master node election is completed;
[0047] Each of the slave nodes maintains a heartbeat connection with the master node. When the heartbeat connection is disconnected for a preset duration, the election of the master node is triggered again;
[0048] The master node election rule is specifically as follows: Each node periodically calculates a performance index based on the current network resources and computing resources, stores the performance index, sorts each node based on the performance index, and elects the node with the strongest performance index as the master node; when none of the nodes stores a performance index, the master node is elected based on the order of the device serial numbers;
[0049] The master node is an edge computing device or a cloud node; the slave node is an edge computing device.
[0050] Further, the node initialization module is specifically used for:
[0051] The master node initializes the reference clock, and the master node and each slave node initialize the clock frequency for identifying the length of 1 second, thereby completing the initialization operations of the master node and each slave node.
[0052] Further, the clock calibration module is specifically used for:
[0053] A stopwatch sensor generates a number of time points T0, T1, T2,..., Tn in real time, T0 is the current time point, T1 is the first second in the future, and T2 is the second second in the future;
[0054] The master node sends a clock calibration request to the stopwatch sensor to obtain the T1 and T2;
[0055] The master node is based on the current time t of this node now 、T1 and T2 calculate the time error t error :
[0056] t error =t now -(T2 - T1);
[0057] The master node verifies t error based on a preset error threshold. When the t error is greater than the error threshold, a clock calibration operation is performed based on the t error ;
[0058] In the time parameter calculation module, the calculation formula for the network delay is as follows:
[0059]
[0060] The calculation formula for the time offset is as follows:
[0061]
[0062] Where t delay represents the network delay; t offset represents the time offset.
[0063] Furthermore, in the Kalman gain synchronization module, the calculation process of the predicted state value is as follows:
[0064] x = Fy + Bu;
[0065] Where x represents the predicted state value of the time parameter at time t; F represents the state transition matrix of the time parameter; y represents the transfer data of the predicted state value; B represents the control input matrix of the predicted state value; u represents the control vector;
[0066] The calculation process of the Kalman gain is as follows:
[0067] K = P k H T / (HP k H T + R);
[0068] P k = FP k-1 F T + Q;
[0069] Where K represents the Kalman gain; P k represents the predicted covariance matrix at time k; H represents the observation matrix of the time parameter; T represents the transpose; R represents the observation noise covariance matrix of the time parameter; P k-1 represents the predicted covariance matrix at time k - 1; Q represents the process noise covariance matrix of the time parameter.
[0070] The advantages of the present invention are as follows:
[0071] 1. When a distributed network composed of several nodes starts up, a master node is elected from each node in the distributed network based on the master node election rule, and the remaining nodes are used as slave nodes. After the master node and each slave node perform initialization operations, the master node performs clock calibration operations through a stopwatch sensor. Then, the master node periodically sends synchronization requests to each slave node, receives the delay responses feedback by each slave node, records the timestamp when the master node sends the synchronization request as t1, the timestamp when the slave node receives the synchronization request as t2, the timestamp when the slave node sends the delay response as t3, and the timestamp when the master node receives the delay response as t4, and calculates time parameters including network delay and time offset based on t1, t2, t3, and t4. The master node inputs the time parameters into the master Kalman filter to calculate the predicted state value and Kalman gain of the time parameters, and synchronizes the predicted state value and Kalman gain to each slave node. Each slave node obtains the observed state value of the time parameters, and inputs the Kalman gain, predicted state value, and observed state value into the local slave Kalman filter to compensate the local clock, and then synchronize with the clock of the master node. That is, the entire distributed network is divided into multiple local nodes, the local observation data (t1, t2, t3, t4) of each node is collected, and collaborative estimation between multiple nodes is realized through a distributed Kalman filter (master Kalman filter, slave Kalman filter), that is, the network delay and time offset are dynamically estimated and corrected through the Kalman filter to reduce the error of clock synchronization between nodes, and the distributed architecture enables strong adaptability in a complex industrial Internet of Things environment, which is beneficial to the precise collaborative work of edge computing devices, and ultimately greatly improves the accuracy of clock synchronization of edge computing devices.
[0072] 2. The process noise covariance matrix affected by environmental and network delay fluctuations is extracted through the Kalman filter, and the noise covariance matrix parameters affected by environmental and network delay fluctuations are extracted through the Kalman filter algorithm, which can be adaptively adjusted to meet the dynamically changing environmental conditions, and greatly improves the generalization performance of clock synchronization.
[0073] 3. Synchronizing from the master node to the slave node through a distributed architecture enables edge computing devices to effectively reduce communication overhead, improve synchronization efficiency, support large-scale deployment, reduce error accumulation in clock synchronization, and thus greatly improve the reliability and collaboration ability of the entire system.
[0074] 4. By setting the master-slave mode of the master node and the slave node, and the master node is elected based on the master node election rule, even if the master node is offline (not connected to the Internet), the clock synchronization between the master node and the slave node can be guaranteed, that is, it can be deployed offline and perform clock synchronization, ensuring the stability of the operation of edge computing devices. Description of the Drawings
[0075] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0076] Figure 1 It is a flowchart of a clock synchronization method for an edge computing device for intelligent manufacturing according to the present invention.
[0077] Figure 2 It is a schematic structural diagram of a clock synchronization system for an edge computing device for intelligent manufacturing according to the present invention. Specific embodiments
[0078] The overall idea of the technical solution in the embodiments of the present application is as follows: The entire distributed network is divided into multiple local nodes, and the local observation data (t1, t2, t3, t4) of each node is collected. Through a distributed Kalman filter, collaborative estimation between multiple nodes is achieved, that is, the network delay and time offset are dynamically estimated and corrected through the Kalman filter to reduce the error of clock synchronization between nodes, and the distributed architecture enables strong adaptability in a complex industrial Internet of Things environment, which is beneficial to the precise collaborative work of edge computing devices, thereby improving the accuracy of clock synchronization of edge computing devices.
[0079] Please refer to Figures 1 to 2 As shown, a preferred embodiment of a clock synchronization method for an edge computing device for intelligent manufacturing according to the present invention includes the following steps:
[0080] Step S1: Set a master node election rule. When a distributed network composed of several nodes is started, a master node is elected from each node in the distributed network based on the master node election rule, and the remaining nodes are used as slave nodes; the master node is an edge computing device or a cloud node; the slave node is an edge computing device.
[0081] Step S2: The master node and each slave node perform initialization operations.
[0082] Step S3: The master node performs clock calibration operations through a stopwatch sensor.
[0083] Step S4: The master node periodically sends synchronization requests to each slave node, receives the delay responses feedback by each slave node, records the timestamp when the master node sends the synchronization request as t1, the timestamp when the slave node receives the synchronization request as t2, the timestamp when the slave node sends the delay response as t3, and the timestamp when the master node receives the delay response as t4, and calculates time parameters including network delay and time offset based on t1, t2, t3, and t4 for subsequent clock compensation.
[0084] Step S5: The master node inputs the time parameter into the local master Kalman filter to calculate the Kalman gain, and synchronizes the Kalman gain to each slave node.
[0085] Step S6: Each slave node inputs the received Kalman gain into the local slave Kalman filter to compensate the local clock, and then synchronize with the clock of the master node.
[0086] The specific content of step S1 is as follows:
[0087] Set a master node election rule. When a distributed network composed of several nodes starts, the master node is elected from each node in the distributed network based on the master node election rule, and the master node is online verified. If the node is online, the master node election is completed, and the remaining nodes are slave nodes; if the node is offline, the master node is elected from the remaining nodes based on the master node election rule until the master node election is completed; the master node is used to send a synchronization request to the slave node and receive a delay response, calculate the Kalman gain based on the sending and receiving times of the synchronization request and the delay response, and synchronize the Kalman gain to each slave node; the slave node is used to send a delay response to the master node when receiving the synchronization request, and perform clock synchronization operations based on the received Kalman gain;
[0088] Each slave node maintains a heartbeat connection with the master node. When the heartbeat connection is disconnected for a preset duration, the election of the master node is triggered again.
[0089] The specific content of the master node election rule is as follows: Each node periodically calculates a performance index based on the current network resources and computing resources, stores the performance index, sorts each node based on the performance index, and elects the node with the strongest performance index as the master node; when no node stores the performance index, the master node is elected based on the order of the device serial numbers.
[0090] The master node is an edge computing device or a cloud node; the slave node is an edge computing device.
[0091] Synchronized from the master node to the slave node through a distributed architecture, enabling edge computing devices to effectively reduce communication overhead, improve synchronization efficiency, support large-scale deployment, reduce error accumulation in clock synchronization, and thus greatly improve the reliability and collaboration ability of the entire system.
[0092] By setting the master-slave mode of the master node and the slave node, and the master node is elected based on the master node election rule, even if the master node is offline (not connected to the Internet), the clock synchronization between the master node and the slave node can be guaranteed, that is, it can be deployed offline and perform clock synchronization, ensuring the stability of the operation of edge computing devices.
[0093] The specific content of step S2 is as follows:
[0094] The master node initializes the reference clock, and the master node and each slave node initialize the clock frequency for identifying the length of 1 second, thereby completing the initialization operations of the master node and each slave node. To ensure the uniqueness of the reference clock, only one master node is set in the distributed network. The reference clock is the reference time, such as 1900-1-1 00:00:00, and the current clock is calculated based on the reference clock.
[0095] The specific content of step S3 is as follows:
[0096] The stopwatch sensor generates a number of time points T0, T1, T2, …, Tn in real time, where T0 is the current time point, T1 is the first second in the future, and T2 is the second second in the future;
[0097] The master node sends a clock calibration request to the stopwatch sensor to obtain T1 and T2;
[0098] The master node is based on the current time t of its own node now , T1 and T2 to calculate the time error t error :
[0099] t error = t now -(T2 - T1);
[0100] The master node verifies t error based on a preset error threshold. When t error is greater than the error threshold, a clock calibration operation is performed based on t error ;
[0101] In step S4, the calculation formula for the network delay is:
[0102]
[0103] The calculation formula for the time offset is:
[0104]
[0105] where t delay represents the network delay; t offset represents the time offset.
[0106] In step S5, the calculation process of the predicted state value is:
[0107] x = Fy + Bu;
[0108] Among them, x represents the predicted state value of the time parameter at time t; F represents the state transition matrix of the time parameter; y represents the transition data of the predicted state value. Assuming the current time is t, the previous time is t - 1, and the next time is t + 1, then y is the predicted state value of predicting time t based on time t - 1; B represents the control input matrix of the predicted state value; u represents the control vector.
[0109] The calculation process of the Kalman gain is as follows:
[0110] K = P k H T / (HP k H T + R);
[0111] P k = FP k-1 F T + Q;
[0112] Among them, K represents the Kalman gain; P k represents the predicted covariance matrix at time k; H represents the observation matrix of the time parameter; T represents the transpose; R represents the observation noise covariance matrix of the time parameter; P k-1 represents the predicted covariance matrix at time k - 1; Q represents the process noise covariance matrix (Process No i se Covar i ance), with a value of 0.01, reflecting the random variation of the clock offset, that is, external interference and hardware influence, etc.; the process noise covariance is an important parameter in the Kalman filter, used to describe the uncertainty in the system dynamic model. The process noise covariance matrix is a square matrix, used to characterize the random interference degree in the system dynamic model, and describes the error introduced due to model imperfection, external interference or internal random variation of the system; in the Kalman filter, the process noise is usually assumed to be Gaussian white noise with a mean of zero, and the process noise covariance matrix is used to quantify the statistical characteristics of these noises.
[0113] The process noise covariance matrix affected by the environment and network delay fluctuations is extracted through the Kalman filter, and the noise covariance matrix parameters affected by the environment and network delay fluctuations are extracted through the Kalman filter algorithm, which can be adaptively adjusted to meet the dynamically changing environmental conditions, greatly improving the generalization performance of clock synchronization.
[0114] In the industrial Internet of Things environment, when using a Kalman filter for clock synchronization, it is crucial to determine the values of the process noise covariance matrix and the control input matrix. These parameters directly affect the synchronization accuracy of the Kalman filter. The initial values can estimate the error and convergence rate through a performance evaluation method. According to experience, the process noise covariance matrix is set to 0.01, and the control input matrix is set to 0. If the Kalman filter is too sensitive to noise, the process noise covariance matrix can be increased; if the Kalman filter converges too slowly, the process noise covariance matrix can be decreased.
[0115] A preferred embodiment of a clock synchronization system for an edge computing device for intelligent manufacturing according to the present invention includes the following modules:
[0116] A master node election module, configured to set a master node election rule. When a distributed network composed of several nodes is started, based on the master node election rule, a master node is elected from each node in the distributed network, and the remaining nodes are used as slave nodes; the master node is an edge computing device or a cloud node; the slave node is an edge computing device;
[0117] A node initialization module, configured to perform initialization operations on the master node and each slave node;
[0118] A clock calibration module, configured to perform clock calibration operations on the master node through a stopwatch sensor;
[0119] A time parameter calculation module, configured to the master node periodically sends synchronization requests to each slave node, receives the delay responses feedback by each slave node, records the timestamp when the master node sends the synchronization request as t1, the timestamp when the slave node receives the synchronization request as t2, the timestamp when the slave node sends the delay response as t3, and the timestamp when the master node receives the delay response as t4, and calculates time parameters including network delay and time offset based on t1, t2, t3, and t4 for subsequent clock compensation;
[0120] A Kalman gain synchronization module, configured to the master node inputs the time parameters into the local master Kalman filter to calculate the Kalman gain, and synchronizes the Kalman gain to each slave node;
[0121] A clock synchronization module, configured to each slave node inputs the received Kalman gain into the local slave Kalman filter to compensate the local clock, and then synchronize with the clock of the master node.
[0122] The master node election module is specifically configured to:
[0123] Set a master node election rule. When a distributed network composed of several nodes starts, a master node is elected from each node in the distributed network based on the master node election rule, and the master node is online verified. If the node is online, the master node election is completed, and the remaining nodes are slave nodes; if the node is offline, a master node is elected from the remaining nodes based on the master node election rule until the master node election is completed; the master node is used to send a synchronization request to the slave node and receive a delayed response, calculate the Kalman gain based on the sending and receiving times of the synchronization request and the delayed response, and synchronize the Kalman gain to each slave node; the slave node is used to send a delayed response to the master node when receiving the synchronization request, and perform a clock synchronization operation based on the received Kalman gain;
[0124] Each of the slave nodes maintains a heartbeat connection with the master node. When the heartbeat connection is disconnected for a preset duration, the election of the master node is triggered again;
[0125] The master node election rule is specifically as follows: Each node periodically calculates a performance index based on the current network resources and computing resources, stores the performance index, sorts each node based on the performance index, and elects the node with the strongest performance index as the master node; when none of the nodes store the performance index, the master node is elected based on the order of the device serial numbers;
[0126] The master node is an edge computing device or a cloud node; the slave node is an edge computing device.
[0127] Synchronized from the master node to the slave node through a distributed architecture, enabling edge computing devices to effectively reduce communication overhead, improve synchronization efficiency, support large-scale deployment, reduce error accumulation in clock synchronization, and thus greatly improve the reliability and collaboration ability of the entire system.
[0128] By setting the master-slave mode of the master node and the slave node, and the master node is elected based on the master node election rule, even if the master node is offline (not connected to the Internet), the clock synchronization between the master node and the slave node can be guaranteed, that is, it can be deployed offline and perform clock synchronization, ensuring the stability of the operation of the edge computing device.
[0129] The node initialization module is specifically used for:
[0130] The master node initializes the reference clock, and the master node and each slave node initialize the clock frequency for identifying the length of 1 second, thereby completing the initialization operations of the master node and each slave node. To ensure the uniqueness of the reference clock, only one master node is set in the distributed network. The reference clock is the reference time, such as 1900-1-1 00:00:00, and the current clock is calculated based on the reference clock.
[0131] The clock calibration module is specifically used for:
[0132] The stopwatch sensor generates several time points T0, T1, T2, ..., Tn in real time, where T0 is the current time point, T1 is the first second in the future, and T2 is the second second in the future;
[0133] The master node sends a clock calibration request to the stopwatch sensor to obtain T1 and T2;
[0134] The master node is based on the current time t of this node now , T1 and T2 calculate the time error t error :
[0135] t error =t now -(T2-T1);
[0136] The master node calculates t based on a preset error threshold error To check, when the t error When the error threshold is greater than the error threshold, based on the t error Perform clock calibration operation;
[0137] In the time parameter calculation module, the calculation formula of the network delay is:
[0138]
[0139] The calculation formula of the time offset is:
[0140]
[0141] Among them, t delay Indicates network delay; t offset Indicates the time offset.
[0142] In the Kalman gain synchronization module, the calculation process of the predicted state value is:
[0143] x=Fy+Bu;
[0144] Among them, x represents the predicted state value of the time parameter at time t; F represents the state transfer matrix of the time parameter; y represents the transfer data of the predicted state value. Assuming that the current time is t, the previous time is t-1, and the next time is t+1, then y is the predicted state value at time t based on the prediction of time t-1; B represents the control input matrix of the predicted state value; u represents the control vector;
[0145] The calculation process of the Kalman gain is:
[0146] K=P k H T / (HPk H T + R);
[0147] P k = FP k-1 F T + Q;
[0148] where K represents the Kalman gain; P k represents the predicted covariance matrix at time k; H represents the observation matrix of the time parameter; T represents the transpose; R represents the observation noise covariance matrix of the time parameter; P k-1 represents the predicted covariance matrix at time k - 1; Q represents the process noise covariance matrix (Process Noise Covariance), with a value of 0.01, reflecting the random variation of the clock offset, i.e., external interference and hardware effects, etc.; the process noise covariance is an important parameter in the Kalman filter, used to describe the uncertainty in the system dynamic model. The process noise covariance matrix is a square matrix, used to characterize the degree of random interference in the system dynamic model, and describes the errors introduced due to imperfect models, external interference, or internal random variations in the system; in the Kalman filter, the process noise is usually assumed to be Gaussian white noise with a mean of zero, and the process noise covariance matrix is used to quantify the statistical characteristics of these noises.
[0149] By using the Kalman filter to extract the process noise covariance matrix affected by the environment and network delay fluctuations, and by using the Kalman filter algorithm to extract the noise covariance matrix parameters affected by the environment and network delay fluctuations, it can be adaptively adjusted to meet the dynamically changing environmental conditions, greatly improving the generalization performance of clock synchronization.
[0150] In the industrial Internet of Things environment, when using the Kalman filter for clock synchronization, it is crucial to determine the values of the process noise covariance matrix and the control input matrix. These parameters directly affect the synchronization accuracy of the Kalman filter. The initial values can estimate the error and convergence speed through a performance evaluation method. According to experience, set the process noise covariance matrix to 0.01 and the control input matrix to 0. If the Kalman filter is too sensitive to noise, the process noise covariance matrix can be increased; if the Kalman filter converges too slowly, the process noise covariance matrix can be decreased.
[0151] In summary, the advantages of the present invention are as follows:
[0152] 1. When a distributed network composed of several nodes starts up, a master node is elected from each node in the distributed network based on the master node election rule. The remaining nodes act as slave nodes. After the master node and each slave node perform initialization operations, the master node performs clock calibration operations through a stopwatch sensor. Then, the master node periodically sends synchronization requests to each slave node, receives the delay responses fed back by each slave node, records the timestamp when the master node sends the synchronization request as t1, the timestamp when the slave node receives the synchronization request as t2, the timestamp when the slave node sends the delay response as t3, and the timestamp when the master node receives the delay response as t4. Time parameters including network delay and time offset are calculated based on t1, t2, t3, and t4. The master node inputs the time parameters into the master Kalman filter to calculate the predicted state value and Kalman gain of the time parameters, and synchronizes the predicted state value and Kalman gain to each slave node. Each slave node obtains the observed state value of the time parameters, and inputs the Kalman gain, predicted state value, and observed state value into the local slave Kalman filter to compensate the local clock, and then synchronize with the master node's clock. That is, the entire distributed network is divided into multiple local nodes, and local observation data (t1, t2, t3, t4) of each node is collected. Through the distributed Kalman filter (master Kalman filter, slave Kalman filter), collaborative estimation between multiple nodes is realized, that is, the network delay and time offset are dynamically estimated and corrected through the Kalman filter to reduce the error of clock synchronization between nodes. And the distributed architecture enables strong adaptability in a complex industrial Internet of Things environment, which is conducive to the precise collaborative work of edge computing devices, and ultimately greatly improves the accuracy of clock synchronization of edge computing devices.
[0153] 2. The process noise covariance matrix affected by environmental and network delay fluctuations is extracted through the Kalman filter, and the noise covariance matrix parameters affected by environmental and network delay fluctuations are extracted through the Kalman filter algorithm, which can be adaptively adjusted to meet the dynamically changing environmental conditions, greatly improving the generalization performance of clock synchronization.
[0154] 3. Synchronizing from the master node to the slave node through the distributed architecture enables edge computing devices to effectively reduce communication overhead, improve synchronization efficiency, support large-scale deployment, reduce error accumulation in clock synchronization, and thus greatly improve the reliability and collaboration ability of the entire system.
[0155] 4. By setting the master-slave mode of the master node and slave node, and the master node is elected based on the master node election rule. Even if the master node is offline (not connected to the Internet), the clock synchronization between the master node and the slave node can be guaranteed, that is, it can be deployed offline and perform clock synchronization, ensuring the stability of the operation of edge computing devices.
[0156] Although the specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments we described are illustrative rather than intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should all be covered by the scope protected by the claims of the present invention.
Claims
1. A method for clock synchronization of edge computing devices for intelligent manufacturing, characterized in that: It includes the following steps: Step S1: Set a master node election rule. When a distributed network composed of several nodes starts, based on the master node election rule, elect a master node from each node in the distributed network, and the remaining nodes are slave nodes; the master node is an edge computing device or a cloud node; the slave nodes are edge computing devices; Step S2: The master node and each slave node perform initialization operations; Step S3: The master node performs clock calibration operations through a stopwatch sensor; Step S4: The master node periodically sends synchronization requests to each slave node, receives the delay responses fed back by each slave node, records the timestamp when the master node sends the synchronization request as t1, the timestamp when the slave node receives the synchronization request as t2, the timestamp when the slave node sends the delay response as t3, and the timestamp when the master node receives the delay response as t4, and calculates time parameters including network delay and time offset based on t1, t2, t3, and t4; Step S5: The master node inputs the time parameters into the local master Kalman filter to calculate the predicted state value and Kalman gain of the time parameters, and synchronizes the predicted state value and Kalman gain to each slave node; Step S6: Each slave node obtains the observed state value of the time parameters, and inputs the Kalman gain, predicted state value, and observed state value into the local slave Kalman filter to compensate the local clock, so as to synchronize with the clock of the master node.
2. The clock synchronization method for an edge computing device used in intelligent manufacturing according to claim 1, characterized in that: The specific content of step S1 is as follows: Set a master node election rule. When a distributed network composed of several nodes starts, based on the master node election rule, elect a master node from each node in the distributed network, perform an online check on the master node. If the node is online, the master node election is completed, and the remaining nodes are slave nodes; If the node is offline, elect a master node from the remaining nodes based on the master node election rule until the master node election is completed; Each slave node maintains a heartbeat connection with the master node. When the mental connection is disconnected for a preset duration, trigger the election of the master node again; The specific master node election rule is as follows: Each node periodically calculates a performance index based on the current network resources and computing resources, stores the performance index, sorts each node based on the performance index, and elects the node with the strongest performance index as the master node; When none of the nodes stores the performance index, elect the master node based on the order of the device serial numbers; The master node is an edge computing device or a cloud node; the slave nodes are edge computing devices.
3. A clock synchronization method for an edge computing device used in intelligent manufacturing according to claim 1, characterized in that: The specific content of step S2 is as follows: The master node initializes the reference clock, and the master node and each slave node initialize the clock frequency used to identify the length of 1 second, thereby completing the initialization operations of the master node and each slave node.
4. A clock synchronization method for an edge computing device used in intelligent manufacturing according to claim 1, characterized in that: The specific content of step S3 is as follows: The stopwatch sensor generates several time points T0, T1, T2,..., Tn in real time. T0 is the current time point, T1 is the first second in the future, and T2 is the second second in the future; The master node sends a clock calibration request to the stopwatch sensor to obtain T1 and T2; The master node calculates the time error t based on the current time t of this node now , T1, and T2 error : t error = t now -(T2 - T1); The master node performs verification on t based on a preset error threshold error When the t error is greater than the error threshold, a clock calibration operation is performed based on the t error In the step S4, the calculation formula of the network delay is as follows: The calculation formula of the time offset is as follows: Among them, t delay represents network latency; t offset represents time offset.
5. A clock synchronization method for an edge computing device used in intelligent manufacturing according to claim 1, characterized in that: In the step S5, the calculation process of the predicted state value is as follows: x = Fy + Bu; where x represents the predicted state value of the time parameter at time t; F represents the state transition matrix of the time parameter; y represents the transfer data of the predicted state value; B represents the control input matrix of the predicted state value; u represents the control vector; The calculation process of the Kalman gain is as follows: K = P k H T / (HP k H T +R); P k = FP k-1 F T + Q; where, K represents the Kalman gain; P k represents the predicted covariance matrix at time k; H represents the observation matrix of the time parameter; T represents the transpose; R represents the observation noise covariance matrix of the time parameter; P k-1 represents the predicted covariance matrix at time k-1; Q represents the process noise covariance matrix of the time parameter.
6. An edge computing device clock synchronization system for intelligent manufacturing, characterized in that: It includes the following modules: The master node election module is used to set a master node election rule. When a distributed network composed of several nodes starts, the master node is elected from each node in the distributed network based on the master node election rule, and the remaining nodes are used as slave nodes; the master node is an edge computing device or a cloud node; the slave node is an edge computing device; The node initialization module is used to perform initialization operations on the master node and each slave node; The clock calibration module is used for the master node to perform clock calibration operations through a stopwatch sensor; The time parameter calculation module is used for the master node to periodically send synchronization requests to each slave node, receive the delay responses feedback by each slave node, record the timestamp when the master node sends the synchronization request as t1, the timestamp when the slave node receives the synchronization request as t2, the timestamp when the slave node sends the delay response as t3, and the timestamp when the master node receives the delay response as t4, and calculate the time parameters including network delay and time offset based on t1, t2, t3, and t4; The Kalman gain synchronization module is used for the master node to input the time parameters into the local master Kalman filter to calculate the Kalman gain, and synchronize the Kalman gain to each slave node; The clock synchronization module is used for each slave node to input the received Kalman gain into the local slave Kalman filter to compensate the local clock, and then synchronize with the clock of the master node.
7. The clock synchronization system for an edge computing device used in intelligent manufacturing according to claim 6, wherein: The master node election module is specifically used for: Setting a master node election rule. When a distributed network composed of several nodes starts, the master node is elected from each node in the distributed network based on the master node election rule, and the master node is online verified. If the node is online, the master node election is completed, and the remaining nodes are used as slave nodes; If the node is offline, the master node is elected from the remaining nodes based on the master node election rule until the master node election is completed; Each slave node maintains a heartbeat connection with the master node. When the heartbeat connection is disconnected for a preset duration, the election of the master node is triggered again; The master node election rule is specifically as follows: Each node periodically calculates a performance index based on the current network resources and computing resources, stores the performance index, sorts each node based on the performance index, and elects the node with the strongest performance index as the master node; When no node stores the performance index, the master node is elected based on the order of the device serial numbers; The master node is an edge computing device or a cloud node; the slave node is an edge computing device.
8. The clock synchronization system for an edge computing device used in intelligent manufacturing according to claim 6, characterized in that: The node initialization module is specifically used for: The master node initializes the reference clock, and the master node and each slave node initialize the clock frequency for identifying the length of 1 second, thereby completing the initialization operations of the master node and each slave node.
9. The clock synchronization system for an edge computing device used in intelligent manufacturing according to claim 6, characterized in that: The clock calibration module is specifically configured to: The stopwatch sensor generates a number of time points T0, T1, T2, …, Tn in real time, where T0 is the current time point, T1 is the first second in the future, and T2 is the second second in the future; The master node sends a clock calibration request to the stopwatch sensor to obtain the T1 and T2; The master node calculates the time error t based on the current time t of this node now , T1, and T2 error : t error = t now -(T2 - T1); The master node performs a check on t based on a preset error threshold error When the t error is greater than the error threshold, a clock calibration operation is performed based on the t error In the time parameter calculation module, the calculation formula for the network delay is: The calculation formula for the time offset is: where t delay represents network latency; t offset represents time offset.
10. The clock synchronization system for an edge computing device used in intelligent manufacturing according to claim 6, wherein: In the Kalman gain synchronization module, the calculation process for the predicted state value is: x = Fy + Bu; Where x represents the predicted state value of the time parameter at time t; F represents the state transition matrix of the time parameter; y represents the transfer data of the predicted state value; B represents the control input matrix of the predicted state value; u represents the control vector; The calculation process for the Kalman gain is: K = P k H T / (HP k H T +R); P k = FP k-1 F T + Q; Among them, K represents the Kalman gain; P k represents the predicted covariance matrix at time k; H represents the observation matrix of the time parameter; T represents the transpose; R represents the covariance matrix of the observation noise of the time parameter; P k-1 represents the predicted covariance matrix at time k-1; Q represents the covariance matrix of the process noise of the time parameter.
Citation Information
Cited By
Intelligent all-in-one machine with body, system and operation method
CN120722832A
Distributed LED screen cooperative control system based on wireless synchronization protocol
CN120751477A