| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

Functions | Variables
DC1942.ino File Reference
Battery Management System (BMS) » LTC6804-2: Multicell Battery Monitor

DC1942B LTC6804-2: Battery stack monitor. More...

## Detailed Description

DC1942B LTC6804-2: Battery stack monitor.

    NOTES
     Setup:
       Set the terminal baud rate to 115200 and select the newline terminator.
       Ensure all jumpers on the demo board are installed in their default positions from the factory.
       Refer to Demo Manual D1894B.

     Menu Entry 1: Write Configuration
       Writes the configuration register of the LTC6804. This command can be used to turn on the reference.

     Menu Entry 2: Read Configuration
       Reads the configuration register of the LTC6804, the read configuration can differ from the written configuration.
       The GPIO pins will reflect the state of the pin

     Menu Entry 3: Start Cell voltage conversion
        Starts a LTC6804 cell channel adc conversion.

     Menu Entry 4: Read cell voltages
        Reads the LTC6804 cell voltage registers and prints the results to the serial port.

     Menu Entry 5: Start Auxiliary voltage conversion
        Starts a LTC6804 GPIO channel adc conversion.

     Menu Entry 6: Read Auxiliary voltages
        Reads the LTC6804 axiliary registers and prints the GPIO voltages to the serial port.

     Menu Entry 7: Start cell voltage measurement loop
        The command will continuously measure the LTC6804 cell voltages and print the results to the serial port.
        The loop can be exited by sending the MCU a 'm' character over the serial link.

    USER INPUT DATA FORMAT:
     decimal : 1024
     hex     : 0x400
     octal   : 02000  (leading 0)
     binary  : B10000000000
     float   : 1024.0

http://www.linear.com/product/LTC6804-1

http://www.linear.com/product/LTC6804-1#demoboards

