Why is the average trace (math) of my signal different to the actual signal? - Page 1
Forum section: electronics / beginners

author: eTobey
author_rank: Super Contributor
timestamp: December 29, 2024, 04:03:47 pm
content: 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 usedpersistencein combination withdot mode display.What am i missing?Red trace: trigger signalYellow trace: actual SignalOrange trace: math average of yellow signalIts a SDS800X HD.

author: inse
author_rank: Super Contributor
timestamp: December 29, 2024, 04:15:09 pm
content: What is the average function doing exactly on you scope?The average I know from e.g. Lecroy and Rigol is doing an average of selectable subsequent trigger events thus reducing random noise.If the signal is not stable, it gives an erroneous waveform.Then there is a filter function which is in principle a configurable low pass (introducing a phase shift like a real filter).Tektronix has a high-res mode that averages between the individual samples.Edit: damn, missed the 10pts resolution…Does this only apply to the math function?The yellow trace seems to consist of a lot more samples

author: Andy Watson
author_rank: Super Contributor
timestamp: December 29, 2024, 04:21:22 pm
content: Your timebase claims to be 200ns - 5 MSamples/s - that's one sample point per division. Clearly there is some interpolation happening - probably a sinc function on channel 1.

author: gf
author_rank: Super Contributor
timestamp: December 29, 2024, 04:32:39 pm
content: Quote from: eTobey on December 29, 2024, 04:03:47 pmAt only 5MSa/s, the displayed shape relies heavily on trigger point interpolation.Try the same with a significantly higher sample rate, say 50MSa/s or more.EDIT:Quote from: Andy Watson on December 29, 2024, 04:21:22 pmSeems you were fasterEDIT:In dots mode, only the horizontal trigger point position is interpolated between adjacent samples, and the dots of the traces are plotted at their interpolated horizontal positions (i.e. each plotted trace has an individual horizontal offset in the range -100...+100ns from the 200ns grid). Due to persistence, the dots of subsequent traces accumulate on the screen, similar to ETS sampling.I wonder, however, how trigger point interpolation and averaging work together, since averaging requires that the dots of the averaged traces lie on a common horizontal grid. If the fractional sample positions are simply ignored in the averaging, then statistically the averaging does indeed have a low-pass effect, which could explain the orange vs. yellow curve.

author: CaptDon
author_rank: Super Contributor
timestamp: December 29, 2024, 05:02:55 pm
content: The more rounded shape indicates bandwidth limiting or most likely rounded interpolation of fewer sample points.

author: eTobey
author_rank: Super Contributor
timestamp: December 29, 2024, 05:09:57 pm
content: Quote from: inse on December 29, 2024, 04:15:09 pmIt creates an average of multiple captures.Manual says:QuoteQuote from: inse on December 29, 2024, 04:15:09 pmSignal is stable, as can be seen on the picture. (persistence mode)Quote from: inse on December 29, 2024, 04:15:09 pmWhat exactly?Quote from: inse on December 29, 2024, 04:15:09 pmIts persistence mode.

author: CaptDon
author_rank: Super Contributor
timestamp: December 29, 2024, 05:24:38 pm
content: That yellow trace looks FAR to clean for persistance mode! Look at where you are triggering from. There should be enough 'bobble' around that trigger point to cause the yellow trace to become 'fat', almost like a C.R.T. scope looking slightly out of focus. I don't really know your scope but in almost every instance of using persistance mode on our lab scopes the trace tends to 'grow'. On that slopie sloopy trigger point it will never trigger at exactly the same point on the waveform therefore in persistance mode the trace will bloom. Are you in the constant run mode or was that scope shot from a 'single sweep' event? I have simply never seen traces that narrow and clean with persistance turned on.

author: gf
author_rank: Super Contributor
timestamp: December 29, 2024, 05:39:01 pm
content: It's persistance in conjunction with "dots" mode. For each trace, only 10 sparse points are plotted, and persistance accumulates the points of many traces, similar to ETS.

