Voltage accuracy

440 views
Skip to first unread message

Maksym Siryk

unread,
Mar 5, 2015, 12:58:59 PM3/5/15
to cheali-...@googlegroups.com
Hello.

I try cheali-charger and it's excellent firmware! I use Turnigy Accucell 6. I change power MOSFET for less Rdson, TL431 for high stability voltage reference, shunt resistor for double charge and discharge current on output with genuine firmware (of course I had current twice lower on the screen) and shottky diodes to more powerful schottky diodes in TO220 case. So my charger now can provide up to 10 A charging current and up to 2 A discharge without any problem. Of course I change in cheali-charger HardwareConfig.h maximum current and maximum power. Anything is excellent except voltage accuracy on discharge at high current. Usually I am using 1S Li-Ion battery and don't use balance port. 

Whats the problem? When I discharge battery with 2A current I have difference betwen voltage on the screen and on the banana plug 46 mV. I try to connect balance port for one cell and has difference 64 mV. When I change charging current to 1 A the difference is 12 mV and 33 mV. When I charge battery the difference is about 5 mV on charging current 1A and 3A - it's OK. But discharging difference is very high for me. Also I use function Noise ADC. Of course when I measure voltage on battery the difference became higher because of wire resistant. 

Of course I know about o.discharge settings, but it only change cut-off voltage, so I get wrong Wh. Also o.discharhe settings is different for different discharge current. 

Maybe there are some way to correct voltage using wire resistance? Or add o.discharge (and o.charge) to the battery settings (but I still get wrong Wh). Maybe there are some way to calibrate charger voltage on two different current? Maybe anybody hase some ideas what to do with voltage difference on high curent? 

Paweł Si

unread,
Mar 6, 2015, 11:49:54 AM3/6/15
to cheali-...@googlegroups.com

Nice work!

Yes, there is a problem with  voltage measurement during discharge,
on 50W chargers connecting the balance port  wont help (not true for 200W chargers), this is why:



Vbat = Vbat+ - Vbat-
Vb1 = Vb_pin1 - Vb_pin0

We are measuring voltages according to GND,
during discharge the voltage on Bat- goes below 0V 
and the ADC sees only positive voltage,
it's even worse if you connect the balance port since:
Vb_pin0 < Vbat- < 0V

It's just a design "feature",
although there is probably a simple solution for that,
in theory you could connect the battery to "port 3" of the balance port,
this input measures the differential voltage,
but for that you will have to change also this part:

maybe there are other solution, I'm open for any suggestions.

Best Regards,
Paweł

Maksym Siryk

unread,
Mar 6, 2015, 12:45:12 PM3/6/15
to cheali-...@googlegroups.com
Thank you.

