MultiWii PRO VBAT pin setup

Post Reply
pkedvessy
Posts: 5
Joined: Mon Sep 14, 2015 10:22 pm

MultiWii PRO VBAT pin setup

Post 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

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: MultiWii PRO VBAT pin setup

Post by edsimmons3 »

Find "OVERRIDE_V_BATPIN" in config.h and set it to A15...
I hope that helps...
Ed

pkedvessy
Posts: 5
Joined: Mon Sep 14, 2015 10:22 pm

Re: MultiWii PRO VBAT pin setup

Post 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?

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: MultiWii PRO VBAT pin setup

Post 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...

pkedvessy
Posts: 5
Joined: Mon Sep 14, 2015 10:22 pm

Re: MultiWii PRO VBAT pin setup

Post 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?

edsimmons3
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: MultiWii PRO VBAT pin setup

Post 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

pkedvessy
Posts: 5
Joined: Mon Sep 14, 2015 10:22 pm

Re: MultiWii PRO VBAT pin setup

Post 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.

pkedvessy
Posts: 5
Joined: Mon Sep 14, 2015 10:22 pm

Re: MultiWii PRO VBAT pin setup

Post by pkedvessy »

Ed, thanks for your help. I missed to uncomment OVERRIDE_V_BATPIN. Now it is working as I have expected.

Post Reply