• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Pumpkin drop event

Snarls

Gravity Tester
Mentor
#1
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:
LOG00021Maiden_0_response.png

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.
 

ElectriSean

Eternal Student
Mentor
#2
I've never been good at tuning. Thankfully both of my 5" machines fly really well with BF defaults, but I've been struggling with my micro's. I will have to give this a try on the Sparrow, unfortunately my Eclair has no black box functionality.
 

Snarls

Gravity Tester
Mentor
#3
I am wondering if I could use this tool on logs from the KISS FC using an external loggeer. My KISS build has always been a headscratcher to tune so some data and analysis on my flights would be nice.
 

PsyBorg

Wake up! Time to fly!
Mentor
#4
I saw this video a while ago chasing Bardwell links looking into someones issues. I saw somewhere that it is / can / or will be working on KISS very soon. An sd logger is on my list of wants just for this purpose as it will be a great tool to have to test tunes or to prove my own insanity to myself of what I have learned and if my methods do work.
 

Snarls

Gravity Tester
Mentor
#5
Flew a couple more packs today and here are some of the results.

Following the last post, I made the following changes to P/I/D:
Roll: 65/45/30 --> 62/45/35
Pitch: 75/45/30 --> 80/55/40
Yaw: 65/45/0 --> 80/55/20

This tune felt slightly more locked in (could just be me getting used to it), with slightly more propwash oscillations. Bounce backs were still almost nonexistent.

Here are the results from the PID Analyzer:
LOG00001Tune1_0_response.png

Comparing it to the previous analysis from the maiden, the overshoot on roll and pitch looks to have decreased. Roll at this point looks pretty good and only needs fine adjustments. The blue pitch response has an interesting dip on the initial rise. Flo says this could be due to propwash/low frequency resonances. The orange pitch response looks good, with some small oscillation. Raising I gain helped bring the response to 1 in strength, but I still noticed some pitching when punching out, so at this point it may be worth increasing I even more. The yaw response looks better than before. The orange line is closer to the blue line, and there is less oscillation. They also reach a steady state value closer to 1. From what I've seen, the yaw response generally does not overshoot like pitch and yaw. So the current response is a good one to see. If anything, I will decease yaw P because it felt a little too stiff for me.

Based off these results, the next tune will involve the following:
Raise Roll P slightly, decrease pitch P to mediate prop wash and oscillation, increase pitch I to help with punch outs, lower yaw P slightly for better feel.
 

Snarls

Gravity Tester
Mentor
#7
For this third tune, I made the following changes to P/I/D:
Roll: 62/45/35 --> 65/45/35
Pitch: 80/55/40 --> 75/65/40
Yaw: 80/55/0 --> 75/55/0

This tune felt similar to the last, with a slightly looser yaw as I prefer. Bounce backs are still almost nonexistent and propwash is minimal, but noticeable if you are looking for it.

LOG00002Tune2_0_response.png

Accordingly, the response plots are similar to the previous ones.

Worth talking about at this point are the middle response time vs. throttle % plots. These plots show how the response times change with throttle %. The response plots at the bottom are more like averages, whereas the middle plots show how the response differs throughout the throttle range. What we can see is that for this flight, the response with respect to throttle % is pretty consistent over the throttle range used. This is a good thing and indicates uniform performance throughout the throttle range. It can also be an indicator that TPA is doing it's job well. To support this, I did not notice any high throttle oscillations during my flight. If the plots showed more yellow at higher throttle percentages, I would be inclined to increase my TPA or change its setpoint.

The tune is feeling really good except for a few detailed, but significant things. First, there is still some pitching during punch outs. Increasing the I gain on pitch didn't seem to improve this behavior from last time, so it is probably worth looking at antigravity gain at this point. The second thing is propwash. So far this setup has the least propwash I have ever dealt with, and I am wondering if I can eliminate it entirely. To do this, it is time to start looking at an analysis of the noise in the system.

LOG00002Tune2_0_noise.png

These noise plots are interesting, and can probably be used for a lot more than what I am about to suggest.

With this tune, I am using the gyro lpf at 90 hz, the d-term lpf at 100 hz, and the d-term notch filter at 260 hz with cutoff at 160 hz. Overall, the high frequency noise in my system is pretty low compared to others I have seen. One thing that has been discussed on the Plasmatree RCGroups thread, is the necessity of d-term filters. Any filtration added to the system adds latency, which can effect the feel of the quad, and contribute to propwash. Flo (Plasmatree) suggests that d-term filters are not necessary, and that two PT1 filters on the gyros at 100 hz can do the job, with less latency. Removing the d-term filters is a bit risky, but I was curious about this idea.

