The content of the invention
The technical problem to be solved in the present invention and the technical assignment proposed are prior art to be improved with being improved,
A kind of setting means based on NTP networks are provided, purpose during reaching accurate pair.Therefore, the present invention takes following technical side
Case.
A kind of setting means based on NTP networks, it is characterised in that comprise the following steps:
A) main website sends the request of inquiry precision clock to terminal, and records the time for sending request;
B) terminal receives the inquiry precision clock request of main website;
C) request of the inquiry precision clock of terminal replies main website, reply request bag receives inquiry precision clock containing terminal please
The time that the time and reply asked send;
D) main website receives the request reply of terminal transmission, and records request and reply the time received, repeats a), b), c), d)
Until number of repetition reaches setting number;
E) main website calculates the time that main website transmits to the network of terminal, adjustment time deviation;
F) main website sends the request of modification time deviation to terminal;
G) terminal check, and modification time;
H) main website inquiry terminal time;
I) terminal returns to terminal time to main website;
J) main website confirm terminal time it is correct after, to terminal send school when ask;
K) terminal is set time according to request during the school of main website to a meter;
L) terminal check.
As further improving and supplementing to above-mentioned technical proposal, present invention additionally comprises following additional technical feature.
When calculating the time that main website transmits to the network of terminal, d is madeiAnd liThe time delay with return information is respectively sent, and
If li=kdi;In first synchronization:
U1=T2,1-T1,1=d1+φ
V1=T4,1-T3,1=kd1-φ (1)
In second synchronization:
U2=T2,2-T1,2=d2+φ
V2=T4,2-T3,2=kd2-φ (2)
Obtained by formula (1), formula (2)
When calculating the time that main website transmits to the network of terminal, d is madeiAnd liThe time delay with return information is respectively sent, and
If li=kdi;At first;In synchronization, there is following relational expression
U1=T2,1-T1,1=d1+φ
V1=T4,1-T3,1=kd1-φ (1)
In second synchronization, there is following relational expression
U2=T2,2-T1,2=d2+φ
V2=T4,2-T3,2=kd2-φ (2)
First consider formula (1), give mono- suitable initial value of k, and solve formula (1), try to achieve a φ value;Again the φ tried to achieve
Value is updated in formula (2), is solved formula (2), is tried to achieve a new k value;Again the k value substitution formulas (1) tried to achieve, formula (1) is solved, is obtained
The φ value new to one;Then make a decision, if the front and rear φ value errors tried to achieve twice are sufficiently small, stop calculating;Otherwise, then
The secondary φ value substitution formulas (2) that will newly try to achieve, formula (2) is solved to obtain a new k value;So iterate solution, Zhi Daoman
The sufficient condition of convergence.
It is a kind of based on NTP networks pair when system, it is characterised in that:Including concentrator:For obtaining the time, to obtain when
Between carry out a time bias and message when generating school;It route Homeplug:The time compensates again during for school;Collection
Device:Message when handling carrier wave message and generating standard school;Described concentrator is provided with delivery time computing module:It passes through multiple
Main website request, terminal response are replied to calculate main website to the message transfer time of terminal, and the concentrator compensation time includes message biography
Send the time;Described concentrator, route Homeplug are in main website, and described collector is in terminal.
Collector is connected by RS485 with ammeter.
Beneficial effect:When the technical program makes the terminal accomplish accurate pair of second level by NTP correcting time in network algorithms, improve pair
Shi Jingdu, the accurate time of origin of the moments such as load, voltage, electric current amount data is obtained, improve the correctness that tou power price calculates.
Embodiment
Technical scheme is described in further detail below in conjunction with Figure of description.
The present invention comprises the following steps:
A) main website sends the request of inquiry precision clock to terminal, and records the time for sending request;
B) terminal receives the inquiry precision clock request of main website;
C) request of the inquiry precision clock of terminal replies main website, reply request bag receives inquiry precision clock containing terminal please
The time that the time and reply asked send;
D) main website receives the request reply of terminal transmission, and records request and reply the time received, repeats a), b), c), d)
Until number of repetition reaches setting number;
E) main website calculates the time that main website transmits to the network of terminal, adjustment time deviation;
F) main website sends the request of modification time deviation to terminal;
G) terminal check, and modification time;
H) main website inquiry terminal time;
I) terminal returns to terminal time to main website;
J) main website confirm terminal time it is correct after, to terminal send school when ask;
K) terminal is set time according to request during the school of main website to a meter;
L) terminal check.
As shown in figure 1, algorithm logic figure when being pair.
Pair when algorithm one:
Make diAnd liThe time delay with return information is respectively sent, and sets li=kdi.In first NTP synchronization, just like
Lower relational expression
U1=T2,1-T1,1=d1+φ
V1=T4,1-T3,1=kd1-φ (1)
In second NTP synchronization, there is following relational expression
U2=T2,2-T1,2=d2+φ
V2=T4,2-T3,2=kd2-φ (2)
4 equations and 4 unknown numbers are shared in formula (1) and (2), then are easily tried to achieve
Accordingly can be in the hope of k value
Exemplified by as shown in Figure 2, calculating process is illustrated, if equipment and the real time deviation of main frame are 10s, the
Sent during one NLP synchronization and the actual time delay of return information is respectively 2 seconds and 4 seconds, sent and return in second NLP synchronization
The actual time delay ceased of writing in reply is respectively 3 seconds and 6 seconds, and the actual value of ratio k is 2.
The time deviation φ and ratio k tried to achieve by formula (3) and (4) is respectively 10s and 2, that is, the result tried to achieve is completely accurate.
Certainly, this example is to have done idealization to handle, in other words, although algorithm is assumed to send and return information
Time delay has fixed ratio, but this ratio still has certain fluctuation in different NLP synchronizations in reality.Therefore, in reality
In the engineer applied on border, the time deviation φ obtained with the algorithm is not exactly equal to 10s's.But due to time delay ratio
The fixed hypothesis of example is still to have realistic basis, and the time deviation φ that the algorithm is obtained necessarily extremely approaches actual value.
The advantages of algorithm is only to do the synchronous time deviations very high with regard to that can obtain precision of NLP twice.
Pair when algorithm two:
Make diAnd liThe time delay with return information is respectively sent, and sets li=kdi.In first NTP synchronization, just like
Lower relational expression
U1=T2,1-T1,1=d1+φ
V1=T4,1-T3,1=kd1-φ (1)
In second NTP synchronization, there is following relational expression
U2=T2,2-T1,2=d2+φ
V2=T4,2-T3,2=kd2-φ (2)
First consider formula (1), give mono- suitable initial value of k, and solve formula (1), try to achieve a φ value.Again the φ tried to achieve
Value is updated in formula (2), is solved formula (2), is tried to achieve a new k value.Again the k value substitution formulas (1) tried to achieve, formula (1) is solved, is obtained
The φ value new to one.Then make a decision, if the front and rear φ value errors tried to achieve twice are sufficiently small, stop calculating;Otherwise, then
The secondary φ value substitution formulas (2) that will newly try to achieve, formula (2) is solved to obtain a new k value.If solution is iterated, Zhi Daoman
The sufficient condition of convergence.
The algorithm is tested with that example above.Take ratio k initial value be 0.5, this value differed with actual value 2 compared with
Far.If convergent absolute error is limited to 0.00001.Result of calculation is as follows
Iterations n |
Reporting φ |
Time delay ratio k |
1 |
8.0000000 |
0.5 |
2 |
8.6666666 |
0.8 |
3 |
9.1111111 |
1.0769230 |
4 |
9.4074074 |
1.3142857 |
5 |
9.6049382 |
1.5051546 |
6 |
9.7366255 |
1.6509090 |
7 |
9.8244170 |
1.7578814 |
8 |
9.8829446 |
1.8341252 |
9 |
9.9219631 |
1.8873404 |
10 |
9.9479754 |
1.9239415 |
11 |
9.9653169 |
1.9488622 |
12 |
9.9768779 |
1.9657133 |
13 |
9.9845853 |
1.9770548 |
14 |
9.9897235 |
1.9846641 |
15 |
9.9931490 |
1.9897586 |
16 |
9.9954326 |
1.9931646 |
17 |
9.9969551 |
1.9954396 |
18 |
9.9979700 |
1.9969582 |
19 |
9.9986467 |
1.9979714 |
20 |
9.9990978 |
1.9986473 |
21 |
9.9993985 |
1.9990980 |
22 |
9.9995990 |
1.9993986 |
23 |
9.9997326 |
1.9995990 |
24 |
9.9998217 |
1.9997327 |
25 |
9.9998811 |
1.9998218 |
26 |
9.9999207 |
1.9998811 |
27 |
9.9999471 |
1.9999207 |
28 |
9.9999647 |
1.9999471 |
29 |
9.9999765 |
1.9999647 |
30 |
9.9999843 |
1.9999765 |
Result of calculation shows that the algorithm can obtain convergence, and convergency value can good approaching to reality value.
Algorithm 1 and algorithm 2 are all based on formula (1) and (2) to solve time deviation φ values, the difference is that algorithm 1 is straight
Connect and ask, algorithm 2 is asked with the mode of iteration.Two methods can obtain very accurate solution.
It is a kind of based on NTP networks pair when system, including concentrator:For obtaining the time, one is carried out to obtaining the time
Time bias and message when generating school;It route Homeplug:The time compensates again during for school;Collector:Handle carrier wave
Message and message when generating standard school;Described concentrator is provided with delivery time computing module:It is asked, eventually by multiple main website
End response is replied to calculate main website to the message transfer time of terminal, and concentrator, which compensates the time, includes message transfer time;It is described
Concentrator, route Homeplug in the main website, described collector is in terminal.
As shown in figure 3, broadcast timing system error at different levels and time delay summation are up to 1660ms, even more high.The master of error
Want source to be concentrator here, as long as therefore can largely eliminate this part of error, it is possible to realize that error is
During broadcast school within 1s, specifically implementation method is as follows:
The internal clocking precision of concentrator is brought up into 1ms, its error drops down to such concentrator as clock source
1ms;
When concentrator is to route hair school during message, a time bias is actively carried out, is exactly specifically by upper figure
When ductility error all fall to compensation, the summation of ductility error is 150ms when in figure, therefore concentrator is when generating school during message,
Message can be made to issue constantly the time quantum 150ms included in message in advance, such as:Should be 00:00:10:000
This moment sends out one and includes 00:00:10:The message of 000 this time quantum, then concentrator can shift to an earlier date 150ms 00:
00:09:850 this moment just sent out one and include 00:00:10:The message of 000 this time quantum;
Figure 1 above, a kind of setting means based on NTP networks shown in 2 are the specific embodiments of the present invention, have been embodied
Go out substantive distinguishing features of the present invention and progress, can according to reality use needs, the present invention enlightenment under, it is carried out shape,
The equivalent modifications of structure etc., this programme protection domain row.