Driver for Texas Instruments' battery state-of-charge estimator.

Dependents:   BQ34Z100G1-Utils BQ34Z100G1-ChemIDMeasurer

BQ34Z100G1 Driver

Newer releases of this driver have moved to GitHub: https://github.com/USCRPL/BQ34Z100G1-Driver

By USC Rocket Propulsion Lab / Arpad Kovesdy, Kyle Marino, Jamie Smith

After lots of development, testing, debugging, dead ends, backtracking, and retracing our steps, we at RPL are proud to present a complete driver for Texas Instruments' BQ34Z100G1 state-of-charge estimator. This handy chip handles all the complexities of monitoring a battery's charging and discharging cycle, and is one of the only real ways to have a real estimate of how much usable energy is left in a standard lithium-ion battery.

However, in order to perform this function, the IC needs a lot of information, including both the on-paper specifications of your battery system and the results of several different calibration runs of your real battery system. With one exception*, this driver can handle all the needed configuration, taking you from unconfigured to calibrated in as little time as possible.

Note: To initially program the Chem ID information into each chip to configure it for your battery, you will need an EV2300 or EV2400 programmer box from TI, as well as a header to plug it in on your board.

Calibrating the Chip

See here.

Credits

The initial version of this driver was taken from Ralim on GitHub here.

However, we have made a huge number of changes and additions since then, including porting the Arduino library to Mbed, cleaning up the code to use enums, breaking out the configuration to external constants, and fixing looots of bugs.

Revision:
1:6483d36150c3
Parent:
0:6d09d3ad58aa
--- a/BQ34Z100.h	Sun Feb 07 01:17:28 2021 -0800
+++ b/BQ34Z100.h	Sun Feb 07 20:36:23 2021 -0800
@@ -20,17 +20,16 @@
 
 //Battery configuration settings
 //Stored in flash: run flashSettings() then reset sensor to save
-//battery information:
-//https://www.batteryspace.com/polymerli-ioncell37v1400mah703562-10c518wh10adrainrate-ullisted.aspx
 #define DESIGNCAP 1400 //mAh, per cell (Page 48, offset 11)
 #define DESIGNENERGY 5180 //mWh, per cell (Page 48, offset 14)
 #define CELLCOUNT 0x04 //number of series cells (Page 65, offset 7)
-#define LEDCONFIG 0x4b //5-LED Expander with I2C host comm (Page 64, offset 5)
+#define LEDCONFIG 0x4b //5-LED Expander with I2C host comm (Page 64, offset 4)
 #define VOLTSEL true //Switches to an external battery voltage divider
 #define ZEROCHARGEVOLT 3375 //mV, charge cut-off voltage/Cell terminate voltages
 #define FLASH_UPDATE_OK_VOLT 2800 // mV, below this voltage per cell flash writes will not go through
 
-#define QMAX0 10000 //mAh, same as c-rate
+#define QMAX0 1400 //mAh, datasheet says to use c-rate current
+
 //The voltage divider works by this formula: Gain = (TOP LEG R/BOTTOM LEG R)*1000
 //Top leg: 294Kohm and bottom leg: 16.5Kohm
 //This only works if you enable the external voltage divider (VOLTSEL) option for the sensor