two point calibration

751 views
Skip to first unread message

Paweł Si

unread,
Apr 19, 2016, 3:52:40 PM4/19/16
to cheali-...@googlegroups.com, Igon

2016-04-18 0:08 GMT+02:00 Igon <igg...@gmail.com>:

Pawel, can you explain how the voltage calibration works -
As I understand - the first point - input voltage.. What about second point? 

Also how to use p1 & p0 correctly and can such calibration help with Thunder's crater between 1 and 15 volts?

This is how it works:

1. we measure i_adc_[Vout_plus_pin]     - ADC readings between red plus wire and GND;
2. we measure i_adc_[Vout_minus_pin]  - ADC readings between black minus wire and GND;

from this two values we calculate the output voltage taking into account calibration:

Vout = calibrateValue(Vout_plus_pin, i_adc_[Vout_plus_pin]) - calibrateValue(Vout_minus_pin, i_adc_[Vout_minus_pin])

The calibrateValue function is just a linear interpolation of the two points: p0, p1.

when you do a simple calibration p0 is set to {0,0} by default - which means:  a ADC=0 is 0V, and you only set the second point: p1.

To be more precise, when you "edit" a cell voltage in "calibration->voltage" we:
1. take   x = i_adc_[Vout_plus_pin]  reading
2. take   y = "V1-6:" displayed voltage  
and we set p1 to {x, y} for the  Vout_plus_pin input
we also set the same value p1 = {x,y} for the Vout_minus_pin input,
(both inputs are calibrated with the same p1)
p0 for these inputs is untouched and should be = {0,0}.
 
-----------------------------------------------------------------------

Performing a 2 point calibration for Vout, (proposition):

1. go to "calibrate->expert DANGER!"
2. set "calib. p.:" to 1
3. take a battery ~15V, connect it to GND (not the black minus wire, but the PCB's GND) and to the red plus wire.
4. measure battery voltage and set it in "Vplus:"

5. set "calib. p.:" to 0
6. take a battery ~1.5V, connect it to GND and to the red plus wire.
7. measure battery voltage and set it in "Vplus:"

8. set "calib. p.:" to 1
9. take a battery ~1.5V, connect it to GND and to the black minus wire.
10. measure battery voltage and set it in "Vminus:"

note: we use low voltage to calibrate the minus wire since there is voltage on it only when current is flowing and it is quite small (<1V), we also leave p0 at {0,0}.


 
(Y axis - difference between Vout indication and real voltage in calibration mode, balancer is not connected)
















T610out - output voltage error of HW-modded Thunder T610 in LED mode
Strange but PWM "DAC" linearity is much better than ADC

I fixed a bug recently in the ADC routine:
maybe it will help.

also this may be interesting:

 

Do we have some more eeprom space for multipoint voltage calibration
For example for 1-2-5-10-20v?

To be honest, I'm not a big fan of this approach,
even with 2 points the calibration procedure is quit complicated,
and I'm not even sure if it gives any benefits.
The problem is  that when you connect a constant voltage to the output
and you start charging (current is flowing) then the i_adc_[Vout_plus_pin]
and i_adc_[Vout_minus_pin]  values start to rise,
when p0 != {0,0} or there are more points 
you could experience a voltage change even when the voltage is constant.


Igon

unread,
Apr 24, 2016, 5:10:23 PM4/24/16
to cheali-charger, igg...@gmail.com
 
I fixed a bug recently in the ADC routine:
maybe it will help.
 
I was going to ask you about occasional abnormal voltage readings (65472) but you fixed it earlier ;)
Hope it will also help against "battery disconnected" at discharge

Paweł Si

unread,
Apr 26, 2016, 10:52:51 AM4/26/16
to cheali-charger
2016-04-24 23:10 GMT+02:00 Igon <igg...@gmail.com>:
 
I fixed a bug recently in the ADC routine:
maybe it will help.
  
I was going to ask you about occasional abnormal voltage readings (65472) but you fixed it earlier ;)

