Summary of the invention
The embodiment of the present application provides a kind of clock synchronizing method based on the IEEE1588 agreement, device and base station clock equipment, in the time of can't obtaining reliable clock source signals to solve existing local clock, is difficult to realize synchronous problem with master clock.
In order to solve the problems of the technologies described above, the embodiment of the present application discloses following technical scheme:
A kind of clock synchronizing method based on IEEE1588 comprises:
Base station side realize that by Ethernet interaction data message clock is synchronous from clock and system's master clock;
After synchronously, obtain described from the crystal oscillator count value of clock and the crystal oscillator count value of base station local clock;
The crystal oscillator count value of described crystal oscillator count value from clock and described local clock as the reference source, is calculated the adjusted value of local clock;
By described adjusted value local clock is adjusted, so that the output of described local clock and described master clock clock signal synchronous.
Described obtaining from the crystal oscillator count value of clock and the crystal oscillator count value of base station local clock comprises:
Receive first data message and second data message that described master clock sends continuously;
When receiving described first data message, read described from the first crystal oscillator count value of clock and the first crystal oscillator count value of described local clock, and when receiving described second data message, from described second data message, read described from the second crystal oscillator count value of clock and the second crystal oscillator count value of described local clock.
The adjusted value of described calculating local clock comprises:
By calculating described from the first crystal oscillator count value of clock and the time interval of the second crystal oscillator count value from the standard crystal oscillator count value of clock, the described first crystal oscillator count value and the second crystal oscillator count value from clock;
According to the standard crystal oscillator count value of local clock, the first crystal oscillator count value and the second crystal oscillator count value and the described time interval of local clock, the deviate of the crystal oscillator count value of local clock in the unit of account time;
The deviate that obtains when some master clocks that add up send datagram continuously obtains the Accumulated deviation value;
Calculate the mean value of the historical adjusted value of some local clocks;
This adjusted value according to described Accumulated deviation value and the described local clock of described mean value calculation.
Describedly by described adjusted value local clock adjustment is comprised:
Calculate the default voltage step long value of the crystal oscillator that is used for output local clock signal and the product of described this adjusted value, obtain voltage change;
The magnitude of voltage that the predeterminated voltage initial value addition of described voltage change and described crystal oscillator is obtained is as the adjustment magnitude of voltage of described crystal oscillator, so that the output of described crystal oscillator and described master clock clock signal synchronous.
A kind of clock synchronization apparatus based on IEEE1588 comprises:
Interactive unit is used for making from clock and system's master clock and realizes that by Ethernet interaction data message clock is synchronous;
Acquiring unit is used for obtaining described from the crystal oscillator count value of clock and the crystal oscillator count value of base station local clock after synchronously;
Computing unit, be used for will described crystal oscillator count value from clock and described local clock the crystal oscillator count value as the reference source, the adjusted value of calculating local clock;
Adjustment unit is used for by described adjusted value local clock being adjusted, so that the output of described local clock and described master clock clock signal synchronous.
Described acquiring unit comprises:
The message receiving element is used for receiving first data message and second data message that described master clock sends continuously;
The count value reading unit, be used for when receiving described first data message, read described from the first crystal oscillator count value of clock and the first crystal oscillator count value of described local clock, and when receiving described second data message, from described second data message, read described from the second crystal oscillator count value of clock and the second crystal oscillator count value of described local clock.
Described computing unit comprises:
The deviate computing unit, be used for by calculating described from the first crystal oscillator count value of clock and the time interval of the second crystal oscillator count value from the standard crystal oscillator count value of clock, the described first crystal oscillator count value and the second crystal oscillator count value from clock, and according to the standard crystal oscillator count value of local clock, the first crystal oscillator count value and the second crystal oscillator count value and the described time interval of local clock, the deviate of the crystal oscillator count value of local clock in the unit of account time;
The deviate unit that adds up is used for the deviate that adds up and obtain when some master clocks send datagram continuously, obtains the Accumulated deviation value;
Average calculation unit is for the mean value of the historical adjusted value that calculates some local clocks;
The adjustment calculation unit is used for this adjusted value according to described Accumulated deviation value and the described local clock of described mean value calculation.
Described adjustment unit comprises:
The adjustment calculation unit is used for calculating the default voltage step long value of the crystal oscillator that is used for output local clock signal and the product of described this adjusted value, obtains voltage change;
The magnitude of voltage adjustment unit, be used for magnitude of voltage that the predeterminated voltage initial value addition with described voltage change and described crystal oscillator obtains as the adjustment magnitude of voltage of described crystal oscillator, so that the output of described crystal oscillator and described master clock clock signal synchronous.
A kind of base station clock equipment comprises:
From clock module, be used for realizing that by Ethernet interaction data message clock is synchronous with the system master clock;
Soft phase-locked module, be used for described synchronous from clock and master clock after, obtain described crystal oscillator count value from clock, and the crystal oscillator count value by described base station local clock, the crystal oscillator count value of described crystal oscillator count value from clock and described local clock as the reference source, is calculated the adjusted value of local clock;
The crystal oscillator module is used for by described adjusted value local clock being adjusted, so that the output of described local clock and described master clock clock signal synchronous.
Also comprise:
The FPGA module is used for obtaining the crystal oscillator count value of described local clock, and the crystal oscillator count value of described local clock is offered described soft phase-locked module.
As can be seen from the above-described embodiment, base station side realizes that by Ethernet interaction data message clock is synchronous from clock and system's master clock in the embodiment of the present application, after synchronously, obtain from the crystal oscillator count value of clock and the crystal oscillator count value of base station local clock, will be from the crystal oscillator count value of the crystal oscillator count value of clock and described local clock as the reference source, calculate the adjusted value of local clock, by adjusted value local clock is adjusted, so that local clock output and master clock clock signal synchronous.By 1588 message protocols, do not have at local clock under the situation of reliable external timing signal input in the embodiment of the present application, by the count value of crystal oscillator count value instead of external clock signal, thereby realized the accurately synchronous of base station side local clock and master clock.
Embodiment
The following embodiment of the present invention provides clock synchronizing method and the device based on the IEEE1588 agreement.Make and be difficult to provide under the situation of 1PPS clock signal 1588 from clock, by 1588 protocol massages make synchronous from clock and master clock after, utilize 1588 to be reference from the crystal oscillator reading value of clock and the reading value of local OCXO (constant-temperature crystal oscillator), calculate the adjustment magnitude of voltage of OCXO, thereby clock signal and the master clock of the OCXO output of realization local clock are accurately synchronous.
In order to make those skilled in the art person understand technical scheme in the embodiment of the invention better, and the above-mentioned purpose of the embodiment of the invention, feature and advantage can be become apparent more, below in conjunction with accompanying drawing technical scheme in the embodiment of the invention is described in further detail.
Referring to Fig. 1, be the first embodiment flow chart of the application's clock synchronizing method:
Step 101: base station side realize that by Ethernet interaction data message clock is synchronous from clock and system's master clock.
Step 102: after synchronously, obtain from the crystal oscillator count value of clock and the crystal oscillator count value of base station local clock.
Concrete, receive first data message and second data message that master clock sends continuously, when receiving described first data message, read from the first crystal oscillator count value of clock and the first crystal oscillator count value of local clock, and when receiving second data message, from second data message, read from the second crystal oscillator count value of clock and the second crystal oscillator count value of local clock.
Step 103: will calculate the adjusted value of local clock from the crystal oscillator count value of the crystal oscillator count value of clock and local clock as the reference source.
Concrete, by the standard crystal oscillator count value from clock, calculate from the first crystal oscillator count value of clock and the time interval of the second crystal oscillator count value from the first crystal oscillator count value and the second crystal oscillator count value of clock, standard crystal oscillator count value according to local clock, the first crystal oscillator count value of local clock and second crystal oscillator count value and the time interval, the deviate of the crystal oscillator count value of local clock in the unit of account time, the deviate that obtains when some master clocks that add up send datagram continuously, obtain the Accumulated deviation value, calculate the mean value of the historical adjusted value of some local clocks, according to this adjusted value of Accumulated deviation value and mean value calculation local clock.
Step 104: by adjusted value local clock is adjusted, so that local clock output and master clock clock signal synchronous.
Concrete, calculate the default voltage step long value of the crystal oscillator that is used for output local clock signal and the product of this adjusted value, obtain voltage change, the magnitude of voltage that the predeterminated voltage initial value addition of voltage change and crystal oscillator is obtained is as the adjustment magnitude of voltage of crystal oscillator, so that crystal oscillator output and described master clock clock signal synchronous.
Referring to Fig. 2, be the second embodiment flow chart of the application's clock synchronizing method:
Step 201: base station side realize that by Ethernet interaction data message clock is synchronous from clock and system's master clock.
Wherein, system's master clock is when sending the Sync message from clock, stabs TM1 and time of reception stabs TS1 from the transmitting time of obtaining this Sync message of clock from this Sync message; , when sending the Delay_Req message to master clock, obtain the transmitting time of this Delay_Req message from clock and stab TS2 and time of reception stamp TM2 from clock
The timestamp that obtains when the clock utilization receives message and send message carries out following calculating:
Delay=((TS1-TM1)+(TS2-TM2))÷2;
Offset=TS1-TM1-Delay;
In the following formula, Delay is propagation delay time, and Offset is time error, according to this Delay and Offset realize from clock and system's master clock accurately synchronously, this synchronizing process is consistent with prior art, does not repeat them here.
Step 202: after synchronously, receive first data message and second data message that master clock sends continuously.
From clock and system's master clock synchronously after, from the polling tasks of clock by its MAC layer, receive at every turn data message that system's master clock sends the time, trigger 64 bit registers in the MAC layer and read crystal oscillator count value F from clock
1588, and trigger the crystal oscillator count value F that reads local clock by FPGA (Field-Programmable GateArray, field programmable gate array) register
Local
Step 203: read the crystal oscillator count value after receiving first data message and second data message.
When receiving described first data message, read from the first crystal oscillator count value of clock and the first crystal oscillator count value of local clock, and when receiving second data message, from second data message, read from the second crystal oscillator count value of clock and the second crystal oscillator count value of local clock.
Under the perfect condition, the 1588 standard crystal oscillator count values from clock are F
1588 (marks)(then this standard meter numerical value is 100M for the given standard frequency value of crystal oscillator, the crystal oscillator of 100M for example), the standard crystal oscillator count value of local clock is F
Local (mark)Appoint when getting the adjacent two data message that receives the continuous transmission of master clock, the crystal oscillator count value that obtains, when supposing to receive the datagram of master clock transmission for the first time, the crystal oscillator count value from clock that reads is F
1588 (1), the crystal oscillator count value of local clock is F
Local (1), when receiving for the second time the datagram of master clock transmission, the crystal oscillator count value from clock that reads is F
1588 (2), the crystal oscillator count value of local clock is F
Local (2)
Step 204: calculate from the first crystal oscillator count value of clock and the time interval of the second crystal oscillator count value.
By from the standard crystal oscillator count value of clock, calculate from the first crystal oscillator count value of clock and the time interval of the second crystal oscillator count value from the first crystal oscillator count value and the second crystal oscillator count value of clock.Concrete, can be according to following formula interval T computing time:
T=(F
1588 (2)-F
1588 (1))/F
1588 (marks)
Step 205: according to the deviate of this time interval unit of account crystal oscillator count value of local clock in the time.
According to the standard crystal oscillator count value of local clock, the first crystal oscillator count value and the second crystal oscillator count value and this time interval of local clock, the deviate of the crystal oscillator count value of local clock in the unit of account time.Concrete, can be according to following formula calculation deviation value TE:
TE=(S1-S2)/T
In the following formula, S1 represents (being that local clock is accurately synchronous with master clock) under the perfect condition, the desirable difference of the crystal oscillator count value of adjacent twice local clock; S2 represents under the actual conditions, the difference of the crystal oscillator count value of adjacent twice local clock that reads; The deviate of the crystal oscillator count value of actual conditions and ideal situation in the TE representation unit time, wherein, S1 and S2 can calculate by following formula respectively:
S1=(F
1588 (2)-F
1588 (1)) * F
Local (mark)/ F
1588 (marks)
S2=F
Local(2)-F
Local(1)
Step 206: the deviate that adds up and obtain according to the continuous data message that sends of some master clocks obtains the Accumulated deviation value.
Reach at local clock with from clock under the accurately synchronous situation, the value that TE should be arranged is 0, but in actual conditions, TE is not 0 usually, and therefore the cumulative errors value CTE of deviate behind k reading of the crystal oscillator count value of local clock then arranged
k, following formula calculates:
CTE
k=TE
1+TE
2+...+TE
k
Step 207: the mean value that calculates the historical adjusted value of some local clocks.
When the mean value of the historical adjusted value that calculates local clock, at first need to begin from the historical adjusted value of certain local clock the historical adjusted value of the some local clocks of continuous drawing, and calculate the mean value of the historical adjusted value that extracts.
Concrete, can calculate this mean value correct according to following formula
Ref:
In the following formula, c
tBe the historical adjusted value of local clock, N is generally the integer value greater than 3000.
Step 208: according to this adjusted value of Accumulated deviation value and mean value calculation local clock.
Calculate this adjusted value c of local clock according to following formula
k:
c
k=correct
ref-CTE
k÷damp
In the following formula, damp is constant value, for example, can value be 200.
Step 209: according to this adjustment calculation voltage change.
Calculate the default voltage step long value of the crystal oscillator that is used for output local clock signal and the product of this adjusted value, obtain voltage change.
Step 210: according to voltage change the voltage of crystal oscillator is adjusted, so that crystal oscillator output and master clock clock signal synchronous.
The magnitude of voltage that the predeterminated voltage initial value addition of described voltage change and described crystal oscillator is obtained is as the adjustment magnitude of voltage of crystal oscillator, so that crystal oscillator output and described master clock clock signal synchronous.
Concrete, suppose that default voltage step long value is OcxoAdjCoef, initial voltage value is InitVol, then voltage change Vol calculates according to following formula:
Vol=InitVol+OcxoAdjCoef×c
k
Calculate the magnitude of voltage that each needs are adjusted by above formula, thereby make the clock signal clk 2 of crystal oscillator output to keep accurately synchronously with system's master clock.
Referring to Fig. 3, for using a kind of LET base station clock module diagram of the application's method embodiment:
Comprise 1588 from clock in the LET base station clock module among Fig. 3, soft phase-locked loop, FPGA and OCXC, wherein, 1588 comprise the MAC layer from clock, comprise 1588 controllers in the MAC layer.
By the mutual message data of Ethernet, 1588 controllers in the MAC layer contain the high accuracy phase locked algorithm to IEEE1588 master clock and 1588, can guarantee that 1588 is accurately synchronous from clock and master clock from clock.When 1588 reach accurately synchronously from clock and 1588 master clocks after, because the clock signal clk 1 of MAC layer can not offer local clock and use, therefore the polling tasks of MAC layer is receiving that at every turn 1588 master clocks send to 1588 in the data message of clock, and soft phase-locked loop can read the 1588 crystal oscillator count value F from clock by 64 bit registers in the MAC layer
1588, and read the crystal oscillator count value F of local clock by the FPGA register
LocalAs the reference source, the deviate that soft phase-locked loop utilizes above-mentioned reference source to calculate adjustment is adjusted OCXO, produces and the phase difference of the 1588 master clock signals reliable clock signal clk 2 in ± 1.5uS from making OCXC.The concrete process previous embodiment of adjusting deviate of calculating is described in detail, does not repeat them here.
Phase-locked loop (PLL) can utilize frequency and the phase place of the reference signal control loop internal oscillation signal of outside input and since phase-locked loop can realize output signal frequency to frequency input signal from motion tracking, so phase-locked loop is generally used for the closed loop tracking circuit.Phase-locked loop is in the process of work, and when output signal frequency equated with the frequency of input signal, output voltage and input voltage kept fixing phase difference value, and namely the phase place of output voltage and input voltage is lockable.Phase-locked loop is made up of phase discriminator (PD), loop filter (LF) and voltage controlled oscillator (VCO) three parts usually.Phase discriminator is used for differentiating the phase difference between input signal and the output signal, and output error voltage, noise in the error voltage and interference component are by the low-pass loop filter filtering, form control voltage of voltage-controlled oscillator Uc, the result that Uc acts on voltage controlled oscillator pulls to the loop input signal frequency to its output frequency of oscillation, when the two was equal, loop was locked, was called into lock.The control voltage of keeping locking is provided by phase discriminator, so leaves certain phase difference between two input signals of phase discriminator.
The embodiment of the present application is to be adjusted frequency and the phase place of the clock signal clk 2 of OCXO output, makes its and 1588 master clocks reach accurately synchronous, need to prove, this accurately can allow between the two error synchronously in certain scope.
Fig. 4 is the embodiment block diagram of the application's clock synchronization apparatus:
This clock synchronization apparatus comprises: interactive unit 410, acquiring unit 420, computing unit 430 and adjustment unit 440.
Wherein, interactive unit 410 is used for making from clock and system's master clock and realizes that by Ethernet interaction data message clock is synchronous;
Acquiring unit 420 is used for obtaining described from the crystal oscillator count value of clock and the crystal oscillator count value of base station local clock after synchronously;
Computing unit 430, be used for will described crystal oscillator count value from clock and described local clock the crystal oscillator count value as the reference source, the adjusted value of calculating local clock;
Adjustment unit 440 is used for by described adjusted value local clock being adjusted, so that the output of described local clock and described master clock clock signal synchronous.
Concrete, acquiring unit 420 can comprise (not shown among Fig. 4): the message receiving element is used for receiving first data message and second data message that described master clock sends continuously; The count value reading unit, be used for when receiving described first data message, read described from the first crystal oscillator count value of clock and the first crystal oscillator count value of described local clock, and when receiving described second data message, from described second data message, read described from the second crystal oscillator count value of clock and the second crystal oscillator count value of described local clock.
Concrete, computing unit 430 can comprise (not shown among Fig. 4): the deviate computing unit, be used for by calculating described from the first crystal oscillator count value of clock and the time interval of the second crystal oscillator count value from the standard crystal oscillator count value of clock, the described first crystal oscillator count value and the second crystal oscillator count value from clock, and according to the standard crystal oscillator count value of local clock, the first crystal oscillator count value and the second crystal oscillator count value and the described time interval of local clock, the deviate of the crystal oscillator count value of local clock in the unit of account time; The deviate unit that adds up is used for the deviate that adds up and obtain when some master clocks send datagram continuously, obtains the Accumulated deviation value; Average calculation unit is for the mean value of the historical adjusted value that calculates some local clocks; The adjustment calculation unit is used for this adjusted value according to described Accumulated deviation value and the described local clock of described mean value calculation.
Concrete, adjustment unit 440 can comprise (not shown among Fig. 4): the adjustment calculation unit, be used for calculating the default voltage step long value of the crystal oscillator that is used for output local clock signal and the product of described this adjusted value, and obtain voltage change; The magnitude of voltage adjustment unit, be used for magnitude of voltage that the predeterminated voltage initial value addition with described voltage change and described crystal oscillator obtains as the adjustment magnitude of voltage of described crystal oscillator, so that the output of described crystal oscillator and described master clock clock signal synchronous.
Referring to Fig. 5, be the embodiment block diagram of the application's base station clock equipment.
This base station clock equipment comprises:
From clock module 510, be used for realizing that by Ethernet interaction data message clock is synchronous with the system master clock;
Soft phase-locked module 520, be used for described synchronous from clock and master clock after, obtain described crystal oscillator count value from clock, and the crystal oscillator count value by described base station local clock, the crystal oscillator count value of described crystal oscillator count value from clock and described local clock as the reference source, is calculated the adjusted value of local clock;
Crystal oscillator module 530 is used for by described adjusted value local clock being adjusted, so that the output of described local clock and described master clock clock signal synchronous.
Further, can also comprise: FPGA module 540 is used for obtaining the crystal oscillator count value of described local clock, and the crystal oscillator count value of described local clock is offered described soft phase-locked module.
By to the description of above execution mode as can be known, base station side realizes that by Ethernet interaction data message clock is synchronous from clock and system's master clock in the embodiment of the present application, after synchronously, obtain from the crystal oscillator count value of clock and the crystal oscillator count value of base station local clock, will be from the crystal oscillator count value of the crystal oscillator count value of clock and described local clock as the reference source, calculate the adjusted value of local clock, by adjusted value local clock is adjusted, so that local clock output and master clock clock signal synchronous.By 1588 message protocols, do not have at local clock under the situation of reliable external timing signal input in the embodiment of the present application, by the count value of crystal oscillator count value instead of external clock signal, thereby realized the accurately synchronous of base station side local clock and master clock.
The technology that those skilled in the art can be well understood in the embodiment of the invention can realize by the mode that software adds essential general hardware platform.Based on such understanding, the part that technical scheme in the embodiment of the invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product can be stored in the storage medium, as ROM/RAM, magnetic disc, CD etc., comprise that some instructions are with so that a computer equipment (can be personal computer, server, the perhaps network equipment etc.) carry out the described method of some part of each embodiment of the present invention or embodiment.
Each embodiment in this specification all adopts the mode of going forward one by one to describe, and identical similar part is mutually referring to getting final product between each embodiment, and each embodiment stresses is difference with other embodiment.Especially, for system embodiment, because it is substantially similar in appearance to method embodiment, so description is fairly simple, relevant part gets final product referring to the part explanation of method embodiment.
Above-described embodiment of the present invention does not constitute the restriction to protection range of the present invention.Any modification of doing within the spirit and principles in the present invention, be equal to and replace and improvement etc., all should be included within protection scope of the present invention.