If you've been around here a while you might know that I have a love/hate relationship with PID tuning. I spend way more packs tuning than the average pilot these days, but I enjoy getting the most performance out of my builds. It seems that at present, there are two types of pilots; ones who fly stock betaflight and are happy with it, and ones who tune to the edge. Now there is a new tool that can help us tuners out. It is called the Plasmatree PID Analyzer and was created by a user named Flo. I found as discussion about it on the multicopter Reddit and thought I should try it out.
The PID Analyzer takes any betaflight blackbox log and runs an analysis for you. Currently it requires downloading the program and running a simple command line ,so it is not as simple to use as Blackbox Analyzer, but it provides a lot of information very quickly. Running the program will produce multiple plots. I'm not going to cover all of them, but the most important one is the step response. In controller design, step responses are widely used to exemplify how the system will react to an input. If we look at the roll, pitch, and yaw step responses, we can gauge how well tuned out system.
Before continuing to my own results using the PID Analyzer, you can learn more about the program, how it works, and how to interpret it with these resources:
Plasmatree PID Analyzer GitHub: https://github.com/Plasmatree/PID-Analyzer
RCGroups Thread: https://www.rcgroups.com/forums/showthread.php?2953533-Betaflight-PID-Analyzer
Great overview video by UAV Tech:
My Own Results:
This afternoon I maidened my 6" Rooster build. I used PIDs from the previous 6" Martian frame I was using so the new build flew pretty well, and I was able to jump into some freestyle tricks. Here are a couple observations I made: propwash is pretty minimal, there are very slight bounce backs on hard rolls, pitch is drifting on punch outs, and generally the quad is not flying as tight/locked as I want it to. Overall flies great, but could be better.
Here are the results from running the PID Analyzer:
The top plots show how my input lines up with the copter's output as measured by the gyro. Overall the inputs match the outputs well, with some overshooting on the hard roll and pitch inputs. Middle plots show latency in the system, where hotter colors (like yellow) indicate more delay in the system compared to cooler (turquoise) color. The bottom plots, the step responses, are the most interesting. Ideally, we want to see a fast rise time (time to get to 1.00 in strength), minimal overshoot, and a quick settling time without oscillations to a final value of 1.
By these standards, the bottom left step response for roll is pretty ideal. Rise time is good, there are minimal oscillations, and the response settles down quickly with almost no steady state error. The one thing that could be improved is the overshoot when the roll rate is greater than 500 deg/s (orange line). This is indicative of the slight bounce back I was seeing on fast rolls. To improve this, I will try lowering roll P by a small amount and/or increasing roll D. Roll I seems to be tuned well as there is no steady state error.
The pitch step response is slightly worse than that for roll. When the pitch rate is less than 500 deg/s, the rise time is greater than that for roll, and there is some steady state error in the system, which supports the drift in pitch I observed when doing punch outs. The response when the pitch rate is greater than 500 deg/s has a faster rise time, but greater overshoot and a longer settling time with slight oscillations compared to roll. To improve pitch, I will try increasing P slightly to improve the rise time, while also increasing D to remove the slight oscillations and bring down overshoot. I will also increase the I gain to remove steady state error on the lower rate pitch movements.
The yaw step response is the worst out of the three. There appears to be a decently overdamped response here. The rise time is quite large and there is plenty of steady state error is indicated by the response never reaching a strength of 1. By definition there is no overshoot. There are also oscillations when the yaw rate is greater than 500 deg/s. I think this yaw response is why I felt like the quad was not quite tracking where I wanted, and struggling in some of the turns. To improve the yaw performance, I will try increasing P to improve rise time. For some reason I also had a D gain of 20, so I will also reset that back to 0 to reduce the damping on the response. I will also increase the I gain to remove the steady state error.
So to summarize, from the step response plots I am motivated to make the following adjustments:
Roll: Lower P slightly, Leave I, Increase D slightly
Pitch: Increase P slightly, Increase I, Increase D
Yaw: Increase P, Reduce D to 0, Increase I
I will make these adjustments, fly another battery, and come back with an analysis of the updated flight.
The PID Analyzer also provides frequency plots for noise/filter tuning. I will cover these plots in a future post.
The PID Analyzer takes any betaflight blackbox log and runs an analysis for you. Currently it requires downloading the program and running a simple command line ,so it is not as simple to use as Blackbox Analyzer, but it provides a lot of information very quickly. Running the program will produce multiple plots. I'm not going to cover all of them, but the most important one is the step response. In controller design, step responses are widely used to exemplify how the system will react to an input. If we look at the roll, pitch, and yaw step responses, we can gauge how well tuned out system.
Before continuing to my own results using the PID Analyzer, you can learn more about the program, how it works, and how to interpret it with these resources:
Plasmatree PID Analyzer GitHub: https://github.com/Plasmatree/PID-Analyzer
RCGroups Thread: https://www.rcgroups.com/forums/showthread.php?2953533-Betaflight-PID-Analyzer
Great overview video by UAV Tech:
My Own Results:
This afternoon I maidened my 6" Rooster build. I used PIDs from the previous 6" Martian frame I was using so the new build flew pretty well, and I was able to jump into some freestyle tricks. Here are a couple observations I made: propwash is pretty minimal, there are very slight bounce backs on hard rolls, pitch is drifting on punch outs, and generally the quad is not flying as tight/locked as I want it to. Overall flies great, but could be better.
Here are the results from running the PID Analyzer:
The top plots show how my input lines up with the copter's output as measured by the gyro. Overall the inputs match the outputs well, with some overshooting on the hard roll and pitch inputs. Middle plots show latency in the system, where hotter colors (like yellow) indicate more delay in the system compared to cooler (turquoise) color. The bottom plots, the step responses, are the most interesting. Ideally, we want to see a fast rise time (time to get to 1.00 in strength), minimal overshoot, and a quick settling time without oscillations to a final value of 1.
By these standards, the bottom left step response for roll is pretty ideal. Rise time is good, there are minimal oscillations, and the response settles down quickly with almost no steady state error. The one thing that could be improved is the overshoot when the roll rate is greater than 500 deg/s (orange line). This is indicative of the slight bounce back I was seeing on fast rolls. To improve this, I will try lowering roll P by a small amount and/or increasing roll D. Roll I seems to be tuned well as there is no steady state error.
The pitch step response is slightly worse than that for roll. When the pitch rate is less than 500 deg/s, the rise time is greater than that for roll, and there is some steady state error in the system, which supports the drift in pitch I observed when doing punch outs. The response when the pitch rate is greater than 500 deg/s has a faster rise time, but greater overshoot and a longer settling time with slight oscillations compared to roll. To improve pitch, I will try increasing P slightly to improve the rise time, while also increasing D to remove the slight oscillations and bring down overshoot. I will also increase the I gain to remove steady state error on the lower rate pitch movements.
The yaw step response is the worst out of the three. There appears to be a decently overdamped response here. The rise time is quite large and there is plenty of steady state error is indicated by the response never reaching a strength of 1. By definition there is no overshoot. There are also oscillations when the yaw rate is greater than 500 deg/s. I think this yaw response is why I felt like the quad was not quite tracking where I wanted, and struggling in some of the turns. To improve the yaw performance, I will try increasing P to improve rise time. For some reason I also had a D gain of 20, so I will also reset that back to 0 to reduce the damping on the response. I will also increase the I gain to remove the steady state error.
So to summarize, from the step response plots I am motivated to make the following adjustments:
Roll: Lower P slightly, Leave I, Increase D slightly
Pitch: Increase P slightly, Increase I, Increase D
Yaw: Increase P, Reduce D to 0, Increase I
I will make these adjustments, fly another battery, and come back with an analysis of the updated flight.
The PID Analyzer also provides frequency plots for noise/filter tuning. I will cover these plots in a future post.