Moving Average and Low-Pass Filters
Noisy sensor readings are usually smoothed before a controller uses them. A moving average averages the last few readings. A first-order low-pass filter blends each new reading into a running estimate. Both reduce noise, and both add delay.
Two filters
The moving average delays the signal by about \((N-1)/2\) samples. The low-pass filter has time constant \(\tau \approx T_s(1-\alpha)/\alpha\).
What to notice
Bigger windows and smaller \(\alpha\) give smoother lines, but the step shows up later. That delay is the price of smoothing, and in a control loop it can cause oscillation, as in the discrete-time control concept. The low-pass filter needs only one stored number, which is why it is everywhere in embedded code. The moving average forgets old data completely after \(N\) samples, while the low-pass filter forgets gradually.