Count('Expression','Level*','Hysteresis*','EdgeType*', 'Reset=0')
Arguments
|
'Expression' |
Measured value |
|
|
'Level*' |
Specification of the level value |
|
|
'Hysteresis' |
Specification of a hysteresis band |
|
|
'EdgeType*' |
Indication of whether rising, falling or rising and falling edges should be counted |
|
|
'EdgeType' <0 |
only falling edges (leaving out hysteresis band in the negative direction) |
|
|
'EdgeType' >0 |
only rising edges (leaving out hysteresis band in the positive direction) |
|
|
'EdgeType' = 0 |
falling and rising edges |
|
|
'Reset' |
Optional digital parameter that can be used to reset the counter. ‘Reset’ can be an expression as well. An analog signal signal can be used for reset too, but it's value must be exactly = 1 (integer). |
|
|
'Reset' = 1 or True |
Counter is reset; analog reset signal: value has to be integer |
|
|
'Reset' ≠ 1 |
Counter value is retained / continues to count (default) |
|
Parameters ending with * are only evaluated once at the start of the acquisition.
Note |
|
|---|---|
|
The 'Reset' condition must not be related to the count function itself. |
|
Description
The function counts the crossings of 'Expression' through 'Level'.
The 'Hysteresis' parameter can be used to define a tolerance band which is above and below 'Level' by equal amounts. Only complete crossings through the tolerance band are counted.
The 'EdgeType' parameter determines which kind of edges are counted.
The 'Reset' parameter is used to reset the counter value to 0. 'Reset' can also be formulated as an expression.
Examples:
|
Count([0:0],10,1,1) |
No reset happens ('Reset' omitted) |
|
Count([0:0],10,1,1,If(Mod(T(),20)=0,TRUE()m,FALSE())) |
The counter is reset in a time interval of 20 seconds. |
|
Count([0:0], [3.1]) |
e.g. with [3.1] = If([0:0]<1, 1, 0) The counter is reset as soon as the expression [3.1] returns TRUE, i.e. if the expression [0:0] falls below the limit value 1. |
Tip |
|
|---|---|
|
The COUNT function can also be used for binary signals. For this purpose, choose 0.5 for Level and, for example, 0.1 for Hysteresis. This then means that all changes from FALSE to TRUE and vice versa are detected and counted. |
|
Example
Tip |
|
|---|---|
|
This function can be used in a virtual retentive module. Its result values can thus be obtained despite stopping and restarting the measurement. |
|
The number of deviations of the measuring signal from the value of 10 in a 20 second interval in both directions should be counted, but only after complete crossings through the hysteresis band of width 2. The maximum value of each interval without the start phase should be saved.
Task description
The 'Reset' parameter of the count function consists of an If query of the modulo function of time. The maximum value is reset once via the OneShot function as soon as the measured value has leveled off at the beginning of the measurement.
Solution

|
Blue |
Measured value |
Green area |
Hysteresis band |
|
Red |
Count function |
Green signal |
Maximum value of the intervals of the count function |
Tip |
|
|---|---|
|
When specifying a hysteresis band of 2 around 'Level' 10, the crossings in the increasing direction are first counted for 'Expression'>11 and in the descending direction for 'Expression'<9. |
|