Page 1 of 1
MultiWii PRO VBAT pin setup
Posted: Mon Sep 14, 2015 10:26 pm
by pkedvessy
Hi,
I have a MultiWii PRO board from HobbyKing (
http://hobbyking.com/hobbyking/store/__ ... ouse_.html) but this board does not have a dedicated VBAT pin. I'd like to set up the firmware to use AUX4 (PIN A15) as analog input to measure the battery voltage.
Is there anybody who can help me?
Thanks
Re: MultiWii PRO VBAT pin setup
Posted: Tue Sep 15, 2015 7:48 am
by edsimmons3
Find "OVERRIDE_V_BATPIN" in config.h and set it to A15...
I hope that helps...
Ed
Re: MultiWii PRO VBAT pin setup
Posted: Wed Sep 16, 2015 9:26 pm
by pkedvessy
Thanks for your suggestion but seems like it is not enough to change it to A15.
I've tried to do that and the result is 2.3V based on the GUI and without connecting the battery to A15 pin. Isn't it an issue that A15 is used for AUX4 by default?
Re: MultiWii PRO VBAT pin setup
Posted: Thu Sep 17, 2015 9:56 am
by edsimmons3
I just found the reason for this in the code... since you have a MEGA based flight controller, this comes into play:
#if defined(MEGA)
DDRK = 0; // defined PORTK as a digital port ([A8-A15] are consired as digital PINs and not analogical)
#endif
So, A8-A15 are actually digital pins - it should work if you use one of A0-7 as your battery pin...
Re: MultiWii PRO VBAT pin setup
Posted: Thu Sep 17, 2015 12:40 pm
by pkedvessy
There are no jumpers for A0-7 pins. Will it help if I change DDRK from 0 to 128? Or is there anything else to change?
Re: MultiWii PRO VBAT pin setup
Posted: Thu Sep 17, 2015 12:58 pm
by edsimmons3
find:
Code: Select all
void configureReceiver() {
/****************** Configure each rc pin for PCINT ***************************/
#if defined(STANDARD_RX)
#if defined(MEGA)
DDRK = 0; // defined PORTK as a digital port ([A8-A15] are consired as digital PINs and not analogical)
#endif
and edit it to your liking, maybe something like this will work for you:
Code: Select all
void configureReceiver() {
/****************** Configure each rc pin for PCINT ***************************/
#if defined(STANDARD_RX)
#if defined(MEGA)
DDRK = 0; // defined PORTK as a digital port ([A8-A15] are consired as digital PINs and not analogical)
// added by Ed in an effort to make V_BATPIN work when it is overridden with OVERRIDE_V_BATPIN to be one of A8-A15 on a mega
pinMode(V_BATPIN,INPUT); // just to ensure the pin is actually set up correctly...
digitalWrite(V_BATPIN,LOW);
uint16_t temp = analogRead(V_BATPIN);
#endif
Hope that helps...
Ed
Re: MultiWii PRO VBAT pin setup
Posted: Thu Sep 17, 2015 10:02 pm
by pkedvessy
I got the same result. GUI shows 2.3V (it is around 1V without the multiplication). I've tried to wire 5V to the A15 pin but nothing has changed.
Re: MultiWii PRO VBAT pin setup
Posted: Fri Sep 18, 2015 9:58 pm
by pkedvessy
Ed, thanks for your help. I missed to uncomment OVERRIDE_V_BATPIN. Now it is working as I have expected.