| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

Functions | Macros | Variables
DC1812A-B.ino File Reference
Power Monitors and Coulomb Counters » LTC2944: Multicell Battery Gas Gauge with Temperature, Voltage and Current Measurement

DC1812A-B LTC2944: Multicell Battery Gas Gauge with Temperature, Voltage and Current Measurement. More...

## Detailed Description

DC1812A-B LTC2944: Multicell Battery Gas Gauge with Temperature, Voltage and Current Measurement.

      Setup:
         Apply a voltage source to the V_BATT terminal and a load at the V_CHRG/LD terminal.
         Refer to the Demo Manual Guide for a detailed setup description. Ensure that JP1 is
         set to AL# position.

      Explanation of Commands:

         1 - Automatic Mode - Scans Voltage, Current, Temperature and charge every 60ms.
             Scanning interval has been increased to 1s for ease of reading on the Serial Prompt.
             Displays an alert if it is set in the status register at the time of scan.

         2 - Scan Mode - Scans Voltage, Current, Temperature and charge every 10s.
             Displays an alert if it is set in the status register at the time of scan.

         3 - Manual Mode - Provides a SnapShot of the Voltage, Current, Temperature and Accumulated Charge.
             After the initial SnapShot, the part goes into sleep mode where it only counts charge.
             Displays an alert if it is set in the status register at the time of scan.

         4 - Sleep Mode - The ADC portion of the LTC2944 is shutdown. In this mode only charge is accumulated.

         5 - Shutdown Mode - The LTC2944 goes into low power mode.

         6 - Settings - Allows user to set alert thresholds, set prescalar, set AL#/CC# pin mode and change the temperature and charge units.

    NOTES
     Setup:
     Set the terminal baud rate to 115200 and select the newline terminator.
     Requires a power supply.
     Refer to demo manual DC1812A-B.

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

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.

Definition in file DC1812A-B.ino.

Go to the source code of this file.

