Author Topic: EEVblog #662- How & Why to use Integration on an Oscilloscope  (Read 34711 times)

0 Members and 1 Guest are viewing this topic.

Offline EEVblogTopic starter

  • Administrator
  • *****
  • Posts: 38563
  • Country: au
    • EEVblog
EEVblog #662- How & Why to use Integration on an Oscilloscope
« on: September 13, 2014, 10:44:33 pm »
In this tutorial Dave demonstrates the seldom used and often little understood mathematical integration function available on your modern digital oscilloscope. And demonstrates a practical example use for it in accurately measuring the total power consumption of a microcontroller that sleeps and then wakes up and does some processing before shutting down again. By getting the total area under the current curve.

 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2320
  • Country: au
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #1 on: September 13, 2014, 11:27:48 pm »
About the inaccurate measurement of sleep current by the integral function -- Putting on my pedantic hat; it might be more accurate to blame that error on offset, rather than noise. I only say that because noise is not a DC thing, some of those samples will be high, some will be low, it all cancels out -- that's one of the wonderful things about integration, it pulls the interesting low-frequency stuff out of the noise. What's left over, and what survives integration, is offset error. It would be interesting to short the input to the uCurrent to see what a true zero-current reading looks like, and to see if any real signal survived the quantization process (it wouldn't be too bad to use the zero-current integral as an offset null).?

[ Double-posted to the YouTube comments as well because I reflexively commented on YouTube for some daft reason. EEVBlog forum is where it's at! ]
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #2 on: September 13, 2014, 11:43:19 pm »
Nice video, I take back that you are only doing mailbag and teardowns :)

Question, is the Area measurement the same thing?
At least on my Rigol it does seem to match:

Both the integral and the area shows 10.5mVs


And in here they both agree on 4.20mVs (well, close enough)


Edit: updated the images so that it shows VMax of the Math channel, but it doesn't show the scale in mVs just mV.
Also Dave covered this in the video, I guess I wasn't paying attention at that moment.
« Last Edit: September 14, 2014, 12:45:54 am by miguelvp »
 

Offline Legit-Design

  • Frequent Contributor
  • **
  • Posts: 562
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #3 on: September 13, 2014, 11:49:07 pm »
Sound is wrong on that video... also video looks yellowish, my guess that is the Sony camera.
 

Offline EEVblogTopic starter

  • Administrator
  • *****
  • Posts: 38563
  • Country: au
    • EEVblog
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #4 on: September 14, 2014, 12:01:56 am »
Sound is wrong on that video... also video looks yellowish, my guess that is the Sony camera.

Canon HF G30.
I used the mid range boost function in the camera, designed for speech. Was an experiment.
Sounds good to me.
Re. the yellow, that's an oops, forgot to turn back on manual white balance after the trade show. That always happens.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #5 on: September 14, 2014, 12:40:16 am »
Nevermind about the area measurement, you did cover it, I guess when I watch it I was distracted when you mentioned it :)

Edit: plus it's nice to be able to visualize it instead of just looking at a number.
« Last Edit: September 14, 2014, 01:31:46 am by miguelvp »
 

Offline Prime73

  • Regular Contributor
  • *
  • Posts: 174
  • Country: ca
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #6 on: September 14, 2014, 01:00:07 am »
Sound is wrong on that video... also video looks yellowish, my guess that is the Sony camera.
sounds good to me - no issues.
 

Offline cosrologist

  • Newbie
  • Posts: 4
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #7 on: September 14, 2014, 01:06:52 am »
Dave,

You should be able to configure the CRO probe input to convert the voltage to a current, including using a conversion factor such as 1mV = 100uA, (which is the setting on the uCurrent) so that the display shows Amperes (or mA) and the integral is mA Seconds.   which is easier to read/do calcs with.

Cheers
Kym
 

