Auto Tuning in 4.3.0

Hello,

Have been doing manual tuning all these days, thought will try auto tuning with the latest stable 4.3.0 FW.

I faced two problems, first I did thr FF auto tune which went well, next I did the rate D & P of pitch axis which too went well.
Next I tried rate D & P for the roll axis it failed twice, for this I increased the freq to 100 and it went well and completed the auto tune, but after landing I see that only the D value is tuned and the P value remained 0.

Next day, we thought will repeat the D & P gains for the roll, but today we are facing a new problem, the message I’m getting is “Auto tune: failing to level, please tune manually”.

No matter what axis I change to or what seq I change to, it’s the same error “failing to level.”

Would appreciate if anyone could help me out here.

Thanks and regards,
Adarsh

Hi Adarsh,
Since this is a new feature, I am always interested to see how well the autotune does in tuning a heli. Could you make all of your flights available for me to review? Of course, make the last flight available so I can see why it is failing to level. What size heli is this?
Thanks!

Hello Bill,

This is an electric two blade 900 size. Will send you all the log files in sometime.

Thank you for your help.

Thanks and regards,
Adarsh

@bnsgeyer
Hello Bill,

I have this message also, during my AT flight for tuning the ATC_ANG_YAW_P of my
Agusta 109. You can see it in the log

But the AT went on and finished with success:

BR

Heri

Hi Bill,

Here are the log files of all my AT flights.

The FF auto tuning went on smooth, i did the pitch and roll separately.
FF Pitch:
https://drive.google.com/file/d/1kXqc2ShGO9xsWJac-nzmXQlQplBfEq0c/view?usp=share_link

FF Roll:
https://drive.google.com/file/d/1Wk5LlYJO-FgtrlOZiR5vx_lC-MahTGRf/view?usp=share_link

Rate D & P Pitch axis
https://drive.google.com/file/d/1-LnRRkBHZAs5if-9BFHOgsxffBw87xEB/view?usp=share_link

Rate D & P Roll axis - This is where i had to increase the max freq to 100 and then it completed the AT and gave a message AT success. But had tuned only the Rate D and the rate P was zero.
https://drive.google.com/file/d/1yQ43mG3ece9BgdSrAnb8VBoZSXqNWSi_/view?usp=share_link

Today repeated the Rate D & P roll axis AT, but today when i switched to AT, nothing happened, no frequency sweeps or anything, only messages saying “Auto Tune failing to level, please tune manually”.
https://drive.google.com/file/d/1jiDC4R2jQDKUP2up8YGrC-rwPBho6Z0a/view?usp=share_link
and another log of the same error;
https://drive.google.com/file/d/1UE5RV4m-OIUjn6p2DdZbeexM0sdrJ2av/view?usp=share_link

These are all the AT logs. Hope this helps.

Thanks & Regards,
Adarsh

@Adi_Fly Hi Adarsh,
I looked over all of your tuning logs. The autotune did well tuning the pitch and roll FF gains. For the pitch and roll tuning it performed as designed. For the pitch tuning, the max response gain was set to 1.0 which is pretty low for the pitch and roll axes. But it appears to have done pretty well with that axis. You could increase the max response gain (AUTOTUNE_GN_MAX) to 1.4 and still get an acceptable tune. For the roll axis, the ATC_RAT_RLL_P was not tuned because the response gain was beyond the AUTOTUNE_GN_MAX value. So it just stopped. The peak of the roll axis response gain is 2.3. Having just ATC_RAT_RLL_D gain tuned with no ATC_RAT_RLL_P gain would be fine. To improve this tune anymore would require using the filters to modify the rates to reduce the response gain.

The one thing I noticed is that between flights, the harmonic notch filter was changed. It appears that for the Pitch Rate P and D tuning, it was disabled. Then for the first flight of Roll Rate P and D tuning it was enabled. For the most recent flight for roll tuning, it was disabled. I think it could be the notch filter being disabled that may be causing the failing to level messages. Were you intentionally changing the harmonic notch?

Hi Bill,

Thanks for your reply.

During the initial pitch rate D & P tuning, I forgot to change the max gain and to enable the notch filter.

When the roll rate D & P tuning was failing in the beginning that’s when I changed the max gain and max freq and even enabled the static notch filter for wanting the AT to work.

