A kind of quick high accuracy time service method of Embedded GPS terminal

文档序号:1754768 发布日期:2019-11-29 浏览:38次 中文

阅读说明:本技术 一种嵌入式gps终端的快速高精度授时方法 (A kind of quick high accuracy time service method of Embedded GPS terminal ) 是由 吴允平 王廷银 苏伟达 郎毅 李汪彪 张国栋 于 2018-05-22 设计创作,主要内容包括:本发明涉及一种嵌入式GPS终端的快速高精度授时方法,由GPS模块、微处理器、电源模块组成,电源模块分别和GPS模块、微处理器相连,微处理器和GPS模块相连。微处理器有一个定时器1,当进入定时器1中断时,对GPS数据进行解析处理,获得UTC时间及设置IsGPS_Time;还有一个定时器0中断计数器T<Sub>count0</Sub>,当进入INT中断服务时,读取的定时器0计数值和T<Sub>count0</Sub>用于计算时间长度T<Sub>pps</Sub>。当满足设定条件时就将GPS UTC时间给RTC的相应单元,同时将RTC的毫秒、微秒清零。采用本发明的有益效果是:无需增加其他辅助设备,每秒实现授时操作,具有快速、高精度的应用效果。(The present invention relates to a kind of quick high accuracy time service methods of Embedded GPS terminal, are made of GPS module, microprocessor, power module, and power module is connected with GPS module, microprocessor respectively, and microprocessor is connected with GPS module.Microprocessor has a timer 1, when entering the interruption of timer 1, carries out dissection process to GPS data, obtains UTC time and setting IsGPS_Time;There are one 0 interrupt counter T of timer count0 , when entering INT interruption service, 0 count value of timer and T of reading count0 For calculating time span T pps .When meeting setting condition just by GPS UTC time to the corresponding units of RTC, while the millisecond of RTC, microsecond being reset.Using the beneficial effects of the present invention are: without increasing other ancillary equipments, realization time service operation per second has quick, high-precision application effect.)

1. a kind of quick high accuracy time service method of Embedded GPS terminal, is made of microprocessor, GPS module, power module, Power module is connected with GPS module, microprocessor respectively, and microprocessor is connected with GPS module, wherein the PPS signal of GPS module Pin with microprocessor there is the INT pin of interrupt function to be connected, and the UART pin of GPS module and the UART of microprocessor draw Foot is provided with 16 timers 0 in microprocessor, and the least count period is Tf, UART one word of reception of microprocessor It is T the time required to sectionUART, it is characterised in that:

1) microprocessor described in is provided with 0 interrupt counter T of timer 0 and timercount0;0 initial value of timer is 0, The least count period is Tf, unit is microsecond, interrupt cycle 216×Tf;When timer 0, which interrupts, to be occurred, timer 0 is interrupted Counter Tcount0It is accumulative to add one;

2) microprocessor described in is provided with a timer 1, if the time of 1 interrupt cycle of timer is T1 milliseconds, T1 range It is 1~50 millisecond, time T1=n × T of 1 interrupt cycle of timerUART, n range is 1.1~50;

3) microprocessor has a GPS data time resolution effective marker IsGPS_Time, interrupts service journey when entering timer 1 When sequence, it is first shut off the interruption of timer 1 and enables, the data in buffer area are received to GPS data, are advised according to NMEA-0813 agreement Model carries out dissection process, obtains the UTC time in message;If obtaining effective GPS UTC time, IsGPS_ is just set Time is True, and it is False that IsGPS_Time, which is otherwise arranged,;

4) microprocessor is first shut off timer when the INT interrupt service routine that the PPS signal entered by GPS module triggers 0, the count value for reading timer 0 is temporarily saved in Timer0, then calculates the last time span interrupted and interrupted to this Tpps, unit is microsecond;The synchronous judgement of time service and operation are finally carried out again.

2. a kind of quick high accuracy time service method of Embedded GPS terminal according to claim 1, it is characterised in that described Last interrupt the time span T interrupted to thispps=(Tcount0×216+ Timer0) × Tf

