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.
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
Do you get the GCS saved gains message? That’s the indication that the gains were actually recorded.
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.
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.
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
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.
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.
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.
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.