how to calculate a amps/hour value

Hi there...
I'm measuring DC current using one acs714 and i believe that part is ok, as my reading match my fluke ampmeter ....
I'm measuring a battery charger and i want to calculate the amps/hour .
Beside this reading the code is analysing other variables so i can't have code that is dedicated to this task..
i'm now using an timerinterrupt to do a 100 reads each second, but as my code is outputting to serial line sometimes the interrupt breaks my output string...
And if my instantaneous amps measures are aligned with the fluke the amp/hour after some hours are not....
Any one can help ..

something like ampshour=(ampshour+readamps)/3600....

But should i need to read the amps once a second ? will be enough ? should be continuous reading ? how ?

Regards

The problem is an integration problem, every measurement has its own error and they add up if you sample often and if you sample less you miss "fast" changes.

So what is the ideal frequency to sample depends on the nature of the beast you want to sample.

  • is it quite constant or can it change fast?

Rule of thumb - you need to sample twice the speed of the highest frequency you want to see.

Decoupling measurements & reporting
You should decouple the frequency of the measurements from the frequency of the serialprints you make, e.g. you can sample 20 times per second and only send the totals once every 2 seconds to your PC/LCD whatever. That gives more accurate readings and less chance of interference. Use of the highest baudrate 115200 minimizes time for serial communication (or go even faster, search for 345600 on the forum). You might also need to take the clock (millis) into account. If you sum several readings you can weight them with the length of the period since last reading. If these are equal weighting is not needed of course.

hopes this helps

And its "ampere-hours", not amps/hour.... ampere-hours (Ah) is a unit of charge, amps/hour is a rate of change. 1Ah = 3600 coulombs.