How to Assess PID Quality

Hello everyone,

I hope to precisely tune my PID parameters through actual flight. I have watched many videos and read a lot of documentation. The official documentation suggests increasing D by 50%, then reducing it by 10% if oscillation occurs, and then reducing it by another 25% once the oscillation disappears. The same method should then be applied to adjust the P value, and finally set the I value to P = I.

Following this method, my 2.5-inch micro quadcopter can fly, but its performance is still far from commercial drones or DJI products. To maximize stability and minimize control lag as much as possible, judging a drone’s tuning quality from PID graphs would be more objective. However, I am not specialized in automatic control systems, even though I have tried my best to study and understand the relevant knowledge. I already understand the meanings of P, I, and D.

Time-domain curves in tools like PID Review are relatively easy to understand; I can basically tell overshoot or undershoot by comparing the desired and actual curves. But frequency spectrum curves and PID spectrograms are much harder to comprehend, especially step response curves, which involve Laplace transforms — they are really difficult for me to understand. Although I have learned how to use step response curves, I still struggle to grasp how they are generated.

I have been flying a 2.5-inch micro quadcopter indoors to find PID tuning patterns, but I have not succeeded yet. Therefore, I want to start a dedicated thread and post the issues I encounter during PID tuning here, so that many drone enthusiasts like me can better understand PID principles. I also hope everyone will share their problems here so we can discuss them together.

The problem I currently don’t understand is: for a well-tuned PID controller, should I focus mainly on the time-domain curve or the step response curve?

On my 2.5-inch tiny whoop, I found that the time-domain tracking is very good, but the step response curve is poor.

Moreover, the step response curve behaves completely differently in hover and when moving left/right with stick inputs.

Which one should I take as the reference?

I’ve encountered this issue on other drones: when I give left/right stick inputs, the actual response follows the target curve quite well, the step response reaches 1 and converges quickly. However, in hover mode, the entire step response curve stays below 1, with the peak only around 0.85.This has been confusing me for a long time — should I base my tuning on the step response in hover or during left/right stick movements?

I am not a professional in this kind of analysis, but to the extent possible I’m quite sure you see the effects of input shaping. This can be turned off by disabling the feed forward part of the control loop, that is, by ATC_RATE_FF_ENAB = 0. I believe @amilcarlucas has a step like that somewhere in the Methodic Configurator manual (if that was a different thing, please correct me). This way, you’ll likely see more consistency between hover and sharp inputs (but the overall smoothness will probably be a bit worse actually).

And as a 2-inch flyer, I would suggest having a look at fast rates (this: Unlocking the Potential of Faster Attitude Rates in Copter Control and associated documentation). A bit more involved, but is totally worth it for small drones. Worked like a charm for me even on F405-based AIO flight controllers once I got the basics right.

@xingxing what exactly is your goal?

If your goal is to treat and use ArduPilot like betaflight or INAV, stop it. ArduPilot is not Betaflight. It is different and needs to be used differently. If you really want to do step response analysis and analytical optimization, then there are no shortcuts, you need to do it like the rest of us and learn control theory.

If your goal is instead to get the best tune out of ArduCopter, then follow the documentation, configure the notch filter correctly and do an autotune. Once that is done you can play with the step response, because the results will be a lot better than the ones you have now.

ArduPilot is different, and needs a different approach. And no, you do not need to know any control theory if you follow the documentation. It is quite easy to use.

1 Like

@MaxBuzz Yes, for the kind of stuff he is doing and the kind of knowlage @xingxing has, using AMC would be the best solution, and there is a step where ATC_RATE_FF_ENAB = 0 that does exactly what @xingxing wants. And that step is in the correct sequence, @xingxing you need to do all the previous steps in order for that one to do what you want.

I’ve been following the AMC tuning steps and have applied filtering to this 2.5-inch mini quad. Due to limited knowledge, some steps are still unclear to me. I’ve been cramming on these topics over the past few days. Since I rarely have the chance to do autotuning outdoors, I’ve been flying indoors in Stabilized or ACRO mode to figure out the patterns.

I’ve read a lot about how PID affects the step response curve, but in practice, things don’t always match the theory. Let me give you an example: I set the PID values as shown in the figure.

From the step response curve, I can see the blue line has reached 1 with a very small overshoot peak, which I thought indicated insufficient P gain or excessive D gain. However, looking at the time-domain curve, the actual response overshoots the target, which would suggest that P gain is too high or D gain is insufficient.

So I increased the P value to 0.11. I expected the step response curve to show a larger overshoot peak, but after flying with left/right stick inputs, the curve actually dropped below 1. Later, I kept increasing the P value alone, yet the step response still stayed below 1. I then increased the D value, but the curve still didn’t rise back to 1. I continued increasing the I value until it equaled the P value, but the step response remained below 1. Meanwhile, overshoot was still visible on the time-domain rate curve. I’ve tried many different PID values for a long time but still can’t find a pattern. Am I misunderstanding the theory?

