Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Betaflight PID and filter tuning notes
#1
I'm going to share things I'm learning about Betaflight PID and filter tuning in this thread.

Resources I've studied a bit so far are Chris Rosser's PID and filter tuning videos, Oscar's PID and filter tuning articles, and RONIN’S QUAD BLACKBOX TUNING GUIDE.

I was just working through Ronin's tuning guide, and one of the first things I noticed is that some of the BF parameter names have changed between 4.2, which is used in the Ronin guide, and 4.3, which is what I have on the Volador30 quad I'm working on (Cinebot30 guts on a Volador 3" freestyle frame). I did a web search on some of these changes, and started reading this: Betaflight 4.3 Tuning Notes | Betaflight.

In reading the BF 4.3 tuning notes, I saw this:

Quote:250hz or 500hz radio link users MUST choose a suitable Preset. 500hz radio links must have feedforward_smoothing set to 65-70 with 2 point averaging. 250hz radio links need feedforward_smoothing set to 35-40 with 2 point averaging.

And this:

Quote:We now have second order smoothing on boost, soft interpolation during slow stick moves, and more accurate duplicate packet interpolation. Most slower radio links won't need averaging, which is now off by default. High speed radio links (250hz and higher) will typically benefit from 2 point averaging and stronger smoothing. Presets to suit most common link types make Radio link configuration easy.

I had previously loaded the ExpressLRS 250Hz preset (my radio packet rate is set to 250Hz), but in following the Ronin tuning guide, I had changed some of the values set in the preset. After reading the 4.3 tuning notes, I re-loaded the preset.

The learning is that one must be careful in following PID/filter tuning instructions based on earlier Betaflight versions.

So, what I'm going to do at this point is go back to Oscars article, Betaflight FPV Drone Tuning In 10 Simple Steps - Oscar Liang, which is an approach that doesn't use any blackbox logging, and uses bf 4.3.1, which is what I have on this quad. Once I work through that, I'll get back to Oscar's articles on blackbox tuning and CR's blackbox tuning videos. One issue I have with the videos is that he goes through some points too quickly for me to understand exactly what he's doing.

I'm focusing on the Volador30 for learning about tuning, because on the AOS35 (Chris Rosser's AOS EVO 3.5 inch frame with parts mostly recommended by InfoFPV forum members) I'm using Chris's AOS 3.5 tune for now, and it seems to be working well.

I flew a couple of packs on each quad yesterday, after replacing a fried motor on the AOS35, and they both flew quite nicely. I checked motors after every flight, and they were cool to the touch every time. I did some blackbox logging on the V30, but I had the sampling rate set to 1kHz, while 2 kHz is recommended.

What I learned about sampling rate is that it needs to be set to twice the highest frequency you want to convert from analog to digital. Here is a ChatGPT explanation:


Quote:One crucial aspect of the sampling rate is its relationship with the Nyquist frequency. The Nyquist frequency is half of the sampling rate. To avoid aliasing, which is distortion that occurs when the sampling rate is insufficient to capture high-frequency components of the signal accurately, the sampling rate must be at least twice the highest frequency component of the analog signal (Nyquist rate). If the sampling rate is too low, high-frequency components may be misrepresented in the digital signal, leading to aliasing.[/font][/size][/color]

This cleared up some confusion I had while first watching a Chris Rosser video on tuning, in which he showed blackbox explorer analyzer chart showing a max frequency of 1,000 Hz, but I was seeing a much lower max frequency for mine. I later figured out that it was because I had used a lower sampling rate, based on something I had read somewhere else.

Yesterday I had my sampling rate set to 1 kHz somehow, so I only see a max of 500 Hz in the logs from yesterday. I've now set it to 2 kHz, so next time I log I'll be able to see up to 1 kHz on the chart.
[-] The following 2 users Like aerokam's post:
  • ph2t, Lemonyleprosy
