Battery Monitoring Problems on Multiwii Pro

This forum is dedicated to all issues and questions related to your individual setups and configurations
Post Reply
beentheunseen
Posts: 10
Joined: Mon Apr 20, 2015 8:24 pm

Battery Monitoring Problems on Multiwii Pro

Post by beentheunseen »

Hi All,

I'm having real trouble getting voltage monitoring working on my HK multiwii pro board using a 56K/33K voltage divider (3s battery). I have re-assigned the V_BATPIN to A15 as many other threads suggest, as A0 is not broken out on the multiwii pro. However, no matter what voltage i put through the pin it always seems to read 13.00v - its behaving as though the pin is constantly saturated with 5v. As I measure it now, my voltage divider is putting out 4.30v, but has no effect on the multiwii reading when i plug it in. The only thing that will make it budge is grounding to the pin, which causes it to drop to 0.0v as expected.

I noticed that it still reads 13.0v even when nothing at all is plugged into A15. I therefore tried disabling the pullup just before the input is read in the code. This made the reading drop to 0.0v when left unconnected, but when i plugged in my voltage divider (still reading 4.30v) the multiwii jumped right back up to 13.0v again!

I have tried both multiwii 2.3 and 2.4, and have tried clearing the eeprom. I've also tried pins A13 and A14.

Can anyone help?

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Battery Monitoring Problems on Multiwii Pro

Post by Cereal_Killer »

What code changes exactly are you using to change the vbatt pin assignment? Also what lines have you uncommented for the standard vbatt setup? What values for the set points and the main offset?

Do you have a bench top power supply? It would help if you could dial up and down the voltage and feed it in like a divider for testing.

beentheunseen
Posts: 10
Joined: Mon Apr 20, 2015 8:24 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by beentheunseen »

I have tried both:

'#define OVERRIDE_V_BATPIN A15'
...in config.h

#define AUX4PIN A0
#define V_BATPIN A15
...swapping Aux4 and vbat in def.h

my vbat setup looks like this:

#define VBAT // uncomment this line to activate the vbat code
#define VBATSCALE 115 // (*) (**) change this value if readed Battery voltage is different than real voltage
#define VBATNOMINAL 126 // 12,6V full battery nominal voltage - only used for lcd.telemetry
#define VBATLEVEL_WARN1 107 // (*) (**) 10,7V
#define VBATLEVEL_WARN2 99 // (*) (**) 9.9V
#define VBATLEVEL_CRIT 93 // (*) (**) 9.3V - critical condition: if vbat ever goes below this value, permanent alarm is triggered
#define NO_VBAT 60 // Avoid beeping without any battery

I have also done some bench tests with a variable potential divider as you suggested. With 0v at the pin i get 0v in multiwii, then as as i increase it it rises nicely until i hit 4v at the pin, and multiwii reads 13.00v. As i continue to increase the voltage to 5v, multiwii's reading remains stuck on 13v! For some reason the pin only has a range of 0-4v, and the last volt is totally unreadable!

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Battery Monitoring Problems on Multiwii Pro

Post by Cereal_Killer »

Are you using 1% resistors? What banding do they have? Sounds like you can get away with adjusting the values a bit to make the output 1-4v, you'll sacrifice a bit of accuracy as it'll scale differently but I think that would get you going.

schnupperm
Posts: 31
Joined: Tue Jun 25, 2013 1:41 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by schnupperm »

if the red multwii pro board from HK gets its power via the motor control output, the voltage for the processor is only 3.9 V. So 3.9 Volt is the maximum voltage it can measure on any analog input.

beentheunseen
Posts: 10
Joined: Mon Apr 20, 2015 8:24 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by beentheunseen »

Cereal Killer - I have tried exactly that, using a 68k/33k to keep my fully-charged voltage scaled below 4v. That seems to work, but i don't seem to be able to set VBATSCALE in a way that properly follows the voltage with this arrangement...

schupperm - That explains everything! What is the reason the red HK pro board is set up this way? Is it recommended to send a full 5v to the processor? If so, where should I connect the supply?

Thanks for the help guys! Feel like i'm getting close to solving this...

schnupperm
Posts: 31
Joined: Tue Jun 25, 2013 1:41 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by schnupperm »

beentheunseen wrote:
That explains everything! What is the reason the red HK pro board is set up this way?

who knows ;-)
Is it recommended to send a full 5v to the processor?

yes
If so, where should I connect the supply?

look here:
http://www.rcgroups.com/forums/showpost ... count=1859
and here:
http://www.rcgroups.com/forums/showpost ... count=1005

beentheunseen
Posts: 10
Joined: Mon Apr 20, 2015 8:24 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by beentheunseen »

Ok, I set up a jumper which takes the full 5v to the chip, and now a 51k/33k voltage divider is being read by multiwii through it's full range - wahey!

However, the scaling doesn't seem to be working correctly. I have adjusted the vbat scale such that multiwii reads 11.70 on a battery which I have measured at 11.70v on my meter. All good so far, but then I plug in another battery which measures at 10.90v, and multiwii thinks it's 11.20! This is actually exactly the same problem i was having when I was using the 0-4v voltage divider as suggested by cereal killer...

I have been careful to observe the voltage via my OSD with the USB unplugged to ensure there is no interference.

What could be causing this?

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Battery Monitoring Problems on Multiwii Pro

Post by Cereal_Killer »

[Probably a dumb question, you seem to know what you're talking about so I assume you're doing it right but...]You are setting the real scale in the code right? Not just the nominal scale in the GUI / on board display / Bluetooth?

Edit:
And you're reading it where (a GUI or on-board display)?
Last edited by Cereal_Killer on Thu Apr 30, 2015 8:19 pm, edited 1 time in total.

