A kind of distributed time service of synchronously realizing based on message and punctual method
Technical field
The present invention relates to a kind of industrial equipment precision time service and punctual method, belong to technical field of industrial control.
Background technology
Usually the mode obtaining absolute time in the equipment of industrial control field exports the temporal information of B code or extended formatting to terminal equipment by external clock reference equipment such as () gps receivers, realize the time service function to equipment, every platform equipment has by this point-to-point mode and clock source acquisition time information, but it is many at some number of devices, and the application scenario of synchronous operation, such as transforming plant distributed protective device, up to a hundred protected locations may be had, these protected location synchronous operations, and all need accurate absolute time, if every platform equipment road all uses an external clock reference to provide accurate clock, whole clock system will complex, bad maintenance, point-to-point time service mode is no longer applicable in this case.
Summary of the invention
For solving the deficiencies in the prior art, the object of the present invention is to provide a kind of distributed time service of synchronously realizing based on message and punctual method, amplifying message agreement on the basis that message is synchronous, realize message synchronous while, ready-made transmission channel is utilized to realize the precision time service of accurate one master and multiple slaves, and at algorithm of keeping time from device end optimization, realize high-precision punctual function.
In order to realize above-mentioned target, the present invention adopts following technical scheme:
The distributed time service synchronously realized based on message and a punctual method, is characterized in that, comprise the steps:
1) master unit send message, send heading moment obtain second in century value and nanosecond counter value, will the synchronous head of message be put into;
2) subelement receives message, resolve obtain second in century value and nanosecond value, the temporal information according to message transmissions delay value compensation message inside obtains the value of current absolute time;
The formula compensated is: the value of current absolute time=century second+nanosecond+transmission delay value;
3) mode that subelement uses speed to combine approaches the master unit time fast: if the time difference of subunit computes local zone time and master unit is greater than set point, use large paces rapid adjustment local zone time; The time difference of When subunits calculating local zone time and master unit, when reaching set point, uses little paces to adjust local zone time; Described large paces and little paces can adjust according to the rate request approached.
4) master unit uses the mode of broadcast to send time service information to each subelement:
If communication is normal, subelement is according to deviation adjusting paces, constantly approach the time of master unit, the aging learning method of lasting average is adopted in the process of approaching, the last absolute time receiving message of study, the time receiving master unit message for n time that study master unit is nearest, calculate the average time interval △=(T of this n time message
n-T
0)/n and remainder △ t=(T
n-T
0) %n;
If occur, communication abnormality or subelement are not normally sending more than △ certain hour or are receiving message, and subelement enters punctual flow process; Described certain hour sets based on experience value; Remainder, according to average △ and remainder △ t, compensates in each interrupt INT, produces local INT and pulse per second (PPS) by subelement uniformly.
Aforesaid a kind of distributed time service of synchronously realizing based on message and punctual method, it is characterized in that, described subelement is provided with several, by the communication board message transmission of optical-fibre channel and master unit; Described master unit is by the quantity of communication extension plate configuration subelement.
Aforesaid a kind of distributed time service of synchronously realizing based on message and punctual method, it is characterized in that, described master unit adopts crystal oscillator to safeguard nanosecond counter; Described nanosecond, counter reset at pulse per second (PPS) rising edge, accumulated counts between rising edge.
The beneficial effect that the present invention reaches:
1) utilize the message transfer system of ready-made message one master and multiple slaves, channel multiplexing, system configuration is simple.
2) time service information is attached to synchronizing information inside, utilizes original message synchronization mechanism, and do not need extra special message to realize time service and punctual, process is simple, pair time fast, overhead is little;
3) subelement utilizes the aging and remainder penalty method of different depth average can realize different punctual precision, flexibly punctual;
4) favorable expandability, can with configuring different number sub-cells according to different occasion, and autgmentability flexibility is strong.
Accompanying drawing explanation
Fig. 1 is flow chart of the present invention;
Fig. 2 is the framework schematic diagram of system;
Fig. 3 is message transmissions schematic diagram;
Fig. 4 is message structure schematic diagram.
Embodiment
Below in conjunction with accompanying drawing, the invention will be further described.Following examples only for technical scheme of the present invention is clearly described, and can not limit the scope of the invention with this.
The present invention be utilize FPGA (programmable gate array) to realize the distributed packet of one master and multiple slaves is synchronous, time service and Time keeping system, main equipment utilizes FPGA as the transmission and reception controller of message, and interrupting amplifying message content on synchronous basis, embed master clock information, the precision time service to each subset is realized by the message of broadcast, subset receives time service message simultaneously, temporal information in analytic message, and utilize the synchronous delayed data calculated and transmitting-receiving and local optimized algorithm, realize keeping time with the synchronous of main equipment and high accuracy function.
The configuration diagram of system is as Fig. 2, be made up of a master unit and several subelements, subelement is by the communication board message transmission of optical-fibre channel with master unit, and master unit passes through communication extension plate, can the quantity of flexible configuration subelement, be applicable to different application occasion.
Transmission between master unit and subelement as shown in Figure 3, M-SMSG message is the message that master unit sends to subelement, S-MMSG is the message that subelement is sent to master unit, T1, T3 are respectively the Interruption INT moment of master unit and subelement, this time trigger message sends, and T2, T4 are respectively the time that subelement and master unit receive the other side's message.
As long as be aware of these four times of T1, T2, T3, T4, the skew of boss's unit interrupt INT and channel transfer time delay Delay just can be calculated.
In the message sent to subelement in the INT moment at master unit, there is a synchronous head, synchronous head content is just with interrupting synchronous time scale information, concrete mode is as follows: master unit obtains absolute time information generation value second in century and pulse per second (PPS) PPS by outside clock source, and master unit uses High Precision Crystal Oscillator to safeguard nanosecond counter, this counter resets at PPS rising edge, accumulated counts between rising edge.
When master unit sends message, send heading moment obtain second in century value and nanosecond counter value, they are put into the synchronous head of message, the second in century that subelement receives packet parsing acquisition is exactly the current numerical value of certificate to the second of time, nanosecond, value was the position that master unit delivery time is between two seconds, subelement obtains the absolute time of master unit when these information are exactly master unit transmission message, because message transmissions needs the time, the temporal information that subelement must repay message inside according to the value complement of message transmissions time delay Delay after receiving message just can obtain the value of current absolute time.
The formula compensated is: the value of current absolute time=century second+nanosecond+transmission delay.
In the process of approaching the master unit time, what subelement used speed to combine approaches mode fast, if the time difference of subunit computes local zone time and master unit is greater than certain set point, use large paces rapid adjustment local zone time, when reaching set point, use little paces to adjust, the mode of approaching that this speed combines can effectively improve velocity of approch, efficiency and the uniformity.
Master unit uses the mode of broadcast to send time service information to each subelement, if there is communication abnormality, subelement can realize high-precision punctual function automatically.Use the crystal oscillator preventive maintenance time information of high stability in each subelement, in the normal situation of communication, constantly revise deviation, constantly approach the time of master unit, meanwhile, in the process of approaching, use lasting aging learning method, the last absolute time receiving message of study.In the present embodiment, n time (can adjust average degree of depth n according to required precision, larger precision is higher) that study master unit is nearest, n=1025, receives the time of master unit message, then calculates average time interval and the remainder of these 1025 messages:
△=(T1024-T0)/1024
△t=(T1024-T0)%1024
Subelement sends abnormal more than △ certain hour (configurable) or receive message, judge that communication disruption is abnormal, enter punctual flow process, the △ obtained according to self study produces local with △ t (mending in each interrupt INT uniformly) by subelement, produce local INT and PPS, under the crystal oscillator condition using high stability, it is per hour that time keeping error is less than 1us.
Distributed time service proposed by the invention and punctual method, through checking and the test of reality, structure is simple, and communication overhead is little, and precision is high, needs the Distributed Application occasion of synchronous operation at substation relay protection etc., has very high applied value.
The above is only the preferred embodiment of the present invention; it should be pointed out that for those skilled in the art, under the prerequisite not departing from the technology of the present invention principle; can also make some improvement and distortion, these improve and distortion also should be considered as protection scope of the present invention.