TIME SYNCHRONIZATION IN A NETWORK

20230079221 · 2023-03-16

Assignee

Inventors

Cpc classification

International classification

Abstract

Method for time synchronization in a network comprising masters and at least one slave. The slave receives synchronization messages from the masters via the network for time synchronization of a first clock and a second clock of the slave. A first master sends a first synchronization message having a first time stamp to the slave for time synchronization of the first clock. The slave calculates a clock rate and a time difference between the first clock and the first master and aligns the first clock with a synchronized time. A second master sends a second synchronization message having a second time stamp to the slave for the time synchronization of the second clock. The clock rate of the second clock is set to the first clock rate. A time difference between the second clock and the second master is calculated and the second clock is aligned with the synchronized time.

Claims

1. A method for time synchronization in a network, the network comprising a plurality of masters and at least one slave having a first and second clock, the at least one slave receiving synchronization messages from the plurality of masters for time synchronization of the first clock and the second clock of the slave via the network, the method comprising: sending a first synchronization message having a first time stamp from a first master to the at least one slave for time synchronization of the first clock and the at least one slave; comparing the first time stamp of the first synchronization message with the first current time of the first clock; based on this comparison of the first time stamp of the first synchronization message with the first current time of the first clock, calculating a clock rate and a time difference between the first clock and the first master and carrying out a time alignment in such a way that the first clock in the slave runs with a synchronized time; a second master sending a second synchronization message having a second time stamp from the second master to the at least one slave for the time synchronization of the second clock, wherein a clock rate of the first clock is used to specify a clock rate for the second clock, by setting the clock rate of the second clock to the clock rate of the first clock; comparing, in the at least one slave, the second time stamp of the second synchronization message with the second current time of the second clock; and, based on this comparison in the at least one slave, calculating a time difference between the second clock and the second master and carrying out a time alignment in such a way that the second clock in the slave runs with the synchronized time.

2. The method according to claim 1, wherein the time synchronization takes place at intervals of between 10 and 200 ms.

3. The method according to claim 1, wherein a time stamper is associated with at least one of the first clock or the second clock of the at least one slave and assigns a time stamp to a data packet.

4. The method according to claim 1, wherein the time synchronization takes place in the at least one slave via synchronization and a clock rate and a time difference are calculated, and the time difference between at least one of the first clock or the second clock and the master is compensated for by at least one of a time jump or a frequency alignment.

5. The method according to claim 1, wherein the time synchronization takes place in at least one slave via syntonization and a clock rate and a time difference are calculated, and the time difference between the at least one first clock or the second clock and the master is compensated for by adjusting the clock rate.

6. The method according to claim 1, wherein a timer is associated with at least one first clock or with a second clock and issues an interrupt request at regular intervals.

7. A network comprising: a plurality of masters and at least one slave, the plurality of masters and the at least one slave each having a first clock and a second clock; the first master being configured to send a first synchronization message having a first time stamp to the at least one slave, and the at least one slave being designed to calculate a clock rate and a first time difference relative to the first current time of the first clock in relation to the first master on the basis of the first time stamp and to carry out a time alignment in such a way that the first clock in the slave runs with a synchronized time; the second master being configured to send a second synchronization message having a second time stamp to the at least one slave; the at least one slave being designed to specify the clock rate of the first clock as a clock rate for the second clock, and to set the clock rate of the second clock to the clock rate of the first clock; and the at least one slave being designed to calculate a second time difference between the second current time of the second clock and the second master on the basis of the second time stamp and to carry out a time alignment in such a way that the second clock in the slave runs with the synchronized time.

Description

BRIEF DESCRIPTION OF THE DRAWINGS

[0048] The present invention will be explained in greater detail in the following with reference to FIG. 1 to 5, which show exemplary advantageous embodiments of the invention in a schematic and non-limiting manner. In the drawings:

[0049] FIG. 1 is a flowchart for time synchronization in the prior art;

[0050] FIG. 2 is a flowchart for time synchronization according to the invention;

[0051] FIG. 3 shows schematic time synchronization of the clocks in the slave in the prior art;

[0052] FIG. 4 shows schematic time synchronization according to the invention of the clocks in the slave; and

[0053] FIG. 5 shows how a timer works in a network with time synchronization according to the invention.

