How to set VBAT (Ver2.1)

Post Reply
User avatar
NikTheGreek
Posts: 348
Joined: Thu Dec 08, 2011 4:17 pm
Location: Greece
Contact:

How to set VBAT (Ver2.1)

Post by NikTheGreek »

Hi again.
I know it's noobish but i want to make clear in my mind how exactly i should setup my VBAT defines.

Image

1. According to PatrikE configurator http://panoramaic.se/configurator/dev_20120414/
in the section V BAT monitoring: if you mark the checkbox the V_BAT CALCULATOR Button highlighted.
When clicked ...
Enter the nuber of cells in your battery. appears
In my case is 3cells (3S battery) so i put 3 in the box and then OK
Next
Enter Meassured Battery power appears
In my case is 12.6Volt (it's my battery fully charged) so i put 12.6 in the box and click OK
Next
Please enter VoltDifference from the point between the resistors and Ground.appears
With my voltmeter i'm taking 3.85 Volts in B and C of the above pic. so i put 3.85 i the box and click OK.
Next
You selected a 3S battery with 12.6 Volt .
And a diff on the Divider on 3.85!
Is this correct?..

appears just to verify that all your inputs are correct.
and click OK
And at the end the result..
Your VbatValue is 100 will be used as VBATSCALE:

2.Now in config.h file i found this......

Code: Select all

/********************************************************************/
  /****           battery voltage monitoring                       ****/
  /********************************************************************/
    /* for V BAT monitoring
       after the resistor divisor we should get [0V;5V]->[0;1023] on analog V_BATPIN
       with R1=33k and R2=51k
       vbat = [0;1023]*16/VBATSCALE
       must be associated with #define BUZZER ! */
    //#define VBAT              // uncomment this line to activate the vbat code
    #define VBATSCALE     131 // change this value if readed Battery voltage is different than real voltage
    #define VBATLEVEL1_3S 107 // 10,7V
    #define VBATLEVEL2_3S 103 // 10,3V
    #define VBATLEVEL3_3S 99  // 9.9V
    #define NO_VBAT       16 // Avoid beeping without any battery


so i'm changing the values according the results displayed in PatrikE configurator
and of course uncomment #define VBAT

Did i make anything wrong ?

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: How to set VBAT (Ver2.1)

Post by doughboy »

thats a great link.

did you actially get 3.85 volt on middle of resistor divider?

I did not know of this vbat calculator, but the voltage reading shown on the gui is exactly my actual battery voltage. and my mid point voltage (on pin A3) is closer to 5v (I think 4.96).

anyway, just try that vBatvalue and see if the GUI shows 12.6v when your actual battery voltage is 12.6 v.

User avatar
NikTheGreek
Posts: 348
Joined: Thu Dec 08, 2011 4:17 pm
Location: Greece
Contact:

Re: How to set VBAT (Ver2.1)

Post by NikTheGreek »

doughboy wrote:
did you actially get 3.85 volt on middle of resistor divider?



I didnt test it yet !!! :lol:

doughboy
Posts: 252
Joined: Tue Sep 04, 2012 7:20 am

Re: How to set VBAT (Ver2.1)

Post by doughboy »

I don't know why they use 3.85v as the default, as it does not make sense.

the resistor divider is 51k and 33k, so total resistance is 84k.

if battery is 12.6v, then A3 pin should get

12.6 x 33/84 = 4.95v.

the default value in config.h should work fine, you will need to change only if you are using a different resistor value.

User avatar
NikTheGreek
Posts: 348
Joined: Thu Dec 08, 2011 4:17 pm
Location: Greece
Contact:

Re: How to set VBAT (Ver2.1)

Post by NikTheGreek »

Tested and working :D

PatrikE
Posts: 1962
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: How to set VBAT (Ver2.1)

Post by PatrikE »

So my calculator works?...

User avatar
NikTheGreek
Posts: 348
Joined: Thu Dec 08, 2011 4:17 pm
Location: Greece
Contact:

Re: How to set VBAT (Ver2.1)

Post by NikTheGreek »

PatrikE wrote:So my calculator works?...


Yep :D

dale.e
Posts: 48
Joined: Sat Sep 29, 2012 6:27 am

Re: How to set VBAT (Ver2.1)

Post by dale.e »

If I may jump in, I cant seem to find the right resistors.
I can get 33k 39k 47k and 56k
I was thinking if I used:

56k and 33k, total resistance of 89k.

12.6 x 33/89 = 4.67v.

is this ok to use or should I maybe go 39k and 56k?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: How to set VBAT (Ver2.1)

Post by copterrichie »

dale.e wrote:If I may jump in, I cant seem to find the right resistors.
I can get 33k 39k 47k and 56k
I was thinking if I used:

56k and 33k, total resistance of 89k.

12.6 x 33/89 = 4.67v.

is this ok to use or should I maybe go 39k and 56k?


Why not make one of the resistor a variable POT, this way the voltage can be find tune?

dale.e
Posts: 48
Joined: Sat Sep 29, 2012 6:27 am

Re: How to set VBAT (Ver2.1)

Post by dale.e »

copterrichie wrote:
dale.e wrote:If I may jump in, I cant seem to find the right resistors.
I can get 33k 39k 47k and 56k
I was thinking if I used:

56k and 33k, total resistance of 89k.

12.6 x 33/89 = 4.67v.

is this ok to use or should I maybe go 39k and 56k?


Why not make one of the resistor a variable POT, this way the voltage can be find tune?


Pretty sure I understand that the fine tune is in the Wii sketch itself by simply adjusting one value, I just need to know if I will throw things out too much with useing these resistors.
I dont live any where close to an electronics store and shipping for a 5 cent resistor would be stupid.
I dont go down to Victoria often and maybe once a year on a weekday when Quael electronics would be open.
on another note, standard 1/4 watt resistors are all thats needed here right? is the 33k to ground or Vin?

PatrikE
Posts: 1962
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: How to set VBAT (Ver2.1)

Post by PatrikE »

I think your
56k and 33k, total resistance of 89k.
12.6 x 33/89 = 4.67v.
Will work fine.

Calculate your VBat value vith the calculator on
http://panoramaic.se/configurator/2.0/

User avatar
NikTheGreek
Posts: 348
Joined: Thu Dec 08, 2011 4:17 pm
Location: Greece
Contact:

Re: How to set VBAT (Ver2.1)

Post by NikTheGreek »

Use the calculator form here.. http://panoramaic.se/configurator/dev_20120414/
no matter what values , will give you the results.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: How to set VBAT (Ver2.1)

Post by copterrichie »

Point being, if using a POT, then one can use a Volt/Ohm meter to calibrate the voltage of the resistor network. Resistor have tolerances (5,10 and 20 percent). ;) for this application, a POT is an overkill but I love precision.