author: eTobey
author_rank: Super Contributor
timestamp: December 29, 2024, 05:51:18 pm
content: I looked at the average trace, it is indeed a interpolated trace (removed persistence and looked at the math trace). This really surprises me, as i have not set interpolation for THIS VERY reason.BUT, even with dot-mode it looks wrong, but i think, i have the explanation:The sample points (of the average memory) are moving horizontically, with the old value from the former position. Thus taking values of the signal that are 1 sample points apart.I should stop playing around at edge cases.Its interesting though.I hope i did not fool/annoy you guys to much with this edge case.

author: gf
author_rank: Super Contributor
timestamp: December 29, 2024, 07:02:21 pm
content: Quote from: eTobey on December 29, 2024, 05:51:18 pmLet's assume that Average(C1) calculates Average(Interpolate(C1)) under the hood, which is indeed a possible solution to the problem of averaging traces with individual horizontal offsets. Then you still have the problem that the signal shown by the yellow trace is IMO undersampled and therefore not eligible for interpolation. You still need a higher sampling rate.

author: radiolistener
author_rank: Super Contributor
timestamp: December 30, 2024, 03:30:56 pm
content: Quote from: eTobey on December 29, 2024, 04:03:47 pmCould you explain, how average signal can perfectly fit with actual signal?Average function is a kind of low pass filter, the output of low pass filter is not the same as input.

author: eTobey
author_rank: Super Contributor
timestamp: December 30, 2024, 04:10:30 pm
content: Quote from: radiolistener on December 30, 2024, 03:30:56 pmIt is that very function of the scope to removenoise / fluctuations. It theoretically would work with just one sample point. Cant explain it really...

author: MrAl
author_rank: Super Contributor
timestamp: December 30, 2024, 04:11:36 pm
content: Quote from: eTobey on December 29, 2024, 04:03:47 pmHello,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=0START REPEAT:v=signalsum=(sum*2+v)/3END REPEATIn 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)/20That's the simplest form of an actual first order digital low pass filter.

author: shapirus
author_rank: Super Contributor
timestamp: December 30, 2024, 04:22:52 pm
content: Quote from: radiolistener on December 30, 2024, 03:30:56 pmThis will happen when the input (and digitized) signal is ideal: no jitter and every sampled point after the trigger event is exactly the same every time it triggers. Then the average value of every sample accumulated over a certain time will be equal to the respective sampled value of the live signal.In real periodic signals sampled values will fluctuate due to noise, and using the average function allows to cancel out this (random, non-periodic) noise and see the perodic content. Sometimes this averaging is the only way to dig out very low-level signals from would otherwise look like only noise.Quote from: radiolistener on December 30, 2024, 03:30:56 pmNot in this situation. We're talking about averaging values across the Y axis (voltage), not X (timebase).

author: gf
author_rank: Super Contributor
timestamp: December 30, 2024, 08:00:56 pm
content: Quote from: radiolistener on December 30, 2024, 03:30:56 pmWhat you describe is usually called HiRes or ERES functionality of a scope. It's either offered as a math function, or as an acquisition mode. Under the hood it's a lowpass filter which is applied to a single trace.Trace averaging is different. It averagesmultipletraces (from multiple successive acquisitions) after aligning them horizontally at the trigger point. Ideally, in the absence of trigger jitter (i.e. when the traces are perfectly aligned), this is not expected to do any lowpass filtering. In the presence of trigger jitter, the traces are not perfectly aligned horizontally, and averaging the imperfectly aligned traces does have a lowpass effect, too.

author: eTobey
author_rank: Super Contributor
timestamp: December 30, 2024, 08:53:45 pm
content: Quote from: gf on December 30, 2024, 08:00:56 pmAltouth i am a kind of scope noob, i have some pretty good understanding of ADC, so this is how i see it working:The ADC and trigger system run in paralell. The ADC is in "free running mode", so sample points will never align at all. Exception: The signal has the right frequency.I would like to mention again:Quote from: eTobey on December 29, 2024, 05:51:18 pmIts in fact two seperate things, that have the same result: Points having been connected by interpolation, and points that resample averaged values beeing drawn (persistence).So i just did with persistence, what the scope would do anyway with just one capture, alltough i set it up, to not do it. Naughty little scope.