Finally, I kept increasing the values to P=0.24 and D=0.006. Looking at the time-domain rate curve, the actual response follows the target quite well, but the step response curve consistently stays below 1, which really confuses me. AMC also mentions step response curves, and I noticed that the step response curves shown there are also below 1.

Does the step response curve have to reach 1? AMC doesn’t mention to what extent the step response curve should reach to be considered a good one.

To get you a good initial PID you need to configure the notch filters first then do a in-flight magfit, then autotune.

AMC guides you in that process. Then you have a good pid starting point to play with.

Btw you question is incorrectly formatted. A step response is a time domain result.

In system identification we use frequency domain data to optimize the PIDs.

2 Likes

Which AMC step(s) are unclear?

In AMC, it is stated that the *RATE.out values in the log should not exceed 0.15.

Regarding this metric:

  1. How is this value calculated?

  2. What output characteristic does it represent?

  3. According to Mission Planner documentation, this is a normalized value. My understanding is that it represents motor output, and its magnitude indicates the strength of attitude correction.

  4. Do I only need to check that the magnitude ≤ 0.15, or should I also check the frequency?

Also, should this value be judged mainly in hover or during aggressive maneuvers?My understanding is that it should be based on hover, because during large maneuvers this value will almost certainly exceed 0.15.

I have carefully re-read AMC’s PID tuning steps and done some further thinking. From a PD perspective for a multicopter, P determines the aircraft’s rapid response, while D mainly acts as a damping brake. Our goal is to increase PD as much as possible—up to the point where the system corrects errors quickly without oscillation.

In actual PID tuning, for example, if I see from the time-domain curve that the actual response goes higher than the desired setpoint, I could either lower P or increase D. However, to make the system eliminate error as quickly as possible, I need to find a balanced PD value that reduces error rapidly while avoiding overshoot.

My question now is: how do I find this balanced PD value, and what is a reasonable P-to-D ratio in general?

In the example shown by AMC, both the rate loop and the angle loop have P and D values significantly higher than the defaults. Under oscillation-free conditions, such PD values should clearly provide better response without overshoot. Yet in AMC’s example, the step response does not look ideal: although the response appears fast at only 60 ms, the steady-state error is only around 0.75. This part confuses me, and I don’t understand the reason behind it.

Also, if the weather is good, I plan to run an AUTOTUNE to see the results. But AUTOTUNE requires low wind. What wind speed is generally considered “low enough” for automatic tuning?

Additionally, during AUTOTUNE the drone drifts around, and I can only tune on a rooftop with limited space. That is why I have been trying to tune PID by analyzing flight log curves: partly due to environmental constraints, and partly because I want to better understand the actual principles of PID control.

I just want to chime in from “the peanut gallery” because, if it’s not already clear to you, you’re making great progress towards this goal. The topic is difficult, and learning any difficult thing feels overwhelming & frustrating while you’re doing it. If you’re feeling that: Something is going right!

I see your progress in insights like “From a PD perspective for a multicopter, P determines the aircraft’s rapid response, while D mainly acts as a damping brake.” Yes, correct!

Then you ask like “My question now is: how do I find this balanced PD value, and what is a reasonable P-to-D ratio in general?” This is a good question… Controls folks have been asking it for hundreds of years! Did you already try searching the internet for ‘how to tune a PID controller’? I’m guessing you did, and I’m guessing you found a slew of methods ranging in complexity from ‘by-feel’ to ‘follow this N-step process’ (e.g. Zieger-Nichols). I can’t tell if you already drew the key insight from this though… the reason the question has been re-asked for hundreds of years is because there’s not a single best answer. Yet also, some answers are (objectively) better than others, so it’s wrong to say there’s “no answer”.

A quick note on your question: I wonder if you chose the words “in general” quickly, without considering that they fundamentally alter the question in an important (and unconstrained) way.

My advice, which you’re welcome to ignore, is to distinguish between two things which are perhaps not (yet) distinct in your head:

  1. How can I use AMC and ArduPilot and similar to achieve excellent (“best”) performance from my system?
  2. Help me learn about PID and controls and control-tuning using AMC/ArduPilot as a motivating example?

Volunteers here are much more likely to help you with (1). Don’t forget to thank them frequently for that!

They may help you with (2), but also they may reasonably feel that’s your own responsibility. To the extent that you are pursuing (2), but phrasing your questions as though its (1), they might feel that you’re (perhaps unknowingly) taking advantage of their time.