dale.e
Posts: 48
Joined: Sat Sep 29, 2012 6:27 am

Re: How to set VBAT (Ver2.1)

Post by dale.e »

Patrik and nik thanx much :)

dale.e
Posts: 48
Joined: Sat Sep 29, 2012 6:27 am

Re: How to set VBAT (Ver2.1)

Post by dale.e »

Just wanted to throw in antoher thanx guys!!
my voltage read out is dead on after fine tuneing!!

User avatar
dramida
Posts: 473
Joined: Mon Feb 28, 2011 12:58 pm
Location: Bucharest
Contact:

Re: How to set VBAT (Ver2.1)

Post by dramida »

I think we have a bug regarding Vbat for 4S lipo:
I can't change the voltage prescaller in software so regardless what VbatSCALE value i wrote, the voltage shown in GUI stays the same. Am i missingng something?
What it does VBATNOMINAL...is it really necessary? Do i have to erase eeprom to change the scale? Wouldn't be straight forward to have in GUI a box to enter the scale for voltage sensor (voltage divider) and current also?
ps. Test were made on Crius AIOP mega board.

User avatar
Hamburger
Posts: 2559
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: How to set VBAT (Ver2.1)

Post by Hamburger »

You can do al that via lcd.conf in lcd.tty mode already in a serial monitor / tdrminal.

