Switching from horizon/level to acro causes hard pitch/roll

Post Reply
Fastrack
Posts: 23
Joined: Tue May 14, 2013 5:36 am

Switching from horizon/level to acro causes hard pitch/roll

Post by Fastrack »

Hi all,

First quad... I have a multiwii ez black 3.0 from witespy with the external mag/gps.

I tuned the sub trims on my taranis to 1000/1500/2000 and have a deadband of 4 as the taranis seems to be +\- 3 or 4 in the center.

I plugged in my battery with my quad on a 100% level surface... Then calibrated the gyros and ACC via the sticks.

I flew outside tuned acro mode via the transmitter trims...I switched to level mode and tuned ACC via the stick commands... It'll pretty much hover without any pitch or roll input in either mode..

However switching from horizon or level into acro cause a major forward pitch and roll to the right. I would guess at least 10 degrees on pitch maybe 5-10 roll

Any ideas? Is it because ACC should be calibrated AFTER trimming acro mode? I'm seeing about 1535 on pitch btw...

Thanks..

Ben

waltr
Posts: 733
Joined: Wed Jan 22, 2014 3:21 pm
Location: Near Philadelphia, Pennsyvania, USA

Re: Switching from horizon/level to acro causes hard pitch/r

Post by waltr »

You did the procedure correctly. Acro mode tx trims then Angle mode with ACC TRIM stick commands.
I have had some change of pitch/roll when switching from Angle to Acro modes on some quads I've built but not as much as you describe.

Note: When you plug in the battery the copter does not need to be level. It only needs to be NOT moving. On MW boot-up it does a Gyro cal but not an accel cal. Acc is calibrated only once and the the Trim by stick commands.
If you think the copter moved during boot-up then do a gyro cal with stick commands.

The 1535 you see on pitch: Is this with the stick centered after trimming in acro mode?

Fastrack
Posts: 23
Joined: Tue May 14, 2013 5:36 am

Re: Switching from horizon/level to acro causes hard pitch/r

Post by Fastrack »

Hey Walt

The 1535 could be when I had my c/g wrong... I've seen so many numbers I confuse myself,. Lol. But it's after acro tuning though.

I made sure the c/g was correct when I did the second tuning... by building a jig and balancing it on 2 framing nails, nailed through a 3/4" piece of plywood. So gyro doesn't have to be level... Good to know!

Good to hear it doesn't matter when the ACC calibration is done... I figured this... since you can do it without a transmitter connected.. but it was worth asking.

What I can't figure out... I know the config file is expecting 1500 for center... But now that I trimmed for acro mode.. That's no longer the case!

I see a minor twitch between baro and horizon, but this is quite a change.. The 10 degrees is a guess of course.

What's odd is once I correct the banking... It will hover again no issues in acro with no stick input... I'm not sure if this is a twitch and self corrects... as I haven't left it long enough to find out :) !

Ben

waltr
Posts: 733
Joined: Wed Jan 22, 2014 3:21 pm
Location: Near Philadelphia, Pennsyvania, USA

Re: Switching from horizon/level to acro causes hard pitch/r

Post by waltr »

Kinda odd but wondering if its something to do with the stick center value after trimmed in acro mode. It really should be at 1500.
This is defined in the config.h file as "MIDRC. Is this 1500?

When you switch the Acro mode and the copter is tilted it will stay tilted so no self-correcting to level. You must be on the stick and level it or fly it.
I use this fact when hand launching my small acrobatic quad, hold level, Arm, tilt away from me and hit the throttle. It then flies away from me at the tilted angle.

Since your quad does fly well once the flight mode is changed maybe just be ready to adjust when you flip into acro mode for now.

Fastrack
Posts: 23
Joined: Tue May 14, 2013 5:36 am

Re: Switching from horizon/level to acro causes hard pitch/r

Post by Fastrack »

So I just hooked it up... The 1535 I was remembering was when the C/g was wrong.

The values I have now are:
ROLL - 1494
PITCH - 1502

Which makes sense.. as my trims are a few clicks forward on pitch and a few clicks to the left on roll.

It rolls to right and forward when switching..........

I guess I'll try and re-calibrate ACC again and see if it makes a difference

