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: CurrentMonitor/CurrentMonitor.cpp
- Revision:
- 13:fbd9b3f5a07c
- Parent:
- 12:e0adb697fcdb
- Child:
- 14:8d4959210d4b
- Child:
- 25:900579201439
--- a/CurrentMonitor/CurrentMonitor.cpp Tue Oct 21 23:44:15 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-#include "mbed.h"
-#include "CurrentMonitor.h"
-#include "Store_RTC.h"
-
-#define MSEC_HRS 2.77778e-7
-#define DC_DC_ISENSE_OFFSET_V 0.5
-#define DC_DC_ISENSE_INCREMENT 0.133
-
-#define BAT_ISENSE_OFFSET_V 1.65
-#define BAT_ISENSE_INCREMENT 0.5297
-
-CANBuffer *tx_Current_Buffer;
-
-double BATmA_Hr;
-float DCA_msec,BATA_msec;
-float Bat_I_Ratio,DC_I_Ratio;
-
-AnalogIn BatISense(p19);
-AnalogIn DCSense(p20);
-
-RTCStore store;
-
-union converter{
- float data;
- char ch[4];
-} convert;
-
-CurrentMonitor::CurrentMonitor(CANBuffer *can){
- tx_Current_Buffer = can;
-}
-
-void update_current(const void *arg){
- char data[4] = {0};
- while(1){
- float bat_reading = store.read(1);
- convert.data = bat_reading;
-
- data[0] = convert.ch[0];
- data[1] = convert.ch[1];
- data[2] = convert.ch[2];
- data[3] = convert.ch[3];
-
- CANMessage txMessage(TX_CURRENT_ID, data, 4);
- tx_Current_Buffer->txWrite(txMessage);
-
- Thread::wait(100); //10 Hz update
- }
-}
-
-void monitor_current(const void *arg){
- while(1){
- Bat_I_Ratio=BatISense.read();
- BATA_msec=(((Bat_I_Ratio*3.3) - BAT_ISENSE_OFFSET_V)/BAT_ISENSE_INCREMENT);
- BATmA_Hr+=(BATA_msec*MSEC_HRS);
- store.write(BATmA_Hr,0);
-
- DC_I_Ratio=DCSense.read();
- DCA_msec=(((DC_I_Ratio*3.3) - DC_DC_ISENSE_OFFSET_V)/DC_DC_ISENSE_INCREMENT);
- store.write(DCA_msec,1);
-
- Thread::wait(1); //1 Khz coulomb counter
- }
-}
-
-void CurrentMonitor::start_update(){
- Thread monitor_thread(monitor_current);
- Thread update_thread(update_current);
-}
\ No newline at end of file
