'Program for High Side current measure, no voltage. 'Display current, and Amp-Hours ' 0-4 Amps, 0-65 AH pause 3000 'allow serial meter to initialize Main: For b6 = 0 to 4 'count for readout after 5 samples readadc10 4, w0 'get current reading if w0<10 then 'allow for zero drift w0=0 'calibrate so w0 = 200 at 1amp current endif w0=w0/2 'scale to 100 = 100uA-H if sampled each 0.36Secs '10,000 samples/Hour w1=w1+w0 'accumulate uA-H inc w4 'count readings to be used for Cal. if w1=>1000 then 'accumulate to 1000 uA-H= 1mA-H then w1=w1-1000 'save excess to accumulate uA-H inc w2 'accumulate mA-H endif serout 0, T2400, ("?y1?x00") 'cursor start of 2nd line serout 0, T2400, (#w4) 'display count pause 280 'time interval, adjust for 10K readings/Hr '1000 counts in 6 min. next b6 w5 =w0 * 10 'current reading scaled to mA serout 0, T2400, ("?f") 'cls cursor home serout 0, T2400, (#w5) 'mA reading serout 0, T2400, ("mA?y0?x08") 'mA, set cursor for A-H to follow if W2=0 then 'accumalating first 1000uA-H. serout 0, T2400, (#w1) 'uA-H readings to meter serout 0, T2400, ("uAH") 'units endif if W2=>1 then 'accumulating over 1 mA-H serout 0, T2400, (#w2) 'mA-H readings to meter serout 0, T2400, ("mAH") 'units endif goto Main 'repeat