MAvgOnTrigger('Expression', 'Trigger', 'NumberOfValues*', 'Reset=0')
Parameters ending with * are only evaluated once at the start of the acquisition..
Arguments
|
'Expression' |
Measured value, for which the average is formed |
|
|
'Trigger' |
Digital signal or expression as a trigger for the execution of the command |
|
|
'NumberOfVlaues*' |
Number of samples which are used for the calculation of the average; Parameter will be evaluated at start of acquisition. Therefore, rather use a fix value instead of an expression. |
|
|
'Reset' |
Optional parameter (default = 0) to stop and restart the calculation. |
|
|
'Reset' =0 |
Perform calculation |
|
|
'Reset' =1 |
Stop calculation, delete all buffered data and set result to 0 |
|
|
'Reset' =2 |
Stop calculation and keep result |
|
Description
This function returns the moving arithmetic average of 'Expression', which is evaluated on every rising edge of 'Trigger'. Only as many values as specified by 'NumberOfValues' are taken into account for the calculation. After start of acquisition or after a reset with 'Reset' = 1, 'Trigger' has to be fired 'NumberOfValues' times before the first average value can be calculated. With each other trigger the average for the last 'NumberOfValues' triggered samples is calculated.
This makes it possible to calculate moving averages controlled by events. The calculation then can be performed e. g. per revolution of a machine or per produced part instead only linear over time.
Example
Apply MAvgOnTrigger on a triangular signal

For explanatory reasons only 'NumberOfValues' = 5 has been specified in the example.
Not until the 5th trigger after start of acquisition a first average value (red 1.) is calculated from the 5 selected samples (blue dots). The distance between the trigger events does not matter. The small and even distance between the first 5 triggers is due to graphical reasons.
With each other trigger the new actual and the last 4 samples are taken into account for the calculation, returning the respective average values (green 2., 3., 4., 5. etc.)