Data
A Data event trigger executes when a
device variable's data value meets a defined condition.
The conditions available include being equal to, greater than or less than a value. The conditions also include concepts of dead band and tolerance.
The trigger component handles the periodic reading of the device variable's value and applying the defined condition. If the condition is met, the data event trigger is scheduled to execute. This alleviates the trigger's application logic from reading the variable's value and comparing it to the condition before deciding to execute the application logic in the trigger's actions.
Defining a data event trigger
To define a data event trigger, follow these steps:
- From the Workbench left pane, expand the node where
you want to define the data event trigger.
- Select the Project icon to display
the Projects window, right click a
specific project tab to display its pop-up menu, and
then select New.
You also can select the New button at the bottom of the Projects window when a specific project tab has already been selected. - The new Trigger window
appears.
Name the trigger. The trigger name can be up to 64 characters and include letters, numbers, and the underscore character. Spaces are allowed. - From the Event tab, select the
Trigger Event Type down-arrow, and
then select Data.
The Event tab becomes active with parameters that accommodate the data event. - Select the device variable that will be monitored
to determine when the trigger should be executed.
On the Event tab, use the down-arrow next to Variable Name.
A list of the currently started devices on this node appears. - Expand the list, and then select the variable you
want to use.
For this example, Local CPU 1.D[1].
The name of the device variable is displayed in the Variable Name parameter. - Use the Variable Type down-arrow
to display a list of device data types.
For this example, accept the default INT2. -
Now that you have added the device variable and specified the variable data type, your next step is to select the condition to be evaluated.
Use the Condition down-arrow to display a list of conditions.
For this example, Value changed is selected. Therefore, whenever the Local CPU 1.D[1] device variable 's value changes, the trigger will execute.
The condition can be specified as follows:Condition Description Value changed The value of a device variable changed from its previous value. On start or value changed The value of the device variable changed from its previous value. Also, the trigger is executed once as soon as it is loaded. Greater than The device variable is greater than a defined value. Greater than or equal to The device variable is greater than or equal to a defined value. Equal to The device variable is equal to a defined value. Less than or equal to The device variable is less than or equal to a defined value. Less than The device variable is less than a defined value. - When Value changed or On Start or Value Changed are specified as the condition, the Value, Tolerance Range, and Deadband Range parameters are not used.
- When Equal to is specified
as the condition, the Tolerance
Range, and Deadband
Range parameters are not used.
- Use the Priority parameter to
select a value in milliseconds. The
Priority parameter is used to specify
the frequency to read the value of the device variable.
Values are in milliseconds.
For the example bellow, the device variable is read at least once within 500 milliseconds, and evaluated against the condition.
For this example, the condition is Value Changed from the last value read. -
For other conditions, select values for the remaining condition parameters:
Parameter Description On Edge Limits the number of times a trigger executes. Used in conjunction with Greater than and Less than conditions and Tolerance Range. Tolerance Range Limits the number of times the trigger executes. The interpretation of the value is based on the selected event condition (Greater than, Less than, Greater than or equal to, and Less than or equal to).
The value that you specify will indicate how much you want to allow the value of the device variable to fluctuate before the system acts on it. The value can be either a constant value or device variable.Deadband Range Specify a deadband range value when you want to filter insignificant changes. If the value read does not differ from the last stored value by at least the deadband range value, the trigger is not executed. The value can be either a constant value or device variable. Works in conjunction with Value changed, On Start or Value Changed, Greater than, Less than, Greater than or equal to, and Less than or equal to conditions. Value A numeric value used in conjunction with Greater than, Less than, Equal to, Greater than or equal to, Less than or equal to conditions. The value can be either a constant value or device variable.
If two different priorities are defined, one of them X ms, the second Y ms, where Y < X, the device variable will be read at least once within Y ms. In conclusion, it will be read at least once within the minimal time-span defined.
Data event type trigger event variables
The input event variables available to a data event trigger are:
Event variable |
Data type |
Description |
---|---|---|
DATA | The data type of the device variable | The data value from the device variable. |
PREVIOUS_DATA | The data type of the device variable | The data value from the device variable on the previous read. |
PREVIOUS_TIME | TIMESTAMP | The date and time from the previous read. |
Complete the trigger definition
Complete the definition of the trigger, including the follow trigger components:
- The trigger's actions
- The trigger's local variables, static variables, macros and event variables
- The trigger's settings.
Use the Validate button to check the
parameters and then the Save button to
save the trigger's definition.
The trigger will be listed in the Project's tab list of
triggers in the Stopped state.
Data event trigger priority parameter considerations
The Priority parameter is used to specify the frequency, in milliseconds, to read the value of the device variable. Since this reading of the device variable takes system resources, the requirements of the application and the capability of the system need to be understood. Considerations include:
- Every data event trigger defines a device variable that will be read by the system at the defined priority (frequency).
- Every data mapping defines a device variable that will be read by the system at the defined priority (frequency).
- Every device variable has an expected change rate.
This may be constant or it may be variable. For
example:
- Once every 5 minutes at the end of a manufacturing process is relatively constant.
- Every time a sensor's temperature value changes .1 degrees is most likely a variable rate.
- The application logic's latency requirement for the
data event's condition being met. For example:
- The end of the 5 minute manufacturing process needs to be recognized within 10 seconds.
- The change in the temperature value needs to recognized within 1 second.
- The more frequent the device variable is read, (a lower priority value) the lower the latency for the data event trigger's condition being met and the data trigger logic being executed.
- The more frequent the device variable is read, (a lower priority value) the higher the load on system resources.
The overall application's requirements and the capability of the system need to be monitored while the application is being developed and while it is in production.