Question about how oscilloscope math works - Page 1
Forum section: electronics / beginners

author: dc443
author_rank: Newbie
timestamp: May 26, 2022, 07:04:27 am
content: I have a Siglent SDS 1202X-E here. I also have a 1104X-E sitting in the box unopened because I am thinking I can return it and save $500 if I don't really need the extra features.So this is my first scope and I'm dipping my toes into getting deeper into electronics. I'm a software programmer by trade. In my senior year at college I did take the intro 101 course for electrical engineering, just for fun, and although there were bits that were a bit less than fun I definitely got some value out of it!Alright, so the thing that is bothering me the most right now tinkering with this 1202X-E is I don't seem to quite understand how the math function is supposed to work. And as with most things I end up diving into pretty much the most obscure stuff right off the bat.So I have a pair of alkaline cells in series (both are at 1.37V) and I'm attempting to use Math to do a differential measurement. So it's set to CH1 minus CH2, i've taken the ground leads off of the probes, and when I connect the probes and use Auto Setup, it comes back setting my CH1 offset to 1.380V and CH2 offset to -1.354V. Both got set to 50mV/div. They line up. The waveform is a super jiggly 60Hz thing, now that makes sense since nothing is grounded, and the probe leads (and battery I suppose) are acting as an antenna for the EMF in my room here which happens to be dominated by the 60Hz AC wiring in the house.When I set up Math, with Operator "-" and Source A = CH1, Source B = CH2, I turn on the Mean for MATH in Measurement, and that reads 2.72V. OK.- Why is it 2.72V and not 2.74V as my multimeter reads? Which one is more correct?- Is switching on the Mean in Measurement the only way to get a readout of the math output? Is the only other way to actually count divisions and use cursors stuff? I suppose this is a dumb question because the same applies to the regular probe readings. Looks like you can't get a readout unless using the Measure feature.When I disconnect either probe, both waveforms disappear. This makes sense because they went back to zero, and my auto setup window very specifically zoomed me into the vicinity of 1.380V and -1.354V which plainly explains why they have disappeared since 0 is outside the limits.Here's where I get confused. When the probes are disconnected, the Math reading Mean shows 2.22V.In the course of typing up this question I am formulating a guess. I'll walk you through it. I suppose that the scope might be pegging the probe readings to the screen boundaries and using those values for math, even though other math, even though measurements on the channels in this state show "****" due to out of range. So it's just not propagating the out-of-range condition. I've already noticed that the white math waveform will clip. So, following through with this hypothesis: With 4 divisions above and below the center line on the screen, that's 200mV to reach the edge. I'm not entirely sure about this math, but: 1.380 + 1.354 - 2*.2 works out to 2.334V. This is close to the 2.22V reading, but no cigar. The clip boundary would need to be 0.257V, which is 5.14 divisions, instead of the 4 shown on-screen.So that was an inconclusive deduction.I have further evidence however. If i tweak any of the vertical knobs for the channels it will change the Math readout. I shall spend more time to determine if all the dynamics here make sense as predicted from above, but this does support the notion that it's just math done on these clipped values.Anyone know what the deal is? Is this perhaps even fully spelled out in the manual (which I have not opened, naturally)?I know i'm pretty far in the weeds. But I must understand.

author: tggzzz
author_rank: Super Contributor
timestamp: May 26, 2022, 09:01:32 am
content: Welcome to the forum. It is good to see someone testing their instrument and understanding, andthinking.Without delving into your specific case, I'll note a few general points.All instruments have their limitations, which may or may not be stated in the manual.In the case of scopes, the tolerance on the vertical measurements may be worse that you expect; see the manual. (The timebase will be pretty accurate). Note the first point in my .sigFor Z=X-Y, if the tolerances on X and Y are, say, 2%, then the tolerance on Z can be much much larger.Scopes can behave "badly" if the input is out of range. The front-end amplifiers can saturate and misbehave. As a starting point, if any part of the input is off the screen then beware!With a digitising scope, differencing will be done numerically after the ADCs. With an analogue scope, the differencing is done after the input stages, but before the final Y amplifiers.

author: eugene
author_rank: Frequent Contributor
timestamp: May 26, 2022, 06:16:47 pm
content: If your trace disappear off screen, then adjust the vertical scale (increase volts/division) until it comes back. Then adjust the vertical position to put it where you want on the screen, possibly readjusting the vertical scale to taste. If your MATH trace goes off screen it's because the calculations put it out of range. You need to adjust the vertical scale of the probe channels that result in the calculations.The Auto Setup button is awesome if you can't get something on screen just by twiddling the knobs, but you should strive to get by without it. You should certainly not be afraid to change things after using it. Think of it as a software example that you start with but end up changing to get the program you need.I don't want to be condescending. All I have to go on is what you wrote in your one and only post, but I'm concerned that you might be looking for an expert to answer your questions before looking for documentation (manuals, references, tutorials, blogs, ...) to help you figure out the answer on your own. As a professional software engineer, I'm sure you already understand how important this is to growth. Not just finding an answer to a question, but growing your own skills. I'm hoping I misread your attitude.

