Vertical Pulsing in Altitude Modes

I have a new build using an AOS 7 and Matek H743-SLIM and when switching to an Altitude mode i.e., Loiter, Alt Hold, or Position Hold I am getting vertical pulsing. It flies fine in Stabilized.
I have reduced ATC_RAT_PIT_P & I & D and ATC_RAT_RLL_P & I & D twice by 50% which has reduced the problem but not fixed it. I have also reduced PSC_POSZ_P and PSC_VELZ_P to 1.0 but this had no effect.
Can someone please take a look at the log to help me find what is causing this?

Did you start by copying parameters from another file?
Set these from the Initial Tuning Parameters, they are at default:
ATC_ACCEL_P_MAX
ATC_ACCEL_R_MAX
ATC_ACCEL_Y_MAX
Set the Rate PID’s back to half of default they are too low.
Set the PSC parameters you changed back to default and set these only for now:
PSC_ACCZ_I,0.42
PSC_ACCZ_P,0.21
Make a hover flight in Althold, graph the RCouts and make sure you don’t see anything like this:

@dkemxr Dave
Thanks for your help and those changes fixed the problem. Autotune next?

Disable Raw IMU from the Log_bitmask. Everything else looks pretty good but that is preventing a view of the FFT and it’s not needed anyway. The default for the log Bitmask is sufficient for most things. You can Add PID and Fast Harmonic Notch Logging to it if you have a reason to.

@dkemxr Dave
Thanks for the help!

The Autotune went well and the copter seems to fly well. I have been following the Blog ’ ArduCopter 7” Long-Range Standard Build

One thing I am curious about is the negative spikes in the FFT ACC2 graph as below.

I’m using ESC telemetry for the harmonic notch.
Any idea what the spikes are about??

It’s likely that spike is an artifact of the high logging rate and raw IMU logging and the harmonic notch filter also set to a high rate and a notch per motor - rather than a real dip in X acceleration.

In that log the tuning is still very bad and does not look autotuned at all.
It looks like you didnt set the parameters as per Daves advice.
And apart from you mentioning 7" builds, the parameters dont match a 7" build at all.

Can you connect to Initial Paremeters in Mission Planner,
Put in your props size and battery cell count, select “Suggested settings” too and hit the Calculate button then accept ALL changes it suggests.

Then set these:

ATC_ANG_RLL_P,6.0
ATC_ANG_PIT_P,6.0
ATC_RAT_RLL_P,0.07
ATC_RAT_RLL_I,0.07
ATC_RAT_RLL_D,0.0015
ATC_RAT_PIT_P,0.07
ATC_RAT_PIT_I,0.07
ATC_RAT_PIT_D,0.0015
INS_HNTCH_FREQ,120
INS_HNTCH_BW,60
INS_HNTCH_OPTS,0
LOG_BITMASK,145406
PSC_ACCZ_I,0.4
PSC_ACCZ_P,0.2
SERVO_DSHOT_RATE,0

and do a test flight with Stabilise and AltHold. If it’s working OK then just do some hovering and gentle movements.
Dont worry about PosHold and Loiter at this stage.

Hi Shawn

Thanks for your help. I will ensure I follow your instructions and post a log.

Some question?

You said, ‘it does not look autotuned at all’.

In simple terms what are you looking to see in a good tune?

Ardupilot is a complex beast with a lot of detail about the dozens of setting, but it is difficult in simple terms to check if you have them all working together correctly. Some general guidance would be very helpful!

INS_HNTCH_FREQ,120

Is this value from the first peak of the FFT GYRO graph?

Where did you get the values for the parameters ATC_ANG_RLL_P to ATC_RAT_PIT_D?

I cant give away ALL my secrets!
(there’s not much that is secret :slight_smile: )

Mainly we are just looking for attitude versus desired attitude, and a few other things like oscillations and noisy motor outputs.

Really, it’s easy to see if a whole range of values have been set by mere mortals, or set by Autotune. With yours I can see that MOT_THST_EXPO doesnt fit with normal expectations for ATC_ACCEL_MAX values, nor INS_GYRO_FILTER and some other things.

Some of the values like PIDs I can guess at based on your copters behaviour and a whole bunch of logs I’ve got from a range of copters. And I can make an educated guess about INS_HNTCH_FREQ based on your prop size and also your ESC RPM data → 9000rpm / 60 = 150Hz but I thought we’d start low for now.
When the Harmonic Notch filter is driven by ESC RPM the proportion of Freq to BW is important, and the actual frequency will be calculated and set from the live RPM.

And rarely does changing just one thing fix a copter. So set everything exactly I’ve specified, in the order I’ve specified (Initial Params first).
If it was to be done in stages, or separate parameters and retest each, I would have said so - you may get to that stage at some point.

EDIT: I got the feeling you were going to run Autotune further back in the discussion, but I could have been wrong.

Hopefully those setting are correct and here is a .bin of the flight you suggested.

https://drive.google.com/file/d/1HVsUIfu12a8Qd8UPP-YXgE2FvGRjYPT1/view?usp=sharing

Thanks for the useful information!.

What a difference!
Tuning needs a bit more work, but much closer than before.
Many of the bad aspects are gone.

How close were we on the Harmonic Notch frequency? 120Hz predicted versus 124Hz actual.
My spreadsheet with actual maths actually predicts 129Hz.
Being driven by the ESC RPM, we only need to adjust the bandwidth now, this should be the new value:
INS_HNTCH_BW,32
to keep that as narrow as possible but still effective.

Set this to improve the GPS performance
GPS_GNSS_MODE,65
so it’s not overwhelmed by too many constellations

Now the problem is the copter is a bit overpowered and learned hover throttle is not going low enough.
The hover throttle is also not saving.
Set these to improve the hover

MOT_HOVER_LEARN,2
MOT_THST_HOVER,0.13

and to hopefully improve the attitude control some more

ATC_ANG_RLL_P,8.0
ATC_ANG_PIT_P,8.0
ATC_RAT_RLL_P,0.08
ATC_RAT_RLL_I,0.08
ATC_RAT_RLL_D,0.0026
ATC_RAT_PIT_P,0.09
ATC_RAT_PIT_I,0.09
ATC_RAT_PIT_D,0.003

and do another flight in AltHold, try hovering for some time and we’ll see what the hover throttle does. Try a few more pitch and roll movements.

Hi Shawn.
A bit wet and windy to do a re-fly.

Some questions if I may?
Did you read the Harmonic Notch frequency of 124Hz from the first peak ion the FFT GYRO graph?
So does that become the INS_HNTCH_FREQ value??

You suggest setting the INS_HNTCH_BW,32 which is found from INS_HNTCH_FREQ/2 which means the INS_HNTCH_FREQ = 64?

I found the wiki quite confusing about where to set the INS_HNTCH_FREQ as it just says set it below below the hover frequency. I would have thought the harmonic notch would need some specific starting point which would be the motor peak in the FFT GYRO graph?

Thanks for the help which is appreciated

I read the frequency from the first major peak in this graph. Often the base frequency is not so obvious, and may be about 1/4 the amplitude and 1/2 the frequency of the first real obvious peak.

image

The bandwidth can be Freq / 2 for a quick and dirty calc, but if it can be narrowed down to just what is actually required that is even better. This minimises the work the HNOTCH has to do and minimises any lag in the system.
So in your case the bandwidth is between approximately 114Hz and 140Hz = 26Hz
It wont hurt to have a bit wider at 32.

image

You could actually set these just to make sure the HNOTCH covers all situations

INS_HNTCH_BW,25
INS_HNTCH_FREQ,100

Hi Shawn.

Thanks and that’s made it a lot clearer. Good learning!

I assume the following changes are to tighten up the RDes, R, PDes, P differences?

