Maxim Integrated / max17055

Fork of max17055 by Central Applications - Mbed Code repo

Embed: (wiki syntax)

« Back to documentation index

MAX17055 Class Reference

MBED Library for the MAX17055
The MAX17055 is a low 7μA operating current fuel gauge which
implements Maxim ModelGauge™ m5 EZ algorithm. More...

#include <max17055.h>

Data Structures

struct  platform_data
 Saved Platform Data for Fuel Gauge Model. More...
struct  saved_FG_params_t
 Saved Fuel Gauge Parameters. More...

Public Types

enum  Registers_e {
  STATUS_REG = 0x00, VALRTTH_REG = 0x01, TALRTTH_REG = 0x02, SALRTTH_REG = 0x03,
  ATRATE_REG = 0x04, REPCAP_REG = 0x05, REPSOC_REG = 0x06, TEMP_REG = 0x08,
  VCELL_REG = 0x09, CURRENT_REG = 0x0A, AVGCURRENT_REG = 0x0B, MIXSOC_REG = 0x0D,
  AVSOC_REG = 0x0E, MIXCAP_REG = 0x0F, FULLCAPREP_REG = 0x10, TTE_REG = 0X11,
  QRTABLE00_REG = 0x12, FULLSOCTHR_REG = 0x13, CYCLES_REG = 0x17, DESIGNCAP_REG = 0x18,
  AVGVCELL_REG = 0x19, MAXMINVOLT_REG = 0x1B, CONFIG_REG = 0x1D, ICHGTERM_REG = 0x1E,
  TTF_REG = 0x20, VERSION_REG = 0x21, QRTABLE10_REG = 0x22, FULLCAPNOM_REG = 0x23,
  LEARNCFG_REG = 0x28, RELAXCFG_REG = 0x2A, TGAIN_REG = 0x2C, TOFF_REG = 0x2D,
  QRTABLE20_REG = 0x32, RCOMP0_REG = 0x38, TEMPCO_REG = 0x39, VEMPTY_REG = 0x3A,
  FSTAT_REG = 0x3D, QRTABLE30_REG = 0x42, DQACC_REG = 0x45, DPACC_REG = 0x46,
  VFSOC0_REG = 0x48, QH0_REG = 0x4C, QH_REG = 0x4D, VFSOC0_QH0_LOCK_REG = 0x60,
  LOCK1_REG = 0x62, LOCK2_REG = 0x63, MODELDATA_START_REG = 0x80, IALRTTH_REG = 0xB4,
  CURVE_REG = 0xB9, HIBCFG_REG = 0xBA, CONFIG2_REG = 0xBB, MODELCFG_REG = 0xDB,
  ATTTE_REG = 0xDD, ATAVSOC_REG = 0xDE, ATAVCAP_REG = 0xDF, OCV_REG = 0xFB,
  VFSOC_REG = 0xFF
}
 

Register Addresses for the MAX17055.

More...

Public Member Functions

 MAX17055 (I2C &i2c)
 max17055 Constructor
 ~MAX17055 ()
 Fuel Gauge Destructor.
int poll_flag_clear (Registers_e reg_addr, int mask, int timeout)
 Poll Flag clear Function.
int check_POR_func ()
 Check POR function.
int clear_POR_bit ()
 clear POR bit function
int write_and_verify_reg (Registers_e reg_addr, uint16_t reg_data)
 Write and Verify a MAX17055 register.
int init (platform_data des_data)
 Initialization Function for MAX17055.
int get_temperature ()
 Get Temperature Function from the MAX17055 TEMP register.
uint16_t forcedExitHiberMode ()
 Forced Exit Hibernate Mode Function for MAX17055.
uint16_t EZconfig_init (platform_data des_data)
 EZ Config Initialization function.
int get_SOC ()
 Get reported State Of Charge(SOC) Function from MAX17055 Fuel Gauge.
int get_atAvSOC ()
 Get at rate Average State Of Charge(SOC) Function from MAX17055 Fuel Gauge.
float get_TTE ()
 Get the Time to Empty(TTE) Function form MAX17055 Fuel Gauge.