Yes, it was a fix for this issue. 
 
Hope it will also help against "battery disconnected" at discharge

hm.. I will check that.
 

Igon

unread,
May 2, 2016, 8:15:18 AM5/2/16
to cheali-charger

>> we use this formula:
>> y = (x-x0)*(y1-y0)/(x1-x0) + y0

Can we calculate  y0 for x0 = 0
and y1 -= y0

and use simplified formula?
y = x * y1 / x1 + y0


Heh, according to T610's graph - precise calibration can be quite tricky



















For example - current will be calibrated at 0.5 and 5V points for 50W chargers
T610 -- standard calibration
T610_8p -- 8-point calibration
mega32 -- standard calibration, same charger, different CPU

Yes I am still thinking about multipoint calibration.. actually it must be a linearization for calibration
I expect it will be the same for all ADC inputs (How did you think, is it true?)
It must be applied before AnalogInputs::calibrateValue -- x = linearise(x); y = calibrateValue(..., x);
Also I am not searching the way to calculate linearisation coefficients automatically because it is a compromise between local error and whole ADC transfer function


Pawel can you please start changing build versions?
All versions are 1.99 and you never know is it compatible with your current eeprom version or it asks you to reset it all..
Something like 1.9.10.3.12

Paweł Si

unread,
May 21, 2016, 1:52:41 PM5/21/16
to Igon, cheali-charger
2016-05-02 14:15 GMT+02:00 Igon <igg...@gmail.com>:

>> we use this formula:
>> y = (x-x0)*(y1-y0)/(x1-x0) + y0

Can we calculate  y0 for x0 = 0
and y1 -= y0

and use simplified formula?
y = x * y1 / x1 + y0

In theory we could, but this has some consequences:
currently the smallest error should be near the calibration points,
we are using integers for all calculations (instead of floats)
so if we calculate y0 for x0=0 (it will be rounded to the nearest integer) 
we will introduce a additional error to the system.
 

Heh, according to T610's graph - precise calibration can be quite tricky



















For example - current will be calibrated at 0.5 and 5V points for 50W chargers
T610 -- standard calibration
T610_8p -- 8-point calibration
mega32 -- standard calibration, same charger, different CPU

Yes I am still thinking about multipoint calibration.. actually it must be a linearization for calibration
I expect it will be the same for all ADC inputs (How did you think, is it true?)

if I were you, I would probably only add multipoint calibration to Vout,
mainly because of the eeprom shortage.
Currently we have 15 inputs (17 inputs for 8-cell charger) , each calibration point requires 2*2 bytes = 4 bytes,
so 8 cabli. points for each input would require 8*15*4 = 480 bytes (half of the eeprom)

 
It must be applied before AnalogInputs::calibrateValue -- x = linearise(x); y = calibrateValue(..., x);
Also I am not searching the way to calculate linearisation coefficients automatically because it is a compromise between local error and whole ADC transfer function
 

Pawel can you please start changing build versions?
All versions are 1.99 and you never know is it compatible with your current eeprom version or it asks you to reset it all..
Something like 1.9.10.3.12
 
hm... if you referring to the hex/bin file name I'm totally with you,
I will add such a suffix after the v2.00 release - I hope to release it  this weekend.

Maksym Siryk

unread,
May 28, 2016, 11:29:44 AM5/28/16
to cheali-charger, igg...@gmail.com
So what is calibration procedure now? 

As I undestand:
1). Calibrate voltage,currentcharge and discharge.
2). Go to expert calibration and calibrate Vb0pin, Vb1pin, Vb2pin.
3). In expert calibration calibrate Vplus and Vminus at p.0 and p.1 by 10 steps wrote in first message.  
4). If make any change in voltage calibration at step 1 I must recalibrate step 2-3. 

Is it correct? And I can't see any confirmayion during calibration p.0 and p.1. So when I change p.1 to p.0 does calibrated value save?

Ronald Zonneveld

unread,
May 29, 2016, 10:25:09 AM5/29/16
to cheali-charger, igg...@gmail.com
i think we should split this calibation thing into

