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