beentheunseen
Posts: 10
Joined: Mon Apr 20, 2015 8:24 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by beentheunseen »

Yup, been doing it in the code and hitting 'reset' in the gui...

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Battery Monitoring Problems on Multiwii Pro

Post by Cereal_Killer »

Ok and then you're changing the nominal voltage to match ?

-again sorry for simple questions. Just that I've been there & done that on to many things before so I wanna cover all the bases before looking deeper ya know.

beentheunseen
Posts: 10
Joined: Mon Apr 20, 2015 8:24 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by beentheunseen »

I have the nominal voltage set to 12.6, the fully charged voltage of my 3s battery. Is that correct?

Please feel free to ask simple questions! There's more than likely something dumb i have missed...

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Battery Monitoring Problems on Multiwii Pro

Post by Cereal_Killer »

Yes that's [usually] correct (tho you can adjust as needed).
I think you missed my edit to my post a few up- where are you reading this voltage? In the GUI or on an on-board display?


Do me this favor, just so I can stop asking about your settings please paste this snipit of code over your code (this is from my code which I've dialed in very well verifying with a on-board uDMM)


Code: Select all

    #define VBAT              // uncomment this line to activate the vbat code
    #define VBATSCALE       126 // (*) (**) change this value if readed Battery voltage is different than real voltage
    #define VBATNOMINAL     126 // 12,6V full battery nominal voltage - only used for lcd.telemetry
    #define VBATLEVEL_WARN1 107 // (*) (**) 10,7V
    #define VBATLEVEL_WARN2  99 // (*) (**) 9.9V
    #define VBATLEVEL_CRIT   93 // (*) (**) 9.3V - critical condition: if vbat ever goes below this value, permanent alarm is triggered
    #define NO_VBAT          16 // Avoid beeping without any battery
    #define VBAT_OFFSET       0 // offset in 0.1Volts, gets added to voltage value  - useful for zener diodes

beentheunseen
Posts: 10
Joined: Mon Apr 20, 2015 8:24 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by beentheunseen »

Here's the relevant section of code:

#define VBAT // uncomment this line to activate the vbat code
#define VBATSCALE 115 // (*) (**) change this value if readed Battery voltage is different than real voltage
#define VBATNOMINAL 126 // 12,6V full battery nominal voltage - only used for lcd.telemetry
#define VBATLEVEL_WARN1 107 // (*) (**) 10,7V
#define VBATLEVEL_WARN2 99 // (*) (**) 9.9V
#define VBATLEVEL_CRIT 93 // (*) (**) 9.3V - critical condition: if vbat ever goes below this value, permanent alarm is triggered
#define NO_VBAT 60 // Avoid beeping without any battery

I'm reading it from my OSD, which is reading data from the multi-wii board. The multiwii gui confirms the same thing - i've just been reading it from the OSD to ensure that the USB doesn't interfere with the voltage as it did before i installed the 5v jumper.

Cereal_Killer
Posts: 221
Joined: Fri Mar 06, 2015 5:44 am

Re: Battery Monitoring Problems on Multiwii Pro

Post by Cereal_Killer »

Ok this is actually something I've been wondering about a while now- how does the OSD get it's info, does it read the individual input's that the main FC is getting as individual raw data or is it being sent all the params in packets via serial data (i2c / UART / other)?

Back to your question, do you have a way to sweep the input voltage (variable power supply) so we could pinpoint the exact level it starts to go the other way? What does a batt @ exactly 12.6v read?

Can you take a DMM and actually measure the resistance of each side, as well as the total resistance of the divider?

How important is this to you? You're flying to far away that a stand-alone cell monitor / voltage alarm wouldn't be a substitute? I'm not saying I think you should give up, just trying to figure out where I suggest you go from here. How familiar are you with arduino?

PS final thought, and again this is back to the basics but... you the resistors in the right order?

beentheunseen
Posts: 10
Joined: Mon Apr 20, 2015 8:24 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by beentheunseen »

Ok guys, think i fixed it!

I found that even when i reduced the potential going into the potential divider to 1v, pin a15 was still measuring 2.3 v. Some extra volts were somehow getting added to the output from the potential divider. I therefore decided to go into the code and disable the pull up resistor by adding the following line to multiwii.cpp:

static uint16_t vvec[VBAT_SMOOTH], vsum;
digitalWrite(V_BATPIN, LOW);
uint16_t v = analogRead(V_BATPIN);

It now works perfectly! It's a mystery to me why no-one else seems to have needed to make this modification, but whatever, it works. Thanks for your help y'all!

servo23
Posts: 22
Joined: Tue Apr 17, 2012 8:54 pm
Location: Lugano Svizzera
Contact:

Re: Battery Monitoring Problems on Multiwii Pro

Post by servo23 »

Hello beentheunseen

Sorry for my English not at the top

I want to ask if you can please post here multiwii.cpp file or all files of MultiWii 2.4
Or modified by you because even I have the same problem.

Hello and thanks.

servo23
Posts: 22
Joined: Tue Apr 17, 2012 8:54 pm
Location: Lugano Svizzera
Contact:

Re: Battery Monitoring Problems on Multiwii Pro

Post by servo23 »

Ok problem solved by the same :D

csorrows
Posts: 1
Joined: Fri Jul 17, 2015 12:16 pm

Re: Battery Monitoring Problems on Multiwii Pro

Post by csorrows »

I just registered to thank you for this solution. I have been racking my brain for over 12 hours trying to fix the problem. This really should be committed to source as I'm sure others have had the same issue moving to pin A15. I was almost to the point of selling my MultiWii because of it!

THANK YOU SO MUCH FOR POSTING THIS SOLUTION!

Post Reply