Multicell calibration(used only for multi cell batteries)
Single cell calibration.(only used for single cell lipo's and/or pb/zinc/nicad/nimh

i noticed that the standard calibration works perfectly for multicell lipo's(vb1-Vb6 are correct and also total voltage is correct)

however the p0, p1, Vplus and vminus calibration seems to affect single sell calibration and not so much multi cell

eg you charge+balance a multi cell lipo
after charging has completed it displays the total voltage.
now if you disconnect the balanceplug the total voltage should stay the same but is is not.
the total voltage changes when you disconnect the balanceplug

if the charger is correctly calibrated on al fronts it stays the same.

i can however not get it right when doing the procedure

The only(and quickest way) to get it corrected is to write down the difference in voltage between balance plug connected and not connected.
i add/substract that difference from the vplus and then it is alright.


Igon

unread,
Jun 1, 2016, 5:24:26 PM6/1/16
to cheali-charger, igg...@gmail.com

Not sure do we need such precision and complexity with conventional chargers or not %)
multipoint calibration(linearization) mostly aimed at power supplies..


>> Currently we have 15 inputs (17 inputs for 8-cell charger) , each calibration point requires 2*2 bytes = 4 bytes,
>> so 8 cabli. points for each input would require 8*15*4 = 480 bytes (half of the eeprom)

Yes, multipoint become too heavy in a case of separate function for each input
I suggest to linearize ADC circuit --
  x = linearize(x); (linearization is the same for all inputs)

And use conventional "AnalogInputs::calibrateValue" after it --
y = calibrateValue(..., x);

(as I understand we have only one ADC and multiplier with different per-channel amplification and biasing)
btw ADC's artificial noise did not significantly affect ADC's transfer function (non-linearity)


----

Does calibration point setting has any effect at balancer calibration?
I want to calibrate balancer for p0 = 1.8 and p1 = 4.2 volts
p0 = 0 gives me quite inaccurate readings with NiZN batteries..

TBAmax

unread,
Dec 15, 2022, 5:21:15 PM12/15/22
to cheali-charger
Quite a old thread here. But I am looking at the code and noticing some topics:
1.Left alinged ADC on atmega32. Left aligned is originally only meant to be used when you want to have a lower (8bit) resolution and easy way to discard two lower bits. Left aliged the way it is currently used essentially then means that values are pre multiplied by 64. This gives no benefit.
2.Why not use usual common oversampling techniques: Sample 2;4;8;16;32 or 64 samples? 10 bit ADC values can be added 64 times and still fit to the uint16_t. No need to use uint32_t there. Moreover, when after needed, the sum can be divided down by bit shifting, to use the average of the sampled values. Atmega32 do not have a hardware divide so bit shift used instead is blazing fast, as this is usually done so.
In other words: when you divide by variable or some random number the atmega32 struggles. When you divide by constant  2;4;8;16;32 or 64 atmega32 is happy, because it can use its bit shift.
Message has been deleted

Kamil Siegmund

unread,
May 27, 2023, 5:27:14 PM5/27/23
to cheali-charger
Procedura kalibracji p0 i p1 jest bardzo niejasna!!!!
Nie wiadomo co właściwie dzięki niej zyskujemy.  Dobrze by było sformułować pełną instrukcję wszystkich dostępnych opcji kalibracji !!!!
Nie rozumiem dlaczego po kalibracji dla 5s napięcia na celach są OK, ale dla 3s już nie. Nie znajdę odpowiedzi w instrukcji... bo ta jest bardzo ogólna, nie uwzględnia dodatkowych opcji p0 i p1 oraz nie ma w niej informacji, o tym co możemy zyskać.

