![]() |
Qwiic_MAX1704X_Py
2.0.0-1-g99d01a0
Python for SFE Qwiic MAX1704X
|
Public Member Functions | |
def | __init__ (self, address=None, i2c_driver=None, device_type=kDeviceTypeMAX17043) |
Constructor. More... | |
def | is_connected (self) |
Determines if this device is connected. More... | |
def | begin (self) |
Initializes this device with default parameters. More... | |
def | set_device (self, device_type) |
Set the device type. More... | |
def | quick_start (self) |
A quick-start allows the MAX17043 to restart fuel-gauge calculations in the same manner as initial power-up of the IC. More... | |
def | get_voltage (self) |
Get the MAX17043's voltage reading. More... | |
def | get_soc (self) |
get_soc() - Get the MAX17043's state-of-charge (SOC) reading, as calculated by the IC's "ModelGauge" algorithm. More... | |
def | get_version (self) |
Get the MAX17043's version number. More... | |
def | get_id (self) |
get_id() - (MAX17048/49) Returns 8-bit OTP bits set at factory. More... | |
def | set_reset_voltage_threshold (self, threshold) |
set_reset_voltage_threshold(threshold) - (MAX17048/49) Set the 7-bit VRESET value. More... | |
def | set_reset_voltage_volts (self, threshold_volts) |
Helper function to set the reset voltage threshold in volts. More... | |
def | enable_comparator (self) |
enable_comparator() - (MAX17048/49) Set bit in VRESET/ID reg Comparator is enabled by default. More... | |
def | disable_comparator (self) |
disable_comparator() - (MAX17048/49) Clear bit in VRESET/ID reg Disable the analog comparator, saves 0.5uA in hibernate mode. More... | |
def | get_change_rate (self) |
get_change_rate() - (MAX17048/49) Get rate of change per hour in % Output: (signed) Float (that is the 0.208% * CRATE register value) A positive rate is charging, negative is discharge. More... | |
def | get_status (self) |
(MAX17048/49) Get the 7 bits of status register More... | |
def | clear_status_reg_bits (self, mask) |
clear_status_reg_bits() - (MAX17048/49) Clear the specified mask in the status reg More... | |
def | is_reset (self, clear=False) |
is_reset() - (MAX17048/49) Check if the reset bit is set in the status register More... | |
def | is_voltage_high (self, clear=False) |
is_voltage_high() - (MAX17048/49) Check if the voltage high bit is set in the status register More... | |
def | is_voltage_low (self, clear=False) |
is_voltage_low() - (MAX17048/49) Check if the voltage low bit is set in the status register More... | |
def | is_voltage_reset (self, clear=False) |
is_voltage_reset() - (MAX17048/49) Check if the voltage reset bit is set in the status register More... | |
def | is_low (self, clear=False) |
is_low() - (MAX17048/49) Check if the low bit is set in the status register More... | |
def | is_change (self, clear=False) |
is_change() - (MAX17048/49) Check if the change bit is set in the status register More... | |
def | clear_alert (self) |
clearAlert() - Clear the MAX1704X's ALRT alert flag. More... | |
def | get_alert (self, clear=False) |
get_alert() - Check if the MAX1704X's ALRT alert interrupt has been triggered. More... | |
def | enable_soc_alert (self) |
enable_soc_alert() - (MAX17048/49) Enable the SOC change alert More... | |
def | disable_soc_alert (self) |
disable_soc_alert() - (MAX17048/49) Disable the SOC change alert More... | |
def | enable_alert (self) |
enable_alert() - Enable the MAX1704X's VRESET Alert More... | |
def | disable_alert (self) |
disable_alert() - Disable the MAX1704X's VRESET Alert More... | |
def | get_threshold (self) |
get_threshold() - Get the MAX17043's current percentage threshold that will trigger an alert. More... | |
def | set_threshold (self, percent=4) |
set_threshold() - Set the MAX17043's percentage threshold that will trigger an alert. More... | |
def | sleep (self) |
sleep() - Set the MAX17043 into sleep mode. More... | |
def | wake (self) |
wake() - Wake the MAX17043 up from sleep. More... | |
def | reset (self) |
Issue a Power-on-reset command to the MAX17043. More... | |
def | get_compensation (self) |
get_compensation() - Get the ModelGauge compensation value - an obscure 8-bit value set to 0x97 by default. More... | |
def | set_compensation (self, newCompensation) |
set_compensation(newCompensation) - Set the 8-bit compensation value. More... | |
def | set_valrt_max (self, threshold=0xFF) |
Set the MAX17048/49 VALRT Maximum threshold. More... | |
def | set_valrt_max_volts (self, threshold_volts=5.1) |
Helper function to set the MAX17048/49 VALRT Maximum threshold in volts. More... | |
def | get_valrt_max (self) |
Get the MAX17048/49 VALRT Maximum threshold LSb = 20mV. More... | |
def | set_valrt_min (self, threshold=0x00) |
Set the MAX17048/49 VALRT Minimum threshold. More... | |
def | set_valrt_min_volts (self, threshold_volts=0.0) |
Helper function to set the MAX17048/49 VALRT Minimum threshold in volts. More... | |
def | get_valrt_min (self) |
Get the MAX17048/49 VALRT Minimum threshold LSb = 20mV. More... | |
def | is_hibernating (self) |
is_hibernating() - (MAX17048/49) Check if the IC is in hibernate mode More... | |
def | get_hibrt_act_thr (self) |
get_hibrt_act_thr() - (MAX17048/49) Read and return the MAX17048/49 HIBRT Active Threshold LSb = 1.25mV More... | |
def | set_hibrt_act_thr (self, threshold) |
Set the MAX17048/49 HIBRT Active Threshold LSb = 1.25mV. More... | |
def | get_hibrt_act_thr_volts (self, threshold_volts) |
Helper function to set the MAX17048/49 HIBRT ACT Threshold in volts. More... | |
def | get_hibrt_hib_thr (self) |
get_hibrt_hib_thr() - (MAX17048/49) Read and return the MAX17048/49 HIBRT Hibernate Threshold LSb = 1.25mV More... | |
def | set_hibrt_hib_thr (self, threshold) |
Set the MAX17048/49 HIBRT Hibernate Threshold LSb = 1.25mV. More... | |
def | get_hibrt_hib_thr_percent (self, threshold_percent) |
Helper function to set the MAX17048/49 HIBRT Hibernate Threshold in percent LSb = 0.208%/hr. More... | |
def | enable_hibernate (self) |
enable_hibernate() - (MAX17048/49) Enable hibernate mode More... | |
def | disable_hibernate (self) |
disable_hibernate() - (MAX17048/49) Disable hibernate mode More... | |
def | write16 (self, address, register, data) |
Write 16-bit data to a register (big-endian) More... | |
def | read16 (self, address, register) |
Read 16-bit data from a register (big-endian) More... | |
Public Attributes | |
address | |
Properties | |
connected = property(is_connected) | |
def qwiic_max1704x.QwiicMAX1704X.__init__ | ( | self, | |
address = None , |
|||
i2c_driver = None , |
|||
device_type = kDeviceTypeMAX17043 |
|||
) |
Constructor.
int,optional | address: The I2C address to use for the device If not provided, the default address is used |
I2CDriver,optional | i2c_driver: An existing i2c driver object If not provided, a driver object is created |
def qwiic_max1704x.QwiicMAX1704X.begin | ( | self | ) |
Initializes this device with default parameters.
True
if successful, otherwise False
def qwiic_max1704x.QwiicMAX1704X.clear_alert | ( | self | ) |
clearAlert() - Clear the MAX1704X's ALRT alert flag.
def qwiic_max1704x.QwiicMAX1704X.clear_status_reg_bits | ( | self, | |
mask | |||
) |
clear_status_reg_bits() - (MAX17048/49) Clear the specified mask in the status reg
int | mask: The mask to clear |
def qwiic_max1704x.QwiicMAX1704X.disable_alert | ( | self | ) |
disable_alert() - Disable the MAX1704X's VRESET Alert
EnVr (enable voltage reset alert) when set to 1 asserts the ALRT pin when a voltage-reset event occurs under the conditions described by the VRESET/ ID register.
def qwiic_max1704x.QwiicMAX1704X.disable_comparator | ( | self | ) |
disable_comparator() - (MAX17048/49) Clear bit in VRESET/ID reg Disable the analog comparator, saves 0.5uA in hibernate mode.
def qwiic_max1704x.QwiicMAX1704X.disable_hibernate | ( | self | ) |
disable_hibernate() - (MAX17048/49) Disable hibernate mode
def qwiic_max1704x.QwiicMAX1704X.disable_soc_alert | ( | self | ) |
disable_soc_alert() - (MAX17048/49) Disable the SOC change alert
def qwiic_max1704x.QwiicMAX1704X.enable_alert | ( | self | ) |
enable_alert() - Enable the MAX1704X's VRESET Alert
EnVr (enable voltage reset alert) when set to 1 asserts the ALRT pin when a voltage-reset event occurs under the conditions described by the VRESET/ ID register.
def qwiic_max1704x.QwiicMAX1704X.enable_comparator | ( | self | ) |
enable_comparator() - (MAX17048/49) Set bit in VRESET/ID reg Comparator is enabled by default.
(Re)enable the analog comparator, uses 0.5uA.
def qwiic_max1704x.QwiicMAX1704X.enable_hibernate | ( | self | ) |
enable_hibernate() - (MAX17048/49) Enable hibernate mode
def qwiic_max1704x.QwiicMAX1704X.enable_soc_alert | ( | self | ) |
enable_soc_alert() - (MAX17048/49) Enable the SOC change alert
def qwiic_max1704x.QwiicMAX1704X.get_alert | ( | self, | |
clear = False |
|||
) |
get_alert() - Check if the MAX1704X's ALRT alert interrupt has been triggered.
bool | clear: If True, the alert flag will be cleared if it was set |
def qwiic_max1704x.QwiicMAX1704X.get_change_rate | ( | self | ) |
get_change_rate() - (MAX17048/49) Get rate of change per hour in % Output: (signed) Float (that is the 0.208% * CRATE register value) A positive rate is charging, negative is discharge.
def qwiic_max1704x.QwiicMAX1704X.get_compensation | ( | self | ) |
get_compensation() - Get the ModelGauge compensation value - an obscure 8-bit value set to 0x97 by default.
def qwiic_max1704x.QwiicMAX1704X.get_hibrt_act_thr | ( | self | ) |
get_hibrt_act_thr() - (MAX17048/49) Read and return the MAX17048/49 HIBRT Active Threshold LSb = 1.25mV
def qwiic_max1704x.QwiicMAX1704X.get_hibrt_act_thr_volts | ( | self, | |
threshold_volts | |||
) |
Helper function to set the MAX17048/49 HIBRT ACT Threshold in volts.
float | threshold_volts: The threshold voltage to set |
def qwiic_max1704x.QwiicMAX1704X.get_hibrt_hib_thr | ( | self | ) |
get_hibrt_hib_thr() - (MAX17048/49) Read and return the MAX17048/49 HIBRT Hibernate Threshold LSb = 1.25mV
def qwiic_max1704x.QwiicMAX1704X.get_hibrt_hib_thr_percent | ( | self, | |
threshold_percent | |||
) |
Helper function to set the MAX17048/49 HIBRT Hibernate Threshold in percent LSb = 0.208%/hr.
float | threshold_percent: The threshold percentage to set |
def qwiic_max1704x.QwiicMAX1704X.get_id | ( | self | ) |
get_id() - (MAX17048/49) Returns 8-bit OTP bits set at factory.
Can be used to 'to distinguish multiple cell types in production'.
Writes to these bits are ignored.
def qwiic_max1704x.QwiicMAX1704X.get_soc | ( | self | ) |
get_soc() - Get the MAX17043's state-of-charge (SOC) reading, as calculated by the IC's "ModelGauge" algorithm.
The first update is available approximately 1s after POR of the IC. Output: floating point value between 0-100, representing a percentage of full charge.
def qwiic_max1704x.QwiicMAX1704X.get_status | ( | self | ) |
(MAX17048/49) Get the 7 bits of status register
def qwiic_max1704x.QwiicMAX1704X.get_threshold | ( | self | ) |
get_threshold() - Get the MAX17043's current percentage threshold that will trigger an alert.
def qwiic_max1704x.QwiicMAX1704X.get_valrt_max | ( | self | ) |
Get the MAX17048/49 VALRT Maximum threshold LSb = 20mV.
def qwiic_max1704x.QwiicMAX1704X.get_valrt_min | ( | self | ) |
Get the MAX17048/49 VALRT Minimum threshold LSb = 20mV.
def qwiic_max1704x.QwiicMAX1704X.get_version | ( | self | ) |
Get the MAX17043's version number.
Output: 16-bit value representing the version number.
def qwiic_max1704x.QwiicMAX1704X.get_voltage | ( | self | ) |
Get the MAX17043's voltage reading.
Output: floating point value between 0-5V in 1.25mV increments.
def qwiic_max1704x.QwiicMAX1704X.is_change | ( | self, | |
clear = False |
|||
) |
is_change() - (MAX17048/49) Check if the change bit is set in the status register
bool | clear: If True, the change bit is cleared |
def qwiic_max1704x.QwiicMAX1704X.is_connected | ( | self | ) |
Determines if this device is connected.
True
if connected, otherwise False
def qwiic_max1704x.QwiicMAX1704X.is_hibernating | ( | self | ) |
is_hibernating() - (MAX17048/49) Check if the IC is in hibernate mode
def qwiic_max1704x.QwiicMAX1704X.is_low | ( | self, | |
clear = False |
|||
) |
is_low() - (MAX17048/49) Check if the low bit is set in the status register
bool | clear: If True, the low bit is cleared |
def qwiic_max1704x.QwiicMAX1704X.is_reset | ( | self, | |
clear = False |
|||
) |
is_reset() - (MAX17048/49) Check if the reset bit is set in the status register
bool | clear: If True, the reset bit is cleared |
def qwiic_max1704x.QwiicMAX1704X.is_voltage_high | ( | self, | |
clear = False |
|||
) |
is_voltage_high() - (MAX17048/49) Check if the voltage high bit is set in the status register
bool | clear: If True, the voltage high bit is cleared |
def qwiic_max1704x.QwiicMAX1704X.is_voltage_low | ( | self, | |
clear = False |
|||
) |
is_voltage_low() - (MAX17048/49) Check if the voltage low bit is set in the status register
bool | clear: If True, the voltage low bit is cleared |
def qwiic_max1704x.QwiicMAX1704X.is_voltage_reset | ( | self, | |
clear = False |
|||
) |
is_voltage_reset() - (MAX17048/49) Check if the voltage reset bit is set in the status register
bool | clear: If True, the voltage reset bit is cleared |
def qwiic_max1704x.QwiicMAX1704X.quick_start | ( | self | ) |
A quick-start allows the MAX17043 to restart fuel-gauge calculations in the same manner as initial power-up of the IC.
If an application's power-up sequence is exceedingly noisy such that excess error is introduced into the IC's "first guess" of SOC, the host can issue a quick-start to reduce the error. A quick-start is initiated by a rising edge on the QSTRT pin, or through software by writing 4000h to MODE register.
Note: on the MAX17048/49 this will also clear / disable EnSleep bit
def qwiic_max1704x.QwiicMAX1704X.read16 | ( | self, | |
address, | |||
register | |||
) |
Read 16-bit data from a register (big-endian)
int | register: The register to read from |
def qwiic_max1704x.QwiicMAX1704X.reset | ( | self | ) |
Issue a Power-on-reset command to the MAX17043.
This function will reset every register in the MAX17043 to its default value.
def qwiic_max1704x.QwiicMAX1704X.set_compensation | ( | self, | |
newCompensation | |||
) |
set_compensation(newCompensation) - Set the 8-bit compensation value.
This is an obscure 8-bit value that has some effect on Maxim's ModelGauge algorithm. The POR value of RCOMP is 0x97.
From the datasheet: "Contact Maxim for instructions for optimization." For best performance, the host microcontroller must measure battery temperature periodically, and compensate the RCOMP ModelGauge parameter accordingly, at least once per minute. Each custom model defines constants RCOMP0 (default is 0x97), TempCoUp (default is -0.5), and TempCoDown (default is -5.0). To calculate the new value of CONFIG.RCOMP:
// T is battery temperature (degrees Celsius) if (T > 20) { RCOMP = RCOMP0 + (T - 20) x TempCoUp;} else { RCOMP = RCOMP0 + (T - 20) x TempCoDown; }
: param newCompensation: The new compensation value to set : type newCompensation: int
: return: True if successful, otherwise False : rtype: bool
def qwiic_max1704x.QwiicMAX1704X.set_device | ( | self, | |
device_type | |||
) |
Set the device type.
Do this after instantiation but before .begin()
int | device_type: The device type to set |
def qwiic_max1704x.QwiicMAX1704X.set_hibrt_act_thr | ( | self, | |
threshold | |||
) |
Set the MAX17048/49 HIBRT Active Threshold LSb = 1.25mV.
def qwiic_max1704x.QwiicMAX1704X.set_hibrt_hib_thr | ( | self, | |
threshold | |||
) |
Set the MAX17048/49 HIBRT Hibernate Threshold LSb = 1.25mV.
def qwiic_max1704x.QwiicMAX1704X.set_reset_voltage_threshold | ( | self, | |
threshold | |||
) |
set_reset_voltage_threshold(threshold) - (MAX17048/49) Set the 7-bit VRESET value.
A 7-bit value that controls the comparator for detecting when a battery is detached and re-connected. 40mV per bit. Default is 3.0V. For captive batteries, set to 2.5V. For removable batteries, set to at least 300mV below the application's empty voltage, according to the desired reset threshold for your application. Input: [threshold] - Should be a value between 0-127. Output: 0 on success, positive integer on fail.
int | threshold: The threshold value to set |
def qwiic_max1704x.QwiicMAX1704X.set_reset_voltage_volts | ( | self, | |
threshold_volts | |||
) |
Helper function to set the reset voltage threshold in volts.
float | threshold_volts: The threshold voltage to set |
def qwiic_max1704x.QwiicMAX1704X.set_threshold | ( | self, | |
percent = 4 |
|||
) |
set_threshold() - Set the MAX17043's percentage threshold that will trigger an alert.
int | percent: The percentage value that will trigger an alert interrupt. Any value between 1 and 32 is valid. Default value is 0x1C == 4% |
def qwiic_max1704x.QwiicMAX1704X.set_valrt_max | ( | self, | |
threshold = 0xFF |
|||
) |
Set the MAX17048/49 VALRT Maximum threshold.
This register is divided into two thresholds: Voltage alert maximum (VALRT.MAX) and minimum (VALRT. MIN). Both registers have 1 LSb = 20mV. The IC alerts while VCELL > VALRT.MAX or VCELL < VALRT.MIN
int | threshold: The threshold value to set |
def qwiic_max1704x.QwiicMAX1704X.set_valrt_max_volts | ( | self, | |
threshold_volts = 5.1 |
|||
) |
Helper function to set the MAX17048/49 VALRT Maximum threshold in volts.
float | threshold_volts: The threshold voltage to set |
def qwiic_max1704x.QwiicMAX1704X.set_valrt_min | ( | self, | |
threshold = 0x00 |
|||
) |
Set the MAX17048/49 VALRT Minimum threshold.
This register is divided into two thresholds: Voltage alert maximum (VALRT.MAX) and minimum (VALRT. MIN). Both registers have 1 LSb = 20mV. The IC alerts while VCELL > VALRT.MAX or VCELL < VALRT.MIN
int | threshold: The threshold value to set |
def qwiic_max1704x.QwiicMAX1704X.set_valrt_min_volts | ( | self, | |
threshold_volts = 0.0 |
|||
) |
Helper function to set the MAX17048/49 VALRT Minimum threshold in volts.
float | threshold_volts: The threshold voltage to set |
def qwiic_max1704x.QwiicMAX1704X.sleep | ( | self | ) |
sleep() - Set the MAX17043 into sleep mode.
In sleep mode, the IC halts all operations, reducing current consumption to below 1uA. After exiting sleep mode, the IC continues normal operation. In sleep mode, the IC does not detect self-discharge. If the battery changes state while the IC sleeps, the IC cannot detect it, causing SOC error. Wake up the IC before charging or discharging.
def qwiic_max1704x.QwiicMAX1704X.wake | ( | self | ) |
wake() - Wake the MAX17043 up from sleep.
def qwiic_max1704x.QwiicMAX1704X.write16 | ( | self, | |
address, | |||
register, | |||
data | |||
) |
Write 16-bit data to a register (big-endian)
int | register: The register to write to |
int | data: The data to write |
qwiic_max1704x.QwiicMAX1704X.address |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |