The content of the invention
The present invention is directed to deficiency of the prior art, there is provided a kind of pulse per second (PPS) encodes setting means, it is only necessary to by logical
Letter bus allow host node to from node transmit whole pulse per second (PPS) just can be accurate pair when, make host node synchronous with from node time, it is our
Method need not increase other communication hardwares, greatly reduce cost during synchronous pair of distributed system.
In order to solve the above-mentioned technical problem, the present invention is addressed by following technical proposals:A kind of pulse per second (PPS) coding pair
Shi Fangfa, it is characterised in that host node control node level is reception state from node and described is adopted from node to node level
With rising edge interrupt processing, specifically comprising following steps:
Step A):Described host node is in time t0Lifting section level point, while by communication bus master time t0
It is broadcast to by way of whole pulse per second (PPS) all described from node;
Step B):Described triggers interruption from node when level is driven high, and retains current from node time t1;
Step C):It is described that the t that the host node is broadcast in a manner of whole pulse per second (PPS) is received from node0Afterwards, preserve now
From node time t2, by the way that new lock in time t is calculatedIt is synchronous=t2+(t0-t1)。
In above-mentioned technical proposal, it is preferred that it is described to be divided into whole number of seconds S, two sections of millisecond number MS from node time, with
Symbol A:B forms represent that then current time is S:MS;When it is described receive whole pulse per second (PPS) from node when, if now
Millisecond MS<500, it is S to set the time now:0, as now millisecond MS>500, it is S+1 to set the time now:0.
In above-mentioned technical proposal, it is preferred that t is transmitted in described whole pulse per second (PPS) in a manner of encoding0The UTC number of seconds of time,
And by following coding:
Setting be encoded to 1 and 0 composition, when for 1 when transmit the whole pulse per second (PPS), when for 0 when do not transmit the whole pulse per second (PPS),
Transmit t0Temporal information needs 70 bits data altogether, and both described host node transmitted t by the whole pulse per second (PPS)0Temporal information
Needed altogether from node 70 seconds to described, t0Coding is as follows respectively:
Frame head length 4bits, is encoded to 0111;
Time span 64bits, UTC time, which is converted into after 2 systems, needs 32bits, and the code 1 in 32bits data is with 01
Represent, code 0 represents with 10, both now each bit come with 2 bits it is encoded translated, then from the past high position sequence of low level;
Even parity check length 2bits, 1 is represented with 01 in the even parity check that UTC time is 32, and 0 is represented with 10.
In above-mentioned technical proposal, it is preferred that the t0Time when time is first bit (value is 0) for transmitting frame head.
In above-mentioned technical proposal, it is preferred that it is described to be decoded since when node receives continuous three whole pulse per second (PPS)s, and
Using first received whole pulse per second (PPS) time+1s as t1Time.
In above-mentioned technical proposal, it is preferred that the whole pulse per second (PPS) time received from node when even parity check to the end encodes
For t2Time, both transmit t0Time during last bit of time encoding.
The lock in time of this method is defined by host node, while respectively from node also in the independence maintenance time, and each node is inclined
Difference is within 100ppm (the most deviation 0.1ms of 1s).This method is by temporal information (t0) after coding by way of whole pulse per second (PPS)
It is broadcast to from node.Temporal information coding using Binary Zero, 1 represent, and assert when for 1 when transmit the whole pulse per second (PPS), when
For 0 when do not transmit the whole pulse per second (PPS).The 32bits follow-up code of sequeling of UTC time binary code is obtained, is 01,0 for 10 with 1
Temporal information is extended for 64bits binary code, and it is because continuous three are not present in 64bits temporal informations so to set
111 codings, and frame head 4bits is encoded to 0111, so can is learnt after three whole pulse per second (PPS)s are continuously received from node
What is received is frame head, so as to start to decode.The time t for the temporal information for receiving frame head is preserved from node1With received even school
Test temporal information t2, by calculating t2+(t0-t1) lock in time to the end.Whole temporal information stream has 70bits, passes through
Whole pulse per second (PPS) transfer mode needs to cause after 70s all synchronous with master time from node.Simultaneously first is received from node
When whole pulse per second (PPS), if now millisecond MS<500, it is S to set the time now:0, as now millisecond MS>500, this is set
When time be S+1:0, due to receiving after first whole pulse per second (PPS) just so that millisecond number is changed into 0 so that in synchronous phase
Number of seconds will not changed.By this set, the whole pulse per second (PPS) of host node transmitting can be each received from node, with for the moment
Carried out in section time calibration, the same deadline at time point is synchronous.Again because whole pulse per second (PPS) is precise and stable, by this method
Synchronous time deviation rate is low, and accuracy is high, does not have to extra communication device again, both reduces hardware cost, also reduce because
For time synchronized deviation caused by communication delay.
Compared with prior art, the beneficial effects of the invention are as follows:Only need by communication bus by host node to from node
Whole pulse per second (PPS) is transmitted when just can be accurate pair, makes host node synchronous with from node time, it is hard that this method need not increase other communications
Part, greatly reduce cost during synchronous pair of distributed system.