Instalacja oprogramowania cheali-charger jest prostsza i lepiej opisana niż kalibracja, od której zależy bezpieczeństwo naszych lipo i domów !!!!!!!!!!!!!!!!!!!!!!!! Uważam, że konieczne jest napisanie szczegółowej i zrozumiałej instrukcji dla wszystkich opcji !!!! Zysków i strat użycia danej opcji, marginesu błędu odczytu wartości, wzajemnych zależności itp.... w przeciwnym wypadku używanie cheali-charger jest bardzo niebezpieczne i frustrujące, bo użytkownicy mogą nie zdawać sobie sprawy z tego co dokładnie robią i jaki to może mieć skutek !!!! Zawarcie informacji jakiej wersji oprogramowania dotyczy instrukcja!!!

Jestem w trakcie poszukiwań wyżej wymienionych informacji, bo taka instrukcja nie istnieje. Problemy były poruszane w róźnych wątkach na grupie, ale informacje są niekompletne bądź zdawkowe, lub niezrozumiałe dla kogoś kto nie zajmuje się programowaniem.

PS- Używam clone B6 , zamieżam wstawić do niej dodatkowy opamp dla pomiaru bal0 i bal 1 , bo irytuje mnie brak dokładności oryginalnego rozwiązania.
Serdecznie pozdrawiam !!!

Kamil Siegmund

unread,
May 27, 2023, 6:37:50 PM5/27/23
to cheali-charger
The p0 and p1 calibration procedure is very unclear!!!! We don't know what we gain from it. It would be good to formulate a complete manual of all available calibration options!!!! I do not understand why after calibration for 5s the voltages on the cells are OK, but for 3s they are not. I will not find the answer in the manual ... because this is very general, it does not take into account the additional p0 and p1 options and there is no information about what we can gain. The installation of the cheali-charger software is simpler and better described than the calibration, on which the safety of our lipo and homes depends !!!!!!!!!!!!!!!!!!!!!!!! I believe it is necessary to write a detailed and understandable manual for all options !!!! The profit and loss of using a given option, the margin of error reading the values, interdependencies, etc.... otherwise, using the cheat-charger is very dangerous and frustrating, because users may not realize what exactly they are doing and what effect it can have !!!! Including information on which software version the manual applies to!!! I am in the process of searching for the above-mentioned information, because such a manual does not exist. The issues have been raised in various threads on the group, but the information is incomplete or perfunctory, or incomprehensible to someone who does not deal with programming. PS- I'm using clone B6, I'm going to put an additional opamp to it for measuring bal0 and bal 1, because I'm irritated by the lack of accuracy of the original solution. Best wishes !!

diggit

unread,
Jun 11, 2023, 12:03:05 PM6/11/23
to cheali-charger
Chill out honey bunny...

> We don't know what we gain from it.
Well, then don't use it. Calibration process does not mention it. You can assume is has sane defaults and happily ignore it.

> ...on which the safety of our lipo and homes depends
If you are not ok with risks, don't use cheali charger. Even thought it is not written in readme, developers don't take any responsibility for the code.
If there is something missing or does not work properly, any (constructive) contribution is welcome. Cheali is opensource project after all.

> PS- I'm using clone B6...
I suggest you to create new thread here and post pictures of your charger board and which file you flashed in. It is possible that they are not compatible and you should flash something different.


Anyway, to answer question what does "calib. p." option do...
To convert some ADC value to voltage/current/whatever, you need to do some mathematical conversion. Due to nature of some components (eg. op amp offsets), 0 from ADC does not have to mean 0 V/A/...
Once you have at least two calibration points, you can do linear interpolation to cover the rest of range. If there is linear relation between ADC value and measured property, 2 points are sufficient.
Try googling, there is a lot about this topic: https://www.google.com/search?q=two+point+calibration
Current measurement is most sensitive to this (several op amps in path, high gains). Due to that, menus are adjusted to be more clear about it.
Voltage measurements are not so sensitive to this phenomenon (in these devices). Still, charger has two calibration points for them. By default, calibration point 0 is set tot 0:0, meaning that value 0 from ADC represents 0 V measured. Normal calibration process is touching only calibration point 1. No significant offset is expected and thus point 0 is left to it's defaults (0:0).
Reply all
Reply to author
Forward
0 new messages