VC10LPFilter
V = Variables
C = Calculation functions
The VC10LPFilter function implements a first-order low-pass digital filter (RC filter) for WORD dimension data.
IMPLEMENTATION
VC10LPFilter (Tsample, Tau, FilterIn, FilterOut)
Parameters:
IN/OUT | VARIABLE TYPE | EXAMPLE NAME | DIM | |
---|---|---|---|---|
IN | SYSTEM | swTsample | W | Sample time filter (msec) [0÷32767]. |
IN | SYSTEM | swTau | W | The filter time constant (ms) [0÷32767] |
IN | GLOBAL | gwFilterIn | W | Value of the variable that you want to filter (UM) [-32768÷32767] |
OUT | GLOBAL | gwFilterOut | W | Value of the filtered variable (UM) [-32768÷32767] |
Description
The VC10LPFilter function implements a digital low-pass filter of the first order whose time constant (Tau) is defined in the parameters passed to the function itself. Assuming you start from a zero input variable value the output of the filter takes a value equal to 63% of the entrance after the long Tau time. Similarly the cutoff frequency of the filter is
Example
;--------------------------------------------- ; Project : REG_012 ; Module Name : ReadTemp ; Author : ; Description : Read temperature & filter ;--------------------------------------------- MAIN: CALL ReadTemp swTsample = 100 ;100 ms sampling time filter swTau = 5000 ;5 sec filter time constant VC10LPFilter (swTsample, swTau, gwFilterIn, gwFilterOut) WAIT 1 JUMP MAIN
Note
-
The function contains a timer that marks the time filter sampling. It's important that the function is placed in the software that runs to each loop task.