Example 7 - Limit value monitoring, hysteresis & holding time
Task:
A measured value of a device should be monitored for limit value violations, and disturbances in the measured value should also be suppressed. Furthermore, it should also be recorded how long the limit value was violated - in total and for the last event.
Solution:
$"Math.Trigger_Thresh" = threshold($'FuncGen.Sinus', 0.0, -0.1, {delayOn: 0.5});
$"Math.Trigger_Trig" = trigger($'FuncGen.Sine', 0.0, -0.1, {stableOn: 0.5}); // alternative function
// Add up the total time if the limit value is violated
$"Math.TimeArc_s" = integrate($"Math.Trigger_Thresh", {storage: 'T_Arcs'});
// Duration of the last limit value violation
$"Math.TimeArcEvent_s" = stopwatch($"Math.Trigger_Trig", {latch: false, period: false, hold: false});
threshold()
and trigger()
can both be used for threshold monitoring, but they work slightly differently.
More details can be found in the explanation below, or in the documentation of the functions.
Functions used:
Explanation:
-
Math.Trigger_Thresh
: The threshold function is used to detect a limit value violation. A hysteresis of-0.1
is also specified so that small disturbances in the measured value are suppressed. For further interference suppression, the parameterdelayOn
is set to0.5
so that the output is only set totrue
as soon as the monitored signal has exceeded the limit value for 0.5 seconds. -
Math.Trigger_Trig
: The trigger function as an alternative tothreshold()
is similar in most aspects, but returns the original start and end times of the threshold violation as soon asstableOn
orstableOff
are fulfilled. -
Math.TimeArc_s
: The total time for which the limit value was violated is determined here using an integral (integrate()
) viaMath.Trigger_Thresh
. Using the parameterstorage: ...
, the value is stored persistently on the device and thus specifies the total duration of the limit value violation for the life cycle of the device. -
Math.TimeArcEvent_s
: The duration of the last limit value violation is recorded using thestopwatch()
function. The optional parameterhold: false
ensures that the measured time is reset to 0 for each positive edge ofMath.Trigger_Trig
. The parameterperiod: false
is used to change the measurement method of the function from the time between two rising edges to the time for whichMath.Trigger_Trig == true
. The parameterlatch: false
causes the measured time to be output continuously.