float get_atTTE ()
 Get the at Time to Empty(atTTE) value Function for MAX17055 Fuel Gauge.
int get_mixSOC ()
 Get mix State Of Charge(SOC) Function for MAX17055 Fuel Gauge.
float get_TTF ()
 Get the Time to Full(TTE) values Function for MAX17055 Fuel Gauge.
int get_Vcell ()
 Get voltage of the cell Function for MAX17055 Fuel Gauge.
int get_Current (platform_data des_data)
 Get current Function for MAX17055 Fuel Gauge.
int get_AvgCurrent (platform_data des_data)
 Get average current Function for MAX17055 Fuel Gauge.
int lsb_to_uvolts (uint16_t lsb)
 lsb_to_uvolts Conversion Function
int raw_current_to_uamps (uint32_t curr, int rsense_value)
 raw_current_to_uamp Conversion Function
int save_Params (saved_FG_params_t FG_params)
 Save Learned Parameters Function for battery Fuel Gauge model.
int restore_Params (saved_FG_params_t FG_params)
 Restore Parameters Function for battery Fuel Gauge model.
int avCurr_2_atRate ()
 Function to Save Average Current to At Rate register.

Static Public Attributes

static const uint8_t I2C_W_ADRS = 0x6C
 8-bit write address
static const uint8_t I2C_R_ADRS = 0x6D
 8-bit read address

Protected Member Functions

int writeReg (const Registers_e reg_addr, uint16_t reg_data)
 Writes to MAX17055 register.
int32_t readReg (Registers_e reg_addr, uint16_t &value)
 Reads from MAX17055 register.

Detailed Description

MBED Library for the MAX17055
The MAX17055 is a low 7μA operating current fuel gauge which
implements Maxim ModelGauge™ m5 EZ algorithm.


ModelGauge m5 EZ makes fuel gauge implementation easy by eliminating
battery characterization requirements and simplifying host
software interaction. The ModelGauge m5 EZ robust algorithm
provides tolerance against battery diversity for most lithium
batteries and applications. Communication is through an
SPI-compatible interface. The MAX17055 comes as part of the
MAX32620FTHR MBED enable development board.

Visit the product page for more information: MAX17055 Product Page
MAX17055 Data Sheet
MAX32620FTHR Product Page
MAX32620FTHR Data Sheet

 ///This is not the final test code. Just sample place holder. 
 #include "mbed.h"
 #include "MAX17055.h"


 // Hardware serial port
 Serial serial(USBTX, USBRX);

 //SPI communications
 I2C i2c(SCL, SDA);

 //Fuel Gauge
 MAX17055 max17055(i2C, Sutff );//To be completed


 int main(void)
 {
     CODE CODE TBD
      while(true)
      {
          CODE CODE TBD
      }
 }

MAX17055 Class Class for MAX17055 Battery Fuel Gauge

  • Generic API for Implementing the Battery Fuel Gauge

Definition at line 118 of file max17055.h.


Member Enumeration Documentation

Register Addresses for the MAX17055.

Enumerated register addresses

Enumerator:
STATUS_REG 

0x00 default value = 0x0002

VALRTTH_REG 

0x01

TALRTTH_REG 

0x02

SALRTTH_REG 

0x03

ATRATE_REG 

0x04 write negative 2s comp of a 16-bit theoretical load

REPCAP_REG 

0x05

REPSOC_REG 

0x06

TEMP_REG 

0x08

VCELL_REG 

0x09

CURRENT_REG 

0x0A

AVGCURRENT_REG 

0x0B

MIXSOC_REG 

0x0D

AVSOC_REG 

0x0E

MIXCAP_REG 

0x0F

FULLCAPREP_REG 

0x10

TTE_REG 

0x11

QRTABLE00_REG 

0x12

FULLSOCTHR_REG 

0x13

CYCLES_REG 

0x17

DESIGNCAP_REG 

0x18

AVGVCELL_REG 

0x19

MAXMINVOLT_REG 

0x1B

CONFIG_REG 