DETAILED DESCRIPTION

[0054] The particulars shown herein are by way of example and for purposes of illustrative discussion of the embodiments of the present invention only and are presented in the cause of providing what is believed to be the most useful and readily understood description of the principles and conceptual aspects of the present invention. In this regard, no attempt is made to show structural details of the present invention in more detail than is necessary for the fundamental understanding of the present invention, the description taken with the drawings making apparent to those skilled in the art how the several forms of the present invention may be embodied in practice.

[0055] FIG. 1 shows a prior art method for data transfer for time synchronization in a network 1 having network subscribers. Different roles for time synchronization are distributed in a network 1. In a network 1 there are network subscribers having the role of master M and slave S. According to the invention, at least two clocks are provided. However, a plurality of clocks can also be present and be subject to time synchronization. In the case of time synchronization according to the invention, there is at least one first clock and one second clock. The first clock runs with a first time and the second clock with a second time.

[0056] To illustrate this, a working clock 3 is shown representatively for a first clock and a global clock 5 is shown representatively for a second clock. However, completely different clocks could also run in a network and on network subscribers, for example a production clock, a batch clock, etc. For synchronization, the role of a master M.sub.1 is assigned for the working time and the role of a master M2 is assigned for the global time. In principle, both masters M.sub.1 and M2 can be run on the same network subscribers, but are often distributed to different network subscribers. All other working clocks 3 and global clocks 5 in a network are then considered slave clocks. According to the invention, a slave S contains a working clock 3 that outputs a first time as the working time and a global clock 5 that outputs a second time as the global time. The global time can usually be the time of an atomic clock such as TAI or UTC, which should be the same everywhere in the world, depending on the time zone. However, it can also be possible for a slave S to contain only a single clock. This can then often be a working clock 3, and there is no synchronization with the global time. The clocks of the present invention can constitute any combination of hardware-based and logical clocks. For example, both the working clock 3 and the global clock 5 can access the same hardware-based clock, but both the working clock 3 and the global clock 5 can each access a hardware-based clock.

[0057] The network subscribers are connected to each other via network lines. The network lines often form a data bus for data communication between the network subscribers. The network lines can be LAN cables, network buses, fiber optic cables and the like, which allow communication in the network between the network subscribers. Any communication protocol can be implemented for data communication. A network infrastructure can also be provided that connects different networks or different portions of a network to one another, for example switches, routers, etc. Wireless data traffic having time synchronization via a wireless network, such as wireless LAN (WLAN), is also conceivable in a network 1 or in parts of a network 1. Any network topologies for the network 1 that are familiar to a person skilled in the art and that allow targeted data transfer with time synchronization between the network subscribers are possible. In terms of data traffic (in addition to other data messages), the network 1 allows bidirectional sending and receiving of synchronization messages between different network subscribers.

[0058] The synchronization messages are exchanged between network subscribers in the network 1 for time synchronization. For this purpose, one of the masters M.sub.1, M.sub.2 regularly sends synchronization messages D.sub.1, D.sub.2 to the at least one slave S. The master M.sub.1 sends a synchronization message D.sub.1 to synchronize the working clock 3, and the master M.sub.2 sends a synchronization message D.sub.2 to synchronize the global clock 5. The synchronization messages D.sub.1, D.sub.2 can be sent in one data packet, i.e., in a closed data unit that is intended for network traffic, but the synchronization messages D.sub.1. D.sub.2 can also be sent independently of one another in different data packets in the network 1. The synchronization messages D.sub.1 for the working clock 3 are preferably sent at a higher interval than the synchronization messages D.sub.2 for the global clock 5. The working clock 3 can often be synchronized four times as often compared to the global clock 5.

[0059] The synchronization message D.sub.1 contains a time stamp t.sub.1 from the master M.sub.1 and the synchronization message D.sub.2 contains a time stamp t.sub.2 from the master M.sub.2. A time stamp t.sub.1, t.sub.2 is the time of a working clock 3 or global clock 5 of a master at the time a synchronization message D is sent. The synchronization messages D.sub.1, D.sub.2 are used to calculate a clock rate r and a time difference dt in the slave S relative to the master M.sub.1, M.sub.2 and to set the working clock 3 or global clock 5 in such a way that the working time and global time are the same as those of the master and continue to run in the same manner.

