|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
70 #ifndef BATTERY_MONITOR_H
71 #define BATTERY_MONITOR_H
79 #if BATTERY_MONITOR_REV4
81 #define BATTERY_MONITOR_BIT_RES 10 // define bit resolution: 12 for AD7998 (rev4)
84 #define BATTERY_MONITOR_BIT_RES 12 // define bit resolution: 10 for AD7997 (rev5)
88 #define BATTERY_MONITOR_VREF 5000 //mV
91 #define BATTERY_MONITOR_VREF_MULT BATTERY_MONITOR_VREF/(1<<BATTERY_MONITOR_BIT_RES)
94 #define BATTERY_CELLS_NB 6
97 #define TEMP_SENSORS_NB 6
103 #if BATTERY_MONITOR_REV4
105 #define GAIN_CELL_1 1.001
106 #define GAIN_CELL_2 2.011
107 #define GAIN_CELL_3 3.027
108 #define GAIN_CELL_4 4.063
109 #define GAIN_CELL_5 4.217
110 #define GAIN_CELL_6 4.973
113 #define GAIN_CELL_1 1.0
114 #define GAIN_CELL_2 2.0
115 #define GAIN_CELL_3 3.0
116 #define GAIN_CELL_4 4.03
117 #define GAIN_CELL_5 5.0
118 #define GAIN_CELL_6 6.0
134 #define BATTERY_MONITOR_BUS_CURRENT_CHANNEL 2
135 #define BATTERY_MONITOR_BUS_VOLTAGE_CHANNEL 4
147 #if BATTERY_MONITOR_REV4
161 #ifndef BATTERY_MONITOR_CURRENT_OFFSET //mV
162 #ifdef BATTERY_MONITOR_REV4
164 #define BATTERY_MONITOR_CURRENT_OFFSET -120
167 #define BATTERY_MONITOR_CURRENT_OFFSET -657
171 #ifndef BATTERY_MONITOR_CURRENT_SENSITIVITY //mV/A
172 #define BATTERY_MONITOR_CURRENT_SENSITIVITY 25.6
180 #ifndef BATTERY_MONITOR_TEMP_OFFSET //mV
181 #define BATTERY_MONITOR_TEMP_OFFSET 250
183 #ifndef BATTERY_MONITOR_TEMP_SENSITIVITY //mV/C
184 #define BATTERY_MONITOR_TEMP_SENSITIVITY 10
float batmon_temp_sensitivity
@ BATTERY_MONITOR_BUS_TEMPERATURE_READ
@ BATTERY_MONITOR_BUS_VOLTAGE_READ
void battery_monitor_read_bus(void)
Read bus (current, voltage and temperature sensors)
@ BATTERY_MONITOR_BUS_TEMPERATURE_REQ
Battery monitor Bus ADC struct.
Battery monitor Balance ADC struct.
struct BatMonBus batmonbus
struct i2c_transaction bus_trans
void battery_monitor_init(void)
Init variables.
uint16_t bat_cell_mvolts[BATTERY_CELLS_NB]
void battery_monitor_event(void)
Event function Check i2c transaction status for each device.
float bus_temp[TEMP_SENSORS_NB]
void battery_monitor_init_bus(void)
Initializes bus ADC.
void battery_monitor_init_balance(struct BatMonBal *)
Initalizes balance ADC.
static const uint8_t battery_monitor_tempmap[]
void battery_monitor_read_balance_ports_2(void)
Read Balance ADC 2.
BatmonBusStatus
Status for Bus ADC.
@ BATTERY_MONITOR_BUS_VOLTAGE_REQ
uint16_t bus_tempsensors_mvolts[TEMP_SENSORS_NB]
@ BATTERY_MONITOR_BUS_CURRENT_READ
static const float BatmonVbusGain
Architecture independent timing functions.
struct BatMonBal batmonbal1
I2C transaction structure.
struct i2c_transaction bus_trans
static const uint8_t battery_monitor_cellmap[]
Cell map - which cell is which channel Channels are 1-indexed, ie.e.
struct BatMonBal batmonbal2
static const float battery_monitor_cellgains[]
float batmon_current_sensitivity
int16_t batmon_current_offset
void battery_monitor_check_i2c_transaction(struct i2c_transaction *t)
Complete i2c transactions once they succeed or fail.
int16_t batmon_temp_offset
uint16_t bus_voltage_mvolts
uint8_t battery_monitor_get_address(uint8_t channel)
Translates the channel number to the value for address pointer register Channels are numbered from 1 ...
void battery_monitor_read_balance_ports(struct BatMonBal *)
Read balance ADC.
void battery_monitor_read_balance_ports_1(void)
Read Balance ADC 1.
@ BATTERY_MONITOR_BUS_CURRENT_REQ
uint16_t bus_current_mvolts
enum BatmonBusStatus bus_status