Time synchronization method in a data transmission system

Abstract: A method for synchronizing the times of a master clock provided in the master station and slave clocks provided in the slave stations in a data transmission system consisting of the master station as a data transmission control station and slave station and/or stations for bothway data transmis­ sion, comprising the steps for; sending the slave clock time survey command code to the slave station to the master sta­ tion and storing the time of the master clock in such a timing as completing transmission of such code within the master station; transmitting the stored received slave clock time on the occasion of transmitting the preset slave clock time data to the master station after the slave station which has re­ ceived the command code once stores the time of the slave clock in such a timing as completing the reception within the slave station; receiving such slave clock time data and stor­ ing the master clock time in such a timing as completing the reception within the master station and obtaining a time dif­ ference between the master clock and the slave clock consi­ dering the data transmission delay time between the master station and the slave station based on various data of these slave clock time and master clock time and then transmit­ ting the time correction data to the slave station based on such time difference; and correcting the time of slave clock by the slave station on the basis of such time correction data.

Description: Field of the Invention The present invention relates to a time synchronization method in a data transmission system and particularly to a time synchronization method to synchronize times of clocks respectively provided at both master station and distant slave station or stations which are transmitted bidirectional data transmissions, by means of the data transmission line and/or lines. Description of the Prior Art Necessity for accurate record and analysis of operation times and procedures of respective units such as protection apparatus, for example, of electrical power generating facilities, power transmission facilities or power substation facilities of various electrical stations located in broad region becomes increasingly apparent with sophisticated operations of electrical power systems in recent years. In addition, it is also necessary to match the timings for metering data in the slave station located in different points even on the occasion of collecting the metering data at each electrical station to the slave stations provided to respective electrical stations and the master station as the control station through the data transmission line. Therefore, assumed here as a data transmission system, for example, is the method that the bidirectional data transmission is carried out between the master station and each slave station using the polling/selecting system, a clock circuit is respectively provided to the master station and each slave station of the transmission system, the operation data of various units such as said protection apparatus is transmitted with the code of time of such clock circuits, data is measured simultaneously in each slave station at the predetermined time, and such measured data is once stored in the associated memory, etc. and then transmitted to the master station through the transmission line. The polling/selecting system employed here means the centralized control by the master station (generally a computer) provided as the control station for establishment of data link. For example, this system is employed, for example, in such a case that flow of data is controlled by the control station like the multipoint-type system. In case of this system, the master station transmits the polling code including slave station address in accordance with predetermined format in order to urge the slave station (normally, a terminal) as the mate station for calling to send data. Moreover, in case of sending data from the master station, the master station issues a selecting code including slave station address to each slave station to make preparation for reception. In the time synchronization as described above, it is important that the clock circuits of the master and slave stations are synchronized within such a range of error as not resulting in a problem for practical use. However, since the time required for data transmission has come to by far exceed the time within the allowable error range, particular measures have been required for the method of synchronization. As an example, there is a "remote supervisory control apparatus" described in Japanese Laid-open Patent No. JP-A-57-69496 applied to the Patent Office in Japan by MITSUBISHI DENKI KABUSHIKI KAISHA (Mitsubishi Electric Co., Ltd.), and laid open on April 28, 1982. Fig. 1 is a block diagram illustrating the outline of structure of the conventional data transmission system disclosed in the above patent entitled "remote supervisory control apparatus". For example, in this figure, the data transmission system consisting of Supervisory Control And Data Acquisition (hereinafter, abbreviated as SCADA) system comprises a master station 1 as the control station, slave stations 2, 3, ... as the mate stations of such master station and data transmission path 5 connecting said master station 1 and slave stations 2, 3, .... Said master station 1 comprises a central processing unit (CPU) 10, a display panel 11 which displays conditions of said slave stations 2, 3, ..., a control desk 12 which sends a control command to said slave stations 2, 3, ..., a typewriter 13 which records operations of this data transmission system and data sent from slave stations 2, 3, ..., an output circuit 14 provided between an internal bus 51 connected to said CPU 10 and said display panel 11, an input circuit 15 connected respectively to said internal bus 51 and said control desk 12, a typewriter control circuit 16 connected respectively to said internal bus 51 and said typewriter 13, a master clock 17 which is connected to said internal bus 51, a code sending and receiving circuit 18 which is connected to said internal bus 51, and a modem circuit 19 which forms said data transmission path 5 and is provided between external bus 5A which connects the master station 1 and slave station 2 and said code sending and receiving circuit 18. Meanwhile, the slave station 2 or 3 comprises a CPU 20 or 30 which performs processings such as transmission and reception of data with an electrical station to which a slave station is provided and with the master station, an internal bus 52 or 53 connected to said CPU 20 or 30, an output circuit 24 or 34 which is connected to such internal bus 52 or 53 and provides a measuring command, etc. to an electrical station, etc. to which a slave station is provided, an input circuit 25 or 35 which is connected to said internal bus 52 or 53 and inputs measured data, etc. of said electrical station, etc., a slave clock 27 or 37 which is connected to the internal bus 52 or 53, a code sending and receiving circuit 28 or 38 which is connected to the internal bus 52 or 53, and a modem circuit 29 or 39 which is provided between such code sending and receiving circuit 28 or 38 and the external lines 5A and 5B or 5B and 5C which form said data transmission path 5. Operations of data transmission system based on such structure will then be explained. Fig. 2 illustrates a time chart of codes transmitted and received between the master station 1 and the slave stations 2, 3, .... The code transmitted by the master station 1 is illustrated at the upper most part and the codes transmitted by the slave stations 2 and 3 are also illustrated respectively at the intermediate and lower portions. In the sending code of the data transmission system, there is the polling signal S1 which is sequentially transmitted from the sending and receiving circuit 18 of the master station 1 to the slave station 2 or 3. This polling signal S1 reaches the slave station 2 after a transmission delay time τ₁ and the slave station 3 after a transmission delay time τ₂, through the modem circuit 19 and data transmission path 5, respectively. On the other hand, at each slave station 2 or 3, status of contacts to be watched such as the auxiliary contacts, for example, of protection relay or circuit breaker, etc. are input to the input circuit 25 or 35, and status change of said contacts may be detected by the CPU 20 or 30 through the periodical scanning for the input circuit 25 or 35. If such status change is detected, such input address number and novel state are stored within the memories (not illustrated) of respective slave stations 2 or 3 with the time data of such status change read by the slave clock 27 or 37. If it is assumed here that said polling signal S1 is destinated, for example, to the slave station 2, CPU 20 returns content of status change stored in said memory not illustrated and detection time of such status change (or such and such if status change is not detected) to the master station 1 as the return code S2. This return code S2 is transmitted from the code sending and receiving circuit 28 after a constant time t P from completion of reception of said polling signal S1 and is then transmitted to the master station 1 through the modem circuit 29 and external bus 5A. As illustrated in Fig. 2, the return code S2 from the slave station 2 reaches the code sending and receiving circuit 18 of master station 1 after a transmission delay time τ₁, while the return code S2 from the slave station 3 reaches said circuit 18 after the transmission delay time τ₂. Operations in the master station 1 will then be explained. Upon reception of the return code S2 from the slave station 2 or 3 through the code sending and receiving circuit 18, CPU 10 updates stored contents of a memory not illustrated within the master station 1. Moreover, CPU 10 renews display on the display panel 11 through the output circuit 14 and then records status changes of the slave station 2 or 3 by operating the typewriter 13 through the typewriter control circuit 16. CPU 10 of the master station 1 encodes the address and-the state to be controlled (for example, ON/OFF status of switch) of the facilities in an electrical station, for example, to which a relevant slave station, for example, like the slave station 2 and this slave station are provided, on the basis of an input from the control desk 12 through the input circuit 15 and then outputs this code to the code sending and receiving circuit 18. This code sending and receiving circuit 18 receives the information from CPU 10 and sends a selection/control code S3 to the corresponding slave station, for example, the first slave station 2 in place of the polling signal. At the slave station, the code sending and receiving circuit 28 or 38 receives this selection/control code S3 and in case the first slave station 2, for example, is selected, the code sending and receiving circuit 28 of such slave station 2 receives such selection/control code S3 and gives a control command to the facilities, for example, of an electrical station to which said first slave station 2 is provided through the output circuit 24. When the relevant facilities respond to this command, the code sending and receiving circuit 28 sends the code as an answer code S4 as in case of the return code S2 based on said status change. In this case, transmission is carried out, as is obvious from Fig. 2, by the code sending and receiving circuit 28 after a constant time t P from reception of the selection/control code S3 and thereby said code S4 is transmitted to the master station 1 through the modem circuit 29 and external bus 5A. Explanation and illustration for the third and the succeeding slave stations are omitted but structure and operation of these slave stations are exactly the same as those of the first and second slave stations 2 and 3 described previously. In case of analyzing conditions of the system considered as the object of supervisory control based on the data collected through such ordinary remote supervisory control operations, the time information sent from the slave station 2 or 3 must be accurate and accordingly, the time setting is carried out periodically (for example, once at twelve o'clock midnight in every day) to the slave clocks 27, 37 of slave stations 2, 3 for time synchronization to the master clock 17. Namely, CPU 10 of the master station 1 transmits the time setting code S5, encoded time T₀ to be set (for example, 24 o'clock 00 minute 00 second 000 millisecond), to each slave station 2, 3, ... through the modem circuit 19 and data transmission path 5 from the code sending and receiving circuit 18 when the preset time comes close. The slave stations 2, 3, ... having received such time setting code S5 with the code sending and receiving circuits 28, 38 store the time to be set in the memory of CPUs 20, 30 as the preparation for input of a setting command signal S6. CPU 10 of the master station 1 supervises the time of master clock T₀ and transmits the setting command signal S6 from the code sending and receiving circuit 18 to the slave stations 2, 3, ... through the modem circuit 19 and external buses 5A, 5B ... of data transmission path 5 when the time of master clock reaches the preset time T₀. The setting command signal S6 reaches the slave station 2 after the transmission delay time τ₁ from the preset time T₀ and to the slave station 3 after the transmission delay time τ₂. When this setting command signal S6 reaches, CPU 20 of the slave station 2 sets the time of slave clock 27 to T₀ + τ₁, while CPU 30 of the slave station 3 sets the time of slave clock 37 to T₀ + τ₂. Here, the slave stations 2, 3, ... measure the transmission delay times τ₁, τ₂, ... and store such delay times to the memory of CPUs 20, 30, ... and then add to the designated setting time T₀ by the time setting code S5. Upon completion of processing for time setting, CPU returns again to the remote supervisory control operation by sending the polling signal S1. Since the conventional time synchronization method of the prior art is thus constituted, it accordingly results in the problem that the time synchronization is carried out on the real time basis, operations do not have allowance, and CPUs of the master station and slave stations hold the other operations and must execute only the operations of time synchronization. Moreover, the prior art described previously also has provided a problem that a transmission delay time between the master station and slave stations must be measured previously and stored as the data in CPU and if the transmission route is changed, said operations must be carried out again. In addition, there has been a problem in the system which always periodically executes data transmission that transmission of time synchronization signal on the real time basis requires temporary stop of data flow. US-A-4 473 889 discloses a method for correlating in a digital data acquisition system the time sequence of a group of events at locations remote from the master station. The method corrects the time tags on the events record for the signal transmission time between the master and remote stations and also takes into account the turnaround time at the remote station. In addition, compensation is made for the drift of the remote clocks with reference to the master clock. SUMMARY OF THE INVENTION It is an object of the present invention to provide a time synchronization method in the data transmission system in which neither extra transmission line for the time synchronization is necessary nor interruption/heavy loading to CPU is necessary for the time synchronizing operation. It is the second object of the present invention to provide a time synchronization method in the data transmission system, especially in a polling/selecting system in which the procedures of separately measuring a transmission delay time are eliminated and any modification of the transmission delay time data is not required against the change of transmission route. It is the third object of the present invention to provide a time synchronization method in the data transmission system in which time synchronization can be established between the master clock of the master station and slave clocks of the slave stations under the condition that flow of data transmission is not stopped but continued, not only in case said system executes the data transmission by polling/selection but also in case by automatic cyclical transmission. In order to achieve the objects described previously, the time synchronization method in the data transmission system to which the present invention pertains discloses that a slave station transmits a code of slave clock time data to the master station in accordance with the code of slave clock time survey command sent from the master station, the master station calculates the time difference between the master clock and the slave clock taking the transmission procedure and the transmission delay time into consideration, such time difference is transmitted to the slave station as the code of time correction data, and the time of slave clock is corrected in the slave station in accordance with time difference received from the master station and thereby the times of master clock and slave clocks are synchronized. As described above, on the occasion of correcting difference between the times indicated by the master station and slave station on the basis of the transmission delay time between the master station and slave stations, calculation of time correction data is carried out as explained below and the time of slave clock is corrected and synchronized with the master clock on the basis of such time correction data. Namely, the time of slave clock which is read at a constant predetermined time before the partition of frame which devides the flow of data to be transmitted and is stored in the register the time stored in said register is transmitted as the data during said frame following such partition, said master station stores in the register the time of master clock when it has received said frame, calculates an estimated time of slave clock by subtracting the sum of the length of the 1-frame of code, said constant predetermined time and transmission delay time from said stored time, transmits the difference, as the time correction data, between such estimated time and the time of said slave clock input as the data from said slave station, and said slave station receives such data and synchronizes said slave clock to said master clock by adding said difference to the time of said slave clock in order to correct said time. Furthermore, deviation of synchronized time between the master clock and slave clocks can be corrected by the following procedures. A slave station transmits the time of said slave clock, which has been read at predetermined constant time before the partition of frame of code being transmitted to the master station and stored in the register, as the data in said frame following such partition in accordance with the time survey command sent from the master station, while said master station stores the time of said master clock in such a timing of having received said frame to the register and then calculates an estimated time of slave clock which is equal to that obtained by adding a sum of the transmission delay time, the time up to transmission of code from readout of time of said slave clock and length of code 1 frame to the time of said slave clock having been input as the data from said slave station, transmits the difference between said estimated time of slave clock and the time of said master clock at the timing of having received said frame to said slave station as the time correction data, and said slave station receives such time correction data and synchronizes said slave clock to said master clock by adding said difference to the time of said slave clock for correction. BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a block diagram illustrating outline of structure of a data transmission system for explaining a time synchronization method of the prior art. Fig. 2 is a time chart of bothway data transmission between the master station and slave stations in the data transmission system of Fig. 1. Fig. 3 is a block diagram illustrating outline of structure of the data transmission system to which the time synchronization system by the first embodiment of the present invention pertains. Fig. 4 is a time chart for explaining operations of the system illustrated in Fig. 3. Fig. 5 is a block diagram illustrating outline of structure of Supervisory Control And Data Acquisition (hereinafter referred to as SCADA) system to which the time synchronization method by the second embodiment of the present invention pertains, and Fig. 6 is a pictorial presentation for explaining outline of data to be transmitted or received between the master station and the slave station in the system illustrated in Fig. 5. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS The preferred embodiments of the time synchronization method in the data transmission system to which the present invention pertains are described in greater detail with reference to the accompanying drawings. Fig. 3 and Fig. 4 are accompanied for explaining the first embodiment of the present invention and those given the same reference numbers as those in Figs. 1 and 2 indicate the same or corresponding portions in each figure. In Fig. 3, the master station 1 comprises a first register 41 and a second register 42 which are respectively connected with the internal buses 51 and also with the master clock 17 and code sending and receiving circuit 18. In addition, the first slave station 2 comprises a slave clock register 21 respectively connected with the internal bus 52 and also with the slave clock 27 and code sending and receiving circuit 28 and the second slave station 3 also comprises a slave clock register 31 respectively connected with the internal bus 53 and with the slave clock 37 and code sending and receiving circuit 38. In case of Fig. 3, many slave stations such as the third, fourth and the succeeding slave stations not illustrated are also connected as in case of Fig. 1. Operations of the structure described previously are explained hereunder. An ordinary remote supervisory control operation is the same as operations of the prior art. Namely, CPU 10 of the master station 1 executes once the processing for time synchronization of slave clock 27 or 37 in every constant period (there is dispersion from once in every hour to once in every day in accordance with the accuracy of slave clocks 27, 37). Fig. 4 is a time chart which illustrates time relation of code to be transmitted or received in such a time between the master station 1 and the slave stations 2, 3, .... The sending code of master station 1 is indicated at the upper most part, while the sending codes of the first and second slave stations 2, 3 at the lower part, respectively. Here, since operations of slave stations 2, 3 ... are similar to each other, only the first slave station 2 is explained hereunder. The code sending and receiving circuit 18 of the master station 1 transmits the code S11 of the slave clock time survey command to the first slave station 2 and stores the time T M of the master clock 17 in such a timing as completing transmission of code S11 of such slave clock time survey command to the first register 41. The code S11 of said slave clock time survey command reaches the first slave station 2 after the transmission delay time τ₁ and when the code S11 of such slave clock time survey command is received, the first slave station 2 stores the time T S of the slave clock 27 in the timing of completing transmission in the slave clock register 21. The code S12 of time data of the slave clock which starts transmission after a constant period t P is transmitted with the time data stored in said slave clock register 21. In the master station 1, when reception of the code S12 of slave clock time data sent from the slave station 2 after the transmission delay time τ₁ is started, the time T De of the master clock 17 in such start timing is stored in the second register 42. Thereafter, CPU 10 of the master station 1 calculates the transmission delay time τ₁ between the master station 1 and slave station 2 by the following equation from the time T M and T De stored in said first and second registers 41, 42. τ₁ = (T De - t P - T M )/2 Next, a time difference T D ₁ between the master clock 17 and slave clock 27 is calculated by the following equation considering such transmission delay time τ₁ and it is transmitted to the slave station 2 as the code S13 of the time correction data. T D1 = T M + τ₁ - T S When the slave station 2 receives the code S13 of such time correction data, CPU 20 thereof reads the time of the slave clock 27, adds the time difference T D1 (including the code) transmitted together with the code S13 of time correction data to such time data and then sets the time of the slave clock 27 to said time. Thereby, the time of the slave clock 27 is synchronized with the time of the master clock 17. The slave station 2 sends the certification code S14 to the master station 1 in order to certify time synchronization after setting the time of slave clock 27 and the content of such code is certified in the master station 1. It is also possible that operations for certification are carried out on the occasion of issuing the next slave clock time survey command and status change or content can be started in place of the certification code S14. Thereafter, operations return to the transmission and reception of code for ordinary remote supervisory control. Moreover, it is not always required to immediately execute the operation for time correction described above and it is enough that CPU 10 of the master station 1 transmits the code of time correction data S13 in an adequate timing after detecting the time difference between the master clock 17 and slave clock 27 from the code S11 of the slave clock time survey command and the code S12 of the slave clock time data which is an answer to said code S11. In the abovementioned embodiment, a transmission delay time is once calculated and then time difference is obtained based on such delay time, but the same result can also be obtained by the procedures that it is calculated directly by substituting the equation for obtaining the transmission delay time to the equation for obtaining time difference from the times of the first and second registers, time of slave clock register and a constant period up to the transmission start of code of slave clock time data in a slave station. In addition, since transmission delay time can be calculated anytime by each transmission of polling signal and reception of return signal thereto, time difference can be calculated immediately, for example, by storing the data of several times of transmission and reception in the past and abnormal value resulting from disturbance of code due to a noise can be excepted from data. Next, the second embodiment of the present invention will be explained by referring to Fig. 5 and Fig. 6. This second embodiment relates to the time synchronization of the master clock 17 and slave clocks 27 and 37 between the master station 1 and first and second slave stations 2 and 3 forming Supervisory Control And Data Acquisition (so-called, SCADA) system. In Fig. 5, the like elements as those in Fig. 1 or Fig. 3 are given the like reference numerals. In the same figure, the internal bus 51 of the master station 1 comprises a code sending circuit 101 for data transmission with the first slave station 2, a modulation circuit 102 provided between such code sending circuit 101 and external line 50A forming the data transmission path 5, a demodulation circuit 103 connected to an external line 50B for returning the data sent from the first slave station 2 and a code receiving circuit 104 provided between such demodulation circuit 103 and the internal bus 51. Moreover, the master station 1 comprises, for data transmission with the second slave station 3, a code sending circuit 105, a modulation circuit 106, a demodulation circuit 107 and a code receiving circuit 108. The code receiving circuit 104 which receives data from the second slave station 2 is also connected to the first register 41 and the code receiving circuit 108 which receives data from the second slave station 3 is also connected to the second register 42. The first slave station 2 comprises a demodulation circuit 201 connected to said external line 50A, a code receiving circuit 202 provided between such demodulation circuit 201 and internal bus 52, a code sending circuit 203 connected to the internal bus 52 and a modulation circuit 204 provided between the code sending circuit 203 and external line 50B. The code sending circuit 203 is connected to the register 21. Moreover, the second slave station 3 comprises a demodulation circuit 301 which demodulates the signal transmitted from the modulation circuit 106 of the master station 1 through the external line 55A, a code receiving circuit 302 provided between such demodulation circuit 301 and internal bus 53, a code sending circuit 303 connected to the internal bus 53 and a modulation circuit 304 provided between the code sending circuit 303 and external line 55B. Said code sending circuit 303 is also connected to the register 31 which is connected to the slave clock 37. The data transfer operations in the SCADA system illustrated in Fig. 5 are explained by referring to the time chart of Fig. 6. First, ordinary remote supervisory control and operation records are explained hereunder. In Fig. 5, CPU 20 of the first slave station 2 scans conditions of contact to be supervised (such as auxiliary contacts of protection relay or circuit breaker, etc.) input to the input circuit 25 and stores such conditions. If status change occurs in the input contact, the address number of such contact and novel condition are transferred to the code sending circuit 203. The code sending circuit 203 always transmits the code to the master station 1. Upon reception of address of said status change contact and data of new status from CPU 20, the code sending circuit 203 transfers such address and data to the modulation circuit 204 in order to send the data to the master station 1 on the code frame next to the code being transmitted at that time. An example of code transmitted by the code sending circuit 203 is illustrated as the data 2S of the slave station 2 of Fig. 6. In Fig. 6, D is each frame of code and F is a flag indicating partition between the frames D . A pattern of flag F is fixed but the frame D changes including the length thereof in accordance with the content to be transmitted. Moreover, as the content, a control part for certain transmission and reception and a code check part are generally added in addition to the data to be transmitted. As an example of the code format, there is the high-level data link control (hereinafter referred to as HDLC) procedure. Now, referring again to Fig. 5, the modulation circuit 204 modulates the code received from the code sending circuit 203 into the signal, for example the frequency shift keying (hereinafter referred to as FSK) signal which is suited to the signal transmission line and is resistive to influence of noise and then transmits it to the master station 1 through the external bus 50B which forms the signal transmission line. In the master station 1, the demodulation circuit 103 receives such signal, demodulates the signal into a DC pulse and then transfers the pulse to the code receiving circuit 104. The code having reached the code receiving circuit 104 is delayed as long as the transmission delay time t P as in case of the sending code 2S like the receiving data 2R of the master station 1 illustrated in Fig. 6. CPU 10 of the master station 1 reads the received content from the periodical scanning or the interrupt signal from the code receiving circuit 104. When status change data is received, CPU 10 updates contents of own memory and changes display on the display panel 11 through the output circuit 14. In addition, such status change is recorded by the typewriter 13 through the typewriter control circuit 16. CPU 10 of the master station 1 also scans the input from the control desk 12 through the input circuit 15 and encodes the device address and status to be controlled (ON-OFF status), if selection, control command is issued for said device of the slave station 2 and applies such codes to the code sending circuit 101. The code sending circuit 101 is transmitting the code indicated as the sending data 2S of Fig. 6 and transmits such code on the one frame of such sending data code to the code receiving circuit 202 of the first slave station 2 through the modulation circuit 102, external bus 50A of transmission line 5 and demodulation circuit 201. CPU 20 of the first slave station 2 reads the receiving content by the periodical scanning or interrupt signal as a receiving data 1R sent from the code receiving circuit 202 and gives control command to the designated device through the output circuit after code check and decoding. Aforementioned operations are similar to those of the second slave station 3 and therefore explanation is not repeated here. The similar additional structure to the third, fourth and succeeding slave stations not illustrated realizes the exactly same operations. Ordinary remote supervisory control and record of operation are explained above. However, in case the operations are recorded in the master station 1, there is no other way than the sequential record of times of the master clock 17 certified by CPU 10 of the master station 1 since the data of time at which the status change occurs is not inputted from each slave station 2, 3, ... in said normal operation. But in case operations of protection apparatus and device is by far quicker than the time required for code transmission of data transmission system like the power system, accurate discrimination of operation sequence is impossible when data has reached the master station 1. In order to solve such problem, the slave clocks 27, 37, ... are provided respectively to the slave stations 2, 3, ... and these slave clocks are synchronized with the master clock 17. When a status change occurs, times of slave clocks 27, 37, ... are also transmitted to the master station 1. Namely, if status change occurs at the contact being inputted to the input circuit 25 of the first slave station 2 explained previously, CPU 20 transmits the time of slave clock 27 to the master station 1 together with the address number of relevant contact and new status. Thereby CPU 10 of the master station 1 once stores such data to the memory of CPU 10 and arranges in order these data in the sequence of time added after acquisition of the data from the other slave station during a constant period and then outputs such data by the typewriter 13 through the typewriter control circuit 16. Thereby, an operator knows the correct operation time and its sequence. In this case, the master clock 17 of the master station 1 and the slave clocks 27, 37, ... of the slave stations 2, 3, ... must be synchronized with considerable accuracy (for example, within several milliseconds) and operations for such synchronization will then be explained hereunder. CPU 10 of the master station 1 issues a time survey command for checking the times of slave clocks 27, 37 ... once in every constant period (once in every hour to every day in accordance with accuracy of slave clock) to the slave stations 2, 3, ... through the code sending circuits 101, 105, .... The slave station 2 is then explained. First, as the normal operation, the code sending circuit 203 sends a signal to the register 21 before a constant time t a determined previously of the code frame transmission starting time and the register 21 repeatedly reads and stores the time of slave clock 27 in such a timing as such signal is inputted. When CPU 10 of the master station 1 issues the time survey command, the code sending circuit 101 transmits it to the code receiving circuit 202 of the slave station 2 through the modulation circuit 102, external bus 50A forming the transmission line 5 and demodulation circuit 201. This operation is indicated as D (TIQ) in the sending data 1S of master station 1 in the time chart of Fig. 6. When the code receiving circuit 202 receives the time survey command D (TIQ), CPU 20 of the slave station 2 puts the data stored in the register 21 on the next code frame. Here, since the data of register 21 is the time of slave clock 27, as indicated at the upper part of the sending data 2S of Fig. 6, before the time t a from the next frame (at the end of transmission of the previous frame in this example), if it is considered as T S1 , the CPU 20 transmits this T S1 as the time data of slave clock 27 in the next frame D (TAS) to the code receiving circuit 104 through the code sending circuit 203, modulation circuit 204, external bus 50B and demodulation circuit 103. The signal input to the code receiving circuit 103 is delayed as long as the transmission delay time τ like the sending data 2S as in the case of receiving data 1R of Fig. 6. Upon reception of frame containing the time data of slave clock 27, the code receiving circuit 104 reads the time T M of master clock 17 at this time and then stores it in the register 41. CPU 10 reads said time data T M stored in said register 41, calculates an estimated time T S10 of the slave clock by subtracting a sum of the length t c of the 1-frame of code previously known, time t a up to the transmission of code from read of time of slave clock described previously and a transmission delay time τ from said time data T M and obtains a difference (T S10 - T S1 ) between such estimated time and the time T S1 of slave clock input with the frame of D (TAS) from the slave station and then stores it in the own memory as the time difference between the master clock 0 and slave clock 1. Next, CPU 10 of the master station 1 transmits said time difference as the slave clock correction data to the code receiving circuit 202 of the first slave station 2 through the code sending circuit 101, modulation circuit 102, external bus 50A and demodulation circuit 201. The time chart of this operation is indicated by the frame D (TAJ) of Fig. 6. When the code receiving circuit 202 receives the time correction data D (TAJ), CPU 20 of the first slave station 2 reads the time of slave clock 27, adds the time correction data (including the sign) thereto and set the time of slave clock 27 to such time data. Thereby, the time of slave clock 27 is synchronized with the time of master clock 17. Time synchronization can be performed with the same operations for the slave clock 37 of second slave station 3 and the succeeding ones. The time correction data can also be obtained as a difference (T I - T M ) between the estimated time T I of slave clock attained by CPU 10 of the master station 1 by adding a sum of the transmission delay time τ, time t a up to transmission of code from reading of time of slave clock and the length t c of the 1-frame of code to the time T S1 of slave clock 27 input, on the contrary from the above case, for example, from the first slave station 2. The time synchronization method of the present invention can be applied to the data transmission system which always transmits the code and such system is also explained in the embodiments, but it is certain that this method of the present invention can also be adopted to the other system, for example, those which do not always transmit the codes and each slave station transmits the codes in accordance with the polling from the master station. Even in case of the structure of embodiment, the time correcting operations of slave clocks of slave stations may be done in parallel, for example, by providing individually the register 41, 42, ... of the master station 1 as in case of the embodiment, but it is also certainly possible that various structures may be employed, for example, the one common register may be used sequentially by realizing sequential correction for slave station by slave station. In this case, it is also possible that the transmission delay time τ between the master station and slave stations is measured, when the data transmission system is installed, by the loop-back test, wherein, for example, the modulation circuit 102 and demodulation circuit 103 of the master station and the modulation circuit 204 and demodulation circuit 201 of the first slave station 2 are separated from the internal circuits in Fig. 5, an output of the demodulation circuit 201 is connected to the modulation circuit 204 and the time until appearance of change in the input code of the modulation circuit 102 of the master station 1 in the output of demodulation circuit 103 is measured and then is divided by 2, and then it is stored as the data in the memory of CPU 10 of the master station 1. The time correcting operations are not always required to be executed for all digits (hour, minute, second, millisecond) of time in every operation and it is also possible that correction up to the digit of second (or time setting of slave clock by transmitting the absolute time) is carried out at the time of starting operation of device or with a period of long time and the slave clock time and bit length of its corrected data may be subtracted by once correcting millisecond every hour. As explained heretofore in detail, according to the time synchronization method of the present invention, the slave station returns time data of the slave clock to the master station in accordance with the slave clock time survey command to the slave station from the master station in the data transmission system, while the master station calculates transmission delay time based on the time when the code including such time data has arrived from the slave station, obtains a time difference between the master clock and slave station by adding such transmission delay time as an element for calculation and synchronizes the times of the master station and slave station of data transmission system by correcting the time of the slave clock on the basis of such time difference data. Accordingly, the time synchronization method of the present invention is capable of executing the time correcting operation with reference to the absolute time and provides following effects for the practical use. First, it is no longer necessary to interrupt the other operations to be carried out by CPU provided in the master station and slave stations for the time synchronization and thereby an excessive load to be applied on CPU can be prevented. In addition for the polling/selecting system, since it is also no longer necessary to separately measure the transmission delay time between the master station and slave stations and previously store such delay time as the data within the memory, etc. in CPU, the procedures required for such measuring operation and storing operation can be eliminated. Even in case of changing the transmission route, update of data measured and stored is not required and therefore the method for realizing time synchronization in the transmission system can be provided without any troublesome procedures. Moreover, in case that this time synchronization method is applied to the system of automatic cyclical data transmission, the times of clocks provided in the master station and slave stations may be synchronized without suspending flow of data transmission, and alleviation of load applied on CPU and improvement of transmission efficiency can also be improved from such point of view.

