firmware
IEM Firmware Documentation
Loading...
Searching...
No Matches
LTC6811.h
Go to the documentation of this file.
1
6
7#ifndef LTC6811_NO_MALLOCS_H
8#define LTC6811_NO_MALLOCS_H
9
10#include "BMSconfig.h"
11#include "SPI.h"
12#include "math.h"
13// Lock your computer bro --Louis Ye
14
15// ADC measurement to voltage conversion constant
16#define LTC6811_ADC_LSB_PER_V 10000
17
18static const float lookupTableTemps[] = {
19 //203 value lookup table to avoid Stenhart-Hart equation.
20 //Resolution increases around 40c to account for change in equation
21 //Values are in 0.5c increments
22 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,
23 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,
24 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,
25 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,
26 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,
27 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
28
29
30 };
31
32
33
34
35typedef enum {
45// StartCellVoltageADCConversionAll = 0x260, // MD = 00, DCP = 0, CHG = 000
47// StartCellTempVoltageADCConversionAll = 0x460, // MD = 00, CHG = 000
48 StartCellTempVoltageADCConversionAll = 0x560, // MD = 00, CHG = 000
51
52void initPECTable(void);
53void writeConfigAddress(BMSConfigStructTypedef *cfg, uint8_t address);
55bool readCellVoltage(uint8_t address, uint16_t cellVoltage[12]);
56
57
59bool readCellTemp(uint8_t address, uint16_t cellTemp[4], bool dcFault[4], bool tempFault[4]);
61// bool checkCellConnection(uint16_t cellVoltage[12], bool cellConnection[12]);
63bool dischargeCellGroups(BMSConfigStructTypedef *cfg, bool cellDischarge[12][12]);
64void wakeup_idle();
65// bool dischargeCell(BMSConfigStructTypedef config, bool cellDischarge[8]);
66bool readConfig(uint8_t address, uint8_t cfg[8]);
67bool readRegister(CommandCodeTypedef command, uint8_t address, uint16_t *data);
69void sendAddressCommand(CommandCodeTypedef command, uint8_t address);
70uint16_t calculatePEC(uint8_t len, uint8_t *data);
73
74#endif // LTC6811_NO_MALLOCS_H
BMS configuration.
bool readConfig(uint8_t address, uint8_t cfg[8])
This method uses general readRegister function to check current state of LTC configuration reg....
Definition LTC6811.c:336
CommandCodeTypedef
Definition LTC6811.h:35
@ ReadAuxiliaryGroupA
Definition LTC6811.h:42
@ ReadConfigurationRegisterGroup
Definition LTC6811.h:37
@ StartCellTempVoltageADCConversionAll
Definition LTC6811.h:48
@ ReadCellVoltageRegisterGroup10to12
Definition LTC6811.h:41
@ StartOpenWireConversionPulldown
Definition LTC6811.h:44
@ ReadCellVoltageRegisterGroup4to6
Definition LTC6811.h:39
@ ReadCellVoltageRegisterGroup7to9
Definition LTC6811.h:40
@ ReadAuxiliaryGroupB
Definition LTC6811.h:43
@ StartCellVoltageADCConversionAll
Definition LTC6811.h:46
@ ClearRegisters
Definition LTC6811.h:49
@ WriteConfigurationRegisterGroup
Definition LTC6811.h:36
@ ReadCellVoltageRegisterGroup1to3
Definition LTC6811.h:38
bool readAllCellVoltages(CellData bmsData[144])
This function reads all cell voltages by essentially parsing each board and reading the individual ce...
Definition LTC6811.c:181
bool readCellVoltage(uint8_t address, uint16_t cellVoltage[12])
This function sends an ADCV command that begins conversion for every cell to specified LTC....
Definition LTC6811.c:130
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....
Definition LTC6811.c:236
bool readAllCellTemps(CellData bmsData[144])
This function reads cell temps from all of our board by calling readCellTemp for each board....
Definition LTC6811.c:282
bool poll_single_secondary_temp_reading(uint8_t board_num, BMSConfigStructTypedef *cfg, CellData bmsData[144])
Definition LTC6811.c:474
static const float lookupTableTemps[]
Definition LTC6811.h:18
bool readRegister(CommandCodeTypedef command, uint8_t address, uint16_t *data)
Reads register specified by command from specified board address.
Definition LTC6811.c:533
void sendAddressCommand(CommandCodeTypedef command, uint8_t address)
Sends specified write-only command to LTC with the specified address.
Definition LTC6811.c:645
void writeConfigAddress(BMSConfigStructTypedef *cfg, uint8_t address)
this method is used for cellDischarge in order to write configuration datra to the LTC with specified...
Definition LTC6811.c:72
void wakeup_idle()
This function is used to wakeup the LTC chip that we want to use to get readings from.
Definition LTC6811.c:429
bool checkAllCellConnections(BMSConfigStructTypedef cfg, CellData bmsData[144])
This function checks the cell connections of each cell in the BMS data array. Currently not used,...
Definition LTC6811.c:363
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 byt...
Definition LTC6811.c:56
bool poll_single_secondary_voltage_reading(uint8_t board_num, BMSConfigStructTypedef *cfg, CellData bmsData[144])
Definition LTC6811.c:437
bool dischargeCellGroups(BMSConfigStructTypedef *cfg, bool cellDischarge[12][12])
This function writes the configuration struct of cells that are currently being discharged....
Definition LTC6811.c:411
void writeConfigAll(BMSConfigStructTypedef *cfg)
This function is called every loop to accommodate dischargeCells method Specifically writes configura...
Definition LTC6811.c:117
void initPECTable(void)
Initializes Packet Error Code LUT by generating PEC look up table -> call on startup.
Definition LTC6811.c:34
void sendBroadcastCommand(CommandCodeTypedef command)
Sends specified write only command to every LTC in the chain (ex: ADCV)
Definition LTC6811.c:626
CellData bmsData[144]
Definition main.c:123
Definition BMSconfig.h:20
Definition BMSconfig.h:71