Abstract:
Method of synchronizing at least one user of a bus system which is operated with a preselectable system clock period (NTU), a local clock period (LNTU) and a reference clock period (GNTU) being preselected for the at least one user, and the reference clock period (GNTU) being synchronized with the system clock period (NTU), a local clock period (SLNTU), synchronized with the system clock period (NTU), of the at least one user being generated by linking the local clock period (LNTU) to a scaling factor (P), the scaling factor (P) reflecting a ratio of the reference clock period (GNTU) to the local clock period (LNTU), the scaling factor (P) for synchronization of the local clock period (LNTU) being adapted to the system clock period (NTU) by addition or subtraction of an adjustment value (O).

Description:
FIELD OF THE INVENTION 
   The present invention relates to a method and a device for synchronizing at least one user of a bus system, and also to a bus system. 
   BACKGROUND INFORMATION 
   Networking of controllers, sensors and actuators with the help of a communication system, a bus system, has increased drastically in recent years in the construction of modern motor vehicles and in machine construction, in particular in the machine tool sector and in automation. Synergistic effects due to the distribution of functions among a plurality of control units may also be achieved in this way. These are known as distributed systems. Communication between different stations is increasingly being accomplished via a bus or bus system. Communication traffic on the bus system, access and reception mechanisms as well as error processing are regulated according to a protocol. 
   The CAN (controller area network) protocol has become established in the automotive sector. This is an event-controlled protocol, i.e., protocol activities such as sending a message are initiated by events originating outside the communication system. Definite access to the communication system, i.e., bus system, is achieved by priority-based bit arbitration. This requires that each message be assigned a definite priority. The CAN protocol is very flexible, so it is readily possible to add additional nodes and messages as long as there are still free priorities (message identifiers). The collection of all messages to be sent in the network together with their priorities and sender nodes as well as possible reception nodes are stored in a list known as the communication matrix. 
   An alternative approach to spontaneous, event-controlled communication is the strictly time-controlled approach. All communication activities on the bus are strictly periodic. Protocol activities such as sending a message are triggered only by the passing of time, which is valid for the entire bus system. Access to the medium is based on the allocation of time ranges in which one sender has exclusive sending right. The protocol is comparatively inflexible; new nodes may be added only if the corresponding time intervals have been freed up in advance. This circumstance requires that the order of messages be determined even before starting operation. Thus, a schedule is compiled which must meet the requirements of the messages with respect to repeat rate, redundancy, deadlines, etc. This is known as a bus schedule. Positioning of the messages within the transmission periods must be coordinated with the applications produced by the message contents to minimize the latencies between application time and transmission time. If this coordination does not take place, the advantage of time-controlled transmission (minimum latency jitter in sending the message on the bus) is lost. High demands are thus made of the scheduling tools. 
   German Published Patent Application No. 100 00 302, German Published Patent Application No. 100 00 303, German Published Patent Application No. 100 00 304 and German Published Patent Application No. 100 00 305 describe approaches to time-controlled CAN, namely TTCAN (time triggered controller area network) which complies with the requirements outlined above with regard to time-controlled communication as well as the demand for a certain measure of flexibility. TTCAN meets this by establishing a communication cycle (basic cycle) in exclusive time windows for periodic messages of certain communication stations and in arbitrating time windows for spontaneous messages of a plurality of communication stations. 
   In addition, a TTCAN network as a bus system is assumed, but this is not to be understood as restrictive with regard to the subsequent object of the present invention. Instead, the object of the present invention, which is to be explained below, may also be used with other comparable bus systems. 
   In doing so, a uniform clock pulse must be derived from the various internal local clock pulses of the users, in particular the control units, for the communication network, i.e., the bus system in networked control units in automation, in motor vehicles and in other areas of use, for example, or the individual starting clocks of the users must be synchronized to such a uniform common network clock, e.g., the network time unit NTU for TTCAN. 
   The usual method of forming a local clock adapted to the reference clock and/or the system clock from a reference clock and in particular a faster system clock is based on counting how many system clock periods are in a certain number of reference clock periods, known as the measurement period. The numerical value then indicates how many system clock periods form the local clock to be adapted. The measurement period is usually constant and limited to values of 2 n  reference clock periods (nεN 0 ). This adjustment or synchronization is performed by defining a scaling factor which is linked to the local clock to generate a synchronized local clock. To do so, multiplication and division must be implemented to determine the new scaling factor. In particular in the case of a hardware implementation, multiplication and division are very complex to handle. 
   Therefore, the goal of the present invention is to provide a general method, a device and a corresponding bus system by which synchronization of a user, i.e., adjustment of a local clock and/or a local clock period of such a user, may be performed easily without the length of the measurement period having to remain constant or being limited to certain values. 
   SUMMARY OF THE INVENTION 
   The present invention describes a general method and a device and a corresponding bus system by which an adjustment of a local clock to a reference clock and/or the system clock may be performed easily, in particular without multiplication or division, thereby greatly facilitating an adjustment, i.e., synchronization of a local clock and/or a local clock period and/or the local representation of the network clock with a reference clock or system clock, and this is accomplished with less complex hardware, so that integration into an IC (integrated circuit) in particular is greatly facilitated. 
   In addition, the lengths of the measurement periods are also referred to below as “measurement time windows” during which the deviations between the reference clock and/or the reference clock period and the local clock and/or the local clock period which is to be adjusted are measured, are allowed to change, i.e., they need not be constant, and they are not limited to certain predetermined values. 
   This is achieved by a method and a device as well as a bus system having a device for synchronizing at least one user of a bus system which is operated with a preselectable system clock period (NTU), a local clock period (L_NTU) and a reference clock period (G_NTU) being preselected for the at least one user, and the reference clock period (G_NTU) being synchronized with the system clock period (NTU); a local clock period (SL_NTU), synchronized with the system clock period (NTU), of the at least one user is generated by linking the local clock period (L_NTU) to a scaling factor or prescaler (P); the scaling factor or prescaler (P) reflecting a ratio of the reference clock period (G_NTU) to the local clock period (L_NTU), the scaling factor, i.e., prescaler (P) for synchronization of the local clock period (L_NTU) being advantageously adapted to the system clock period (NTU) by addition or subtraction of an adjustment value or offset (O). In other words, this adjustment value is added or subtracted, depending on whether the offset, i.e., the adjustment value O is greater than or less than 0. In the special case when no adjustment is necessary, the value 0 may be obtained as the adjustment value or offset. 
   A measurement time window MT is advantageously preselected by a recurring event, although it need not necessarily recur periodically, this measurement time window MT being determined first in a number of local clock periods L_NTU as a unit as a first local measurement window as local_period and in a number of reference clock periods G_NTU as an additional unit as a second global measurement window, as global_period; a difference period_diff being determined from the first measurement window, i.e., the local_period, and the second measurement window, the global_period, the adjustment value or offset O being determined with the help of this difference period_diff. 
   Offset O is advantageously also determined as a function of a ratio of the scaling factor or prescaler P to the second measurement window, the global_period, the ratio being represented using dual logarithms, which advantageously permits a rounding of the dual logarithm of scaling factor LDP and the dual logarithm of second measurement window LD global_period, so that in a binary representation, instead of the complete dual logarithm, the value of the highest position in binary representation is used, thus expediently yielding a difference DLD according to the particular highest position of the rounded-off value for scaling factor LDPR and the rounded-off value of second measurement window LDGB. 
   Through such a procedure of conversion to dual logarithms and rounding off, it is possible to avoid overshooting while also achieving a better convergence of the method. Difference DLD between the rounded-off value for scaling factor LDPR and the rounded-off value for second measurement window LDGP is expediently formed according to equation 19: DLD=(LDPR−LDGP)−1. 
   A further advantageous increase in convergence may be achieved by the difference DLD being formed according to equation 20: DLD=(LDPR−LDGP). 
   The adjustment value or offset O is advantageously formed so that the difference between the first and second measurement windows, i.e., period_diff, in binary representation is shifted by individual positions of the binary representation according to difference DLD of the rounded-off values for scaling factor and second measurement window LDPR and LDGP in the case of a positive difference DLD in the direction of the highest position, or in the case of a negative difference it is shifted in the direction of the lowest position. Therefore, multiplication and division are advantageously converted to addition and a shift function, permitting a simple and thus inexpensive hardware implementation, in particular in an IC. 
   Through the method according to the present invention and/or the corresponding device and bus system, a plausibility check is also advantageously performable in such a way that offset O and/or the sum of the offset and of prescaler P and/or the difference between offset O and prescaler P may be compared with at least one preselectable threshold value. 
   The at least one preselectable threshold value may be preselected as a maximum value, for example, and on reaching and/or exceeding this maximum value, further synchronization by adapting offset O is suppressed or the offset and/or the sum of offset O and of the prescaler, i.e., scaling factor P, is limited to the maximum value. 
   Likewise the at least one preselectable threshold value may be advantageously preselected as a minimum value and on reaching and/or falling below this minimum value, further synchronization by adapting offset O is not performed or the adjustment value itself, i.e., offset O and/or the difference between the offset and the scaling factor, i.e., prescaler P, is limited to the minimum value. 

   
     BRIEF DESCRIPTION OF THE DRAWINGS 
       FIG. 1  shows a network or bus system having at least one first user and second means, in particular a second user for preselecting a reference clock and/or a reference clock period. 
       FIG. 2  shows a flow chart for forming the scaling factor or prescaler and the adjustment value or offset having a first measurement window local_period and a second measurement window global_period. 
       FIG. 3  shows again a time representation of the clock adjustment and/or the clock period adjustment, i.e., synchronization of the at least one user via a time stream. 
   

   DETAILED DESCRIPTION 
     FIG. 1  shows a bus system  103  having a first user  100  and another user  101 . First user  100  is described below as the user to be synchronized; this also shows an interface element  104  for communication link  103 . A clock generator  106  having an internal clock source, e.g., a quartz crystal  107 , is also shown. Furthermore, clock generator  106  includes a counter  112 . A component  110  is also illustrated by which synchronization of the user and/or adjustment of the clock may be implemented. This component  110  and/or the corresponding functionality may optionally also be accommodated in clock generator  106 . User  101  is referred to below as a reference generator, in the specific case of a TTCAN system it is known as the time master which is connected via an interface module  105  to communication link  103 . Clock generator  108  of the reference user, the time master in the TTCAN system through which the local time of this time master is determined, is thus considered the reference time for the entire bus system. In other words, local time generator  108  of reference user  101  is thus considered a global time generator of the bus system. Here again a local clock source  109 , in particular a quartz crystal or some other time source, is also shown. Here again there is a counter  113  for acquiring the local time source. This also shows another optional component  111 , e.g., a processing module or a processor by which messages may be sent and received and/or analyzed. Optionally instead of using a reference user  101 , a reference clock generator  102  may also be connected to the communication link, likewise with time source  114  and counter module  115 , for example. Thus, the reference time for communication link  103  and/or the entire bus system may also come from simple second means, i.e., a simple timer module, instead of a reference user. 
   The basis of the clock adjustment is a recurring event, in particular a regularly recurring event, but it need not recur absolutely periodically, i.e., at equidistant intervals, which is observable in all nodes of a network and may function as a reference point for preselection of the measurement time window, i.e., the measurement period. In the remaining discussion, the term “measurement time window” or “measurement window” is preferably used, because as already pointed out, a periodicity of this measurement time window, and thus also a measurement period, is not absolutely necessary although it is possible. Events for defining this measurement time window are events observable simultaneously in the time master, i.e., reference user  101  and the at least one time slave, i.e., user  100  which is to be synchronized, as is the case, e.g., in the TTCAN network with the start of frame of the reference message. User  101 , which supplies the reference clock, i.e., the reference clock period and increments a counter, in particular counter  113  using this reference clock, i.e., corresponding period, then sends the count of counter  113  which has been confirmed for this specific measurement event to all other users, in particular user  100 , which capture for the same measurement event the counter reading of the local counter, e.g.,  112 , which is incremented with its local clock from clock source  107 . The counter readings may be captured, by saving in memories or registers which are not represented explicitly, these memories or registers being present in particular in timer  106  or  108  or in other modules, e.g.,  110  or  111  or even separately. The differences between the counts captured for these successive measurement events then indicate the length of the measurement period in the reference clock periods, i.e., in the unit of the reference clock, and, in the case of the user to be synchronized, in local clock periods, i.e., in the unit of the local clock period. 
   In addition to the quartz crystal, an oscillator, in particular a VCO, may also be used as the clock source, i.e., the time source. 
   The reference clock of reference generator  101  is referred to below as global timing GT. The local clock to be adjusted to the reference clock and/or the system clock, i.e., the local clock to be synchronized with it, is referred to in the remaining discussion as local timing LT. The period of reference clock GT is G_NTU and the period of local clock LT is L_NTU. The scaling factor or prescaler P, in particular actual value P_actual or prescaler_actual, indicates how many system clock periods are contained in a certain number N, which is usually large. εN, of local clock periods L_NTU, where N is a constant which determines the ratio of the prescaler, i.e., scaling factor P, and local clock period L_NTU. The length of the measurement period, represented or measured in units of the period of reference clock pulse G_NTU, is measured, i.e., detected, as global_period and the pendant, i.e., the length of the measurement time window, is measured, i.e., detected, as local_period in units of local clock period L_NTU. Thus, global_period and local_period are the measurement windows, i.e., the corresponding values which are then used to determine the deviation of local period L_NTU from global period G_NTU. The deviation itself, i.e., the difference between local_period and global_period, is referred to as period_diff. According to the present invention, an offset or adjustment value is added to or subtracted from the prescaler or the scaling factor to achieve the result that L_NTU and G_NTU do not differ from one another and/or the synchronized local clock generated with the help of the prescaler and offset, i.e., synchronized local clock period SL_NTU is synchronized with the reference clock, i.e., the system clock, in particular it corresponds to the reference clock, i.e., reference clock period G_NTU. 
   All the values mentioned here are integrals, which further simplifies the implementation. 
     FIG. 2  illustrates the synchronization, i.e., adjustment, in detail, whereby the adjustment may be repeated regularly to compensate for fluctuations in the system clock, i.e., system clock period, and reference clock, i.e., reference clock period. 
   In  FIG. 2 , the reference message, i.e., according to the present invention the counter value of reference user  101 , in block  201  is detected by block  200  as the instantaneous reference value in block  201 , e.g., on occurrence of the first measurement event. If the second measurement event occurs as a recurring event, then the value which was previously the instantaneous value from block  201  is written to block  202  as the preceding or previous reference value, and the counter value of the recurring measurement event remains as the current value in block  201 . The same thing is also true of blocks  204 ,  205  and  206  for the user which is to be synchronized and which ensures its current counter value in block  205  for the measurement event and, on occurrence of the recurring measurement event, transmits this value from block  205  to block  206  and writes the new counter value for the measurement event as the current value to block  205 . In other words, in this example the system first waits for the two measurement events, namely the measurement event occurring first and the recurring event, to then have a current value and a previous value with which the measurement time window is determinable, i.e., the difference may be formed. 
   Another possibility is to provide as the first event a constant and to accept this constant as the previous value into blocks  202  and  206  and then write the first measurement event, i.e., the corresponding counter value, as the current value to block  201  and/or block  205  for the reference user and/or to the users to be synchronized. 
   Another possibility would be to set both values, i.e., the current value and the previous value, at constant values in blocks  201  and  202  or  205  and  206  before the first measurement event, so that then a first predetermined difference is used for global_period and local_period, i.e., the measurement window. 
   In the case of a TTCAN system, the start occurs with the start of the basic cycle, the counter values being captured at the start of frame of the TTCAN. 
   Thus in general, when a new counter value arrives, the previous counter value is saved as the previous value according to the measurement event that occurs, so that a new difference may be formed with the new counter value. Thus, for each measurement event, the measurement window local_period, i.e., the difference between the counter values for the measurement events from blocks  205  and  206  and the measurement window global_period, i.e., the difference between the counter values of the reference user and the measurement events in block  201  and block  202 , must be determined anew. This difference is formed in block  203 , so that the global_period, i.e., the second measurement window, is formed here, and the local_period, i.e., the first measurement window, is formed in block  207 . Both measurement window values, i.e., in units of reference time periods and/or reference clock periods and local clock periods, are then sent to block  209 . Block  209  also receives via block  208  the previous scalar ratio, scaling factor P and/or P_actual or prescaler_actual which enters into the subsequent determination of the new scaling factor or prescaler_setpoint in block  209 . 
   First in block  209  the two values local_period and global_period are compared by forming period_diff, which means that when period_diff is not equal to 0, L_NTU must be adjusted to G_NTU. 
   According to the present invention, this adjustment is performed by adding an offset O, an adjustment value, to the current prescaler value, prescaler_actual or P_actual, to arrive at the new prescaler value prescaler_setpoint or P_setpoint, i.e., P. Offset O may be either positive or negative or even zero in the case of period_diff=0. This depends on the sign of period_diff. 
   By definition the following equations always hold according to the present invention:
 