3. a kind of quick high accuracy time service method of Embedded GPS terminal according to claim 1, it is characterised in that described The synchronous judgement of time service and operation, be when meeting 999990 < Tpps≤ 1000010 and IsGPS_Time=True, just by GPS The year, month, day, hour, min of UTC, second are assigned to the corresponding units of RTC clock functional unit, while the millisecond of RTC, microsecond is clear Zero.

Technical field

The present invention relates to a kind of satellite time transfer field, especially a kind of quick high accuracy time service side of Embedded GPS terminal Method.

Background technique

Time is that substance exists and one of essential characteristic of movement, be seven fundamental physical quantities of the International System of Units wherein it One, it is the highest fundamental physical quantity of current measurement accuracy;Precise time is even more the paving stone for pushing hi-tech development, is The important guarantee that mankind's Activities are smoothly carried out.

After the mankind enter information-intensive society, the step by step advance application of Internet of Things, more and more device distributions are each heavy Node is wanted, is then the big data service providing data foundation of industry, seems to be difficult to collect originally and make in center convergence again Data are easily used to play a great role now, these big datas from distributed apparatus are just gradually created for the mankind Make more values.In the entire system, it is necessary to the stringent synchronization of length of a game is ensured, if each distributed apparatus in system Do not have unified clock reference, then obtained measurement result is since timing differential will be unable to reflect truth, due to Each data can not react to be obtained at which moment, and the relevance just not determined between them, these final data just can not yet Play due effect.For example, accurate time synchronization is set for being related to many key foundations of national economy social safety Apply most important, such as communication system, electric system, (mobile communication needs accurate time synchronization to ensure base to financial system The synchronous operation stood, power network need accurate time synchronization effectively to transmit and distribute electric power, financial system needs precision Time synchronization is to ensure economic normal operation), high-precision Time Service System, which has become, measures a national science and technology water Flat most crucial technical indicator.

GPS receiver exports accurate synchronous time mark PPS signal and NMEA-0813 protocol massages by decoding satellite-signal (information such as UTC time, position are contained in message), as GPS receiver integrated level is higher and higher, price is lower and lower, embedding It has been technology hand commonly used in the art that the NMEA-0813 protocol massages for entering the parsing GPS receiver output of formula terminal, which obtain UTC time, Section.In general, PPS signal precision can reach nanosecond, NMEA-0813 protocol massages are to generate high level PPS signal and keeping It is exported after a few tens of milliseconds duration, in the more demanding application of time service precision, often using combining PPS signal or other are auxiliary Assistant's section etc. realizes precision time service.In December, 2002, Zeng Xiangjun, Yin Xianggen, K.K.Li etc. were sent out at " Proceedings of the CSEE " Table " GPS clock on-line monitoring and modification method ", it is indicated that the influence factor of GPS clock error analyzes GPS clock important Application in industrial circle need to solve two problems: the real-time monitoring and error compensation of GPS clock, and article also uses high-precision brilliant Vibration is monitored and corrects to GPS clock, realizes a kind of production method of high precision clock;Document CN101202545B will The pulse per second (PPS) information and absolute time information of GPS passes to the internal clocking of admission control panel and Corrective control plate, to meet essence It spends of less demanding in being 1 × 10-4The application of second, it is thus achieved that a kind of high-accuracy data receiving time service instrument;Document CN101430372B provides a kind of chip-scale time service based on GPS receiver and synchronous method and its equipment, One embodiment using ordinary temp compensation crystal oscillator (0.5PPM) in the case where, realize 200ns rank time service precision and The synchronization accuracy of 50ns rank;Document CN100565390C is the precision for guaranteeing time service, is triggered and is interrupted using PPS signal, in The current time information in portion all stores, and decoding is obtained again after the message information that GPS is sent all decodes out Temporal information plus the time used is completed to decoding after triggering be that can guarantee that clock inside MCU and GPS clock keep ratio Height it is consistent;The high-precision timing scheme of document CN105281859B invention, is being not required to increase other ancillary equipment premises Under, it realizes that RTC clock is synchronous with GPS UTC clock at zero second moment per minute, reaches more accurate time service effect.