[0060] The clock rate r defines a periodic signal that is determined by its frequency or period duration and is often used to coordinate the timing of processes in a digital system. A clock rate r can be output by a quartz oscillator in a hardware-based clock, for example. The time difference dt describes the absolute difference between two times. For example, a global time can be 11:23 a.m. on the master M and a global time on the slave S can be 11:25 a.m. The time difference dt would then be 2 minutes or 120 seconds.

[0061] FIG. 1 shows the flow of synchronization in the prior art. The master M.sub.1 sends a synchronization message D.sub.1 via the network to at least one slave S at specific points in time that can be predetermined or can also result, for example, from a change of a master M.sub.1. The synchronization message D.sub.1 receives a time stamp t.sub.1 and has a runtime in the network of Δt.sub.1. The runtime can be considered to be known or can at least be estimated. By default, the runtime Δt.sub.1 can be measured by separate messages. The synchronization message D.sub.1 arrives at a slave S, for example at a network port in the slave S, and is passed on to the working clock 3. As a rule, a time synchronization mechanism 7, 8 in each slave S, for example in a clock, calculates the deviations from the master M.sub.1, M.sub.2. The working clock 3, or the time synchronization mechanism of the working clock 7, now uses the time stamp t.sub.1 and the known runtime Δt.sub.1 to calculate the clock rate r1 and the time difference dt1 for its own working clock 3 and carry out a time alignment. If there are large deviations between the master M.sub.1 and the working clock 3 in the slave S, a time jump is carried out and the clock rate r.sub.A is also aligned. An alignment of the clock rate r.sub.A means that the duration of a clock in the slave S and in the master is the same after the alignment, and the time thus advances in the same way. Such an alignment of the clock rate r.sub.A can, for example, only be possible after a specific number of synchronization messages D.sub.1. For example, in the case of small deviations, it may only be necessary to adjust the clock rate r.sub.A, for example to accelerate or decelerate it. For this purpose, the clock rate r can be accelerated for a certain period of time in order to compensate for a difference, and can then, for example, allow 1.2 seconds to pass instead of 1 second per clock beat. Of course, the technically usual clock rates are in substantially lower ranges, for example 8-10 ns (nanoseconds). In the case of small differences, an adjustment of the clock rate r (frequency adjustment) can be sufficient.

[0062] The master M.sub.2 also sends a synchronization message D.sub.2 to the global clock 5 in the slave S. The synchronization message D.sub.2 receives a time stamp t.sub.2 from the master M.sub.2 and has a runtime Δt.sub.2 that can again be considered to be known. Due to the fact that the roles of the masters M can be executed on different network subscribers, the runtimes of the synchronization messages D.sub.1, D.sub.2 can definitely differ. However, different runtimes can also result, for example, from the fact that the synchronization messages D.sub.1, D.sub.2 are sent via different network paths. The global clock 5 or the time synchronization mechanism of the global clock 8 in the slave S calculates the clock rate r.sub.G and the time difference dt.sub.2, as described above for the first synchronization message D.sub.1. This can be done via a time jump or a frequency adjustment, depending on the deviation between the master M2 and the global clock 5 in the slave S.

[0063] In the prior art, there is therefore no interaction between the working clock 3 and the global clock 5. Each is synchronized individually by the respective master M.sub.1, M.sub.2. Due to the time synchronization using the first synchronization message D.sub.1 and the second synchronization message D.sub.2, it can happen that both the working clock 3 and the global clock 5 execute time jumps forward or backward and/or a clock rate r.sub.A, r.sub.G of one or each of the two clocks, i.e., working clock 3 and/or global clock 5, is accelerated or decelerated in order to compensate for a time difference relative to one of the masters M.sub.1, M.sub.2. The time synchronization in the prior art can therefore result in the working clock 3 and the global clock 5 having different clock rates r.sub.A and r.sub.G.