author: bdunham7
author_rank: Super Contributor
timestamp: May 26, 2022, 06:45:31 pm
content: A completely floating differential measurement using MATH will be very noisy, thus requiring the mean filter to get some sort of stable reading. And using subtract, I think you amplify common-mode noise. Try putting both ground clips to the common battery terminals. Even real differential probes don't really float like that.Your conclusion about clipping is more or less correct. The MATH features will work properly when the individual channel traces are both on the screen (or would be if they weren't hidden if you use that feature), but there's often some bit of overrange area just off the screen where things might still work. This area varies. If you go outside of that area (clip) the results are not going to be totally predictable.As for 2.72 vs 2.74, scopes are much less accurate vertically than even basic multimeters. At a billion 8-bit samples per second, they do as well as can be expected.Sell the SDS1202X-E on eBay and keep the SDS1104X-E. You'll thank me later.

author: tggzzz
author_rank: Super Contributor
timestamp: May 26, 2022, 06:51:56 pm
content: Quote from: eugene on May 26, 2022, 06:16:47 pmNow do the arithmetic for Z=X-Y, where X, Y are 1% different, and are quantised in 0.5% steps (i.e. 8-bit ADC)

author: eugene
author_rank: Frequent Contributor
timestamp: May 26, 2022, 07:08:45 pm
content: Quote from: tggzzz on May 26, 2022, 06:51:56 pmI don't see what that has to do with getting the math trace on the screen. Worst case, Z is very small with only a few bits of info. That doesn't stop anyone from displaying it on the scope.The value of an analog differential preamp is a topic for a different thread.

author: tggzzz
author_rank: Super Contributor
timestamp: May 26, 2022, 07:16:42 pm
content: Quote from: eugene on May 26, 2022, 07:08:45 pmThat's the point: the displayed X-Y won't look much like the actual X-Y. That's highly relevant for understanding, say, a differential signal.

author: dc443
author_rank: Newbie
timestamp: May 27, 2022, 08:48:56 am
content: Quote from: eugene on May 26, 2022, 06:16:47 pmThanks. Only mildly. I'm definitely doing a slightly unorthodox approach to "save time" but you're probably totally right that what time I say this way I'll pay back over in head-scratching. Noted, and love that you're calling me out on this.Quote from: bdunham7 on May 26, 2022, 06:45:31 pmAwesome point. The value of this thing is not in precision but in the sample rate. I tunnelvisioned that out a bit there.Quote from: bdunham7 on May 26, 2022, 06:45:31 pmI'll thank you now. Yeah it's going to bother me at some point not to have the extra channels. I can tell already...

author: Zero999
author_rank: Super Contributor
timestamp: May 27, 2022, 10:19:26 am
content: Does anyone know what data type is used for the output from the math function?If I were to design it, I'd choose 16-bit integers for multiplication, addition and subtraction and 8.8-bit fixed point for division.

author: mclute0
author_rank: Regular Contributor
timestamp: May 27, 2022, 04:17:27 pm
content: Quote from: Zero999 on May 27, 2022, 10:19:26 amWould that not slow down the sampling significantly due to type conversions and/or casting? Or am I misunderstanding that the math is done post sample and it won't impact sampling speed?I think in from the CS world, C++ pointer math would be more efficient if complicated way depending on the hardware end.

author: Zero999
author_rank: Super Contributor
timestamp: May 27, 2022, 07:36:04 pm
content: Quote from: mclute0 on May 27, 2022, 04:17:27 pmI wouldn't have thought so. Don't forget that type casting hides what the hardware is really doing. On processors with a hardware multiplier, the result contains double the number of bits. If you multiply two 16-bit numbers together on an 32-bit x86 processor, it gives you a 32-bit result regardless of the data type you store the result in. Dividing two 16-bit integers gives two 16-bit integers: the quotient and remainder. Multiplying two 8-bit numbers to give 16-bit result wouldn't require any more than one multiplication instruction, plus what's needed to load the values into the registers. Diving to give a fixed point would require more work though.Anyway, I doubt it's coded in C++, but a hardware description language, so the data type of the result can be anything and as long as they're enough gates with a short enough propagation delay, the entire calculation can be done in one clock cycle.