In recent years, the development of Internet of Things and cloud computing (service) changes obvious to all to every profession and trade bring, as support The Clock Synchronization Technology of one of technology, it has also become a big hot spot of current distribution application system research, researchers are increasingly Pay attention to realizing SOE(Sequence of Events, sequence of events recording in front end distributed terminal) function, accurate record and report Accuse preconfigured sensor, on-off model of state change etc., for object crash analysis provide it is clear, precisely effective Therefore how clue and evidence realize high-precision quick time service on existing Embedded GPS terminal formation base, are still One of great value research.

Summary of the invention

The purpose of the present invention is the PPS signals, decoding NMEA- on existing built-in terminal formation base, around GPS A kind of time service method that 0813 protocol massages are realized, meets the quick requirement of high-precision time service.

In order to achieve the above objectives, the technical scheme is that

A kind of Embedded GPS terminal, is made of microprocessor, GPS module, power module, power module respectively with GPS module, Microprocessor is connected, and microprocessor is connected with GPS module, and wherein the PPS signal pin and microprocessor of GPS module, which have, interrupts The INT pin of function is connected, and the interrupt priority level for setting INT pin is not highest;The UART pin and micro process of GPS module The UART pin of device is connected, and the microprocessor NMEA-0813 agreement report that thus channel is exported with interrupt mode reception GPS module Text, it is T that UART, which receives a byte required time,UART, unit is millisecond;Microprocessor is internally provided with a RTC clock function Energy unit, is made of, technical solution of the present invention is characterized in year, month, day, hour, min, second, millisecond, microsecond;

1) microprocessor is provided with 0 interrupt counter T of timer 0 and timercount0, 0 initial value of timer is 0, most Subtotal one number time is Tf, usually closely related with crystal oscillator frequency, unit is microsecond, and the interrupt cycle of timer 0 is 216×Tf;It is fixed When device 0 interrupt counter Tcount0, the interruption times of recording timer 0;When timer 0, which interrupts, to be occurred, timer 0 interrupts meter Number device Tcount0It carries out adding up to add one.

The microprocessor is provided with a timer 1, if the time of 1 interrupt cycle of timer is T1 milliseconds, with UART Serial ports is related the time required to receiving a byte, are as follows: T1=n × TUART, n range are as follows: 1.1~50, T1 range are 1~50 millisecond.

The microprocessor has a GPS data to receive buffer area, when the UART serial ports of microprocessor interrupts primary receive One byte, received content order save GPS data and receive buffer area, and timer 1 can all be reset by receiving to interrupt every time Initial value, setting opening timing device 1 run and setting interrupt it is enabled.

The microprocessor has a GPS data time resolution effective marker IsGPS_Time, when in entrance timer 1 When disconnected service routine, it is first shut off the interruption of timer 1 and enables, the data in buffer area are received to GPS data, according to NMEA- 0813 protocol specification carries out dissection process, obtains the UTC time in message;If obtaining effective GPS UTC time, just set Setting IsGPS_Time is True, and it is False that IsGPS_Time, which is otherwise arranged,.

The microprocessor is first shut off when the INT interrupt service routine that the PPS signal entered by GPS module triggers Timer 0, the count value for reading timer 0 are temporarily saved in Timer0;Then calculate it is last interrupt to this interrupt when Between length Tpps, unit is microsecond, calculates TppsFormula are as follows: (Tcount0×216+ Timer0) × Tf;It is same that time service is finally carried out again Step judgement and operation, i.e., as 999990 < T of satisfactionpps≤ 1000010 and IsGPS_Time=True, just by the year of GPS UTC, The moon, day, when, minute, second is assigned to the corresponding units of RTC, while the millisecond of RTC, microsecond being reset.