[0064] FIG. 3 shows an exemplary time course during regular time synchronization of the working clock 3 and the global clock 5 in the prior art. Time differences dt and clock rates r are always relative to a master M.sub.1, M.sub.2. The ordinate describes the time course of the time stamps t.sub.1, t.sub.2 and the abscissa describes the arrival of new synchronization messages D(t) from the master M as a function of the time and the runtime t+Δt. The arrival of the synchronization messages is not the same, but depends on the synchronization intervals of the masters M.sub.1 and M.sub.2. The working clock 3 and the global clock 5 each initially run at clock rates r.sub.A and r.sub.G. The master M.sub.1 sends the first synchronization message D.sub.1.1 with a time stamp t.sub.1.1 and said synchronization message arrives at the slave S after the runtime Δt.sub.1. The slave S compares the time stamp t.sub.1.1 of the first synchronization message D.sub.1.1 with the working time of the working clock 3 and uses the time synchronization mechanism 7, for example the working clock 3, to calculate a new clock rate r.sub.A.1 and, based on the deviations of the working clock 3 from the time stamp t.sub.1.1, a time difference dt.sub.1.1 for the working clock 3. The global clock 5 has not yet received a synchronization message and continues to run at clock rate r.sub.G. Depending on the calculated time difference dt.sub.1.1, the working clock 3 jumps as a result of the synchronization and changes the clock rate r.sub.A.1. Next, in this example, the slave S receives a synchronization message D.sub.2.1 from the master M.sub.2 for the global clock 5. Via the time stamp t.sub.2.1 of the synchronization message D.sub.2.1, a clock rate r.sub.G.1 and time difference dt.sub.2.1 is calculated with the global clock time synchronization mechanism 8. As a result, the global clock 5 jumps and changes the clock rate r.sub.G.1 in FIG. 3, which can be seen from the gradient in FIG. 3. In a preferred embodiment, a jump is performed only after the first synchronization message from both the working clock 3 and the global clock 5, and later synchronization messages D.sub.1, D.sub.2 can only cause a change in the clock rate r.sub.A, r.sub.G. The process repeats itself at different times. The runtimes Δt can differ between the different synchronization messages, for example if a different master M is specified, but are known to the slave S.

[0065] This process can be repeated as long as synchronization messages D.sub.1, D.sub.2 are sent from the master M.sub.1, M.sub.2 to the slave S for time synchronization. Identical points in time on the ordinate for the same clock with the same value would have the same time stamp t and would then no longer be distinguishable. This is indicated by way of example in FIG. 3 for working clock 3 with time stamps T.sub.1 and T.sub.2. Events that have this time stamp t, i.e. T.sub.1 and T.sub.2, would generally no longer be distinguishable with regard to the time base.

[0066] FIG. 2 shows the time synchronization according to the invention in a network 1. As described above, a master M.sub.1, M.sub.2 sends a first and a second synchronization message D.sub.1 and D.sub.2. In the case according to the invention, the first synchronization message D.sub.1 also contains a time stamp t.sub.1 so that the slave S can align the working clock 3. The second synchronization message D.sub.2 contains a time stamp t.sub.2 in order to align the global clock 5. The global clock 5 always calculates the time difference dt.sub.2 relative to a global time specified by a master M.sub.2. Both take place via the time synchronization mechanisms 7, 8. Consequently, the global time is aligned between the master M.sub.2 and the slave S with each synchronization message D.sub.2. However, the clock rate r.sub.G of the global clock 5 is not adjusted via the synchronization message D.sub.2.

[0067] The clock rate r.sub.A of the working clock 3 is now used to specify the clock rate r.sub.A for the global clock 5. Thus, the clock rate r.sub.A of the working clock 3 corresponds to the clock rate r.sub.G of the global clock 5, i.e., r.sub.A=r.sub.G. As a result, the clock rates r.sub.A, r.sub.G in the slave S are aligned internally via the specification from the working clock 3 and not, as before, via a specification from the master M.sub.2, which sent a second synchronization message D.sub.2 to the slave S. As a result, there are no different clock rates r.sub.A, r.sub.G between the working clock 3 and the global clock 5, as in the prior art. This is advantageous because applications such as a timer or a “monotonic clock,” which can be associated with either the working clock 3 or the global clock 5, now always access the same clock rate r.sub.A=r.sub.G.