Offline plesa

  • Frequent Contributor
  • **
  • Posts: 965
  • Country: se
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #8 on: September 14, 2014, 01:08:39 am »
You can also adjust the units in probe menu from volts to amps and change the sensitivity according to transimpedance of your uCurrent.
But there are some limitations max 10V/A minimum 1mV/A. So it is useless for measurement with uCurrent.
« Last Edit: September 14, 2014, 01:13:07 am by plesa »
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2320
  • Country: au
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #9 on: September 14, 2014, 01:28:36 am »
At 9:37, you say the average current is 12.1 uA according to the scope, but you have a 2 second period on your integral -- so 12.1 mVs / 2 s works out to 6.05 mV average --> 6.05 uA, much closer to reality! But since a little bit of offset error could swamp the reading, I agree with your overall conclusion that the number isn't reliable.
« Last Edit: September 14, 2014, 02:23:17 am by rs20 »
 

Offline dentaku

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #10 on: September 14, 2014, 02:28:46 am »
I've always known how integration is useful for me when modifying audio signals but this is the first time I've had a good explanation of what exactly integration is.
I see that if the yellow curve was to never settle back all the way down the purple one would just keep going up.

I can easily visualize why integrating a square wave gives you a triangle and integrating a triangle gives you a sine.

 

Offline Wim_L

  • Regular Contributor
  • *
  • Posts: 212
  • Country: be
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #11 on: September 14, 2014, 03:47:34 am »
About the inaccurate measurement of sleep current by the integral function -- Putting on my pedantic hat; it might be more accurate to blame that error on offset, rather than noise. I only say that because noise is not a DC thing, some of those samples will be high, some will be low, it all cancels out -- that's one of the wonderful things about integration, it pulls the interesting low-frequency stuff out of the noise. What's left over, and what survives integration, is offset error. It would be interesting to short the input to the uCurrent to see what a true zero-current reading looks like, and to see if any real signal survived the quantization process (it wouldn't be too bad to use the zero-current integral as an offset null).?

[ Double-posted to the YouTube comments as well because I reflexively commented on YouTube for some daft reason. EEVBlog forum is where it's at! ]

Indeed, noise doesn't matter, it's the offset between the average value and zero that will determine the deviation of the integral. That's also why integrals give nice curves even on noisy data: they're inherently averaging things together.

The opposite is true for differentiation, which amplifies noise. A typical high sample rate noise oscilloscope signal is likely to need a lot of averaging/low pass filtering, or the differentiated signal will be nothing but noise.
 

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1353
  • Country: si
  • I like to measure things.
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #12 on: September 14, 2014, 04:36:47 am »
I am also going to put on my pedantic hat (implying that I ever take it off) and say that the measurement was incorrect.
You measured the charge of that current pulse to be 700nC over the period of 5ms.
Then you connected the multimeter to measure the sleep current. The numbers were jumping from 4.16µA to about 13µA. You then turned on averaging and ruined your whole measurement. The multimeter was averaging the sleep current as well as the spikes. The actual sleep current was about 4.16-4.17µA (these were the lowest values the multimeter was settling to).

So, your actual current consumption would be closer to:
(4.16µA*(2s-5ms)+700nC)/2s = 4.51µA

On a side note, please watch out for correct terminology. You shouldn't confuse energy and charge.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2320
  • Country: au
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #13 on: September 14, 2014, 04:44:17 am »
I can easily visualize why integrating a square wave gives you a triangle and integrating a triangle gives you a sine.

OK, I'm just going to declare today rs20-has-pedantic-hat-day: Triangle integrates to something vaguely sine-ish, but not a true sine wave -- only a (co)sine wave integrates to give a sine wave. However, it's true that as you keep on integrating over and over again, you get closer and closer to a sine wave as you attenuate those harmonics more and more: square --> triangle --> vaguely sine-ish string of parabolas --> even more sine-ish string of cubics --> (infinity* steps later) --> sine --> sine --> sine

* Where infinity is defined as anything greater than, oh, I dunno, seven.

Indeed, noise doesn't matter, it's the offset between the average value and zero that will determine the deviation of the integral. That's also why integrals give nice curves even on noisy data: they're inherently averaging things together.

The opposite is true for differentiation, which amplifies noise. A typical high sample rate noise oscilloscope signal is likely to need a lot of averaging/low pass filtering, or the differentiated signal will be nothing but noise.

It does leave me wondering why scopes don't have more versatile low-pass filtering capability. For instance, when I'm using my uCurrent, I want my scope to have a bandwidth limit of 0.4 to 0.5 MHz, because I know anything above that isn't a valid signal from the uCurrent, therefore pure noise. Low-pass filtering also gives you more effective bits. But no, all I have are two options: 20 MHz and 100 MHz.  It can be done in software; loosely speaking it's averaging contiguous samples in each captured waveform (instead of averaging feature, which averages separate waveforms)... a dialable software bandwidth limit feature would be higher up my list than many other impressive but more contrived features offered by modern scopes.

 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6289
  • Country: 00
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #14 on: September 14, 2014, 04:55:31 am »
What is the nature of the noise near the horizontal line?  If it's random ac with zero DC average and if the integrator is signed then it should contribute zero charge to the integration.

Several months ago I faced a similar need, to measure the charge of single cell mobile devices. The current consumption fluctuates a lot over time, nothing clean as periodic like in this video. I ended up building a small OSH integrator based on LTC2943. It does continuous integration by a linear Coulomb counter (50mv burden voltage max scale, you provide the shunt) that triggers a digital charge counter. It was designed to have very low integration offset works great also with long term integrations (hours and days).  The integrator has a 1.3" OLED display and shows metrics such as average current (charge/time), number of software awakes (current is above a certain threshold), and a real time graph and also allows to log the data on a computer. So far I build 30 of them (3~5 at a time) giving to colleagues that ask.



One commercial charge integrator I am aware of is Monsoon Power Monitor https://www.msoon.com/LabEquipment/PowerMonitor/  it is fully controlled via a USB port and contains both a programable power supply and current integrator.
 

Offline Dongulus

  • Regular Contributor
  • *
  • Posts: 232
  • Country: us
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #15 on: September 14, 2014, 06:06:15 am »
I've seen the famous quantization noise SNR equation for an ideal ADC. The equation assumes that the probability of the error in an ADC sample is equally distributed between +/- 1/2 LSB. I know that SAR ADCs the distribution for the quantization noise will be from 0 to -1 LSB because the logic in a SAR ADC will always produce a result that is less than what the analog input actually is. This would produce quantiztion noise with a constant offset of -1/2 LSB.

Does anyone know if the quantization noise distribution veers from the ideal for other types of ADCs?
Also, what kind of ADCs are typically found in oscilloscopes?
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2320
  • Country: au
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #16 on: September 14, 2014, 07:22:15 am »
I've seen the famous quantization noise SNR equation for an ideal ADC. The equation assumes that the probability of the error in an ADC sample is equally distributed between +/- 1/2 LSB. I know that SAR ADCs the distribution for the quantization noise will be from 0 to -1 LSB because the logic in a SAR ADC will always produce a result that is less than what the analog input actually is. This would produce quantiztion noise with a constant offset of -1/2 LSB.

Does anyone know if the quantization noise distribution veers from the ideal for other types of ADCs?
Also, what kind of ADCs are typically found in oscilloscopes?

A constant offset of -1/2 LSB with respect to what? None of this is relevant if the scope has a calibration procedure.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22368
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #17 on: September 14, 2014, 07:39:40 am »
OK, I'm just going to declare today rs20-has-pedantic-hat-day: Triangle integrates to something vaguely sine-ish, but not a true sine wave -- only a (co)sine wave integrates to give a sine wave. However, it's true that as you keep on integrating over and over again, you get closer and closer to a sine wave as you attenuate those harmonics more and more: square --> triangle --> vaguely sine-ish string of parabolas --> even more sine-ish string of cubics --> (infinity* steps later) --> sine --> sine --> sine

* Where infinity is defined as anything greater than, oh, I dunno, seven.

This resonates with the Fourier transform, and with the Taylor series expansion of sin(x).  (Screw pedantism, he's bringing out the calculus?  Head for the hills!!)

The expansion is all even (cos) or odd (sin) powers of x from 1 or 2 to n, each with a leading coefficient of 1/n!.  This is a true representation of the function, but only as long as n --> infty.  There's no reason it has to work for small n, though as it turns out, sin/cos are suitable functions which approximate reasonably well.  So, the more powers you have, the more accurate the approximation.

Now, one nice thing about a Taylor series is, it's trivial to integrate -- it's just a polynomial, so you increment each exponent by one, and divide the constant.  The power goes up, and the approximation gets better (assuming you bring in new constant terms every time you hit +/- cos) because the series 'grows'.

The Fourier transform of a square wave (and its subsequent integrals) follows a similar pattern: the harmonics goes as 1/n^(p+1), where p is the number of integrations.  A square wave has harmonics that go as 1/n, so the 3rd has an amplitude of 1/3, and so on.  Triangle goes as 1/n^2, so the harmonics drop off more quickly.  Each time you integrate, it goes lower and lower, until after infinite passes, the harmonics completely disappear.

When it comes to circuits, if you're talking single frequency (not the variable output from a function generator), the harmonics can be attenuated with a filter.  An integrator is simply a -20dB/decade everywhere, so it's as good as a lowpass filter if the unity gain frequency is appropriately selected.  Practically speaking, the lowest harmonics are the hardest to treat, and you can get better performance with a filter that incorporates zeroes (like an elliptical) at strategic frequencies.

Indeed, noise doesn't matter, it's the offset between the average value and zero that will determine the deviation of the integral. That's also why integrals give nice curves even on noisy data: they're inherently averaging things together.

Arguably not: low frequency noise tends to go as 1/f, which looks like Brownian noise in the integral, and depending on your point of view and scale, manifests as low frequency rumble, uncertain offset, etc.

There's also the matter of quantization: on average, it's just noise -- but for a given situation, it may not be incoherent.  That is, if your 8 bit ADC is always reading the same numbers for each point on the waveform, averaging won't get you anything, because the noise is correlated with, and now inseparable from, the signal.  It actually pays to have a slightly noisy measurement (1-2 LSBs, say) when you're doing averaging (or oversampling).  BTW, note that averaging is the same as equivalent time sampling (with averaging), because it doesn't matter whether the acquisition was obtained in real time (bursts of a screen at a time) or here-and-there (delayed or random trigger per point).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #18 on: September 14, 2014, 07:42:56 am »
I can easily visualize why integrating a square wave gives you a triangle and integrating a triangle gives you a sine.

OK, I'm just going to declare today rs20-has-pedantic-hat-day: Triangle integrates to something vaguely sine-ish, but not a true sine wave -- only a (co)sine wave integrates to give a sine wave. However, it's true that as you keep on integrating over and over again, you get closer and closer to a sine wave as you attenuate those harmonics more and more: square --> triangle --> vaguely sine-ish string of parabolas --> even more sine-ish string of cubics --> (infinity* steps later) --> sine --> sine --> sine

* Where infinity is defined as anything greater than, oh, I dunno, seven.

Since I'm using the 1KHz 3V test signal I did try to make a triangle wave with Intg(CH1)-Intg(3-CH1) that gives me a triangle wave.



But if I integrate that I do not get a sine wave.

Further I did try Intg(Intg(Intg(CH1)-Intg(3-CH1))) and I get 2 quadrants of a sine wave on 16 square wave cycles then it does a parabola down to minus infinity.

Edit: here is what it shows:

I'm just wondering what should I input in the math function to actually get a sine wave from a square wave (not using the sine cosine and tangent operators of course).

Edit: If I differentiate the result with  Diff(Intg(CH1)-Intg(3-CH1)) I do get the square wave back as expected.
« Last Edit: September 14, 2014, 07:53:48 am by miguelvp »
 

Offline bktemp

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: de
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #19 on: September 14, 2014, 07:47:40 am »
Sorry but I don't get it. What is the advantage of using a scope to measure the avarage current consumption? Would it not be much easier and more accurate to simply add a low pass filter after the uCurrent and measure the avaraged voltage with a DMM?
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #20 on: September 14, 2014, 08:25:53 am »
I used the mid range boost function in the camera, designed for speech. Was an experiment.
Sounds good to me.

There was a kind of "bump" in the sound quality in the middle of the video.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1353
  • Country: si
  • I like to measure things.
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #21 on: September 14, 2014, 10:47:06 am »
Sorry but I don't get it. What is the advantage of using a scope to measure the avarage current consumption? Would it not be much easier and more accurate to simply add a low pass filter after the uCurrent and measure the avaraged voltage with a DMM?
You would need a really low frequency filter, therefore huge inductance, resistance and capacitance. Capacitor leakage would kill the accuracy.

It might not be a bad idea to use a low pass filter in combination with a fast multimeter. The filter would stretch the pulse enough for a meter like 34401A to sample it at 1000/s or so. Slap the acquired data into Matlab and presto.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22368
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #22 on: September 14, 2014, 11:50:50 am »
Sorry but I don't get it. What is the advantage of using a scope to measure the avarage current consumption? Would it not be much easier and more accurate to simply add a low pass filter after the uCurrent and measure the avaraged voltage with a DMM?
You would need a really low frequency filter, therefore huge inductance, resistance and capacitance. Capacitor leakage would kill the accuracy.

It might not be a bad idea to use a low pass filter in combination with a fast multimeter. The filter would stretch the pulse enough for a meter like 34401A to sample it at 1000/s or so. Slap the acquired data into Matlab and presto.

If you're only looking for DC, any standard integrating DMM will do (i.e., not the $3 cheapshit yellow box kind).

Even if your meter responds poorly to AC (sample-and-hold type), a moderate R and sufficiently large C (larger than might be used for line frequency filtering, but no need for sheer farads) will get the cutoff frequency down in the Hz where absolutely any measurement device will do the job.

If you want to know the peaks and pulse widths, you have little choice but to graph or sample it.  Measuring the peaks quantitatively is best done with an integral as shown here -- the widths, heights and shapes may be deformed, but the integral over that range must be consistent.  This is used in many physical analyses, such as MS, NMR, XRD, nuclear spectroscopy and so on.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline Tek_TDS220

  • Regular Contributor
  • *
  • Posts: 74
  • Country: 00
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #23 on: September 14, 2014, 12:21:02 pm »
Strictly speaking, it doesn't make sense to say 'total power consumption'.  It should be 'total energy consumption'.  Proper energy units would be uWs.  Similarly, when you write 'total current' you probably mean 'integrated current'.
 

Offline dentaku

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Re: EEVblog #662- How & Why to use Integration on an Oscilloscope
« Reply #24 on: September 14, 2014, 02:55:54 pm »
I can easily visualize why integrating a square wave gives you a triangle and integrating a triangle gives you a sine.

OK, I'm just going to declare today rs20-has-pedantic-hat-day: Triangle integrates to something vaguely sine-ish, but not a true sine wave -- only a (co)sine wave integrates to give a sine wave. However, it's true that as you keep on integrating over and over again, you get closer and closer to a sine wave as you attenuate those harmonics more and more: square --> triangle --> vaguely sine-ish string of parabolas --> even more sine-ish string of cubics --> (infinity* steps later) --> sine --> sine --> sine

* Where infinity is defined as anything greater than, oh, I dunno, seven.


That would be a funny looking hat :)

I guess you're right but I really don't know anything about this stuff anyway. It's just that this video finally helped me understand what is happening when I build an integrator with an opamp to modify different waveforms.
When making analog synthesizers, nothing's ever perfect and I guess that's why the analog synth geeks love them so much.

I did a little experiment in Excel so I could graph what I was imagining and it works.
I broke up a triangle into little squares under the curve then added them all up and drew a graph.

« Last Edit: September 14, 2014, 03:53:23 pm by dentaku »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf