OpenXsensor 4 cell calibration problem!

Development & General Chat for the superb openxvario project.

Moderator: rainer

Post Reply
Juhani
Posts: 5
Joined: Fri Mar 29, 2019 1:28 pm
Country: -

OpenXsensor 4 cell calibration problem!

Post by Juhani » Tue Apr 23, 2019 7:08 pm

Hi, can someone please help me to find what I am doing wrong during calibration?

I am using:
3.3V arduino 8Mhz (vcc 3301 and just a 1mv drift down during 5min measurement)
UT171A (44000 count) multimeter
frsky taranis x9d

I got my hands on good multimeter and decided to calibrate 4th cell 4.23-4.24V problem.
4th cell is off in 2 of the sensors made even with measured ressistor values.
Everything seemed simple. Did excel to calculate offset and scale. (If i calculate by hand, i get correct correction.)
If i enter those values back to code, voltages go way off.
I have messed with it 3 nights by now and could not crack it.

From this forum I found out how to activate debugging and get values sent to taranis in 3 decimal places instead of two.
This should have made difference but it didnt.

snap of a excel is in the attachments.

This is what i started first and then entered those results to excel.
// ***** 6.2 - Voltage parameters *****
#define PIN_VOLTAGE 3 , 2 , 0 , 7 , 8 , 8
#define RESISTOR_TO_GROUND 1.302 , 3.578 , 2.188 , 1.302 , 0 , 18
#define RESISTOR_TO_VOLTAGE 0.362 , 5.498 , 6.724 , 5.512 , 0 , 47
#define OFFSET_VOLTAGE 0 , 0 , 0 , 0 , 0 , 0
#define SCALE_VOLTAGE 1.0,1.0,1.0,1.0, 1.0 , 1.0

lower
At 2300966 Cnt = 144 mVolt 0 = 3406
At 2300968 Cnt = 144 mVolt 1 = 6843
At 2300970 Cnt = 144 mVolt 2 = 10278
At 2300973 Cnt = 144 mVolt 3 = 13733
Cell calculation for cellId 0 Frist Cell = 1703 Second Cell = 1718 Frsky value = 6B66A740
Cell calculation for cellId 2 Frist Cell = 1717 Second Cell = 1727 Frsky value = 6BF6B542


upper
At 2452509 Cnt = 143 mVolt 0 = 4186
At 2452513 Cnt = 143 mVolt 1 = 8373
At 2452515 Cnt = 143 mVolt 2 = 12552
At 2452517 Cnt = 143 mVolt 3 = 16769
Cell calculation for cellId 0 Frist Cell = 2093 Second Cell = 2093 Frsky value = 82D82D40
Cell calculation for cellId 2 Frist Cell = 2089 Second Cell = 2108 Frsky value = 83C82942


---------------------------------------------------------------------------------
This is what i ended up after the corrections

// ***** 6.2 - Voltage parameters *****
#define PIN_VOLTAGE 3 , 2 , 0 , 7 , 8 , 8
#define RESISTOR_TO_GROUND 1.302 , 3.578 , 2.188 , 1.302 , 0 , 18
#define RESISTOR_TO_VOLTAGE 0.362 , 5.498 , 6.724 , 5.512 , 0 , 47
#define OFFSET_VOLTAGE -6 , 157 , 25 , -95 , 0 , 0
#define SCALE_VOLTAGE 0.99744 , 1.03600 , 1.00672 , 0.96982 , 1.0 , 1.0

openXsensor starting..
milli=0
freeRam=1012
Enter setup voltage
Reference voltage:3301
Voltage:1 , pin=3 , offset=-6 , mVoltPerStep=4.11
Voltage:2 , pin=2 , offset=157 , mVoltPerStep=8.48
Voltage:3 , pin=0 , offset=25 , mVoltPerStep=13.23
Voltage:4 , pin=7 , offset=-95 , mVoltPerStep=16.38
Voltage:5 , pin=8 , offset=0 , mVoltPerStep=3.23
Voltage:6 , pin=8 , offset=0 , mVoltPerStep=11.65
FRSky Output Module: TX Pin=4
Sport protocol= 1
End of general set up

upper
At 79979 Cnt = 143 mVolt 0 = 4167
At 79981 Cnt = 143 mVolt 1 = 8831
At 79983 Cnt = 143 mVolt 2 = 12667
At 79985 Cnt = 143 mVolt 3 = 16173
Cell calculation for cellId 0 Frist Cell = 2083 Second Cell = 2332 Frsky value = 91C82340
Cell calculation for cellId 2 Frist Cell = 1918 Second Cell = 1753 Frsky value = 6D977E42

2083*2= 4166 mV
2332*2= 4664 mV
1918*2= 3836 mV
1753*2= 3506 mV

Many thanks in advance,
Juhani
Attachments
openx.JPG


mstrens
Posts: 1245
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: OpenXsensor 4 cell calibration problem!

Post by mstrens » Tue Apr 23, 2019 7:53 pm

Calibration may not be done cell by cell.
In fact arduino does not measure the voltage of each cell individually.
It measures the voltages regarding ground so it measures:
- on the first pin = cell1
- on the second pin = cell1 + cell2
- on the third pin = cell1 + cell2 + cell3
- on the forth pin = cell1 + cell2 + cell3 + cell4.
Offsets and scales must be calculated based on those values.

So if I understand correctly your measurements and what you get with scale =1 and offset = 0, this is what you should apply
Volt 0 volt1 Volt2 volt3
3406 6843 10278 13733 output (with serial) Low
3403 6806 10238 13683 real (voltmeter) Low

4186 8373 12552 16769 output High
4181 8361 12542 16726 real High


0,997435897 1,016339869 1,013192612 1,002305665 scale

-5,733333333 148,8137255 175,5936675 81,66370224 offset

Note : here some offsets are quite big. You would probably get better results if you measure and get directly the voltage on each pin (so Volt1, vol2, volt3 and volt4); here I summarised the voltages of several cells which increase the risk of error.

Juhani
Posts: 5
Joined: Fri Mar 29, 2019 1:28 pm
Country: -

Re: OpenXsensor 4 cell calibration problem!

Post by Juhani » Wed Apr 24, 2019 4:50 pm

mstrens many thanks to you!

Config description wasnt that clear for me how to calibrate multiple cells.
After little bit of testing every sensor measurement is +- 0.01V off, thats perfect.


As a little note, my offset formula was done by the example and its clearly wrong.
It gets correct value but offset direction must be flipped.

in the description it is:

* and OFFSET_VOLTAGE = -3510 + (3622 * 0.99958 ) = 110

but should be OFFSET_VOLTAGE = -(-3510 + (3622 * 0.99958 )) = -110

(Thats what you showed too by calculating with my data.)


Adding spreadsheet as an attachment for those who plan to calibrate.
Attachments
OpenXsensor up to 4cell calibration.xlsx
(11.46 KiB) Downloaded 25 times


Post Reply

Return to “OpenXVario - an open source vario supported by the open source firmwares!!”