System for time stamping events using a remote master clock
BACKGROUND OF INVENTION 
     1. Field of Invention 
     This invention relates to a system for determining the absolute time of the occurrence of events at one or more spaced locations using a local counter at each location and a single, remote absolute clock, and has particular application to time stamping contact activity in a number of protective relays in an electric power distribution network. 
     2. Background Information 
     There are many applications where it is desirable to record the real time, known as time stamping, of certain events to provide a historic view of the activity of a particular device. Normally, a real-time clock is used to provide accurate time references for the stamps. Difficulties arise, however, when several devices are linked and yet do not share the same clock reference. Clocks will drift with respect to each other resulting in inaccurate time stamps. 
     This problem can occur in attempting to time stamp contact activity in protective relays which control circuit breakers in an electric power distribution system. It is desirable in such an application to determine the time of contact activity in the different relays with an accuracy of a few milliseconds for use in analyzing the sequence of events if there is a disturbance in the system. 
     It is an object of the invention, therefore, to provide a system which generates accurate time stamps of events in a number of devices such as contact activity in the protective relays in an electric power transmission system. 
     It is a more specific object of the invention to provide such a system which utilizes a single absolute clock to provide accurate time stamps for monitored events in each of the separate devices. 
     It is another object of the invention to provide such a system which provides accurate time stamps for at least a certain number of the most recent of the monitored events in each device. 
     It is still another object of the invention to provide such a system which stores information used to generate the time stamps in slave stations associated with each device and transmits this information to a master station which contains the single absolute clock. 
     SUMMARY OF THE INVENTION 
     These and other objects are realized by the invention which is directed to a system which includes in its broadest terms, a slave station which upon the occurrence of a predetermined event initiates a count of clocking pulses of fixed duration. This count represents the relative time since the occurrence of the event. In response to a send command, the current count is transmitted to a master station over a communications network. The master station includes a master clock which maintains the absolute time. It also contains a processing unit which calculates the absolute time of the event as a function of the transmitted count, the duration of the interval between clock pulses, the absolute time maintained by the absolute clock in the master station, and the transmission time required to transmit the count from the slave station to the master station. 
     In preferred form of the invention, a slave station monitors a plurality of events, and the detection means includes means for identifying the particular event. The slave station also includes a memory device having a first slot in which the identification of the first event which initiates the count is stored. The memory includes additional slots in which the identification of subsequent events and the count at the time of the occurrence of the subsequent events are stored. In this embodiment, when the send command is received, the identification of the first event and the current count in the counter are transmitted to the master station along with the identification and counts associated with each of the subsequent events stored in the additional memory slots. 
     The master station calculates the absolute time of the first event by subtracting from the current absolute time maintained by the master station the transmission time from the respective slave stations and the product of the count at the time of transmission multiplied by the fixed duration of the clocking pulses. The absolute times of the subsequent events are then calculated by adding to the absolute time of the first event, the count stored at the occurrence of the subsequent event multiplied by the fixed time duration of the clocking pulses. 
     A clear command, preferably generated by the master station, is sent to the slave stations over the communications network after receipt of the data from the slave station. The clear command clears the memory and stops and resets the count. 
     Each slave station has only a predetermined number of additional memory slots. If more events are detected, the data for the predetermined number of most recent events are retained in the predetermined number of additional memory slots. However, the data for the first event is retained, since this is the event from which the absolute times for all of the subsequent events are calculated. 
     As long as data is collected by the master station on a regular basis, errors due to variations in clocking pulses in the various slave stations is insignificant. 
     The invention has particular application to providing absolute time stamps for contact activity in the protective relays of an electric power distribution network. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     A full understanding of the invention can be gained from the following description of the preferred embodiments when read in conjunction with the accompanying drawings in which: 
     FIG. 1 is a schematic diagram of a portion of an electric power distribution network incorporating the invention. 
     FIG. 2 is a flow chart of a suitable timer interrupt computer program used by the slave stations which form part of the system disclosed in FIG. 1. 
     FIGS. 3A, 3B and 3C are maps of a portion of the random assess memory in the slave stations generated by the program shown in FIG. 2. 
     FIG. 4 is a flow chart of a suitable main computer program for such slave devices. 
     FIG. 5 is a flow chart of a suitable computer program for the master station which forms a part of the system shown in FIG. 1. 
     FIG. 6 is a flow chart of a suitable computer program for operating the slave stations in accordance with a second embodiment of the invention. 
     FIGS. 7A, 7B, 7C and 7D are maps of the random access memory of the slave device when operated in accordance with the program of FIG. 6. 
     FIG. 8 is a flow chart of a suitable main program used by the slave devices when operated in accordance with the second embodiment of the invention. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     The invention has particular application to time stamping contact activity in protective relays in an electric power distribution network and will be described in that environment, however, it will be clear to those skilled in the art that the invention has application to the time stamping of other events in other devices and in other systems. 
     As shown in FIG. 1, the electric power distribution network 1 includes a three-phase segment comprising the conductors 3 which is protected by a circuit breaker 5. The circuit breaker 5 is controlled by a protective relay 7 which may be one of several known types. Such a protective relay 7 monitors the current in the conductors 3 through current monitors 9 and, the voltage through potential transformers 11. As is well known in the field, the protective relay 7 trips the circuit breaker 5 to open circuit the conductors 3 upon the detection of specified abnormal conditions. 
     The protective relay 7 typically includes several electrical contacts which may for instance be normally closed type contacts 13 or normally open type contacts 15. In some protective relays, solid state switches are used rather than electromechanical relays. However, even these devices typically use the more reliable contacts of electromechanical relays as outputs. In any event, it is to be understood that the invention is applicable to devices with outputs indicating the occurrence of selected events. 
     The contacts 13 and 15 perform various functions in the protective relay 7. For instance, one contact controls tripping of the circuit breaker 5, and another may activate an alarm upon the detection of certain conditions. Different types of protective relays in the distribution network can have contacts performing different functions or indicating different conditions. The purpose of the invention is to provide accurate absolute time stamps of contact activity in all of the protective relays without the need to have an absolute clock associated with each relay, and all the problems attendant thereto. 
     In accordance with the invention, microcomputer based slave stations such as 17 are associated with the protective relays 7. The slave stations 17 are linked with a master station 19 over a network bus 21 to form a network 22. Each slave station 17 includes a microcontroller 23 comprising a central processing unit (CPU) 25, a read only memory (ROM) 27 in which the microcontroller program is stored, a random access memory (RAM) 29 in which the time stamping data and other parameters are stored, a timer 31 which provides the clock pulses for the microcontroller, and a bus 30 interconnecting all of these components. Also connected to the bus 30 are a contact input/output device 33 through which the status of the protective relay contacts is monitored, and a network input/output device 35 connecting the slave station 17 to the network bus 21. 
     The contacts 13, 15 are &#34;wet&#34;, that is a voltage is applied across them continuously. Thus, a monitoring circuit 37 connected across each contact 13, 15 will detect the applied voltage when the contact is open, and zero voltage when the contact is closed. This indication is used to generate a logic signal which is applied to the contact input/output device 33 for entry into the microcontroller 31. Each slave station 17 can monitor multiple contacts of a single protective relay or one or two contacts of two or more protective relays, depending upon the number of contacts of each protective relay to be monitored and the capacity of the slave station. Multiple slave stations 17 can be connected to the network 22. 
     Each of the slave stations respectively samples the status of each of the contacts 13, 15 that it is assigned to monitor. Such contacts have a tendency to bounce and may be subject to transient conditions or &#34;glitches&#34; as they are known. Various schemes can be used to increase the reliability of detecting valid changes in contact status. A simple method is to require that a change in contact status persist for a certain interval in order to be considered valid. 
     Upon the detection of a change in status of any of the monitored contacts of the associated protective relay(s), the microcontroller 25 initiates a count. The count is generated by clocking pulses derived from the microcontroller timer 31. Such pulses are generated at fixed intervals and thus the count is a measure of the relative time since the first change in contact status. Where there are several contacts assigned to a slave station 17, the identification of the first contact to operate is stored in a first memory slot in the RAM. Upon the occurrence of a change in status of a second contact, the identification of that contact and the count at the time of the change in status of the second contact are stored in an additional slot in the RAM 29. The RAM 29 has a predetermined number of additional slots in which the identification and count associated with the predetermined number of additional contact operations are stored. It should be understood that multiple operations of a particular contact may be stored, such as repetitive operations of the contacts of a trip relay where repeated attempts are made to reset a circuit breaker which responds to a fault which has not been cleared. 
     The identification of the first contact operation which is stored in the first slot in RAM 29, the current count and the identification of additional contacts and the counts at which they operated which are stored in the additional slots in RAM 29 are sent over the network bus 21 to the master station 19 upon command from the master station. Such a send command can be generated by the master station 19 periodically for all the slave stations for instance, or the master station can poll the slave stations to determine if they have stored information to transmit and then just send the transmit command to those stations, as another example. 
     The master station 19 comprises a microprocessor 39 which includes a CPU 41, a ROM 43 in which the master station&#39;s programs are stored, a RAM 45 in which the data collected from the slave stations, the results of the master station&#39;s calculations and other parameters are stored, and a real time clock 47. A bus 49 connects all these components with each other and with a network input/output device 51 which interconnects with the network bus 21. 
     The master station 19 uses the information received from the slave stations to generate real time time stamps for each of the contact operations. The total accumulated count at the time that transmission of the data is commanded by the master station is stored as the count for the first contact operation. This count is referred to as t 0 , time stamp zero. The master station calculates the absolute time of the first event as follows: 
     
         t.sub.0 abs=t.sub.current -(t.sub.0 *k+t.sub.transmission) Eq. 1 
    
     where: 
     t 0  abs=absolute time of the first contact operation 
     t current  =current absolute time determined from real time clock 47 
     k=interval between clock pulses generated by slave stations 
     t transmission  =is time required to transmit data from the slave station to the master station and depends upon the transmission medium and other transmission delays. 
     For all subsequent events, the absolute time for that contact operation is calculated from the stored count by adding the absolute time of the first event to the product of the stored count for the subsequent event and the interval between counts. Thus: ##EQU1## Where t 1  abs to t n  abs =the absolute times of the subsequent events 
     t 1  to t n  =the stored counts for each additional event 
     The master station 19 stores the calculated absolute times together with the identifications of the contacts in the RAM 45. This data may be extracted by conventional output devices and/or transmitted over the network 22 to other locations. 
     Following receipt of data from a slave station, the master station sends a clear command which resets the slave station to standby for a new first event and zeros the count. By collecting the data and resetting the counters in the slave stations with reasonable frequency, accumulated errors, such as those resulting from variations in the timing interval in the individual slave stations, are insignificant. 
     If the predetermined number of additional slots in the RAM 29 in a slave station becomes filled, the identification of the first event in the first memory slot is retained along with the identification and count for the most recent predetermined number of additional contact operations, and the count continues. Retention of the data for the most recent contact operations in addition to the data for the first may be accomplished in different ways, such as by shifting the data between the additional slots, discarding the oldest data, and inserting the new data in the empty slot, or by using pointers to indicate the oldest data and writing over the oldest data with the data for the newest contact operation. The data for the first event is retained since this is the event from which the relative timing of the subsequent events is calculated. 
     FIGS. 2 and 4 illustrate flow charts for suitable computer programs for the microcontrollers 23 of the slave stations 17. FIG. 2 shows a suitable timer-interrupt routine for the slave station. This routine is called at the predetermined interval determined by the timer 31. In an exemplary system this interval is 1.14428 msec. The routine of FIG. 2 is used in the embodiment in which data is shifted in memory if there is an overflow in order to maintain data for the most recent contact operations. Each time this routine is called, a check is made at 53 to determine if any events are already stored. If not, a check is made at 55 to determine whether any new event has occurred. If not, the program continues to cycle through these steps each time the routine is called until the first event is detected at 55. When this occurs, a pointer, &#34;nxt --  slot&#34;, is set equal to 0 at 57. If all the slots are not filled as determined at 59, and of course that would be the case in the instance of the first event, the identification of the event and the time stamp, are stored in the slot identified as &#34;nxt --  slot&#34; as indicated at 61 and &#34;nxt --  slot&#34; is incremented at 63. In this instance of the first event detected, the data is stored in slot 0. The count will be zero at this point, but it is the final count which is transmitted to the master station for calculating the absolute time of the first event. The count is then incremented at 65 before the routine is exited. The next time the routine is called, an event will be stored when the program is entered at 53, and if any new event has been detected at 67 since the last time the routine was run the identification of that event and the time will be stored, and &#34;nxt --  slot&#34; will be incremented as previously described. Whether or not there are any new events detected at 67 on this run of the routine, the count is incremented at 65. 
     If on any run of the routine of FIG. 2 there is a new event to store and &#34;nxt --  slot&#34; is equal to more than the last slot as determined in 59, meaning that the memory slots are all filled, an index, i, is set equal to 1 in box 69. The data in slot i+1 is then inserted into slot i as indicated at 71 and i is incremented at 73. The data is shifted successively in this manner for each slot until i equals the &#34;last slot&#34; as determined at 75. The identification of the new event and the count or time stamp for that new event is then stored in slot i as indicated at 77, and the count is again incremented at 65. For each subsequent run of the program, if the data is not collected by the master station, the data for the oldest contact event will be discarded in a similar manner and the data for the latest contact operation will be stored as just described. 
     FIGS. 3A, 3B and 3C illustrate states of a memory map for a portion of the RAM 29 of the microcontroller in the slave station during use of the routine of FIG. 2. Slot 0 is used for storing the data for the first event and slots 1 to n are used for storing data associated with the additional events. The identification of the event represented by &#34;event --  &#34; and the count at the time of the event represented by &#34;stamp --  &#34; are stored in each slot for each event. Thus, as shown in FIG. 3A &#34;event 0&#34; and &#34;stamp 0&#34; are stored in slot 0 for the first event. The &#34;stamp 0&#34; for the first event is the count at the time that the command is received from the master station to transmit the data. The &#34;stamp&#34; for the other events is the count at which the event occurred. FIG. 3A illustrates the situation where no events have yet been detected. In FIG. 3B the buffer is filled and data for the n events has been stored. FIG. 3C illustrates the situation where one more event than there is storage space for has been detected. In this instance the data for the third event which is identified as &#34;event 2&#34; and &#34;stamp 2&#34; is moved from slot 2 to slot 1 and thus the information for the second event which was stored in slot 1 is discarded by being written over. The data from the nth event is moved into slot n-1 and the data for the new event n+1 is inserted in slot n. This process is repeated for each additional event with the data stored in slot 0 maintained throughout, the data in slot 1 is discarded and the data from the additional slots are moved up one with the data for the newest event being stored in slot n. 
     FIG. 4 illustrates the flow chart for a suitable main program for the microcontroller 23 of a slave station 17. If no command is received from the master station as determined at 79, the slave device performs a self test function such as indicated at 81. However, if the slave station receives a command at 83 to send the data to the master station, the identification of the first event stored in the first slot and the present count are transmitted as indicated at 85. The present count can be inserted into slot 0 for this purpose. Then the identification and time stamps for all the additional events are transmitted at 87. If the slave station receives a command to clear events as determined at 89, all events and time stamps are cleared at 91 and the count is reset to 0 at 93. If there is no clear command, other commands are serviced at 95. As is typical, clearing of the event and time stamp data does not require zeroing the memory, but is accomplished by a flag indicating there is no data to be transmitted and then writing over the old data. 
     FIG. 5 illustrates the flow chart for a suitable computer program for the microcontroller 39 of the master station 19. The master station first sends a request successively to each slave station commanding that the stored events and time stamps be transmitted to the master station as indicated at 97. If data is available as indicated at 99, the time of the first event is calculated at 101 using equation 1 above. The index i is then set equal to 1 at 103 and a loop is entered in which the time for each of the additional events is calculated at 105 with i being successively incremented at 107 until data for each of the events transmitted has been processed as determined at 109. The master station then sends a &#34;clear event&#34; command to the slave station at 111. 
     FIG. 6 illustrates a flow chart for a computer program for the microcontroller 23 of the slave station 17 in accordance with an alternate embodiment of the invention. Under this scheme, pointers are used to indicate the memory slot in which new data is to be written over the data for the oldest event when there is an overflow. Thus, data need not be shifted between slots as in the first embodiment of the invention discussed above. This routine uses two pointers, &#34;nxt --  ptr&#34; which identifies the slot in which data for the next event is to be stored, and a &#34;tl --  ptr&#34; which indicates the slot in which data is to be written over if there is an overflow. Referring to FIG. 6, if no events have been stored as determined at 113 when the first event is detected at 115, the &#34;nxt --  ptr&#34; is set to 0 at 117 and the identification of the event and the time stamp, which will of course be 0 for the first event, as are stored in the slot 0 identified by the &#34;nxt --  ptr&#34; as indicated at 119. The &#34;tl --  ptr&#34; is then set equal to 1 and the &#34;nxt --  ptr&#34; is made equal to &#34;nxt --  ptr+1&#34; as shown at 121 and the program is exited. The program is also exited at 115 if no event is detected. On subsequent runs of the interrupt routine, there will, of course, now be events stored when checked at 113, and if there are no new events as determined at 123, the count will be incremented at 125 before the program is exited. When a new event is detected at 123 on any subsequent run of the interrupt routine, a determination is made whether the slots are all filled at 127. If not, and a flag is not set indicating that the slots have all been filled as determined at 129, then the identification of the event and the count is stored in the slot identified by the &#34;nxt --  ptr&#34; as indicated at 131. The next pointer is then incremented at 133 and the count is incremented at 135 before the routine is exited. When during a subsequent execution of the interrupt routine it is determined that the slots are all filled as determined at 127 or there is an overflow as indicated by the flag being set as determined at 129, the &#34;nxt --  ptr&#34; is set equal to the &#34;tl --  ptr,&#34; the &#34;tl --  ptr&#34; is indexed, and the flag is set indicating that if an overflow has been detected, all as indicated at 137. If the &#34;tl --  ptr&#34; has reached the last slot as determined at 139, then the &#34;tl --  ptr&#34; is reset equal to 1 at 141. In either event, the identification of the event and the count are stored in the slot indicated by the &#34;nxt --  ptr&#34; as shown at 143, and again, the count is incremented at 135 before the program is exited. 
     This procedure of using pointers to maintain the data for the most recent additional event and the first event is illustrated by FIGS. 7A through 7D. As seen from FIG. 7A, when no events are stored the &#34;tl --  ptr&#34; and the &#34;nxt --  ptr&#34; both point to slot 0. As data is entered, first in slot 0, the &#34;tl --  ptr&#34; moves to slot 1 and remains there while the &#34;nxt --  ptr&#34; indexes to the next slot to be filled as illustrated in FIG. 7B. When all of the slots have been filled as illustrated in FIG. 7C, the next pointer will be pointing to a nonexistent slot beyond the last slot, n. Upon detection of the next event, the &#34;tl --  ptr&#34; advances to slot 2 and the &#34;nxt --  ptr&#34; points to the first slot in which the data for the new event, n+1, is written over the data for the first additional event detected as shown in FIG. 7D. The &#34;tl --  ptr&#34; and &#34;nxt --  ptr&#34;  then advance together through the slots and wrap around back to slot 1 when they reach n. 
     FIG. 8 illustrates a flow chart for a suitable main program for the slave microcontroller 23 when the alternate interrupt routine of FIG. 6 is used. Again, as long as no commands are received at 145, the microcontroller performs a self test at 147. When a command to send data is received at 149, the data for the first event is transmitted at 151. An index, i, is then set equal to &#34;tl --  ptr&#34; at 153 and the data for slit i is transmitted at 155. The index i is then incremented at 157. When the last slot is reached as determined at 159, i is reset to 1 at 161. The data from each subsequent slot is transmitted in the loop including blocks 155, 157, 159, 161, if necessary, and 163 until i becomes equal to &#34;nxt --  ptr&#34; at 163 indicating that all of the data has been transmitted. With this sequence, the data for the first event is transmitted first followed in sequence by the data for the next oldest event up to the most recent event. If a &#34;clear events&#34; command is received from the master station at 165, all of the events and time stamps are cleared from the slots at 167 and then the count, the &#34;nxt --  ptr&#34; and the &#34;tl --  ptr&#34; are set equal to 0 and the flag is cleared at 169. All other commands are serviced at 171 if there is no send data at 149 or clear events command at 165. 
     While specific embodiments of the invention have been described in detail, it will be appreciated by those skilled in the art that various modifications and alternatives to those details could be developed in light of the overall teachings of the disclosure. Accordingly, the particular arrangements disclosed are meant to be illustrative only and not limiting as to the scope of the invention which is to be given the full breadth of the appended claims and any and all equivalents thereof.