Go Down

Topic: SMBus reading battery status, decoding message (Read 3083 times) previous topic - next topic


Dec 04, 2011, 04:54 pm Last Edit: Dec 04, 2011, 04:56 pm by fca Reason: 1
I 'm doing some tests on batteries to use on my multisensor project...

i'm  connected to  battery using i2cmaster  and  reading fine all the info from the batt.
by bat has a TI2 BQ2060 (http://www.ti.com/lit/ds/symlink/bq2060a.pdf)

now according to bq2060 sheet the 0x16 register Battery Status has this result......  that i want to decode...

When i read that register like this
Code: [Select]
word rs=i2c_smbus_read_word( Cmd_BatteryStatus );
Serial.print(" |Cmd_Batterystatus DEC  ");   Serial.println(rs,DEC   );
Serial.print(" |Cmd_Batterystatus BIN  ");   Serial.println(rs,BIN   );
      Serial.print(" |Cmd_Batterystatus HEX  ");   Serial.println(rs,HEX   );

My output is :

|Cmd_Batterystatus DEC  2768
|Cmd_Batterystatus BIN  101011010000
|Cmd_Batterystatus HEX  AD0

Question is how to map this output with the table from the bq2060 above ?



The value AD0 would normally be written 0x0AD0. From this, you can see that the 4th column (the left most one) is 0. This means that 0x8000, 0x4000, 0x2000, and 0x1000 are not set.

The 3rd column contains an A, which is 8 + 2, which means that 0x0800 and 0x0200 are set. These correspond to TERMINATE_DISCHARGE_ALARM and REMAINING_CAPACITY_ALARM being set.

The 2nd column contains a D, which is 8 + 4 + 1. which means that 0x0080, 0x0040, and 0x0010 are set, which means that your battery is dead.


hi and thanks for the info, but i'm dum still din't get it...

You say that the third collunn has "A" ?  in "0AD0"  so when you the "left most zero" you mean the right most zero ?

0A-> contains the alarm bits, yes ?
and D0 the status bits , yes ?
when i put the bat on charge the status goes to 4290...

it means 4 "TERMINATE_CHARGE_ALARM"   2 ??? 

Sorry i'm not understanding any help or/and some documentation  it may help to understand please let  me know


You say that the third collunn has "A" ?  in "0AD0"  so when you the "left most zero" you mean the right most zero ?

No, I don't. It would have been better if your sample value did not have two 0 in it. The value that you are getting is a 2 byte value. Each byte is composed of 8 bits, or two nibbles. Each nibble has significance. In this value, the 4 nibbles are 0, A, D, and 0.

The first nibble, 0, is the first set of alarm values listed. The second nibble, A, is the second set of alarm values listed.

The simplest way to deal with the value is a set of if tests.
Code: [Select]
if(Cmd_Batterystatus > 0x8000)
   Cmd_Batterystatus -= 0x8000;

if(Cmd_Batterystatus > 0x4000)
   Cmd_Batterystatus -= 0x4000;

// Add cases for the rest of the values


Dec 05, 2011, 04:19 pm Last Edit: Dec 05, 2011, 04:35 pm by fca Reason: 1
Hi, can i match the bin results to direct table :

Cmd_Batterystatus BIN  1   0 1011010000.
                                |   |
                               bit0|  =1 means OVERCHARGED_ALARM is true
                                  bit1  =0   TERMINATE_CHARGE_ALARM  is false

its this ok ?

Another register:
"Pack Status and Pack Configuration (0x2f); [0x2f]
This function returns the Pack Status and Pack Configuration registers. The Pack Status register contains a
number of status bits relating to bq2060A operation. The Pack Status register is the least significant byte of the
word. The Pack Configuration register is the most significant byte of the word. The byte reflects how the
bq2060A is configured as defined by the value programmed in Pack Configuration in EE 0x3f.
The Pack Status Register consists of the following bits:

The Pack configuration Register consists of the following bits: :

I receive this output:
Pack Status and Pack Configuration   DEC  25842
Pack Status and Pack Configuration   BIN  110010011110010
Pack Status and Pack Configuration   HEX  64F2

My quick question is , is bit 6 (seal) enable ? i think no because if i count the 6 bit from the msbyte the left  the bit 6 if 0 .., but to see if i get should i start to read from left or from the right ?
         pack config     packstatus
BIN     01100100           11110010
so in pack config bit 6 is zero ?



Hi, can i match the bin results to direct table :

Yes. The value in Cmd_Batterystatus is stored in binary. The bits are numbered from left to right, so the overcharged alarm bit is bit 15. (Your numbering is wrong; the bits are numbered from the other end.)

Keep in mind that the binary value you are looking at has had all the leading 0s suppressed, so you don't see all 16 bits.

The same numbering problem and missing leading 0s applies to your other question, too.



@fca: did you have success with the Arduino and the bq2060A?

I found this http://info.hit-karlsruhe.de/info-ws10/arduino_logger/standdertechnik.html

But i have no success with reading.
I am using the Arduino-Uno but only get 0x00 from every register.
When i use the i2cmaster the Uno freezed.

Do you think you can shere your code with me?

Thank you
BR Bernd

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131