Autotune failed to save new PID with Copter-4.0.0-rc2

It is the second time that this happen to me. The first time with a little 3inch with revo-mini so I have no log. The second time happened with a 5inch with Pixracer and so I have the log.

I did Autotune on the three axis, I tested both old and new PID in flight then I landed with Autotune On and disarmed. After this I saw on GCS (Tower on Android phone) the new PID, but after power off - power on I saw the old PID.

Using mavparms.py I could extract the parameters both from df log and from tlog. On the first I have old PID and on the second new PID.

I attach dataflash log, telemetry log, params extracted from dflog and params extracted from tlog.

I have to say that I was using Copter-4.0.0-rc2 with PR #11886 from @andyp1per applied cloned from here.

1 Like

Here a graph from my Log, CH7 is for Autotune and CH8 for Land.

Is it normal that I see Autotune Off after switching HIGH Land (CH8) even if Autotune (CH7) remained HIGH?

I fear this is why I donā€™t get New PID from Autotune saved, or am I wrong?

I wonder if itā€™s my PR. There is code in there to save the FFT settings on disarm - maybe thatā€™s interfering with things.

Maybe if you can build you can take out the call to gyrofft.save_params_on_disarm() ā€¦ and now I can see thatā€™s not called, weird - Iā€™ll try and figure out later.

Ok my code is not in there - so it canā€™t be affecting this :slight_smile:
Do you get the GCS saved gains message? Thatā€™s the indication that the gains were actually recorded.

2 Likes

Good!

I donā€™t remember, that should be in the tlog, I think, I will look better at it, anyway on df log I see ā€œAutoTune: Successā€.

The last MSG I see on tlog is ā€œAutoTune: Stoppedā€ contemporary to switching on Land mode via RC, the same as showed on my previously posted graph.

As I said before it seems strange to me that Autotune go Off when I switch to land mode. When the copter disarm itself, after Land, it find Autotune Off and so the new PID are not saved, but I did not switched Off the Autotune by RC.

Yes, the reason they arenā€™t saving is because you are going into land mode. Autotune and Land are both flight modes, so independent of which switch you have them set on, the flight mode gets set to whichever switch was last changed (I hope that made sense, not sure I explained it very well) .

So you arenā€™t disarming in autotune mode, hence they donā€™t save. It might also be worth noting, that when you switch out of autotune to any other mode the PIDS revert back to what they were before the autotune. So when you switch to land, it is actually flying on a potentially worse tune. If you switch back to autotune, then you will get the new tuned pids back and can test them out, land, and disarm to save.

1 Like

So you are saying that I have to land by hand (lowering throttle) and then disarm and not by switching Land mode.
It seems to me that I have done this (switching Land after Autotune) in the past without problems, but maybe I am wrong.

Correct. I am confident that this is how it works.

You can switch out of autotune and back in if you like. But you must be in autotune when you disarm to save the gains. For example, I was tuning roll pitch and yaw in the same flight when the battery was getting low after only tuning roll. So I switched to stabilise, landed but didnā€™t lower the throttle to zero. When on ground I switched back to autotune and then disarmed. That saved the gains for the axis that had completed.

I was autotuning with 4.0 rc2, 2 days ago and I can confirm that the pid set and save for autotune is working.

2 Likes

I was tuning roll pitch and yaw in the same flight when the battery was getting low after only tuning roll. So I switched to stabilise, landed but didnā€™t lower the throttle to zero. When on ground I switched back to autotune and then disarmed. That saved the gains for the axis that had completed.

I confirm Iā€™m used to autotune always this ways as described by @IAMMATT, and the above example is cool, sometimes Iā€™ve missed to save the autotuned perams, but probably having the habit to swith to autotune after landing is very effective

I remembered well, I found a log (actually more then one) in which, with Copter-3.6.6, after Autotune I landed switching to Land mode and I had gains saved.
In the plot, after Land by Radio, is visible the message ā€œAutoTune: Stoppedā€ and after Land Complete the message ā€œAutoTune: Saved gainsā€.

So it seems is something that changed from 3.6 to 4.0, I donā€™t know if it is intentional.

That is strange. Perhaps it was the case that it would save the gains in flight modes other than Autotune, in previous versions. Iā€™m not sure about that. However, in 4.0 you definitely need to be in the Autotune flight mode when you disarm to save the gains:

As I understand it, this behaviour is needed so that users have the option to land and it doesnā€™t save the parameters. For example, if Autotune has done a poor job and the aircraft is hard to control with the new gains.

This is where this behavior changed:

Ah, good to know.

So itā€™s your fault @iampete :wink::yum:

I believe the bug was never in 3.6. Essentially there was a discrepancy between what happening and what it said should happen in the Wiki. That PR brought the code back in line with the wiki. The wiki has always said you must disarm in autotune as far as I know.

1 Like

I had the (wrong) habit to use one switch for Land and one for Autotune, when I saw Autotune success I switched Land HIGH leaving Autotune switch HIGH to have my gains saved. If I did not like the Autotune results I switched Autotune LOW and then Land High to keep old gains.

I did this way because i misinterpreted the point 9 on Autotune Wiki:
ā€œIf you are happy with the autotuned PID gains, leave the ch7/ch8 switch in the HIGH position, land and disarm to save the PIDs permanently.ā€

All this on Copter 3.6 worked.

Now with Copter 4.0 I have to change my habit and not switch to Land but reduce throttle to land then disarm.

I wanted to clarify this in the event that someone else made the same mistake as me.

2 Likes

To be honest, it is perfekt described in the wiki. Each time when I build another kopter or put another payload I do the autotune exactly how it discribted in the wiki. And the results are fantastic

What has happened to RC8_OPTION? I had previously used it to select AutoTune. That way it did not affect flight modes. Now the RC8_OPTION selection is greyed out, and AutoTune is not listed as an option for the parameter in the documentation. Must AUTOTUNE be a Flight Mode now?

Solved! Mission Planner 1.3.70 Seems to correct the problem.

Thanks all!

Maybe it should read:

If you are happy with the autotuned PID gains, leave the ch7/ch8 switch in the HIGH position, land and disarm all while in Autotune flight mode in order to save the PIDs permanently.
NOTE: You must land in Autotune flight mode for PIDs to the saved. Switching to any other flight mode will result in not saving PIDs.

ā€¦on a side noteā€¦i have been meaning to jump in and work on editing the wiki, but I havent made that move yet. If someone sees the above, please feel free to copy/paste my words into the wiki

I would only add a note to say to land manually, such as:

NOTE: You have to land by reduce throttle till landing complete and then disarm. If you land by switching to Land mode you are no more in Autotune mode and the PIDs will not be saved.