Claims: A time synchronization method where a master station (1), which is provided with at least a central processing unit (10) (CPU), a master clock (17) and a sending/receiving means (18), is connected with a slave station and/or stations (2;3) having at least a CPU (20;30), a slave clock (27;37) and a sending/receiving means (28;38) through the data transmission line (5) and the time of said slave clock and/or clocks (27;37) in the data transmission system which assures bidirectional data transmission between said master station (1) and the slave station and/or stations (2;3) are synchronized with the time of said master clock (17); said time synchronization method comprising: a first step wherein said master station (1) transmits the code of slave clock time survey command to said slave station (2;3) and the time T M of said master station (1) at the timing of completing the transmission of such code is stored in a first register (41) provided in said master station (1) at the time of such transmission; a second step wherein a slave station (2;3) which has received the code of said slave clock time survey command stores the time T S of said slave clock (27;37) in such a timing as completing reception of said code received from said master station (1) into a slave station register (21;31) provided in said slave station (2;3) and then transmits the time T S of said slave clock stored in said register (21;31) to said master station (1), on the occasion of transmitting, thereafter, the code of slave clock time data which is preset so that the transmission to said master station (1) is started after a constant period t P from the timing of completing the reception of said code; characterized by a third step wherein said master station (1) which has received the code of said slave clock time data reads the time T De of said master clock in such a timing as starting reception of said code and stores it in a second register (42), thereafter obtains, on the basis of two time data of the slave clock time T S in such a timing as completing reception of said time survey command code in the slave clock (27;37) sent in the code of such slave clock time data and the master clock time T M in such a timing as completing transmission of said time survey command code stored in said first register (41), a time difference T D1 between said master clock (17) and said slave clock (27;37) considering the times respectively stored in said first and second registers (41;42) and the transmission delay time τ₁ calculated from a constant time up to the start of transmission of code of said slave clock time data in said slave station (2;3) τ₁ = (T De - t P - T M )/2, and transmits such time difference T D1 = T M + τ₁ - T S to said slave station (2;3) in the code of time correction data; and a fourth step wherein said slave station (2;3) which has received said time difference T D1 in said time correction data code corrects the time of said slave clock (27;37) based on such time difference. A time synchronization method of the data transmission system according to claim 1, wherein said transmission delay time considered for obtaining time difference between said master clock (17) and said slave clock (27;37) in said third step is calculated by said CPU (20;30) based on the data given to said master station (1) several times in the past. A time synchronization method where a master station (1) which is provided with at least a central processing unit (10) (CPU), a master clock (17) and a sending/receiving means (18), is connected with slave station and/or stations (2;3) having at least a CPU (20;30), a slave clock (27;37) and a sending/receiving means (28;38) through the data transmission line (5) and the time of said slave clock and/or clocks (27;37) in the data transmission system which assures bidirectional data transmission between said master station (1) and the slave station and/or stations (2;3) are synchronized with the time of said master clock (17), said time synchronization method comprising: a first step of transmitting the time T S1 of the slave clock (27;37) which is read at a constant time t a before the partition of the frame of the code being transmitted by said slave station (2;3) to said master station (1) in accordance with the slave clock time survey command sent from said master station (1) and is stored in a slave station register (21;31) as the data to be transmitted the frame following said partition; characterized by a second step of calculating an estimated slave clock time T S10 by subtracting a sum of the length t c of on frame of the code transmitted, said constant time t a and transmission delay time τ from said time T M of the master clock (17) in such a timing as completing reception of said frame after such time T M is stored in the first register (41) of the master station and then transmitting a time difference (T S10 - T S1 ) between such time T S10 and the time T S1 of said slave clock to said slave station (2;3) as the time correction data; and a third step of correcting the time by adding said time difference received by said slave station (2;3) to the actual time of slave clock (27;37). A time synchronization method according to claim 3, characterized in that said second step is replaced by the step of calculating an estimated slave clock time T I obtained by adding a sum of the transmission delay time τ, time t a up to transmission of code from read of the time of said slave clock (27;37) and the length t c of the 1-frame of code to the time T S1 of said slave clock input as the data from said slave station (2;3) after said master station (1) stores the time T M of master clock in such a timing as completing reception of said frame to the first register (41) of said master station (1) and then transmitting a time difference (T M - T I ) between such estimated slave clock time T I and the time T M of said master clock (17) in such a timing as completing reception of the frame to said slave station (2;3) as the time correction data.

Inventors: SHOYAMA TERUHISA MITSUBISHI DE, TERAJI NOBUO MITSUBISHI DENKI, YAMANAKA TORAO MITSUBISHI DENK, SHOYAMA, TERUHISA MITSUBISHI DENKI K.K., TERAJI, NOBUO MITSUBISHI DENKI K.K., YAMANAKA, TORAO MITSUBISHI DENKI K.K.
Applicants: MITSUBISHI ELECTRIC CORP, MITSUBISHI DENKI KABUSHIKI KAISHA
Application year: 1987
Main classification: H04J3
IPC codes: H04J3, H04B3