152 Serial.begin(115200);
163 if (Serial.available())
167 Serial.println(user_command);
220 Serial.println(F(
"A PEC error was detected in the received data"));
229 Serial.println(F(
"cell conversion completed"));
238 Serial.println(F(
"A PEC error was detected in the received data"));
247 Serial.println(F(
"aux conversion completed"));
256 Serial.println(F(
"A PEC error was detected in the received data"));
262 Serial.println(F(
"transmit 'm' to quit"));
267 if (Serial.available() > 0)
279 Serial.println(F(
"A PEC error was detected in the received data"));
286 Serial.println(F(
"A PEC error was detected in the received data"));
296 Serial.println(F(
"Incorrect Option"));
321 Serial.println(F(
"Please enter LTC6803 Command"));
322 Serial.println(F(
"Write Configuration: 1"));
323 Serial.println(F(
"Read Configuration: 2"));
324 Serial.println(F(
"Start Cell Voltage Conversion: 3"));
325 Serial.println(F(
"Read Cell Voltages: 4"));
326 Serial.println(F(
"Start Aux Voltage Conversion: 5"));
327 Serial.println(F(
"Read Aux Voltages: 6"));
328 Serial.println(F(
"loop cell voltages: 7"));
329 Serial.println(F(
"Please enter command: "));
341 for (
int current_ic = 0 ; current_ic <
TOTAL_IC; current_ic++)
343 Serial.print(
" IC ");
344 Serial.print(current_ic+1,DEC);
345 for (
int i=0;
i<12;
i++)
348 Serial.print(
i+1,DEC);
363 for (
int current_ic =0 ; current_ic <
TOTAL_IC; current_ic++)
365 Serial.print(
" IC ");
366 Serial.print(current_ic+1,DEC);
367 for (
int i=0;
i < 2;
i++)
369 Serial.print(
" Temp-");
370 Serial.print(
i+1,DEC);
375 Serial.print(
" ITemp");
377 Serial.print((
temp_codes[current_ic][2]*0.1875)-274.15,4);
388 Serial.println(
"Written Configuration: ");
389 for (
int current_ic = 0; current_ic<
TOTAL_IC; current_ic++)
391 Serial.print(
" IC ");
392 Serial.print(current_ic+1,DEC);
396 Serial.print(
", 0x");
398 Serial.print(
", 0x");
400 Serial.print(
", 0x");
402 Serial.print(
", 0x");
404 Serial.print(
", 0x");
406 Serial.print(
", Calculated PEC: 0x");
418 Serial.println(
"Received Configuration ");
419 for (
int current_ic=0; current_ic<
TOTAL_IC; current_ic++)
421 Serial.print(
" IC ");
422 Serial.print(current_ic+1,DEC);
423 Serial.print(
": 0x");
425 Serial.print(
", 0x");
427 Serial.print(
", 0x");
429 Serial.print(
", 0x");
431 Serial.print(
", 0x");
433 Serial.print(
", 0x");
435 Serial.print(
", Received PEC: 0x");
449 Serial.print((byte)data,HEX);
452 Serial.print((byte)data,HEX);
static void print_config()
Prints the configuration data that is going to be written to the LTC6803 to the serial port...
static void print_menu()
Prints the main menu.
unsigned char user_command
static void loop()
main loop
static uint8_t tx_cfg[TOTAL_IC][6]
The tx_cfg[][6] stores the LTC6803 configuration data that is going to be written to the LTC6803 ICs ...
LTC6803-2 Multicell Battery Monitor.
Header File for Linduino Libraries and Demo Code.
static void setup()
Inititializes hardware and variables.
static void init_cfg()
Initializes the configuration array.
static uint8_t rx_cfg[TOTAL_IC][7]
the rx_cfg[][8] array stores the data that is read back from a LTC6803-2 daisy chain.
union LT_union_int32_4bytes data
static void run_command(uint32_t cmd)
static void serial_print_hex(uint8_t data)
Print Data Byte in Hex Format.
static uint16_t cell_codes[TOTAL_IC][12]
The cell codes will be stored in the cell_codes[][12] array in the following format: ...
#define input(pin)
Return the state of pin "pin".
uint8_t pec8_calc(uint8_t len, uint8_t *data)
Function that calculates PEC byte.
static void print_rxconfig()
Prints the configuration data that was read back from the LTC6803 to the serial port.
const uint8_t TOTAL_IC
number of ICs in the daisy chain
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
static void print_cells()
Prints cell coltage codes to the serial port.
void LTC6803_sttmpad()
Function to start Temp channel voltage measurement.
void LTC6803_wrcfg(uint8_t total_ic, uint8_t config[][6])
Function that writes configuration of LTC6803-1/-3.
int8_t LTC6803_rdtmp(uint8_t total_ic, uint16_t temp_codes[][3])
Function that reads Temp Voltage registers.
void LTC6803_initialize()
Initializes the SPI port.
uint8_t LTC6803_rdcv(uint8_t total_ic, uint16_t cell_codes[][12])
Function that reads Cell Voltage registers.
static void print_temp()
Prints GPIO voltage codes and Vref2 voltage code onto the serial port.
int8_t LTC6803_rdcfg(uint8_t total_ic, uint8_t r_config[][7])
Function that reads configuration of LTC6803-1/-3.
static uint16_t temp_codes[TOTAL_IC][3]
The Temp codes will be stored in the temp_codes[][3] array in the following format: ...
void LTC6803_stcvad()
Function to start Cell Voltage measurement.