Is there an Analog to digital converter channel available on your microcontroller? You could just stick the current carrying bar through something like this:
http://search.digikey.com/scripts/Dk...+300-s&x=0&y=0
(they have them with any current range you want)
The interface to the sensor is OUT, +5V, and GROUND. Zero current through the sensor means OUT is 2.5v. 300 amps gives an output of 2.5 + 0.625v. -300 amps gives an output of 2.5 - 0.625v.
Just feed the output into the available A/D channel, and read it in fixed intervals. Say 1kHz. Then when you read the current, you have used that amount of currrent * 0.001 seconds. Add it up in an accumulator variable. The variable will start back at zero when the power shuts off unless you save it though.
So, let's say you read a 10 bit value for the A/D result. 512 would mean zero current. 512 + 128 would mean 300 amps. Just save your total in a long INT.
Every 0.001 seconds do:
ampHrsRaw = (A_D_Result - 512) + ampHrsRaw
The units of ampHrsRaw are "A/D tick * millisecond". So, you have to wait until it gets to what corresponds to 32 amp*hours. 32 amp*hours converted to "A/D tick * millisecond" would be ...
32amp*hr*3600sec/hr*1000ms/sec*128ADTicks/300amp. Now once the units cancel, you get...
49,152,000. So...
if (ampHrsRaw >= 49152000)
OH NO!!! 32 AMP*HRS HAVE BEEN USED! DO SOMETHING!!!