| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

Functions | Macros | Variables
DC2574A_KIT.ino File Reference
Power Monitors and Coulomb Counters » LTC2947 a high-precision power and energy monitor with an internal sense resistor supporting up to 30A.

Linduino.INO File for DC2574A_KIT: Standalone power/energy monitor for evaluation of the LTC2947 monitor without a PC Linear Technology DC2574A_KIT Demonstration Board: Standalone power/energy monitor for evaluation of the LTC2947 monitor without a PC. LTC2947: high-precision power and energy monitor with an internal sense resistor supporting up to 30A. More...

## Detailed Description

Linduino.INO File for DC2574A_KIT: Standalone power/energy monitor for evaluation of the LTC2947 monitor without a PC Linear Technology DC2574A_KIT Demonstration Board: Standalone power/energy monitor for evaluation of the LTC2947 monitor without a PC. LTC2947: high-precision power and energy monitor with an internal sense resistor supporting up to 30A.

Date
  6/17/2016

NOTE: The DC2574A-KIT includes the following items:

- DC2334A: LTC2947 Demo Circuit
- DC2026: Linduino with Pre-Programmed "LTC2947 - DC2574A_KIT Linduino.INO File" (THIS FILE!)
- LCD Keypad Shield
- USB Cable: Power Supply And Optional Communication Interface for Operating with the GUI
- 14-pin Ribbon Cable.

The DC2574A_KIT Linduino sketch contains a lot of code that is only necessary to operate with the LCD, the serial ports and to allow compatibility with DC590 commands (see usage of GUI together with the DC2574A-KIT). This code might not be of interest by the customer that wants to focuse on functionality of the LTC2947. The focuse on LTC2947 relevant code only, just search for LTC2947_ within this source file.

Setup: Set the terminal baud rate to 115200 and de-select the newline terminator. (That means e.g. within the serial monitor of the Arduino IDE select "No line ending") Refer to Demo Manual DC2574A_KIT. Ensure all jumpers are installed in the factory default positions. Especially make sure the board is configured to I2C mode with slave address set to 0x5C (LL), see also below the define LTC2947_I2C_ADDRESS

Command Description: After start-up the DC2574A_KIT Linduino sketch will send the following lines on the connected serial com port:

Hello LTC2947 30A PowerMonitor LCD found! Enter l or m for options.

- or in case no LCD Keypad Shield is plugged on top of the DC2334A demoboard -

No LCD found! Enter l or m for options.

In any case commands l or m can be send: l-command: Status/Alert regsierts, the following submenu will be shown: 0:STATUS 1:STATVT 2:STATIP 3:STATC 4:STATE 5:STATCEOF 6:STATTB 7:STATVDVCC 8:CYCLE ALL enter 0-8, any other to cancel

Select one out of 0-7 to report a single status/alert register or 8 to cycle through all status/alert registers. In both cases new values will be reported every second. E.g. for option 0 (STATUS) you will get the following output: STAT:UPD,

STAT:UPD, ...

The bits of the status/alert registers that are set to 1 will be reported, e.g. UPD is the UPDATE bit of the STATUS register that tells a new conversion cycle was performed.

Option 8 (CYCLE ALL) will show the following output:

STAT:UPD,

STATVT:

STATIP:

STATC:

STATE:

STATCEOF:

STATTB:

STATVDVCC:

In the example output above only the UPDATE bit was set

m-command: Measurement values, the following submenu will be shown: 0: I V P TEMP 1:C1 VDVCC E1 TB1 2:C2 VDVCC E2 TB2 3:IMIN IMAX PMIN PMAX 4:VMIN VMAX TMIN TMAX 5:TMIN TMAX VDMIN VDMAX 6:CYCLE ALL measurements enter 0-6, any other to cancel

Select one out of 0-5 to report a single set of measurement values or 8 to cycle through all measurements. In both cases new values will be reported every second. E.g. for option 0 (I V P TEMP) you will get the following output:

I V P TEMP 0.012A -0.342V 0.000W 30.2°C 0.006A -0.342V 0.000W 30.2°C 0.012A -0.342V 0.000W 30.2°C I V P TEMP 0.012A -0.342V 0.000W 30.2°C ....

Current, Voltage, Power and die temperature are reported every second. Option 6 (CYCLE ALL) will show the following output:

I V P TEMP 0.006A -0.342V 0.000W 30.2°C 0.012A -0.342V 0.000W 30.2°C 0.012A -0.342V 0.000W 30.2°C C1 VDVCC E1 TB1 4.83mAh 4.50V 0.00mWh 34m35s 4.83mAh 4.50V 0.00mWh 34m36s 4.83mAh 4.50V 0.00mWh 34m37s C2 VDVCC E2 TB2 4.84mAh 4.64V 0.00mWh 34m40s 4.84mAh 4.50V 0.00mWh 34m41s 4.85mAh 4.50V 0.00mWh 34m42s ....

In case a LCD Keypad Shield is plugged on top of the DC2334A demoboard, all output will also be shown on the LCD.

DC590B compatibility: Appart from commands m and l the DC2574A_KIT sketch also supports a subset of the DC590B commands. This way the LTC2947 GUI is also able to communicate with the DC2574A_KIT sketch which enables the user to use the GUI to change LTC2947 configuration e.g. to set alarm thresholds etc. The main limitations of this compatibility mode are:

- EEPROM read from the DC2334A demo board is faked (it will always report the right EEPROM string)
- SPI operation is not supported, due to incompatibility with the optional LCD Keypad Shield

See tinyDC590.cpp for details

http://www.linear.com/product/LTC2947

http://www.linear.com/product/LTC2947#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.

Linduino .INO file for LTC2947 a high-precision power and energy monitor with an internal sense resistor supporting up to 30A.

Definition in file DC2574A_KIT.ino.

Go to the source code of this file.

## Functions
static void | setup ()
| general initialization More...
static void | update ()
| update LTC2947 measurement results More...
static void | loop ()
| main loop More...
static void | DelayAndProcessInputs (unsigned long ms)
| Delay and process input commands either from serial port or from keypad. More...
boolean | userInput ()
| processes the user input from LCD keypad shield More...
static void | processCommands (char command)

## Macros
#define | LTC2947_I2C_MODE_ENABLE
| Edit LTC2947.h to adjust the following settings: Internal / External clock operation and frequency setting I2C / SPI mode operation In case of I2C: Slave address configuration. More...
#define | SCREEN_UPDATE_TIME 1000UL
| Only one mode is possible at a time. More...
#define | LABEL_DELAY 2000UL
#define | SPLASH_SCREEN_DELAY 3000UL
#define | USER_SEL_GRP1_COUNT 9
| Menu Group 1 count: STATUS STATVT STATIP STATC STATE STATCEOF STATTB STATVDVCC "CYCLE stats". More...
#define | USER_SEL_GRP1_CYCLE_COUNT 8
| Menu Group 1 cycle count: STATUS STATVT STATIP STATC STATE STATCEOF STATTB STATVDVCC. More...
#define | USER_SEL_GRP2_COUNT 7
| Menu group 2 count: RAW, ACCU1, ACCU2, Track1, Track2, Track3, "Cycle meas.". More...
#define | USER_SEL_GRP2_CYCLE_COUNT 6
| Menu Group 2 cycle count: RAW, ACCU1, ACCU2, Track1, Track2, Track3. More...
#define | USERGROUPCYCLETIMERRELOAD 3
| defines how many cycles a single measurement group will be displayed on the LCD in case of "cycle all" (2 means each measurement is shown 3 times) More...
#define | MEAS_LABEL00 F("I V")
#define | MEAS_LABEL01 F("P TEMP")
#define | MEAS_LABEL10 F("C1 VDVCC")
#define | MEAS_LABEL11 F("E1 TB1")
#define | MEAS_LABEL20 F("C2 VDVCC")
#define | MEAS_LABEL21 F("E2 TB2")
#define | MEAS_LABEL30 F("IMIN IMAX")
#define | MEAS_LABEL31 F("PMIN PMAX")
#define | MEAS_LABEL40 F("VMIN VMAX")
#define | MEAS_LABEL41 F("TMIN TMAX")
#define | MEAS_LABEL50 F("TMIN TMAX")
#define | MEAS_LABEL51 F("VDMIN VDMAX")
#define | MEAS_LABEL60 F("CYCLE ALL")
#define | MEAS_LABEL61 F("measurements")

## Variables
boolean | dc590Busy
| DC590 busy check. More...
unsigned long | nextUpdateTime = 0
| The next update time. More...
LCDKeypad * | lcd
| pointer to the LCD keypad object More...
static int8_t | previousKey = KEYPAD_NONE
| The previous key. More...
boolean | flagClear = false
| flag to store actions from user input. More...
static uint8_t | userSelGroup1 = 0
| User selection of the first group. More...
boolean | userGroup1Cycle = false
| group 1 cycle enable More...
static uint8_t | userSelGroup2 = 0
| User selection of the second group. More...
boolean | userGroup2Cycle = false
| group 2 cycle enable More...
boolean | userGroupSelect = true
| selected group 1: false, 2: true More...
boolean | statusRegsRead = false
| flag is asserted once after all status registers were read. More...
byte | statusRegs [8]
| array to store all status / alert registers More...
static uint8_t | userGroupCycleTimer = 0
| The user group cycle timer. More...

## Function Documentation

## ◆ DelayAndProcessInputs()

void DelayAndProcessInputs | ( | unsigned long | ms | ) |
| static

Delay and process input commands either from serial port or from keypad.

Parameters

  ms | delay in milliseconds

Definition at line 799 of file DC2574A_KIT.ino.

## ◆ loop()

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

main loop

Definition at line 790 of file DC2574A_KIT.ino.

## ◆ processCommands()

static void processCommands | ( | char | command | ) |
| static

Definition at line 978 of file DC2574A_KIT.ino.

## ◆ setup()

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

general initialization

Definition at line 299 of file DC2574A_KIT.ino.

## ◆ update()

void update | ( |  | ) |
| static

update LTC2947 measurement results

Definition at line 345 of file DC2574A_KIT.ino.

## ◆ userInput()

boolean userInput | ( |  | ) |

processes the user input from LCD keypad shield

Returns
  true if any key was pressed on the LDC keypad shield

Definition at line 835 of file DC2574A_KIT.ino.

## Macro Definition Documentation

## ◆ LABEL_DELAY

#define LABEL_DELAY 2000UL

Definition at line 243 of file DC2574A_KIT.ino.

## ◆ LTC2947_I2C_MODE_ENABLE

#define LTC2947_I2C_MODE_ENABLE

Edit LTC2947.h to adjust the following settings: Internal / External clock operation and frequency setting I2C / SPI mode operation In case of I2C: Slave address configuration.

Define either LTC2947_I2C_MODE_ENABLE or LTC2947_SPI_MODE_ENABLE to set the communication interface to I2C or SPI NOTE: It is not possible to operate in SPI mode together with the LCD due to pin conflicts. If you want to operate in SPI mode you have to remove the LCD and connect DC2334A via the 14-pin ribbon cable to J1 of Linduino instead of connecting DC2334A as a shield on top of Linduino.

Definition at line 233 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL00

#define MEAS_LABEL00 F("I V")

Definition at line 256 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL01

#define MEAS_LABEL01 F("P TEMP")

Definition at line 257 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL10

#define MEAS_LABEL10 F("C1 VDVCC")

Definition at line 258 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL11

#define MEAS_LABEL11 F("E1 TB1")

Definition at line 259 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL20

#define MEAS_LABEL20 F("C2 VDVCC")

Definition at line 260 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL21

#define MEAS_LABEL21 F("E2 TB2")

Definition at line 261 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL30

#define MEAS_LABEL30 F("IMIN IMAX")

Definition at line 262 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL31

#define MEAS_LABEL31 F("PMIN PMAX")

Definition at line 263 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL40

#define MEAS_LABEL40 F("VMIN VMAX")

Definition at line 264 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL41

#define MEAS_LABEL41 F("TMIN TMAX")

Definition at line 265 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL50

#define MEAS_LABEL50 F("TMIN TMAX")

Definition at line 266 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL51

#define MEAS_LABEL51 F("VDMIN VDMAX")

Definition at line 267 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL60

#define MEAS_LABEL60 F("CYCLE ALL")

Definition at line 268 of file DC2574A_KIT.ino.

## ◆ MEAS_LABEL61

#define MEAS_LABEL61 F("measurements")

Definition at line 269 of file DC2574A_KIT.ino.

## ◆ SCREEN_UPDATE_TIME

#define SCREEN_UPDATE_TIME 1000UL

Only one mode is possible at a time.

If I2C and SPI are both enabled, I2C mode will be used! update interval time in milli seconds

Definition at line 242 of file DC2574A_KIT.ino.

## ◆ SPLASH_SCREEN_DELAY

#define SPLASH_SCREEN_DELAY 3000UL

Definition at line 244 of file DC2574A_KIT.ino.

## ◆ USER_SEL_GRP1_COUNT

#define USER_SEL_GRP1_COUNT 9

Menu Group 1 count: STATUS STATVT STATIP STATC STATE STATCEOF STATTB STATVDVCC "CYCLE stats".

Definition at line 246 of file DC2574A_KIT.ino.

## ◆ USER_SEL_GRP1_CYCLE_COUNT

#define USER_SEL_GRP1_CYCLE_COUNT 8

Menu Group 1 cycle count: STATUS STATVT STATIP STATC STATE STATCEOF STATTB STATVDVCC.

Definition at line 248 of file DC2574A_KIT.ino.

## ◆ USER_SEL_GRP2_COUNT

#define USER_SEL_GRP2_COUNT 7

Menu group 2 count: RAW, ACCU1, ACCU2, Track1, Track2, Track3, "Cycle meas.".

Definition at line 250 of file DC2574A_KIT.ino.

## ◆ USER_SEL_GRP2_CYCLE_COUNT

#define USER_SEL_GRP2_CYCLE_COUNT 6

Menu Group 2 cycle count: RAW, ACCU1, ACCU2, Track1, Track2, Track3.

Definition at line 252 of file DC2574A_KIT.ino.

## ◆ USERGROUPCYCLETIMERRELOAD

#define USERGROUPCYCLETIMERRELOAD 3

defines how many cycles a single measurement group will be displayed on the LCD in case of "cycle all" (2 means each measurement is shown 3 times)

Definition at line 254 of file DC2574A_KIT.ino.

## Variable Documentation

## ◆ dc590Busy

boolean dc590Busy

DC590 busy check.

Declared and controlled by DC590_subset.ino true if DC590 is busy processing commands, false if not busy

DC590 busy check.

Asserted while DC590B command is processed

Definition at line 110 of file DC590_subset.ino.

## ◆ flagClear

boolean flagClear = false

flag to store actions from user input.

Definition at line 279 of file DC2574A_KIT.ino.

## ◆ lcd

LCDKeypad* lcd

pointer to the LCD keypad object

Definition at line 275 of file DC2574A_KIT.ino.

## ◆ nextUpdateTime

unsigned long nextUpdateTime = 0

The next update time.

Stores the next time stamp (used for timing of update task)

Definition at line 272 of file DC2574A_KIT.ino.

## ◆ previousKey

int8_t previousKey = KEYPAD_NONE
| static

The previous key.

Stores previously pressed key

Definition at line 277 of file DC2574A_KIT.ino.

## ◆ statusRegs

byte statusRegs[8]

array to store all status / alert registers

Definition at line 293 of file DC2574A_KIT.ino.

## ◆ statusRegsRead

boolean statusRegsRead = false

flag is asserted once after all status registers were read.

Definition at line 291 of file DC2574A_KIT.ino.

## ◆ userGroup1Cycle

boolean userGroup1Cycle = false

group 1 cycle enable

Definition at line 283 of file DC2574A_KIT.ino.

## ◆ userGroup2Cycle

boolean userGroup2Cycle = false

group 2 cycle enable

Definition at line 287 of file DC2574A_KIT.ino.

## ◆ userGroupCycleTimer

uint8_t userGroupCycleTimer = 0
| static

The user group cycle timer.

Definition at line 295 of file DC2574A_KIT.ino.

## ◆ userGroupSelect

boolean userGroupSelect = true

selected group 1: false, 2: true

Definition at line 289 of file DC2574A_KIT.ino.

## ◆ userSelGroup1

uint8_t userSelGroup1 = 0
| static

User selection of the first group.

Definition at line 281 of file DC2574A_KIT.ino.

## ◆ userSelGroup2

uint8_t userSelGroup2 = 0
| static

User selection of the second group.

Definition at line 285 of file DC2574A_KIT.ino.