Editing defaultCalibration.cpp

231 views
Skip to first unread message

Diogo Carvalho

unread,
Jan 22, 2016, 5:47:44 AM1/22/16
to cheali-charger
Hi Pawel,

I want to edit the defaultCalibration.cpp to my charger.
Can you explain what is the mean of each value and how I can calculate the values?

Thanks

Paweł Si

unread,
Jan 22, 2016, 9:25:06 AM1/22/16
to cheali-charger
2016-01-22 11:47 GMT+01:00 Diogo Carvalho <diogoc....@gmail.com>:
Hi Pawel,

I want to edit the defaultCalibration.cpp to my charger.
Can you explain what is the mean of each value


The defaultCalibration.cpp file contains the default calibration for each charger,
this calibration will be overwritten when you calibrate your charger.
(you can always go back to default by pressing "options"->"reset default")

We use a two points calibration method for each input -  you have to tell the charger
what a ADC reading corresponds to what "real" value at two points,
for example:
{{4701, 3660}, {0, 0}}, //Textern
first point is {4701, 3660}, when the ADC returns 4701 we assume the external temperature is 36.60°C (it's the human body temperature, you can try to guess how I measured it ;) )
second point is {0, 0} when the ADC returns 0 the temp is 0°C.
we use a linear function to extrapolate any other values:


each line in AnalogInputs::inputsP_[] corresponds to one input, example:

const AnalogInputs::DefaultValues AnalogInputs::inputsP_[] PROGMEM = {

  {{0,  50},         {12913,  11895}},   //Vout_plus_pin

  {{0,  50},         {12913,  11895}},   //Vout_minus_pin

  {{348,  100},         {5491,  1000}},   //Ismps

  {{1230,  100},         {3947,  300}},   //Idischarge


  {{0,  0},         {1,  1}},   //VoutMux

  {{8000,  5940},         {8642,  3479}},   //Tintern

  {{0,  0},         {23492,  14052}},   //Vin

  {{4701,  3660},         {0,  0}},   //Textern


  {{0,  0},         {25219,  3946}},   //Vb0_pin

  {{0,  0},         {26178,  3975}},   //Vb1_pin

  {{0,  0},         {26077,  3957}},   //Vb2_pin

  {{0,  0},         {26171,  3963}},   //Vb3_pin

  {{0,  0},         {25184,  3912}},   //Vb4_pin

  {{0,  0},         {25169,  3916}},   //Vb5_pin

  {{0,  0},         {25405,  3933}},   //Vb6_pin


  {{347,  100},         {5487,  1000}},   //IsmpsSet

  {{1915,  100},         {6210,  300}},   //IdischargeSet

};

inputs:
Vout_plus_pin -> Voltage between GND and "+" terminal (batteries red wire) (in mV: 11895 == 11.895V ), output voltage is: Vout = Vout_plus_pin - Vout_minus_pin
Vout_minus_pin -> Voltage between GND and "-" terminal (batteries black wire) (in mV: 11895 == 11.895V ), output voltage is: Vout = Vout_plus_pin - Vout_minus_pin
Ismps -> output current when charging (in mA: 1000 == 1A)
Idischarge -> output current when discharging (in mA: 300 == 300mA)
VoutMux -> not used
Tintern -> internal temperature (used when a internal sensor is present, in 10m°C: 3479 == 34.79°C)
Vin -> power supply voltage (in mV: 14052 == 14.052V)
Textern -> external sensor temperature  (in 10m°C: 3660 == 36.60°C)
Vb0_pin -(*) voltage between GND and first balance port pin (not always used, in mV 3946== 3.946V)
Vb1_pin -> (*) voltage between GND and second balance port pin (in mV 3975 == 3.975V)
Vb2_pin -> (*) voltage between GND and third balance port pin (in mV 3957 == 3.957V)
Vb3_pin -> voltage on the third cell (in mV 3963 == 3.963V)
Vb4_pin -> voltage on the fourth cell (in mV 3912 == 3.912V)
Vb5_pin -> voltage on the fifth cell (in mV 3912 == 3.912V)
Vb6_pin -> voltage on the sixth cell (in mV 3912 == 3.912V)

outputs:  (what should be set on the PWM (or PID) to get a particular output current)
IsmpsSet -> output current when charging (in mA: 1000 == 1A)
IdischargeSet -> output current when discharging (in mA: 300 == 300mA)

 
(*) for 200W chargers:
1. Vb0_pin - is not used
2. Vb1_pin, Vb2_pin, Vb3_pin - indicates the voltage on each cell (first, second, third)

(*) for 50W chargers:
Vb1 = Vb1_pin - Vb0_pin  (voltage on first cell)
Vb2 = Vb2_pin - Vb1_pin  (voltage on second cell)
Vb3 = Vb3_pin - Vb2_pin  (voltage on third cell)


and how I can calculate the values?

hm.. the easiest way is to calibrate you charger then
read you eeprom and save it to a file and run:
cheali-charger$ cd utils/eepromExtractor
cheali-charger/utils/eepromExtractor$ ./eeprom.py some_eeprom_file.bin

if everything goes well you should see a new defaultCalibration.cpp corresponding to your current calibration.
(you need python for that)
 
Best Regards
Paweł

Diogo Carvalho

unread,
Jan 22, 2016, 11:02:41 AM1/22/16
to cheali-charger
Thank you very much :)