0x1D default = 0x2210

ICHGTERM_REG 

0x1E

TTF_REG 

0x20

VERSION_REG 

0x21

QRTABLE10_REG 

0x22

FULLCAPNOM_REG 

0x23

LEARNCFG_REG 

0x28

RELAXCFG_REG 

0x2A

TGAIN_REG 

0x2C

TOFF_REG 

0x2D

QRTABLE20_REG 

0x32

RCOMP0_REG 

0x38

TEMPCO_REG 

0x39

VEMPTY_REG 

0x39

FSTAT_REG 

0x39

QRTABLE30_REG 

0x39

DQACC_REG 

0x39

DPACC_REG 

0x39

VFSOC0_REG 

0x39

QH0_REG 

0x39

QH_REG 

0x39

VFSOC0_QH0_LOCK_REG 

0x39

LOCK1_REG 

0x39

LOCK2_REG 

0x39

MODELDATA_START_REG 

0x39

IALRTTH_REG 

0x39

CURVE_REG 

0x39

HIBCFG_REG 

0x39 default = 0x870C (0x890C)

CONFIG2_REG 

0xBB default = 0x3658

MODELCFG_REG 

0xDB

ATTTE_REG 

0xDD

ATAVSOC_REG 

0xDE

ATAVCAP_REG 

0xDF

OCV_REG 

0x39

VFSOC_REG 

0x39

Definition at line 132 of file max17055.h.


Constructor & Destructor Documentation

MAX17055 ( I2C &  i2c )

max17055 Constructor

max17055 Constructor with battery and i2c as parameters

Definition at line 78 of file max17055.cpp.

~MAX17055 (  )

Fuel Gauge Destructor.

Definition at line 87 of file max17055.cpp.


Member Function Documentation

int avCurr_2_atRate (  )

Function to Save Average Current to At Rate register.

Details
For User friendliness display of atTTE, atAvSOC, atAvCAP write the average current to At Rate registers every 10sec when the battery is in use. NOTE: do not use this function when the Battery is charging.
Return values:
0for success
non-0negative for errors

Definition at line 814 of file max17055.cpp.

int check_POR_func (  )

Check POR function.

Details
This function check is there was a power on reset event for the MAX17055
Return values:
0on success (POR detected)
non-0for errors (POR not detected)

Definition at line 259 of file max17055.cpp.

int clear_POR_bit (  )

clear POR bit function

Details
This function clear the indicating bit for POR - MAX17055
Return values:
0for Success
non-0for errors

Definition at line 279 of file max17055.cpp.

uint16_t EZconfig_init ( platform_data  des_data )

EZ Config Initialization function.

Details
This function implements the steps for the EZ config m5 FuelGauge
Parameters:
[in]des_data- Plataform_data struct with information about the design.
Return values:
0on success
non-zerofor errors

STEP 2.1.1 EZ config values suggested by manufacturer.

STEP 2.1.2 Store the EZ Config values into the appropriate registers.

Definition at line 397 of file max17055.cpp.

uint16_t forcedExitHiberMode (  )

Forced Exit Hibernate Mode Function for MAX17055.

Details
This function executes a force exit from hibernate mode.
Return values:
HibCFGoriginal value before forced Exit Hibernate mode *

Definition at line 369 of file max17055.cpp.

int get_atAvSOC (  )

Get at rate Average State Of Charge(SOC) Function from MAX17055 Fuel Gauge.

Details
This function sends a request to access the atAvSOC register of the MAX17055. The AvSOC registers hold the calculated available capacity and percentage of the battery based on all inputs from the ModelGauge m5 algorithm including empty compensation. These registers provide unfiltered results. Jumps in the reported values can be caused by abrupt changes in load current or temperature.
Return values:
atAvSOC_data- Average SOC data from the atAVSOC register in % value.
non-0negative values check for errors

Definition at line 461 of file max17055.cpp.

float get_atTTE (  )

Get the at Time to Empty(atTTE) value Function for MAX17055 Fuel Gauge.

