BQ28Z610 Driver
BQ28Z610 Battery fuel gauge device driver for Arduino
Functions
std_data_commands.cpp File Reference

12.1 Standard Data Commands implementation More...

#include "std_data_commands.h"

Functions

word ManufacturerAccessControl ()
 12.1.1 0x00/01 ManufacturerAccessControl More...
 
float Temperature ()
 12.1.4 0x06/07 Temperature More...
 
float Voltage ()
 12.1.5 0x08/09 Voltage More...
 
word BatteryStatus ()
 12.1.6 0x0A/0B BatteryStatus More...
 
int Current ()
 12.1.7 0x0C/0D Current More...
 
word RemainingCapacity ()
 12.1.9 0x10/11 RemainingCapacity More...
 
word FullChargeCapacity ()
 12.1.10 0x12/13 FullChargeCapacity More...
 
int AverageCurrent ()
 12.1.11 0x14/15 AverageCurrent The value is updated every 1s. Units are mA. More...
 
word CycleCount ()
 12.1.22 0x2A/2B CycleCount More...
 
word RelativeStateOfCharge ()
 12.1.23 0x2C/2D RelativeStateOfCharge More...
 
word StateOfHealth ()
 12.1.24 0x2E/2F State-of-Health (SOH) More...
 
float ChargingVoltage ()
 12.1.25 0x30/31 ChargingVoltage More...
 
word ChargingCurrent ()
 12.1.26 0x32/33 ChargingCurrent More...
 
word DesignCapacity ()
 12.1.27 0x3C/3D DesignCapacity More...
 

Detailed Description

12.1 Standard Data Commands implementation

The host controller communicates with the gauge through gauge commands. A gauge command is the equivalent to a register. For example, reading the state of charge is accomplished through the StateOfCharge() gauge command, which has the command codes 0x1C and 0x1D. So if the interface is I2C, reading from device register 0x1C and 0x1D returns the current state of charge of the battery as calculated by the gauge.

To enable the system to read and write battery information, the BQ28Z610 uses a series of 2-byte standard I2C commands with a 7-bit device address of 0x55 (8 bits = 0xAA to write and 0xAB to read). Each standard command has an associated command code pair, as indicated in Table 12-1, Standard Commands. Each protocol has specific means to access the data at each command code. Data RAM is updated and read by the gauge once per second.

BQ28Z610
Technical Reference Manual
(c) Texas Instruments
Literature Number: SLUUA65E
See also
https://www.ti.com/lit/ug/sluua65e/sluua65e.pdf

MIT License

Copyright (c) 2024 Oleksii Sylichenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Function Documentation

◆ AverageCurrent()

int AverageCurrent ( )

12.1.11 0x14/15 AverageCurrent The value is updated every 1s. Units are mA.

12.1.11 0x14/15 AverageCurrent

Returns
a signed integer value that is the average current flow through the sense resistor.

◆ BatteryStatus()

word BatteryStatus ( )

12.1.6 0x0A/0B BatteryStatus

Bits 3:0: EC3,EC2,EC1,EC0 - Error Code:
  0x00 = OK
  0x1 = Busy
  0x2 = Reserved Command
  0x3 = Unsupported Command
  0x4 = AccessDenied
  0x5 = Overflow/Underflow
  0x6 = BadSize
  0x7 = UnknownError
Bit 4: FD—Fully Discharged
  0 = Battery ok
  1 = Battery fully depleted
Bit 5: FC—Fully Charged
  0 = Battery not fully charged
  1 = Battery fully charged
Bit 6: DSG—Discharging
  0 = Battery is charging.
  1 = Battery is discharging.
Bit 7: INIT—Initialization
  0 = Inactive
  1 = Active
Bit 8: RTA—Remaining Time Alarm
  0 = Inactive
  1 = Active
Bit 9: RCA—Remaining Capacity Alarm
  0 = Inactive
  1 = Active
Bit 10: Reserved
Bit 11: TDA—Terminate Discharge Alarm
  0 = Inactive
  1 = Active
Bit 12: OTA—Overtemperature Alarm
  0 = Inactive
  1 = Active
Bit 13: Reserved
Bit 14: TCA—Terminate Charge Alarm
  0 = Inactive
  1 = Active
Bit 15: OCA—Overcharged Alarm
  0 = Inactive
  1 = Active

◆ ChargingCurrent()

word ChargingCurrent ( )

12.1.26 0x32/33 ChargingCurrent

Returns
the desired charging current.

◆ ChargingVoltage()

float ChargingVoltage ( )

12.1.25 0x30/31 ChargingVoltage

Returns
the desired charging voltage.

◆ Current()

int Current ( )

12.1.7 0x0C/0D Current

Returns
the measured current from the coulomb counter.

◆ CycleCount()

word CycleCount ( )

12.1.22 0x2A/2B CycleCount

Returns
the number of discharge cycles the battery has experienced.

◆ DesignCapacity()

word DesignCapacity ( )

12.1.27 0x3C/3D DesignCapacity

Returns
the theoretical maximum pack capacity.

◆ FullChargeCapacity()

word FullChargeCapacity ( )

12.1.10 0x12/13 FullChargeCapacity

Returns
the predicted battery capacity when fully charged.

◆ ManufacturerAccessControl()

word ManufacturerAccessControl ( )

12.1.1 0x00/01 ManufacturerAccessControl

A read on this register returns the Control bits.

This Control Register is an I2C register, and the control bits are read back on register 0x00/0x01. These control bits are provided for backward compatibility/ease-of-use.

  • SEC1 (Bit 14): SECURITY Mode
  • SEC0 (Bit 13): SECURITY Mode
  • AUTHCALM (Bit 12): Automatic CALIBRATION mode
  • CheckSumValid (Bit 9): Checksum Valid
  • BTP_INT (Bit 7): Battery Trip Point Interrupt
  • LDMD (Bit 3): LOAD Mode
  • R_DIS (Bit 2): Resistance Updates
  • VOK (Bit 1): Voltage OK for QMax Update
  • QMax (Bit 0): QMax Updates. This bit toggles after every QMax update
Warning
[!] SEC1, SEC0 (Bits 14, 13): SECURITY Mode - doesn't work correct!
It's (0, 0) for Full Access but should be (1, 0).
Use function "12.2.30 AltManufacturerAccess() 0x0054 OperationStatus()" instead.

◆ RelativeStateOfCharge()

word RelativeStateOfCharge ( )

12.1.23 0x2C/2D RelativeStateOfCharge

Returns
the predicted remaining battery capacity as a percentage of FullChargeCapacity().

◆ RemainingCapacity()

word RemainingCapacity ( )

12.1.9 0x10/11 RemainingCapacity

Returns
the predicted remaining battery capacity.

◆ StateOfHealth()

word StateOfHealth ( )

12.1.24 0x2E/2F State-of-Health (SOH)

Returns
the state-of-health (SOH) information of the battery in percentage of design capacity.

◆ Temperature()

float Temperature ( )

12.1.4 0x06/07 Temperature

Returns
an unsigned integer value of temperature in units ( 0.1 k) measured by the gas gauge, and is used for the gauging algorithm. It reports either InternalTemperature() or external thermistor temperature, depending on the setting of the [TEMPS] bit in Pack configuration.

◆ Voltage()

float Voltage ( )

12.1.5 0x08/09 Voltage

Returns
the sum of the measured cell voltages.