Lag Filter
medium
Smooths a noisy analog input by closing a fraction of the gap to it once per second.
What it teaches
Each second, move the output a fixed fraction of the way toward the input — the classic first-order lag. A small fraction smooths heavily but responds slowly; a large one tracks fast but smooths less. Jitter averages away while sustained moves still arrive, just softened. Complements a median filter: the median rejects single bad samples outright, the lag softens everything.
Inputs and outputs
| Tag | Type | Default | Description |
|---|---|---|---|
| In_Value | REAL | 100 | Noisy analog input |
| Cfg_Tau | DINT | 4 | Smoothing strength; each tick closes 1/Cfg_Tau of the gap |
| Out_Filtered | REAL | — | Smoothed value |
Required behavior
- Once per second, Out_Filtered moves toward In_Value by 1/Cfg_Tau of the remaining gap: with Cfg_Tau 4, each tick closes a quarter of the gap.
- Between ticks the output holds — the smoothing rides on the 1-second tick, not on the scan.
- Cfg_Tau of 1 copies the input on every tick; a Cfg_Tau of 0 or less freezes the output.
- The output starts at 0 and converges toward the input tick by tick.