Change
(Engine-Level Function)
Description: | Returns a true when the value of the first parameter changes by at least the value of the second parameter. |
Returns: | Boolean |
Usage: | Steady State only. |
Function Groups: | Variable |
Related to: | DeadBand | Edge | Latch | Toggle | Save |
Format: | Change(Value, MaxLimit) |
Parameters: |
Value |
Required. Any numeric expression giving the value to check for the change. |
MaxLimit |
Required. Any numeric expression giving the amount by which Value must change for the function to be true. The change in Value must be strictly greater than MaxLimit for the Change function to be true. If MaxLimit is less than zero, the function will always be true. |
Comments: |
The change specified by MaxLimit is the absolute value of the change so the Value is checked for an increase or decrease by this amount. Value must change from a valid value to another valid value. Changing to or from an invalid value does not trigger a Change. |
Example:
Save(0, 0, 0, 0, 1, 0, 0 { Save 1 float value to disk }, 1000 { Number of records }, 50 { Buffer 50 records }, "G:\DATA\SETPT.DAT" { file name }, Change(sp, 0) { Trigger - any changes in sp }, Sp { Setpoint value to log });
This shows how to use a Change function as a trigger for a Save statement to log data whenever the datum changes. Notice that by using a 0 as the MaxLimit value, all changes no matter how small are registered. When the Save statement is triggered (when data are logged), the Change statement is reset to wait for another change.
An example of how Change is used is as an action trigger follows:
If Change(X, 0.5); [ ... ]
The script will execute once every time x changes by more than 0.5. The Change function is reset when it is used in a action trigger and it becomes true. Suppose the following happens to x:
X (initial value) = 3.4 X (changes to) = 3.5 -> Nothing happens yet X (changes to) = 3.9 -> Action triggers, script executes, Change is reset
Change now waits for X < 3.4 or X > 4.4
X (initial value) = 4.1 X (changes to) = 4.2 -> Nothing happens yet X (changes to) = 5.1 -> Action triggers, script executes, Change is reset
Change now waits for x < 4.6 or x > 5.6