MultiWii PRO VBAT pin setup

MultiWii PRO VBAT pin setup

Postby pkedvessy » Mon Sep 14, 2015 10:26 pm

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
pkedvessy
 
Posts: 5
Joined: Mon Sep 14, 2015 10:22 pm

Re: MultiWii PRO VBAT pin setup

Postby edsimmons3 » Tue Sep 15, 2015 7:48 am

Find "OVERRIDE_V_BATPIN" in config.h and set it to A15...
I hope that helps...
Ed
edsimmons3
 
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: MultiWii PRO VBAT pin setup

Postby pkedvessy » Wed Sep 16, 2015 9:26 pm

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?
pkedvessy
 
Posts: 5
Joined: Mon Sep 14, 2015 10:22 pm

Re: MultiWii PRO VBAT pin setup

Postby edsimmons3 » Thu Sep 17, 2015 9:56 am

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...
edsimmons3
 
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: MultiWii PRO VBAT pin setup

Postby pkedvessy » Thu Sep 17, 2015 12:40 pm

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?
pkedvessy
 
Posts: 5
Joined: Mon Sep 14, 2015 10:22 pm

Re: MultiWii PRO VBAT pin setup

Postby edsimmons3 » Thu Sep 17, 2015 12:58 pm

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
edsimmons3
 
Posts: 100
Joined: Thu Sep 10, 2015 11:29 am

Re: MultiWii PRO VBAT pin setup

Postby pkedvessy » Thu Sep 17, 2015 10:02 pm

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

Postby pkedvessy » Fri Sep 18, 2015 9:58 pm

Ed, thanks for your help. I missed to uncomment OVERRIDE_V_BATPIN. Now it is working as I have expected.
pkedvessy
 
Posts: 5
Joined: Mon Sep 14, 2015 10:22 pm


Return to Shields, boards and sensors

Who is online

Users browsing this forum: No registered users and 2 guests

cron