Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Diff: CoulombCounter/CoulombCounter.cpp
- Revision:
- 30:91af74a299e1
- Parent:
- 24:f58a3c0071c3
- Child:
- 31:7eaa5e881b56
diff -r f58a3c0071c3 -r 91af74a299e1 CoulombCounter/CoulombCounter.cpp
--- a/CoulombCounter/CoulombCounter.cpp Fri Nov 07 21:26:46 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-#include "CoulombCounter.h"
-
-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_LIMS = 3.0; // Over-current limit = +/- 3A
-
-CoulombCounter::CoulombCounter(int _mSec, int _rtcGPREG_counter, int _rtcGPREG_capacity) : BatISense(p19) {
- mSec = _mSec;
- rtcGPREG_counter = _rtcGPREG_counter;
- rtcGPREG_capacity = _rtcGPREG_capacity;
-
- // Take the initial reading
- currentSample = BatISense*BAT_ISENSE_MULTIPLIER+BAT_ISENSE_OFFSET;
- if (currentSample < -BAT_ISENSE_LIMS || currentSample > BAT_ISENSE_LIMS) overCurrent = true;
- else overCurrent = false;
-
- // Start counting
- sampler.attach_us(this, &CoulombCounter::sample, mSec*1000);
-}
-
-void CoulombCounter::sample() {
- // Take the reading
- currentSample = BatISense.read()*BAT_ISENSE_MULTIPLIER+BAT_ISENSE_OFFSET;
-
- // Signal error on over current
- if (abs(currentSample) > BAT_ISENSE_LIMS) {
- overCurrent = true;
- } else overCurrent = false;
-
- // Integrate
- float f = ampHours()+currentSample*mSec*MSEC_HRS;
- store.write(f, rtcGPREG_counter);
-}
\ No newline at end of file
