Define when a Logic Program Updates its Outputs
You can use the Logic program Forms to define when a Logic program updates its output values:
- Display the configuration Form for the relevant program (see Configure an ST Program, Ladder Diagram, SFC or FBD).
- Select the Logic tab.
- Use the Update Outputs combo box to set a program to update its outputs:
- Changed Outputs Only—If the program calculates values that are different to the existing output values, the existing output values are overwritten. The new values from the program’s results replace the existing output values (but only for those outputs that have different values to those in the program’s results). This setting is useful when you only want the program to update the outputs to reflect changes in the Logic program’s calculated results.
The main advantages of using the Changed Outputs Only setting are that the program will only generate historic records for values that have changed and there is no needless processing (as ClearSCADA only writes new values to the outputs that need to be updated and only generates historic records for values that have changed).
- All Outputs (Always)—The program will write a new value, even if the result of the program returns the same output value as the existing output value. This setting is useful when you only want the program to update on every execution.
The main advantage of using the All Outputs (Always) setting is that you can check that the program is executing correctly at the required intervals or when the inputs are updated. This means you can have confidence that the program is functioning correctly, even though its outputs are not changing.
- All Outputs (If Any Changed)—If the program returns one or more output values that are different to the existing values, new values are written for each of the outputs. This setting is mainly designed for use with Logic programs that write to the PresetTimestamp or PresetQuality fields of internal points.
To help you understand how the All Outputs (If Any Changed) setting works, we will begin by explaining how the PresetTimestamp and PresetQuality fields can be used.
The Preset Timestamp and PresetQuality data fields are used to store the time stamp and quality values for the internal point’s historic record. By default, the PresetTimestamp value is the current time and the PresetQuality value is Good, but by writing to these fields, you can apply a different time stamp and quality value. This is useful when you use an internal point to store a value that is derived from other point values, for example, for storing the average value of a selection of points. By writing to the PresetTimestamp and PresetQuality fields, you can set the historic record of the internal point to match the time stamps and quality values of the points used in the calculation. If the PresetQuality and PresetTimestamp were not written, the internal point’s historic record would use the time stamp for the time of the calculation and the quality would be ‘Good’ (which may not be the case).
The PresetQuality and PresetTimestamp are written when the internal point is next updated, and once written, are reset. This means that once they have been applied, they have no effect on further updates (unless the program is coded so that the PresetQuality and PresetTimestamp fields are written to again).
If you have a Logic program that writes to the PresetQuality and/or PresetTimestamp fields, your choice of Update Outputs affects when the Preset values are applied:
- With the Changed Outputs Only setting, the Preset fields are only applied if there is a change to the calculated value (that is to be stored in the internal point changes). This is because the Logic program is set to only write to the CurrentValue of the internal point if the calculated value has changed since the last execution. If the Logic program does not write to the CurrentValue, there is no new historic value to be logged and so the Preset values are ignored.
- With the All Outputs (If Any Changed) setting, the Preset fields are applied if the Logic program’s inputs have a change of quality, a different time stamp, or the result of the Logic program’s calculation changes. If any of these changes occur, the Logic program writes to the CurrentValue, PresetTimestamp and PresetQuality fields of the internal point. This means that a historic record is created even if the calculated value of the Logic program has not changed.
- With the All Outputs (Always) setting, the Preset fields are applied every time the Logic program executes. This is because the Logic program writes the PresetTimestamp, PresetQuality and CurrentValue of the internal point on each execution, irrespective of whether any of these values has changed. As a result, there is a historic value logged for every execution of the Logic program.
- Changed Outputs Only—If the program calculates values that are different to the existing output values, the existing output values are overwritten. The new values from the program’s results replace the existing output values (but only for those outputs that have different values to those in the program’s results). This setting is useful when you only want the program to update the outputs to reflect changes in the Logic program’s calculated results.
To configure the other Logic tab settings, see Configure an ST Program, Ladder Diagram, SFC or FBD.