Aliexpress 0x32 Clone Support
cranefist opened this issue · 16 comments
Would it be possible to support the Aliexpress clone boards that have 0x32 address? They seem to work, but work differently. And i expect that there are more of these than there are of the original ones around. Someone must have gotten these to work properly.
There is one post here, that shows how it works:
https://forum.arduino.cc/t/max17043-fuel-gauge-not-working-at-all/329534/17
I tested this (after changing the I2C address in the MAX1704X.h file) , by rapidly putting it to sleep, waking it up and then reading. This way it gets a reading, other than that it seems to not read the voltage. The percentage is still wrong though.
Also, seems the voltage reading is wrong. I measured the cell at 4.158v. But at least it gives some sort of reading.. though the max is 5v, so maybe its just giving the max value. But the person on arduino forum did manage to get it working.
After testing more, quick start or reset works also. After that you can read it once in a really short time period. I tested using a ledlight, and the voltage reading drops like it should. And right around when it hits 4.2v the percentage is 100%. So the readings are just too high, but otherwise correct.
So this was the quickest way to read, using the example code:
FuelGauge.quickstart();
delay(100);
displayReading();
Just quickstart it before reading. It seems to need 100ms delay between the quickstart & reading.
Just the voltages & percentage now needs to be calibrated to match correct values. Maybe the percentage is using the 1/256 reading, instead of the 1/100%? Full cell reports 195%. And around 4.9 volts.
I am willing to make and changes necessary and provide support for clones. Do you have any idea what is needed? I need to try to purchase at least one clone to experiment with.
Currently, all i got is how to read it... i don't understand the readings yet, they do work in the sense that the readings go down as the battery is used. Just not sure how to get them right.
The original chip has a measuring range upto 5v, but this seems to top out at 4.2v. Because a fully charged and measured at 4.2v cell gives you the output of 4.9v. So maybe the 10bit readout is just scaled for the max of 4.2v.
Percentages go up to around 200% at fully charged. So there is some logic behind this, just need to figure it out.
I hooked up to my bench power supply. It tops out at 4.3v like I though. 4.364v according to my multimeter, at this point the chip reads 5115mv... and if you go over that, it loops back to 5mv. So the 12bit readout is scaled to 0 - 4.3v. Instead of the 0-5v.
It seems to have 10mv steps, so not sure if its 12bit.
At 4.25v it reads 200%. And at 2.75v its at 0%. These are both multimeter readings.
Highest percentage reading is 217.42%.
I just divided the percentage by 2 (or is this too simplistic, does it put the 50% value at a wrong point?.. also, 2.7v as 0% is kinda low.. ), and i think that fixes that.. then the 12bit voltage readout needs to be just correctly scaled. And that should fix that.
At what voltage does the authentic chip say 0%?
Adjusted the increments to 1.065 in the MAX17043.h. Now the voltage readings are perfectly accurate. Percentage with divider of 2.
Put to sleep works, wake up works. Reset works. Clear alert works. Setting threshold works.
Alert percentage should be also adjusted to show correctly. There is also a pin for the alert? I have not tested that.
12bit ADC value maxes at (accurate voltage reading):
So everything expect the alert works now perfectly. 4% alert percentage was triggered at 2% with the divider of 2. And 10% alert was triggered at 5%. So of course the alert needed a divider of 2 also to show correct values on the output print.
So the alert threshold values that are given to the chip need to be multiplied by 2, and outputs divided by 2.
So i can set the threshold between 2-16%. Probably reading the bits somehow wrong.. thats something i'm not good at. It probably needs double the bits! More bits.
So i think this is everything, and its now working 100%.
Can you try changing the compensation value to see how or if it affects the readings?
Can you try changing the compensation value to see how or if it affects the readings?
By the compensation value, you mean the 0x97? Ill try fiddling with it. Have no idea what to change it into.
I have a clone on order and will start to test with it as soon as I get it.
I received my clone and did some testing side by side with a SparkFun chip. The readings below are from the same battery.
SparkFun Chip:
Device Reading:
Address: 0x36
Version: 3
ADC: 3230
Voltage: 4037.50 mV
Percent: 80.59%
Is Sleeping: No
Alert: No
Threshold: 4%
Compensation: 0x97
Clone:
Device Reading:
Address: 0x32
Version: 3
ADC: 3772
Voltage: 4715.00 mV
Percent: 166.95%
Is Sleeping: No
Alert: Yes
Threshold: 4%
Compensation: 0x97
Did you change the voltage increment for this? If you change that, you will get accurate voltage readings. But i have not figured how to get the percentages to make sense.
I contacted the factory through alibaba, and got some files. But havent had time to check them properly.
In the above example, the increments can be changed to something like 1.07 to match but the reading wasn't consistent. There is also the issue that it always returns 0 unless quick start is used just prior to the VCELL reading. Lastly, even if the VCELL reading is compensated, the percentage is way off and there is no way to adjust this. The internal formula is not linear so it wold require knowing how the percentage is calculated to somehow applying a "smart" adjustment. All of this seems more work than needed to get these chips working.
If you can share the files/information you received I can spend some time looking into it.
Yes, you always have to do the quick start before the reading. And the correct adjustment was 1.06, and that makes sense considering how it tops at 4.3v instead of 5v having 12bit range.
The percentage was the actual issue, as that does not make sense. I dont think the readings are in any way "smart", i think there is just a curve. But on these fake chips, the percentage seems linear.
If you connect the authentic chip to a lab supply, and just adjust the voltage from 4.3v to around 3v.. i think you will see how the percentage is calculated and that it probably just has a precalculated curve.
Here is the file : https://aleksikoski.com/temp/MAX17043.zip
Just FYI, but I bought this one (I believe it's a copy of Sparkfun's?), and the address was 0x36.
I used your library (porrey/max1704x), and it worked just fine without modifying the code.
Just FYI, but I bought this one (I believe it's a copy of Sparkfun's?), and the address was 0x36.
I used your library (porrey/max1704x), and it worked just fine without modifying the code.
This one appears to have a genuine Maxim Integrated chip instead of a clone. The price is good too.
Clones of the MAX1704X chip appear to not work accurately. I have found no way to adjust this library to work with them. If anyone stumbles across a way, I will be more than happy to update the library as log as it does not affect the genuine chips. For no I am closing this issue as there are no apparent issues with the current library.