Tuning the Harmonic Notch

My FFT change is merged but disabled on all 1Mb boards apart from KakuteF7Mini and KakuteF7. The concern is that on F405 boards the CPU won’t be able to keep up even at default settings.

If you have flown successfully with my FFT on a 1mb board and are reasonably confident that it is working well, please can you let me know which board so that I can enable it for that board (ideally with a log if possible). Thanks.

It’s in Master now? I don’t see the INS_HNTCH_OPTS = 1 parameter.

No. FFT is in master, double harmonic notch is still a PR.

Ah right, I missed the context of your post.

Is there a guide for in-flight FFT? I have seen some content in this thread just checking if it’s somewhere else specific.

I tested (little indoor flight) your small-copter-4.1 branch on my 3 inch copter with revo-mini (F405). The copter is really really stable and the little revo-mini has no problems with double harmonic notch and dynamic FFT.
Thanks a lot for all your hard work.

Here the log.

[Edit]
I commented out the line
define HAL_WITH_DSP FALSE
from hwdef.dat

Thanks, the load looks good at about 60% max, which is quite high but I guess manageable.
I’m a little disconcerted by the dropouts on the detected frequency, I think that may be because my algorithm to detect harmonics could be improved. I suspect you don’t notice much difference, but I would like to get it picking the harmonics more predictably, perhaps by adding a low-pass filter on the multiplier.

1 Like

I have flown the FFT notch on an Omnibus nano w/out any problems… But that was a while ago and I don’t have any logs to share… I switched to ESC based soon after I tried the FFT one.

It looks like what I really need to see is whether there are any slips reported when SCHED_DEBUG = 2 unfortunately the output is not logged, it will only show up in the console - so might be difficult to tell

This is what I see with SCHED_DEBUG = 2 as messages on GCS:

[MAV 001:1] PERF: 40/7999 [2355:814] F=800Hz sd=54 Ex=0 
[MAV 001:1] PERF: 42/8000 [2020:603] F=800Hz sd=54 Ex=0 
[MAV 001:1] PERF: 22/8000 [2020:922] F=800Hz sd=39 Ex=0 
[MAV 001:1] PERF: 30/8000 [2112:672] F=800Hz sd=46 Ex=0 
[MAV 001:1] PERF: 33/8000 [2112:912] F=800Hz sd=47 Ex=0 
[MAV 001:1] PERF: 48/8000 [2120:866] F=799Hz sd=53 Ex=0 
[MAV 001:1] PERF: 50/8000 [2112:546] F=800Hz sd=56 Ex=0 
[MAV 001:1] PERF: 52/8000 [2065:599] F=800Hz sd=58 Ex=0 
[MAV 001:1] PERF: 14/1544 [2183:938] F=765Hz sd=60 Ex=800 
[MAV 001:1] PERF: 50/8000 [2687:561] F=796Hz sd=59 Ex=0 
[MAV 001:1] PERF: 44/8000 [2125:914] F=800Hz sd=53 Ex=0 
[MAV 001:1] PERF: 49/8000 [2011:718] F=800Hz sd=54 Ex=0 
[MAV 001:1] PERF: 48/8000 [2119:913] F=795Hz sd=55 Ex=0 
[MAV 001:1] PERF: 41/8000 [2109:636] F=800Hz sd=50 Ex=0 
[MAV 001:1] PERF: 56/8000 [2112:904] F=794Hz sd=57 Ex=0 
[MAV 001:1] PERF: 51/8000 [2117:830] F=797Hz sd=58 Ex=0 
[MAV 001:1] PERF: 48/8000 [2014:917] F=799Hz sd=52 Ex=0 
[MAV 001:1] PERF: 16/1535 [2218:931] F=771Hz sd=70 Ex=700 
[MAV 001:1] PERF: 58/8000 [2529:916] F=799Hz sd=60 Ex=0 
[MAV 001:1] PERF: 53/8000 [2113:802] F=797Hz sd=57 Ex=0 
[MAV 001:1] PERF: 48/8000 [2112:596] F=801Hz sd=56 Ex=0 
[MAV 001:1] PERF: 53/8000 [2118:816] F=800Hz sd=58 Ex=0 
[MAV 001:1] PERF: 44/8000 [2115:697] F=800Hz sd=55 Ex=0 
[MAV 001:1] PERF: 47/8000 [2011:821] F=801Hz sd=52 Ex=0 
[MAV 001:1] PERF: 48/8000 [2110:598] F=801Hz sd=58 Ex=0 
[MAV 001:1] PERF: 49/8000 [2118:606] F=801Hz sd=54 Ex=0 
[MAV 001:1] PERF: 16/1537 [9605:908] F=706Hz sd=256 Ex=800 
[MAV 001:1] PERF: 43/8000 [2357:811] F=801Hz sd=54 Ex=0 
[MAV 001:1] PERF: 19/8000 [2011:921] F=800Hz sd=38 Ex=0 
[MAV 001:1] PERF: 51/8000 [2112:914] F=801Hz sd=58 Ex=0 

