Airplane-Acrotrainer no servo on mega pls help

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Airplane-Acrotrainer no servo on mega pls help

Post by Gimbal »

Hi all thanx for you're deep commitment and endless programing.
Moved from Mini to Mega to try Airplane-mode and now all servo goes berserk, tryed r1097 no success
pls help

KaiK
Posts: 58
Joined: Thu Jul 28, 2011 8:32 pm
Contact:

Re: Airplane-Acrotrainer no servo on mega pls help

Post by KaiK »

Might be the same as documented here: viewtopic.php?f=8&t=2385

Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Re: Airplane-Acrotrainer no servo on mega pls help

Post by Gimbal »

Yes it's the same, i will go back to Mini so i can go flying with my giant P51, i am a bad rc flyer and need assistants when i'm loosing the concept :lol:

Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Re: Airplane-Acrotrainer no servo on mega pls help

Post by Gimbal »

So their seams to bee little or no interest in Mega and Acrotrainer, hm can somebody point me in the right direction, a bit confusing with all this code...

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

Re: Airplane-Acrotrainer no servo on mega pls help

Post by PatrikE »

I would be a great benfinit to get airplane mode work on Mega.
One serialport on ProMini is a BIG limitation for debugging GPS code!

Does someone have knowlage how the code is sopposed to work?

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

Re: Airplane-Acrotrainer no servo on mega pls help

Post by Hamburger »

maybe some interrupt hassle?
Ronco has been quiet for some time, so maybe go back to a real old version and check for servo functionality? At worst you will find it never did work.

Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Re: Airplane-Acrotrainer no servo on mega pls help

Post by Gimbal »

yes, but it work's with the wing right, so with some reverse engineering it wold bee possible to get a clue

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

Re: Airplane-Acrotrainer no servo on mega pls help

Post by PatrikE »

It's been a problem for a long time!
Maby even before V1.8. The servo code was changed there somewhere.
Around the time when i was doing the Airplane implementation.

But i thougt it was my mega 1280 that was faulty.
Iw'e only used it on the desk for developing and not for flying.

Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Re: Airplane-Acrotrainer no servo on mega pls help

Post by Gimbal »

Hi, i try'd this in output, from unit8 to unit16 and it works for me ;-)
haven't run it on mini, think it's using 8 bit


#if defined(AIRPLANE)|| defined(HELICOPTER)
// To prevent motor to start at reset. atomicServo[7]=5 or 249 if reversed servo
volatile uint16_t atomicServo[8] = {8000,8000,8000,8000,8000,8000,8000,8000};
Last edited by Gimbal on Thu Sep 20, 2012 11:18 pm, edited 1 time in total.

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

Re: Airplane-Acrotrainer no servo on mega pls help

Post by PatrikE »

Itis clearly a bug! 8000 need 16 bits!

I'll test tomorrow..
Last edited by PatrikE on Sat Sep 22, 2012 2:05 pm, edited 1 time in total.

Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Re: Airplane-Acrotrainer no servo on mega pls help

Post by Gimbal »

D2,3,5,6 servo ok D7,8,9,10 need to be rerouted

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

Re: Airplane-Acrotrainer no servo on mega pls help

Post by PatrikE »

Gimbal wrote:D2,3,5,6 servo ok D7,8,9,10 need to be rerouted


D7,8,9,10 Is not servoOutputs Only Motor.
Servos use. 2,3,5,6,33,34,35 & 37

I have tested an everything seems to work as expected now :D
Great find @Gimbal

I uploaded the Fix to _shared.

Gimbal
Posts: 146
Joined: Tue Jul 24, 2012 7:14 pm
Location: Sweden

Re: Airplane-Acrotrainer no servo on mega pls help

Post by Gimbal »

Tnx P, my Chines board's using D7,8,9 and 10 but that's n easy fix in def.h right

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

Re: Airplane-Acrotrainer no servo on mega pls help

Post by PatrikE »

Can be fixed like this.

Add #define SERVO_ON_MEGA_MOTRORPINS in config

And In def

Code: Select all

#if defined (SERVO_ON_MEGA_MOTRORPINS)
  #define SERVO_1_PINMODE            pinMode(10,OUTPUT);   // TILT_PITCH - WING left
  #define SERVO_1_PIN_HIGH           PORTB |= 1<<4;
  #define SERVO_1_PIN_LOW            PORTB &= ~(1<<4); 
  #define SERVO_2_PINMODE            pinMode(9,OUTPUT);    // TILT_ROLL  - WING right
  #define SERVO_2_PIN_HIGH           PORTH |= 1<<6;
  #define SERVO_2_PIN_LOW            PORTH &= ~(1<<6); 
  #define SERVO_3_PINMODE            pinMode(8,OUTPUT);    // CAM TRIG  - alt TILT_PITCH
  #define SERVO_3_PIN_HIGH           PORTH |= 1<<5;
  #define SERVO_3_PIN_LOW            PORTH &= ~(1<<5); 
  #define SERVO_4_PINMODE            pinMode (7, OUTPUT);  // new       - alt TILT_ROLL
  #define SERVO_4_PIN_HIGH           PORTH |= 1<<4;
  #define SERVO_4_PIN_LOW            PORTH &= ~(1<<4);
#else 
// original servo defines
  #define SERVO_1_PINMODE            pinMode(34,OUTPUT);pinMode(44,OUTPUT); // TILT_PITCH - WING left
  #define SERVO_1_PIN_HIGH           PORTC |= 1<<3;PORTL |= 1<<5;
  #define SERVO_1_PIN_LOW            PORTC &= ~(1<<3);PORTL &= ~(1<<5);
  #define SERVO_2_PINMODE            pinMode(35,OUTPUT);pinMode(45,OUTPUT); // TILT_ROLL  - WING right
  #define SERVO_2_PIN_HIGH           PORTC |= 1<<2;PORTL |= 1<<4;
  #define SERVO_2_PIN_LOW            PORTC &= ~(1<<2);PORTL &= ~(1<<4);
  #define SERVO_3_PINMODE            pinMode(33,OUTPUT); pinMode(46,OUTPUT); // CAM TRIG  - alt TILT_PITCH
  #define SERVO_3_PIN_HIGH           PORTC |= 1<<4;PORTL |= 1<<3;
  #define SERVO_3_PIN_LOW            PORTC &= ~(1<<4);PORTL &= ~(1<<3);
  #define SERVO_4_PINMODE            pinMode (37, OUTPUT);                   // new       - alt TILT_ROLL
  #define SERVO_4_PIN_HIGH           PORTC |= 1<<0;
  #define SERVO_4_PIN_LOW            PORTC &= ~(1<<0);
#endif


It would be a great option because like you say.
D 2,3,5,6,7,8,9&10 is routed on most boards.
But not 33,34,35 & 37.

Post Reply