working on a Smart Battery. Want to read all the interesting data like voltage, innertemperatur, current,Capacity....
All these are done in seperated sketches. Now I want to put it in one big sketch and there I get problems I can't explain (see comments). It seems that the values are switched: Getting voltage-values during reading for temperature and vice versa.
Here is the code for the first attempt (getting voltage and temperature in one sketch):
Sorry for the lack of information. BL03 is a LiIon battery with Battery Managment System. It's like a black box for me. There is no datasheet available. So after reverse engineering I found out thats a SMBus Communciation to read out relevant data like Capacity, Current, Voltage,.....
So after spending a few hours searching in the forum, I found that a few guys have a similar problem. The SMBus protocol requires 2 Startbits and then one Stopbit. Something like this:
Startbit
WriteaddressBattery
Registeraddress (where the data is stored)
Startbit
ReadAddressBattery
Number of Bytes to write
Stopbit
Well, for one value like temperature, there is no problem. But putting two values in one programm the wire library seems not to be able to handle it correctly.
I haven't used either I2C or SMBus but my understanding is that they are both essentially the same, the differences being small and relating to clock speeds and voltage levels. Also SMBus has an ALERT signal.
In either case there are no start "bits", there is a single start "condition" and two acknowledge bits.
SMBus is very well documented, have you searched for the spec and other documentation?
ARDUINO 1.0.1 - 2012.05.21
...
* Added ability to generate repeated starts in the Wire library (in
master mode). Extra boolean parameters to endTransmission() and
requestFrom() control whether or not to send a stop (or a repeated
start instead). (Todd Krein)
http://code.google.com/p/arduino/issues/detail?id=663
...
I also used some SMBus devices which also didn't follow your description. Maybe your device is very special in this regard and introduced something special or you misinterpreted the start and stop condition to be start and stop bits (that are not bits because the clock line is not alternated). In any case, multiple start conditions are device specific and not part of the SMBus specification (to my knowledge).
Well, for one value like temperature, there is no problem. But putting two values in one programm the wire library seems not to be able to handle it correctly.
Please describe how this is meant. What does "one program" mean in this context?
I cannot find such a definition in the SMBus description on Wikipedia:
A Smart Battery IC needs the following and above mentioned transmission (pseudocode) without a stopbit between the startbits. And by the way: Wikipedia is not almighty
I also used some SMBus devices which also didn't follow your description
Yeah, totally right.
Maybe your device is very special in this regard and introduced something special or you misinterpreted the start and stop condition to be start and stop bits (that are not bits because the clock line is not alternated). In any case, multiple start conditions are device specific and not part of the SMBus specification (to my knowledge).
Well, I started with a white paper. After sniffing the data between a analyzing device, whose software is not open and which i could only use for a few hours, I decided to go that way. But I don't want to ignore that I could misinterpreted something.
Well, for one value like temperature, there is no problem. But putting two values in one programm the wire library seems not to be able to handle it correctly.
Please describe how this is meant. What does "one program" mean in this context?
Sorry. I'm not a native speaker. So what i meant was:
Reading one value in one sketch (in the loop() ) was no problem at all. But reading two values in one sketch got me the problem.