Background
The modern transformer substation automatically completes basic functions such as information acquisition, measurement, control, protection, monitoring and metering by taking total-station information digitization, communication platform networking and information sharing standardization as basic requirements. However, the calculation processing of the measurement and control device, the protection device and the metering device requires that the sampling data should be collected at the same time point, so as to prevent errors of the phase and the amplitude. For protection such as overcurrent protection, the short-term stability of the local crystal oscillator clock protected by the microcomputer is very high, and the action precision of the protection cannot be influenced. However, for differential protection and metering, because the local crystal oscillator clock protected by the microcomputer is not very accurate, phase errors and amplitude errors of different sampling data across compartments can be gradually enlarged after long-time error accumulation, and false operation of differential protection and serious errors of metering are caused, so that the local clock needs to be corrected by a time synchronization technology.
IEEE1588 defines a Protocol that can implement high Precision clock synchronization in a measurement and control system, namely Precision Time Protocol (PTP). The basic principle of the PTP protocol is to transmit a synchronization packet between a master clock and a local clock, record the transmission time and reception time information of the packet, and tag a timestamp on each packet. The PTP protocol defines four multicast packets for using and describing time information, namely a synchronization packet Sync, a following packet Follow _ Up following the synchronization packet, a Delay measurement packet Delay _ Req, and a Delay measurement response packet Delay _ Resp.
The mechanism for transmitting the synchronization packet is a 'delay-request response mechanism', as shown in fig. 1, the master clock periodically transmits Sync packets containing clock quality, and then transmits Follow-up packets to inform the actual transmission time T of the last packet of the local clock m1 (ii) a Local clock records arrival time T of Sync information packet s1 Subsequently at T s3 Sending Delay _ Req information at any momentPackaging; the main clock records the arrival time T of the Delay _ Req information packet m3 And sends a packet Delay _ Resp to send T m3 Tells the local clock. The local clock calculates the offset and the transmission delay of the clock based on the four pieces of time information. T in FIG. 1 assuming that the round-trip delay of a packet is considered equal in the communication of information by a clock m1 、T s1 、T s3 、T m3 The line of the four points is an isosceles trapezoid.
The local clock can calculate the information exchange delay T between itself and the main clock delay Is composed of
T delay =[(T m3 ﹣T m1 )﹣(T s3 ﹣T s1 )]/2 (1.1)
Clock phase offset T of local clock and master clock offset Is composed of
T offset =[(T s1 ﹣T m1 )+(T s3 ﹣T m3 )]/2 (1.2)
The local clock modifies the local time in accordance with the calculated phase offset to achieve synchronization with the master clock.
The PTP eliminates the influence of the processing delay of the physical layer through the delay-request response mechanism, thereby further improving the time setting precision. Although IEEE1588 eliminates the influence of the upper layer processing delay and the physical layer processing delay through the PTP protocol, it has the same limitation as that of all network time synchronization algorithms, and four measurements performed by the PTP protocol to calculate the clock phase offset are based on the same transmission delay of the time synchronization information in the transmission direction, but in actual use, it is impossible to absolutely satisfy this premise. Although the IEEE1588 protocol introduces a transparent clock and a boundary clock, it needs a switch to support the IEEE1588 clock mechanism, and at the same time, the randomness and the lower frequency of the network transmission delay measurement are the same, but when the network load changes suddenly, the delay difference of the packet in the transmission direction becomes large, so the assumption that the formula (1.1) and the formula (1.2) are satisfied — the round-trip delay of packet exchange is not the same, and T in fig. 1 is the assumption that T is equal m1 、T s1 、T s3 、T m3 A line connecting four points will be one unequalThe waist trapezoid gives a large error in the correction of the local clock if the local clock phase offset is simply calculated by the formula (1.2).
The method only compensates the phase offset of the local clock and does not compensate the frequency offset of the local clock. The fundamental reason for the phase shift is that the local crystal oscillator clock frequency is not very accurate, and has an error compared with the main clock frequency, and the phase shift is caused by long-time error accumulation.
Disclosure of Invention
The purpose is as follows: in order to overcome the defects in the prior art, the invention provides a substation network time synchronization method based on an adaptive algorithm.
The technical scheme is as follows: in order to solve the technical problems, the technical scheme adopted by the invention is as follows:
a transformer substation network time synchronization method based on an adaptive algorithm comprises the following steps:
the method comprises the following steps: when the main clock and the local clock are synchronized once, N times of information exchange is carried out, and the processing delay of the physical layer is set to be a fixed value d; in the kth information exchange, T 1,k The actual sending time of the kth information packet of the master clock; t is 2,k The time when the kth information packet is received by the local clock; t is 3,k Actual transmission time for transmitting the kth packet for the local clock; t is 4,k The time when the kth information packet is received by the master clock; setting the network transmission delay of information from the main clock to the local clock as a random variable X k Setting the network transmission delay from the local clock to the main clock as a random variable Y k Assuming network delayAndrespectively obeying exponential distributions with mean values of alpha and beta;
step two: maximum likelihood estimation of phase-offset computation, assuming round-trip delay symmetry of network transmissionPreferably, the network transmission delay X k And Y k Subject to the exponential distribution of the same parameters, the mean of these two exponential functions can be made equal, with α = β = λ; meanwhile, because the randomness of network transmission delay causes the uncertainty of information exchange delay, the round-trip delay data of the information exchange obtained after N times of time synchronization can be obtainedAndcounting the numerical values from small to large in sequence, and rearranging the numerical values to obtain the numerical valuesAndthe likelihood function can be constructed as:
considering equations (2.3) and (2.4), the round-trip delays for N exchanges of time tick are summed, as
And
is determined by the average value of (a) of (b),average value of (d);
the two formulas (2.6) and (2.7) are added to obtainCan be substituted by formula (2.5)
By using the likelihood function L of equation (2.8) R (d, phi) obtaining the maximum value to obtain the maximum likelihood estimation value of the parameter;
the maximum likelihood estimate of d and Φ is solved as:
U (1) to representMiddle rank first, V (1) To representThe middle sequence is first;
step three: the optimal linear unbiased estimation of the phase deviation calculation firstly makes the round-trip delay data of the information exchange obtained after N times of time settingAndcounting the numerical values from small to large in sequence, and rearranging the numerical values to obtain the numerical valuesAnd
defining the unknown variable matrix to be solved as delta' = [ d phi alpha beta ]] T Then there is
P' in the matrix is a matrix determined by the length N of the time tick information sample;
because the information exchange delay data is subjected to sequential statistics, a linear model is established, and the optimal linear unbiased estimation of delta' is as follows:
wherein Q' W Is the covariance matrix of W; round-trip delay due to information exchangeAndfor two independent exponential random distributions, we can obtain:
q is information exchange delay data U (k) And V (k) The NxN order symmetric positive definite covariance matrix;
the observed information exchange delay data is:
W=[U 1 V 1 U 2 V 2 …U N V N ] T
the optimal linear unbiased estimate of δ' can be solved as:
wherein the content of the first and second substances,andround-trip delay data for information exchange respectivelyAndis also after sequential statisticsAndthe sample average of (a);
step four: number of information exchanges N, alpha BLUE 、β BLUE Into formula (2.16) where BLUE Optimal linear unbiased estimation, beta, of network transmission delay representing information from master clock to local clock BLUE An optimal linear unbiased estimate of network transmission delay of the representative information from the local clock to the master clock;
if equation (2.16) holds, the phase shift φ value is taken as φ in equation (2.9) MLE ;
If the formula (2.16) does not hold, the phase deviation phi value adopts phi in the formula (2.13) BLUE ;
Step five: let the local clock output time at this time be C i (t) actual output time C 'after phase offset compensation' i (t) is:
C’ i (t)=C i (t)+Φ (3.5)
step six: the optimal estimation of the local clock frequency deviation assumes that the clock phase deviation monotonically increases due to the influence of the frequency deviation eta between the local clock and the main clockThat is, the frequency offset eta is not changed, and the time synchronization information is exchanged for N times in one time, wherein the time synchronization information is exchanged for the k time 2,k And T 3,k Are the local time of the local clock each,andthe local time of the master clock, the physical layer processing delay is a fixed value d, and the network transmission delay of the information from the master clock to the local clock is a random variable X k The network transmission delay of the information from the local clock to the master clock is a random variable Y k (ii) a Selection of T 1,1 Is a reference time, i.e. T 1,1 Is the actual local time of the master clockTime zero; thenAndrespectively the actual local time of the master clockAndrelative time of (d);is shown inPhase shift of reference clock of time of day, where r Represents the actual phase offset of the local clock; the relative observation time when the local clock receives the kth time setting information is T 2,k The relative observation time when the kth time setting information is sent is T 3,k The method comprises the following steps:
is provided with
In the same way have T 3,k =(T 4,k -d-Y k )(1+η)+φ (3.2)
When the network transmission delay symmetry is good, it is assumed that the round-trip average delay α and β of the network transmission have α = β, and the local clock phase offset Φ has been compensated by calculation, and the physical layer processing delay d is determined by the device, and is a known value, the likelihood function can be constructed as
X k >, 0 and Y k >, 0, available Domain
Due to d>, 0 and 1+ eta>, 0, can be derived from the domain of definitionWhile (T) in the formula (3.3) is observed 2,k ﹣T 3,k ) Always negative, network transmission delay beta&0, so if the likelihood function L (eta, beta) has the maximum value, the value of eta should be as small as possible; the maximum likelihood estimate of η is at its minimum, i.e.
Wherein
Step seven: and (3) setting the natural frequency of the local clock crystal oscillator as f, and after the natural frequency is compensated, setting the actual frequency f' as:
f’=f×(1+η min ) (3.6)。
preferably, the number of times of information exchange N is set to 16.
Has the beneficial effects that: aiming at the problems that when the network load of the intelligent substation is heavy, the network transmission round-trip delay is asymmetric, and the error of the correction of a local clock is larger in single Time comparison of the traditional Precision Time Protocol (PTP).
Detailed Description
The present invention will be further described with reference to the accompanying drawings.
The following packet and the delay measurement response packet in the single time tick message exchange of the PTP protocol are mainly used to make the local clock obtain the precise sending and receiving time of the master clock, as shown by the solid line part in fig. 1, the actual single time tick needs to be T m1 、T s1 、T s3 、T m3 Time of four key points. Therefore, it can be considered that each time setting information exchange, the local clock can obtain the time of the four key points, the dotted line part in fig. 1 is omitted, and meanwhile, the influence of the frequency offset of the local clock is not considered, and then a clock simplified model of the PTP protocol for N times of time setting information exchange is shown in fig. 2. T is 1,k Actual transmission time of kth information packet of the master clock; t is 2,k The time when the kth information packet is received by the local clock; t is 3,k Transmitting kth for local clockActual transmission time of the packet; t is 4,k The time when the kth packet is received for the master clock.
In fig. 2, because the information exchange delay between the master clock and the local clock is asymmetric, N times of time-setting information exchange are required in total to perform mathematical statistics estimation on the phase offset Φ of the local clock, where N is the number of samples required for statistical calculation. Through the analysis, in the PTP time synchronization protocol, the upper layer processing time delay can be ignored through a hardware time stamping method; the physical layer processing delay can be set to a fixed value d; in the kth information exchange, the network transmission delay from the main clock to the local clock of the information is set as a random variable X k Setting the network transmission delay from the local clock to the main clock as a random variable Y k Assuming network delayAndobeying an exponential distribution with mean values α and β, respectively. Thus, the packet time stamp T 2,k And T 4,k Can be expressed as:
T 2,k =T 1,k +d+φ+X k (2.1)
T 4,k =T 3,k +d-φ+Y k (2.2)
in the kth exchange of time ticks, the round-trip delay of the exchange of time ticks between the local clock and the master clock can be defined as:
U k =T 2,k -T 1,k =d+φ+X k (2.3)
and V k =T 4,k -T 3,k =d-φ+Y k (2.4)
1. Optimal estimation of local clock phase offset
When the background flow in the network transmission is smaller, the network transmission delay is smaller, the randomness of the network transmission delay is also smaller, so the round-trip delay X of the network transmission is smaller k And Y k Can be considered symmetrical; however, when the background flow in the network transmission is larger, the network transmission delay becomes larger, and the networkThe randomness of the transmission delay increases, at which time the round-trip delay X of the network transmission k And Y k Is asymmetric, and the round-trip average delay alpha of network transmission is not equal to beta.
1.1. Maximum likelihood estimation of phase-offset computation
When the phase offset is calculated by adopting a maximum likelihood estimation method, the round-trip delay symmetry of network transmission is assumed to be good, and the network transmission delay X is assumed to be k And Y k The mean of these two exponential functions can be made equal, with α = β = λ, subject to an exponential distribution of the same parameters. Meanwhile, because the randomness of network transmission delay causes the uncertainty of information exchange delay, the round-trip delay data of the information exchange obtained after N times of time synchronization can be obtainedAndcounting the numerical values from small to large in sequence, and rearranging the numerical values to obtain the numerical valuesAnd
the likelihood function can be constructed as:
considering equations (2.3) and (2.4), the round-trip delays for N exchanges of time tick are summed, as
And
is determined by the average value of (a) of (b),average value of (a).
The two formulas (2.6) and (2.7) are added to obtainCan be substituted by formula (2.5)
By using the likelihood function L of equation (2.8) R (d, Φ) the maximum value is obtained, and the maximum likelihood estimation value of the parameter can be obtained.
The maximum likelihood estimate of d and Φ is solved as:
U (1) to representMiddle rank first, V (1) To representRank one in the middle.
1.2. Optimal linear unbiased estimation of phase-bias computation
Firstly, the round-trip delay data of information exchange obtained after N times of time synchronizationAndcounting the numerical values from small to large in sequenceAfter new arrangement becomeAnd
defining the unknown variable matrix to be solved as delta' = [ d phi alpha beta ]] T Then there is
P' in the matrix is a matrix determined by the length N of the time tick information samples.
Because the information exchange delay data is subjected to sequential statistics, a linear model is established, and the optimal linear unbiased estimation of delta' is as follows:
wherein Q' W Is the covariance matrix of W. Round-trip delay due to information exchangeAndfor two independent exponential random distributions, we can obtain:
q is information exchange delay data U (k) And V (k) N × N order symmetric positive definite covariance matrix.
Observed information exchange delay data of
W=[U 1 V 1 U 2 V 2 … U N V N ] T
The optimal linear unbiased estimate of δ' can be solved as:
wherein the content of the first and second substances,andround-trip delay data for information exchangeAndis also after sequential statisticsAndthe sample average of (2).
1.3. Optimal estimation of local clock phase offset
Comparing the mean square error of the maximum likelihood estimation of the formula (2.9) and the linear unbiased estimation of the formula (2.13) to obtain:
it can be seen from the equations (2.14) and (2.15) that although the maximum likelihood estimation of the local clock phase offset is biased in the case of asymmetric network transmission delay, under certain conditions it has better performance than the linear unbiased estimation, with
MSE(φ BLUE )>MSE(φ MLE )
Namely that
It can be seen from the above equation that, when the number of times N of switching packets is fixed, i.e. the number of samples required for phase offset calculation is fixed, the larger the round-trip average delay α and β of network transmission, and the smaller the asymmetry degree | α - β | are, the smaller the mean-square error of the maximum likelihood estimation will be compared with the linear unbiased estimation.
When the network transmission delay is only slightly asymmetric, the maximum likelihood estimation has a better estimation effect around α = β.
When the asymmetry of the network transmission delay gradually increases, the | alpha-beta | gradually deviates from 0, and the linear unbiased estimation is gradually superior to the maximum likelihood estimation.
As shown in fig. 4, considering the amount of calculation of the microcomputer chip, N is preferably 16 in the present design. In order to realize the optimal estimation of the phase deviation calculation, self-adaptive selection is required according to network delay. Firstly, the network transmission delays alpha and beta are estimated through an equation (2.13), and then are substituted into an equation (2.16), and whether the inequality is established or not is checked. If the inequality is true, selecting the maximum likelihood estimation to carry out phase deviation calculation, and if the inequality is false, selecting the linear unbiased estimation to carry out the phase deviation calculation.
2. Optimal estimation of local clock frequency offset
Assuming that the phase deviation of the clock monotonically increases due to the influence of the frequency deviation η between the local clock and the master clock, that is, the frequency deviation η does not change, a clock model for exchanging the time synchronization information of the phase deviation and the frequency deviation of the clock is constructed, as shown in fig. 3. The time synchronization information is exchanged for N times in one time synchronization, wherein the T of the k time synchronization information exchange 2,k And T 3,k Are the local time of the local clock each,andis the local time of the master clock. Neglecting the upper layer processing delay, the physical layer processing delay is a fixed value d, and the network transmission delay of the information from the main clock to the local clock is a random variable X k The network transmission delay of the information from the local clock to the master clock is a random variable Y k . Selection of T 1,1 Is a reference time, i.e. T 1,1 Is the actual local time of the master clockTime zero. ThenAndrespectively the actual local time of the master clockAndrelative time of (d);is shown inPhase shift of reference clock of time of day, where r Representing the actual phase offset of the local clock. The relative observation time when the local clock receives the kth time setting information is T 2,k The relative observation time when the kth time setting information is sent is T 3,k The method comprises the following steps:
is provided with
In the same way, there is T 3,k =(T 4,k -d-Y k )(1+η)+φ (3.2)
It can be seen from the equations (3.1) and (3.2) that the relative observation time of the local clock is affected by the frequency offset and is represented by (T) in the equations 1,k +d+X k ) The term of η and (T) 4,k -d-Y k ) The influence of the term η.
When the network transmission delay symmetry is good, it is assumed that the round-trip average delay α and β of the network transmission have α = β, and the local clock phase offset Φ has been compensated by calculation, and the physical layer processing delay d is determined by the device, and is a known value, the likelihood function can be constructed as
X k >, 0 and Y k > 0, available Domain
Due to d>, 0 and 1+ eta>, 0, can be derived from the domain of definitionWhile (T) in the formula (3.3) is observed 2,k ﹣T 3,k ) Always negative, network transmission delay beta&And gt, 0, so that if the likelihood function L (eta, beta) is to have a maximum value, the value of eta should be as small as possible. The maximum likelihood estimate of η is at its minimum, i.e.
Wherein
3. Calculation of local clock frequency offset and phase offset
Let the local clock output time at this time be C i (t) compensating the time difference to actually output the time C' i (t) is
C’ i (t)=C i (t)+Φ (3.5)
The natural frequency f of the local clock crystal oscillator is set as f, and after the natural frequency f is compensated, the actual frequency f' is set as
f’=f×(1+η min ) (3.6)
The algorithm can perform prior calculation estimation according to the round-trip delay of network transmission, select a proper phase deviation calculation method, and meanwhile, because the local clock frequency deviation calculation needs to compensate the phase deviation first, the total calculation flow is shown in fig. 4.
The above description is only of the preferred embodiments of the present invention, and it should be noted that: it will be apparent to those skilled in the art that various modifications and adaptations can be made without departing from the principles of the invention and these are intended to be within the scope of the invention.