Copyright 2018(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
- The use of this software may or may not infringe the patent rights of one or more patent holders. This license does not release you from the requirement that you obtain separate licenses from these patent holders to use this software.
- Use of the software either in source or binary form, must be run on or directly connected to an Analog Devices Inc. component.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copyright 2013 Linear Technology Corp. (LTC)

Definition in file DC1942.ino.

Go to the source code of this file.

## Functions
static void | setup ()
| More...
static void | loop ()
| More...
static void | run_command (uint16_t cmd)
| More...
static void | init_cfg ()
| More...
static void | print_menu ()
| More...
static void | print_cells ()
| More...
static void | print_aux ()
| More...
static void | print_config ()
| More...
static void | print_rxconfig ()
| More...
static void | serial_print_hex (uint8_t data)

## Variables
const uint8_t | TOTAL_IC = 1
| number of ICs in the isoSPI network LTC6804-2 ICs must be addressed in ascending order starting at 0. More...
static uint16_t | cell_codes [TOTAL_IC][12]
| The cell codes will be stored in the cell_codes[][12] array in the following format: More...
static uint16_t | aux_codes [TOTAL_IC][6]
| The GPIO codes will be stored in the aux_codes[][6] array in the following format: More...
static uint8_t | tx_cfg [TOTAL_IC][6]
| The tx_cfg[][6] stores the LTC6804 configuration data that is going to be written to the LTC6804 ICs on the daisy chain. More...
static uint8_t | rx_cfg [TOTAL_IC][8]
| the rx_cfg[][8] array stores the data that is read back from a LTC6804-1 daisy chain. More...

## Function Documentation

## ◆ init_cfg()

static void init_cfg | ( |  | ) |
| static

Initializes the configuration array

Definition at line 297 of file DC1942.ino.

## ◆ loop()

static void loop | ( | void |  | ) |
| static

main loop

Definition at line 162 of file DC1942.ino.

## ◆ print_aux()

static void print_aux | ( |  | ) |
| static

Prints GPIO Voltage Codes and Vref2 Voltage Code onto the serial port

Definition at line 356 of file DC1942.ino.

## ◆ print_cells()

static void print_cells | ( |  | ) |
| static

Prints Cell Voltage Codes to the serial port

Definition at line 332 of file DC1942.ino.

## ◆ print_config()

static void print_config | ( |  | ) |
| static

Prints the Configuration data that is going to be written to the LTC6804 to the serial port.

Definition at line 382 of file DC1942.ino.

## ◆ print_menu()

static void print_menu | ( | void |  | ) |
| static

Prints the main menu

Definition at line 313 of file DC1942.ino.

## ◆ print_rxconfig()

static void print_rxconfig | ( | void |  | ) |
| static

Prints the Configuration data that was read back from the LTC6804 to the serial port.

Definition at line 418 of file DC1942.ino.

## ◆ run_command()

static void run_command | ( | uint16_t | cmd | ) |
| static

executes the user inputted command

Menu Entry 1: Write Configuration
Writes the configuration register of the LTC6804. This command can be used to turn on the reference and increase the speed of the ADC conversions.

Menu Entry 2: Read Configuration
Reads the configuration register of the LTC6804, the read configuration can differ from the written configuration. The GPIO pins will reflect the state of the pin

Menu Entry 3: Start Cell voltage conversion
Starts a LTC6804 cell channel adc conversion.

Menu Entry 4: Read cell voltages Reads the LTC6804 cell voltage registers and prints the results to the serial port.

Menu Entry 5: Start Auxiliary voltage conversion Starts a LTC6804 GPIO channel adc conversion.

Menu Entry 6: Read Auxiliary voltages Reads the LTC6804 axiliary registers and prints the GPIO voltages to the serial port.

Menu Entry 7: Start cell voltage measurement loop The command will continuously measure the LTC6804 cell voltages and print the results to the serial port. The loop can be exited by sending the MCU a 'm' character over the serial link.

Definition at line 203 of file DC1942.ino.

## ◆ serial_print_hex()

static void serial_print_hex | ( | uint8_t | data | ) |
| static

Definition at line 446 of file DC1942.ino.

## ◆ setup()

static void setup | ( | void |  | ) |
| static

Inititializes hardware and variables

Definition at line 150 of file DC1942.ino.

## Variable Documentation

## ◆ aux_codes

uint16_t aux_codes[TOTAL_IC][6]
| static

The GPIO codes will be stored in the aux_codes[][6] array in the following format:

aux_codes[0][0] | aux_codes[0][1] | aux_codes[0][2] | aux_codes[0][3] | aux_codes[0][4] | aux_codes[0][5] | aux_codes[1][0] | aux_codes[1][1] | .....
--- | --- | --- | --- | --- | --- | --- | --- | ---
IC1 GPIO1 | IC1 GPIO2 | IC1 GPIO3 | IC1 GPIO4 | IC1 GPIO5 | IC1 Vref2 | IC2 GPIO1 | IC2 GPIO2 | .....

Definition at line 116 of file DC1942.ino.

## ◆ cell_codes

uint16_t cell_codes[TOTAL_IC][12]
| static

The cell codes will be stored in the cell_codes[][12] array in the following format:

cell_codes[0][0] | cell_codes[0][1] | cell_codes[0][2] | ..... | cell_codes[0][11] | cell_codes[1][0] | cell_codes[1][1] | .....
--- | --- | --- | --- | --- | --- | --- | ---
IC1 Cell 1 | IC1 Cell 2 | IC1 Cell 3 | ..... | IC1 Cell 12 | IC2 Cell 1 | IC2 Cell 2 | .....

Definition at line 107 of file DC1942.ino.

## ◆ rx_cfg

uint8_t rx_cfg[TOTAL_IC][8]
| static

the rx_cfg[][8] array stores the data that is read back from a LTC6804-1 daisy chain.

The configuration data for each IC is stored in blocks of 8 bytes. Below is an table illustrating the array organization:

rx_config[0][0] | rx_config[0][1] | rx_config[0][2] | rx_config[0][3] | rx_config[0][4] | rx_config[0][5] | rx_config[0][6] | rx_config[0][7] | rx_config[1][0] | rx_config[1][1] | .....
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
IC1 CFGR0 | IC1 CFGR1 | IC1 CFGR2 | IC1 CFGR3 | IC1 CFGR4 | IC1 CFGR5 | IC1 PEC High | IC1 PEC Low | IC2 CFGR0 | IC2 CFGR1 | .....

Definition at line 137 of file DC1942.ino.

## ◆ TOTAL_IC

const uint8_t TOTAL_IC = 1

number of ICs in the isoSPI network LTC6804-2 ICs must be addressed in ascending order starting at 0.

Definition at line 99 of file DC1942.ino.

## ◆ tx_cfg

uint8_t tx_cfg[TOTAL_IC][6]
| static

The tx_cfg[][6] stores the LTC6804 configuration data that is going to be written to the LTC6804 ICs on the daisy chain.

The LTC6804 configuration data that will be written should be stored in blocks of 6 bytes. The array should have the following format:

tx_cfg[0][0] | tx_cfg[0][1] | tx_cfg[0][2] | tx_cfg[0][3] | tx_cfg[0][4] | tx_cfg[0][5] | tx_cfg[1][0] | tx_cfg[1][1] | tx_cfg[1][2] | .....
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
IC1 CFGR0 | IC1 CFGR1 | IC1 CFGR2 | IC1 CFGR3 | IC1 CFGR4 | IC1 CFGR5 | IC2 CFGR0 | IC2 CFGR1 | IC2 CFGR2 | .....

Definition at line 125 of file DC1942.ino.