In the newer logs, as I was getting the “failing to level” error, I tried with all combinations to get the AT to work.

I tried to start the AT in all combinations but it did not start the AT.

Will try again tomrorow, what changes do you recommend me doing?

Thanks and regards,
Adarsh

Adarsh,
I think that I have seen enough on the Roll rate p and d tuning. Set the ATC_RAT_RLL_D to 0.0003. Leave the ATC_RAT_RLL_P at zero. Perform the angle P tuning for roll and pitch. Be sure to have the harmonic notch filter enabled. Don’t turn it off again. it is needed to clean up the rate signals for the controller.

Hello Bill,

I did as you suggested. surprising was this time the AT frequency sweeps started without giving the “failing to level” error. I did not change anything except for the axis and seq.
Also, does the auto tune tunes the Rate-I too, cause, i had the I value at 0.1, now its changed very slightly.

First did the AT for Ang-P for pitch and roll together, it failed, increased the max frequency to 100 and got the AT success message.
Log file: 022
https://drive.google.com/file/d/1Jq-Xy1Pisajpy6Rsv-kHZp9U7bpe1cKl/view?usp=share_link

Next tried AT of Yaw D & P, changed the Gain max to 1.0 and max freq to 70 and tired the AT, the AT sweeps went on for a very long time but did not complete, had to land the heli to replace the batts.
Log file : 023
https://drive.google.com/file/d/1OemQYQACP9Muugr_sXvPuN4SpsoI8Bqb/view?usp=share_link

Keeping the default values for the Yaw D & P (D=0.003 & P=0.18) went ahead and tried the AT for yaw-Ang-P, this got done.
Log file : 025
https://drive.google.com/file/d/1kHhHOaQOCNkn1Vs-vIhq94AiYuAW8TJG/view?usp=share_link

Tried re doing AT for Yaw D&P, (with max gain at 1 and freq at 100) the AT was success
Log file: 026
https://drive.google.com/file/d/1r1czY28WlYWT4o7n5OB0w4j-w3dW5YTQ/view?usp=share_link

After the Yaw D&P was success, keeping these newly AT values re did the Yaw Ang-P AT again, this too was a success but with the yaw AT D & P rates after the AT yaw-ang-p tuned, the tail was not stable and was osscilating.
Log file: 027
https://drive.google.com/file/d/13_j5f7HTxNXa6ACxMlPwMxVvGwoGXEc2/view?usp=share_link

As the tail was osscillating and when tail input was given and the stop was very sharp, hence, redced the AT yaw-P value from 0.272 to 0.20 and yaw-D value from 0.008 to 0.007 and re did the AT for Yaw-ang-P again. with this AT success, the tail was good and was not osscillating.
Log file: 028
https://drive.google.com/file/d/1CFGPk7_DGxV3mOOX1X-wXF9lrBl64S4E/view?usp=share_link

With this done, wanted to try the AT for Rate D & P for roll axis again as earlier had got 0 for the Roll-P value, Did in max gain 1 and in max gain 1.8. With max gain at 1, got D at 0.0006 & P at 0.0303. With the max gain at 1.8, got D at 0.0003 and P at 0.123. The PWith max gain at 1.8, in the later part of AT, the roll sweeps get more aggressive visibly.
Log file:031
https://drive.google.com/file/d/1GHCOWXpvhNdaex5O0bR3vm4JUCT9OzWj/view?usp=share_link

Here, i faced a minor problem, after i got the message “AT success” i switched over to Alt-hold and switched back to AT to check the tune, but when i switched back to AT, the freqency/roll started again and during this the message i got is ':Pilot testing". I had to again switch back to Alt-hold and switch to AT, now it was ok and could land to disarm. Redoing this, gave me D at 0.0006 and P at 0.124. Without changing any other params, by doing the same AT consecutively, the P value remained almost same but the D value doubled. ( earlier it was 0.0003 and now its 0.0006)
I did this Roll D & P again cause of the above problem, and on both occasions it did the same.
Log file 032
https://drive.google.com/file/d/1qyPmXK-Ajmny5ypngh1HiyhKd6egsmLX/view?usp=share_link

Will do a loiter flight and an small auto flight and check and update you in a day.
is there anything else i need to tweak?

Hope these logs help.

Thanks for all your help Bill.