@amilcarlucas is extremely talented and helpful. I have no idea if he agrees with my ponderings here… perhaps he rejects them! (My sincere apologies in advance if that’s the case!) I want to explicitly highlight that he’s given an incredible amount already—especially through building and maintaining AMC which is amazing—and for that IMO he deserves extreme thanks even if/when he stops responding to specific further questions.

You might wonder: Who is hunt0r? I’m a controls expert who has a passion for helping learners like you. I have so little skill compared to others here in (1)-type topics (how to use AP & AMC effectively) that I’d prefer to stay quiet in the thread. But if you’ve got more (2)-type questions, please feel free to start a fresh thread or DM me. I’m also on Discord, which is often easier for quicker back-and-forth.

Keep up your learning, you’re doing great, and don’t forget to express extreme thankfulness to the amazing folks who have built these tools you’re using.

2 Likes

Thank you so much for taking the time to write such thoughtful and detailed advice — I really appreciate it more than I can say.

I want to sincerely apologize if my previous messages came off as ungrateful or impolite. That was absolutely not my intention. I’ve been so focused on diving deep into the theoretical side of PID and control theory that I unintentionally neglected to clearly express how thankful I am for everyone’s help, especially for @amilcarlucas and the community for sharing their knowledge and maintaining such incredible tools like AMC.

You’re completely right that I need to better distinguish between asking for practical tuning guidance (using AMC/ArduPilot) and pursuing deeper control theory learning. Going forward, I’ll be more mindful of how I frame my questions and make sure to show proper gratitude for the time and expertise others generously offer.

Your encouragement means a lot, and I’ll keep studying and improving. Thank you again for your patience and for helping me grow both in knowledge and in how I engage with the community.

My oral and written English is not good, but I can read and understand English technical documents. Most of what I try to express relies on translation software. However, language should not be a barrier to learning.

I majored in Electronic Information Engineering in college, but I have not worked in this field after graduation. It has been nearly 20 years since I graduated. I feel ashamed that my theoretical foundation was not solid enough at that time, and I also failed to combine theory with practice in a timely manner.

I have been using ArduPilot for nearly 10 years. I have tuned fixed-wing aircraft, VTOL, and multirotors, and I can make them fly. But I still feel like I’m only at the hobbyist level, and there is still a long way to go to achieve stable and reliable flight. So I want to make a breakthrough and really tune the drones to a much better performance.

I am especially grateful to everyone in the ArduPilot community for your selfless sharing.

1 Like

Don’t stress too much about the step response. Its just a tool to try and help you understand the time domain plots. The grey “shadows” show how much variation there is throughout the flight, the blue is the average of the shadows. So if there is a large spread in shadows the blue average is not very reliable. In general to get more trustworthy step response results you want to crop down to a portion of the flight with large inputs in the axis your looking at.

The copter flys based on the time domain data, so it that is king.

1 Like

There is new Joshua Bardwell tool to better understand PIDs

I also found that Ardupilot pid review tool step response is looking different than for example pidtoolbox one, and often don’t allign with time series data, it’s just a question what to count as ‘average’, sure there is a room for improvement.

Thank you, Peter. Next time, I will simulate the step response by applying a stick input through a specific axis, and then compare the differences between the time-domain curve and the step response curve

Thanks Mike for the video. I’ve downloaded PIDtoolbox, but it seems this tool can only analyze Betaflight logs and does not support selecting BIN files.

Just run autotune, I can guarantee that playing manually with the PID step response will not get you better than that. These tools are great for figuring out problems when you have a decent autotuned tune, but I would not start with them and do not believe folks coming from betaflight who say you should - they are wrong.

4 Likes

@xingxing notice how the ArduPilot developers all tell you the same thing:

  • follow the ArduPilot existing, proven and established processes
  • ArduPilot is NOT betaflight
3 Likes

First of all, thank you @ammicarlucas. I’ve gone through the entire AMC tuning guide in detail—it’s very well written and references many excellent blogs and videos, which have been a huge help to me. Special thanks to @andyp1per for one of his videos that walks through the full tuning process using a 7-inch drone as an example. It shares a lot of practical experience that you won’t find in the official Wiki documentation.

The wind has been quite strong these days, blowing at 5 to 6m/s, so I should run an auto-tune as soon as possible. Right now, my drone keeps bouncing up and down noticeably in windy conditions. I plan to do wind velocity compensation and barometer compensation.

I have one more question:

Do the frontal and side projected area measurements of the drone need to be extremely precise? Will inaccurate area values heavily impact wind compensation performance? I’ve been calculating these areas by taking reference photos, but I can’t help feeling the results are not accurate enough.

You may want to know that Autotune and System Identification flight modes perform best without ANY wind.

It could be due to the barometer’s value varying during windy conditions. Consider covering up more of the FCU or the initial PIDs is not yet close to perfect.

1 Like