firmware
IEM Firmware Documentation
|
Go to the source code of this file.
Macros | |
#define | LTC6811_ADC_LSB_PER_V 10000 |
Enumerations | |
enum | CommandCodeTypedef { WriteConfigurationRegisterGroup = 0x001 , ReadConfigurationRegisterGroup = 0x002 , ReadCellVoltageRegisterGroup1to3 = 0x004 , ReadCellVoltageRegisterGroup4to6 = 0x006 , ReadCellVoltageRegisterGroup7to9 = 0x008 , ReadCellVoltageRegisterGroup10to12 = 0x00A , ReadAuxiliaryGroupA = 0x00C , ReadAuxiliaryGroupB = 0x00E , StartOpenWireConversionPulldown = 0x229 , StartCellVoltageADCConversionAll = 0x360 , StartCellTempVoltageADCConversionAll = 0x560 , ClearRegisters = 0x711 } |
Functions | |
void | initPECTable (void) |
Initializes Packet Error Code LUT by generating PEC look up table -> call on startup. | |
void | writeConfigAddress (BMSConfigStructTypedef *cfg, uint8_t address) |
this method is used for cellDischarge in order to write configuration datra to the LTC with specified address | |
void | writeConfigAll (BMSConfigStructTypedef *cfg) |
This function is called every loop to accommodate dischargeCells method Specifically writes configuration data (UV, OV, ADCMode, etc) to BMSConfig struct. | |
bool | readCellVoltage (uint8_t address, uint16_t cellVoltage[12]) |
This function sends an ADCV command that begins conversion for every cell to specified LTC. This results in the function readings all cell voltage registers using the readRegister function. | |
bool | readAllCellVoltages (CellData bmsData[144]) |
This function reads all cell voltages by essentially parsing each board and reading the individual cell voltages. These are then stored in the bmsData array, along with the cell number that is associated with the reading. | |
bool | readCellTemp (uint8_t address, uint16_t cellTemp[4], bool dcFault[4], bool tempFault[4]) |
This function initiates ADC conversion for GPIO inputs connected to temperature sensors. Reads auxiliary register groups using readRegister function. Then, converts measured voltage into temperature based on temperature sensor response. Also checks for disconnected temperature sensor and OT faults. NOTE: We only read 4 temps per board, and they are the 4 highest temps on each board. | |
bool | readAllCellTemps (CellData bmsData[144]) |
This function reads cell temps from all of our board by calling readCellTemp for each board. NOTE : This is not proven to work properly yet. | |
bool | checkAllCellConnections (BMSConfigStructTypedef cfg, CellData bmsData[144]) |
This function checks the cell connections of each cell in the BMS data array. Currently not used, as we have not been able to get it working, but the whole idea is that this function compares previously measured values to open wire check values, and if there is a significant drop in voltage, cell is allegedly disconnected. | |
bool | dischargeCellGroups (BMSConfigStructTypedef *cfg, bool cellDischarge[12][12]) |
This function writes the configuration struct of cells that are currently being discharged. This is to track which cells are // being discharged while running our balancing algorithm. | |
void | wakeup_idle () |
This function is used to wakeup the LTC chip that we want to use to get readings from. | |
bool | readConfig (uint8_t address, uint8_t cfg[8]) |
This method uses general readRegister function to check current state of LTC configuration reg. Mostly used for testing purposes. | |
bool | readRegister (CommandCodeTypedef command, uint8_t address, uint16_t *data) |
Reads register specified by command from specified board address. | |
void | sendBroadcastCommand (CommandCodeTypedef command) |
Sends specified write only command to every LTC in the chain (ex: ADCV) | |
void | sendAddressCommand (CommandCodeTypedef command, uint8_t address) |
Sends specified write-only command to LTC with the specified address. | |
uint16_t | calculatePEC (uint8_t len, uint8_t *data) |
This method is used when sending a command to calculate the necessary PEC bytes to follow command bytes. Should be used when receiving data to compare receieved PEC with expected PEC value. | |
bool | poll_single_secondary_voltage_reading (uint8_t board_num, BMSConfigStructTypedef *cfg, CellData bmsData[144]) |
bool | poll_single_secondary_temp_reading (uint8_t board_num, BMSConfigStructTypedef *cfg, CellData bmsData[144]) |
Variables | |
static const float | lookupTableTemps [] |
#define LTC6811_ADC_LSB_PER_V 10000 |
enum CommandCodeTypedef |
uint16_t calculatePEC | ( | uint8_t | len, |
uint8_t * | data ) |
This method is used when sending a command to calculate the necessary PEC bytes to follow command bytes. Should be used when receiving data to compare receieved PEC with expected PEC value.
len | is the number of bytes that we will be stepping through in our data |
data | is the data that we will be using to calculate the expected PEC |
bool checkAllCellConnections | ( | BMSConfigStructTypedef | cfg, |
CellData | bmsData[144] ) |
This function checks the cell connections of each cell in the BMS data array. Currently not used, as we have not been able to get it working, but the whole idea is that this function compares previously measured values to open wire check values, and if there is a significant drop in voltage, cell is allegedly disconnected.
cfg | is the BMS configuration struct with constants |
bmsData | is an array of 144 cellData structs, containing index, fault, voltage and temperature |
bool dischargeCellGroups | ( | BMSConfigStructTypedef * | cfg, |
bool | cellDischarge[12][12] ) |
This function writes the configuration struct of cells that are currently being discharged. This is to track which cells are // being discharged while running our balancing algorithm.
cfg | is the configuration struct that stores all the constants in our BMS algorithm |
cellDischarge | is a 2D array of cells that tracks which cells are being discharged or not : 1 = discharging, 0 = not discharging returns 0 always -> not sure why we need a return value on this |
void initPECTable | ( | void | ) |
Initializes Packet Error Code LUT by generating PEC look up table -> call on startup.
bool poll_single_secondary_temp_reading | ( | uint8_t | board_num, |
BMSConfigStructTypedef * | cfg, | ||
CellData | bmsData[144] ) |
bool poll_single_secondary_voltage_reading | ( | uint8_t | board_num, |
BMSConfigStructTypedef * | cfg, | ||
CellData | bmsData[144] ) |
bool readAllCellTemps | ( | CellData | bmsData[144] | ) |
This function reads cell temps from all of our board by calling readCellTemp for each board. NOTE : This is not proven to work properly yet.
bmsData | is an array of 144 cellData structs, containing index, fault, voltage and temperature |
bool readAllCellVoltages | ( | CellData | bmsData[144] | ) |
This function reads all cell voltages by essentially parsing each board and reading the individual cell voltages. These are then stored in the bmsData array, along with the cell number that is associated with the reading.
bmsData | is an array of 144 cellData structs, containing index, fault, voltage and temperature |
bool readCellTemp | ( | uint8_t | address, |
uint16_t | cellTemp[4], | ||
bool | dcFault[4], | ||
bool | tempFault[4] ) |
This function initiates ADC conversion for GPIO inputs connected to temperature sensors. Reads auxiliary register groups using readRegister function. Then, converts measured voltage into temperature based on temperature sensor response. Also checks for disconnected temperature sensor and OT faults. NOTE: We only read 4 temps per board, and they are the 4 highest temps on each board.
address | is the address of the board being read |
cellTemp | is the array that will hold the cell temps read during readRegister |
dcFault | is the array that stores temperature sensor ceonnection for all cells read |
tempFault | stores OT fault info for each cell read |
bool readCellVoltage | ( | uint8_t | address, |
uint16_t | cellVoltage[12] ) |
This function sends an ADCV command that begins conversion for every cell to specified LTC. This results in the function readings all cell voltage registers using the readRegister function.
address | is the address of the board that will be read |
cellVoltage | is the array that will store the voltages of all the cells on the board being read |
bool readConfig | ( | uint8_t | address, |
uint8_t | cfg[8] ) |
This method uses general readRegister function to check current state of LTC configuration reg. Mostly used for testing purposes.
address | is the address passed into the readRegister function |
cfg | is part of the configuration that will be passed to check the current state of the LTC |
bool readRegister | ( | CommandCodeTypedef | command, |
uint8_t | address, | ||
uint16_t * | data ) |
Reads register specified by command from specified board address.
command | is the command that we will send to the board |
address | is the specific board that will get the command |
data | is where the data read from the specific board will be StartOpenWireConversionPulldown |
void sendAddressCommand | ( | CommandCodeTypedef | command, |
uint8_t | address ) |
Sends specified write-only command to LTC with the specified address.
command | is the command that will be sent to the LTC |
address | is the specified address of the LTC that will receive the command |
void sendBroadcastCommand | ( | CommandCodeTypedef | command | ) |
Sends specified write only command to every LTC in the chain (ex: ADCV)
command | contains every command code used |
|
inline |
This function is used to wakeup the LTC chip that we want to use to get readings from.
void writeConfigAddress | ( | BMSConfigStructTypedef * | cfg, |
uint8_t | address ) |
this method is used for cellDischarge in order to write configuration datra to the LTC with specified address
cfg | is the configuration struct for BMS constants |
address | is the address used to pass into our config file |
void writeConfigAll | ( | BMSConfigStructTypedef * | cfg | ) |
This function is called every loop to accommodate dischargeCells method Specifically writes configuration data (UV, OV, ADCMode, etc) to BMSConfig struct.
cfg | is the configuration files for the constants in the BMS system |
|
static |