Reply
Login to remove this ad | Register Here
#2
WOW, talk about going down a rabbit hole.. let me say this .. BE CAREFUL..meaning having a quad perfectly “tuned” isn’t what you want. Yes, CR will get you there.. and the quad will fly AMAZING… but as soon as u bend / damage a prop.. something will give (electronically)…
I’ve read / seen where the BF PID tune is just fine and speaking from experience.. able to fly back with damaged / broken props.. unless you have major propwash or handling issues.. BF PIDs have never caused any issues with my quads..
But bay, your braver than me…. And n turn I had seen significant improvement when I loaded the “cinematic” preset in 4.3 from the standard ..
Go for it…keep us posted.. I’m more than happy to learn..
Reply
#3
I too have been down the rabbit hole of tuning in the past few months. Still a novice to tuning though. Although I definitely have my quads flying a bit better than stock BF, which is good.

Chris Rosser's info has been good. I have generally (loosely) followed most of his advice for ESC setup, dynamic idle, filters, and finding an appropriate D term. The other major resource for me that has made it all feel much more real world and practical (and less academic) has been UAV Tech. His YouTubes are a starter, but for $5 you can access his Patreon, which has been excellent for going deeper. Well worth it, at least for a month or two to get into it more. I don't do Patreon subscriptions much at all, but UAV Tech has been a no brainer, excellent resource and I have no regrets. He has the skill and experience and gets right into it in an authoritative way that is practical and immediately applicable. He gets into his presets in depth, and why they are the way they are, and does sophisticated analysis against other presets. Chris Rosser, by contrast, feels like a university lecture, or he is covering an engineering publication for other academics (which I love too, but it's different). I need to get out and fly more and spend less time in my head, so UAV Tech wins the day.
[-] The following 2 users Like EyeBotXander's post:
  • aerokam, Lemonyleprosy
Reply
#4
Quote:I need to get out and fly more and spend less time in my head

This is where the simple tuning menu on the OSD is great for this.   Took a while to learn the basic PID relationships on the menu items but I find it very handy to not even disconnect a pack.  You can fly, land, alter, fly, land, alter, etc...  Works a treat!
[-] The following 3 users Like ph2t's post:
  • EyeBotXander, aerokam, Lemonyleprosy
Reply
#5
(02-Aug-2023, 11:33 PM)EyeBotXander Wrote: The other major resource for me that has made it all feel much more real world and practical (and less academic) has been UAV Tech. His YouTubes are a starter, but for $5 you can access his Patreon, which has been excellent for going deeper. Well worth it, at least for a month or two to get into

I'll check it out. Thanks for the tip.
[-] The following 1 user Likes aerokam's post:
  • EyeBotXander
Reply
#6
(03-Aug-2023, 05:13 AM)ph2t Wrote: This is where the simple tuning menu on the OSD is great for this.   Took a while to learn the basic PID relationships on the menu items but I find it very handy to not even disconnect a pack.  You can fly, land, alter, fly, land, alter, etc...  Works a treat!

Agreed. I found out how to activate the PID tuning in OSD from a CR video, but I only tried actually using it for the first time yesterday. 

I increased my master multiplier until I heard the twitching upon arming that Chris mentions; the sound was very apparent. I backed off one notch, and the twitching went away.

I had accidentally increased my D gains multiplier first, until I heard the twitching, but then I realized my mistake, and found the master multiplier control, reset the D gain multiplier to 1.0, and adjusted the MM.

It was very easy to accidentally change something while getting used to the interface. When I connected to BF this morning, it was using different Profile and Rate Profile values than I had last set in BF--I'm just using 1 for both, so apparently I had changed those accidentally in the OSD interface.

Hopefully I'll get set up for some additional tweaking and logging later this morning.
Reply
#7
(01-Aug-2023, 03:55 PM)Rob Axel Wrote: WOW, talk about going down a rabbit hole..

One nice thing about our hobby is that there are so many dimensions to it. Just flying is a blast, but I'm an engineer by training (BSEE), and just generally interested in technical topics, so learning about tuning scratches that itch.

I will say that I'm loving the way my quads are flying, using the CR AOS 3.5 preset for the AOS35, and a pretty basic PID/Filter setup for the Volador30. As I recall, the latter is based on CR recommended defaults, but I think it's also consistent with what Oscar recommends in his articles.

Here's what I have right now for the Volador30:

Loaded the Express LRS 250 Hz preset (for both quads).

Filters:
  • No gyro LP or notch filters.
  • Gyro RPM filter with 3 harmonics and 100 Hz min freq.
  • Dynamic notch filter with notch count 1, Q factor 250, Min freq 70 Hz, Max freq 350 Hz.
  • Dterm LPF, dynamic, BIQUAD, with min cutoff 75, max cutoff 150, dynamic curve expo 5.
  • No Dterm notch filter.
  • No Yaw LPF. I did have this on with 100 Hz cutoff, but at some point I turned it off. Yaw generally is not very noisy, so the yaw filtering doesn't seem to matter much. I'll probably turn this back on at some point, since apparently it doesn't "cost" much.
PID:
  • Betaflight defaults.
  • Mode: RPY (haven't studied this yet).
  • All multipliers set to 1, except for master which is set to 1.1 after yesterday's OSD tuning tweaks.
  • All the settings on the right side of the PID tuning tab are unchanged. I think the ELRS preset sets some of these.
I think one of my next steps will be to set the multipliers for some of the gains to 0, as I think that's the recommendation to do one of the next tuning steps.

The reason I started by increasing the master multiplier is that CR says that the P/D balance (and other balances) are quite good with BF defaults, so it's easier to find the ideal P/D balance later by starting with the defaults, rather than starting by tweaking the D gains.
Reply
#8
… your gonna pass a blonde girl named Alice at one point…tell her I said “Hey”..
WAY to much for me to even think about..It’s hard enough to find time to fly .. “tuning” is out of the equation..
Reply
#9
(04-Aug-2023, 03:59 PM)Rob Axel Wrote: … your gonna pass a blonde girl named Alice at one point…tell her I said “Hey”..
 WAY to much for me to even think about..It’s hard enough to find time to fly .. “tuning” is out of the equation..

I know her well. When I see her again, I'll pass on your regards, but I'm afraid she might not invite you to tea.

I found a beautiful time to fly a couple of days ago. About 6:30 am at the local highschool, with nothing but geese and a bunch of soccer goals on the field. It's not much more than a stone's throw from my house, but to walk the "official" way would take about 30 minutes. The day before that I'd discovered a couple of holes in the fence between a walkway basically across the street from my house and the high school field. I got to walk there almost as the crow flies, and the flying was glorious. The geese pretty much just ignored the bird buzzing over them.

Only flew 3 packs on the Volador30, with the little bit of tuning I think I mentioned, but I had to get on with the day.

Today I decided to upgrade firmware from 4.3 to 4.4, and I'm still working my way through that rabbit hole, enjoying it thoroughly. Going through the CLI dump comparing post-upgrade to pre-upgrade, and trying to make sure I understand what each difference is doing differently in BF. I could brute force my way through reconfiguring everything manually, but it's fun to run the CLI commands to do it instead.

Was too busy with all of that (and the grandkids who learned to swim in the deep end of the pool today) to actually fly today (well actually yesterday).
[-] The following 2 users Like aerokam's post:
  • EyeBotXander, Lemonyleprosy
Reply
#10
I know her well. When I see her again, I'll pass on your regards, but I'm afraid she might not invite you to tea.

Yeah, she is still upset with me, took it personal when I had to pass on the first tea party invite.. she got a little mad when I asked for a cup of coffee…even more when she asked me “cream and sugar”? .. I replied, “no THANKYOU.. I like my coffee like I like my women..hot, strong, and bitter…”. I don’t expect a RSVP from her anytime soon..

Was too busy with all of that (and the grandkids who learned to swim in the deep end of the pool today) to actually fly today (well actually yesterday).
[/quote]
Keeping focus on life’s important things.. good call!
[-] The following 1 user Likes Rob Axel's post:
  • Pathfinder075
Reply
#11
Upgraded firmware to 4.4, and got everything it messed up straightened out. Used some of the CLI from the post-update dump to reset things, and did some of it manually in BF. Took me awhile to remember how to set the ports to get the OSD working.

Then I realized that a lot of the tuning videos were using 4.3 or earlier, so searched for something using 4.4. I'm now following along with this one, which uses 4.4 and goes through it slowly enough that I can follow:




However, to find P/D balance in this one, he fixes the P&I gains and adjusts the D gains with each test flight, while one I found earlier and followed for this part fixed D and adjusted P&I with each test flight. So my blackbox logs have P&I gains of 0.8, 0.9, 1.0, 1.1, and 1.2., with D gains fixed at 1.

The common recommendation is to set FF, D Max and I Gain sliders all to 0 for the P/D balance test flights, so I did that. I did these test flights in angle mode, and just cranked the pitch and roll quickly all around the stick limits, which is a common approach.

I've viewed the logs in the PID toolbox step response tool, following the linked video's instructions. I also reviewed the PIDtoolbox user guide, which was helpful. The conclusion was that the best response was for a P/D balance of 1.0, so both D Gains and P&I Gains sliders set to 1.0, which is the default. So, as Chris Rosser said in one of his videos, the P/D balance is quite good with the BF 4.4 defaults.

Another thing the Rotor Riot guy mentions is that he uses a filter preset, and doesn't mess around much with the filters other than that. I reviewed available presets, and loaded one for a very clean build with rpm filtering, and the settings were not too much different than those in the AOS 3.5 tune presets. One difference I notice is that the preset uses a PT1 D term LPF, while CR recommends BIQUAD. I switched it to BIQUAD.

Like CR's tune, the preset sets gyro LPF 2 to 1,000 Hz cutoff, PT1. Chris replied to my question about this with this comment:

Quote:The 1000Hz Gyro LPF is to cover the case where an FC is running 8K/4K and is not needed in any other situation. It's better to have it as it adds no significant delay and if you run 8K/4K without any gyro 2 LPF the FC secretly applies a harsh filter in the background which does add delay!

The default setting for the GEPRC F722 AIO-55, from the Cinebot30, is 8.00 kHz, and that's what I'm using, so according to CR, using one gyro LPF with a 1 kHz cutoff is the way to go.

Right now I'm going to set the PID tuning back to normal for flying, and go fly. Later I'll continue with the next tuning steps.
[-] The following 2 users Like aerokam's post:
  • Lemonyleprosy, EyeBotXander
Reply
#12
Got out to the field, and my AOS35 would not arm. Hmm. So, switched to the Volador30, the one I'm tuning, and it took off OK, but almost immediately started giving me a low battery warning (1100 mAh LiHV pack). I was sure I'd charged all of my batteries.

Same thing with one or two more HV packs. Switched to my 650 mAh LiPO and got some flight time out of it, and ditto for one of my fat-ass 1100 mAh CNHL packs. By then it was getting hot, and I was getting hungry, so headed on home for breakfast.

Looked at a few things in BF, and quickly found that somehow the rx UART on the AOS had gotten turned off, so turned that back on and verified tx/rx communication.

RE: the low battery issue on the Volador, BF was showing the correct voltage in the Power & Battery tab with the proper scaling (111 in my case), so 26.0 V, but when I looked at it in the goggles, it showed average voltage 3.7 V, which would be 22.2 V. So I set my OSD to show pack voltage, and low and behold, it showed 26.0 V for the pack, but still 3.7 V average cell voltage.

Then I remembered that I had noticed it had indicated 7 cells in the P&B tab in BF, which makes sense, since 26/7 = 3.7. Hmm.

So connected to BF again, and now it's showing 6 cells. Connect to goggles again, and now showing the proper average cell voltage.

I'm puzzled, because I don't think I changed anything. Any ideas?
Reply
#13
If you’re running HV lipos, you need to set the maximum cell voltage to 4.35 [edit- set it to 4.4v] in the power & battery tab in BF. Otherwise it can get the cell count wrong and think you have a higher cell count battery with low voltage. Smile

Edit- it tends to only happen with a fully charged HV lipo, so if you don’t change the max cell voltage and let it sit and drain a wee bit and then unplug and replug, it’ll take it back down below the max cell voltage and show the correct cell count.

Edit edit- if it still continues to happen after you’ve increased the max cell voltage, double check that you’ve calibrated your voltage sensor in BF, and make sure that you’ve calibrated your charger and that it isn’t overcharging your lipos.

And another edit- you might actually want to set the max cell voltage to 4.4v for HV. It’s supposed to be a wee bit higher than the max fully charged cell voltage.
Dangerous operations.

Disclaimer: I don’t know wtf I’m talking about.
I wish I could get the smell of burnt electronics out of my nose.
Reply
#14
Is this the fc u “updated” to 4.4? If so.. this is a reason I REARLY update ..you end up starting from “scratch”.. some people will do a “diff all” in the cli.. then paste it after updating..not all things transfer proper … and the devs change stuff.. or the fc target was set up wrong by the devs .. there is a lot of targets…or, something got mis-typed in the cli…
In just spitballing.. either way.. you discovered and corrected it..
You may want to do a “dump” on that fc and save it..
Reply
#15
To expand on my post above, since I know you like to know the how/why:

Our boards aren’t capable of reading individual battery cells. We only connect to our batteries via the main positive and negative lead (xt60, xt30, etc.)

In order to read the voltage of individual cells, we would have to connect via the balance lead, with each cell going to its own voltage sensor.

We don’t, and our boards aren’t capable of that. So instead, we get the whole pack voltage. Betaflight then does some maths based on your max cell voltage and determines what cell count battery it thinks you have.

As you’ve found out, with fully charged HV batteries, it’s going to read a level that it will assume must be a higher cell count battery but with low voltage, unless you change the max cell voltage.

6s lipo fully charged: 25.2v
6s HV lipo fully charged: 26.1v
BF with max cell voltage set to 4.3v, max 6s voltage: 25.8v

So when betaflight reads 26.1v, it assumes you must be running a 7s battery, and after it does its math, it thinks you only have an average cell voltage of 3.72.

During your plugged in time in the field or while you were trying to figure things out, you managed to drain the HV lipo down to 25.8v or less, so on next plugin it correctly identified it as a 6s.

In case you missed my last edit of my previous post, try setting your max cell voltage to 4.4v.
Dangerous operations.

Disclaimer: I don’t know wtf I’m talking about.
I wish I could get the smell of burnt electronics out of my nose.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Wont connect to betaflight FPVrambling 3 177 21-Jun-2024, 10:55 PM
Last Post: FPVrambling
  [SOLVED] betaflight 4.4 rx configuration for frsky r-xsr sim_tcr 7 3,013 18-May-2024, 07:25 PM
Last Post: SnowLeopardFPV
  Announcement Betaflight 4.5.0 *** FINAL RELEASE *** Now Available SnowLeopardFPV 4 1,253 08-May-2024, 02:19 PM
Last Post: SnowLeopardFPV
Exclamation Betaflight Configurator - HELP iFly4rotors 11 870 05-May-2024, 08:09 PM
Last Post: Eyes.fpv
  Announcement Betaflight 4.5.0 Release Candidate 4 Now Available SnowLeopardFPV 8 3,021 15-Apr-2024, 06:50 PM
Last Post: SnowLeopardFPV


Login to remove this ad | Register Here