Skip to content

Commit

Permalink
ISL94202: Avoid balancing during measurements
Browse files Browse the repository at this point in the history
Fixes #16
  • Loading branch information
martinjaeger committed May 20, 2021
1 parent 11d60a4 commit cd60e9a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
25 changes: 25 additions & 0 deletions src/isl94202/bms_isl94202.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,31 @@ bool bms_dis_switch(BmsConfig *conf, BmsStatus *status, bool enable)

void bms_apply_balancing(BmsConfig *conf, BmsStatus *status)
{
uint8_t stat3;
isl94202_read_bytes(ISL94202_STAT3, &stat3, 1);

/*
* System scans for voltage, current and temperature measurements happen in different
* intervals depending on the mode. Cell balancing should be off during voltage scans.
*
* Each scan takes max. 1.7 ms. Choosing 16 ms off-time for voltages to settle.
*/
if (stat3 & ISL94202_STAT3_INIDLE_Msk) {
// IDLE mode: Scan every 256 ms
isl94202_write_delay(ISL94202_CBONT, ISL94202_DELAY_MS, 240, 0);
isl94202_write_delay(ISL94202_CBOFFT, ISL94202_DELAY_MS, 16, 0);
}
else if (stat3 & ISL94202_STAT3_INDOZE_Msk) {
// DOZE mode: Scan every 512 ms
isl94202_write_delay(ISL94202_CBONT, ISL94202_DELAY_MS, 496, 0);
isl94202_write_delay(ISL94202_CBOFFT, ISL94202_DELAY_MS, 16, 0);
}
else if (!(stat3 & ISL94202_STAT3_INSLEEP_Msk)) {
// NORMAL mode: Scan every 32 ms
isl94202_write_delay(ISL94202_CBONT, ISL94202_DELAY_MS, 16, 0);
isl94202_write_delay(ISL94202_CBOFFT, ISL94202_DELAY_MS, 16, 0);
}

/*
* Balancing is done automatically, just reading status here (even though the datasheet
* tells that the CBFC register value cannot be used for indication if a cell is
Expand Down
6 changes: 3 additions & 3 deletions src/isl94202/registers.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@
#define ISL94202_CBONT_Msk (0xFFFU << ISL94202_CBON_Pos)

// Cell Balance Off Time (CBOFF)
#define ISL94202_CBOFT (0x26U)
#define ISL94202_CBOFT_Pos (0x0U)
#define ISL94202_CBOFT_Msk (0xFFFU << ISL94202_CBOF_Pos)
#define ISL94202_CBOFFT (0x26U)
#define ISL94202_CBOFFT_Pos (0x0U)
#define ISL94202_CBOFFT_Msk (0xFFFU << ISL94202_CBOF_Pos)

// Cell Balance Minimum Temperature Limit (CBUTS)
#define ISL94202_CBUTS (0x28U)
Expand Down

0 comments on commit cd60e9a

Please sign in to comment.