MicroArduCopter, 3" props, Omnibus Nano, Success!

Thanks, now is all clear, i think I will go with the “cross your fingers” option :slight_smile:

I’m sure that’s fine, the only thing to watch for is dropping the notch too far into your control bandwidth - so for instance if I set MINHZ to 50Hz on my 4" quad it gets very unstable. So higher is safer, but you obviously want to target enough of the throttle range to be useful.

I just tried this. Everything went well. I’ll assume it’s working… I can’t say I noticed a difference, but I already had the previous filters set up well. Only changes I made were enabling the FFT harmonic notch and disabled the static notch.

INS_HNTCH_ATT,30
INS_HNTCH_BW,50
INS_HNTCH_ENABLE,1
INS_HNTCH_FREQ,80
INS_HNTCH_HMNCS,3
INS_HNTCH_MODE,4
INS_HNTCH_REF,1

FFT_ATT_REF,15
FFT_BW_HOVER,20
FFT_ENABLE,1
FFT_FREQ_HOVER,140 (I guessed on this, but just looked at a previous FFT, and think is should actually be 240)
FFT_MAXHZ,350
FFT_MINHZ,80
FFT_SAMPLE_MODE,0
FFT_SNR_REF,25
FFT_THR_REF,0.16
FFT_WINDOW_OLAP,0.5
FFT_WINDOW_SIZE,32

FFT_THR_REF, FFT_BW_HOVER and FFT_FREQ_HOVER are learned values. If you hover steadily for a while they should converge on values that you can use in the throttle-based harmonic notch.

What you should find is if it is working well you can rerun autotune and get more aggressive PIDs.

Are you able to get logs? An FFT log will tell you how well things are working

I didn’t realize before the flight, but I had logging disabled.

those parameters didn’t change over the course of two flights… But I wasn’t hovering long for either flight… Just a few min over my house to get GPS, then I was off flying around the area.

The FFT_freq_hover param should be the center frequency from a hovering flight, though, correct? Because I do know that number is about 240hz from an FFT I made a couple months ago on this copter.

I’ll be sure to log a flight next time… Has anything changed in the last several months about logging FFT? Is it still the batch sampler? (I think I’ve seen posts saying logging raw IMU will produce an FFT, but don’t know for sure)

I built arducopter from your fork with “In-flight dynamic FFT analysis” for my quad with revo-mini, 3inch props, 1104 5400KV motors and 2S battery.
Follows images with FFT in 3 cases

pre-filter

post-filter with INS_HNTCH_MODE=1

post-filter with INS_HNTCH_MODE=4

Viewing the pre-filter FFT I set a notch at 150Hz and an harmonic notch at 350Hz and I tested both throttle based and FFT based.
I think it is all working good because now I have a really stable quad even with PID tuned by hand.
The only thing that doesn’t work is that I never see the learned values on the FFT params.

I attach two logs one with INS_HNTCH_MODE=1 and one with INS_HNTCH_MODE=4
log1
log2

Yes it should converge on your center frequency. It gets learned at the same time as HOVER_LEARN so if you aren’t hovering it won’t change.

FFT logging is unchanged.

Can we still log pre and post filter in the same flight?
That info never made it into the documentation, but I think that was something you (or someone) worked on at the beginning of the summer. Was it simply setting the INS_LOG_BAT_OPT param to 3?

Edit, that was actually ATC_LOG_BAT_OPT, which was for D term logging, and maybe that never was never a part of INS_LOG_BAT.

No you can’t do both at the same time. I had some back and forth with tridge about doing more logging but there is clearly a concern around CPU load etc.

The other thing this allows you to do is raise your gyro low pass filter value without the motors getting hot giving you more control.

Nice graphs!

So I wouldn’t do it that way round. Your main motor peak is down at 150Hz, but that will vary significantly as you throttle up and down so if you blast around you will see that the notch is not taking out this noise very well. Instead set the harmonic notch at 150Hz and the harmonics to 3 (the default) which will mean that both the 150Hz and its 2nd harmonic at 300Hz will be tracked. You could then set the static notch at 350Hz if needed, but I doubt you do as the low pass gyro filter will have take out most of that noise.

If you set INS_HNTCH_MODE=4 then its important to also set FFT_MINHZ and FFT_MAXHZ correctly. Can you post your parameters? I always have trouble reading them from a log!

