# Low pass filtering effect on accuracy of power measurement

I'm planning on measuring consumed power (for an e-bike) by sampling current and voltage with an ADC and digitally approximating the power based on the obtained values.

I need to pick a sampling rate for the ADC to measure the current.

Based on on the current waveform that I've measure with an oscilloscope I think 1 Msps should be enough but maybe I can get away with a lower sampling rate low pass filtering the current sense voltage before the ADC.

How will the low pass filtering down to 50 kHz and sampling at 100 kHz affect the measurement accuracy of the energy consumed over time if my target is accurate within +/-5%? (I'm not worried about instantaneous power.)

(The below was measured between the battery and controller across a wire shunt amplified with an op-amp from 0 to full throttle with no load. I am not sure if the measurement setup is correct.)

• You'd want to low pass filter beneath the nyquist frequency to prevent aliasing. – Unimportant Jan 7 at 19:41
• Sorry, I got the 2 numbers the wrong way around, the sampling should 2x the highest frequency of-course, corrected. – axk Jan 7 at 19:44
• What errors can you tolerate due to battery loss in voltage when only current is measured? Can you give a spec for desired Power Accuracy and max time interval needed? These answers define the optimal solution – Sunnyskyguy EE75 Jan 7 at 21:20
• @sunnyskyguy-ee75, battery voltage loss is significant (13s Li-Ion battery, from 54.6V to 39V) so I'll need to measure the voltage as well, but it won't change anywhere as fast as the current, so I'm not worried about that. The time interval would be several hours (e.g. 2 hours) and I would consider 5% a good accuracy. – axk Jan 7 at 21:26
• I've not actually measured the voltage with a scope but I assume the battery being a low resistance source the fluctuations in current shouldn't affect the voltage significantly, but I can sample the voltage at the same rate as the current with a second ADC if needed. – axk Jan 7 at 21:30

## 1 Answer

If I'm reading your scope correctly the fundamental frequency of that hash is about 2kHz, and it doesn't have a lot of sharp edges. That suggests that you've got frequency content up to maybe 10kHz at most. Depending on how aggressively you want to filter, you could probably get away with less than 100kHz, but 100kHz (and an appropriate anti-aliasing filter) would do it.

To get the most accurate power reading you want to sample voltage and current simultaneously, multiply, and average.

This article is really directed more toward debunking common misconceptions about sampling, but should have some guidance about how to select an anti-aliasing filter to go with that signal and a 100kHz sampling rate.

• Can you say that in 25 words or less how Sampling rate and filter affects % error by Fs/Fbw ratio – Sunnyskyguy EE75 Jan 7 at 19:53
• The more you filter, the more you get rid of unwanted noise, unwanted aliasing products, and (possibly) wanted signals. It depends on the input signal and what you're doing with it. There's a reason this kind of stuff tends to get done by the senior people. – TimWescott Jan 7 at 20:36
• I was hoping you would used quantitative words or the formula... – Sunnyskyguy EE75 Jan 7 at 20:38
• Not in 25 words or less, and certainly not for a mostly-undefined input signal and a mostly-undefined usage. The whole issue of sampling and anti-aliasing filtering is treated in depth in a lot of places -- usually in book-length form, or articles whose abstracts significantly exceed 25 words. – TimWescott Jan 7 at 20:43
• For sampling a 1 KHz sinusoid 2 Ksps is enough but then how do I reconstruct the integral, not straightforward. Sampling at 20 Ksps provided the signal doesn't contain anything significant above 1 KHz I could get away with simple trapezoid area approximations for the integral and get a decent accuracy. So maybe it is easier with oversampling in this respect if I sample at 1MHz, not sure how difficult it would be to reconstruct the integral from 2f sample rate samples. – axk Jan 7 at 20:55