global_period* G   —   NTU =local_Period* L   —   NTU   (equation 1)
 
 G   —   NTU=L   —   NTU *local_period/global_period  (equation 2)
 
 N*L   —   NTU=P _actual* NTU (system clock period)  (equation 3)
 
 N*G   —   NTU=P _setpoint* NTU   (equation 4)
 
   This yields by rearranging:
 
 P _setpoint= P _actual*local_period/global_period  (equation 5)
 
with the switch in the correction factor to an offset. To arrive at an easily implementable hardware embodiment, the result to be achieved now is that:
 
 P _setpoint= P _actual+ O   (equation 6).
 
Thus the previous equations yield the following for offset O:
 
 O=P _actual*local_period/global_period− P _actual  (equation 8)
 
and
 
 O=P _actual*(local_period/global_period−1)  (equation 9).
 
   With the definition already proposed for the difference period_diff from local_period and global_period:
 
period_diff=local_period_global_period  (equation 10)
 
and the representation of the offset
 
 O=P _actual*(((period_diff+global_period)/global_period)−1)  (equation 11)
 
 O=P _actual*period_diff/global_period  (equation 12)
 
this yields the following for the offset
 
offset=period_diff*( P _actual/global_period)  (equation 13),
 
i.e., the value of the offset or adjustment value O depends on the difference period_diff and the ratio of P_actual to global_period, as already described in the advantages of the invention and in the claims. Now according to the present invention the quotient P_actual to global_period is formed via dual logarithms:
 
 P _actual/global_period=2 ld(P     —     actual)−ld(global   —   period)   (equation 14).
 
   To arrive at a more extensive hardware-friendly adjustment, according to the present invention the dual logarithms ld(P_actual) and ld(global_period) are rounded off to integers, i.e., instead of the complete dual logarithm, the value of the highest position in this binary representation is used for the particular values in binary representation, i.e., the highest bit of this number, so that value ldPr is obtained for the dual logarithm of scaling factor ld(P_actual), and value ldGP is obtained for the dual logarithm of second measurement window ld(global_period), where ldPr≦ld(P_actual) and ldGP≦ld(global_period). Thus the difference from equation 14 with the rounded-off values, i.e., the integers corresponding to the highest bits of the dual logarithm, is obtained the equation:
 
 Did =( ldPr−ldGP )−1  (equation 19)
 
where it holds that:
 
( P _actual/global_period)/4≦2 Dld   ≦P _actual/global_period  (equation 15).
 
   As an additional adjustment according to the present invention, the following is thus also obtained for the offset:
 
 O=period _diff*2 Dld =shift(period_diff, Dld )  (equation 16).
 
   In other words, the offset may be represented by a shift function, which means that the difference between the first and second measurement windows, i.e., period_diff, in binary representation is shifted accordingly by individual positions in the binary representation according to the difference Dld of the rounded-off value for scaling factor ldPr of the rounded-off value of second measurement window ldGP accordingly. In the case of a positive difference Dld in the direction of the highest position, which would correspond here to a shift_left function, or in the case of a negative difference Dld in the direction of the lowest position, which would correspond to a shift_right function, assuming the highest bits are represented at the left and the lowest bits are represented at the right. In the inverse representation the shift function may be used accordingly. This yields the following for new scaling factor P. i.e., P_setpoint using the offset thus found:
 
 P _setpoint= P _actual+shift_left(period_diff,  Dld )  (equation 17),
 
with which the multiplication and division have been converted to a shift function and addition. It is readily possible according to the present invention to achieve a hardware-friendly adjustment for determination of scaling factor P, i.e., P_setpoint so that it is easily implementable in an IC.
 
   The correction established by the offset or adjustment value O always has the correct sign (see equations 13 and 16). The correction advantageously does not go beyond the target value itself because overshooting is impossible due to equation 15. The clock adjustment presented here is performed after each measurement event, at least one quarter of the remaining deviation being corrected each time as part of the measurement and adjustment accuracy until remaining period_diff converges toward 0. If reference clock period G_NTU is not an integral multiple of system clock period NTU, then in this special case, period_diff will not remain at 0, but instead it will remain in a small interval around the value 0. 
   As an alternative, difference Dld of the rounded-off dual logarithms may also be estimated for equation 15 as
 
 Dld =( dlpr−dlGP )  (equation 20)
 
where it then holds that:
 
( P _actual/global_period)/2≦2 Dld   ≦P _actual/global_period  (equation 18).
 
   This alternative estimate converges even more quickly than the estimate in forming the difference according to equation 19. 
   According to the present invention, all methods and/or the corresponding devices and bus systems which use an adjustable variable to adjust a local clock and/or a local clock period to a reference clock, i.e., a reference clock period according to the system clock, i.e., the system clock period, are covered by the present invention. This means that the adjustment to the reference clock period, i.e., the reference clock is implementable by adding a value, i.e., an adjustment value, in particular an offset, to this adjustable variable, whereby an adjustment value is determined for the adjustment value using rounded dual logarithms of the available variables. 
   Another advantage derived from the method and/or device according to the present invention and the bus system is the possibility of implementing a plausibility check in which the adjustment value, i.e., offset O and/or the sum or difference of the scaling factor prescaler P_actual and the offset are compared with a predetermined threshold value, in which case the clock adjustment may then either be omitted or limited to the threshold value if the calculated offset exceeds or falls below the threshold value. In other words, the sum or difference of P_actual and offset may be compared with a threshold value, depending on the sign of the offset or the offset itself, this threshold value being implementable as a maximum or minimum in particular. 
   In the case of a preselected maximum value as the threshold value, on reaching and/or exceeding this maximum value, either the clock adjustment is stopped, i.e., there is no further adjustment of the adjustment value, or the adjustment value, i.e., the sum of P_actual and offset, is limited to this maximum value according to the sign of the offset. The same thing also holds on reaching or falling below a minimum value as the threshold value. The clock adjustment may be suppressed here or limited to the minimum value. 
     FIG. 3  shows again briefly on the basis of a time stream the transfer of values and determination of the scaling factor. At time T 0 / 1  the event which is globally observable in the entire bus system occurs. In other words, at this point in time, the reference user captures its counter value and the other users capture the counter value of their local counter. These capture values or captured counter values become valid at time T 1 / 1  in block  2 . Likewise at this point in time the old current value becomes the previous value. In other words, the reference counter value detected at T 0 / 1  or in block  1  is made known to the other users via communication link  103 . At time T 2 / 1  or in block  3 , the scaling factor, i.e., the P setpoint value, is calculated again, i.e., redetermined, by adding the offset to the P actual value as described in conjunction with  FIG. 2 . In the TTCAN system, for example, this scaling factor is known as TUR time unit ratio. Aforementioned blocks  1 ,  2 , and  3  are then repeated at times T 0 / 2 , T 1 / 2 , and T 2 / 2 . This cycle then begins again with block  1  at T 0 / 3 . 
   By applying this method as also illustrated in  FIG. 3 , the error, i.e., the clock difference, i.e., the clock period difference or the speed difference converges toward 0. Depending on the application of the convergence equation with difference Did [this occurs] slightly more rapidly or not as rapidly with the guarantee of no overshooting period. 
   Thus, the method and the corresponding device as well as the bus system having the corresponding device make do without multiplication or division, which involve complex hardware and would require a great implementation complexity. In addition, a very simple plausibility check of the values thus determined is made possible, as described above. In addition, this method also advantageously converges geometrically, i.e., very rapidly, for all practical applications. Thus advantageously minor changes in the target value may be pursued very rapidly and very smoothly. On an IC for example the clock regulating method as described here is detectable by measuring the input clock and the output clock of the IC and/or the functions of the IC controlled by the output clock.