author: gf
author_rank: Super Contributor
timestamp: December 30, 2024, 09:09:04 pm
content: Did you try to do the same at a (say) 10x higher sample rate and check if the deviation between C1 and Average(C1) becomes smaller?

author: eTobey
author_rank: Super Contributor
timestamp: December 30, 2024, 09:35:53 pm
content: Quote from: gf on December 30, 2024, 09:09:04 pmYes, it became much smaller at 2x higher sample rate already .

author: gf
author_rank: Super Contributor
timestamp: December 30, 2024, 10:56:16 pm
content: Quote from: eTobey on December 30, 2024, 08:53:45 pmYou can think of them as if they would. But they are not really independent, because it is a "digital trigger" which is also calculated from ADC samples.Many (most?) modern scopes no longer have dedicated trigger hardware (except for the external trigger input).Nevertheless, the horizontal position of the trigger point is determined with higher resolution than one sampling interval of the acquisition sample rate:a) via interpolation between samplesb) because the ADC always runs at full speed (1GSa/s or 2GSa/s), and so does the digital trigger engine[ any lower acquisition sample rate is down-sampled from the full ADC sample rate by the FPGA ]This allows the dots mode, in conjunction with persistence, to successively build up the correct shape of periodic signals with sparse, unconnected dots,even if the signal was undersampled. That's similar toLeCroy's Random Interleaved Sampling(but without hardware TDC, just based on the digital trigger).

author: BillyO
author_rank: Super Contributor
timestamp: December 31, 2024, 12:50:29 am
content: It's an average over a moving window. It looks perfectly fine to me.

author: eTobey
author_rank: Super Contributor
timestamp: December 31, 2024, 07:05:25 am
content: Quote from: BillyO on December 31, 2024, 12:50:29 amWhy would it then not average, if i increase the sample rate? And where could i set up the width of the window?

author: eTobey
author_rank: Super Contributor
timestamp: December 31, 2024, 07:09:55 am
content: Quote from: gf on December 30, 2024, 10:56:16 pmSome good information, that i just confirmed (by testing) to not have any flaws. My information is from a video 7 years old.Interpolation is a great tool, that is also something that will come into play in my BLDC controller.

author: gf
author_rank: Super Contributor
timestamp: December 31, 2024, 07:40:13 am
content: Quote from: BillyO on December 31, 2024, 12:50:29 amTrace averaging does not explicitly apply a moving average filter.Still, a convolution can happen as (unwanted) side effect.

author: gf
author_rank: Super Contributor
timestamp: December 31, 2024, 07:43:25 am
content: Quote from: eTobey on December 31, 2024, 07:09:55 amBtw, this applies to Siglent scopes like yours (which you obviously consider so buggy that they are almost unusable). Don't expect that any other scope does the same.

author: eTobey
author_rank: Super Contributor
timestamp: December 31, 2024, 09:42:12 am
content: Quote from: gf on December 31, 2024, 07:40:13 amIsnt a moving window averaging all the values that werebeforea point? I believe in my case, its like the ERES defintion where adjacent points are averaged.

author: eTobey
author_rank: Super Contributor
timestamp: December 31, 2024, 09:47:34 am
content: Quote from: gf on December 31, 2024, 07:43:25 amOf course i already checked, that this would apply to my scope. (Some features have some flaws that are at least confusing, which would let you think your circuit is doing weird stuff, when acutally the scope doing weird stuff - Apart from "normal" weird stuff.)

author: MrAl
author_rank: Super Contributor
timestamp: December 31, 2024, 04:24:39 pm
content: Quote from: eTobey on December 31, 2024, 09:42:12 amIt does not matter it depends on how the algorithm was made and applied. It could also be such that it waits for 1/2 the number of samples before it averages, or it begins averaging right away. In the case for sum=(sum*19+v)/20 we would see a very small average to start with if the signal started out at 0 volts. The first two samples would result in a low value, which would be normal for that kind of algorithm.There are other algorithms which implement a digital filter in a more elaborate form. 2nd order, 3rd order, etc., which can usually respond faster to changes in the signal level. There are so many kinds of digital filters though so there are many algorithms. There are books written just for that.