Files
TX/source/battery.h

96 lines
2.0 KiB
C

/*
* battery.h
*
* Created on: Mar 1, 2023
* Author: Keith.Lloyd
*/
#ifndef BATTERY_H_
#define BATTERY_H_
#define ALKALINE_VAL 300
#define LITHIUM_MID_POINT 1.0 // mid point tap = 0V for lithium
//#define BATTERY_NINETY 15.2
//#define BATTERY_FULL 16.4
//#define BATTERY_3QUARTERS 15.0
//#define BATTERY_FIFTY 14.4
//#define BATTERY_1QUARTER 14.28
//#define BATTERY_EMPTY 12.3
#define L_BATTERY_FULL 16.4 // Cap fitted Lithium
#define L_BATTERY_NINETY 16.0
#define L_BATTERY_3QUARTERS 15.6
#define L_BATTERY_FIFTY 14.8
#define L_BATTERY_1QUARTER 14.0
#define L_BATTERY_1EIGTH 13.6
#define L_BATTERY_EMPTY 12.3
#define NCL_BATTERY_FULL 14.94 // No Cap Fitted Lithium
#define NCL_BATTERY_NINETY 14.62
#define NCL_BATTERY_3QUARTERS 14.3
#define NCL_BATTERY_FIFTY 13.68
#define NCL_BATTERY_1QUARTER 13.05
#define NCL_BATTERY_1EIGTH 12.72
#define NCL_BATTERY_EMPTY 11.72
#define A_BATTERY_FULL 12.0
#define A_BATTERY_NINETY 11.85
#define A_BATTERY_3QUARTERS 10.72
#define A_BATTERY_FIFTY 10.24
#define A_BATTERY_1QUARTER 9.76
#define A_BATTERY_1EIGTH 9.20
#define A_BATTERY_EMPTY 9.15
#define NCA_BATTERY_FULL 11.61
#define NCA_BATTERY_NINETY 11.17
#define NCA_BATTERY_3QUARTERS 10.95
#define NCA_BATTERY_FIFTY 10.42
#define NCA_BATTERY_1QUARTER 9.86
#define NCA_BATTERY_1EIGTH 9.44
#define NCA_BATTERY_EMPTY 8.98
#define LITHIUM_CUT_OFF 11.69 // No Cap fitted
#define ALKALINE_CUT_OFF 9.2 // No Cap fitted
#define CF_LITHIUM_CUT_OFF 12.28 //Cap fitted
#define CF_ALKALINE_CUT_OFF 9.0 // Cap fitted
#define DEMAND1 0.1 // current demand
#define DEMAND2 0.2
#define DEMAND3 0.3
#define DEMAND4 0.4
#define DEMAND5 0.5
#define DEMAND6 0.6
typedef enum {
ALKALINE,
LITHIUM,
BAT_ERROR,
EXT_DC
}BAT_STACK_t;
void Check_Bat_Id(void);
void Chk_Bat_Level(void);
void Test_Bat_Level(float32_t Bat_Cut_Off);
float32_t Adjust_Battery_For_Load();
bool Compare_With_Limit(float32_t V1 ,float32_t V2,float32_t limit);
/*typedef enum {
I_OUT1,
V_OUT1,
N_USED,
PSU_MON,
VBAT_MON,
ID1,
ID2,
V_CHK,
TEMP_SENSOR,
VBUS,
BAT_ID
}ADC_STACK_t;
*/
#endif /* BATTERY_H_ */