I am stuck with rather theoretical problem. I am building a small battery managent controller. I need precise values for discharging and charging currents in order to calculate correct battery capacity and charge state.

The problem is that both discharging and charging currents are not pure DC nor sine wave. Currents can fluctuate form zero to maximum in one millisecond. So, calculated average values over a longer period are not correct. Nor are correct RMS values, as there is no sinewave.

When charging or discharging battery voltage fluctuates correspondondingly with currents. So, voltages can not be used as constants.

If calculating A/h value, then it is easy - just use arithmetic average value. But when it comes to measuring power drawn from battery and calculating correct currents and Voltages at the same time I am stuck, as arthmeticaverage voltage and current wonâ€™t give correct power.

Any ideas?