mysku82
Posts: 17
Joined: Wed Oct 12, 2011 7:32 am
Location: Bucharest, Romania
Contact:

Re: How to set VBAT (Ver2.1)

Post by mysku82 »

Please help me
How set v_bat for 4S in code ?
V in it is 16,8v, my rezistor it is R1 29K, R2 69K Vout it is 4.971
Thanks

User avatar
Hamburger
Posts: 2559
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: How to set VBAT (Ver2.1)

Post by Hamburger »

Measure voltage
Attach battery
Use lcd.conf menu to tune vbatscale until voltage displayed equals battery voltage.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: How to set VBAT (Ver2.1)

Post by copterrichie »

Do anyone have a circuit that will monitor each individual cell? I understand the limited number of MWC analog ports, just looking for a circuit right now.

mysku82
Posts: 17
Joined: Wed Oct 12, 2011 7:32 am
Location: Bucharest, Romania
Contact:

Re: How to set VBAT (Ver2.1)

Post by mysku82 »

Hamburger,
I took your advice and I do
Thanks

dale.e
Posts: 48
Joined: Sat Sep 29, 2012 6:27 am

Re: How to set VBAT (Ver2.1)

Post by dale.e »

on my MWFC SE there was a pin marked Vbat, I now have a Crius AIO Pro and I am not sure where to connect?

dale.e
Posts: 48
Joined: Sat Sep 29, 2012 6:27 am

Re: How to set VBAT (Ver2.1)

Post by dale.e »

can anyone help me out here? I still have no idea where to connect V_BATPIN on the AIOpro

User avatar
Hamburger
Posts: 2559
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: How to set VBAT (Ver2.1)

Post by Hamburger »

from def.h, Section MEGA
#define V_BATPIN A0 // Analog PIN 0

cururu
Posts: 5
Joined: Thu Jan 10, 2013 3:21 pm

Re: How to set VBAT (Ver2.1)

Post by cururu »

Hamburger wrote:from def.h, Section MEGA
#define V_BATPIN A0 // Analog PIN 0


Defining V_BATPIN, do I still need to use the resistors?

Can't I plug my lipo on A0 and the board will not be damaged?

Thanks

User avatar
Hamburger
Posts: 2559
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: How to set VBAT (Ver2.1)

Post by Hamburger »

Contact your board vendor/dealer for specific info on your particular board.

dale.e
Posts: 48
Joined: Sat Sep 29, 2012 6:27 am

Re: How to set VBAT (Ver2.1)

Post by dale.e »

Hamburger wrote:from def.h, Section MEGA
#define V_BATPIN A0 // Analog PIN 0


exactly what I needed! thanx!!

teslahed
Posts: 84
Joined: Wed Jun 27, 2012 2:51 pm

Re: How to set VBAT (Ver2.1)

Post by teslahed »

I'm currently trying to set VBAT up on my crius all in one pro. Is it my imagination or are R1 and R2 the wrong way around in the diagram at the start of this thread given that R1 = 33K and R2 = 51K? R1 should be the bigger resistor if you want less voltage dropped between the centre point and ground than between the centre point and 12.6 V, i think?

My understanding at the moment is the idea of the voltage divider is to limit the voltage to less than 5V on the analogue input pin so that the flight controller can read the voltage, then scale accordingly.

felixrising
Posts: 244
Joined: Sat Mar 23, 2013 12:34 am
Location: Australia

Re: How to set VBAT (Ver2.1)

Post by felixrising »

hi teslahed, you should definitely just workout the voltage divider value that suits your needs, keeping in mind that the analog input is on a 0-5v scale.. so if you have a 16.8v 4s attached, you will need to ensure that the divider does not let the scaled value exceed the 5v threshold, in my case I went with something that delivers 5v only at 17.2volts (in case of surge or cells are overcharged to 4.3v).