How can stick center stay at 1500 if you have to use the trims to adjust acro flight?

Ben

waltr
Posts: 733
Joined: Wed Jan 22, 2014 3:21 pm
Location: Near Philadelphia, Pennsyvania, USA

Re: Switching from horizon/level to acro causes hard pitch/r

Post by waltr »

1494 & 1502 should be close enough to 1500. 1535 would be too far from center.

I use a cheap radio so enabled the DEADBAND in the config.h file since my sticks never return to exactly the same value.
You could give this a try to see if it makes a difference.
Other than that I am out of ideas.

mahomedia
Posts: 12
Joined: Tue Feb 05, 2013 10:59 pm

Re: Switching from horizon/level to acro causes hard pitch/r

Post by mahomedia »

Hello friends. I have exactly same issue on my quad and hexa.
It flies perfect on acro mode. It flies perfect in angle mode too. But it rapidly changes pitch/roll when I switched from angle to acro. Sometimes very rapid and hard changes happen in pitch/roll. I found the issue goes away if pitch and roll "I" value is set to zero in PID settings. I think this is a bug in PID calculation but I still not found any solution :(

There is no problem like this in MW 2.2, revealed when I installed 2.3.

User avatar
Leo
Posts: 372
Joined: Wed Sep 17, 2014 7:01 am
Location: Germany
Contact:

Re: Switching from horizon/level to acro causes hard pitch/r

Post by Leo »

For the record I'm having the same issue. I have yet to find out why.

I'm using current pre 2.4 release: MultiWii_dev_2014_12_01__r1729

mahomedia
Posts: 12
Joined: Tue Feb 05, 2013 10:59 pm

Re: Switching from horizon/level to acro causes hard pitch/r

Post by mahomedia »

Hello again.
I have updated some lines of code and it fixed, let me explain:
This is the result of "I" component of PID calculation and developer friend has made a solution for bumping from acro to angle mode with those lines:

Code: Select all

 
// bumpless transfer to Level mode
if (!f.ANGLE_MODE) {
errorAngleI[ROLL] = 0; errorAngleI[PITCH] = 0;
f.ANGLE_MODE = 1;
}


I have implemented same idea for angle to acro mode:

Defined a variable for status at the beginning:

Code: Select all

uint8_t  M_LEVEL_TO_ACRO = 0;



Modified lines between 1039 and 1076:

Code: Select all

#if ACC
      if ( rcOptions[BOXANGLE] || (failsafeCnt > 5*FAILSAFE_DELAY) ) {
        // bumpless transfer to Level mode
        if (!f.ANGLE_MODE) {
          errorAngleI[ROLL] = 0; errorAngleI[PITCH] = 0;
          f.ANGLE_MODE = 1;
        } 
       
        M_LEVEL_TO_ACRO = 1; // added
     
      } else {
        // failsafe support
        f.ANGLE_MODE = 0;
       
        // added
        if(M_LEVEL_TO_ACRO){
          errorGyroI[ROLL] = 0; errorGyroI[PITCH] = 0;
          M_LEVEL_TO_ACRO = 0;
        }
       
      }
      if ( rcOptions[BOXHORIZON] ) {
        f.ANGLE_MODE = 0;
        if (!f.HORIZON_MODE) {
          errorAngleI[ROLL] = 0; errorAngleI[PITCH] = 0;
          f.HORIZON_MODE = 1;
          M_LEVEL_TO_ACRO = 1; // added
        }
      } else {
        f.HORIZON_MODE = 0;   
   
        // added
        if(M_LEVEL_TO_ACRO){
          errorGyroI[ROLL] = 0; errorGyroI[PITCH] = 0;
          M_LEVEL_TO_ACRO = 0;
        }
      }
    #endif




Now it works very well.
Modified Multiwii.cpp is attached. Please check cafefully before use or I'll be happy if someone unify it with original code.
Attachments
MultiWii_cpp.rar
Angle/Horizon to Acro mode bumping issue fixed.
(12.92 KiB) Downloaded 281 times

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Switching from horizon/level to acro causes hard pitch/r

Post by Alexinparis »

Hi,

I understand the issue.
errorGyroI[ROLL] and errorGyroI[PITCH] need to be reset when switching to acro mode.
I think there is no need to introduce a new var for this.
If you are in angle mode, f.ANGLE_MODE = 1 just after box deactivation. the same for horizon.
so i suggest this version instead:

could you check ?

Code: Select all

    #if ACC
      if ( rcOptions[BOXANGLE] || (failsafeCnt > 5*FAILSAFE_DELAY) ) {
        // bumpless transfer to Level mode
        if (!f.ANGLE_MODE) {
          errorAngleI[ROLL] = 0; errorAngleI[PITCH] = 0;
          f.ANGLE_MODE = 1;
        } 
       
      } else {
        // added
        if(f.ANGLE_MODE){
          errorGyroI[ROLL] = 0; errorGyroI[PITCH] = 0;
        }
        // failsafe support
        f.ANGLE_MODE = 0;
       
      }
      if ( rcOptions[BOXHORIZON] ) {
        f.ANGLE_MODE = 0;
        if (!f.HORIZON_MODE) {
          errorAngleI[ROLL] = 0; errorAngleI[PITCH] = 0;
          f.HORIZON_MODE = 1;
          M_LEVEL_TO_ACRO = 1; // added
        }
      } else {
        // added
        if(f.HORIZON_MODE){
          errorGyroI[ROLL] = 0; errorGyroI[PITCH] = 0;
        }
        f.HORIZON_MODE = 0;

      }
    #endif

User avatar
Leo
Posts: 372
Joined: Wed Sep 17, 2014 7:01 am
Location: Germany
Contact:

Re: Switching from horizon/level to acro causes hard pitch/r

Post by Leo »

I'm getting the error:

Code: Select all

MultiWii.cpp: In function 'void loop()':
MultiWii.cpp:1058:11: error: 'M_LEVEL_TO_ACRO' was not declared in this scope
           M_LEVEL_TO_ACRO = 1; // added
           ^
Error compiling.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Switching from horizon/level to acro causes hard pitch/r

Post by Alexinparis »

sorry, i did not remove this line
correction:

Code: Select all

    #if ACC
      if ( rcOptions[BOXANGLE] || (failsafeCnt > 5*FAILSAFE_DELAY) ) {
        // bumpless transfer to Level mode
        if (!f.ANGLE_MODE) {
          errorAngleI[ROLL] = 0; errorAngleI[PITCH] = 0;
          f.ANGLE_MODE = 1;
        } 
       
      } else {
        // added
        if(f.ANGLE_MODE){
          errorGyroI[ROLL] = 0; errorGyroI[PITCH] = 0;
        }
        // failsafe support
        f.ANGLE_MODE = 0;
       
      }
      if ( rcOptions[BOXHORIZON] ) {
        f.ANGLE_MODE = 0;
        if (!f.HORIZON_MODE) {
          errorAngleI[ROLL] = 0; errorAngleI[PITCH] = 0;
          f.HORIZON_MODE = 1;
        }
      } else {
        // added
        if(f.HORIZON_MODE){
          errorGyroI[ROLL] = 0; errorGyroI[PITCH] = 0;
        }
        f.HORIZON_MODE = 0;

      }
    #endif

User avatar
Leo
Posts: 372
Joined: Wed Sep 17, 2014 7:01 am
Location: Germany
Contact:

Re: Switching from horizon/level to acro causes hard pitch/r

Post by Leo »

Well, I just came back in from the very cold and windy weather we are having atm.

I gave it several tries and it seems to be working correctly. I do get some "twitching" but that could be the cause of something else, not really worth mentioning.

I would however like to see feed back from others on this issue....

mahomedia
Posts: 12
Joined: Tue Feb 05, 2013 10:59 pm

Re: Switching from horizon/level to acro causes hard pitch/r

Post by mahomedia »

Yes Alexinparis it's true, I couldn't think so :) It was my first dive in to the code. I'll try it today.

Edit:

I have tested, it work great.

elaerico
Posts: 7
Joined: Sun May 18, 2014 6:45 pm

Re: Switching from horizon/level to acro causes hard pitch/r

Post by elaerico »

I tested too. Before it was a nightmare change modes in flight. Now it's smooth. Thanks!

Post Reply