Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC1812A-B.ino
Go to the documentation of this file.
1 /*!
2 DC1812A-B
3 LTC2944: Multicell Battery Gas Gauge with Temperature, Voltage and Current Measurement
4 
5 @verbatim
6 
7  Setup:
8  Apply a voltage source to the V_BATT terminal and a load at the V_CHRG/LD terminal.
9  Refer to the Demo Manual Guide for a detailed setup description. Ensure that JP1 is
10  set to AL# position.
11 
12  Explanation of Commands:
13 
14  1 - Automatic Mode - Scans Voltage, Current, Temperature and charge every 60ms.
15  Scanning interval has been increased to 1s for ease of reading on the Serial Prompt.
16  Displays an alert if it is set in the status register at the time of scan.
17 
18  2 - Scan Mode - Scans Voltage, Current, Temperature and charge every 10s.
19  Displays an alert if it is set in the status register at the time of scan.
20 
21  3 - Manual Mode - Provides a SnapShot of the Voltage, Current, Temperature and Accumulated Charge.
22  After the initial SnapShot, the part goes into sleep mode where it only counts charge.
23  Displays an alert if it is set in the status register at the time of scan.
24 
25  4 - Sleep Mode - The ADC portion of the LTC2944 is shutdown. In this mode only charge is accumulated.
26 
27  5 - Shutdown Mode - The LTC2944 goes into low power mode.
28 
29  6 - Settings - Allows user to set alert thresholds, set prescalar, set AL#/CC# pin mode and change the temperature and charge units.
30 
31 NOTES
32  Setup:
33  Set the terminal baud rate to 115200 and select the newline terminator.
34  Requires a power supply.
35  Refer to demo manual DC1812A-B.
36 
37 USER INPUT DATA FORMAT:
38  decimal : 1024
39  hex : 0x400
40  octal : 02000 (leading 0 "zero")
41  binary : B10000000000
42  float : 1024.0
43 
44 @endverbatim
45 
46 
47 Copyright 2018(c) Analog Devices, Inc.
48 
49 All rights reserved.
50 
51 Redistribution and use in source and binary forms, with or without
52 modification, are permitted provided that the following conditions are met:
53  - Redistributions of source code must retain the above copyright
54  notice, this list of conditions and the following disclaimer.
55  - Redistributions in binary form must reproduce the above copyright
56  notice, this list of conditions and the following disclaimer in
57  the documentation and/or other materials provided with the
58  distribution.
59  - Neither the name of Analog Devices, Inc. nor the names of its
60  contributors may be used to endorse or promote products derived
61  from this software without specific prior written permission.
62  - The use of this software may or may not infringe the patent rights
63  of one or more patent holders. This license does not release you
64  from the requirement that you obtain separate licenses from these
65  patent holders to use this software.
66  - Use of the software either in source or binary form, must be run
67  on or directly connected to an Analog Devices Inc. component.
68 
69 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
70 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
71 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
72 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
73 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
74 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
75 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
76 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
77 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
78 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
79  */
80 
81 /*! @file
82  @ingroup LTC2944
83 */
84 
85 #include <Arduino.h>
86 #include <stdint.h>
87 #include "Linduino.h"
88 #include "LT_I2C.h"
89 #include "UserInterface.h"
90 #include "QuikEval_EEPROM.h"
91 #include "LTC2944.h"
92 #include <Wire.h>
93 
94 
95 // Function Declaration
96 void print_title(); // Print the title block
97 void print_prompt(); // Print the Prompt
98 void store_alert_settings(); // Store the alert settings to the EEPROM
99 int8_t restore_alert_settings(); // Read the alert settings from EEPROM
100 
101 
102 #define AUTOMATIC_MODE_DISPLAY_DELAY 1000 //!< The delay between readings in automatic mode
103 #define SCAN_MODE_DISPLAY_DELAY 10000 //!< The delay between readings in scan mode
104 const float resistor = .100; //!< resistor value on demo board
105 
106 // Error string
107 const char ack_error[] = "Error: No Acknowledge. Check I2C Address."; //!< Error message
108 
109 
110 
111 // Global variables
112 static int8_t demo_board_connected; //!< Set to 1 if the board is connected
113 static uint8_t alert_code = 0; //!< Value stored or read from ALERT register. Shared between loop() and restore_alert_settings()
114 
115 //! Initialize Linduino
116 void setup()
117 {
118  char demo_name[] = "DC1812"; //! Demo Board Name stored in QuikEval EEPROM
119 
120  quikeval_I2C_init(); //! Configure the EEPROM I2C port for 100kHz
121  quikeval_I2C_connect(); //! Connects to main I2C port
122  Serial.begin(115200); //! Initialize the serial port to the PC
123  print_title();
126  {
127  print_prompt();
128  }
129  else
130  {
131  demo_board_connected = true;
132  Serial.println("Did not read ID String, attempting to proceed anyway...\nPlease ensure I2C lines of Linduino are connected to the LTC device");
133  print_prompt();
134  }
135 
136 
137 }
138 
139 
140 //! Repeats Linduino loop
141 void loop()
142 {
143  int8_t ack = 0; //! I2C acknowledge indicator
144  static uint8_t user_command; //! The user input command
145  static uint8_t mAh_or_Coulombs = 0;
146  static uint8_t celcius_or_kelvin = 0;
147  static uint16_t prescalar_mode = LTC2944_PRESCALAR_M_4096;
148  static uint16_t prescalarValue = 4096;
149  static uint16_t alcc_mode = LTC2944_ALERT_MODE;
150 
151  if (demo_board_connected) //! Do nothing if the demo board is not connected
152  {
153  if (Serial.available()) //! Do nothing if serial is not available
154  {
155  user_command = read_int(); //! Read user input command
156  if (user_command != 'm')
157  Serial.println(user_command);
158  Serial.println();
159  ack = 0;
160  switch (user_command) //! Prints the appropriate submenu
161  {
162  case 1:
163  ack |= menu_1_automatic_mode(mAh_or_Coulombs, celcius_or_kelvin, prescalar_mode, prescalarValue, alcc_mode); //! Automatic Mode
164  break;
165  case 2:
166  ack |= menu_2_scan_mode(mAh_or_Coulombs, celcius_or_kelvin, prescalar_mode, prescalarValue, alcc_mode); //! Scan Mode
167  break;
168  case 3:
169  ack |= menu_3_manual_mode(mAh_or_Coulombs, celcius_or_kelvin, prescalar_mode, prescalarValue, alcc_mode); //! Manual Mode
170  break;
171  case 4:
172  ack |= menu_4_sleep_mode(mAh_or_Coulombs, prescalar_mode, prescalarValue, alcc_mode); //! Sleep Mode
173  break;
174  case 5:
175  ack |= menu_5_shutdown_mode(); //! Shutdown Mode
176  break;
177  case 6:
178  ack |= menu_6_settings(&mAh_or_Coulombs, &celcius_or_kelvin, &prescalar_mode, &prescalarValue, &alcc_mode); //! Settings Mode
179  break;
180  }
181  if (ack != 0) //! If ack is not recieved print an error.
182  Serial.println(ack_error);
183  Serial.print(F("*************************"));
184  print_prompt();
185  }
186  }
187 }
188 
189 // Function Definitions
190 //! Print the title block
192 {
193  Serial.println(F("\n*****************************************************************"));
194  Serial.print(F("* DC1812A Demonstration Program *\n"));
195  Serial.print(F("* *\n"));
196  Serial.print(F("* This program communicates with the LTC2944 Multicell Coulomb *\n"));
197  Serial.print(F("* Counter found on the DC1812A demo board. *\n"));
198  Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
199  Serial.print(F("* *\n"));
200  Serial.print(F("*****************************************************************\n"));
201 }
202 
203 //! Print the Prompt
205 {
206  Serial.print(F("\n1-Automatic Mode\n"));
207  Serial.print(F("2-Scan Mode\n"));
208  Serial.print(F("3-Manual Mode\n"));
209  Serial.print(F("4-Sleep Mode\n"));
210  Serial.print(F("5-Shutdown Mode\n"));
211  Serial.print(F("6-Settings\n"));
212  Serial.print(F("Enter a command: "));
213 }
214 
215 //! Automatic Mode.
216 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)
217 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
218 {
219  int8_t LTC2944_mode;
220  int8_t ack = 0;
221  LTC2944_mode = LTC2944_AUTOMATIC_MODE|prescalar_mode|alcc_mode ; //! Set the control register of the LTC2944 to automatic mode as well as set prescalar and AL#/CC# pin values.
222  Serial.println();
223  ack |= LTC2944_write(LTC2944_I2C_ADDRESS, LTC2944_CONTROL_REG, LTC2944_mode); //! Writes the set mode to the LTC2944 control register
224 
225  do
226  {
227  Serial.print(F("*************************\n\n"));
228 
229  uint8_t status_code, hightemp_code, lowtemp_code;
230  uint16_t charge_code, current_code, voltage_code, temperature_code;
231 
232  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_ACCUM_CHARGE_MSB_REG, &charge_code); //! Read MSB and LSB Accumulated Charge Registers for 16 bit charge code
233  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_VOLTAGE_MSB_REG, &voltage_code); //! Read MSB and LSB Voltage Registers for 16 bit voltage code
234  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_CURRENT_MSB_REG, &current_code); //! Read MSB and LSB Current Registers for 16 bit current code
235  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_TEMPERATURE_MSB_REG, &temperature_code); //! Read MSB and LSB Temperature Registers for 16 bit temperature code
236  ack |= LTC2944_read(LTC2944_I2C_ADDRESS, LTC2944_STATUS_REG, &status_code); //! Read Status Register for 8 bit status code
237 
238 
239  float charge, current, voltage, temperature;
240  if (mAh_or_Coulombs)
241  {
242  charge = LTC2944_code_to_coulombs(charge_code, resistor, prescalarValue); //! Convert charge code to Coulombs if Coulomb units are desired.
243  Serial.print("Coulombs: ");
244  Serial.print(charge, 4);
245  Serial.print(F(" C\n"));
246  }
247  else
248  {
249  charge = LTC2944_code_to_mAh(charge_code, resistor, prescalarValue); //! Convert charge code to mAh if mAh units are desired.
250  Serial.print("mAh: ");
251  Serial.print(charge, 4);
252  Serial.print(F(" mAh\n"));
253  }
254 
255 
256  current = LTC2944_code_to_current(current_code, resistor); //! Convert current code to Amperes
257  voltage = LTC2944_code_to_voltage(voltage_code); //! Convert voltage code to Volts
258 
259  Serial.print(F("Current "));
260  Serial.print(current, 4);
261  Serial.print(F(" A\n"));
262 
263  Serial.print(F("Voltage "));
264  Serial.print(voltage, 4);
265  Serial.print(F(" V\n"));
266 
267 
268  if (celcius_or_kelvin)
269  {
270  temperature = LTC2944_code_to_kelvin_temperature(temperature_code); //! Convert temperature code to kelvin
271  Serial.print(F("Temperature "));
272  Serial.print(temperature, 4);
273  Serial.print(F(" K\n"));
274  }
275  else
276  {
277  temperature = LTC2944_code_to_celcius_temperature(temperature_code); //! Convert temperature code to celcius
278  Serial.print(F("Temperature "));
279  Serial.print(temperature, 4);
280  Serial.print(F(" C\n"));
281  }
282 
283  checkAlerts(status_code); //! Check status code for Alerts. If an Alert has been set, print out appropriate message in the Serial Prompt.
284 
285  Serial.print(F("m-Main Menu\n\n"));
286 
287  Serial.flush();
288  delay(AUTOMATIC_MODE_DISPLAY_DELAY); //! Delay for 1s before next polling
289  }
290  while (Serial.available() == false && !(ack)); //! if Serial is not available and an NACK has not been recieved, keep polling the registers.
291  read_int(); // clears the Serial.available
292  return(ack);
293 }
294 
295 //! Scan Mode
296 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)
297 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
298 {
299  int8_t LTC2944_mode;
300  int8_t ack = 0;
301  LTC2944_mode = LTC2944_SCAN_MODE|prescalar_mode|alcc_mode ; //! Set the control mode of the LTC2944 to scan mode as well as set prescalar and AL#/CC# pin values.
302  Serial.println();
303  ack |= LTC2944_write(LTC2944_I2C_ADDRESS, LTC2944_CONTROL_REG, LTC2944_mode); //! Writes the set mode to the LTC2944 control register
304 
305  do
306  {
307  Serial.print(F("*************************\n\n"));
308 
309  uint8_t status_code;
310  uint16_t charge_code, current_code, voltage_code, temperature_code;
311 
312 
313  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_ACCUM_CHARGE_MSB_REG, &charge_code); //! Read MSB and LSB Accumulated Charge Registers for 16 bit charge code
314  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_VOLTAGE_MSB_REG, &voltage_code); //! Read MSB and LSB Voltage Registers for 16 bit voltage code
315  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_CURRENT_MSB_REG, &current_code); //! Read MSB and LSB Current Registers for 16 bit current code
316  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_TEMPERATURE_MSB_REG, &temperature_code); //! Read MSB and LSB Temperature Registers for 16 bit temperature code
317  ack |= LTC2944_read(LTC2944_I2C_ADDRESS, LTC2944_STATUS_REG, &status_code); //! Read Status Registers for 8 bit status code
318 
319  float charge, current, voltage, temperature;
320  if (mAh_or_Coulombs)
321  {
322  charge = LTC2944_code_to_coulombs(charge_code, resistor, prescalarValue); //! Convert charge code to Coulombs if Coulomb units are desired.
323  Serial.print("Coulombs: ");
324  Serial.print(charge, 4);
325  Serial.print(F(" C\n"));
326  }
327  else
328  {
329  charge = LTC2944_code_to_mAh(charge_code, resistor, prescalarValue); //! Convert charge code to mAh if mAh units are desired.
330  Serial.print("mAh: ");
331  Serial.print(charge, 4);
332  Serial.print(F(" mAh\n"));
333  }
334 
335 
336  current = LTC2944_code_to_current(current_code, resistor); //! Convert current code to Amperes
337  voltage = LTC2944_code_to_voltage(voltage_code); //! Convert voltage code to Volts
338 
339 
340  Serial.print(F("Current "));
341  Serial.print(current, 4);
342  Serial.print(F(" A\n"));
343 
344  Serial.print(F("Voltage "));
345  Serial.print(voltage, 4);
346  Serial.print(F(" V\n"));
347 
348 
349  if (celcius_or_kelvin)
350  {
351  temperature = LTC2944_code_to_kelvin_temperature(temperature_code); //! Convert temperature code to Kelvin if Kelvin units are desired.
352  Serial.print(F("Temperature "));
353  Serial.print(temperature, 4);
354  Serial.print(F(" K\n"));
355  }
356  else
357  {
358  temperature = LTC2944_code_to_celcius_temperature(temperature_code); //! Convert temperature code to Celcius if Celcius units are desired.
359  Serial.print(F("Temperature "));
360  Serial.print(temperature, 4);
361  Serial.print(F(" C\n"));
362  }
363  checkAlerts(status_code); //! Check status code for Alerts. If an Alert has been set, print out appropriate message in the Serial Prompt
364 
365  Serial.print(F("m-Main Menu\n\n"));
366 
367  Serial.flush();
369  }
370  while (Serial.available() == false && !(ack));
371  read_int(); // clears the Serial.available
372  return(ack);
373 
374 }
375 
376 //! Manual Mode
377 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)
378 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
379 {
380  int8_t LTC2944_mode;
381  int8_t ack = 0;
382  LTC2944_mode = LTC2944_MANUAL_MODE|prescalar_mode|alcc_mode ; //! Set the control mode of the LTC2944 to manual mode as well as set prescalar and AL#/CC# pin values.
383  Serial.println();
384  ack |= LTC2944_write(LTC2944_I2C_ADDRESS, LTC2944_CONTROL_REG, LTC2944_mode); //! Writes the set mode to the LTC2944 control register
385 
386  int staleData = 0; //! Stale Data Check variable. When set to 1 it indicates that stale data is being read from the voltage, current and temperature registers.
387 
388  do
389  {
390  Serial.print(F("*************************\n\n"));
391 
392  uint8_t status_code;
393  uint16_t charge_code, current_code, voltage_code, temperature_code;
394 
395 
396  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_ACCUM_CHARGE_MSB_REG, &charge_code); //! Read MSB and LSB Accumulated Charge Registers for 16 bit charge code
397  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_VOLTAGE_MSB_REG, &voltage_code); //! Read MSB and LSB Voltage Registers for 16 bit voltage code
398  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_CURRENT_MSB_REG, &current_code); //! Read MSB and LSB Current Registers for 16 bit current code
399  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_TEMPERATURE_MSB_REG, &temperature_code); //! Read MSB and LSB Temperature Registers for 16 bit temperature code
400  ack |= LTC2944_read(LTC2944_I2C_ADDRESS, LTC2944_STATUS_REG, &status_code); //! Read Status Registers for 8 bit status code
401 
402 
403  float charge, current, voltage, temperature;
404  if (mAh_or_Coulombs)
405  {
406  charge = LTC2944_code_to_coulombs(charge_code, resistor, prescalarValue); //! Convert charge code to Coulombs if Coulomb units are desired.
407  Serial.print("Coulombs: ");
408  Serial.print(charge, 4);
409  Serial.print(F(" C\n"));
410  }
411  else
412  {
413  charge = LTC2944_code_to_mAh(charge_code, resistor, prescalarValue); //! Convert charge code to mAh if mAh units are desired.
414  Serial.print("mAh: ");
415  Serial.print(charge, 4);
416  Serial.print(F(" mAh\n"));
417  }
418 
419 
420  current = LTC2944_code_to_current(current_code, resistor); //! Convert current code to Amperes
421  voltage = LTC2944_code_to_voltage(voltage_code); //! Convert voltage code to Volts
422 
423 
424  Serial.print(F("Current "));
425  Serial.print(current, 4);
426  Serial.print(F(" A"));
427  if (staleData) Serial.print(F(" ***** Stale Data ******\n")); //! If Stale data is inside the register after initial snapshot, Print Stale Data message.
428  else Serial.println("");
429 
430  Serial.print(F("Voltage "));
431  Serial.print(voltage, 4);
432  Serial.print(F(" V"));
433  if (staleData) Serial.print(F(" ***** Stale Data ******\n")); //! If Stale data is inside the register after initial snapshot, Print Stale Data message.
434  else Serial.println("");
435 
436 
437  if (celcius_or_kelvin)
438  {
439  temperature = LTC2944_code_to_kelvin_temperature(temperature_code); //! Convert temperature code to Kelvin if Kelvin units are desired.
440  Serial.print(F("Temperature "));
441  Serial.print(temperature, 4);
442  Serial.print(F(" K"));
443  }
444  else
445  {
446  temperature = LTC2944_code_to_celcius_temperature(temperature_code); //! Convert temperature code to Celcius if Celcius units are desired.
447  Serial.print(F("Temperature "));
448  Serial.print(temperature, 4);
449  Serial.print(F(" C"));
450  }
451  if (staleData) Serial.print(F(" ***** Stale Data ******\n"));
452  else Serial.println("");
453 
454 
455  checkAlerts(status_code); //! Check status code for Alerts. If an Alert has been set, print out appropriate message in the Serial Prompt
456 
457 
458  Serial.print(F("m-Main Menu\n\n"));
459 
460  staleData = 1;
461  Serial.flush();
463  }
464  while (Serial.available() == false && !(ack));
465  read_int(); // clears the Serial.available
466  return(ack);
467 }
468 
469 //! Sleep Mode
470 int8_t menu_4_sleep_mode(int8_t mAh_or_Coulombs ,uint16_t prescalar_mode, uint16_t prescalarValue, uint16_t alcc_mode)
471 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
472 {
473  int8_t LTC2944_mode;
474  int8_t ack = 0;
475  LTC2944_mode = LTC2944_SLEEP_MODE|prescalar_mode|alcc_mode ; //! Set the control mode of the LTC2944 to sleep mode as well as set prescalar and AL#/CC# pin values.
476  Serial.println();
477  ack |= LTC2944_write(LTC2944_I2C_ADDRESS, LTC2944_CONTROL_REG, LTC2944_mode); //! Writes the set mode to the LTC2944 control register
478 
479 
480  do
481  {
482  Serial.print(F("*************************\n\n"));
483  delay(100);
484  uint8_t status_code;
485  uint16_t charge_code;
486 
487 
488  ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_ACCUM_CHARGE_MSB_REG, &charge_code); //! Read MSB and LSB Accumulated Charge Registers for 16 bit charge code
489  ack |= LTC2944_read(LTC2944_I2C_ADDRESS, LTC2944_STATUS_REG, &status_code); //! Read Status Registers for 8 bit status code
490 
491 
492  float charge;
493  if (mAh_or_Coulombs)
494  {
495  charge = LTC2944_code_to_coulombs(charge_code, resistor, prescalarValue); //! Convert charge code to Coulombs if Coulomb units are desired.
496  Serial.print("Coulombs: ");
497  Serial.print(charge, 4);
498  Serial.print(F(" C\n"));
499  }
500  else
501  {
502  charge = LTC2944_code_to_mAh(charge_code, resistor, prescalarValue); //! Convert charge code to mAh if mAh units are desired.
503  Serial.print("mAh: ");
504  Serial.print(charge, 4);
505  Serial.print(F(" mAh\n"));
506  }
507 
508  Serial.print(F("Current "));
509  Serial.print(F(" ADC Sleep...\n"));
510 
511 
512  Serial.print(F("Voltage "));
513  Serial.print(F(" ADC Sleep...\n"));
514 
515  Serial.print(F("Temperature "));
516  Serial.print(F(" ADC Sleep...\n"));
517 
518  Serial.print(F("m-Main Menu\n\n"));
519 
520  checkAlerts(status_code);
521 
522  Serial.flush();
524  }
525  while (Serial.available() == false || (ack));
526  read_int(); // clears the Serial.available
527  return(ack);
528 }
529 
530 //! Shutdown Mode
532 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
533 {
534  int8_t ack = 0;
535  ack |= LTC2944_write(LTC2944_I2C_ADDRESS, LTC2944_CONTROL_REG, LTC2944_SHUTDOWN_MODE); //! Sets the LTC2944 into shutdown mode
536  Serial.print("LTC2944 Has Been ShutDown\n");
537  return(ack);
538 }
539 //! Settings Menu
540 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)
541 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
542 {
543  int8_t ack = 0;
544  int8_t user_command;
545  do
546  {
547  Serial.print(F("*************************\n\n"));
548  Serial.print(F("1-Set Alert Thresholds\n"));
549  Serial.print(F("2-Set Prescalar Value\n"));
550  Serial.print(F("3-Set AL#/CC# Pin State\n"));
551  Serial.print(F("4-Set Units\n"));
552  Serial.print(F("m-Main Menu\n\n"));
553  Serial.print(F("Enter a command: "));
554 
555  user_command = read_int();
556  if (user_command == 'm')
557  Serial.println("m");
558  else
559  Serial.println(user_command);
560  Serial.println();
561  switch (user_command)
562  {
563  case 1:
564  ack |= menu_6_settings_menu_1_set_alert_thresholds(); //! Settings Menu to set Alert Thresholds
565  break;
566 
567  case 2:
568  ack |= menu_6_settings_menu_2_set_prescalar_values(prescalar_mode, prescalarValue); //! Settings Menu to set Prescalar Values
569  break;
570 
571  case 3:
572  ack |= menu_6_alert_menu_3_set_allcc_state(alcc_mode); //! Settings Menu to set AL#/CC# mode
573  break;
574 
575  case 4:
576  ack |= menu_6_alert_menu_4_set_units(mAh_or_Coulombs, celcius_or_kelvin); //! Settings Menu to set Temperature and Charge Units
577  break;
578 
579  default:
580  if (user_command != 'm')
581  Serial.println("Incorrect Option");
582  break;
583  }
584  }
585  while (!((user_command == 'm') || (ack)));
586  return(ack);
587 
588 }
589 
590 //! Alert Threshold Menu
592 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
593 {
594  int8_t ack = 0;
595  int8_t user_command;
596  do
597  {
598  Serial.print(F("*************************\n\n"));
599  Serial.print(F("1-Set Charge Thresholds\n"));
600  Serial.print(F("2-Set Voltage Thresholds\n"));
601  Serial.print(F("3-Set Current Thresholds\n"));
602  Serial.print(F("4-Set Temperature Thresholds\n"));
603  Serial.print(F("m-Main Menu\n\n"));
604  Serial.print(F("Enter a command: "));
605 
606  user_command = read_int();
607  if (user_command == 'm')
608  Serial.println("m");
609  else
610  Serial.println(user_command);
611  Serial.println();
612  switch (user_command)
613  {
614  case 1:
615  ack |= menu_6_alert_menu_1_set_charge_thresholds(); //! Set Max and Min Charge Thresholds. The ACR charge lsb size changes with respect to the prescalar and sense resistor value. Due to this variability, for the purpose of this demo enter values in hexadecimal.
616  break;
617  case 2:
618  ack |= menu_6_alert_menu_2_set_voltage_thresholds(); //! Set Max and Min Voltage Thresholds. Enter Values in Volts
619  break;
620  case 3:
621  ack |= menu_6_alert_menu_3_set_current_thresholds(); //! Set Max and Min Current Thresholds. Enter Values in Amperes.
622  break;
623  case 4:
624  ack |= menu_6_alert_menu_4_set_temperature_thresholds(); //! Set Max and Min Temperature Thresholds. Enter Values in Celcius.
625  break;
626  default:
627  if (user_command != 'm')
628  Serial.println("Incorrect Option");
629  break;
630  }
631  }
632  while (!((user_command == 'm') || (ack)));
633  return(ack);
634 
635 }
636 //! Set Charge Threshold Function
638 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
639 {
640  int8_t ack = 0;
641  Serial.print(F("Enter RAW Max Charge Threshold:"));
642 
643  uint16_t max_charge_threshold;
644  max_charge_threshold = read_int(); //! Read user entered value
645  Serial.println(max_charge_threshold);
646 
647  ack |= LTC2944_write_16_bits(LTC2944_I2C_ADDRESS, LTC2944_CHARGE_THRESH_HIGH_MSB_REG, max_charge_threshold); //! write user entered value to HIGH threshold register
648 
649  Serial.print(F("Enter RAW Min Charge Threshold:"));
650 
651  float min_charge_threshold;
652  min_charge_threshold = read_int(); //! Read user entered value
653  Serial.println(min_charge_threshold);
654 
655  ack |= LTC2944_write_16_bits(LTC2944_I2C_ADDRESS, LTC2944_CHARGE_THRESH_LOW_MSB_REG, min_charge_threshold); //! write user entered value to HIGH threshold register
656  return(ack);
657 
658 }
659 
660 //! Set Voltage Thresholds
662 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
663 {
664  int8_t ack = 0;
665  Serial.print(F("Enter Max Voltage Threshold:"));
666 
667  float max_voltage_threshold;
668  max_voltage_threshold = read_float(); //! Read user entered value
669  Serial.print(max_voltage_threshold, 3);
670  Serial.println("V");
671 
672  uint16_t max_voltage_threshold_code = max_voltage_threshold*(0xFFFF)/(LTC2944_FULLSCALE_VOLTAGE); //! Convert user entered voltage into adc code.
673 
674  ack |= LTC2944_write_16_bits(LTC2944_I2C_ADDRESS, LTC2944_VOLTAGE_THRESH_HIGH_MSB_REG, max_voltage_threshold_code); //! Write adc code to HIGH threshold register
675 
676  Serial.print(F("Enter Min Voltage Threshold:"));
677 
678  float min_voltage_threshold;
679  min_voltage_threshold = read_float(); //! Read user entered value
680  Serial.println(min_voltage_threshold, 3);
681  Serial.println("V");
682 
683  uint16_t min_voltage_threshold_code = min_voltage_threshold*(0xFFFF)/(LTC2944_FULLSCALE_VOLTAGE); //! Convert user entered voltage into adc code.
684 
685  ack |= LTC2944_write_16_bits(LTC2944_I2C_ADDRESS, LTC2944_VOLTAGE_THRESH_LOW_MSB_REG, min_voltage_threshold_code); //! Write adc code to LOW threshold register
686  return(ack);
687 }
688 //! Set Current Thresholds
690 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
691 {
692  int8_t ack = 0;
693  Serial.print(F("Enter Max Current Threshold:"));
694 
695  float max_current_threshold;
696  max_current_threshold = read_float(); //! Read user entered value
697  Serial.print(max_current_threshold, 3);
698  Serial.println("A");
699 
700  uint16_t max_current_threshold_code = resistor*max_current_threshold*(0x7FFF)/(LTC2944_FULLSCALE_CURRENT) + 0x7FFF; //! Convert user entered current into adc code.
701 
702  ack |= LTC2944_write_16_bits(LTC2944_I2C_ADDRESS, LTC2944_CURRENT_THRESH_HIGH_MSB_REG, max_current_threshold_code); //! Write adc code to HIGH threshold register
703 
704  Serial.print(F("Enter Min Current Threshold:"));
705 
706  float min_current_threshold;
707  min_current_threshold = read_float(); //! Read user entered value
708  Serial.print(min_current_threshold, 3);
709  Serial.println("A");
710 
711  uint16_t min_current_threshold_code = resistor*min_current_threshold*(0x7FFF)/(LTC2944_FULLSCALE_CURRENT) + 0x7FFF; //! Convert user entered current into adc code.
712 
713  ack |= LTC2944_write_16_bits(LTC2944_I2C_ADDRESS, LTC2944_CURRENT_THRESH_LOW_MSB_REG, min_current_threshold_code); //! Write adc code to LOW threshold register
714  return(ack);
715 }
716 
717 //! Set Temperature Thresholds
719 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
720 {
721  int8_t ack = 0;
722  Serial.print(F("Enter Max Temperature Threshold in Celcius:"));
723 
724  float max_temperature_threshold;
725  max_temperature_threshold = read_float(); //! Read user entered value
726  Serial.print(max_temperature_threshold, 2);
727  Serial.println("C");
728 
729  uint16_t max_temperature_threshold_code = (max_temperature_threshold + 273.15)*(0xFFFF)/(LTC2944_FULLSCALE_TEMPERATURE); //! Convert user entered temperature into adc code.
730 
731 
732  ack |= LTC2944_write_16_bits(LTC2944_I2C_ADDRESS, LTC2944_TEMPERATURE_THRESH_HIGH_REG, max_temperature_threshold_code); //! Write adc code to HIGH threshold register
733 
734  Serial.print(F("Enter Min Temperature Threshold in Celcius:"));
735 
736  float min_temperature_threshold;
737  min_temperature_threshold = read_float(); //! Read user entered value
738  Serial.print(min_temperature_threshold, 2);
739  Serial.println("C");
740 
741  uint16_t min_temperature_threshold_code = (min_temperature_threshold + 273.15)*(0xFFFF)/(LTC2944_FULLSCALE_TEMPERATURE); //! Convert user entered temperature into adc code.
742 
743  ack |= LTC2944_write_16_bits(LTC2944_I2C_ADDRESS, LTC2944_TEMPERATURE_THRESH_LOW_REG, min_temperature_threshold_code); //! Write adc code to LOW threshold register
744  return(ack);
745 
746 }
747 
748 //! Prescalar Menu
749 int8_t menu_6_settings_menu_2_set_prescalar_values(uint16_t *prescalar_mode, uint16_t *prescalarValue)
750 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
751 {
752  int8_t ack = 0;
753  int8_t user_command;
754  do
755  {
756  Serial.print(F("*************************\n\n"));
757  Serial.print(F("1-Set Prescalar M = 1\n"));
758  Serial.print(F("2-Set Prescalar M = 4\n"));
759  Serial.print(F("3-Set Prescalar M = 16\n"));
760  Serial.print(F("4-Set Prescalar M = 64\n"));
761  Serial.print(F("5-Set Prescalar M = 256\n"));
762  Serial.print(F("6-Set Prescalar M = 1024\n"));
763  Serial.print(F("7-Set Prescalar M = 4096\n"));
764  Serial.print(F("m-Main Menu\n\n"));
765  Serial.print(F("Enter a command: "));
766 
767  user_command = read_int();
768  if (user_command == 'm')
769  Serial.println("m");
770  else
771  Serial.println(user_command);
772  Serial.println();
773  switch (user_command)
774  {
775  case 1:
776  *prescalar_mode = LTC2944_PRESCALAR_M_1; //! Set Prescalar Value M = 1
777  *prescalarValue = 1;
778  Serial.println(F("\nPrescalar Set to 1\n"));
779  break;
780  case 2:
781  *prescalar_mode = LTC2944_PRESCALAR_M_4; //! Set Prescalar Value M = 4
782  *prescalarValue = 4;
783  Serial.println(F("\nPrescalar Set to 4\n"));
784  break;
785  case 3:
786  *prescalar_mode = LTC2944_PRESCALAR_M_16; //! Set Prescalar Value M = 16
787  *prescalarValue = 16;
788  Serial.println(F("\nPrescalar Set to 16\n"));
789  break;
790  case 4:
791  *prescalar_mode = LTC2944_PRESCALAR_M_64; //! Set Prescalar Value M = 64
792  *prescalarValue = 64;
793  Serial.println(F("\nPrescalar Set to 64\n"));
794  break;
795  case 5:
796  *prescalar_mode = LTC2944_PRESCALAR_M_256; //! Set Prescalar Value M = 256
797  *prescalarValue = 256;
798  Serial.println(F("\nPrescalar Set to 256\n"));
799  break;
800  case 6:
801  *prescalar_mode = LTC2944_PRESCALAR_M_1024; //! Set Prescalar Value M = 1024
802  *prescalarValue = 1024;
803  \
804  Serial.println(F("\nPrescalar Set to 1024\n"));
805  break;
806  case 7:
807  *prescalar_mode = LTC2944_PRESCALAR_M_4096; //! Set Prescalar Value M = 4096
808  *prescalarValue = 4096;
809  Serial.println(F("\nPrescalar Set to 4096\n"));
810  break;
811  default:
812  if (user_command != 'm')
813  Serial.println("Incorrect Option");
814  break;
815  }
816  }
817  while (!((user_command == 'm') || (ack)));
818  return(ack);
819 }
820 
821 //! AL#/CC# Pin Mode Menu
822 uint8_t menu_6_alert_menu_3_set_allcc_state(uint16_t *alcc_mode)
823 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
824 {
825  int8_t ack = 0;
826  int8_t user_command;
827  do
828  {
829  Serial.print(F("*************************\n\n"));
830  Serial.print(F("1-Enable Alert Mode\n"));
831  Serial.print(F("2-Enable Charge Complete Mode\n"));
832  Serial.print(F("3-Disable AL#/CC# Pin\n"));
833  Serial.print(F("m-Main Menu\n\n"));
834  Serial.print(F("Enter a command: "));
835 
836  user_command = read_int();
837  if (user_command == 'm')
838  Serial.println("m");
839  else
840  Serial.println(user_command);
841  Serial.println();
842  switch (user_command)
843  {
844  case 1:
845  *alcc_mode = LTC2944_ALERT_MODE; //! Set AL#/CC# mode to Alert Mode
846  Serial.println(F("\nAlert Mode Enabled\n"));
847  break;
848  case 2:
849  *alcc_mode = LTC2944_CHARGE_COMPLETE_MODE; //! Set AL#/CC# mode to Charge Complete Mode
850  Serial.println(F("\nCharge Mode Enabled\n"));
851  break;
852  case 3:
853  *alcc_mode = LTC2944_DISABLE_ALCC_PIN; //! Disable AL#/CC# pin.
854  Serial.println(F("\nAL#/CC# Pin Disabled\n"));
855  break;
856  default:
857  if (user_command != 'm')
858  Serial.println("Incorrect Option");
859  break;
860  }
861  }
862  while (!((user_command == 'm') || (ack)));
863  return(ack);
864 }
865 
866 //! Set Charge and Temperature Units Menu
867 uint8_t menu_6_alert_menu_4_set_units(uint8_t *mAh_or_Coulombs, uint8_t *celcius_or_kelvin)
868 //! @return Returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
869 {
870  int8_t ack = 0;
871  int8_t user_command;
872  do
873  {
874  Serial.print(F("*************************\n\n"));
875  Serial.print(F("1-Set Charge Units to mAh\n"));
876  Serial.print(F("2-Set Charge Units to Coulombs\n"));
877  Serial.print(F("3-Set Temperature Units to Celsius\n"));
878  Serial.print(F("4-Set Temperature Units to Kelvin\n"));
879  Serial.print(F("m-Main Menu\n\n"));
880  Serial.print(F("Enter a command: "));
881 
882  user_command = read_int();
883  if (user_command == 'm')
884  Serial.println("m");
885  else
886  Serial.println(user_command);
887  Serial.println();
888  switch (user_command)
889  {
890  case 1:
891  *mAh_or_Coulombs = 0;
892  Serial.println(F("\nCharge Units Set to mAh\n"));
893  break;
894  case 2:
895  *mAh_or_Coulombs = 1;
896  Serial.println(F("\nCharge Units Set to Coulombs\n"));
897  break;
898  case 3:
899  *celcius_or_kelvin = 0;
900  Serial.println(F("\nTemperature Units Set to Celcius\n"));
901  break;
902  case 4:
903  *celcius_or_kelvin = 1;
904  Serial.println(F("\nTemperature Units Set to Kelvin\n"));
905  break;
906  default:
907  if (user_command != 'm')
908  Serial.println("Incorrect Option");
909  break;
910  }
911 
912  }
913  while (!((user_command == 'm') || (ack)));
914  return(ack);
915 
916 }
917 
918 //! Checks to see if a bit in a certain position is set.
919 bool isBitSet(uint8_t value, uint8_t position)
920 //! @return Returns the state of a bit at "position" in a byte. 1 = Set, 0 = Not Set
921 {
922  return((1<<position)&value);
923 }
924 //! 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.
925 void checkAlerts(uint8_t status_code)
926 //! @return
927 {
928  if (isBitSet(status_code,6))
929  {
930  Serial.print(F("\n***********************\n"));
931  Serial.print(F("Alert: "));
932  Serial.print(F("Current Alert\n"));
933  Serial.print(F("***********************\n"));
934  }
935  if (isBitSet(status_code,5))
936  {
937  Serial.print(F("\n***********************\n"));
938  Serial.print(F("Alert: "));
939  Serial.print(F("Charge Over/Under Flow Alert\n"));
940  Serial.print(F("***********************\n"));
941  }
942  if (isBitSet(status_code,4))
943  {
944  Serial.print(F("\n***********************\n"));
945  Serial.print(F("Alert: "));
946  Serial.print(F("Temperature Alert\n"));
947  Serial.print(F("***********************\n"));
948  }
949  if (isBitSet(status_code,3))
950  {
951  Serial.print(F("\n***********************\n"));
952  Serial.print(F("Alert: "));
953  Serial.print(F("Charge High Alert\n"));
954  Serial.print(F("***********************\n"));
955  }
956  if (isBitSet(status_code,2))
957  {
958  Serial.print(F("\n***********************\n"));
959  Serial.print(F("Alert: "));
960  Serial.print(F("Charge Low Alert\n"));
961  Serial.print(F("***********************\n"));
962  }
963  if (isBitSet(status_code,1))
964  {
965  Serial.print(F("\n***********************\n"));
966  Serial.print(F("Alert: "));
967  Serial.print(F("Voltage Alert\n"));
968  Serial.print(F("***********************\n"));
969  }
970  if (isBitSet(status_code,0))
971  {
972  Serial.print(F("\n***********************\n"));
973  Serial.print(F("Alert: "));
974  Serial.print(F("UVLO Alert\n"));
975  Serial.print(F("***********************\n"));
976  }
977 }
978 
#define LTC2944_ALERT_MODE
Definition: LTC2944.h:192
#define LTC2944_AUTOMATIC_MODE
Definition: LTC2944.h:178
unsigned char user_command
#define LTC2944_SLEEP_MODE
Definition: LTC2944.h:181
#define LTC2944_I2C_ADDRESS
Definition: LTC2944.h:91
#define LTC2944_PRESCALAR_M_1024
Definition: LTC2944.h:188
static uint8_t alert_code
Value stored or read from ALERT register.
Definition: DC1812A-B.ino:113
#define LTC2944_TEMPERATURE_MSB_REG
Definition: LTC2944.h:148
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.
Definition: DC1812A-B.ino:377
static int8_t menu_6_settings_menu_2_set_prescalar_values(uint16_t *prescalar_mode, uint16_t *prescalarValue)
Prescalar Menu.
Definition: DC1812A-B.ino:749
#define LTC2944_CHARGE_COMPLETE_MODE
Definition: LTC2944.h:193
#define LTC2944_SCAN_MODE
Definition: LTC2944.h:179
#define LTC2944_ACCUM_CHARGE_MSB_REG
Definition: LTC2944.h:130
const float LTC2944_FULLSCALE_CURRENT
Definition: LTC2944.h:207
Header File for Linduino Libraries and Demo Code.
bool isBitSet(uint8_t value, uint8_t position)
Checks to see if a bit in a certain position is set.
Definition: DC1812A-B.ino:919
static void setup()
Initialize Linduino.
Definition: DC1812A-B.ino:116
#define LTC2944_PRESCALAR_M_64
Definition: LTC2944.h:186
#define LTC2944_CHARGE_THRESH_LOW_MSB_REG
Definition: LTC2944.h:134
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.
Definition: DC1812A-B.ino:925
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.
Definition: DC1812A-B.ino:216
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.
Definition: DC1812A-B.ino:540
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.
Definition: DC1812A-B.ino:867
#define LTC2944_STATUS_REG
Definition: LTC2944.h:128
static uint8_t menu_6_alert_menu_3_set_allcc_state(uint16_t *alcc_mode)
AL#/CC# Pin Mode Menu.
Definition: DC1812A-B.ino:822
static void print_title()
Print the title block.
Definition: DC1812A-B.ino:191
#define LTC2944_DISABLE_ALCC_PIN
Definition: LTC2944.h:195
#define LTC2944_CURRENT_THRESH_HIGH_MSB_REG
Definition: LTC2944.h:144
float LTC2944_code_to_celcius_temperature(uint16_t adc_code)
Calculate the LTC2944 temperature.
Definition: LTC2944.cpp:161
#define LTC2944_VOLTAGE_THRESH_HIGH_MSB_REG
Definition: LTC2944.h:138
static int8_t menu_6_alert_menu_1_set_charge_thresholds()
Set Charge Threshold Function.
Definition: DC1812A-B.ino:637
#define LTC2944_CONTROL_REG
Definition: LTC2944.h:129
#define LTC2944_PRESCALAR_M_4
Definition: LTC2944.h:184
float LTC2944_code_to_mAh(uint16_t adc_code, float resistor, uint16_t prescalar)
Calculate the LTC2944 charge in mAh.
Definition: LTC2944.cpp:129
int8_t LTC2944_read(uint8_t i2c_address, uint8_t adc_command, uint8_t *adc_code)
Reads an 8-bit adc_code from LTC2944.
Definition: LTC2944.cpp:98
#define LTC2944_CURRENT_THRESH_LOW_MSB_REG
Definition: LTC2944.h:146
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.
Definition: DC1812A-B.ino:296
const float LTC2944_FULLSCALE_VOLTAGE
Definition: LTC2944.h:206
const char ack_error[]
Error message.
Definition: DC1812A-B.ino:107
#define LTC2944_MANUAL_MODE
Definition: LTC2944.h:180
static void print_prompt()
Print the Prompt.
Definition: DC1812A-B.ino:204
#define LTC2944_PRESCALAR_M_1
Definition: LTC2944.h:183
#define LTC2944_VOLTAGE_THRESH_LOW_MSB_REG
Definition: LTC2944.h:140
static int8_t menu_5_shutdown_mode()
Shutdown Mode.
Definition: DC1812A-B.ino:531
#define LTC2944_PRESCALAR_M_4096
Definition: LTC2944.h:189
QuikEval EEPROM Library.
static int8_t menu_6_settings_menu_1_set_alert_thresholds()
Alert Threshold Menu.
Definition: DC1812A-B.ino:591
#define LTC2944_CHARGE_THRESH_HIGH_MSB_REG
Definition: LTC2944.h:132
float LTC2944_code_to_kelvin_temperature(uint16_t adc_code)
Calculate the LTC2944 temperature.
Definition: LTC2944.cpp:153
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
float LTC2944_code_to_voltage(uint16_t adc_code)
Calculate the LTC2944 SENSE+ voltage.
Definition: LTC2944.cpp:137
#define LTC2944_TEMPERATURE_THRESH_LOW_REG
Definition: LTC2944.h:151
#define LTC2944_TEMPERATURE_THRESH_HIGH_REG
Definition: LTC2944.h:150
const float LTC2944_FULLSCALE_TEMPERATURE
Definition: LTC2944.h:208
#define AUTOMATIC_MODE_DISPLAY_DELAY
The delay between readings in automatic mode.
Definition: DC1812A-B.ino:102
static void loop()
Repeats Linduino loop.
Definition: DC1812A-B.ino:141
#define SCAN_MODE_DISPLAY_DELAY
The delay between readings in scan mode.
Definition: DC1812A-B.ino:103
int8_t LTC2944_write_16_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t code)
Write a 16-bit code to the LTC2944.
Definition: LTC2944.cpp:88
static int8_t menu_6_alert_menu_4_set_temperature_thresholds()
Set Temperature Thresholds.
Definition: DC1812A-B.ino:718
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
int8_t LTC2944_read_16_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
Reads a 16-bit adc_code from LTC2944.
Definition: LTC2944.cpp:109
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
Definition: DC1880A.ino:97
static int8_t restore_alert_settings()
int32_t read_int()
#define LTC2944_CURRENT_MSB_REG
Definition: LTC2944.h:142
#define LTC2944_PRESCALAR_M_16
Definition: LTC2944.h:185
float read_float()
LTC2944: Multicell Battery Gas Gauge with Temperature, Voltage and Current Measurement.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
Definition: LT_I2C.cpp:394
static int8_t menu_6_alert_menu_3_set_current_thresholds()
Set Current Thresholds.
Definition: DC1812A-B.ino:689
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
Definition: LT_I2C.cpp:401
static float voltage
Definition: DC2289AA.ino:71
static int8_t demo_board_connected
Set to 1 if the board is connected.
Definition: DC1812A-B.ino:112
static uint16_t current
the current measurement from the LTC3335&#39;s counter test mode.
Definition: DC2343A.ino:114
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.
Definition: DC1812A-B.ino:470
#define LTC2944_SHUTDOWN_MODE
Definition: LTC2944.h:196
#define LTC2944_PRESCALAR_M_256
Definition: LTC2944.h:187
float LTC2944_code_to_current(uint16_t adc_code, float resistor)
Calculate the LTC2944 current with a sense resistor.
Definition: LTC2944.cpp:145
static int8_t menu_6_alert_menu_2_set_voltage_thresholds()
Set Voltage Thresholds.
Definition: DC1812A-B.ino:661
int8_t LTC2944_write(uint8_t i2c_address, uint8_t adc_command, uint8_t code)
Write an 8-bit code to the LTC2944.
Definition: LTC2944.cpp:77
static void store_alert_settings()
const float resistor
resistor value on demo board
Definition: DC1812A-B.ino:104
#define LTC2944_VOLTAGE_MSB_REG
Definition: LTC2944.h:136
float LTC2944_code_to_coulombs(uint16_t adc_code, float resistor, uint16_t prescalar)
Calculate the LTC2944 charge in Coulombs.
Definition: LTC2944.cpp:120