Generally, yes, R2 needs to be the smaller value (in case of Vin being >100% of Vout (5v). You can use a calculator like this to find the right values. Note that you really should measure the resistance on a good meter to find the closest resistor value to use and you should verify that the output does not exceed the 5v threshold with a multimeter and a fully charged battery attached. NB: if you are using Comp-PWM enabled ESCs, during regenerative braking, voltages can spike... so a capacitor filter might be useful and ensuring sufficient headroom is a must in this case.

natael
Posts: 33
Joined: Mon Sep 10, 2012 1:21 pm

Re: How to set VBAT (Ver2.1)

Post by natael »

teslahed wrote:I'm currently trying to set VBAT up on my crius all in one pro. Is it my imagination or are R1 and R2 the wrong way around in the diagram at the start of this thread given that R1 = 33K and R2 = 51K? R1 should be the bigger resistor if you want less voltage dropped between the centre point and ground than between the centre point and 12.6 V, i think?

My understanding at the moment is the idea of the voltage divider is to limit the voltage to less than 5V on the analogue input pin so that the flight controller can read the voltage, then scale accordingly.


Just to clarify too, i've had the same question seeing inconsistency between formulas and diagram (first post in the thread)
Back to basics, the schematics as it is shown has been used in the other way around. I think it confuses some people including me who is not sure which value is associated with which resistor.
If V1 is Main battery voltage (Vin to Ground) and V2 analog sensor voltage (A0 or A3 to ground, which is called here middle voltage ??)
This gives V2 = V1 x R2 / (R1 + R2). Some people may have confused the current divider formula ( R1 / (R1+R2)) of a parallel circuit.

Now, if config.h gives them in respective order, R1 = 33k and R2 = 51k, and if it's consistent with the positions of R1 and R2 in the diagram,taking V1 = 12.6,
that gives :

V2 = 12.6 x 51 / 84 = 7.65 V !!!!

If you guys are using like :

V2 = 12.6 x 33/84 = 4.95v

that means you're taking the resistor in the schematics the other way around. Either way, using the formula above and the schematics should clear the confusion.

User avatar
NikTheGreek
Posts: 348
Joined: Thu Dec 08, 2011 4:17 pm
Location: Greece
Contact:

Re: How to set VBAT (Ver2.1)

Post by NikTheGreek »

What is the problem of using a single pot instead of two resistors ?
Vin goes to battery and Vout to Arduino pin..

After all pot is a Voltage divider....right ?

Image

Bbergovoy
Posts: 10
Joined: Sun Aug 24, 2014 4:00 am

Re: How to set VBAT (Ver2.1)

Post by Bbergovoy »

I had to set the vbatt scale to 23 to get my measured battery voltage.

I set this at the gui level on the settings page..

my next problem is getting the buzzer to work...

handsomejackuk
Posts: 97
Joined: Mon Sep 08, 2014 12:25 am

Re: How to set VBAT (Ver2.1)

Post by handsomejackuk »

can you elaborate a bit on this please on how to set v bat on the gui.. as i can't see where on the gui too set it ?

handsomejackuk
Posts: 97
Joined: Mon Sep 08, 2014 12:25 am

Re: How to set VBAT (Ver2.1)

Post by handsomejackuk »

where is this lcd.tty lcd.conf to alter the vbat scale i have tried doing it in the sketch, but with no luck... anyone help me ?

robertha
Posts: 16
Joined: Sun Mar 17, 2013 10:12 pm

Re: How to set VBAT (Ver2.1)

Post by robertha »

I agree with natael - the picture on first post is wrong when compare with config.h - if someone will use the resistor values from config.h and connect as on that picture then it will damage the processor as it receive voltage higher than 5V on analog pin.

Please redo the picture or remeber the resistor between the GND and adruino ANALOG PIN is ALWAYS THE SMALLER VALUE than the second resitor (for 3S or higher count battery). So if you have 33k and 51k then 51k will be between the + and middle pin(arduino input) and 33k between the middle pin and GND.

Post Reply