CN-121978879-A - Time keeping method, terminal equipment and computer readable storage medium
Abstract
The application is applicable to the technical field of clock synchronization, and provides a time keeping method, terminal equipment and a computer readable storage medium, which are applied to a time synchronization device, wherein the time synchronization device comprises a crystal oscillator; the time keeping method comprises the steps of switching a time synchronization device from a first state to a second state, obtaining a prediction model trained based on first collected data when the time synchronization device is in the first state, sequentially obtaining predicted frequency deviation corresponding to each control moment in the second state according to the prediction model, and controlling the time synchronization device to keep time according to the predicted frequency deviation corresponding to each control moment in the second state. The time synchronization device is clocked based on an external reference time source in the first state, and is clocked based on a crystal oscillator in the second state. By the mode, the time keeping precision can be effectively improved.
Inventors
- LIU QISHUANG
- YUAN MINGJUN
- HAN MAOLIN
- Lv Xinya
- HU KAIFANG
- LIU JIAHAO
- GUO CHANGLIN
Assignees
- 长园深瑞继保自动化有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251224
Claims (10)
- 1. The time keeping method is characterized by being applied to a time synchronization device, wherein the time synchronization device comprises a crystal oscillator, and the time keeping method comprises the following steps: The method comprises the steps of switching a time synchronization device from a first state to a second state, acquiring a prediction model trained based on first acquired data when the time synchronization device is in the first state, wherein the time synchronization device is in the first state and is in time keeping based on an external reference time source, the time synchronization device is in time keeping based on the crystal oscillator in the second state, the first acquired data comprises a plurality of first data packets corresponding to first acquisition moments, each first data packet corresponding to the first acquisition moment comprises a target reference time corresponding to the first acquisition moment, environment data and a historical frequency deviation sequence between crystal oscillator frequency of the crystal oscillator and the external reference time source, and the prediction model is used for predicting frequency deviation between the crystal oscillator and the external reference time source according to the target reference time, the environment data and the historical frequency deviation sequence; Acquiring target data, wherein the target data is a latest group of first data packets acquired before the time synchronization device enters the second state; According to the target data and the prediction model, the prediction frequency deviation corresponding to each control moment in the second state is obtained in sequence; And in the second state, controlling the time synchronization device to keep time according to the predicted frequency deviation corresponding to each control moment.
- 2. The time keeping method of claim 1, wherein the method further comprises: When the time synchronization device is switched from the second state to the first state, second acquired data of the time synchronization device are acquired, wherein the second acquired data comprise a plurality of second data packets corresponding to second acquisition moments, and each second data packet corresponding to the second acquisition moment comprises a target reference time corresponding to the second acquisition moment, environment data and a historical frequency deviation sequence between the crystal oscillator frequency and an external reference time source; and updating the prediction model according to the second acquired data to obtain the updated prediction model.
- 3. The time keeping method of claim 1, wherein the acquiring a prediction model trained based on first acquired data when the time synchronization device is in the first state comprises: acquiring the first acquired data; sampling the first acquired data to obtain third acquired data, wherein the sampling frequency corresponding to the third acquired data is lower than the sampling frequency corresponding to the first acquired data; Training an initial model according to the first acquired data to obtain a first model; Training the initial model according to the third acquired data to obtain a second model; and constructing the prediction model according to the first model and the second model.
- 4. The time keeping method according to claim 3, wherein the obtaining, according to the target data and the prediction model, a predicted frequency deviation corresponding to each control moment in the second state includes: Inputting the target data into the first model at a first moment to obtain a first output, wherein the first moment is a first control moment after the time synchronization device is switched from the first state to the second state; Inputting the target data into the second model to obtain a second output; And calculating the predicted frequency deviation corresponding to the first moment according to the first output and the second output.
- 5. The time keeping method of claim 4, wherein after calculating the predicted frequency deviation corresponding to the first time from the first output and the second output, the method further comprises: Calculating the confidence coefficient of the prediction model according to the prediction frequency deviation corresponding to the first moment; And if the confidence coefficient is lower than a preset threshold value, exiting the second state.
- 6. The time keeping method according to claim 3, wherein the time synchronization device comprises two receiving modules for receiving time information from different external reference time sources, respectively; The acquiring the first acquired data includes: for each first acquisition time, acquiring time information received by each receiving module; respectively calculating the signal quality corresponding to each receiving module; Calculating a target reference time corresponding to the first acquisition time according to the signal quality and time information corresponding to each receiving module; acquiring environmental data and a historical frequency deviation sequence corresponding to the first acquisition time; and generating a first data packet corresponding to the first acquisition time according to the target reference time, the environment data and the historical frequency deviation sequence corresponding to the first acquisition time.
- 7. The time keeping method according to claim 1, wherein controlling the time synchronization device to keep time according to the predicted frequency deviation corresponding to each control time in the second state comprises: For each control moment, acquiring the average frequency of the crystal oscillator, wherein the average frequency is the average value of the output frequency of the crystal oscillator corresponding to each first acquisition moment when the time synchronization device is in the first state; calculating a target output frequency corresponding to the control moment according to the average frequency and the predicted frequency deviation corresponding to the control moment; Calculating output compensation voltage corresponding to the control moment according to the target output frequency corresponding to the control moment and a preset sensitivity coefficient; And controlling the crystal oscillator to keep time according to the output compensation voltage corresponding to the control moment.
- 8. The time keeping method of claim 6, wherein after obtaining the target reference time corresponding to the first acquisition time, the method further comprises: and carrying out time keeping and taming on the crystal oscillator according to the target reference time corresponding to the first acquisition time.
- 9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 8 when executing the computer program.
- 10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the method according to any one of claims 1 to 8.
Description
Time keeping method, terminal equipment and computer readable storage medium Technical Field The present application relates to clock synchronization, and more particularly, to a time keeping method, a terminal device, and a computer readable storage medium. Background In the digital transformer station and the intelligent power grid, the cooperative operation of relay protection, fault wave recording, measurement and control, monitoring, communication equipment and the like is dependent on a unified and high-precision time reference, and the time synchronization precision reaches microsecond level. Currently, time synchronization devices typically utilize a Beidou satellite system as a source of time reference. In complex station areas, satellite signals are susceptible to electromagnetic interference, weather changes, building shielding or fraudulent signals, resulting in loss of reception and interruption of timing. When the external reference time source fails, the time synchronization device is in time conservation by depending on a crystal oscillator of the time synchronization device. However, the existing time keeping mode based on the crystal oscillator cannot adapt to dynamic environment changes, and particularly, the time keeping precision is low under the condition of long-time step-out. Disclosure of Invention The embodiment of the application provides a time keeping method, terminal equipment and a computer readable storage medium, which can effectively improve time keeping precision. In a first aspect, an embodiment of the present application provides a time keeping method, which is applied to a time synchronization device, where the time synchronization device includes a crystal oscillator, and the time keeping method includes: The method comprises the steps of switching a time synchronization device from a first state to a second state, acquiring a prediction model trained based on first acquired data when the time synchronization device is in the first state, wherein the time synchronization device is in the first state and is in time keeping based on an external reference time source, the time synchronization device is in time keeping based on the crystal oscillator in the second state, the first acquired data comprises a plurality of first data packets corresponding to first acquisition moments, each first data packet corresponding to the first acquisition moment comprises a target reference time corresponding to the first acquisition moment, environment data and a historical frequency deviation sequence between crystal oscillator frequency of the crystal oscillator and the external reference time source, and the prediction model is used for predicting frequency deviation between the crystal oscillator and the external reference time source according to the target reference time, the environment data and the historical frequency deviation sequence; Acquiring target data, wherein the target data is a latest group of first data packets acquired before the time synchronization device enters the second state; According to the target data and the prediction model, the prediction frequency deviation corresponding to each control moment in the second state is obtained in sequence; And in the second state, controlling the time synchronization device to keep time according to the predicted frequency deviation corresponding to each control moment. In the embodiment of the application, when the time synchronization device is switched to a state (namely a second state) of keeping time based on the self crystal oscillator, the frequency deviation is predicted according to the latest collected data before the time synchronization device enters the second state, and the data collected before the time synchronization device enters the second state is actual data, so that the frequency prediction is performed by taking the data as a reference, which is equivalent to determining more accurate reference data for prediction, and a reliable data basis is provided for subsequent keeping time. In addition, after entering the second state, the frequency deviation is predicted according to the trained prediction model, and the prediction model is trained according to the historical target reference time, the historical environment data and the historical frequency deviation sequence, so that the frequency deviation predicted by the prediction model can adapt to dynamic environment change and is relatively close to the law of the historical frequency deviation, and the time keeping precision of the crystal oscillator can be effectively improved. In a possible implementation manner of the first aspect, the method further includes: When the time synchronization device is switched from the second state to the first state, second acquired data of the time synchronization device are acquired, wherein the second acquired data comprise a plurality of second data packets corresponding to second acquisition moments, and e