[0068] In an extremely illustrative example, the clock rate r.sub.A of the working clock, which is calculated on the basis of the first synchronization message D.sub.1, can only run at 90% of the speed compared to the clock rate r.sub.G of a global clock 5. After a second synchronization message D.sub.2, for example at 1:00 a.m., the global clock 5 is aligned to the global time with the master M.sub.2. In the example, the clocks do not receive any synchronization messages for one hour until 2:00 a.m. Because the clock rate r.sub.A is aligned to r.sub.G, only 56 minutes have passed in the slave S in the global clock and said global clock would now display a time of 1:56 a.m., although it is now 2:00 a.m. With the next second synchronization message D.sub.2 at 2:00 a.m., the global clock is set to the value 2:00 a.m. and is therefore again synchronous with the global time.

[0069] The global clock 5 therefore often performs time jumps on the basis of the second synchronization message D.sub.2. These time jumps can be substantially smaller than the resolution of a global clock 5, and of course not have the size (4 minutes) as in the example above. For example, the resolution of the global clock 5 can be in the range of 1 microsecond (μS), but the time jumps, which are calculated on the basis of the incoming second synchronization messages D.sub.2, can be in the range of less than 1 μS. Thus, such time jumps can be irrelevant for applications and uses related to a user because these small deviations are perceived by a human being as being at the same time.

[0070] FIG. 4. shows an example of a time course during time synchronization according to the invention, which can take place, for example, regularly or at certain defined time intervals. The ordinate describes the course of time t and the abscissa describes the arrival of new synchronization messages D(t) from a master M.sub.1, M.sub.2 as a function of the time and the runtime t+Δt. Before the time synchronization according to the invention, for example after initialization of the network 1, the working clock 3 and global clock 5 can run at different clock rates r.sub.A for the working clock 3 and r.sub.G for the global clock 5, which is not shown in FIG. 4. The first synchronization message D.sub.1.1 with the time stamp t.sub.1.1 arrives at the slave S after the runtime Δt.sub.1.1 and the working clock 3 calculates a new clock rate r.sub.A.1. In a preferred embodiment, the working clock 3 can also calculate a working time difference dt.sub.1.1 with the first synchronization message D.sub.1.1 and performs a time jump, as already described above. As a rule, time jumps can subsequently be dispensed with because the deviation between the master M.sub.1 and the working clock 3 in the slave S is small enough, and then only a frequency alignment takes place. The clock rate r.sub.G of the global clock 5 in FIG. 4 is adjusted according to the invention to the clock rate r.sub.A of the working clock 3, which can be seen from the parallel gradients in FIG. 4. In this area it can also be possible for the global clock 5 to run incorrectly, as described above in the illustrative example. However, the global time is accurate again at the point in time at which the second synchronization message D.sub.2 arrives.

[0071] After a further time, the synchronization message D.sub.2-1 from the master M.sub.2 reaches the slave S. The time synchronization mechanism 8, for example the global clock 5, calculates the global time difference dt.sub.2-1 via the second synchronization message D.sub.2. At the time of processing by the synchronization mechanism 8, the global time is identical to the global time received from the master M.sub.2. It then continues to run at the clock rate r.sub.A of the working clock. This procedure is repeated with the arrival of each first and second synchronization message D.sub.1.n and D.sub.2-n for time synchronization from the masters M.sub.1 and M.sub.2.

[0072] The slave S can also send data traffic into the network 1, for example via data packets Dp, which can control various events and not only act with regard to time synchronization. A data packet can use a network port for this purpose, for example. For most applications it may be necessary to give the data packet a time stamp t. This can be done via a time stamper in the slave S, which gives an outgoing data packet a time stamp t of the slave S. A time stamp t is the time of the working clock 3 or the global clock 5 in the slave S at the time of the data packet. The time stamp t can also be important for regulating data traffic in a network 1. Depending on the event, the working clock 3 can access a working time stamper or the global clock 5 can access a global time stamper. If an event is to receive a time stamp t from the working clock 3, this is carried out by the working time stamper. In the case of the global clock 5, this functionality is taken over by the global time stamper. For example, the global time stamp t.sub.5 of the global clock 5 can be used for events with proximity to a user, while the working time stamp t.sub.3 of the working clock 3 can be used for communication events between network subscribers, for example for events such as coordinated production interactions.