One thing I notice from my noise plots is that there is little noise at 260 hz where my d-term notch filter is. So it may be that my d-term notch is not really doing anything to improve the gyro signal. So even though the d-term notch is said to be the riskiest to remove, I decided it would be worth trying a tune without it, assuming it is not doing anything right now. Since I am flying a 6" build, I am wondering how much different the frequencies I am experiencing are compared to what Betaflight defaults have been developed for.

For this next tune I am keeping the PIDs the same, and I am removing the d-term notch, d-term lpf, and adding two PT1 (lpf) filters on the gyro at 100 hz as suggested by Flo. I also have the dynamic notch enabled. This should give less latency/phase shift on the d-term than before, ideally resulting in better control and less propwash. I will have to keep an eye on the motor temps of course since I am dealing with no filters on the d-term.
 

Snarls

Gravity Tester
Mentor
#8
If your only I problem is on punch outs, you may want to tune anti-gravity rather than messing with I directly.
Yes that is the conclusion I have just reached ha! I learned from my KISS build that drops on punch outs can not always be solved by increasing I alone. Unfortunately, KISS does not have antigravity, but I will have to read about the parameter in betaflight and see how much I should increase it.
 

Snarls

Gravity Tester
Mentor
#9
For the next tune I made some changes to the filters in Betaflight. Inspired by Flo (Plasmatree), I decided to remove all filtering for the D-term entirely. On the gyro I am using two PT1 low pass filters at 100 hz, and the dynamic notch filter as well.

The results were interesting. It could all be a placebo effect, but I felt like the quad flew a bit more locked in, and propwash was even less noticeable. I had to check the motors to make sure they not getting too hot from D term related oscillations, and they were warmer but not hot.

LOG00007Tune3_0_response.png

From the looks of the step response, it looks like the roll and pitch responses got slightly worse after changing the filters. This would go against the more 'locked in' feeling I was having, but again that may have been a placebo. Flo expects that changing the filters this way would require the PIDs to be modified; with P and D being able to be increased. Overall the tune is pretty great so far, and I just have to focus on propwash oscillations and milking out as much of a 'locked in' feeling as possible.

LOG00007Tune3_0_noise.png

Looking at the noise plots, it looks as if D-term noise has increased across every frequency, over all throttle values (note different scale than past noise plots). This is the result of no D-term filtering and may be concerning, but my motors are still coming down with only a little warmth. Looking at the gyro noise plots (right side), there appears to be significantly less transmission in the larger frequencies. All the unwanted noise peaks are being attenuated smoothly by the two PT1 filters.

To improve this tune further, I am going to try increasing P and D. I'll see how high I can go before either the P or D term starts giving negative effects.
 

Snarls

Gravity Tester
Mentor
#10
I did some testing with a KISS blackbox log I found online. If the log is a .txt it will run through the analyzer just fine. Of course some information won't quite work such as the debug noise plots and filters.
 

LitterBug

Troll Spammer
#11
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.
There are also those of us who fly dRonin, run an autotune, and get a locked in tune without all the hassle. It does a little dance in the air for 60 seconds, collects data, and then the next time you plug it in to GCS, it completes the analysis of time it takes for FC to send command till the time it sees the response on the gyro, adjusts PIDs, LQG weights, Althold %, etc. All you really have to do is set your preferred rates and expo. You can also do manual adjustments too, although if you are flying LQG mode, there are no PIDs to adjust.

Sample analysis output from a recent tune of my Tiny Whoop.

Screenshot from 2018-05-27 14-25-29.png
Screenshot from 2018-05-27 14-25-33.png
Screenshot from 2018-05-27 14-25-35.png

Link to online shared tune results: https://dronin.org/tunes#?key=ahFzfmRyb25pbi1hdXRvdG93bnIYCxILVHVuZVJlc3VsdHMYgICAuJ6J1wkM

Cheers!
LitterBug
 
Last edited:

Snarls

Gravity Tester
Mentor
#12
It seems that at present, there are two three types of pilots; ones who fly stock betaflight and are happy with it, ones who tune to the edge, and Litterbug who likes to make a computer tune for him.