|
<< Click to Display Table of Contents >>
Considerations on Processing Events in a PLC's Application |
A PLC's application must keep the next internal variables.
•W03 (address 8206h): Writing pointer of the circular buffer, which must be updated by a PLC's application whenever a new event is added to that buffer
•W04 (address 8208h): Reading pointer of the circular buffer, which must be zeroed by a PLC's application when starting and it is updated by that application after every buffer's successful download
•W05 (address 820Ah): Overflow counter of the circular buffer, which must be zeroed by a PLC's application when starting. Whenever a PLC adds an event to that buffer, it must increment this overflow counter if it was overflowed, that is, the W03 variable is equal to the W04 variable. Before downloading this buffer, an application checks the overflow counter and, if it is different from 0 (zero), then the reading pointer is not considered and the whole buffer is considered as valid
•W06/W07 (address 820Ch/820Eh): Last time base used by an application, a 32-bit DWord, which must be zeroed by a PLC's application when starting and it is updated by that application after every buffer download. The W06 variable contains the 16 least significant bits and the W07 variable contains the 14 most significant bits. This base is not considered by an application if there is an overflow of the circular buffer
•W08/W09 (address 8210h/8212h): Next time base to use, a 32-bit DWord, which must be zeroed by a PLC when starting. The application writes to these memories before sending a clock sync command, which consists of activating an output of one of the PLCs, which must be connected to a specific input in all other PLCs. The activation of this input in the PLCs must be interpreted as a clock sync command. When a PLC receives a sync command, it must add to the buffer an event of switching the time base, the sync event, containing the value of these memories. The W08 variable contains the 16 least significant bits and the W09 variable contains the 14 most significant bits. This command must be triggered periodically by an Elipse Software application, due to controller's clock imprecision
NOTE |
The time bases (32-bit DWords) contain the number of seconds since 1/1/1998 00:00:00. Only the 30 least significant bits are used, allowing a date interval ranging from 1/1/1998 00:00:00 to 01/10/2032 13:37:03. PLCs do not need to manipulate these numbers, only copy them when needed. |
•BUFFER (address 8A00h onward): Buffer for storing events. This is a circular buffer, with its reading and writing indexes returning to 0 (zero) after reaching their maximum limit. The size to allocate for this buffer depends on the maximum number of events defined in this Driver's extra configuration parameters.
Each event consists of two 32-bit Words. The two most significant bits indicate the type of an event:
•00 (channel in zero): The 9 (nine) least significant bits of the first Word indicate the address of the input that generated the event and the second Word contains the value of the hundredths of seconds counter at the moment of the event
•01 (channel in one): The 9 (nine) least significant bits of the first Word indicate the address of the input that generated the event and the second Word contains the value of the hundredths of seconds counter at the moment of the event
•10: Overflow on the hundredths of seconds counter
•11 (syncing): Change in the time base. The 14 least significant bits of the first Word indicate the bits, from 16 to 30, of the new time base and the second Word contains the 16 least significant bits of the new time base. This event is usually activated periodically by an Elipse Software application, activating an output of one of the PLCs that, by its turn, is connected to a specific input of each PLC, and when it is activated, this input is interpreted by a PLC's application as a sync event
The tasks of a PLC's application are the following:
•When starting: Set the memories from W04 to W09 to 0 (zero)
•After adding an event to the memory buffer: Check if an overflow occurred, that is, the W03 variable is equal to the W04 variable, and if positive, increments the W05 variable
A reading pointer allows a PLC to detect and notify an application about a circular buffer overflow, a crucial information when validating data.
A PLC registers the base time for an application together with sync events. This allows an application that is not started to correctly interpret the hundredths of seconds counter of buffer events.
Storing the last base time used by an application, the W06 or W07 variables, allows an application to be stopped and restarted at any time. Events are not lost and time records are fully reliable. The only loss occurs if there is a buffer overflow in a PLC.
The indication of a buffer overflow allows an application to try to recover a larger number of events, because when this occurs, the reading counter is not considered and the whole buffer is then read. This indication also validates or not the last base time used by this Driver, that is, the W06 or W07 variables.
When there is more than one application, then users must create a communication among the PLCs, so that when one of the applications starts to sync the clock, it can inform the new base time to one of the PLCs, and this PLC then informs the other PLCs on the network this new base time, by copying the content of the W08 and W09 variables. This allows an application to update the base time of all PLCs without the need of all applications to be active.