Do I have to see other things?

[Edit]
First messages with copter disarmed, central messages while flying near 1 min, last messages disarmed.

You are looking for this message: Scheduler slip task[%u-%s] (%u/%u/%u)\n but it will only show up on the console as its a printf. You could consider changing to a mav message in AP_Scheduler.cpp if that’s easier to see.

I have added a mav message after the printf and I see so much slip messages :frowning:

[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[38-periodic_tasks] (4/2/300) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[0-rc_loop] (4294901768/8/130) 
[MAV 001:1] Scheduler slip task[1-throttle_loop] (4294901776/1 
[MAV 001:1] 6/75) 
[MAV 001:1] Scheduler slip task[2-update_GPS] (4294901775/16/2 
[MAV 001:1] 00) 
[MAV 001:1] Scheduler slip task[3-update] (4294901763/4/160) 
[MAV 001:1] Scheduler slip task[4-update_batt_compass] (429490 
[MAV 001:1] 1775/80/120) 
[MAV 001:1] Scheduler slip task[5-read_aux_all] (4294901775/80 
[MAV 001:1] /50) 
[MAV 001:1] Scheduler slip task[6-arm_motors_check] (429490177 
[MAV 001:1] 5/80/50) 
[MAV 001:1] Scheduler slip task[7-auto_disarm_check] (42949017 
[MAV 001:1] 74/80/50) 
[MAV 001:1] Scheduler slip task[8-auto_trim] (4294901774/80/75 
[MAV 001:1] ) 
[MAV 001:1] Scheduler slip task[9-read_rangefinder] (429490177 
[MAV 001:1] 
[MAV 001:1] 01766/80/350) 
[MAV 001:1] ) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (4294901767/1 
[MAV 001:1] /50) 
[MAV 001:1] Scheduler slip task[52-update_parameters] (4294902 
[MAV 001:1] 490/800/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[51-sample_gyros] (2/1/50) 
[MAV 001:1] Scheduler slip task[33-update_send] (4/2/550)

Interesting that it’s mainly sample_gyros(). What is your FFT_WINDOW_SIZE? if you change line 85 in AP_Vehicle.cpp to 100us (rather than 50us) does that help?
It could also be a cascading effect of printing messages - as soon as you print one you will delay the next, probably better to try and use mavproxy to display the output and continue to use printf()

My FFT_WINDOW_SIZE is 32, I removed writing to gcs (previously added) and tried 100us in line 85 of AP_Vehicle.cpp but the result is the same: a lot of “slip task[51-sample_gyros] (2/1/100)”.
Now I am using mavproxy to display console output.

It’s possible this is expected - sample_gyros() is supposed to run at the loop rate, so if anything gets missed it will. We actually don’t report anything in the fast loop anyway, it always runs so maybe we should just ignore slips for loop rate tasks.

@wicked1 I finally have the props on my rebuilt Gecko. I think it has the leans like yours - I see significant accel offsets, will investigate more.

I definitely think this is voltage related. My initial calibration was on USB power and that is what resulted in horrible offsets. I re-calibrated with the battery connected and it was a totally different copter - before it was pretty much unflyable, after it hovered beautifully.

Tested also on a 5 inch copter with a Pixracer. Similar behavior with slip, maybe a little less frequent.

Here the log.

Yeah I’ll see if I can get some consensus on whether we are expecting too much here.

Hi Andy,
I was away for the past week…

Is yours still leaning?
I’m almost positive I calibrated while powered w/ battery… I know I have done it both ways in the past. I’ll recalibrate and see if it makes any difference.

The leaning is odd… It’s not always the same. Some flights are horrible, and I have to land after a minute because I can’t compensate anymore. Other times it’s almost fine, w/ no changes to the copter or configuration. Although, temperature, GPS signal, magnetic interference, etc, are all out of my control… Still, it doesn’t really seem to be related to any of that… I can reboot a few times in the same place and time, and it could be fine, or it could be worse.

I hate to put the curse of the leans on you, but I’m kind of glad to see other people w/ the problem. I’ve been trying to figure it out for years, and have made little progress. Hopefully if others can reproduce it, we can figure it out.

Hi all,
I calibrated the notch filter on my 3 ". These are the results that seem good to me.

before

after

dynamic fly NO AUTOTUNE YET

my setting

INS_HNTCH_ATT,15
INS_HNTCH_BW,100
INS_HNTCH_ENABLE,1
INS_HNTCH_FREQ,200
INS_HNTCH_HMNCS,3
INS_HNTCH_MODE,1
INS_HNTCH_REF,0.26

MOT_THST_HOVER,0.296434 (dynamic fly)

It’s correct set the INS_HNTCH_REF to 0.28?

Thanks!

Nice! Yes set the REF to exactly the hover thrust. If you want the notch to go below your hover rpm there is a calculation in the wiki you can use.