A kind of precision time service method based on GPSTechnical field
The present invention relates to a kind of time service field, particularly a kind of precision time service method based on GPS.
Background technology
Along with the development of science and technology, the exact requirements of all trades and professions to the time is more and more higher, as Aero-Space, deep space communication, information superhighway, navigational communications, electric power transfer etc.GPS exports synchronous time mark PPS signal and NMEA-0813 protocol massages (containing the information such as UTC time, position in message) accurately by decode satellite signals, along with GPS integrated level is more and more higher, price is more and more lower, GPS is adopted to be the technological means that this area is commonly used as the technology path of information terminal precision time service, namely in the application scenario that required precision is not high, only resolve its NMEA-0813 protocol massages exported and obtain the UTC time (this scheme time error has hundreds of millisecond).
Usually, PPS signal accuracy can reach nanosecond, NMEA-0813 protocol massages is producing high level PPS signal and is exporting after keeping 100ms duration, requires higher application scenario at time service precision, often adopts and realizes precision time service in conjunction with PPS signal or other supplementary meanss etc.As patent 01134726.0 provides a kind of gps satellite time service telemetering seismograph, realize synchrodata measurement, record, synchronization timing detonates; In December, 2002, once auspicious monarch, Yin Xianggen, K.K.Li etc. delivered " gps clock on-line monitoring and modification method " at " Proceedings of the CSEE ", labor describes the influencing factor of gps clock error, and point out to promote the application of gps clock in essential industry field, need solve two problems: the Real-Time Monitoring of gps clock and error compensation, article proposes to adopt High Precision Crystal Oscillator to carry out monitoring and the simple and practical method corrected to gps clock, set up the measurement model of gps clock error, achieve a kind of production method of high precision clock; ZL200710180533.2 discloses a kind of high-accuracy data receiving time service instrument, the pulse per second (PPS) information of GPS and absolute time information is passed to admission control board the internal clocking of Corrective control plate, to meet required precision not higher than for 1 × 10-4second application scenario, provide asynchronous serial test interface and the true value equipment do not fixed higher than 38400bps, test frame length of traffic rate or equipment under test export the admission of data; Patent ZL200710176937.4 provides a kind of chip-scale time service based on GPS receiver and synchronous method and equipment thereof, to meet the requirement of low cost, an one embodiment when using ordinary temp to compensate crystal oscillator (0.5PPM), can realize the time service precision of 200ns rank and the synchronization accuracy of 50ns rank; ZL200810060615.8 provides a kind of based on the device of GPS technology to ammeter time service, for ensureing the precision of time service, utilize the time delay that fixing offset compensation MCU and ammeter call duration time produce, specifically adopt PPS signal triggered interrupts, the current time information of inside is all stored, to the time used of having decoded, the temporal information obtained decoding again after the message information that GPS is sent all decodes out can ensure that the clock of MCU inside and gps clock keep more consistent than height (error is within 1us) after adding and triggering.In recent years, document is had to disclose high accuracy time service solution based on the Big Dipper and GPS dual-mode, to meet the application demand of different industries successively.
Therefore, according to feature and the required precision of sector application, how to use lower cost to realize the time service of degree of precision, remain an of great value research.
Summary of the invention
The object of the invention is do not increasing under auxiliary equipment prerequisite, by adopting the PPS signal of GPS and NMEA-0813 message protocol, in conjunction with the RTC clock of MCU microprocessor and interrupt mechanism, realize the precise synchronization in zero second per minute moment, thus reach the low cost precision time service effect meeting sector application.
For achieving the above object, design technology project of the present invention is:
A kind of information terminal is made up of GPS module 101, MCU microprocessor 102, power module 103 and crystal oscillator 104, power module 103 is connected with GPS module 101, MCU microprocessor 102 respectively, MCU microprocessor 102 is connected with GPS module 101, crystal oscillator 104, wherein the PPS signal pins of GPS module 101 is connected with the INT pin that MCU microprocessor 102 has interrupt function, the UART pin of GPS module 101 and the UART pin of MCU microprocessor 102, the inner RTC module of MCU microprocessor 102 is connected with crystal oscillator 104.
Described MCU microprocessor, the INT pin interrupt priority level that it is connected with GPS module PPS signal is not set as the highest.
Described MCU microprocessor, there is a RTC time clock feature unit with interrupt function inside, and the signal source of RTC clock is from crystal oscillator 104.
The UART pin of described MCU microprocessor is connected with GPS module UART pin, and MCU microprocessor is its output of channel reception NMEA-0813 protocol massages thus.
Described MCU microprocessor, after receiving complete GPS module NMEA-0813 protocol massages, starts GPS message data and resolves, obtain the UTC time in message.
Described MCU microprocessor, there is a synchronous calibration moment unit inside, and control information terminal carries out the operation moment of clock synchronous calibration; This synchronous calibration moment unit, unit is second, preservation be resolve obtain GPS message UTC time value after calculate the result of conversion, conversion formula is: 60-GPSUTC time second.
The operation moment of described clock synchronous calibration carries out in PPS signal interruption service routine in MCU microprocessor, after MCU microprocessor enters PPS signal interruption service routine, first whether the data of inspection synchronous calibration moment unit are 0, when not being 0, the data that synchronous calibration moment unit is preserved are carried out subtracting an operation, whether the data judging this synchronous calibration moment unit are again 0, if be 0, operate the Hour Minute Second assignment of GPSUTC time to the Hour Minute Second of RTC time, the millisecond simultaneously operating the RTC time resets, thus realize time synchronized and precision time service.
Compared with prior art, the invention has the beneficial effects as follows: overcome the hundreds of milliseconds of time errors of resolving merely UTC clock and causing from GPS message, and under not needing to increase other auxiliary equipment prerequisites, zero second per minute moment realized RTC clock and GPSUTC clock synchronous, reached more accurate time service effect.
Object of the present invention, feature and advantage also will be described in detail by reference to the accompanying drawings by embodiment.
Accompanying drawing explanation
Fig. 1 is hardware platform structure chart of the present invention.
Fig. 2 is GPS message data process of analysis figure of the present invention.
Fig. 3 is PPS signal interruption service procedure figure of the present invention.
Fig. 4 is RTC break in service flow chart of the present invention.
Embodiment
In Fig. 1,101 is GPS module, and 102 is MCU microprocessors, and 103 is power modules, and 104 is crystal oscillators, and PPS pin, the UART pin of 101 are connected with INT, UART pin of 102 respectively, and the RTC pin of 102 is connected with 104, and 103 are connected with 101 and 102 respectively.
In order to describe in more detail the present invention, be described further below in conjunction with Fig. 2, Fig. 3 and Fig. 4.
Step 201:GPS message data is resolved and is started, and performs step 202;
Step 202: judge whether there is the UTC time in GPS message, if do not had, then performs step 205, if had, then performs step 203;
Step 203: resolve and obtain UTC Hour Minute Second data, perform step 204;
Step 204: by UTC number of seconds according to substitution conversion formula, calculate and obtain the synchronous calibration moment, conversion formula is: synchronous calibration moment unit=60-GPSUTC time second, then performs step 205;
Step 205:GPS message data is resolved and is terminated.
The service of step 301:PPS signal interruption starts, and performs step 302;
Step 302: whether the data judging synchronous calibration moment unit are 0, are 0, then perform step 306, otherwise be not 0, performs step 303;
Step 303: the data of synchronous calibration moment unit carry out subtracting an operation, performs step 304;
Step 304: whether the data judging synchronous calibration moment unit are 0, is not 0 and performs step 306, otherwise be 0, perform step 305;
Step 305: when performing clock synchronous calibration operation, by the date Hour Minute Second assignment of GPSUTC time to the date Hour Minute Second of RTC clock, RTC clock millisecond resets, and performs step 305;
The service of step 306:PPS signal interruption terminates.
Step 401:RTC break in service second starts, and performs step 402;
Step 402: judged whether PPS pps pulse per second signal, if had, then performs step 404, otherwise performs step 403;
Step 403: use RTC clock as the time, perform step 404.
Step 404:RTC break in service second terminates.
Although the foregoing describe the specific embodiment of the present invention; but be familiar with those skilled in the art should be appreciated that; specific embodiment described by us is illustrative; instead of for limiting the scope of the invention; anyly inspire the equivalence done to modify by the technology of the present invention route and change, all should be encompassed in scope that the claims in the present invention protect.