Summary of the invention
In view of this, fundamental purpose of the present invention is to provide a kind of device and method of output time information, to solve when there is saltus step in the time service information of satellite signal receiving apparatus output, the problem of saltus step can appear in the time in the application system that needs high precision time service data of outputing to.
For achieving the above object, technical scheme of the present invention is achieved in that
The invention provides a kind of method of output time information, described method comprises: the time service data according to satellite signal receiving apparatus output are the soft time assignment in this locality; The soft time of described this locality was adjusted in real time according to the unit interval; Export the soft time of described this locality in real time.
In such scheme, described is local soft time assignment, comprise: the receiving satellite signal receiving trap is according to the time service data of unit interval output in real time, the time service data that receive are resolved obtain temporal information, and in real time the local satellite time of current preservation is updated to resulting temporal information; When upgrading local satellite time first, give the local satellite BACKUP TIME that is used for calibration with described local satellite time assignment, and according to the described local satellite BACKUP TIME of real-time adjustment of described unit interval; In real time local satellite time and the described local satellite BACKUP TIME that upgrades compared, when the continuous equal times of described local satellite time and described satellite BACKUP TIME reaches pre-configured assignment threshold value, verify that current synchronous mark is for false, represent current not assignment, then described local satellite time assignment is arrived the local soft time, synchronous mark is set simultaneously for true, finishes assignment.
In such scheme, described the soft time of described this locality was adjusted in real time according to the unit interval, be specially: when receiving the pps look-at-me of described satellite signal receiving apparatus output, described local satellite BACKUP TIME is increased the unit interval; Wherein, described satellite signal receiving apparatus is according to unit interval output pps look-at-me.
In such scheme, the described real-time output soft time of described this locality, be specially: break period of pre-configured timing interrupt counter, described timing interrupt counter was according to counting at interval the break period of disposing at interval, and carried out clear operation according to the unit interval; When the counting of described timing interrupt counter reaches the output threshold value that sets in advance, export the current local soft time.
In such scheme, described timing interrupt counter carries out clear operation according to the unit interval, be specially: when receiving the pps look-at-me of described satellite signal receiving apparatus output, the zero clearing of described timing interrupt counter, wherein, described satellite signal receiving apparatus is according to unit interval output pps look-at-me.
In such scheme, after being the soft time assignment in described this locality, described method also comprises: proofread and correct the soft time of described this locality in real time.
In such scheme, the described real-time correction soft time of described this locality, comprise: the receiving satellite signal receiving trap is according to the time service data of unit interval output in real time, the time service data that receive are resolved obtain temporal information, and in real time the local satellite time of current preservation is updated to resulting temporal information; When the counting of timing interrupt counter reaches predefined first corrected threshold, and when the counting that is used to indicate the equal times counter of correction reaches predefined second corrected threshold, give the local soft time with current local satellite time assignment, the soft time of described this locality is proofreaied and correct; Wherein, described timing interrupt counter is according to counting at interval pre-configured break period, and carries out zero clearing according to the unit interval; When the counting of described timing interrupt counter reaches predefined first corrected threshold, described equal times counter is counted or zero clearing: inconsistent at current local satellite time and local soft time, and when described local satellite time equates with described local satellite BACKUP TIME, described equal times rolling counters forward once, otherwise, described equal times counter O reset.
In such scheme, the described unit interval is second.
The present invention also provides a kind of device of output time information, and described device comprises: CPU, output interface, input interface, and wherein, input interface is used for connecting satellite signal receiving apparatus, receives the time service data of described satellite signal receiving apparatus output; CPU, the time service data for receiving according to described input interface are the soft time assignment in this locality, and the soft time of described this locality were adjusted in real time according to the unit interval; Output interface is used for the output soft time of described this locality in real time.
In such scheme, described CPU specifically is used for, and the time service data that described input interface is received are resolved and obtained temporal information, and in real time the local satellite time of current preservation is updated to resulting temporal information; When upgrading local satellite time first, give the local satellite BACKUP TIME that is used for calibration with described local satellite time assignment, and according to the described local satellite BACKUP TIME of real-time adjustment of described unit interval; In real time local satellite time and the described local satellite BACKUP TIME that upgrades compared, when the continuous equal times of described local satellite time and described satellite BACKUP TIME reaches pre-configured assignment threshold value, verify that current synchronous mark is for false, represent current not assignment, then described local satellite time assignment is arrived the local soft time, synchronous mark is set simultaneously for true, finishes assignment.
In such scheme, described CPU also is used for receiving described satellite signal receiving apparatus by the pps look-at-me of unit interval output, according to received pps break period, the soft time of described this locality is adjusted in real time.
In such scheme, described device also comprises: interrupt counter regularly, described timing interrupt counter be according to counting at interval the break period of disposing, and carry out clear operation according to the unit interval; Described CPU also is used for, and when the counting of described timing interrupt counter reaches the output threshold value that sets in advance, the current local soft time is exported by described output interface.
In such scheme, described CPU also is used for, and proofreaies and correct the soft time of described this locality in real time.
In such scheme, described device also comprises, the equal times counter, when the counting of described timing interrupt counter reaches predefined first corrected threshold, described equal times counter is counted or zero clearing: inconsistent at current local satellite time and local soft time, and described local satellite time is when equating with described local satellite BACKUP TIME, described equal times rolling counters forward is once, otherwise, described equal times counter O reset; Described CPU also is used for, and when the counting of described equal times counter reaches second corrected threshold, gives the local soft time with current local satellite time assignment, and the soft time of described this locality is proofreaied and correct.
The device of output time information of the present invention, time service data according to satellite signal receiving apparatus output, to the soft time assignment in this locality, and the soft time of this locality adjusted according to the unit interval, afterwards, export the local soft time to the system that needs precise time information and get final product, replace the directly time service data of output of satellite signal receiving apparatus by the soft time of this locality, even the generation saltus step of time service data or the mistake of satellite signal receiving apparatus output also can guarantee finally to export high temporal information accurately.
In addition; the present invention is according to the pps look-at-me of satellite signal receiving apparatus according to unit interval output; adjust the local soft time; guaranteed that the local soft time can add up at the orthochronous point; simultaneously by appropriate protection mechanism; when skew appears in soft time in this locality, the soft time of correcting local that again can be promptly and accurately, thus guarantee to export all the time high precision time information.
Embodiment
Basic thought of the present invention is: according to the time service data of satellite signal receiving apparatus output, be the soft time assignment in this locality, and receiving satellite signal receiving apparatus per second output pps once when interrupting, the local soft time increases by 1 second, the time service data that replaced satellite signal receiving apparatus output by the soft time of this locality, output to the system that needs time synchronized, as cdma system, so, utilize the steady characteristic of weak point of local soft time, in conjunction with the steady characteristic of length of the satellite time of satellite signal receiving apparatus output, the output shot and long term is stable split-second precision all, solve the problem that there is saltus step in time service data, improved time service precision.
Wherein, the method for output time information of the present invention with reference to shown in Figure 1, mainly may further comprise the steps:
Step 101: the time service data according to satellite signal receiving apparatus output are the soft time assignment in this locality;
Step 102: the soft time of described this locality was adjusted in real time according to the unit interval;
Step 103: export the soft time of described this locality in real time.
Wherein, process for the soft time assignment in this locality, can be: in real time the receiving satellite signal receiving trap be according to the time service data of unit interval output, the time service data that receive resolved obtain temporal information, and in real time the local satellite time of current preservation is updated to resulting temporal information; When upgrading local satellite time first, give the local satellite BACKUP TIME that is used for calibration with described local satellite time assignment, and according to the described local satellite BACKUP TIME of real-time adjustment of described unit interval; In real time local satellite time and the described local satellite BACKUP TIME that upgrades compared, when the continuous equal times of described local satellite time and described satellite BACKUP TIME reaches pre-configured assignment threshold value, verify that current synchronous mark is for false, represent current not assignment, then described local satellite time assignment is arrived the local soft time, synchronous mark is set simultaneously for true.
Here, the initial value of soft time of described this locality, local satellite time and local satellite BACKUP TIME all can be random time.In said process, the setting of described assignment threshold value can be determined according to actual needs.
Here, the time service data of satellite signal receiving apparatus output can comprise information such as time, longitude and latitude, current locking satellite quantity.
Here, described assignment threshold value can be determined according to practical situations, is carrying out assignment fast if desired, what this assignment threshold value can be arranged is smaller, if do not need to carry out fast assignment, require assignment more accurate, what then this assignment threshold value can be arranged is big.For example, can the assignment threshold value be set to 30 times, so, show begin to receive the time service data need be through 30 unit interval to assignment, if the unit interval is second, so, illustrate begin to receive the time service data need be through 30 seconds to assignment.
Wherein, the soft time of described this locality was adjusted in real time according to the unit interval, specifically: when receiving pulse per second (PPS) (pps, the pulses per second) look-at-me of described satellite signal receiving apparatus output, described local satellite BACKUP TIME is increased the unit interval; Wherein, described satellite signal receiving apparatus is according to unit interval output pps look-at-me.
Wherein, identical with the process of adjusting the soft time of described this locality according to the process of the described local satellite BACKUP TIME of real-time adjustment of described unit interval.
In the practical application, described satellite signal receiving apparatus is in unit interval edge output pps look-at-me, and the unit interval here generally is second.
Wherein, export the soft time of described this locality in real time, can be: break period of pre-configured timing interrupt counter, described timing interrupt counter be according to counting at interval the break period of disposing at interval, and carried out clear operation according to the unit interval; When the counting of described timing interrupt counter reaches the output threshold value that sets in advance, export the current local soft time.
Here, the output threshold value can according to break period of the timing interrupt counter that disposes at interval and the described unit interval determine, in the practical application, need and export the time that the local soft time will consume in conjunction with current reception time service data, local soft time of adjustment, and need the application system reception situations such as the local soft needed time of time of exporting of precise time information to determine.
Here, regularly be less than at interval the described unit interval, general, the described unit interval is the break period of the integral multiple at interval that disposes break period of interrupt counter.For example, when the described unit interval was second, selected proper the break period of described timing interrupt counter at interval between 4~25ms, configuration regularly interrupt counter break period be this area common technology means at interval, do not repeat them here.
Here, described timing interrupt counter carries out clear operation according to the unit interval, specifically: when receiving the pps look-at-me of described satellite signal receiving apparatus output, with the zero clearing of described timing interrupt counter, wherein, described satellite signal receiving apparatus is according to unit interval output pps look-at-me.
Wherein, after being the soft time assignment in described this locality, described method also comprises: proofread and correct the soft time of described this locality in real time.
Particularly, proofread and correct the process of soft time of described this locality, can be: the receiving satellite signal receiving trap be according to the time service data of unit interval output in real time, the time service data that receive are resolved obtain temporal information, and in real time the local satellite time of current preservation is updated to resulting temporal information;
When the counting of timing interrupt counter reaches predefined first corrected threshold, and when the counting that is used to indicate the equal times counter of correction reaches predefined second corrected threshold, give the local soft time with current local satellite time assignment, the soft time of described this locality is proofreaied and correct.
Wherein, described timing interrupt counter is according to counting at interval pre-configured break period, and carries out zero clearing according to the unit interval; When the counting of described timing interrupt counter reaches predefined first corrected threshold, described equal times counter is counted or zero clearing: inconsistent at current local satellite time and local soft time, and when described local satellite time equates with described local satellite BACKUP TIME, described equal times rolling counters forward once, otherwise, described equal times counter O reset.
Here, described first corrected threshold is by determining with the described unit interval at interval the break period of the timing interrupt counter that disposes, generally, described timing interrupt counter from zero count to first corrected threshold, the time interval of experiencing is more suitable near the described unit interval, so, can guarantee currently to have received the time service data and finished the renewal of local satellite time, local satellite BACKUP TIME and local soft time.
Described second corrected threshold generally determines according to practical situations, and is general, during configuration, according to coming at interval to determine the correction time of soft time of this locality.If require every 300 unit interval, proofread and correct once, so, can second corrected threshold be set to 300 times.
Accordingly, the present invention also provides a kind of device of output time information, and described device comprises: CPU, output interface, input interface, wherein, input interface is used for connecting satellite signal receiving apparatus, receives the time service data of described satellite signal receiving apparatus output; CPU, the time service data for receiving according to described input interface are the soft time assignment in this locality, and the soft time of described this locality were adjusted in real time according to the unit interval; Output interface is used for the output soft time of described this locality in real time.
In the practical application, described output interface and input interface specifically can be serial ports, Ethernet interface etc.
Wherein, described CPU specifically is used for, and the time service data that described input interface is received are resolved and obtained temporal information, and in real time the local satellite time of current preservation is updated to resulting temporal information; When upgrading local satellite time first, give the local satellite BACKUP TIME that is used for calibration with described local satellite time assignment, and according to the described local satellite BACKUP TIME of real-time adjustment of described unit interval; In real time local satellite time and the described local satellite BACKUP TIME that upgrades compared, when the continuous equal times of described local satellite time and described satellite BACKUP TIME reaches pre-configured assignment threshold value, verify that current synchronous mark is for false, represent current not assignment, then described local satellite time assignment is arrived the local soft time, synchronous mark is set simultaneously for true.
Here, described CPU also is used for receiving described satellite signal receiving apparatus by the pps look-at-me of unit interval output, according to received pps break period, the soft time of described this locality is adjusted in real time.
Wherein, described device also comprises: interrupt counter regularly, described timing interrupt counter be according to counting at interval the break period of disposing, and carry out clear operation according to the unit interval; Described CPU also is used for when the counting of described timing interrupt counter reaches the output threshold value that sets in advance the current local soft time being exported by described output interface.
Wherein, described CPU also is used for, and proofreaies and correct the soft time of described this locality in real time.
Here, described device also comprises, the equal times counter, when the counting of described timing interrupt counter reaches predefined first corrected threshold, described equal times counter is counted or zero clearing: inconsistent at current local satellite time and local soft time, and described local satellite time is when equating with described local satellite BACKUP TIME, described equal times rolling counters forward is once, otherwise, described equal times counter O reset; Described CPU also is used for, and when the counting of described equal times counter reaches second corrected threshold, gives the local soft time with current local satellite time assignment, and the soft time of described this locality is proofreaied and correct.
Realize the detailed process that temporal information is exported by above-mentioned device, please refer to above-mentioned method and describe, do not repeat them here.
Embodiment one
In the present embodiment, the process of output time information specifically can comprise the steps:
Step 1: the device of output time information is connected with satellite signal receiving apparatus, and carries out initialization operation;
Particularly, in the present embodiment, the connected mode in the device of output time information and the external world as shown in Figure 2, satellite signal receiving apparatus receives the signal that satellite sends by antenna, the device of the output time information in the present embodiment, its input port is connected with satellite signal receiving apparatus by physical link, its output port and the system's (not shown) that needs split-second precision information, as cdma system, connect.
Wherein, the device of described output time information mainly comprises an embedded type CPU, has connecting interface, timing interrupt counter and equal times counter on this CPU.Here, connecting interface mainly is input serial ports and output serial ports, wherein, the input serial ports is used for connecting described satellite signal receiving apparatus, the time service data of receiving satellite signal receiving trap output and other, the output serial ports is used for connecting the system that needs split-second precision information, outwards exports the local soft time.
The device of the described output time information of initialization comprises: the local soft time T 1 of initialization, and configuring external interrupts, and configuration is interval break period of interrupt counter regularly;
Here, the local soft time T 1 of initialization can be set to any one time with the soft time T 1 in this locality, for example, the initial value of the soft time T 1 in this locality can be made as 12 o'clock sharps of on January 1st, 2003;
Particularly, the configuring external interruption can be: the external interrupt that the pps look-at-me of satellite signal receiving apparatus is configured to described output time information device.Here, after the satellite signal receiving apparatus initialization, can export one time the time service data p.s., produce a pps look-at-me in the per second edge.
In the practical application, CPU has a plurality of interrupt pin, on the interrupt pin of CPU, if level generation saltus step will trigger an interruption.The pps output port of satellite signal receiving apparatus is connected on the interrupt pin of CPU, when the second of satellite time, the edge arrived, the pps look-at-me generation saltus step that satellite signal receiving apparatus produces, and output on the interrupt pin of CPU, CPU will produce interruption, like this, make the device unit interval of output time information be second, and can be synchronous with the unit interval of satellite.
Particularly, configuration regularly is spaced apart 4ms the break period of interrupt counter, like this, will produce 250 times at timing p.s. interrupt counter and regularly interrupt, and is equivalent to per second is divided into 250 timeslices.
Fig. 3 is the timing distribution figure of present embodiment, and wherein, it is the sequence of unit that sequential is divided into the second by the pps look-at-me, and in each second, is timed again and interrupts being divided into 250 timeslices, and each timeslice length is 4ms.
Here, the size at timing interrupt counter interval break period, the actual CPU that is limited by current output time information device.If timing interrupt counter break period of configuration is too little at interval, 1ms for example then interrupts too frequently, can influence the external response speed of described device; If timing interrupt counter break period of configuration is too big at interval, 100ms for example, then granularity is too thick, and in time handle the back of can't arriving in the time service data of satellite signal receiving apparatus output.Generally, timing interrupt counter break period of configuration is proper between 4~25ms at interval, configuration regularly interrupt counter break period be this area common technology means at interval, the CPU difference of carrying, concrete collocation method is also just different.
Step 2: the time service data according to satellite signal receiving apparatus output are the soft time assignment in this locality;
Particularly, be the process of the soft time assignment in this locality, as shown in Figure 4, idiographic flow is as follows:
S401: current when receiving the pps look-at-me, judge the time service data that whether received described satellite signal receiving apparatus output last one second, if then continue S402; Otherwise, finish current flow process;
Particularly, time service data of satellite signal receiving apparatus per second output when whenever receiving the time service data, trigger the serial ports interrupt function, and the then current sign that is used for the reception of expression data is set to true, and during initialization, this sign is set to false.
Satellite signal receiving apparatus per second edge can produce the pps look-at-me one time, receive the pps look-at-me at every turn, trigger the pps interrupt function, judge the sign state that current described expression data receive, if the state of described sign is true, the time service data that illustrate one second are received, then reset this and are masked as false; If described sign is current to be false, show that one second time service data are not normally received.
S402: resolve received time service data, obtain temporal information, and local satellite time Ts is updated to resulting temporal information;
Particularly, when whenever receiving the time service data, trigger the serial ports interrupt function, the time service data that receive are resolved, obtain temporal information, and resulting temporal information is preserved as local satellite time Ts.
Here, the initial value of local satellite time Tb can be the random time value.
S403: give local satellite BACKUP TIME Tb with described local satellite time Ts assignment;
Particularly, this step also is to realize by triggering the serial ports interrupt function.
Here, the initial value of local satellite BACKUP TIME Tb can be the random time value.
S404: judge whether current sync id is false, if then continue S405; Otherwise, finish current assignment flow process;
Here, whether sync id is used for expression current to the soft time assignment in this locality, and when initial, this sync id is false, shows also not to soft time T 1 assignment in this locality.When initially powering on, sync id all is false at every turn, synchronously after, this sign is made as very.
S405: described local satellite time Ts and described local satellite BACKUP TIME Tb are compared, when local satellite time Ts equates with described local satellite BACKUP TIME Tb, detect described local satellite time Ts and whether reach the assignment threshold value that sets in advance with the number of times that described local satellite BACKUP TIME Tb equates continuously, if, then continue S406, otherwise, continue S408;
Here, can count with the number of times that described local satellite BACKUP TIME Tb equates continuously local satellite time Ts by the counter that is used for assignment, this counter is relatively obtaining local satellite time Ts and described local satellite BACKUP TIME Tb when unequal, zero clearing at every turn; Relatively obtain when local satellite time Ts equates with local satellite BACKUP TIME Tb, counting once at every turn.When the counting of described counter for assignment reaches the assignment threshold value that sets in advance, continue S406, otherwise, continue S408.
In the present embodiment, can described assignment threshold value be set to 30 times, in the practical application, determine according to practical situations.
S406: be local soft time T 1 with described local satellite time Ts assignment, and described synchronous mark is set to very, shows local soft time T 1 assignment, finish the assignment of local soft time.
S407: the soft time T 1 in this locality and local satellite BACKUP TIME Tb are respectively increased by 1 second, finish current flow process;
S408: described local satellite BACKUP TIME Tb is increased by 1 second;
S409: when receiving next pps look-at-me, receive the time service data, resolve received time service data, obtain temporal information, and local satellite time Ts is updated to resulting temporal information, return S404.
Particularly, the implementation procedure of the specific implementation process of S409 and S401~402 is identical.
Here, according to above-mentioned flow process, per second all can upgrade once local satellite time Ts, when the number of times that equates continuously at local satellite time Ts and local satellite BACKUP TIME Tb reaches 30 times, give local soft time T 1 with local satellite time Ts assignment, so, can either guarantee the accuracy of assignment, can also be in the back that powers on rapidly for local soft time assignment, in order to can export orthochronous fast.
Step 3 is in real time by second local soft time of adjustment;
Particularly, satellite signal receiving apparatus per second edge can produce the pps look-at-me one time, whenever receive the pps look-at-me of a satellite signal receiving apparatus output, trigger the pps interrupt function, the soft time T 1 in this locality and local satellite BACKUP TIME Tb are all increased by 1 second, so, make the local soft time to increase with the time synchronized of satellite output, guarantee the real time execution of local soft time.
Step 4: export the local soft time in real time;
Particularly, whenever reach once default output threshold value at the counting of timing interrupt counter, just output local soft time once.
Particularly, whenever receive the pps look-at-me one time, trigger the pps interrupt function, with the zero clearing of described timing interrupt counter once, after the zero clearing, regularly interrupt counter can be according to restarting counting pre-configured break period at interval.If be spaced apart 4ms the break period of disposing, then every 4ms, regularly the interrupt counter counting once when the number of times of described timing interrupt counter counting is added to default output threshold value, is just exported the once local soft time.
In the present embodiment, export threshold value and be set to 10 times, reach at 10 o'clock at each regularly interrupt counter counting, just the 40ms after at every turn receiving the pps look-at-me exports once local soft time T 1.
In actual the use, described pps look-at-me and local soft time T 1 can be exported together.Pps look-at-me and local soft time T 1 can also be distributed to each distributed system, like this, each distributed system just can be shared a time source, thereby can effectively reducing the construction costs.
Here, because the distribution of temporal information need consume the transmission time, when time information arrived goal systems, reality was out-of-date, therefore, need distribute the pps look-at-me simultaneously, so that goal systems can be known the current overtime time.
Wherein, after the soft time assignment to this locality, present embodiment can also comprise: the process that the soft time T 1 in this locality is proofreaied and correct.Particularly, as shown in Figure 5, the flow process that the soft time T 1 in this locality is proofreaied and correct is as follows:
S501: whether the checking regularly counting of interrupt counter reaches the first default corrected threshold 200, if, continue S502, otherwise, current flow process finished;
Here, in edge moment second of absolute time, when just the pps look-at-me arrived, satellite signal receiving apparatus can't be exported the time service data at once, often needed to handle through a series of data, needed the consumption regular hour; And, after the time service data of receiving satellite signal receiving trap output, also need the time service data are resolved, obtain temporal information, upgrade local satellite time, this a series of processing procedure also needs elapsed time.Consider above-mentioned situation, in the present embodiment, first corrected threshold is set to 200, be spaced apart 4ms the break period of current timing interrupt counter, just receive the 800ms after the pps look-at-me, guaranteeing that the time service data in current second receive, and the renewal of local satellite time is also finished.
S502: verify whether current local soft time T 1 equates with local satellite time Ts, if, then continue S507, otherwise, S503 continued;
S503: verify whether local satellite BACKUP TIME Tb equates with local satellite time Ts, if, then continue S504, otherwise, S507 continued;
S504~505: the equal times counter is added up 1, and verify whether the counting of equal times counter reaches the second default corrected threshold 300, if, continue S506, otherwise, S501 returned;
Here, can add up 1 time at equal times counter per second, if the counting of equal times counter reaches 300, namely in 300 seconds (5 minutes) in the past, local satellite time Ts and local satellite BACKUP TIME Tb always are and equate, illustrate that current local satellite time Ts is accurately.And this moment, local soft time T 1 is unequal with local satellite time Ts, illustrates that then skew appearred in the local soft time, needs to proofread and correct.
S506: give local soft time T 1 with current local satellite time Ts assignment, finish the trimming process of soft time of current this locality;
S507: zero clearing equal times counter, return S501.
The above is preferred embodiment of the present invention only, is not for limiting protection scope of the present invention, all any modifications of doing within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.