Maybe one of the solution is to add in settings "Wire resistane" (Rshunt + Rmosfet + Rwire) and correct voltage using the U = I*R. I know that this solution is using in patched genuine firmware (but the resistance for correction is in firmware and you can't change it without reflash). 
The other solution maybe is to calibrate discharge voltage on different current and calculate correction. 
This two solutions for use only power plug without balance port. 
Sorry, but I don't know programming language and can't change code myself. But if you can tell me what must I change I can try it and build hex. As I understand if I use third balance port (connect battery to pins 3-4) I can't use it for balancing as usual? It's not a big problem for me, but it will be better if I can select in battery setup use port 3 for measure battery voltage or use balance port as usual.

Best regards, 
Maksym

Paweł Si

unread,
Mar 7, 2015, 7:28:07 PM3/7/15
to cheali-...@googlegroups.com
2015-03-06 18:45 GMT+01:00 Maksym Siryk <mak...@siryk.com>:
Thank you.

Maybe one of the solution is to add in settings "Wire resistane" (Rshunt + Rmosfet + Rwire) and correct voltage using the U = I*R. I know that this solution is using in patched genuine firmware (but the resistance for correction is in firmware and you can't change it without reflash). 

I have to admit that I'm not a big fan of "Wire resistances" in settings,
reason for that is that the wires resistance changes whenever you unplug and plug the wires
(depends on how good the contacts between connectors are)
But if someone wants to add an compiler option for that (by default disabled) I'm open for such a patch.
 
The other solution maybe is to calibrate discharge voltage on different current and calculate correction.
 
This solution is possible but will probably take to much program memory - although I'm also open for such a patch.

This two solutions for use only power plug without balance port. 

 
Sorry, but I don't know programming language and can't change code myself. But if you can tell me what must I change I can try it and build hex.

here you go, I didn't tested this code so be careful (previously, I missed the lines ;) ): 

diff --git a/src/core/AnalogInputs.cpp b/src/core/AnalogInputs.cpp
index 9ef6861..2fbca03 100644
--- a/src/core/AnalogInputs.cpp
+++ b/src/core/AnalogInputs.cpp
@@ -506,8 +506,10 @@ void AnalogInputs::finalizeFullVirtualMeasurement()
 
     uint8_t ports = getConnectedBalancePorts();
 
-    for(uint8_t i=0; i < ports; i++) {
-        balancer += getRealValue(Name(Vb1+i));
+    for(uint8_t i=0; i < MAX_BANANCE_CELLS; i++) {
+        if(isConnected(Name(Vb1+i))) {
+            balancer += getRealValue(Name(Vb1+i));
+        }
     }
 
     setReal(Vbalancer, balancer);

 
As I understand if I use third balance port (connect battery to pins 3-4) I can't use it for balancing as usual?
It's not a big problem for me, but it will be better if I can select in battery setup use port 3 for measure battery voltage or use balance port as usual. 
hm... I'm not sure but you probably should be able to use it as usual.
 
 

Maksym Siryk

unread,
Mar 8, 2015, 4:44:44 AM3/8/15
to cheali-...@googlegroups.com
OK, I agree with you that best solution is to use 4-wire connection for precize voltage measure by using port 3 of balancing port for voltage measure.

 
This two solutions for use only power plug without balance port. 

 
Sorry, but I don't know programming language and can't change code myself. But if you can tell me what must I change I can try it and build hex.

here you go, I didn't tested this code so be careful (previously, I missed the lines ;) ): 

diff --git a/src/core/AnalogInputs.cpp b/src/core/AnalogInputs.cpp
index 9ef6861..2fbca03 100644
--- a/src/core/AnalogInputs.cpp
+++ b/src/core/AnalogInputs.cpp
@@ -506,8 +506,10 @@ void AnalogInputs::finalizeFullVirtualMeasurement()
 
     uint8_t ports = getConnectedBalancePorts();
 
-    for(uint8_t i=0; i < ports; i++) {
-        balancer += getRealValue(Name(Vb1+i));
+    for(uint8_t i=0; i < MAX_BANANCE_CELLS; i++) {
+        if(isConnected(Name(Vb1+i))) {
+            balancer += getRealValue(Name(Vb1+i));
+        }
     }
 
     setReal(Vbalancer, balancer);

Thank you. I'll try this code.  

Maksym Siryk

unread,
Mar 8, 2015, 2:05:22 PM3/8/15
to cheali-...@googlegroups.com
here you go, I didn't tested this code so be careful (previously, I missed the lines ;) ): 

diff --git a/src/core/AnalogInputs.cpp b/src/core/AnalogInputs.cpp
index 9ef6861..2fbca03 100644
--- a/src/core/AnalogInputs.cpp
+++ b/src/core/AnalogInputs.cpp
@@ -506,8 +506,10 @@ void AnalogInputs::finalizeFullVirtualMeasurement()
 
     uint8_t ports = getConnectedBalancePorts();
 
-    for(uint8_t i=0; i < ports; i++) {
-        balancer += getRealValue(Name(Vb1+i));
+    for(uint8_t i=0; i < MAX_BANANCE_CELLS; i++) {
+        if(isConnected(Name(Vb1+i))) {
+            balancer += getRealValue(Name(Vb1+i));
+        }
     }
 
     setReal(Vbalancer, balancer);


I had test this code. You lost one } but I add it. I got a problem with this code - I can't calibrate voltage. I use battery 25.79V and resistor divider fo 6 ports of balance plug. I calibrate from Vb1 to Vb6 but at the end V1-6 show 49.318V and Vout show 0V. Before calibration V1-6 show about 52V and Vout show 25V.  

Paweł Si

unread,
Mar 8, 2015, 5:53:38 PM3/8/15
to cheali-...@googlegroups.com
2015-03-08 19:05 GMT+01:00 Maksym Siryk <mak...@siryk.com>:
here you go, I didn't tested this code so be careful (previously, I missed the lines ;) ): 

diff --git a/src/core/AnalogInputs.cpp b/src/core/AnalogInputs.cpp
index 9ef6861..2fbca03 100644
--- a/src/core/AnalogInputs.cpp
+++ b/src/core/AnalogInputs.cpp
@@ -506,8 +506,10 @@ void AnalogInputs::finalizeFullVirtualMeasurement()
 
     uint8_t ports = getConnectedBalancePorts();
 
-    for(uint8_t i=0; i < ports; i++) {
-        balancer += getRealValue(Name(Vb1+i));
+    for(uint8_t i=0; i < MAX_BANANCE_CELLS; i++) {
+        if(isConnected(Name(Vb1+i))) {
+            balancer += getRealValue(Name(Vb1+i));
+        }
     }
 
     setReal(Vbalancer, balancer);


I had test this code. You lost one } but I add it.
 
please check this again, all "}" are exactly as they should
(it compiles and executes) 
 
I got a problem with this code - I can't calibrate voltage. I use battery 25.79V and resistor divider fo 6 ports of balance plug. I calibrate from Vb1 to Vb6 but at the end V1-6 show 49.318V and Vout show 0V. Before calibration V1-6 show about 52V and Vout show 25V.

I just  checked this code and calibration works form me, maybe it's something with the additional "}" on your side.


Maksym Siryk

unread,
Mar 8, 2015, 8:31:36 PM3/8/15
to cheali-...@googlegroups.com
I am sorry, it's my mistake. I copy-paste all code, but I must delete 2 rows and didn't do it. Now I correct my mistake and all work! 
As I can understand from code I can use any balance port? So I check voltage accuracy. Now difference is not depend of current! Perfect! 4-wire connection is the best solution! But the difference is :( . On port 3 I have difference of 20 mV, on the port 5 16 mV (on the battery higher voltage than on the screen). Why? I make precise calibration so every channel calibrated +/- 1 mV, but I get difference 15-20 mV (of course on the port 1-2 much more on high current).
Also I go to voltage calibration with 1S battery and connect balance wire to port from 1 to 5 and get difference V1-6 and Vout when I connect balance wire to port:
Port 1: 3 mV
Port 2: 1 mV
Port 3: 22 mV
Port 4: 29 mV
Port 5: 10 mV
The good news is that I can select o.charge and o.disgarge in settings and it's independent of current. But mayby there are other way to correct the difference? And why do I get the diference? 
Thank you.

Maksym Siryk

unread,
Mar 8, 2015, 9:00:56 PM3/8/15
to cheali-...@googlegroups.com
Maybe I can calibrate pot 5 for lower voltage and port 6 for higher voltage for compensation? In real life I don't use balance pot, but even if I use it I never use port 5-6. 

Maksym Siryk

unread,
Mar 9, 2015, 6:31:57 AM3/9/15
to cheali-...@googlegroups.com
Maybe I can calibrate pot 5 for lower voltage and port 6 for higher voltage for compensation? In real life I don't use balance pot, but even if I use it I never use port 5-6. 
Yes! I calibrate port 5 +15 mV and port 6 -15 mV and get +/- 1 mV accuracy!!! Perfect! Excellent!!!! 
I hope you include this function in release. 
If you find why I have difference in voltage with right calibration it will be better, if not - I still can use this function. 
Thank you! 
 

Maksym Siryk

unread,
Mar 9, 2015, 7:07:11 AM3/9/15
to cheali-...@googlegroups.com
I have one question: maximum voltage for balance port? For example if I want to connect Pb 12 V battery can I do this? Or 2S LiPol wothout balance plug (battery from camera, for example)?

Paweł Si

unread,
Mar 9, 2015, 12:14:13 PM3/9/15
to cheali-...@googlegroups.com

2015-03-09 1:31 GMT+01:00 Maksym Siryk <mak...@siryk.com>:
As I can understand from code I can use any balance port? So I check voltage accuracy. Now difference is not depend of current! Perfect! 4-wire connection is the best solution! But the difference is :( . On port 3 I have difference of 20 mV, on the port 5 16 mV (on the battery higher voltage than on the screen). Why? I make precise calibration so every channel calibrated +/- 1 mV, but I get difference 15-20 mV (of course on the port 1-2 much more on high current).
Also I go to voltage calibration with 1S battery and connect balance wire to port from 1 to 5 and get difference V1-6 and Vout when I connect balance wire to port:
Port 1: 3 mV
Port 2: 1 mV
Port 3: 22 mV
Port 4: 29 mV
Port 5: 10 mV
The good news is that I can select o.charge and o.disgarge in settings and it's independent of current. But mayby there are other way to correct the difference? And why do I get the diference? 
Thank you.

hmm... how do you measure the error?
I'm also not sure if a resistor divider is the best choice for calibration,
what kind of resistors are you using?


2015-03-09 12:07 GMT+01:00 Maksym Siryk <mak...@siryk.com>:
I have one question: maximum voltage for balance port? For example if I want to connect Pb 12 V battery can I do this? Or 2S LiPol wothout balance plug (battery from camera, for example)?

the maximum allowed voltage is somewhere between 4.5V - 5V per input. 

Maksym Siryk

unread,
Mar 9, 2015, 1:01:20 PM3/9/15
to cheali-...@googlegroups.com
hmm... how do you measure the error?

By multimeter. Also difference is between power output and balance port when the current is 0.

 
I'm also not sure if a resistor divider is the best choice for calibration,
what kind of resistors are you using?

100 Ohm for every port. 

the maximum allowed voltage is somewhere between 4.5V - 5V per input.  

It's not good info :( . 2S battery I can't measure. 

Paweł Si

unread,
Mar 9, 2015, 1:08:39 PM3/9/15
to cheali-...@googlegroups.com
2015-03-09 18:01 GMT+01:00 Maksym Siryk <mak...@siryk.com>:
hmm... how do you measure the error?

By multimeter. Also difference is between power output and balance port when the current is 0. 

 
I'm also not sure if a resistor divider is the best choice for calibration,
what kind of resistors are you using?

100 Ohm for every port. 
 
are you measuring the voltage on each resistor and typing this value into the charger?
you should.

Maksym Siryk

unread,
Mar 9, 2015, 1:11:22 PM3/9/15
to cheali-...@googlegroups.com


100 Ohm for every port. 
 
are you measuring the voltage on each resistor and typing this value into the charger?
you should.

Yes, even I measure voltage on balance port plug. On each channel. 

Paweł Si

unread,
Mar 9, 2015, 1:14:53 PM3/9/15
to cheali-...@googlegroups.com
2015-03-09 18:01 GMT+01:00 Maksym Siryk <mak...@siryk.com>:
100 Ohm for every port. 

what tolerance have  these resistors?

 

Maksym Siryk

unread,
Mar 9, 2015, 1:19:59 PM3/9/15
to cheali-...@googlegroups.com
100 Ohm for every port. 

what tolerance have  these resistors?

5%, but I measure voltage on every port so tolerance of resistor does not matter. Voltage on every port was different.  

Paweł Si

unread,
Mar 9, 2015, 1:27:00 PM3/9/15
to cheali-...@googlegroups.com
True.

It's strange that you have a bigger accuracy on first 2 port inputs,
than on 3-6, I would rather expect the opposite.
I have no idea why this is so.



Maksym Siryk

unread,
Mar 9, 2015, 1:42:54 PM3/9/15
to cheali-...@googlegroups.com

It's strange that you have a bigger accuracy on first 2 port inputs,
than on 3-6, I would rather expect the opposite.
I have no idea why this is so.

But this accuracy I have without current. When I have current on the power wire the difference on port 1-2 become higher. On port 3-5 independent of current. Port 6 I don't test because my plug easy can't connect to port 6. 
 
Reply all
Reply to author
Forward
0 new messages