a long time ago in a PC. I basically took an amp reading every second and added 1/3600th of the reading to a register. Basically integrating the amps to get amp hours. Seems like you could do something similar, with different math order, in the PIC.