I want to measure the average current through a small DC motor switched with PWM. Current is measured via a hall-sensor with voltage output.
I want a stabilized value each ms for a current regulator, meaning that the filter cant have a too big delay.
First I need an analog filter to get rid of noise and such higher than the Nyqvist frequency and I'm thinking of a simple RC filter for simplicity and flat frequency response. My idea here was to choose the RC time constant to be 1ms/5, so that a step change each ms is going through completely after around approx 1 ms. Is this a good design strategy?
Then I guess digital filtering is the way to go? Moving average? Is there some sort of digital filter that has steep filtering characteristics, yet a fast step response?
The program is to be implemented in C on an embedded system.
Personal opinions and tips about publications regarding this are very appreciated.
- - - Updated - - -
Or should I perhaps trig an interrupt at the beginning of each PWM cycle and measure the current on the battery side during the on time, and then average for each period?
Benefits I see would be elimination of high frequency components in the PWM step functions that could cause aliasing and therefore perhaps eliminate some need for analog signal pre-processing. This would also give a more true average on each PWM cycle, instead of an average thats is slowly converging over multiple periods.