## Functions
static void | print_title ()
| Print the title block. More...
static void | print_prompt ()
| Print the Prompt. More...
static void | store_alert_settings ()
static int8_t | restore_alert_settings ()
static void | setup ()
| Initialize Linduino. More...
static void | loop ()
| Repeats Linduino loop. More...
static int8_t | menu_1_automatic_mode (int8_t mAh_or_Coulombs, int8_t celcius_or_kelvin, uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
| Automatic Mode. More...
static int8_t | menu_2_scan_mode (int8_t mAh_or_Coulombs, int8_t celcius_or_kelvin, uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
| Scan Mode. More...
static int8_t | menu_3_manual_mode (int8_t mAh_or_Coulombs, int8_t celcius_or_kelvin, uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
| Manual Mode. More...
static int8_t | menu_4_sleep_mode (int8_t mAh_or_Coulombs, uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
| Sleep Mode. More...
static int8_t | menu_5_shutdown_mode ()
| Shutdown Mode. More...
static int8_t | menu_6_settings (uint8_t *mAh_or_Coulombs, uint8_t *celcius_or_kelvin, uint16_t *prescalar_mode, uint16_t *prescalarValue, uint16_t *alcc_mode)
| Settings Menu. More...
static int8_t | menu_6_settings_menu_1_set_alert_thresholds ()
| Alert Threshold Menu. More...
static int8_t | menu_6_alert_menu_1_set_charge_thresholds ()
| Set Charge Threshold Function. More...
static int8_t | menu_6_alert_menu_2_set_voltage_thresholds ()
| Set Voltage Thresholds. More...
static int8_t | menu_6_alert_menu_3_set_current_thresholds ()
| Set Current Thresholds. More...
static int8_t | menu_6_alert_menu_4_set_temperature_thresholds ()
| Set Temperature Thresholds. More...
static int8_t | menu_6_settings_menu_2_set_prescalar_values (uint16_t *prescalar_mode, uint16_t *prescalarValue)
| Prescalar Menu. More...
static uint8_t | menu_6_alert_menu_3_set_allcc_state (uint16_t *alcc_mode)
| AL#/CC# Pin Mode Menu. More...
static uint8_t | menu_6_alert_menu_4_set_units (uint8_t *mAh_or_Coulombs, uint8_t *celcius_or_kelvin)
| Set Charge and Temperature Units Menu. More...
bool | isBitSet (uint8_t value, uint8_t position)
| Checks to see if a bit in a certain position is set. More...
static void | checkAlerts (uint8_t status_code)
| Check Alerts Function - Checks to see if an alert has been set in the status register. If an alert has been set, it prints out the appropriate message. More...

## Macros
#define | AUTOMATIC_MODE_DISPLAY_DELAY 1000
| The delay between readings in automatic mode. More...
#define | SCAN_MODE_DISPLAY_DELAY 10000
| The delay between readings in scan mode. More...

## Variables
const float | resistor = .100
| resistor value on demo board More...
const char | ack_error [] = "Error: No Acknowledge. Check I2C Address."
| Error message. More...
static int8_t | demo_board_connected
| Set to 1 if the board is connected. More...
static uint8_t | alert_code = 0
| Value stored or read from ALERT register. More...

## Function Documentation

## ◆ checkAlerts()

static void checkAlerts | ( | uint8_t | status_code | ) |
| static

Check Alerts Function - Checks to see if an alert has been set in the status register. If an alert has been set, it prints out the appropriate message.

Returns

Definition at line 925 of file DC1812A-B.ino.

## ◆ isBitSet()

bool isBitSet | ( | uint8_t | value,
|  | uint8_t | position
| ) |  |

Checks to see if a bit in a certain position is set.

Returns
  Returns the state of a bit at "position" in a byte. 1 = Set, 0 = Not Set

Definition at line 919 of file DC1812A-B.ino.

## ◆ loop()

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

Repeats Linduino loop.

Definition at line 141 of file DC1812A-B.ino.

## ◆ menu_1_automatic_mode()

static int8_t menu_1_automatic_mode | ( | int8_t | mAh_or_Coulombs,
|  | int8_t | celcius_or_kelvin,
|  | uint16_t | prescalar_mode,
|  | uint16_t | prescalarValue,
|  | uint16_t | alcc_mode
| ) |  |
| static

Automatic Mode.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.

Definition at line 216 of file DC1812A-B.ino.

## ◆ menu_2_scan_mode()

static int8_t menu_2_scan_mode | ( | int8_t | mAh_or_Coulombs,
|  | int8_t | celcius_or_kelvin,
|  | uint16_t | prescalar_mode,
|  | uint16_t | prescalarValue,
|  | uint16_t | alcc_mode
| ) |  |
| static

Scan Mode.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 296 of file DC1812A-B.ino.

## ◆ menu_3_manual_mode()

static int8_t menu_3_manual_mode | ( | int8_t | mAh_or_Coulombs,
|  | int8_t | celcius_or_kelvin,
|  | uint16_t | prescalar_mode,
|  | uint16_t | prescalarValue,
|  | uint16_t | alcc_mode
| ) |  |
| static

Manual Mode.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 377 of file DC1812A-B.ino.

## ◆ menu_4_sleep_mode()

static int8_t menu_4_sleep_mode | ( | int8_t | mAh_or_Coulombs,
|  | uint16_t | prescalar_mode,
|  | uint16_t | prescalarValue,
|  | uint16_t | alcc_mode
| ) |  |
| static

Sleep Mode.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 470 of file DC1812A-B.ino.

## ◆ menu_5_shutdown_mode()

static int8_t menu_5_shutdown_mode | ( |  | ) |
| static

Shutdown Mode.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 531 of file DC1812A-B.ino.

## ◆ menu_6_alert_menu_1_set_charge_thresholds()

static int8_t menu_6_alert_menu_1_set_charge_thresholds | ( |  | ) |
| static

Set Charge Threshold Function.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 637 of file DC1812A-B.ino.

## ◆ menu_6_alert_menu_2_set_voltage_thresholds()

static int8_t menu_6_alert_menu_2_set_voltage_thresholds | ( |  | ) |
| static

Set Voltage Thresholds.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 661 of file DC1812A-B.ino.

## ◆ menu_6_alert_menu_3_set_allcc_state()

static uint8_t menu_6_alert_menu_3_set_allcc_state | ( | uint16_t * | alcc_mode | ) |
| static

AL#/CC# Pin Mode Menu.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 822 of file DC1812A-B.ino.

## ◆ menu_6_alert_menu_3_set_current_thresholds()

static int8_t menu_6_alert_menu_3_set_current_thresholds | ( |  | ) |
| static

Set Current Thresholds.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 689 of file DC1812A-B.ino.

## ◆ menu_6_alert_menu_4_set_temperature_thresholds()

static int8_t menu_6_alert_menu_4_set_temperature_thresholds | ( |  | ) |
| static

Set Temperature Thresholds.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 718 of file DC1812A-B.ino.

## ◆ menu_6_alert_menu_4_set_units()

static uint8_t menu_6_alert_menu_4_set_units | ( | uint8_t * | mAh_or_Coulombs,
|  | uint8_t * | celcius_or_kelvin
| ) |  |
| static

Set Charge and Temperature Units Menu.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 867 of file DC1812A-B.ino.

## ◆ menu_6_settings()

static int8_t menu_6_settings | ( | uint8_t * | mAh_or_Coulombs,
|  | uint8_t * | celcius_or_kelvin,
|  | uint16_t * | prescalar_mode,
|  | uint16_t * | prescalarValue,
|  | uint16_t * | alcc_mode
| ) |  |
| static

Settings Menu.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 540 of file DC1812A-B.ino.

## ◆ menu_6_settings_menu_1_set_alert_thresholds()

static int8_t menu_6_settings_menu_1_set_alert_thresholds | ( |  | ) |
| static

Alert Threshold Menu.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 591 of file DC1812A-B.ino.

## ◆ menu_6_settings_menu_2_set_prescalar_values()

static int8_t menu_6_settings_menu_2_set_prescalar_values | ( | uint16_t * | prescalar_mode,
|  | uint16_t * | prescalarValue
| ) |  |
| static

Prescalar Menu.

Returns
  Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge

Definition at line 749 of file DC1812A-B.ino.

## ◆ print_prompt()

static void print_prompt | ( |  | ) |
| static

Print the Prompt.

Definition at line 204 of file DC1812A-B.ino.

## ◆ print_title()

static void print_title | ( | void |  | ) |
| static

Print the title block.

Definition at line 191 of file DC1812A-B.ino.

## ◆ restore_alert_settings()

static int8_t restore_alert_settings | ( |  | ) |
| static

## ◆ setup()

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

Initialize Linduino.

Definition at line 116 of file DC1812A-B.ino.

## ◆ store_alert_settings()

static void store_alert_settings | ( |  | ) |
| static

## Macro Definition Documentation

## ◆ AUTOMATIC_MODE_DISPLAY_DELAY

#define AUTOMATIC_MODE_DISPLAY_DELAY 1000

The delay between readings in automatic mode.

Definition at line 102 of file DC1812A-B.ino.

## ◆ SCAN_MODE_DISPLAY_DELAY

#define SCAN_MODE_DISPLAY_DELAY 10000

The delay between readings in scan mode.

Definition at line 103 of file DC1812A-B.ino.

## Variable Documentation

## ◆ ack_error

const char ack_error[] = "Error: No Acknowledge. Check I2C Address."

Error message.

Definition at line 107 of file DC1812A-B.ino.

## ◆ alert_code

uint8_t alert_code = 0
| static

Value stored or read from ALERT register.

Shared between loop() and restore_alert_settings()

Definition at line 113 of file DC1812A-B.ino.

## ◆ demo_board_connected

int8_t demo_board_connected
| static

Set to 1 if the board is connected.

Definition at line 112 of file DC1812A-B.ino.

## ◆ resistor

const float resistor = .100

resistor value on demo board

Definition at line 104 of file DC1812A-B.ino.