Autotune failed

hi bill @bnsgeyer
I try to test autotune function in my 700 class helicopter, when I try the step 4 which you suggest,
it failed, exceed the frequece,
2022-08-06 09:02:56.712 AutoTune: Exceeded frequency range
2022-08-06 09:02:56.712 Event: DATA_AUTOTUNE_FAILED
so, could you give some advice for that? log attached for you reference.

check the code

it looks like that the start_freq is out of range, so how do we define the start_freq?

@jinchengde i haven’t looked at your log but start_freq in the code could be the start of the sweep or the dwell frequency. Most likely it is a dwell frequency. Typically after it completes the sweep then it will perform dwells and increase or decrease the frequency to find the max gain. You need to look at the log and see if during the sweep there was a frequency which was a maximum in the middle of the range of min to max frequency defined by the autotune parameters. It may have had a spike toward the end of the sweep which caused it to dwell near the max freq and then in the search caused it to exceed the max frequency. I will have to look at it tonight and get back to you.

2022-08-06 09:02:32.802 AutoTune: freq=0.000000 gain=0.000000 phase=0.0000
2022-08-06 09:02:34.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:34.802 AutoTune: Testing
2022-08-06 09:02:34.802 AutoTune: Sweep
2022-08-06 09:02:34.802 AutoTune: freq=11.67878 gain=1.558207 phase=33.457
2022-08-06 09:02:36.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:36.802 AutoTune: Testing
2022-08-06 09:02:36.802 AutoTune: Sweep
2022-08-06 09:02:36.802 AutoTune: freq=13.80920 gain=1.707832 phase=49.846
2022-08-06 09:02:38.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:38.802 AutoTune: Testing
2022-08-06 09:02:38.802 AutoTune: Sweep
2022-08-06 09:02:38.802 AutoTune: freq=16.49130 gain=2.062764 phase=424.25
2022-08-06 09:02:40.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:40.802 AutoTune: Testing
2022-08-06 09:02:40.802 AutoTune: Sweep
2022-08-06 09:02:40.802 AutoTune: freq=20.26834 gain=1.402311 phase=423.87
2022-08-06 09:02:42.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:42.802 AutoTune: Testing
2022-08-06 09:02:42.802 AutoTune: Sweep
2022-08-06 09:02:42.802 AutoTune: freq=23.89044 gain=2.864715 phase=535.20
2022-08-06 09:02:43.217 EKF3 lane switch 2
2022-08-06 09:02:43.217 Event: DATA_EKF_YAW_RESET
2022-08-06 09:02:43.217 Error: Subsys EKF_PRIMARY ECode 2
2022-08-06 09:02:43.217 EKF primary changed:2
2022-08-06 09:02:44.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:44.802 AutoTune: Testing
2022-08-06 09:02:44.802 AutoTune: Sweep
2022-08-06 09:02:44.802 AutoTune: freq=28.82195 gain=1.254261 phase=209.72
2022-08-06 09:02:46.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:46.802 AutoTune: Testing
2022-08-06 09:02:46.802 AutoTune: Sweep
2022-08-06 09:02:46.802 AutoTune: freq=34.52299 gain=0.607158 phase=231.42
2022-08-06 09:02:48.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:48.802 AutoTune: Testing
2022-08-06 09:02:48.802 AutoTune: Sweep
2022-08-06 09:02:48.802 AutoTune: freq=40.53668 gain=0.339297 phase=243.87
2022-08-06 09:02:50.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:50.802 AutoTune: Testing
2022-08-06 09:02:50.802 AutoTune: Sweep
2022-08-06 09:02:50.802 AutoTune: freq=48.70686 gain=0.398283 phase=-510.6
2022-08-06 09:02:52.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:52.802 AutoTune: Testing
2022-08-06 09:02:52.802 AutoTune: Sweep
2022-08-06 09:02:52.802 AutoTune: freq=57.11987 gain=0.337832 phase=-998.1
2022-08-06 09:02:54.507 AutoTune: max_freq=0.799184 max_gain=4.023236
2022-08-06 09:02:54.507 AutoTune: ph180_freq=0.000000 ph180_gain=0.000000
2022-08-06 09:02:54.802 AutoTune: Pitch Angle P Up
2022-08-06 09:02:54.802 AutoTune: Leveling
2022-08-06 09:02:54.802 AutoTune: Dwell
2022-08-06 09:02:56.712 AutoTune: Exceeded frequency range

from the log, we see some EKF lane changed, is that influence the autotune?

should I set param AUTOTUNE_GN_MAX lower? or recalibrate the compass too?

I solve the problem by reduce the ATC_ANG_PIT_P from 4.5 to 2.5
It looks like pitch is too senstive when the autotune start, from log we see
max_freq=0.799184 max_gain=4.023236
max_gain had arrived even freq not tune up
so just reduct ang_p and solve the problem
below is autotune finished in my trex 700
Arducopter helicopter 4.2.2 Loiter after autotune - YouTube

I don’t think these were good values. Sometimes it generates bad information as it is starting the oscillations. So I think re-running the pitch angle p tuning could have caused it to come up with different values and then complete successfully.

Could you post your log for this tuning sequence. I wanted to see what value it determined for Angle P for pitch axis.

great video! thanks for posting it!

I test 3 times of ATC_ANG_PIT_P equal 4.5 and both failed, follow is once log for you reference