Summary of the invention
Technology of the invention solves the problems, such as: overcome the deficiencies in the prior art, proposes the tandem type in a kind of hybrid networkMethod for synchronizing time, by solving the time synchronization problem of father's layer network and sublayer website in hybrid bus network, extensionFather's layer network can carry out the website quantity of time synchronization.
The technical solution of the invention is as follows: the tandem type method for synchronizing time in a kind of hybrid network, the hybrid networkNetwork includes father's layer network and sublayer network, independent according to its between internal each website between father's layer network and sublayer networkMode carries out time synchronization, and shared adaptation website is arranged between father's layer network and sublayer network, shares adaptation website simultaneouslyUsing father's layer network time system time and the system time timing of sublayer network time, any website is as the time in father's layer networkSynchronously control website includes as follows by the method that shared adaptation website and any other website of sublayer network carry out time synchronizationStep:
(1), the time synchronization control site of father's layer network is to shared adaptation website sending time synchronization message, the timeSynchronization message includes father's layer time system time T that the shared adaptation website estimated receives the time synchronization message momentsyn;
(2), it after sharing adaptation website time of receipt (T of R) synchronization message, is parsed to obtain current time father's layer time systemTime Tsyn, while recording the local zone time T that time synchronization message receives the momentlocal_syn;
(3), using shared adaptation website as sublayer network time synchronization control site, the son for being adapted to website according to itself is sharedLayer time system time Tlocal, time synchronization is carried out to other websites in sub- layer network;
(4), it shares adaptation website and receives when having sublayer time system of the transmission of other any websites in sublayer networkBetween mark tsubTime label message after, father's layer time system time T for being obtained using newestsynAnd its corresponding timeSynchronization message receives the local zone time T at momentlocal_syn, by tsubBe converted to the time value T in father's layer networkafterSyn, form fatherThe layer network time marks message, and is fed back to the time synchronization between father's layer network realization hybrid network.
Father's layer network is 1553B bus network.
When the time synchronization control site of father's layer network is BC, the time synchronization control site of father's layer network is to sharedIt is adapted to the real-time sending time synchronization message of website, shared adaptation website expects father's layer time when receiving the time synchronization messageSystem time TsynFor father's layer time system time current time recorded in time synchronization control site.
When the time synchronization control site of father's layer network and shared adaptation website are RT, the time of father's layer network is sameControl site is walked to shared adaptation website sending time synchronization message and shared adaptation time synchronization control of the website to father's layer networkWebsite processed sends father's layer network time synchronization message method particularly includes:
(1.1), sender is first by time synchronization message or corresponding transmission of father's layer network time synchronization message depositIn address;
(1.2), the specific subaddressing for defining each RT website in network is communication request subaddressing, and sender will communicateRequest message is put in communication request subaddressing, and the communication request message includes the address RT for sending data, needs to send messageTransmission subaddressing, the word number of transmission, receive data the address RT, receive subaddressing, received word number;
(1.3), BC carries out periodical inspection to the communication request subaddressing of each RT website in network, when BC is in inspectionWhen finding the request subaddressing of any one RT website in the process has new communication request message, it will be sent in communication request messageThe message that the corresponding needs for sending the corresponding word number of subaddressing of the RT of data are sent, which is forwarded in communication request message, receives numberAccording to the corresponding reception subaddressing of RT in.
The shared adaptation website expects father's layer time system time T when receiving the time synchronization messagesynFor futureCorresponding father's layer time system time at the last BC inspection RT communication request subaddressing moment.
The sublayer time system time T for being adapted to website according to itself is shared in the step (3)local, in sub- layer networkOther websites carry out time synchronization method particularly includes: adaptation website as time synchronization control site in sublayer networkTo other website broadcast transmission time synchronization message reset frames at the time of ground series bus network timer starts to start timing;SoAfterwards, the sublayer time system time T for being adapted to website at itself is sharedlocalEach of whole moment second, the website into sublayer networkSending time synchronization message non-reset frame, the time synchronization message non-reset frame include the sublayer time system of shared adaptation websiteUnite time TlocalSecond place value, i.e. TlocalTime value after casting out millisecond value;Sublayer website is multiple in time of receipt (T of R) synchronization messageAfter the frame of position, then local sublayer network time is reset, sublayer network timer starts timing, time of receipt (T of R) synchronization message non-resetAfter frame, local seconds value is set, is allowed to synchronous with the shared adaptation sublayer network time seconds value of website, and portion of local millisecond timeZero is distinguished, local sublayer network timer continues timing since the seconds value, realizes network time synchronization.
It is Tr that father's layer network time is marked and is converted into the conversion operation of sublayer network time label expression way by definition(t), sublayer network time label is converted into father's layer network time and mark the conversion operation of expression way for Tr-1(t), by tsubTurnThe time value T being changed in father's layer networkafterSynMethod particularly includes:
TafterSyn=Tsyn+Tr-1(tsub-Tlocal_syn)。
The beneficial effect of the present invention compared with the existing technology is:
(1), the method for the invention realizes each website in hybrid network by the method for being embedded in time stratificationTime synchronization, this method preferably improve the scalability of clock synchronization system, can also save system bus website quantity, mentionHigh time synchronization efficiency;
(2), independent clock synchronization system is respectively established between father's layer network and sublayer network of the present invention, any one netThe deviation of network time system does not influence another network, and each localized network equipment can be according to itself function needs, certainlyIt adapts to define local accuracy of timekeeping;
(3), the present invention is by the time system of father's layer network and sublayer network, the conversion when shared adaptation website swapsAt unified time form of calculation, it is adapted to a variety of timing modes;
(4), the present invention receives sublayer network time label in shared fit point and then is carried out according to the most time of receipt (T of R) sameStep, then is converted to the time value in father's layer network for sublayer network time, relative to when often receiving the primary system time and just carrying outBetween for synchronous method, computing resource is greatly saved, exchange between grids time difference calculated result is consolidated network time systemRelative value, absolute value is smaller, and higher precision may be implemented;
(5), the present invention is directed to 1553B bus, proposes one kind without using mode command, total in 1553BAny RT website on line realizes a kind of method of active communication, avoid settling mode bring using mode command due toSignal interference, which generates illegal instruction, causes such as RT to close serious bus failure.
Specific embodiment
Below in conjunction with Figure of description and specific embodiment, the present invention is described in detail.
The present invention provides the tandem type method for synchronizing time in a kind of hybrid network, the hybrid network includes father's layer netNetwork and sublayer network, the method use the thought of time synchronization localization, time synchronization process are divided into father's layer network and sonThe synchronizing process of two localized networks of layer network, father's layer network and sublayer network possess the time synchronization control site of oneself, fatherTime synchronization, father's layer net are carried out according to its mode independent between internal each website between layer network and sublayer networkShared adaptation website is set between network and sublayer network, and shared adaptation website uses father's layer network time system time and son simultaneouslyLayer network time system time timing, any website is used as time synchronization control site in father's layer network, passes through shared adaptation and standsPoint carries out time synchronization with any other website of sublayer network.Sublayer network is using shared adaptation website as time synchronization control stationPoint is responsible for the local zone time by each Site synch of sublayer network internal for it, and time synchronization process is confined to sublayer networkInside, while the time synchronization control site of sublayer network is articulated in father's layer network, when individually carrying out father's layer network systemBetween it is synchronous, so that father's layer network and sublayer network form tandem type time synchronizing method, the time in sublayer network is by sharedAdaptation website is converted, to obtain the time value in father's layer network.This method preferably improves clock synchronization systemScalability, while the independence of his father's layer network and sublayer network time synchronization ensure that each localized network equipment can rootIt is needed according to itself function, it is adaptive to define local accuracy of timekeeping, while system bus website quantity can be also saved, it is same to improve the timeWalk efficiency.
The above method specifically comprises the following steps:
(1), the time synchronization control site of father's layer network is to shared adaptation website sending time synchronization message, the timeSynchronization message includes the shared adaptation website estimated father's layer time system time for receiving the time synchronization message moment estimatedTsyn;
(2), it after sharing adaptation website time of receipt (T of R) synchronization message, is parsed to obtain current time father's layer time systemTime Tsyn, while recording the local zone time T that time synchronization message receives the momentlocal_syn;
(3), using shared adaptation website as sublayer network time synchronization control site, the son for being adapted to website according to itself is sharedLayer time system time Tlocal, time synchronization is carried out to other websites in sub- layer network;
(4), it shares adaptation website and receives when having sublayer time system of the transmission of other any websites in sublayer networkBetween mark tsubTime label message after, father's layer time system time T for being obtained using newestsyn, and the time is same accordinglyStep message receives the local zone time T at momentlocal_syn, by tsubBe converted to the time value T in father's layer networkafterSyn, form father's layerNetwork time marks message, and will feed back to the time synchronization between father's layer network realization hybrid network.Below with 1553B networkAs upper layer network, for serial bus network is as the mixed form network of lower layer's network, the present invention is described in detail.
Embodiment
As shown in Figure 1, in the site network topology connection figure of the embodiment of the present invention, RT1 RTmaster, i.e. conductThe website of time synchronization behavior is initiated in 1553B bus, RT7 is shared adaptation website, and RT7 receives the 1553B bus synchronous of RT1Information, while RT7 is as Uartmaster, as the control site of serial bus network, it is responsible for synchronous serial bus network.RT7As a 1553B bus network website, when can receive the information of RT1, while can receive the band in serial bus networkBetween the information that marks, and time therein label is converted into the time value in 1553B bus network.Have two inside RT7Independent timer, one with 1553B bus network time synchronization, another and serial bus network time synchronization.EmbodimentIn universal serial bus select RS485 universal serial bus.
Using RT1 in 1553B network as time synchronization control site, with the website time synchronization in serial bus networkMethod include the following steps:
(1), for RT1 to RT7 sending time synchronization message, the time synchronization message includes that the shared adaptation website estimated is receivedTo father's layer time system time T at the time synchronization message momentsyn。
RT1 is primary to 1553B Site synch per minute, since 1553B bus is that typical time-devision system command/response formula is moreRoad multiplexed data bus, each RT website need to carry out messaging service by application BC for it to complete.
When the time synchronization control site RT1 of father's layer network is BC, RT1 directly transmits time synchronization message to RT7,RT7 expects father's layer time system time T when receiving the time synchronization messagesynFor recorded in RT1 current time father layer whenBetween system time.
When the time synchronization control site RT1 of father's layer network and shared adaptation website RT7 are RT, father's layer networkTime synchronization control site RT1 to shared adaptation website RT7 sending time synchronization message method particularly includes:
(1.1), time synchronization message is first stored in corresponding transmission subaddressing by RT1, and the time synchronization message includesThe RT7 estimated receives father's layer time system time T at the time synchronization message momentsyn;;
(1.2), define network in each RT website specific subaddressing be communication request subaddressing (such as: subaddressing30) communication request message that, RT1 is referred to as time synchronization request message is put in communication request subaddressing, and the time synchronization is askedAsk message format as follows:
| Word 1 | Word 2 | Word 3 |
| Send command word | Receive command word | Cyclic redundancy check |
Wherein, the communication subaddressing that command word 1 defines RT7 sending time synchronization message, the data word for needing to communicate are sentNumber, while Self address is informed into BC, and receive command word 2 and then define the address for receiving RT1 and subaddressing and needsThe data word word number of communication.It is as follows that this two command words are specifically defined format:
| Bit15 | Bit10~Bit14 | Bit5~Bit9 | Bit0~Bit4 |
| It is left 0 | Transmission/reception address | Transmission/reception subaddressing | Data word number |
When RT needs to send a message to BC, command word zero setting is received, sending command word indicates to send the address of RT and son groundThe data word number of location and the BC of being sent to.
(1.3), BC carries out periodical inspection to the communication request subaddressing of each RT website in network, when BC is in inspectionWhen finding the request subaddressing of any one RT website in the process has new communication request message, it will be sent in communication request messageThe message that the corresponding needs for sending the corresponding word number of subaddressing of the RT of data are sent, which is forwarded in communication request message, receives numberAccording to the corresponding reception subaddressing of RT in.
RT1 can also send the every other website in bus, including website RT7 by 1553B bus broadcast messageTime synchronization message, the time synchronization message definition are as follows:
In this way, the shared adaptation website RT7 expects father's layer time system time when receiving the time synchronization messageTsynFor corresponding father's layer time system time at following the last time BC inspection RT1 communication request subaddressing moment.The RT1 hairSend the interval of time synchronization message that should be longer than twice of value in period of BC inspection communication request subaddressing.
When remaining all website of entire 1553B network time synchronization control site RT1 periodically into network is sentBetween synchronization message, and after remaining website time of receipt (T of R) synchronization message, after correct to the CRC code verification in message, when obtaining currentCarve father's layer time system time Tsys, the time synchronization control station that local father's layer network time is changed in time synchronization messageThe spot net time, be allowed to time synchronization control site time synchronization, to realize father's layer network time synchronization.
(2), the website RT7 in 1553B bus receives father's layer network time synchronization message and to the CRC code school in messageAfter testing correctly, current time father's layer time system time T is obtainedsyn, and the local that time synchronization message receives the moment is recorded simultaneouslyTime Tlocal_syn。
(3), using RT7 as sublayer network time synchronization control site, RT7 is according to itself sublayer time system timeTlocal, time synchronization is carried out to other websites in sub- layer network.
Time control site of the RT7 as universal serial bus, by broadcasting the message to other websites in serial bus networkTime synchronization is carried out, is the time with the local serial bus network time synchronization of RT7 by the time unification of serial bus networkMethod particularly includes: RT7 is opened as time synchronization control site in serial bus network in local serial bus network timerBegin starting timing at the time of to other website broadcast transmission time synchronization message reset frames, it is then, whole each of then runningSecond moment, serially the website sending time synchronization message non-reset frame in bus network, the time synchronization message non-resetFrame includes second place value of the time synchronization control site in local serial bus network timer;Serial bus network website is receivingAfter time synchronization message reset frame, then the local serial bus network time being reset, serial bus network timer starts timing,After time of receipt (T of R) synchronization message non-reset frame, local seconds value is set, is allowed to and the shared sublayer network time for being adapted to website secondValue synchronizes, and local millisecond time portion is reset, and local serial bus network timer continues timing since the seconds value, realExisting network time synchronization.
Such as: RT7 is after being powered on and initialized local hardware, the serially website U in network1, U2, U3Send a frameTime synchronization message reset frame, the reset command attribute field of the time synchronization message reset frame are 0xAA, in serial networkWebsite U1, U2, U3After receiving that message, temporal is reset, and starts timing.Then, when RT7 is according to itself sublayerBetween system time Tlocal, every 1s moment, serially network sent a time synchronization message non-reset frame, and time synchronization message is multiplePosition frame and time synchronization message reset frame message format definition are as follows:
Website U in serial network1, U2, U3After receiving synchronization message, after check frame number, check code are errorless, knowOther flag of frame is time synchronization frame, then checks whether reset command mark is 0xAA, if so, thinking that the frame data are that the time is sameMessage reset frame is walked, local zone time is reset, time synchronization information is recognized if reset command mark is 0x55 next time for waitingIt is time synchronization message non-reset frame for the frame data, local seconds value is set according to 4~byte of byte 7, and when local millisecondBetween zero out portions.
(4), the sublayer time system time that has that RT7 receives the transmission of other any websites in sublayer network marks tuartTime label message after, father's layer time system time T for being obtained using newestsyn, and time synchronization message receives accordinglyThe local zone time T at momentlocal_syn, by tsubBe converted to the time value T in father's layer networkafterSyn, form father's layer network time markRemember message, and the time synchronization between father's layer network realization hybrid network will be fed back to.
Since RS485 universal serial bus belongs to exclusive type bus, i.e., can only at a time there be a website to send message, thereforeU1, U2, U3Message transmitting process dispatched and complete by RT7, in embodiment, RT7 dispatches U by I/O signal1, U2, U3InformationIt sends.The every 50ms of RT7 sends a pulse by I/O signal to gate a universal serial bus website, U1, U2, U3Detecting stringWhen row bus gating signal, send on a frame data to universal serial bus.When RT7 want sending time synchronization message reset frame andWhen time synchronization message non-reset frame, then preferential sending time synchronization message reset frame and time synchronization message non-reset frame give itHis three websites continue the universal serial bus website that gating needs to gate at next 50ms moment.Due to U1, U2, U3It replies toThe information of RT7 gates each website by RT7 and realizes, therefore, reply message in can there is no receiving station address indication field.But can be communicated with each other to each website in universal serial bus, then reply message in also should include receiving station address labelShow field.
Work as U1, U2, U3Returned message band having time label when, it is believed that the website using the time after being synchronized by RT7 asTime label returns to band time label t to RT7uartNet between time synchronization message, time synchronization message field is fixed between the netJustice are as follows:
It is assumed that definition father's layer network time mark be converted into sublayer network time mark expression way conversion operation beTr (t), sublayer network time label are converted into father's layer network time and marks the conversion operation of expression way for Tr-1(t).This implementationIn example, form when time value date Hour Minute Second millisecond meter in the 1553B bus network, that is, be expressed as Year,Month, Day, Hour, Minute, Second, Millisecond } structural body, the 1553B bus network time mark to milliThe time value of second unit indicates that the serial network time is indicated as unit of ms.Definition is to indicate shape with date Hour Minute Second millisecondThe time value of formula is converted to the conversion operation of the time value of millisecond unit as Tr (t): Tr (t)=(((((t.Year × 12+t.Month)×30+t.Day)×24+t.Hour)×60+t.Minute)×60+t.Second)×1000+t.Millisecond
Date Hour Minute Second millisecond is converted into as the conversion operation of the time value of representation using the time value of millisecond unitFor Tr-1(t) then, Tr-1(t) it can indicate are as follows:
Tr-1(t) [t/ (86400 × 30 × 12 × 1000)] .Year=,
Tr-1(t) [(t% (86400 × 30 × 12 × 1000))/(86400 × 30 × 1000)] .Month=,
Tr-1(t) [(t% (86400 × 30 × 1000))/(86400 × 1000)] .Day=,
Tr-1(t) [(t% (86400 × 1000))/(3600 × 1000)] .Hour=,
Tr-1(t) [(t% (3600 × 1000))/(60 × 1000)] .Minute=,
Tr-1(t) [(t% (60 × 1000))/1000] .Second=,
Tr-1(t) .Millisecond=t%1000.
Wherein, brace " [] " indicates that downward rounding operation, percentage sign " % " indicate complementation.
If the time between the net that the website in serial bus network returns in time synchronization message is tsub, to millisecond listThe time value of position indicates, then the serial bus network time is converted into 1553B bus network time TafterSynMode it is as follows:
TafterSyn=Tsyn+Tr-1(tsub-Tlocal_syn)
Tr-1(tsub-Tlocal_syn) it is the exchange between grids time difference.
When RT7 sends the communication mode and RT1 that father's layer network time marks message feedback to father's layer network to RT7Between synchronization message mode it is identical.
Present invention could apply to the different types of network of N layer architecture, (such as the 1st layer network is Ethernet, layer 2 networkFor 1553B bus network, the 3rd layer be serial bus network etc.), N >=2 are top-down to be followed successively by 1~n-th layer netNetwork, time synchronization between each website inside every layer network, the time is mutually indepedent between each website between each layer network, i-th layer of netThere are a sharing site between network and i+1 layer network, i >=1, the sharing site is provided simultaneously with the i-th layer network and i+1Two independent timers of layer network, the method for synchronizing time using above-mentioned cascade method realize between each layer network whenBetween it is synchronous, every level-one includes adjacent two layers network, and any website is as time synchronization control site using in upper layer network, underWebsite time synchronization in layer network.
In order to guarantee timing tracking accuracy, each website in network layer locally has clocking capability, and accuracy of timekeepingFor Millisecond, i.e., each layer network internal time synchronization accuracy is Millisecond.
The present invention is not described in detail content and is known to the skilled person technology.