Details
This function sends a request to access the internal register of the MAX17055
Return values:
atTTE_data- Time to Empty data from the atTTE register in seconds.
non-0negative values check for errors

Definition at line 538 of file max17055.cpp.

int get_AvgCurrent ( platform_data  des_data )

Get average current Function for MAX17055 Fuel Gauge.

Details
This function sends a request to access the aveCURRENT register of the MAX17055 to read the average current readings.
Parameters:
[in]des_data- Plataform_data struct with information about the design.
Return values:
aveCurr_data- current data from the AVGCURRENT register in uAmps.
non-0negative values check for errors.

Definition at line 644 of file max17055.cpp.

int get_Current ( platform_data  des_data )

Get current Function for MAX17055 Fuel Gauge.

Details
This function sends a request to access the CURRENT register of the MAX17055 to read the current readings.
Parameters:
[in]des_data- Plataform_data struct with information about the design.
Return values:
curr_data- current data from the CURRENT register in uAmps.
non-0negative values check for errors.

Definition at line 618 of file max17055.cpp.

int get_mixSOC (  )

Get mix State Of Charge(SOC) Function for MAX17055 Fuel Gauge.

Details
This function sends a request to access mixSOC register of the MAX17055. The MixSOC registers holds the calculated remaining capacity and percentage of the cell before any empty compensation adjustments are performed.
Return values:
mixSOC_data- Mixed SOC register values from the mixSOC register in % value.
non-0for errors

Definition at line 486 of file max17055.cpp.

int get_SOC (  )

Get reported State Of Charge(SOC) Function from MAX17055 Fuel Gauge.

Details
This function sends a request to access the RepSOC register of the MAX17055. RepSOC is the reported state-of-charge percentage output of the fuel gauge.
Return values:
soc_data- Reported SOC data from the RepSOC register in % value.
non-0negative values check for errors

Definition at line 434 of file max17055.cpp.

int get_temperature (  )

Get Temperature Function from the MAX17055 TEMP register.

Details
This function sends a request to access the TEMP register of the MAX17055, which reflects the temperature measured for the fuel gauge. The temperature values will reflect the Config Register (0x1D) selections for Tsel bit (D15). For this library the setting are for die temperature. The MAX32620FTHR thermistor bias pin is not connected. The biasing of the thermistor is done by the MAX77650. See MAX77650 library for how to enable the thermistor biasing.
Return values:
temp- Temperature value from TEMP register in C
non-0negative values check for errors

Definition at line 341 of file max17055.cpp.

float get_TTE (  )

Get the Time to Empty(TTE) Function form MAX17055 Fuel Gauge.

Details
This function sends a request to access the TTE register of the MAX17055 The TTE register holds the estimated time to empty for the application under present temperature and load conditions. The TTE value is determined by relating AvCap with AvgCurrent. The corresponding AvgCurrent filtering gives a delay in TTE, but provides more stable results.
Return values:
tte_data- Time to Empty data from the TTE register in seconds.
non-0negative values check for errors

Definition at line 513 of file max17055.cpp.

float get_TTF (  )

Get the Time to Full(TTE) values Function for MAX17055 Fuel Gauge.

Details
This function sends a request to access the internal register of the MAX17055 The TTF register holds the estimated time to full for the application under present conditions. The TTF value is determined by learning the constant current and constant voltage portions of the charge cycle based on experience of prior charge cycles. Time to full is then estimate by comparing present charge current to the charge termination current. Operation of the TTF register assumes all charge profiles are consistent in the application.
Return values:
ttf_data- Time to Full data from the TTF register in seconds.
non-0negative values check for errors

Definition at line 568 of file max17055.cpp.

int get_Vcell (  )

Get voltage of the cell Function for MAX17055 Fuel Gauge.

Details
This function sends a request to access the VCell Register of the MAX17055 to read the measured voltage from the cell.
Return values:
vcell_data- vcell data from the VCELL_REG register in uVolts.
non-0negative values check for errors

Definition at line 593 of file max17055.cpp.

int init ( platform_data  des_data )

Initialization Function for MAX17055.