Thanks & Regards,
Adarsh

Yes, when you tune an axis, it adjusts the I gain based on the FF gain for pitch and roll.

Ran out of time this evening. I will look at your logs tomorrow evening. Thanks for posting them this is very helpful

@Adi_Fly
@bnsgeyer

This thread is very interesting to read along!
Thank you both for your work.

BR

Heri

Do not use these values for your rate P and D gains for the roll axis. The P gain is too high. Use the previous gains you determined where the P gain was 0.03 and the D gain was 0.0006 are the correct gains. I’ll explain more later.

Definitely didn’t need the max frequency of 100 rad/s. The most you needed on your tail was 50 rad/s.


You can see the phase (blue line) drop off and get jagged after 30-40 rad/s. I don’t know why the value of 1 for the max response gain produced an unstable P gain.

Good job bringing the P gain down. In looking at the logs for your yaw axis. There seems to be quite a bit of lag in the rate response which I believe is causing a lot of overshoot in the angle response. In 4.3.0, we introduced a new parameter called PILOT_Y_RATE_TC. This is a pilot input shaping parameter. It is very similar to ATC_INPUT_TC except it is a time constant for yaw rate response. I think overshooting in the angle response and high angle response gains is do to the shaping is too fast. Set the PILOT_Y_RATE_TC to 0.08. Then set the ATC_RAT_YAW_FLTT to 2 hz. run the angle P tune for the yaw axis again but set your AUTOTUNE_FRQ_MAX to 40.

There is a known bug in the multicopter/helicopter autotune Pilot testing code. It loads the tuned gains at first but as soon as you make any inputs on the sticks then it puts the original gains in there. That is why you initially saw the aircraft oscillating. You had not made any inputs so the tuned gains were loaded and they caused an instability and the oscillations. you switched out and then back in. This time you made inputs and so the gains switched back to the original gains and thus no oscillations. I have a PR in to fix this issue.

A very interesting things happened.
The blade holder I was using earlier for the above AT was the one without the lead lag (two bolt main rotor holder), I replaced to the normal rotor holder with the lead lag and took off the heli in the same tuned params, the heli started oscillating crazy……
so I re did the whole AT process, and came across few issues. Will upload the logs in a while.

The AT for FF went smooth, got Roll-FF of 0.1952316 and Pitch-FF of 0.2140522

Next did AT for D&P Pitch with max freq of 100 and got D value as 0 and P value as 0.1174829. Took off to test the pitch D & P rates, it was fine in the beginning of let’s say 30-40 secs or so, slowly thr pitch started to oscillate and thr oscillation was getting worse, hence landed the heli and zeroed the d&p values of pitch and redid the AT of pitch again with max freq of 70.
This time thr AT was success and gave values of for D = 0.0007756687 and P = 0.1135173.

Next did AT for Roll-D&P, took off and was about to start the AT for roll, was still in stab mode, thr pitch axis started oscillating, slowly oscillation in the beginning and oscillations started to get wilder. Landed the heli without any damage. Reduced the earlier auto tuned pitch P value from 0.1135 to 0.07. And took off to re do the roll D & P auto tuning.
During the roll freq sweeps, I could see that the pitch was unstable and was moving the pitch angle too during the roll AT. Thr freq sweeps were aggressive. Got the AT success message and found very large d & P rates. Got roll D value of 6.524526 and roll P value of 0.1026227.

Hence, stopped thr AT and did a manual tune for pitch and roll D & P. Below are the values:
FF pitch - 0.17
FF roll - 0.17
Rate D pitch - 0.003
Rate D roll - 0.007
Rate P pitch - 0.07
Rate P roll - 0.07
Rate I for both axis - 0.2
With these above values flew the heli, in Stab and alt hold mode, seemed good. Flew in loiter mode and seemed good.

With the above settings, went ahead and tried the AT for Ang-P for pitch and roll and got the value of 3 for both axis.

Next tried AT for yaw D & P with max freq of 70, got the message AT failed, hence increased the max freq to 100 and re did the yaw D&P AT, the AT went on for a real real long time was almost 30mins and the freq sweeps were not that aggressive, waited for the whole flight but AT did not complete…. Had to land cause of battery.

Will Upload the logs in sometime.

Thanks and regards,
Adarsh.