Compared with prior art, the beneficial effects of the present invention are: on existing built-in terminal formation base, without increasing Other ancillary equipments are decoded after judging that GPS message finishes receiving in 1 interrupt service routine of timer of microprocessor , it is interrupted in service in the INT of the PPS signal triggering microprocessor of GPS and decides whether that time service is grasped according to GPS message decoding result Make, there is quick, high-precision application effect.

The purpose of the present invention, feature and advantage will be described in detail by embodiment and in conjunction with attached drawing.

Detailed description of the invention

Fig. 1 is hardware platform structure chart of the invention.

Fig. 2 is that timer 1 of the invention interrupts service flow diagram.

Fig. 3 is that PPS signal of the invention interrupts service flow diagram.

Fig. 4 is that timer 0 of the invention interrupts service flow diagram.

Fig. 5 is that serial ports of the invention receives interruption flow chart.

Specific embodiment

In Fig. 1,101 be GPS module, and 102 be microprocessor, and 103 be power module, the PPS pin of GPS module (101), UART pin is connect with the INT pin of microprocessor (102), UART pin respectively, power module (103) respectively with GPS module (101) it is connected with microprocessor (102).

In order to describe in more detail the present invention, it is described further below with reference to Fig. 2, Fig. 3, Fig. 4 and Fig. 5.

Step 201: entering 1 interrupt service routine of timer, execute step 202;

Step 202: Off Timer 1 is interrupted, and is parsed to GPS receiver buffer area, and step 203 is executed;

Step 203: judging to detect whether data in buffer area have 0x0D, 0x0A, if it is thening follow the steps 204, otherwise execute Step 209;

Step 204: judge whether verification is correct, it is no to then follow the steps 209 if it is thening follow the steps 205;

Step 205: judge whether type of message is GPRMC, it is no to then follow the steps 206 if it is thening follow the steps 207;

Step 206: judge type of message it is no be for GPGGA, it is no to then follow the steps 209 if it is thening follow the steps 207;

Step 207: judge whether GPS effectively and obtains UTC time, it is no to then follow the steps 209 if it is thening follow the steps 208;

Step 208: setting IsGPS_Time is True, executes step 210;

Step 209: setting IsGPS_Time is False, executes step 210;

Step 210: timer 1, which interrupts service, to be terminated;

Step 301: entering PPS signal and interrupt service, execute step 302;

Step 302: Off Timer 0 reads 0 count value of timer and saves, and setting 0 initial value of timer is 0, and timer is arranged 0 opens operation, executes step 303;

Step 303: according to formula: Tpps=(Tcount0×216+ Timer0) × Tf, calculate PPS signal twice and interrupt duration Tpps, hold Row step 304;

Step 304: judging TppsWhether greater than 999990 and less than or equal to 1000010, if it is thening follow the steps 305, otherwise hold Row step 307;

Step 305: judge whether IsGPS_Time variable is True, it is no to then follow the steps 307 if it is thening follow the steps 306;

Step 306: with GPS UTC time assignment to RTC, millisecond, microsecond unit being reset, step 307 is executed;

Step 307: it removes serial ports and receives buffer area:

Step 308:PPS signal interruption service terminates;

Step 401: entering timer 0 and interrupt service;

Step 402:Tcount0Value plus one;

Step 403: timer 0, which interrupts service, to be terminated;

Step 501: entering serial ports and receive interrupt service routine, execute step 502;

Step 502: reading a byte, be saved in GPS data and receive buffer area, receive buffer pointer and move back, reset 1 initial value of timer, setting timer 1 start, and setting timer interruption is enabled;

Step 503: serial ports, which receives the service of interruption, to be terminated.

Although specific embodiments of the present invention have been described above, those familiar with the art should be managed Solution, we are merely exemplary described specific embodiment, rather than are used for limiting the scope of the invention, any to be sent out by this Bright technology path inspires made equivalent modification and variation, should all cover the range protected in the claims in the present invention It is interior.

8页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种动态可配置的冗余IO模块的方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!