Details
This function initializes the MAX17055 for the implementation of the EZconfig model.
The library needs to be customized for the implementation of customize model.
Return values:
0on success
non-0for errors

STEP 0. Check for POR (Skip load model if POR bit is cleared)

STEP 1. Check if FStat.DNR == 0 (Do not continue until FSTAT.DNR == 0)

STEP 1.2. Force exit from hibernate

STEP 2. Initialize configuration

STEP 2.1. Load EZ Config

STEP 2.2. Poll ModelCFG.ModelRefresh bit for clear

STEP3. Restore original HibCfg

Definition at line 196 of file max17055.cpp.

int lsb_to_uvolts ( uint16_t  lsb )

lsb_to_uvolts Conversion Function

Details
This function takes the lsb value of the register and convert it to uvolts
Parameters:
[in]lsb- value of register lsb
Return values:
conv_2_uvolts- value converted lsb to uvolts

Definition at line 669 of file max17055.cpp.

int poll_flag_clear ( Registers_e  reg_addr,
int  mask,
int  timeout 
)

Poll Flag clear Function.

Details
This function clears status flags for the MAX17055
Parameters:
[in]reg_addr- register address
[in]mask- register address
[in]timeout- register data
Return values:
0on success
non-0negative for errors

Definition at line 307 of file max17055.cpp.

int raw_current_to_uamps ( uint32_t  curr,
int  rsense_value 
)

raw_current_to_uamp Conversion Function

Details
This function takes the raw current value of the register and converts it to uamps
Parameters:
[in]curr- raw current value of register
Return values:
res- converted raw current to uamps (Signed 2's complement)

Definition at line 685 of file max17055.cpp.

int32_t readReg ( Registers_e  reg_addr,
uint16_t &  value 
) [protected]

Reads from MAX17055 register.

Parameters:
[in]reg_addrThe register address
valueThe value
Return values:
0on success
non-0for errors

Definition at line 128 of file max17055.cpp.

int restore_Params ( saved_FG_params_t  FG_params )

Restore Parameters Function for battery Fuel Gauge model.

Details
If power is lost, then the capacity information can be easily restored with this function.
Parameters:
[in]FG_paramsStruct for Fuel Gauge Parameters
Return values:
0for success
non-0negative for errors

STEP 1. Restoring capacity parameters

STEP 2. Restore FullCap

STEP 3. Write DQACC to 200% of Capacity and DPACC to 200%

STEP 4. Restore Cycles register

Definition at line 761 of file max17055.cpp.

int save_Params ( saved_FG_params_t  FG_params )

Save Learned Parameters Function for battery Fuel Gauge model.

Details
It is recommended to save the learned capacity parameters every time bit 2 of the Cycles register toggles (so that it is saved every 64% change in the battery) so that if power is lost the values can easily be restored.
Parameters:
[in]FG_paramsFuel Gauge Parameters based on design details.
Return values:
0for success
non-0negative for errors

STEP 1. Checks if the cycel register bit 2 has changed.

STEP 2. Save the capacity parameters for the specific battery.

Definition at line 710 of file max17055.cpp.

int write_and_verify_reg ( Registers_e  reg_addr,
uint16_t  reg_data 
)

Write and Verify a MAX17055 register.

Details
This function writes and verifies if the writing process was successful
Parameters:
[in]reg_addr- register address
[out]reg_data- the variable that contains the data to write to the register address
Return values:
0on success
non-0for errors

Definition at line 159 of file max17055.cpp.

int writeReg ( const Registers_e  reg_addr,
uint16_t  reg_data 
) [protected]

Writes to MAX17055 register.

Writes a register.

Parameters:
[in]reg_addrThe register address
[in]reg_dataThe register data
Return values:
0on success
non-0for errors

Definition at line 101 of file max17055.cpp.


Field Documentation

const uint8_t I2C_R_ADRS = 0x6D [static]

8-bit read address

Definition at line 126 of file max17055.h.

const uint8_t I2C_W_ADRS = 0x6C [static]

8-bit write address

Definition at line 124 of file max17055.h.