/* Change Design Capacity to 2200mAh */ I2C Write 0x8000 to 0x00 //UNSEAL it by sending 0x8000 to Control() (0x00 and 0x01) twice I2C Write 0x8000 to 0x00 I2C Write 0x0013 to 0x00 //Send SET_CFGUPDATE subcommand, Control(0x0013) I2C Read 0x06 //Confirm CFGUPDATE mode by polling Flags() register until bit 4 is set I2C Write 0x00 to 0x61 //Write 0x00 using BlockDataControl() command (0x61) to enable block data memory control I2C Write 0x52 to 0x3E //Write 0x52 using the DataBlockClass() command (0x3E) to access the State subclass (82 decimal, 0x52 hex) containing the Design Capacity parameter I2C Write 0x00 to 0x3F //Write the block offset location using DataBlock() command (0x3F). //Note: To access data located at offset 0 to 31, use offset = 0x00. To access data located at offset 32 to 41, use offset = 0x01. I2C Read 0x60 //Read the 1-byte checksum using the BlockDataChecksum() command (0x60) (Obtained checksum = 0x12) I2C Read 0x4A //Read both Design Capacity bytes starting at 0x4A (offset = 10). Block data starts at 0x40, so to read the data of a specific offset, use address 0x40 + mod(offset, 32). I2C Read 0x4B I2C Write 0x08 to 0x4A //Write both Design Capacity bytes starting at 0x4A (offset = 10). the new value is 2200 mAh. (0x0898 hex) I2C Write 0x98 to 0x4B I2C Write 0x72 to 0x60 //Write New Checksum (0x72 by checksum calculation as mentioned in technical reference) I2C Write 0x0042 to 0x00 //Soft Reset to exit CFGUPDATE Mode I2C Read 0x06 //Confirm CFGUPDATE has been exited by polling Flags() register until bit 4 is cleared. I2C Write 0x0020 to 0x00 //Return to SEALED mode
/* Change clear the OpConfig[BIE] to 0 */ I2C Write 0x8000 to 0x00 //UNSEAL it by sending 0x8000 to Control() (0x00 and 0x01) twice I2C Write 0x8000 to 0x00 I2C Write 0x0013 to 0x00 //Send SET_CFGUPDATE subcommand, Control(0x0013) I2C Read 0x06 //Confirm CFGUPDATE mode by polling Flags() register until bit 4 is set I2C Write 0x00 to 0x61 //Write 0x00 using BlockDataControl() command (0x61) to enable block data memory control I2C Write 0x40 to 0x3E //Write 0x52 using the DataBlockClass() command (0x3E) to access the State subclass (64 decimal, 0x40 hex) containing the OpConfig parameter I2C Write 0x00 to 0x3F //Write the block offset location using DataBlock() command (0x3F). //Note: To access data located at offset 0 to 31, use offset = 0x00. To access data located at offset 32 to 41, use offset = 0x01. I2C Read 0x60 //Read the 1-byte checksum using the BlockDataChecksum() command (0x60) (Obtained checksum = 0x5E) I2C Read 0x40 //Read both Design Capacity bytes starting at 0x40 (offset = 00). Block data starts at 0x40, so to read the data of a specific offset, use address 0x40 + mod(offset, 32). I2C Read 0x41 I2C Write 0x05 to 0x4A //Write both Design Capacity bytes starting at 0x4A (offset = 10). the new value is 2200 mAh. (0x05F8 hex) I2C Write 0xF8 to 0x4B I2C Write 0x61 to 0x60 //Write New Checksum (0x61 by checksum calculation as mentioned in technical reference) I2C Write 0x0042 to 0x00 //Soft Reset to exit CFGUPDATE Mode I2C Read 0x06 //Confirm CFGUPDATE has been exited by polling Flags() register until bit 4 is cleared. I2C Write 0x0020 to 0x00 //Return to SEALED mode
Hi friends!
I'm trying to capture the Voltage, Current, State of Charge (SOC) of a Li-Ion battery using BQ27411-G1A. I'm able to read the Voltage, Current and Power but the SOC value I'm getting is wrong. I'm getting the SOC value 100% sometimes, and 0% sometimes.
By reading the Flag Register (0x06-0x07), I found that the IC is unable to detect the battery and Flags [BAT_DET] is 0 for all the time. Then I tried to re-configure the OpConfig register (0x3A-0x3B) to change the OpConfig[BIE] pin to 0 so that I can manually give input to the IC about Battery Insertion. Following are the steps I did for this.
- Powered ON the board with a DC adapter without battery.
- Changed the "Design Capacity" value to 2200mAh (I'm using a 3.7V, 2200mAh, Li-Ion 18650 cylindrical battery). The pseudo code is attached.
- Changed the "OpConfig" register value to 0x05F8 to clear the OpConfig[BIE] to 0. This step is done to disable the [BIE] bit and manually enter the battery insertion from host. The pseudo code is attached.
- Plugged in the battery.
- Wrote BAT_INSERT Subcommand (0x000C) using the Control Register (0x0000) to Force the Flags() [BAT_DET] bit set since the OpConfig [BIE] bit is 0.
"I2C Write 0x000C to 0x00"
Now I tried to read the SOC Register (0x1C-0x1D) but the value I'm getting is 0x00 and the flag bit [BAT_SET] is cleared to 0 for all the time. But the voltage, current and power values are correct.
Is there anything missed in the process? Or anything wrong with the logic / code?
Any help is appreciated.
-Thanks in Advance
Hari