I’m also interested in the noise at 500Hz I guess it could be aliasing, but its far bigger than I would expect.

Ok the learning code isn’t linked in :blush: I will fix

UPDATE: I’ve just had a flyaway crash in AltHold with my latest branch, I’m nervous about the cause of this so will check with Leonard before posting any further updates. Caveat Emptor - this is still unreleased code! :worried:

1 Like

Here my params file.
parameter-revomini-kk130-02-11-2019-EK2-hntch.param (20.4 KB)

Anyway I used
FFT_MINHZ,100
FFT_MAXHZ,380

I think that if I had to consider 150Hz the main motor peak I have to set something like
FFT_MINHZ,80
FFT_MAXHZ,240

otherwise 350Hz will be chosen as main motor peak.

P.S.:
I’ve got a curiosity:
why the same filter is not applied to the accel other then the gyro?

Ok, this is not doing what you expect.

You can basically ignore INS_HNTCH_FREQ if you have mode set to 4 - the harmonic notch will be set from the detected motor peak. Since you are searching between 100-350Hz (your MINHZ,MAXHZ) it will find the biggest peak at 150 and set the notch there. But you also have the bandwidth set very wide so you will be taking out a lot of useful control information. Your D-Term filtering is pretty low for a copter this size as well.

Here is what I recommend changing:

SCHED_LOOP_RATE = 800
INS_HNTCH_BW = 50
INS_GYRO_FILTER = 100
ATC_RAT_PIT_FLTD = 80
ATC_RAT_PIT_FLTT = 80
ATC_RAT_RLL_FLTD = 80
ATC_RAT_RLL_FLTT = 80

Accel can be filtered far more aggressively because it is not used for fine control - only for AltHold and the like.

Ok here’s a weird thing. When I look at you log above it’s detected the peak at 300Hz. I’m not sure why this is:

Maybe that’s because that is where the peak is? These are really high Kv motors so could easily be spinning at 300Hz. So maybe you having the static notch at 150 is correct.

1 Like

OK, I’d say it’s working… :slight_smile:

On a different subject…
Is anyone still having the issue where the copter leans more and more?
This new firmware is causing more of that for me… There was some discussion that it might be related to processor load, and I do believe I have a higher load on my processor w/ the FFT filtering.

Same as 6 or 8 months ago when I last talked about it. It starts off level, starts tilting more and more if I have no GPS lock. I’m at about 45 degrees after a couple minutes. If I get GPS lock it levels, and up until now, stayed level. Now, it’s going out of level w/ GPS lock, though not bad.

Last spring I also figured out different FC’s did it differently (all omnibus nanos, some tilted a lot more than others). I guess this will encourage me to try the new 20x20 kakute f7.

Can you get a log with this happening? I’m sure a log would tell us a lot. Also I would raise a bug on github - could get some attention that way.

I’ve put a log on google drive (This is also the pre-filter FFT flight above, if you want to review it for any reason(FFT Driven Harmonic Notch Enabled)):

I checked the roll parameters mentioned in “the leans” section of the vibration analysis section of the arducopter docs… Looks ok to me. Me and the other few people w/ this problem all did not think it was an issue w/ vibrations. I think we might have also all been using omnibus nanos. And if it is just an issue w/ this particular FC, I don’t expect it to get a lot of attention.

But if anyone wants to look, or recommend some areas for me to check in the logs, I’d appreciate it.

Also worth mentioning, yawing around in a circle seems to reset the lean, so maybe something magnetometer related… And maybe that makes sense w/ the GPS lock fixing it, because then maybe EKF doesn’t rely on the magnetometer as much… (all just guesses).

In choosing bandwidth I followed your instruction (PR on wiki https://github.com/ArduPilot/ardupilot_wiki/pull/2072/files)
INS_HNTCH_BW = hover_freq / 2

Even on the log I see BwAvg is half the PeakAvg

Is there something wrong with this?

1 Like

Interesting! Ok then - your setting is good. My BwAvg never gets very large, but this is designed to find the 3db points so if it’s 150 then that’s a reasonable value.

My BW is also about 140 in the logs… I have it set to 50 in the parameters, and I don’t see any sign of noise on either end of the notch on the FFT.