The compare block with the
type manages thresholds, reflex outputs and events in the following modes:Comparison is configured in the Configuration screen by activating at least one threshold.
Comparison can be used to trigger:
an event on a threshold associated with an external task
The
type can manage up to four thresholds.A threshold is a configured value that is compared to the current counting value. Thresholds are used to define up to five zones or to react to a value crossing the threshold value.
Threshold values are defined in the configuration window and can also be adjusted in the application program by using the EXPERTSetParam function block.
If Thresholdx (x= 0, 1, 2, 3) is configured and comparison is enabled (EN_Compare
= 1), output pin THx of the HSCMain_M241
function block is:
set when counter value >= Thresholdx
reset when counter value < Thresholdx
EN_Compare
is set to 0 on HSCMain_M241
function block, comparison functions are disabled, including external tasks triggered by a threshold event and Reflex outputs.
The following example for Modulo loop with two thresholds shows comparison in the HSCMain_M241
function block:
Configuring an event on threshold crossing allows to trigger an external task. You can choose to trigger an event when a configured threshold is crossed as follows:
. The event is triggered when the measured value goes above the threshold value.
. The event is triggered when the measured value goes below the threshold value.
. The event is triggered when the measured value goes above the threshold value and when the measured value goes below the threshold value.
Configuring an event allows to trigger an external task. You can choose to trigger an event as follows:
. The event is triggered when the measured value is lower than the threshold value.
. The event is triggered when the measured value is higher than the threshold value.
. The event is triggered when the measured value is between two threshold values.
Using thresholds comparison status available in the task context (TH0
to TH2
output pins of the function block) is suitable for an application with a low time constant.
It can be used, for example, to monitor the liquid level in a tank.
Configuring reflex outputs allows to trigger physical reflex outputs.
These outputs are not controlled in the task context, reducing the reaction time to a minimum. This is convenient for operations that need fast execution.
Outputs used by the High Speed Counter can only be accessed through the function block. They cannot be read or written directly within the application.
The performance is directly linked with the type of output used: fast or regular. For more information, refer to Embedded Expert I/O Assignment.
Example of the reflex outputs triggered by threshold:
Care must be exercised when threshold compares are active to avoid unintended or unexpected results from the outputs or from sudden Event task execution. If the compare function is disabled, threshold values can be modified freely. However, if the compare function is enabled, suspend at least the threshold compare function while modifying the threshold values.
WARNING | |
---|---|
While EN_Compare
= 1, the comparison is active, and it is necessary to follow this procedure to apply changes to threshold values:
Step |
Action |
---|---|
1 |
Set The comparison is frozen at the current value:
NOTE:
EN_Compare , EN_Out0 , EN_Out1 , F_Out0 , and F_Out1 remain operational while SuspendCompare is set.
|
2 |
Modify the threshold values as needed using the
NOTE: Follow this rule to configure the threshold values: TH0 < TH1 < TH2 < TH3.
|
3 |
Set The new threshold values are applied and the comparison is resumed. |