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.)

e-bike current from 0 to full throttle, no load, 500 ms per division

e-bike current no load, stable at full throttle, 5 ms per division

e-bike current no load, stable at full throttle, 1 ms per division

  • \$\begingroup\$ You'd want to low pass filter beneath the nyquist frequency to prevent aliasing. \$\endgroup\$ – Unimportant Jan 7 '19 at 19:41
  • \$\begingroup\$ Sorry, I got the 2 numbers the wrong way around, the sampling should 2x the highest frequency of-course, corrected. \$\endgroup\$ – axk Jan 7 '19 at 19:44
  • \$\begingroup\$ 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 \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jan 7 '19 at 21:20
  • \$\begingroup\$ @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. \$\endgroup\$ – axk Jan 7 '19 at 21:26
  • \$\begingroup\$ 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. \$\endgroup\$ – axk Jan 7 '19 at 21:30

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.

  • \$\begingroup\$ Can you say that in 25 words or less how Sampling rate and filter affects % error by Fs/Fbw ratio \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jan 7 '19 at 19:53
  • \$\begingroup\$ 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. \$\endgroup\$ – TimWescott Jan 7 '19 at 20:36
  • \$\begingroup\$ I was hoping you would used quantitative words or the formula... \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Jan 7 '19 at 20:38
  • \$\begingroup\$ 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. \$\endgroup\$ – TimWescott Jan 7 '19 at 20:43
  • \$\begingroup\$ 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. \$\endgroup\$ – axk Jan 7 '19 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.