Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC2343A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC934 Demonstration Board.
3 LTC3335: Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter
4 
5 @verbatim
6 
7 This sketch demonstrates the LTC3335 using the DC2343A demo board. The data read from
8 the data board is displayed on a serial terminal using 115200 baud, and newline terminations
9 for data input.
10 
11 Code will build for configuration specified in LTC3335_Config.h.
12 
13  1. The selected output voltage is specified by LTC3335_OUTPUT_VOLTAGE.
14  2. The LTC3335 prescaler will be chosen appropriately for the battery capacity specified
15  by LTC3335_CAPACITY.
16  3. The LTC3335 alarm will be chosen appropriately for the value specified by
17  LTC3335_ALARM_CAPACITY.
18  4. The coulomb count and battery current measurement will be scaled accordingly to the
19  LTC3335 prescaler selected by LTC3335_CAPACITY and the LTC3335_IPEAK_CONFIGURATION,
20  setting.
21  5. Set LTC3335_USE_CURRENT_MEASUREMENT if you wish to use the LTC3335 battery current measurement.
22  6. Set LTC3335_USE_SOFTWARE_CORRECTION if you wish to use correction of the LTC3335 coulomb
23  count and battery current measurement. A value of LTC3335_VBAT_TYP must be specified
24  for this sketch as it can not measure the actual battery voltage, and must assume a constant
25  value. Applications reusing this code would improve performance if the actual battery voltage
26  was measured and used for the correction functions. See the DC2343A schematic for a circuit
27  which measures the battery voltage with >10nA of average current drawn from the battery.
28 
29 @endverbatim
30 
31 To use the Linduino with the DC2343A, the PIC16 on the DC2343A must be disconnected by removing
32 the DC2343-ASSY1 PCB from JP5:
33 \image html "../../Part Number/3000/3300/3335/DC2343A/Assy_PCB_Removed.PNG"
34 
35 A cable must then be constructed to connect the Linduino to the DC2343A as shown:
36 \image html "../../Part Number/3000/3300/3335/DC2343A/Linduino_Cable.png"
37 
38 http://www.linear.com/product/LTC3335
39 
40 http://www.linear.com/product/LTC3335#demoboards
41 
42 Copyright 2018(c) Analog Devices, Inc.
43 
44 All rights reserved.
45 
46 Redistribution and use in source and binary forms, with or without
47 modification, are permitted provided that the following conditions are met:
48  - Redistributions of source code must retain the above copyright
49  notice, this list of conditions and the following disclaimer.
50  - Redistributions in binary form must reproduce the above copyright
51  notice, this list of conditions and the following disclaimer in
52  the documentation and/or other materials provided with the
53  distribution.
54  - Neither the name of Analog Devices, Inc. nor the names of its
55  contributors may be used to endorse or promote products derived
56  from this software without specific prior written permission.
57  - The use of this software may or may not infringe the patent rights
58  of one or more patent holders. This license does not release you
59  from the requirement that you obtain separate licenses from these
60  patent holders to use this software.
61  - Use of the software either in source or binary form, must be run
62  on or directly connected to an Analog Devices Inc. component.
63 
64 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
65 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
66 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
67 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
68 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
69 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
70 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
71 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
72 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
73 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74 */
75 
76 /*! @file
77  @ingroup LTC3335
78 */
79 
80 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
81 // Includes
82 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
83 
84 #include <Arduino.h>
85 #include "Linduino.h"
86 #include "LT_I2C.h"
87 #include "LTC3335.h"
88 #include "printf.h"
89 
90 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
91 // Definitions
92 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
93 
94 // Controls rate at which LTC3335 is polled and rate at which terminal is updated.
95 #define REFRESH_INTERVAL 1000 //! in ms, the rate at which the LTC3335 is polled and data output to terminal screen.
96 #define CURRENT_REFRESH_INTERVAL 5000 //! in ms, the period over which the LTC3335 current measurement is averaged.
97 
98 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
99 // Global Data
100 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
101 
102 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
103 // Local Data
104 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
105 
106 uint16_t refresh_time_last; //!< Variable to schedule LTC3335 polling and data output at REFRESH_INTERVAL
107 uint16_t current_refresh_time_last; //!< Variable to schedule LTC3335 current measurement averaging at CURRENT_REFRESH_INTERVAL.
108 
109 uint32_t data_point_counter; //!< counts the number of datapoints output to terminal screen.
110 uint32_t discharged_capacity; //!< in mAs, the discharged capacity calculated from the LTC3335 accumulator and
111 //!< quiescent losses (if software correction is enabled).
112 LTC3335_ALARM_TYPE alarms; //!< active alarms read from the LTC3335.
113 #if LTC3335_USE_CURRENT_MEASUREMENT == true
114 uint16_t current; //!< the current measurement from the LTC3335's counter test mode.
115 #endif // #if LTC3335_USE_CURRENT_MEASUREMENT == true
116 #if LTC3335_USE_SOFTWARE_CORRECTION == true
117 uint16_t vbat = LTC3335_VBAT_TYP; //!< battery voltage, optimally measured with an adc, set to a constant in this sketch
118 #endif // #if LTC3335_USE_CURRENT_MEASUREMENT == true
119 
120 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
121 // Local Prototypes
122 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
123 // \cond
124 void print_separator(); // Prints line on terminal to separate other text blocks.
125 void print_config(); // Prints configuration of LTC3335 set in LTC3335_Config.h.
126 void print_data_header(); // Prints header for data displayed in terminal at runtime.
127 void print_data(); // Prints data displayed in terminal at runtime.
128 // \endcond
129 
130 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
131 // Global Functions
132 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
133 
134 
135 //! Initialize Linduino
136 void setup()
137 {
138 
139  Serial.begin(115200); //! Initialize the serial port to the PC.
140  while (!Serial); //! Wait for serial port to be opened in the case of Leonardo USB Serial.
141 
142  //! Wait for LTC3335 to initialize successfully.
143  while ((LTC3335_Init() != 0))
144  {
145  print_error(); //! Show reasons why LTC3335 might not have initialized.
146  delay(5000);
147  }
148 
149  //! Display configuration set in LTC3335_Config.h.
150  print_config();
151  print_data_header();
152 
153  //! Set up timing for tasks in loop.
154  data_point_counter = 0;
155  refresh_time_last = millis();
157 
158  return;
159 }
160 
161 //! Repeats Linduino Loop
162 void loop()
163 {
164  uint16_t time_new = millis(); // ! Get new time
165 
166  //! Check if it's time to poll LTC3335 and update the terminal.
167  if (time_new - refresh_time_last > REFRESH_INTERVAL)
168  {
169  //! Read the discharged capacity.
170 #if LTC3335_USE_SOFTWARE_CORRECTION == false
172 #else
174 #endif // LTC3335_USE_SOFTWARE_CORRECTION == false
175 
176  //! If current measurement is being used, read it. If software correction is used, pass the battery voltage
177  //! to the function so that the proper correction factor will be used.
178 #if LTC3335_USE_CURRENT_MEASUREMENT == true
179 #if LTC3335_USE_SOFTWARE_CORRECTION == false
181 #else
183 #endif // LTC3335_USE_SOFTWARE_CORRECTION == false
184 #endif // #if LTC3335_USE_CURRENT_MEASUREMENT == true
185 
186  //! Only need to read alarms unless nIRQ is active (although not when nIRQ is used for current measurement).
187  if ((LTC3335_NIRQ_READ() == 0) || (LTC3335_USE_CURRENT_MEASUREMENT == true))
188  {
189  LTC3335_Get_Alarms(&alarms);
190  }
191 
192  //! Update terminal.
193  print_data();
194 
195  // Schedule next loop.
198  }
199 
200 #if LTC3335_USE_CURRENT_MEASUREMENT == true
201  //! If using the current measurement, clear it periodically. The current measurement will be averaged over time until it is reset.
203  {
206  }
207 
208  //! Update the Counter Test current in the background. Must be called more often than LTC3335_MIN_CURRENT_TASK_RATE.
210 #endif // #if LTC3335_USE_CURRENT_MEASUREMENT == true
211 
212  //! If any character is entered, send command to clear interrupt.
213  if (Serial.available())
214  {
215  LTC3335_Clear_Int(&alarms);
216  Serial.read(); // Clear out character that caused Clear Int command to be sent.
217  }
218 
219 }
220 
221 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
222 // Local Functions
223 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
224 // \cond
225 // Code for displaying operation of sketch on a serial terminal.
226 // It is not intended for any of the functions below to be useful in a customer application,
227 // and no attempt was made to optimize it.
228 
229 //! Constants defined so that other constants don't include unexplained numbers in them.
230 #define MV_PER_V 1000
231 #define MA_PER_A 1000
232 #define UA_PER_MA 1000
233 #define SEC_PER_HR 3600
234 #define MS_PER_SEC 1000
235 
236 //! Macro prints a float to the serial port with the precision selected by the size of the number.
237 #define PRINT_PICK_DEC(v) Serial.print(v, v >= 1 ? 3 : 6);
238 
239 // Prints line on terminal to separate other text blocks.
240 void print_separator()
241 {
242  Serial.println(F("=========================================================================================="));
243 }
244 
245 // Prints message to terminal about reasons why the LTC3335 may have failed to communicate.
246 void print_error()
247 {
248  Serial.println(F("Initialization of LTC3335 failed."));
249  Serial.println(F("Ensure Linduino is connected correctly to DC2343A, "));
250  Serial.println(F("DC2343A is connected to VBAT between 1.8V and 5.5V,"));
251  Serial.println(F("and that EN jumper is in the ON position."));
252  print_separator();
253 }
254 
255 // Prints configuration of LTC3335 set in LTC3335_Config.h.
256 void print_config()
257 {
258  // Describe the application.
259  print_separator();
260  Serial.println(F("Sample application for LTC3335 Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter."));
261  print_separator();
262 
263  // Display the parameters set by user in LTC3335_Config.h.
264  Serial.print(F("Capacity = "));
265  Serial.print((uint32_t)(1L * LTC3335_CAPACITY * SEC_PER_HR));
266  Serial.print(F("mAs ("));
267  PRINT_PICK_DEC(1.0 * LTC3335_CAPACITY / MA_PER_A);
268  Serial.print(F("Ah), IPeak = "));
269  Serial.print(LTC3335_IPEAK_MA);
270  Serial.print(F("mA, Output Voltage = "));
271 #if LTC3335_OUTPUT_VOLTAGE == LTC3335_OUTPUT_VOLTAGE_1_8V
272  Serial.print(1.8, 1);
273 #elif LTC3335_OUTPUT_VOLTAGE == LTC3335_OUTPUT_VOLTAGE_2_5V
274  Serial.print(2.5, 1);
275 #elif LTC3335_OUTPUT_VOLTAGE == LTC3335_OUTPUT_VOLTAGE_2_8V
276  Serial.print(2.8, 1);
277 #elif LTC3335_OUTPUT_VOLTAGE == LTC3335_OUTPUT_VOLTAGE_3_0V
278  Serial.print(3.0, 1);
279 #elif LTC3335_OUTPUT_VOLTAGE == LTC3335_OUTPUT_VOLTAGE_3_3V
280  Serial.print(3.3, 1);
281 #elif LTC3335_OUTPUT_VOLTAGE == LTC3335_OUTPUT_VOLTAGE_3_6V
282  Serial.print(3.6, 1);
283 #elif LTC3335_OUTPUT_VOLTAGE == LTC3335_OUTPUT_VOLTAGE_4_5V
284  Serial.print(4.5, 1);
285 #elif LTC3335_OUTPUT_VOLTAGE == LTC3335_OUTPUT_VOLTAGE_5_0V
286  Serial.print(5.0, 1);
287 #endif
288  Serial.println(F("V."));
289  print_separator();
290 
291  // Display the prescaler and capacity range resulting from the parameters set by user in LTC3335_Config.h.
292 #if LTC3335_USE_SOFTWARE_CORRECTION == true
294  {
295  Serial.println(F("LTC3335_CORRECTION_FACTOR_TYP in LTC3335_Config.h not set to value returned as LTC3335_Get_Software_Correction_Factor(LTC3335_VBAT_TYP)"));
296  Serial.print(F("LTC3335_CORRECTION_FACTOR_TYP = "));
297  Serial.print(LTC3335_CORRECTION_FACTOR_TYP);
298  Serial.print(F(", LTC3335_VBAT_TYP = "));
299  Serial.print(LTC3335_VBAT_TYP);
300  Serial.println(F("V."));
301  Serial.print(F("LTC3335_Get_Software_Correction_Factor(LTC3335_VBAT_TYP) = "));
303  }
304  else
305 #endif // #if LTC3335_USE_SOFTWARE_CORRECTION == true
306  {
307  Serial.print(F("Prescaler Set to "));
308  Serial.print(LTC3335_PRESCALER);
309  Serial.print(F(" for a maximum accumulator range of "));
310  Serial.print(LTC3335_RANGE(LTC3335_PRESCALER));
311  Serial.print(F("mAs ("));
312  PRINT_PICK_DEC(1.0 * LTC3335_RANGE(LTC3335_PRESCALER) / (1.0 * MA_PER_A * SEC_PER_HR));
313  Serial.print(F("Ah)"));
314 #if LTC3335_USE_SOFTWARE_CORRECTION == false
315  Serial.println(F("."));
316  Serial.println(F("LTC3335_USE_SOFTWARE_CORRECTION not enabled"));
317 #else
318  Serial.println(F(","));
319  Serial.print(F("assuming an average battery voltage of "));
320  Serial.print(1.0 * LTC3335_VBAT_TYP / MV_PER_V);
321  Serial.println(F("V,"));
322  Serial.print(F("resulting in an average correction of "));
323  Serial.print(-100.0 * LTC3335_Get_Software_Correction_Factor(LTC3335_VBAT_TYP) / (1L << 16) );
324  Serial.println(F("%."));
325 #endif // #if LTC3335_USE_SOFTWARE_CORRECTION == false
326  }
327  print_separator();
328 
329  // Display the alarm value selected to be closest by less than that set by user in LTC3335_Config.h.
330 #if LTC3335_USE_SOFTWARE_CORRECTION == false
331  uint8_t alarm_reg = (1LL * LTC3335_ALARM_CAPACITY * SEC_PER_HR)/LTC3335_RESOLUTION(LTC3335_PRESCALER);
332  uint32_t alarm_mas = alarm_reg * LTC3335_RESOLUTION(LTC3335_PRESCALER);
333 #else
334  uint8_t alarm_reg = (1LL * LTC3335_ALARM_CAPACITY * SEC_PER_HR)/(LTC3335_RESOLUTION(LTC3335_PRESCALER) * ((1LL << 16) + LTC3335_CORRECTION_FACTOR_TYP) / (1L << 16));
335  uint32_t alarm_mas = alarm_reg * LTC3335_RESOLUTION(LTC3335_PRESCALER) * ((1LL << 16) + LTC3335_CORRECTION_FACTOR_TYP) / (1L << 16);
336 #endif // #if LTC3335_USE_SOFTWARE_CORRECTION == false
337  Serial.print(F("Alarm Register Set to "));
338  Serial.print(alarm_mas);
339  Serial.print(F("mAs ("));
340  PRINT_PICK_DEC(1.0 * alarm_mas / (1.0 * MA_PER_A * SEC_PER_HR));
341  Serial.println(F("Ah),"));
342  Serial.print(F("which is "));
343  Serial.print(100.0 * alarm_mas / (1L * LTC3335_CAPACITY * SEC_PER_HR), 2);
344  Serial.println(F("% of the battery capacity."));
345  print_separator();
346 
347 #if LTC3335_USE_CURRENT_MEASUREMENT == true
348  Serial.println(F("Counter Test mode used to measure battery current with nIRQ pin."));
349  print_separator();
350 #endif // #if LTC3335_USE_CURRENT_MEASUREMENT == false
351 
352  Serial.println(F("Send any character to send a Clear Int command to the LTC3335."));
353  print_separator();
354 }
355 
356 // Prints header for data displayed in terminal at runtime.
357 void print_data_header()
358 {
359  printf(F("Test Time (s), "));
360  printf(F("Discharged Capacity (mAs), "));
361 #if LTC3335_USE_CURRENT_MEASUREMENT == true
362  printf(F("Battery Current (mA), "));
363 #endif // #if LTC3335_USE_CURRENT_MEASUREMENT == true
364  printf(F("Alarm Trip Alarm, "));
365  printf(F("Coulomb Counter Overflow Alarm, "));
366  printf(F("AC On Time Overflow Alarm, "));
367  printf(F("PGOOD, "));
368  printf(F("nIRQ\r\n"));
369 }
370 
371 // Prints data displayed in terminal at runtime.
372 void print_data()
373 {
374  printf(F("%13.2f,"), 1.0 * data_point_counter * REFRESH_INTERVAL / MS_PER_SEC);
375  printf(F("%26d,"), discharged_capacity);
376 #if LTC3335_USE_CURRENT_MEASUREMENT == true
377  printf(F("%21.3f,"), 1.0 * current / MA_PER_A);
378 #endif // #if LTC3335_USE_CURRENT_MEASUREMENT == true
379  printf(F("%17b,"), alarms.alarm_trip);
380  printf(F("%31b,"), alarms.coulomb_counter_overflow);
381  printf(F("%26b,"), alarms.ac_on_time_overflow);
382  printf(F("%6b,"), LTC3335_PGOOD_READ());
383  printf(F("%5b\r\n"), LTC3335_NIRQ_READ());
384 }
385 // \endcond
386 
#define REFRESH_INTERVAL
Definition: DC2343A.ino:95
int8_t LTC3335_Reset_Counter_Test_Current(void)
Resets the number of edges and the amount of time stored for the Counter Test feature.
Definition: LTC3335.cpp:396
void LTC3335_Counter_Test_Current_Task(void)
Task that must be run periodically, for the edges and time to be stored for the LTC3335 Counter Test ...
Definition: LTC3335.cpp:409
#define LTC3335_VBAT_TYP
in mV, the nominal battery voltage expected for the majority of the battery discharge.
int8_t LTC3335_Get_Alarms(LTC3335_ALARM_TYPE *alarms)
Gets the alarms active from the LTC3335.
Definition: LTC3335.cpp:225
static uint32_t data_point_counter
counts the number of datapoints output to terminal screen.
Definition: DC2343A.ino:109
Header File for Linduino Libraries and Demo Code.
unsigned ac_on_time_overflow
AC(ON) time operating fault (tAC > tFS) due to improperly chosen inductor value timing out the AC(ON)...
Definition: LTC3335.h:154
static uint32_t discharged_capacity
in mAs, the discharged capacity calculated from the LTC3335 accumulator and
Definition: DC2343A.ino:110
static uint16_t refresh_time_last
Variable to schedule LTC3335 polling and data output at REFRESH_INTERVAL.
Definition: DC2343A.ino:106
#define LTC3335_RANGE(p)
Macro to retrieve the LTC3335 coulomb count range with a given prescaler.
Definition: LTC3335.h:192
static void setup()
Initialize Linduino.
Definition: DC2343A.ino:136
#define LTC3335_CAPACITY
in mAh, capacity of the battery
int8_t LTC3335_Init(void)
Verify that battery capacity isn&#39;t so gigantic that it would overflow a 32 bit number.
Definition: LTC3335.cpp:162
static void loop()
Repeats Linduino Loop.
Definition: DC2343A.ino:162
static uint16_t vbat
battery voltage, optimally measured with an adc, set to a constant in this sketch ...
Definition: DC2343A.ino:117
int8_t LTC3335_Get_Discharged_Capacity(uint32_t *discharged_capacity)
Gets the discharged capacity from the battery in mAs.
Definition: LTC3335.cpp:306
#define LTC3335_RESOLUTION(p)
Macro to retrieve the LTC3335 coulomb count resolution with a given prescaler.
Definition: LTC3335.h:198
unsigned coulomb_counter_overflow
Coulomb counter operating fault due to an improperly chosen prescalar causing the ripple counter to o...
Definition: LTC3335.h:155
LTC3335_ALARM_TYPE alarms
active alarms read from the LTC3335.
Definition: DC2343A.ino:112
#define CURRENT_REFRESH_INTERVAL
Definition: DC2343A.ino:96
LTC3335: Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter.
#define LTC3335_NIRQ_READ()
#define LTC3335_USE_CURRENT_MEASUREMENT
Set to true to use the /IRQ pin to measure the battery current real time.
static uint16_t current_refresh_time_last
Variable to schedule LTC3335 current measurement averaging at CURRENT_REFRESH_INTERVAL.
Definition: DC2343A.ino:107
int8_t LTC3335_Get_Counter_Test_Current(uint16_t *microamps)
Gets the battery current in uA.
Definition: LTC3335.cpp:431
static void print_config()
Prints the configuration data that is going to be written to the LTC6803 to the serial port...
Definition: DC1651A.ino:384
#define LTC3335_PGOOD_READ()
int16_t LTC3335_Get_Software_Correction_Factor(uint16_t vbat)
Returns the software correction factor for a specified LTC3335_IPEAK_CONFIGURATION, LTC3335_OUTPUT_VOLTAGE, and battery voltage.
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
#define LTC3335_PRESCALER
Macro to select the optimal prescaler for the specified battery capacity at compile time...
Definition: LTC3335.h:188
unsigned alarm_trip
Accumulator value has met or exceeded the alarm threshold value.
Definition: LTC3335.h:156
#define LTC3335_IPEAK_MA
mA = 100mA, used in calculations of coulomb count and current.
Definition: LTC3335.h:178
static uint16_t current
the current measurement from the LTC3335&#39;s counter test mode.
Definition: DC2343A.ino:114
#define LTC3335_CORRECTION_FACTOR_TYP
Value of LTC3335_Software_Correction_Table[VBAT_TO_TABLE_INDEX(LTC3335_VBAT_TYP)].
int8_t LTC3335_Clear_Int(LTC3335_ALARM_TYPE *alarms)
Sends the command to clear the INT condition.
Definition: LTC3335.cpp:268
The alarm conditions which cause the LTC3335 to activate the /INT pin.
Definition: LTC3335.h:152
#define LTC3335_ALARM_CAPACITY
in mAh, the capacity at which the alarm should be activated.