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 BufferedSerial ConfigFile
ROBOFRIEN_BAT.cpp
00001 #include "ROBOFRIEN_BAT.h" 00002 00003 AnalogIn BAT_ANALOG(A0); 00004 00005 #define BAT_1CELL_MIN 3.8 00006 #define BAT_1CELL_MAX 4.1 00007 #define DC_DC_REFERENCE 3.3 00008 #define REGISTER_RATIO 11 00009 #define BAT_LPF 0.9 00010 00011 void ROBOFRIEN_BAT::Init(int cell_info){ 00012 BAT_MIN = BAT_1CELL_MIN * cell_info; 00013 BAT_MAX = BAT_1CELL_MAX * cell_info; 00014 } 00015 00016 float ROBOFRIEN_BAT::update(){ 00017 float BAT_PERCENT = 0; 00018 ORIGIN_DATA = BAT_ANALOG; 00019 BAT_PERCENT = ((BAT_ANALOG*DC_DC_REFERENCE*REGISTER_RATIO)-BAT_MIN)/(BAT_MAX-BAT_MIN)*100; 00020 LPF_BAT_DATA = LPF_BAT_DATA * BAT_LPF + BAT_PERCENT * (1-BAT_LPF); 00021 return BAT_PERCENT; 00022 }
Generated on Sat Jul 16 2022 14:19:21 by
 1.7.2
 1.7.2