It is possible somewhat to see the adc value of the inputs?


I am not very familiar with python. One day if I have time I can make an application in C# in order to extract the contents of the EEPROM.
It would be interesting too add the ability to make changes in EEPROM and reloading without having to program the entire firmware.

Paweł Si

unread,
Jan 22, 2016, 6:13:54 PM1/22/16
to cheali-charger
2016-01-22 17:02 GMT+01:00 Diogo Carvalho <diogoc....@gmail.com>:
Thank you very much :)

It is possible somewhat to see the adc value of the inputs?


yes it is, using the UART (you need a USB dongle) 
if you set: "options"->"settings"->"UART:"  to "ext. Adc"
the UART will print all data in ADC values, example:
.
$1;1;7.8;3858;0;0;0;0;47039;2908;14059;0;0;5;5;6;6;0;0;0;0;0;0;1267;0;99;1483;7
$2;1;7.8;4107;0;0;7427;0;8791;23505;60419;0;0;0;38;38;39;40;0;0;100;13;3858;0;0;382;0;2908;14059;47039;0;0;0;5;5;6;6;0;0;0;0;3939;15
$3;1;7.8;1076;1660;61
.

you are interest in lines starting with "$2":
$2;1;7.8;4107;0;0;7427;0;8791;23505;60419;0;0;0;38;38;39;40;0;0;100;13;3858;0;0;382;0;2908;14059;47039;0;0;0;5;5;6;6;0;0;0;0;3939;15

where:
$2;1;7.8    == 2-> second channel (channel number), 1 ->  program type, 7.8 -> time in seconds
4107;0;0;7427;0;879....  == ADC values you are interested in (*)
15  == check sum

(*) order of the inputs is in:
or:
so 4107 - is the ADC value for Vout_plus_pin

only first 17 values make sens when you are interested in the ADC reading (the rest is garbage)
you can also print "real" values  by setting "options"->"settings"->"UART:"  to "ext. deb"
in this case all values make sens.
 


I am not very familiar with python. One day if I have time I can make an application in C# in order to extract the contents of the EEPROM.
 
be aware that the eeprom layout often changes.

It would be interesting too add the ability to make changes in EEPROM and reloading without having to program the entire firmware.

yes, that would be helpful, but consider using python for that, it's much more flexible than C#

JagiChan Sir

unread,
Jan 25, 2016, 9:01:56 AM1/25/16
to cheali-charger
Hi Pawel,
You wrote "we use a linear function to extrapolate any other values: http://www.wolframalpha.com/input/?i=linear+fit+%7B4701%2C++3660%7D%2C+++++++++%7B0%2C++0%7D
"
Q1: Where is the interpolation function defined?
Q2: Are you using the coeffecients that are result of the LinearFit? Where are the coeffecients defined?

Regards,
JagiChan

Paweł Si

unread,
Jan 25, 2016, 5:59:05 PM1/25/16
to cheali-charger
2016-01-25 15:01 GMT+01:00 JagiChan Sir <jaganna...@gmail.com>:
Hi Pawel,
You wrote "we use a linear function to extrapolate any other values: http://www.wolframalpha.com/input/?i=linear+fit+%7B4701%2C++3660%7D%2C+++++++++%7B0%2C++0%7D
"
Q1: Where is the interpolation function defined?

only the two points define the linear function,
a particular value is calculated with this function:

 
Q2: Are you using the coeffecients that are result of the LinearFit? Where are the coeffecients defined?

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

where (x0, y0), (x1 y1) are the given two calibration points,
and Yes, the "coefficients" would be the same if we would use (store) them.
Reply all
Reply to author
Forward
0 new messages