ATC_ANG_RLL_P,8.0
ATC_ANG_PIT_P,8.0
ATC_RAT_RLL_P,0.08
ATC_RAT_RLL_I,0.08
ATC_RAT_RLL_D,0.0026
ATC_RAT_PIT_P,0.09
ATC_RAT_PIT_I,0.09
ATC_RAT_PIT_D,0.003

Yes - you can usually set everything I give you all at once - unless I say specifically to set something then test that before doing more.

How did you work that out?

I did a MOT_THST_HOVER test previously and also got 0.13 which is the same as you suggest. How did you work that out??? Magic??

MissionPlanner Magic!

  • You graph the throttle output and you right-click-graph the altitude
  • You look for some section of relatively constant altitude and zoom in on that area, including both the altitude and throttle
  • MissionPlanner tells you the Min, Max and Average of all the values

From that you can make a reasonable estimate of what the hover throttle might be - at least near enough

Thanks for that Tip. Very Useful.
Here is the Hover test log. Your guesstimate looks correct.

https://drive.google.com/file/d/1gqIzWZsTiWu_abwrzuzl5M8cm5CUq96h/view?usp=sharing

That’s looking better, everything is “smoothing” out and not jumping around so much, including attitude control, altitude and motor outputs.

The Harmonic Notch Filter (and resulting flight) might benefit from some slight adjustments later, but I’m inclined to leave it alone for now at least until we see better basic tuning and attitude control. Then we can hone in on anything more that needs tweaking.

I’ve noticed vibrations - they are not bad or in the danger zone yet, probably even typical for these smaller copters, but if there’s anything you can do to reduce vibrations that will help.
Better mounting of the Flight Controller, wires not pulling on the FC or anything else touching it. Everything secured and not flapping around in the prop wash.

Set these for a bit of general cleanup

ATC_THR_MIX_MAN,0.5
INS_ACCEL_FILTER,10
PSC_ACCZ_I,0.26
PSC_ACCZ_P,0.13

Increasing this Yaw accel and reducing the P will both speed up Yaw, but take less away from pitch and roll attitude - that sounds like two opposites! I’m thinking after some more tuning the Pitch and Roll Angle P’s will be much higher, then this Yaw Angle P can be higher again, but just for now it can stay low while we work on Pitch and Roll.

ATC_ACCEL_Y_MAX,50000
ATC_ANG_YAW_P,5.0

And increase these pitch and roll values a bit
ATC_ANG_PIT_P,10
ATC_ANG_RLL_P,10
ATC_RAT_PIT_P,0.10
ATC_RAT_PIT_I,0.10
ATC_RAT_RLL_P,0.10
ATC_RAT_RLL_I,0.10

It’s back out to the field for you! :slight_smile:
Let’s see the next log.
If attitude control is steady enough at the neutral pitch and roll positions you will be able to run Autotune on pitch and roll axis. Leave Yaw until last, it’s the least critical and easiest to adjust.

Thanks Shawn!

All the changes have been made and below is a new log. Please excuse my poor flying skills!
I found some loose wires which have been secured and the main culprit seemed to be the Air Unit antenna knob which has been repositioned but I think the mount needs changing? The CSFR antenna is still free to vibrate. The vibrations seem better?
This is a completely different quad to what we started with!

That log still looks good, but you didnt implement that last lot of parameter changes.

Also set this
INS_HNTCH_BW,40
in addition to the previous ones

ATC_ACCEL_Y_MAX,50000
ATC_ANG_PIT_P,10
ATC_ANG_RLL_P,10
ATC_ANG_YAW_P,5.0
ATC_RAT_PIT_I,0.10
ATC_RAT_PIT_P,0.10
ATC_RAT_RLL_I,0.10
ATC_RAT_RLL_P,0.10
ATC_THR_MIX_MAN,0.5
INS_ACCEL_FILTER,10
PSC_ACCZ_I,0.26
PSC_ACCZ_P,0.13
1 Like