robs wrote:
...The tuner gets to specify a lag percentage. The output of the lag calculation is the value that percentage of the way between the last output value and the most recent raw value. So a lag value of 0 locks the input forever where it started. A lag of 100 simply gives the most recent sample. A lag value of (say) .75 gives you T(n) = T(n-1) + .75[T(n)-T(n-1)].
OK it indeed is a single tap IIR lopass filter. It creates a single pole lopass filter. Just like the first 2 examples in the linked PDF with the positive values.
2 identical "lag" (or 1st order lopass) filters in cascade is NOT the same as a single 1st order lopass filter with some equivalent "lag factor" (aka time constant aka pole frequency)
The math (using laplace transforms) is like this
1-pole transfer function: 1 / (k1*s + 1) <-- denominator is 1st order
2-pole transfer function: 1 / (k2*s^2 + k3*s + 1) <-- denominator is a 2nd order polynomial... and 2-pole Bessel degenerates into two identical 1-pole filters in cascade
Here is an example of a step response of the former vs. the latter filter. There is no way to make the step responses match by adjusting the lag factor of the 1-pole filter:
The 1-pole filter has a 25% lag factor, the 2-pole has 40% each.
The difference you see in my example may be subtle, but I purposely adjusted them so that they matched partway up. The 2-pole lag filter output rejects high frequency noise much better (see below)
However I don't believe you have ever explained why running values through a lag filter twice is superior for the dot operation, you merely asserted it. But I'm not that fussed about the theory.
A single pole lopass filter will filter out frequencies above its "corner frequency" at a rate of -6 dB per octave, meaning the noise voltage is halved for every doubling in frequency.
For example, if the corner frequency is 100 Hz, noise at 200 Hz will be halved, noise at 400 Hz will be 1/4th in size, and at 800 Hz will be 1/8th in size.. and so on.
For a 2-pole lopass filter, or 2 identical 1-pole lopass filters in cascade, the noise voltage is reduced to *1/4th* for every doubling in frequency.
For example if the corner frequency is 100 Hz, noise at 200 Hz will be 1/4th in size, noise at 400 Hz will be 1/16th in size, and and at 800 Hz will be 1/64th in size.
When you perform a dot operation (differentiation) on a signal, you increase the size of the signal at +6 dB per octave, meaning any signal or noise voltage will be DOUBLED for every doubling in frequency.
Thus a signal or noise at 200 Hz will be double the size of a 100 Hz signal, noise at 400 Hz will be 4x the size, and at 800 Hz will be 8x in size.
If you do the dot operation after 1-pole filtering, the attenuation of the lopass filtering will be canceled by the high frequency amplification of the dot operation. The resulting frequency response is flat. That is, the dot operation and the lag operation will cancel, with the result that signals and noise above the lopass cutoff frequency will neither grow in size with frequency, nor shrink.
If you had done 2-pole lopass filtering before the dot operation, the resulting frequency response will be that of a 1-pole lopass filter. (Every doubling in frequency halves the noise amplitude). Thus high frequency noise attenuated.
If you have specific software filter suggestions, stated in terms that a mathematically literate electronic incompetent might understand, this mathematically literate electronic incompetent will be happy to code them up in R and test them against Gaussian noise, or other suggested test scenarios.
You can write a piece of R code to test it. Try it comparing a 1-pole lag filter with 25% lag factor and a 2 lag filters cascaded, each with 40% lag factor (this matches up their ramp delay times)
You can test it with a 1-sample wide spike of noise, and with gaussian noise.
You can also make it very long, then do an FFT and plot the spectra before, and after filtering.