Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Revision:
30:91af74a299e1
Child:
34:18bcf276d3bf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Libs/CoulombCounter/CoulombCounter.h	Thu Nov 13 10:53:10 2014 +0000
@@ -0,0 +1,45 @@
+#ifndef _FILE_CURRENTMONITOR_H
+#define _FILE_CURRENTMONITOR_H
+
+#include "mbed.h"
+#include "CANBuffer.h"
+#include "RTCStore.h"
+
+const float defaultAh = 1.5;        // Default amphours of battery, in case RTC read is bad/empty
+const float defaultSOC = 0.5;
+const int CC_FILTER_TAPS = 10;
+
+class CoulombCounter {
+public:
+
+    // Configures for a certain pin, millisecond sample period, and which GPREG in RTC to use to store the ampHours
+    CoulombCounter(PinName _pin, int _mSec);
+    
+    // Allow zeroing the SOC when the battery is fully charged/dead, SOC in % from 0 to 1
+    void resetToSOC(float SOC);
+   
+   // Allow zeroing the SOC (via zeroing the Ah) when the battery is fully charged/dead           
+    void resetToAh(float Ah);
+    
+    // Allow change of capacity spec (changes SOC)
+    void changeCapacity(float capAh);
+    
+    bool overCurrentDetected();                                 // Sensor above range
+    float current();                                            // Last current reading in Amps
+    float ampHours();
+    float capacity();
+    float SOC();
+    void sample();
+
+private:
+    //Ticker sampler;         // Used to capture next sample and coulomb count
+    RTCStore store;
+    volatile bool overCurrent;
+    int mSec;
+    volatile float currentSample;
+    AnalogIn BatISense;     // Analog input pin
+    
+    volatile float buffArr[CC_FILTER_TAPS];
+    volatile unsigned int tracker;
+};
+#endif
\ No newline at end of file