Hi,
i played around with my scope and i found something that looks rather strange to me:
I would have expected, that the average of the signal would perfectly fit into the actual signal, but it doesnt. I used persistence in combination with dot mode display.
What am i missing?
Red trace: trigger signal
Yellow trace: actual Signal
Orange trace: math average of yellow signal
Its a SDS800X HD.
Hello,
Averaging requires a time period or number of samples that forms the "window". If the window is wide you get a smoother trace, if the window is narrow you get a rougher trace. If the window was 5 samples, then every 5 samples would be averaged and that would be the value there, and that would be similar to a low pass filter function. If the window was only 1 sample wide (never happens though) the average would be the very same waveform as the signal itself.
The math behind it is: The integral of the time function with time 't' over a time period 'Tp' (then divided by Tp). The period Tp defines the time the average would be accumulated.
Going by samples if we had sample values 2,2,2,6 and the window was 3 samples, the first average point would be (2+2+2)/3=2, and the second average point would be (2+2+6)/3=3.33, and since we don't have any more samples yet that's as far as we can go unless we average the last two.
Your orange trace indicates that the window is wide enough to 'see' the rising part of the signal long before it even happens, so we see the orange trace rise before the yellow trace. When we get nearer to the higher values of the signal, the lower parts of the signal are still being averaged into the mix so we see a lower trace there. On the right side of the signal bump we see the signal go lower than the average, and that is because the higher parts of the signal are still in the sum so the average can not go low right away.
So there's a sort of delay and some smoothing. That's almost always the case. In fact, you can create a digital low pass filter in the same way: by creating a moving average routine in code:
sum=0
START REPEAT:
v=signal
sum=(sum*2+v)/3
END REPEAT
In the above 'v' measures the signal at one point, then the sum sums the weighted sum plus the new sample 'v'. The code then repeats indefinitely or until the wave stops. The weight in the above is '2' and that means the previous sum is doubled and when 'v' is added to it, we have a total of 3 samples so we divide by 3. That's a running average, but it's also a digital low pass filter.
The larger we make the weight (that '2') the smoother the average wave becomes. If we made it 19 for example, then we would divide by 20, and that would produce a much smoother wave than using the weight of '2':
sum=(sum*19+v)/20
That's the simplest form of an actual first order digital low pass filter.