Summary of the invention
The technical assignment of the technical problem to be solved in the present invention and proposition carries out improving to prior art and improves, and provides a kind of setting means based on NTP network, object during to reach accurate pair.For this reason, the present invention takes following technical scheme.
Based on a setting means for NTP network, it is characterized in that comprising the following steps:
A) main website sends the request of inquiry precision clock to terminal, and records the time sent request;
B) terminal receives the inquiry precision clock request of main website;
C) request of the inquiry precision clock of terminal replies main website, the request of reply comprises terminal and receives the time of inquiry precision clock request and reply the time sent;
D) main website receives the request that terminal sends and replys, and record request replys the time received, repeat a), b), c), d) until number of repetition arrival set point number;
E) main website calculates the time that main website transmits to the network of terminal, regulation time deviation;
F) main website sends the request of modification time deviation to terminal;
G) terminal check, and modification time;
H) the main website inquiry terminal time;
I) terminal returns terminal time to main website;
J), after main website confirms that terminal time correctly, ask when terminal sends school;
K) during the school of terminal according to main website request to once show meter to carry out pair time;
L) terminal check.
As improving further and supplementing technique scheme, the present invention also comprises following additional technical feature.
When calculating the time that main website transmits to the network of terminal, make d
iand l
ibe respectively the time delay of transmission and return information, and establish l
i=kd
i; In synchronous at first:
U
1=T
2,1-T
1,1=d
1+φ
V
1=T
4,1-T
3,1=kd
1-φ (1)
In synchronous at second:
U
2=T
2,2-T
1,2=d
2+φ
V
2=T
4,2-T
3,2=kd
2-φ (2)
Obtained by formula (1), formula (2)
When calculating the time that main website transmits to the network of terminal, make d
iand l
ibe respectively the time delay of transmission and return information, and establish l
i=kd
i; At first; In synchronous, there is following relational expression
U
1=T
2,1-T
1,1=d
1+φ
V
1=T
4,1-T
3,1=kd
1-φ (1)
In synchronous at second, there is following relational expression
U
2=T
2,2-T
1,2=d
2+φ
V
2=T
4,2-T
3,2=kd
2-φ (2)
First consider formula (1), the initial value that given k mono-is suitable, and solve formula (1), try to achieve a φ value; Again the φ value of trying to achieve is updated in formula (2), solves formula (2), try to achieve a new k value; Again k value substitution formula (1) of trying to achieve, solve formula (1), obtain a new φ value; Then make a decision, if the φ value error that front and back are tried to achieve for twice is enough little, then stop calculating; Otherwise φ value substitution formula (2) of again will newly try to achieve, solves formula (2) to obtain a new k value; So iterate and solve, until meet the condition of convergence.
Based on NTP network pair time a system, it is characterized in that: comprise concentrator: for acquisition time, message when acquisition time is carried out to a time bias and generates school; Route Homeplug: for again compensating time during school; Collector: process carrier wave message message when generating standard school; Described concentrator is provided with delivery time computing module: it is replied by repeatedly master station acquires, terminal response and calculates the message transfer time of main website to terminal, and the concentrator make-up time comprises message transfer time; Described concentrator, route Homeplug are all located in main website, and described collector is located in terminal.
Collector is connected with ammeter by RS485.
Beneficial effect: when the technical program makes terminal accomplish accurate pair of level second by NTP correcting time in network algorithm, precision during raising pair, obtains the accurate time of origin that load, voltage, electric current etc. measure data instantaneously, improves the correctness that tou power price calculates.
Embodiment
Below in conjunction with Figure of description, technical scheme of the present invention is described in further detail.
The present invention includes following steps:
A) main website sends the request of inquiry precision clock to terminal, and records the time sent request;
B) terminal receives the inquiry precision clock request of main website;
C) request of the inquiry precision clock of terminal replies main website, the request of reply comprises terminal and receives the time of inquiry precision clock request and reply the time sent;
D) main website receives the request that terminal sends and replys, and record request replys the time received, repeat a), b), c), d) until number of repetition arrival set point number;
E) main website calculates the time that main website transmits to the network of terminal, regulation time deviation;
F) main website sends the request of modification time deviation to terminal;
G) terminal check, and modification time;
H) the main website inquiry terminal time;
I) terminal returns terminal time to main website;
J), after main website confirms that terminal time correctly, ask when terminal sends school;
K) during the school of terminal according to main website request to once show meter to carry out pair time;
L) terminal check.
As shown in Figure 1, for pair time algorithm logic figure.
Pair time algorithm one:
Make d
iand l
ibe respectively the time delay of transmission and return information, and establish l
i=kd
i.In first NTP is synchronous, there is following relational expression
U
1=T
2,1-T
1,1=d
1+φ
V
1=T
4,1-T
3,1=kd
1-φ (1)
In second NTP is synchronous, there is following relational expression
U
2=T
2,2-T
1,2=d
2+φ
V
2=T
4,2-T
3,2=kd
2-φ (2)
Have 4 equations and 4 unknown numbers in formula (1) and (2), then easily try to achieve
Accordingly can in the hope of the value of k
To be illustrated in figure 2 example, illustrate computational process, if the real time deviation of equipment and main frame is 10s, when first NLP is synchronous, the actual time delay of transmission and return information is respectively 2 seconds and 4 seconds, when second NLP is synchronous, the actual time delay of transmission and return information is respectively 3 seconds and 6 seconds, and the actual value of ratio k is 2.
The time deviation φ tried to achieve by formula (3) and (4) and ratio k are respectively 10s and 2, and the result of namely trying to achieve is completely accurate.
Certainly, this example has done idealized process, and in other words, although algorithm hypothesis sends and the time delay of return information has fixing ratio, in reality, this ratio still has certain fluctuation at different N LP synchronously.Therefore, in the engineer applied of reality, be not strictly equal 10s's with the time deviation φ that this algorithm is obtained.But because the hypothesis of fixing time delay ratio is still realistic basis, the time deviation φ that obtains of this algorithm is inevitable extremely approach actual value.
The advantage of this algorithm is only twice NLP synchronously just can obtain the very high time deviation of precision.
Pair time algorithm two:
Make d
iand l
ibe respectively the time delay of transmission and return information, and establish l
i=kd
i.In first NTP is synchronous, there is following relational expression
U
1=T
2,1-T
1,1=d
1+φ
V
1=T
4,1-T
3,1=kd
1-φ (1)
In second NTP is synchronous, there is following relational expression
U
2=T
2,2-T
1,2=d
2+φ
V
2=T
4,2-T
3,2=kd
2-φ (2)
First consider formula (1), the initial value that given k mono-is suitable, and solve formula (1), try to achieve a φ value.Again the φ value of trying to achieve is updated in formula (2), solves formula (2), try to achieve a new k value.Again k value substitution formula (1) of trying to achieve, solve formula (1), obtain a new φ value.Then make a decision, if the φ value error that front and back are tried to achieve for twice is enough little, then stop calculating; Otherwise φ value substitution formula (2) of again will newly try to achieve, solves formula (2) to obtain a new k value.Solve if iterated, until meet the condition of convergence.
This algorithm is tested with that example above.The initial value getting ratio k is 0.5, and this value differs far away with actual value 2.If the absolute error of convergence 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, this algorithm can obtain convergence, and convergency value can good approaching to reality value.
Algorithm 1 and algorithm 2 all solve time deviation φ value based on formula (1) and (2), are directly ask unlike algorithm 1, and algorithm 2 asks by the mode of iteration.Two kinds of methods can be obtained and separate very accurately.
Based on NTP network pair time a system, comprise concentrator: for acquisition time, message when acquisition time is carried out to a time bias and generates school; Route Homeplug: for again compensating time during school; Collector: process carrier wave message message when generating standard school; Described concentrator is provided with delivery time computing module: it is replied by repeatedly master station acquires, terminal response and calculates the message transfer time of main website to terminal, and the concentrator make-up time comprises message transfer time; Described concentrator, route Homeplug are all located in main website, and described collector is located in terminal.
As shown in Figure 3, broadcast timing system error at different levels and time delay summation can reach 1660ms, even higher.The main source of error is that concentrator is here, as long as therefore can eliminate the error of this part largely, when just can to realize error be the broadcast school within 1s, implementation method is as follows specifically:
The internal clocking precision of concentrator is brought up to 1ms, and such concentrator just have decreased to 1ms as its error of clock source;
When concentrator sends out school to route during message, initiatively carry out a time bias, be exactly that the time ductility error in upper figure is all fallen to compensation specifically, time in figure, the summation of ductility error is 150ms, therefore concentrator generate school time message time, message can be made to issue time quantum 150ms that the moment comprises in advance in message, such as: should send out in this moment of 00:00:10:000 the message that comprises this time quantum of 00:00:10:000, so concentrator can shift to an earlier date 150ms and just sends out in this moment of 00:00:09:850 the message that comprises this time quantum of 00:00:10:000,
A kind of setting means based on NTP network shown in above Fig. 1,2 is specific embodiments of the invention; substantive distinguishing features of the present invention and progress are embodied; can according to the use needs of reality; under enlightenment of the present invention; it is carried out to the equivalent modifications of the aspect such as shape, structure, all at the row of the protection range of this programme.