pranjal-joshi / BQ76952Lib

Arduino Library to control BQ76952 BMS
MIT License
12 stars 8 forks source link

Every loop reading data rotated. #2

Closed xury77 closed 3 years ago

xury77 commented 3 years ago

Finally, I was able to start I2c communication. However, there is a problem with the data rotating and not going into place. After each loop, the read data goes to a different place.

15:28:16.505 -> Cell voltage-1: 0 15:28:16.505 -> Cell voltage-2: 0 15:28:16.505 -> Cell voltage-3: 0 15:28:16.539 -> Cell voltage-4: 0 15:28:16.539 -> Cell voltage-5: 0 15:28:16.539 -> Cell voltage-6: 0 15:28:16.539 -> Cell voltage-7: 0 15:28:16.539 -> Cell voltage-8: 396 15:28:16.539 -> Cell voltage-9: 1926 15:28:16.539 -> Cell voltage-10: 1926 15:28:16.539 -> Cell voltage-11: 1930 15:28:16.539 -> Cell voltage-12: 1926 15:28:16.539 -> Cell voltage-13: 1928 15:28:16.539 -> Cell voltage-14: 1929 15:28:16.539 -> Cell voltage-15: 1927 15:28:16.539 -> Cell voltage-16: 1930 15:28:16.539 -> Current: 1928 15:28:16.539 -> Internal temp: -80.45 15:28:16.539 -> Termistor ts1: -80.15 15:28:16.539 -> Termistor ts2: -80.15 15:28:16.539 -> Termistor ts3: -80.15 15:28:16.574 -> Termistor hdq: -79.95 15:28:16.574 -> Termistor dchg: -80.15 15:28:16.574 -> Termistor ddsg: -79.95

Next time is:

15:28:26.699 -> Cell voltage-1: 6 15:28:26.699 -> Cell voltage-2: -22 15:28:26.699 -> Cell voltage-3: 0 15:28:26.699 -> Cell voltage-4: 0 15:28:26.699 -> Cell voltage-5: 0 15:28:26.699 -> Cell voltage-6: 0 15:28:26.699 -> Cell voltage-7: 0 15:28:26.699 -> Cell voltage-8: 0 15:28:26.699 -> Cell voltage-9: 0 15:28:26.699 -> Cell voltage-10: 0 15:28:26.699 -> Cell voltage-11: 0 15:28:26.699 -> Cell voltage-12: 0 15:28:26.699 -> Cell voltage-13: 0 15:28:26.699 -> Cell voltage-14: 0 15:28:26.699 -> Cell voltage-15: 0 15:28:26.699 -> Cell voltage-16: 0 15:28:26.733 -> Current: 0 15:28:26.733 -> Internal temp: -273.15 15:28:26.733 -> Termistor ts1: -273.15 15:28:26.733 -> Termistor ts2: -273.15 15:28:26.733 -> Termistor ts3: -273.15 15:28:26.733 -> Termistor hdq: -273.15 15:28:26.733 -> Termistor dchg: -96.85 15:28:26.733 -> Termistor ddsg: 6075.65 And again:

15:28:47.041 -> Cell voltage-1: 1927 15:28:47.041 -> Cell voltage-2: 1930 15:28:47.041 -> Cell voltage-3: 1928 15:28:47.041 -> Cell voltage-4: 1927 15:28:47.041 -> Cell voltage-5: 1929 15:28:47.041 -> Cell voltage-6: 1930 15:28:47.041 -> Cell voltage-7: 1930 15:28:47.041 -> Cell voltage-8: 1932 15:28:47.041 -> Cell voltage-9: 1930 15:28:47.041 -> Cell voltage-10: 1932 15:28:47.041 -> Cell voltage-11: 3071 15:28:47.041 -> Cell voltage-12: 6 15:28:47.075 -> Cell voltage-13: 6 15:28:47.075 -> Cell voltage-14: -45 15:28:47.075 -> Cell voltage-15: 0 15:28:47.075 -> Cell voltage-16: 0 15:28:47.075 -> Current: 0 15:28:47.075 -> Internal temp: -273.15 15:28:47.075 -> Termistor ts1: -273.15 15:28:47.075 -> Termistor ts2: -273.15 15:28:47.075 -> Termistor ts3: -273.15 15:28:47.075 -> Termistor hdq: -273.15 15:28:47.075 -> Termistor dchg: -273.15 15:28:47.075 -> Termistor ddsg: -273.15

nuitterlinden commented 3 years ago

Hi there, Please note that the bq chip needs significant waiting delays between subsequent i2c commands, for example; first tell the bq the address you like to read from with a write command, then wait for a 20ms delay and do a i2c read, for the amount of byes requested. When there is not enough delay, the BQ may return random values. In your case, what are the voltages present at the all 16 vc inputs?

xury77 commented 3 years ago

At this moment I use evaluation board with resistor shunts. On bqStudio all cell cell shows about 1926 and stack voltage 3071. I don't have any temperature sensor so values as -273,2 are correct. By observing the data movement I have the impression that the data is moving. Sometimes they go to the right places. I will try, on your advice, to place some delays between readings. The cause was trivial. 7bit I2C address for read and write should be the same. Now direct commands working, but still I have problems with writing to memory registers.