Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Revision:
17:c9ce210f6654
Parent:
13:fbd9b3f5a07c
--- a/CoulombCounter/CoulombCounter.cpp	Fri Oct 24 22:38:20 2014 +0000
+++ b/CoulombCounter/CoulombCounter.cpp	Sat Oct 25 03:28:55 2014 +0000
@@ -2,10 +2,10 @@
 
 const float MSEC_HRS = 2.77778e-7;                          // Multiplier to convert milliseconds to hours
 const float BAT_ISENSE_MULTIPLIER = 6.2299;                 // Multiplier to convert float to amps
-const float BAT_ISENSE_OFFSET = 0.5*BAT_ISENSE_MULTIPLIER;  // Offset to convert float to amps
+const float BAT_ISENSE_OFFSET = -0.5*BAT_ISENSE_MULTIPLIER; // Offset to convert float to amps
 const float BAT_ISENSE_LIMS = 3.0;                          // Over-current limit = +/- 3A
 
-CoulombCounter::CoulombCounter(PinName _IsensePin, int mSec, int _rtcGPREG_counter, int _rtcGPREG_capacity) : BatISense(p19) {
+CoulombCounter::CoulombCounter(int _mSec, int _rtcGPREG_counter, int _rtcGPREG_capacity) : BatISense(p19) {
     mSec = _mSec;
     rtcGPREG_counter = _rtcGPREG_counter;
     rtcGPREG_capacity = _rtcGPREG_capacity;
@@ -19,15 +19,16 @@
     sampler.attach_us(this, &CoulombCounter::sample, mSec*1000);
 }
 
-void CouloumbCounter::sample() {
+void CoulombCounter::sample() {
     // Take the reading
     currentSample = BatISense.read()*BAT_ISENSE_MULTIPLIER+BAT_ISENSE_OFFSET;
     
     // Signal error on over current
-    if (currentSample < -BAT_ISENSE_LIMS || currentSample > BAT_ISENSE_LIMS) {
+    if (abs(currentSample) > BAT_ISENSE_LIMS) {
         overCurrent = true;
     } else overCurrent = false;
     
     // Integrate
-    store.write(ampHours()+currentSample*mSec*MSEC_HRS, rtcGPREG_counter);
+    float f = ampHours()+currentSample*mSec*MSEC_HRS;
+    store.write(f, rtcGPREG_counter);
 }
\ No newline at end of file