[0073] In a preferred embodiment, FIG. 5 shows a network 1 having timers 6 that use the time synchronization according to the invention. For the sake of clarity, both master roles M.sub.1, M.sub.2 are arranged in one network subscriber. The network subscribers are arranged in a network topology. According to the invention, the first and the second master M.sub.1, M.sub.2 send the synchronization messages D.sub.1, D.sub.2 via the network 1 to a plurality of slaves S. Each network subscriber, i.e., both the master M.sub.1, M.sub.2 and the slaves S with regard to time synchronization, has a timer 6. A timer 6 issues an interrupt request UA at regular intervals, for example, every 1 millisecond (ms). This can be particularly important for cyclic applications, which should take place on all network subscribers at the same time or in a specified sequence. For example, systems access the timer 6 for a production process and, in the simplest case, switch a valve to a specified interrupt request UA.

[0074] A timer 6 on each device must therefore issue the interrupt request UA after a certain time has elapsed. If the clock rates in the slaves S are different, the interrupt requests UA come at different times. This can, for example, trigger errors and problems in high-precision production processes.

[0075] In a network topology, there can be a large number of different network subscribers, such as processing units, bus modules, drive modules, bus couplers, IO modules having integrated network connections, cameras, HMI devices, network-integrated sensors and actuators and run on a wide variety of operating systems, such as Linux/Unix, Windows. Android and the like. Depending on the network subscriber and its operating system, a timer 6 accesses a working clock 3 or a global clock 5 based on the presets. Some network subscribers such as S″ or S′″ have only one working clock 3 and the timer 6 accesses the working clock 3 accordingly.

[0076] In the prior art, each timer 6 in the network 1 would have to be set in order to access a uniform clock, for example the global clock 5. However, this would cause problems for network subscribers without a global clock 5. As described above, in case of alignment with the working clock 3, the advantages of global time would be lost.

[0077] The time synchronization according to the invention allows a timer 6 in the network 1 to access any clocks in the network subscriber, and for the interrupt request UA to take place everywhere after the same period of time. In this way, the control of production processes, for example, can be planned and implemented with great precision.

[0078] The time synchronization mechanisms in the slaves can be implemented in particular by microprocessor-based hardware, microcontrollers, and/or integrated circuits (ASIC, FPGA), and can be implemented digitally, as software on microprocessor-based hardware. Thus, the time synchronization mechanism can be physically implemented by electronic (or optical) circuits such as logic circuits, discrete components, microprocessors, hard-wired circuits, memory elements, wiring connections, and the like, which may be formed using semiconductor-based fabrication techniques or other manufacturing technologies, and/or analog instrumentation, e.g., analog electric/electronic circuits, analog computers, analog devices, etc. Further, the processing of the signal from the transmitting subscriber can be implemented by microprocessors or similar components, programmed using software (e.g., microcode) to perform various functions discussed herein and may optionally be driven by firmware and/or software. Alternatively, the time synchronization mechanism may be implemented by dedicated hardware, or as a combination of dedicated hardware to perform some functions and a processor (e.g., one or more programmed microprocessors and associated circuitry) to perform other functions.

[0079] Moreover, the network can also include at least one memory (not shown). e.g., a non-transitory computer readable medium or media, to store one or more sets of instructions to perform any of the methods or computer-based functions disclosed herein, including operating the timers and timer synchronization mechanisms, either alone or in combination with the other described devices. The network can also include at least one processor that can access the at least one memory to execute the one or more sets of instructions to perform any of the methods or computer-based functions discussed above. Moreover, the at least one memory can be part of the slave or can be remote from the slave, e.g., a remotely located server, memory, system, or communication network or in a cloud environment, and the at least one processor can also part of the slave or remote from the slave.

[0080] It is noted that the foregoing examples have been provided merely for the purpose of explanation and are in no way to be construed as limiting of the present invention. While the present invention has been described with reference to an exemplary embodiment, it is understood that the words which have been used herein are words of description and illustration, rather than words of limitation. Changes may be made, within the purview of the appended claims, as presently stated and as amended, without departing from the scope and spirit of the present invention in its aspects. Although the present invention has been described herein with reference to particular means, materials and embodiments, the present invention is not intended to be limited to the particulars disclosed herein; rather, the present invention extends to all functionally equivalent structures, methods and uses, such as are within the scope of the appended claims.