firmware
IEM Firmware Documentation
Loading...
Searching...
No Matches
LTC6811.h File Reference
#include "BMSconfig.h"
#include "SPI.h"
#include "math.h"
Include dependency graph for LTC6811.h:
This graph shows which files directly or indirectly include this file:

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 []

Macro Definition Documentation

◆ LTC6811_ADC_LSB_PER_V

#define LTC6811_ADC_LSB_PER_V   10000

Enumeration Type Documentation

◆ CommandCodeTypedef

Enumerator
WriteConfigurationRegisterGroup 
ReadConfigurationRegisterGroup 
ReadCellVoltageRegisterGroup1to3 
ReadCellVoltageRegisterGroup4to6 
ReadCellVoltageRegisterGroup7to9 
ReadCellVoltageRegisterGroup10to12 
ReadAuxiliaryGroupA 
ReadAuxiliaryGroupB 
StartOpenWireConversionPulldown 
StartCellVoltageADCConversionAll 
StartCellTempVoltageADCConversionAll 
ClearRegisters 

Function Documentation

◆ calculatePEC()

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.

Parameters
lenis the number of bytes that we will be stepping through in our data
datais the data that we will be using to calculate the expected PEC
Returns
the expected PEC value
Here is the caller graph for this function:

◆ checkAllCellConnections()

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.

Parameters
cfgis the BMS configuration struct with constants
bmsDatais an array of 144 cellData structs, containing index, fault, voltage and temperature
Returns
true is the cell is connnected properly, and false if the cell is "disconnected"
Here is the call graph for this function:

◆ dischargeCellGroups()

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.

Parameters
cfgis the configuration struct that stores all the constants in our BMS algorithm
cellDischargeis 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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initPECTable()

void initPECTable ( void )

Initializes Packet Error Code LUT by generating PEC look up table -> call on startup.

Returns
none
Here is the caller graph for this function:

◆ poll_single_secondary_temp_reading()

bool poll_single_secondary_temp_reading ( uint8_t board_num,
BMSConfigStructTypedef * cfg,
CellData bmsData[144] )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ poll_single_secondary_voltage_reading()

bool poll_single_secondary_voltage_reading ( uint8_t board_num,
BMSConfigStructTypedef * cfg,
CellData bmsData[144] )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readAllCellTemps()

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.

Parameters
bmsDatais an array of 144 cellData structs, containing index, fault, voltage and temperature
Returns
true if PEC value received matches expected PEC value. Otherwise, false. -> i.e., returns false if any readCellTemp return values are false.
Here is the call graph for this function:

◆ readAllCellVoltages()

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.

Parameters
bmsDatais an array of 144 cellData structs, containing index, fault, voltage and temperature
Returns
true if no PEC for any register read for any board
Here is the call graph for this function:

◆ readCellTemp()

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.

Parameters
addressis the address of the board being read
cellTempis the array that will hold the cell temps read during readRegister
dcFaultis the array that stores temperature sensor ceonnection for all cells read
tempFaultstores OT fault info for each cell read
Returns
true if PEC value read matches expected PEC value calculated. Otherwise, false.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readCellVoltage()

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.

Parameters
addressis the address of the board that will be read
cellVoltageis the array that will store the voltages of all the cells on the board being read
Returns
true if PEC matches expected PEC value, else false
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readConfig()

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.

Parameters
addressis the address passed into the readRegister function
cfgis part of the configuration that will be passed to check the current state of the LTC
Returns
true if the received PEC from readRegister mathes the calculated PEC
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readRegister()

bool readRegister ( CommandCodeTypedef command,
uint8_t address,
uint16_t * data )

Reads register specified by command from specified board address.

Parameters
commandis the command that we will send to the board
addressis the specific board that will get the command
datais where the data read from the specific board will be StartOpenWireConversionPulldown
Returns
true if the data is valid, otherwise false (i.e., received PEC matches expected PEC value)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendAddressCommand()

void sendAddressCommand ( CommandCodeTypedef command,
uint8_t address )

Sends specified write-only command to LTC with the specified address.

Parameters
commandis the command that will be sent to the LTC
addressis the specified address of the LTC that will receive the command
Returns
none
Here is the call graph for this function:

◆ sendBroadcastCommand()

void sendBroadcastCommand ( CommandCodeTypedef command)

Sends specified write only command to every LTC in the chain (ex: ADCV)

Parameters
commandcontains every command code used
Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wakeup_idle()

void wakeup_idle ( )
inline

This function is used to wakeup the LTC chip that we want to use to get readings from.

Here is the caller graph for this function:

◆ writeConfigAddress()

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

Parameters
cfgis the configuration struct for BMS constants
addressis the address used to pass into our config file
Returns
none
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeConfigAll()

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.

Parameters
cfgis the configuration files for the constants in the BMS system
Returns
none
Here is the call graph for this function:

Variable Documentation

◆ lookupTableTemps

const float lookupTableTemps[]
static
Initial value:
= {
70, 68.5, 67, 66, 64.5, 63, 62, 61, 60, 59, 58, 57, 56, 55.5, 55, 54, 53, 52, 51.5, 51, 50, 49.5, 49, 48, 47.5, 47, 46, 45.5, 45, 44.5, 44, 43.5, 43, 42, 41.5, 41, 40.5,
40, 40, 39.5, 39.0, 38.5, 38.0, 37.5, 37.0, 36.5, 36.0, 36, 35.5, 35.0, 34.5, 34.0, 34, 33.5, 33.0, 32.5, 32, 32.0, 31.5, 31, 31.0, 30.5, 30.0, 30, 29.5, 29.0, 29, 28.5,
28, 28.0, 27.5, 27, 27.0, 26.5, 26, 26.0, 26, 25.5, 25, 25.0, 24.5, 24, 24.0, 24, 23.5, 23, 23.0, 23, 22.5, 22, 22.0, 22, 21.5, 21, 21.0, 21, 20.5, 20, 20.0, 20, 19.5, 19,
19.0, 19, 18.5, 18, 18.0, 18, 17.5, 17, 17.0, 17, 17, 16.5, 16, 16.0, 16, 15.5, 15, 15, 15.0, 15, 14.5, 14, 14.0, 14, 14, 13.5, 13, 13.0, 13, 13, 12.5, 12, 12.0, 12, 12,
11.5, 11, 11.0, 11, 11, 10.5, 10, 10, 10.0, 10, 9.5, 9, 9, 9.0, 9, 9, 8.5, 8, 8.0, 8, 8, 7.5, 7, 7, 7.0, 7, 7, 6.5, 6, 6, 6.0, 6, 6, 5.5, 5, 5, 5.0, 5, 4.5, 4, 4, 4.0, 4,
4, 3.5, 3, 3, 3.0, 3, 3, 2.5, 2, 2, 2, 2.0, 2, 2, 1.5, 1, 1, 1.0, 1, 1, 0.5, 0, 0, 0.0
}