On this tutorial I’ll share how I take advantage of Blackbox logs to tune filters and PID on a Betaflight FPV Drone. I will likely be utilizing PIDToolBox as the first software for filter and PID tuning, with Blackbox Explorer because the secondary software for Feedforward and normal troubleshooting.
Disclaimer: This information is supposed for informational functions solely. The creator holds no duty for damages ensuing from actions taken by the readers.
Blackbox is just not a should on the subject of tuning as defined on this information, however Blackbox offers you the total perception into what’s actually occurring with the drone and lets you unleash its full potential. Issues like noise filtering and tiny overshoots you’ll be able to solely see in Blackbox. In case you are a perfectionist or simply somebody who prefer to tinker, that is going to be the tutorial for you.
In case you are new to Blackbox, ensure to take a look at the Blackbox for newbies tutorial.
Getting Began
Tuning targets
Utilizing Blackbox to tune our FPV drone, we need to obtain two foremost targets:
- Simpler use of filters: use as little filtering as attainable to reduce delay, however simply sufficient to maintain the noise all the way down to an appropriate degree
- Optimized PID good points and associated settings to get our drone to fly extra exactly and responsively
Primary configurations
0. {Hardware} Guidelines
- Select an FC stack that comes with rubber grommets (aka gummies), gentle mounting is nice for each sturdiness and noise efficiency (vibration dampening).
- Use metallic screws for the FC stack, keep away from nylon/plastic screws/standoffs/spacers as they’re straightforward to interrupt and extra prone to create vibrations. Should you want spacers, use the gentle silicone ones. Utilizing lighter titanium screws can save just a few grams (see submit).
- Locking the stack screws firmly in place with a metallic nut earlier than mounting the 4in1 ESC. In case your body have pressed insert nuts then there’s no want so as to add one other nut. This may stop the stack screws from wiggling and creating vibrations. Tighten them by hand first, then give a ultimate squeeze with the wrench/screwdriver.
To safe the entire FC stack, you need to use 4 plastic nuts. Tighten the nuts by hand, in order that the gummies usually are not excessively crushed, this permits the soft-mount to work successfully.
1. Blackbox Recording Settings
Choose the next settings within the BlackBox tab:
- Onboard Flash or SD Card
- Since we’re tuning filters we need to log at 2KHz (or 1.6KH for BMI270 Gyro)
- Choose “GYRO_SCALED” in debug mode to file unfiltered gyro sign
2. Disable ADC filter in your OpenTX/EdgeTX radio (System->{Hardware}). This may cut back latency.
3. ESC settings:
I’ve a submit explaining the greatest BLHeli32 settings. Right here’s the abstract (for five″ drones):
For BLHeli_32 ESC:
- Rampup Energy 30%
- Motor timing 24
- PWM Frequency: Setting LOW and HIGH to fastened 24KHz or 48KHz. 48KHz is mostly the most secure choice on the subject of gyro noise, it makes your quad smoother and simpler to tune. Nevertheless, 24Khz presents higher braking energy which is best for prop wash dealing with and resposniveness, however there’s a better danger of vibration.
For BLHeli_S ESC, flashing Bluejay is a should, as a result of it permits bi-directional DShot, which is required for numerous options in Betaflight resembling RPM filter and Dynamic Idle. I’ve a information on methods to flash it right here: https://oscarliang.com/bluejay-blheli-s/
3. Flash the newest model of Betaflight firmware to your flight controller and go away PID/filter settings at default. Allow Skilled Mode in Betaflight Configurator, this provides you with all of the obtainable sliders and choices on the PID Tuning web page.
Within the Configuration tab, set your PID Loop Frequency, and within the Motor tab, set your ESC protocol:
- DShot300 for 4KHz or 3.2KHz Loop Frequency
- DShot600 for 8KHz Loop Frequency
4. Within the Motors tab, allow Bi-directional DShot.
Nearly all fashionable ESC assist Bi-directional DShot. I’ve a tutorial on methods to allow RPM filter. For BLHeli_32 ESC it really works out of the field, however you probably have BLHeli_S ESC, that you must flash Bluejay firmware (tutorial) first.
To examine if Bi-directional DShot is working correctly, run the motors within the Motors tab (with out propellers!) and see if the error charge (E) stays at 0% . If this isn’t the case, attempt once more with a slower DShot protocol resembling DShot300 and even DShot150. If none of those protocols provide you with 0% error, then you definately would possibly simply should disable Bi-directional DShot.
After getting Bi-directional DShot enabled, you’ll be able to then allow RPM filter, that is most likely the perfect filter in Betaflight.
5. Load the suitable RC_Link preset.
Completely different RC hyperlinks require particular RC smoothing and feedforward configurations because of the totally different packet charge and packet interval with a view to keep away from issues with Feedforward. My favorite RC hyperlink in the intervening time is ExpressLRS, try what radio gear I take advantage of right here.
By loading the acceptable RC_Link preset, Betaflight will apply all the mandatory config for you routinely. Don’t neglect there are just a few extra choices to choose earlier than loading the preset, particularly flying fashion, for most individuals it could be Freestyle.
In case you are utilizing Crossfire, it’s greatest to lock the packet charge to both 50Hz (longer vary however increased latency) or 150Hz (decrease latency however much less vary). You are able to do this within the TBS Agent Lite LUA script.
6. Decrease TPA
Within the PID tuning tab => Charge Profile, set TPA break level to 1750, that is the throttle place when TPA begin to work. We don’t need TPA to masks all of the oscillation points throughout tuning. We are going to tune TPA later if now we have oscillation points at excessive throttle vary.
Find out how to use PIDToolBox and Blackbox Explorer?
I will likely be utilizing each PIDToolBox (PTB) and Blackbox Explorer (BE) in my PID and filter tuning.
PIDToolBox will likely be our foremost software, it’s by far probably the most highly effective Blackbox software obtainable. It lets you examine a number of logs facet by facet on the identical window, so you’ll be able to see the consequences of the modifications you made in an occasion. The Step Response software is tremendous easy and helpful for tuning PID. One other good thing is the unit on the Y axis within the spectral analyzer (in decibel), which permit for extra correct and goal comparisons. PTB additionally tells you the estimated filter delays which is beneficial.
The primary draw back of PTB in my view is velocity. It masses fairly a bit slower and it simply isn’t as intuitive to make use of as BE. That’s why I largely use BE if I solely have to have a look at one log, or for normal troubleshooting as a result of it’s simply sooner to make use of. However for noise and filter tuning, PTB is certainly the way in which to go.
Filters Tuning
Additional studying: Be taught in regards to the various kinds of filter in Betaflight on this tutorial.
{Hardware} performs a giant half in how a lot filtering is required. For instance, a effectively designed body with out unhealthy resonance points, a set of effectively balanced propellers, new motors with clean bearing, all contribute to a clear quad that requires little filtering.
Performing flight for noise evaluation
Take off, fly ahead with as little throttle as attainable and minimal yaw/pitch/roll stick inputs.
Carry out “throttle sweeps” – slowly ramp up throttle till it reaches 100% over 5-10 seconds. Vibration frequency brought on by the motors can change with throttle degree, this take a look at will present all of the vibrations throughout the entire throttle vary in addition to the place the body resonances are.
Repeat this 2-3 occasions, then land and disarm.
That is what a typical throttle sweep log would appear like (see the underside bar for throttle modifications).
Understanding Gyro Frequency and Delay
Now open the “throttle sweeps” log in Blackbox Explorer, and click on on “Gyro_Scaled” (unfiltered gyro sign) in the proper hand pane. It’s essential to take away the take off and touchdown elements of the log (so these vibrations don’t throw our evaluation off) by urgent the keys “i” and “o”.
Right here’s a breakdown of the uncooked gyro sign frequency graph from a typical 5″ FPV Drone:
- Underneath 20Hz: drone flight actions
- Between 20Hz – 100Hz: propwash and oscillations brought on by suboptimal PID (e.g. trilling brought on by an excessive amount of D acquire), problematic ESC config and unhealthy RC hyperlink associated settings and many others…
- Between 100Hz – 250Hz: body resonance or free elements
- Greater than 250Hz: noise from motors and propellers, and harmonics
All the things under 20Hz is “good” drone movement reacting to the sticks.
Between 20Hz and 100Hz is the undesired vibrations resembling oscillations and propwash. As a normal rule of thumb, you need to see little exercise on this frequency vary. Having some is regular however an excessive amount of means you’ve gotten an oscillation difficulty that must be addressed. Usually we attempt to keep away from filtering under 100Hz as a result of these are actual motions of the drone, that we both need to work with or work towards. Filtering on this low frequency vary can truly make issues worse as a result of it introduces super quantity of latency. Analyzing the spectra below 100Hz may give you perception into vibration or mid throttle oscillation points, and the way effectively the copter is handing propwash.
We don’t care about something above 1000Hz as these have little impact on our drone, what we need to deal with filtering is the noise between 100Hz and 1000Hz.
Maybe not intuitive, however over-filtering can truly trigger oscillation to point out up as noise within the sub-100Hz spectra. That’s as a result of filtering creates one thing referred to as section delay. When the quad tries to make a correction to the error, the response is simply too late as a consequence of delay and is definitely counter productive. It makes the error worse and creates a suggestions loop, so the drone begins to oscillate.
That’s why if we use much less filtering, noise points below 100Hz can generally truly get higher, as a result of latency is decreased and the quad can react sooner to appropriate PID errors. Utilizing much less filtering additionally lets you push PID good points increased which makes your quad monitor setpoint higher and helps fight propwash.
You will discover out how a lot delay is added to the Gyro sign as a consequence of filtering, by plotting Gyro and Gyro_Scaled and measure the hole between them.
In PTB, it routinely estimates the delay brought on by gyro filtering and D-term filtering (see prime proper nook of the primary graph in second column).
Filter Technique
My normal filter technique is to kill motor noise bands utilizing RPM filter, then crush out body resonances with dynamic notch filters, lastly cut back the ambient noise ground with Gyro and D-term lowpass filters. I will likely be tuning filters on this order:
RPM Filter => Dynamic Notch Filter => Gyro Lowpass => D-term Lowpass
We would like as little filtering as attainable to reduce latency, however on the identical time to have sufficient filtering in order that we don’t burn our motors once we are flying residence with a bent prop. One can actually play secure and apply extra filtering than wanted, however when over-filtering, the drone would really feel disconnected and sluggish to react because of the elevated delay. It makes propwash worse too. So there’s a stability we need to try for.
Aside from checking Blackbox logs, motor temperature is one other helpful willpower in filter tuning. When motors get too sizzling is normally an indicator of pushing the filtering too far.
Professional Tip: Sizzling motors – how sizzling is simply too sizzling?
As a normal rule of thumb, in the event you pinch the motor and may’t preserve your fingers on it various seconds, which means it’s too sizzling and you’re most likely pushing your setting too aggressively.
How Clear is Your Construct?
Earlier than we start, you would possibly need to examine you probably have a clear construct. Carry out throttle sweeps as earlier described.
Load the log in PIDToolBox, click on Spectral Analyzer. Choose simply “Gyro prefilt” (the uncooked unfiltered gyro sign, “Gyro” is the filtered sign), and hit Run.
The default filter settings in Betaflight are pretty conservative, most builds ought to have the ability to cut back filtering from there. In case your quad is already noisy with default filter settings, as an alternative of accelerating filtering you must search for attainable mechanical/electrical points. Use capacitor on the ESC enter energy, ensure all screws are tightened up, use recent new props and many others.
On a clear 5″ quad, there must be little exercise between ~50Hz (the quad’s actions) and ~200Hz (motor vibration). When you have numerous noise on this area, it could possibly be electrical noise (maybe gyro enter energy is simply too noisy, or it requires additional capacitor on the ESC enter energy), or perhaps mechanical (e.g. a wire is hitting the gyro). It might be tougher to get optimum filtering on this situation.
As prompt by the creator of PIDToolBox, it’s perfect to have the general noise ground under -30dB above 50Hz. For D time period, it’s perfect to have the general noise ground under -10dB. From wanting on the noise degree in these areas can actually inform how clean your quad flies. The noise degree has to do with how effectively the drone is constructed, how good the {hardware} high quality is, and generally you would possibly simply have a loud Gyro.
In case your quad is noisier than this (e.g. there’s a peak within the center above 0dB), then you’ll need extra filtering. It’s not the tip of the world, it simply means the latency will likely be increased and also you gained’t have the ability to push PID good points as excessive.
Tuning RPM filter
Motor noise is the principle supply of noise for FPV drones, and RPM filter is without doubt one of the handiest filters in Betaflight for tackling motor noise. On a clear construct, RPM filter and Dynamic Notch filters will likely be doing a lot of the work, and we are able to disable many different filters to reduce latency.
Let’s have a look at some examples of motor noise:
- Load the “Throttle Sweeps” log in PTB, click on Spectral Analyzer and click on “Freq x Throttle“.
- Underneath “Presets” choose “Gyro Prefilt, Gyro, Dterm Prefilt, Dterm” and hit Run. That is what I name “warmth maps”.
Let me clarify what we’re right here:
- Near 0Hz, the very shiny horizontal line on the backside (1) is the drone’s movement reacting to the sticks.
- Round 200Hz, the horizontal line (2) is the body resonance. Its frequency doesn’t change regardless the throttle place, but it surely’s the strongest the place it intersects with motor band.
- The diagonal line (3) is the elemental motor noise band, normally the brightest, motor noise sometimes will increase in frequency with throttle degree.
- There are sometimes harmonics at multiples of the elemental motor noise band. In our instance, (4) and (5) are the motor noise band harmonics, they are usually dimmer, generally arduous to identify. Strive adjusting the size and see in the event that they present up extra clearly.
- Notice that 2-blade propellers have a tendency to point out extra and stronger harmonics than 3-blade props.
We are going to use RPM filter to deal with these motor noise bands.
Tuning RPM filter mainly means to optimize the variety of RPM harmonics used and set the best attainable “Min Frequency” primarily based on the beginning frequency of the motor band.
Fewer RPM harmonics and Greater min freq = much less filtering and fewer latency.
Click on the “Information Cursor” software, and click on on the place the motor band begins, it is going to inform you the precise frequency. Verify in roll/pitch/yaw graphs, and take the bottom frequency.
Right here’s an instance of me tuning my new Supply One V5 construct:
- On the left, is the default RPM filter: 3 Harmonics with min frequency of 100Hz
- On the proper, 2 Harmonics with min frequency of 160Hz
By decreasing one harmonics and lift the cutoff frequency, you’ll be able to maybe see extra unfiltered noise from the third motor harmonics.
Though it’s fairly weak, it might probably nonetheless get amplified when it will get into D time period. Let’s examine the Dterm warmth map under on the proper, as you’ll be able to see, a tiny little bit of gyro noise has turn out to be fairly unhealthy Dterm noise.
On this instance, it’s most likely higher to have 3 harmonics in RPM filter.
The opposite factor you might need observed is a few noise round 116Hz left unfiltered as a result of we raised the min freq to 160Hz. To handle that, now we have to decrease Min Freq, i.e. round 20Hz under the noise frequency could be perfect.
Right here’s a comparability of gyro sign after filtering utilizing 3 totally different settings:
- left: 2 harmonics 160Hz min freq
- mid: 3 harmonics 130Hz min freq
- proper: 3 harmonics 100Hz min freq
To crush out the motor bands, it appears we are able to’t actually cut back RPM filter from the default on this case. The default 3 harmonics and 100Hz min freq works the perfect for us on this instance.
RPM Crossfading
This superior function fades within the RPM filter energy over a variety (type of like TPA), the default is sweet for many 5″ builds however it may be optimized particularly for bigger or smaller builds, because the motor noise would possibly begin increased or decrease in frequency, and also you would possibly want it to fade in additional shortly or slowly is determined by the noise. This function is barely accessible in CLI, for instance:
set rpm_filter_min_hz = 100 set rpm_filter_fade_range_hz = 50
This implies the RPM filter is efficient from 100Hz, however at minimal energy, the filtering strengths will increase from 100hz and turn out to be full energy at 150hz.
Q Worth
Growing Q worth of a notch filter makes it extra targeted on the focused frequency (narrower vary), additionally reduces latency. Once more, this superior setting is barely accessible within the CLI, for instance:
set rpm_filter_q = 500
Default works effectively a lot of the occasions, however could be fantastic tuned by growing Q till motor noise is seen within the Filtered Gyro diagram, then again off. Don’t exceed 1000.
RPM Filtering Dimming
This enables particular person management of every RPM filter to focus on harmonics. For instance, when utilizing 3-blade propellers, the second harmonics is normally not very robust, however the third harmonics is. On this case you need to use extra filtering energy on the third harmonics and fewer on the 2nd:
set rpm_filter_weights = 100, 0, 80
And when utilizing 2-blade propellers, the place 2nd harmonics is stronger than the third harmonics, you are able to do one thing like this:
set rpm_filter_weights = 100, 80, 0
You may lower RPM filter weights much more so long as motor noise is just not seen within the filtered gyro diagram.
Tuning Dynamic Notch Filter
The dynamic notch filter suppresses sign peaks in gyro sign which can be largely vibrations from the body or different {hardware}, i.e. body resonance (carbon fibre could be surprisingly springy), antennas, GoPro in a TPU mount, and bent propellers.
When RPM filter is enabled, Betaflight will routinely cut back the quantity of Dynamic Notch filtering (fewer notch counts and better Q worth) as RPM filter will do a lot of the heavy lifting. You may additional tune Dynamic notch primarily based by yourself setup.
Tuning Dynamic Notch Filter means to reduce the notch rely, use the best attainable Q worth and preserve the min/max frequency as slender as attainable. Fewer notches = much less filtering however decrease latency. Even higher, if body resonance isn’t very robust, you’ll be able to attempt disabling this filter to avoid wasting filter delay.
Take a look at the warmth map and establish what number of body resonances there are to resolve what number of notches are wanted. You may have as much as 5 notches however normally 1 or 2 must be sufficient until your drone is poorly constructed or in a extremely beat up situation. Particularly when you’ve gotten RPM filter enabled, 1 notch is normally sufficient to crush out body resonance. In case your quad can’t use RPM Filter, for instance on a tiny whoop, you’ll be able to attempt to allow Dynamic Notch Filter with 5 harmonics, Q issue 350 and Min Frequency at 100Hz as a place to begin, then tune it by working your manner up.
On this instance, there solely appears be to at least one body resonance round 210Hz (see the horizontal line that seems throughout the entire throttle vary).
The Q worth determines the width of the filter: Greater Q = narrower filter, much less filtering however decrease latency.
If the default Q of 500 is working effectively, attempt 600 and even 700 (mainly discover the best Q worth that may nonetheless adequately management these resonances), however keep away from exceeding 1000. If after filtering you’ll be able to nonetheless see the body resonance noise, you would possibly want a decrease worth. Verify Dterm heatmap to see the way it impacts D-term noise as effectively to resolve whether or not or not your Q worth can go increased.
Min/Max Frequency are the cut-off frequencies, it’s mainly the efficient vary of the Dynamic Notch filter. Merely add 20-30Hz extra vary to every facet of the resonance.
I might keep away from setting Min Frequency too excessive for security as bent props can create huge resonance too. Should you crash and attempt to fly residence with a bent prop, the dynamic notch filter can actually assist to scale back the vibrations that may get into the D-term. We don’t know precisely the place that resonance goes to be, however having a wider frequency vary has a better likelihood of catching it. If the Dynamic Notch fails to catch these newly pop up resonances as a consequence of Min Frequency is ready too excessive, your motors can get sizzling and even burn in these conditions.
On this instance, I attempted to extend Q to 700 and set the min/max frequency to 160-230Hz, however Q is clearly too excessive I believe. There may be extra unfiltered noise, and it will get into Dterm and get amplified.
Lastly, once I set Q to 450, the noise is sufficiently managed. Within the under graphs, on the left is Q=700, the proper is Q=450. You may examine Dterm heatmap once more to verify that is working effectively.
Tuning Gyro Lowpass Filter
Normally you’ll be able to simply flip off Gyro Lowpass 1 filter because it’s not wanted, take a look at fly aggressively for 30 seconds, and examine motor temperature to verify they don’t seem to be sizzling earlier than continuing.
Then use the “Gyro Filter Multiplier” slider to scale back Gyro Lowpass 2 a few notches at a time. Shifting the slider to the proper = shifting frequency up = decreasing filtering = much less delay = higher prop wash dealing with and better PID good points.
Right here I’ll examine the gyro frequency spectrum between Gyro Lowpass filter slider worth 1.0 (brown), 1.5 (crimson) and a couple of.0 (orange).
The three strains virtually overlap one another, that recommend Gyro lowpass filter isn’t actually doing a lot and could be decreased. Curiously, in the event you have a look at the noise within the sub-100Hz spectrum, it truly will get ever so barely higher with much less filtering, that echoes what we talked about earlier.
Necessary:
- By no means disable Gyro Lowpass 2 filter for 2K/4K PID loop frequency as a consequence of anti-aliasing causes
- For 2K looptime, go away Gyro Lowpass 2 at 500Hz because the minimal
- For 4K you’ll be able to set Gyro Lowpass 2 so far as 1000Hz
- For 8K, you’ll be able to disable Gyro Lowpass 2 completely if noise isn’t a problem
Tuning D Time period Lowpass
D time period is far noisier than Gyro as a consequence of its delicate nature and noise will get amplified as frequency goes up, so be additional cautious and conservative when coping with D Time period filtering.
Strive shifting the “D Time period Filter Multiplier” slider to the proper a notch at a time and see how the drone responds in a 30-second take a look at flight (do some acro strikes), additionally examine motor temperature after touchdown. In the event that they get sizzling you must return a notch or two.
I might warn towards going too aggressive with decreasing D Time period filtering, go away some headroom for attainable bent props throughout flight. Too little D Time period filtering and a broken propeller are the perfect mixture for decent/burned motors.
Right here’s a comparability between 1.0 (brown), 1.3 (crimson) and 1.6 (orange) in D-term filtering slider positions. As you’ll be able to see much less filtering is clearly noisier for dterm, in contrast to Gyro lowpass.
Within the following heatmap, from left to proper: unfiltered D time period, Dterm lowpass filter 1.0, 1.3 and 1.6.
Should you hear the motors getting tough (thrilling oscillation) as you cut back d-term filtering, it’s the rising noise under 100Hz (you’ll be able to examine the <100Hz graphs to verify). On this instance I’d most likely keep under 1.3, perhaps 1.2 and even simply 1.1 to be secure.
After you’ve gotten tuned PID good points, you must come again and examine once more if D Time period filtering could be optimized.
If the D Time period traces are very noisy, one or two clicks extra filtering on the slider could assist. If the D time period hint may be very clear, you’ll be able to maybe cut back filtering a bit extra (if motors usually are not sizzling). See under graphs, the left has a loud D time period hint, the proper is far cleaner.
Necessary: NEVER disable D-Time period lowpass filters utterly, you’ll burn your motors.
Gyro/D Time period Notch Filters
There’s no want to the touch Gyro Notch Filter and D Time period Notch Filter, these are static notch filters which have turn out to be legacy since they’ve been changed by RPM filter and dynamic notch filters. So a lot of the occasions you gained’t want to make use of them.
Say if there’s a powerful resonance at a really particular frequency (resembling body resonance), static notch filter could be useful. Nevertheless the dynamic notch filter can normally cowl it and so a static notch filter is normally not wanted. You may nonetheless attempt including a static notch for the identified body resonance and decreasing the dynamic notch rely by one and see which technique works higher in your setup.
Yaw Lowpass Filter
The default yaw lowpass filter at 100Hz cutoff has minimal latency penalty subsequently it may be left untouched. Whoops can particularly profit from Yaw Lowpass filter because it helps to scale back yaw spin in collisions.
PID Tuning
To tune PID utilizing Blackbox, I will likely be following the “Basement Tuning” methodology utilizing PIDToolBox. It’s beginner-friendly and you may actually do it in your basement/mattress room therefore the title. Principally you simply have to carry out a collection of quick flights with barely totally different PID values, then examine the logs to seek out the optimum good points.
Throughout flight, you must transfer the quad round in pitch and roll axis, easy sufficient. You may be taught extra in regards to the basement methodology on this video by PIDToolbox.
Though they name it the “basement tuning methodology”, I’m actually not snug doing this indoor. I had a few “fly to the moon” incidents prior to now and I virtually drilled a gap within the ceiling, so I at all times attempt to do these exams within the backyard or within the native park.
Charge Profile and Angle Mode
It takes some good line of sight flying abilities to carry out the basement tuning flights. It’s not straightforward to maintain the drone managed in confined house with out hitting the partitions. To make it simpler, do that charge profile (Precise Charge):
- Middle Sensitivity 250
- Max Charge 400
- Expo 0.00
It has low max charge, so it’s much less prone to get uncontrolled in the event you transfer the sticks an excessive amount of. The excessive and linear middle stick sensitivity ensures the stick inputs are sufficiently big for the logs.
You may even carry out this take a look at in Angle mode which makes it even simpler than charge mode. In line with the creator of PTB, this works simply in addition to in charge mode, however that you must do the next first:
- Calibrate accelerometer on the Setup tab
- Set Angle mode energy to 100 in PID Profile Settings
- Click on Save
Discovering P/D Steadiness
To begin with, decrease these good points in order that they don’t intrude with our tuning:
- Set the “Stick Response” slider (Feed Ahead) to 0
- Set the “Dynamic Damping” (D Max) slider to 0
- Set the “Drift-Wobble” (I good points) slider to 0.2, it’s low sufficient that it shouldn’t introduce overshoot but have just a bit I phrases to assist stabilize the quad higher, makes it simpler to manage
Modify the “Damping” (D good points) slider, begin with a minimal worth you need to take a look at. For a typical 5-inch FPV drone, 0.6 is an efficient start line.
Here’s what you need to carry out within the flight:
- Arm and hover
- Continuously shifting the roll and pitch stick for 20-30 seconds, the extra actions the extra correct will probably be
- Do as massive strikes as you’ll be able to with out hitting the partitions (ideally full stick deflections)
- You may transfer each pitch and roll collectively so long as you’ll be able to preserve it below management
- Strive to not cease/hover for too lengthy throughout flight, and be as steady as you’ll be able to
Elevating the Damping slider by 0.2 every time and repeat the flight: e.g, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6. If you increase D acquire too excessive, your motors will sound tough, subsequently you’ll be able to’t at all times take a look at the final one or two values, which is ok.
The quickest method to change slider worth is by going into Betaflight OSD menu, Profile, Simplified Tuning. However in case you are unable to do that then simply plug within the USB cable and use the Betaflight Configurator.
It’s a good suggestion to alter battery each 2-3 flights to make sure the consequence isn’t affected by voltage. Energy cycle the quad by unplugging the battery earlier than each flight so it creates a brand new log. Or just select “Save and Reboot” within the OSD menu so that you don’t have to unplug.
16MB reminiscence must be sufficient for six 30-second flights in the event you time it effectively.
After you’ve gotten accomplished all of the flights, obtain them to your pc. To arrange the logs higher, I’ve a folder construction created for this course of, obtain right here: https://drive.google.com/file/d/1tx1AV2lOMgknAwIB3VFhqP1i6VpDLVjr/view?usp=share_link
And I rename the logs to one thing like “01 d06“, “02 d08” and many others (01 means first take a look at flight, d06 means damping slider worth 0.6), and put them within the “02 PD Steadiness” folder.
Load all of the logs in PTB, undergo each and take away the take-off and touchdown elements for every log (to do that, allow “Trim” on the proper hand panel).
Click on the “Step Resp Instrument“, choose all of the information and click on Run. you probably have offset within the curves (gyro curve shifting away from setpoint in direction of the tip), allow Y Correction.
It’s fairly straight-forward, merely decide the perfect wanting line, that’s your optimum Damping slider worth. The perfect response ought to look one thing just like the inexperienced line within the following graph, little to no overshoot. Having a tiny little bit of overshoot is suitable.
In case your traces don’t look clean however have a lot of ups and downs, that’s referred to as oscillation, and it’s an indicator that the sign is simply too noisy or your actions aren’t sufficiently big.
The graphs on the proper are additionally extraordinarily useful:
- Peak is highest amplitude of the overshoot (ideally the nearer to 1 the higher)
- Latency is the time it takes to succeed in setpoint (ideally the decrease the higher)
When D acquire is low, you’ll get overshoot and even oscillation. As D acquire will increase, there will likely be much less overshoot and Peak will lower, however Latency will go up because of this. When D is simply too excessive (undershoot), the preliminary peak may not even attain the setpoint and this isn’t perfect. Discover a response that has minimal overshoot and but has comparatively low Latency.
You may zoom in and see it extra clearly (or choose fewer logs, and hit Run once more). We solely want to have a look at Roll and Pitch axis.
In our instance, it’s fairly clear the best worth is orange (3) for each pitch and roll, so that might be 1.0.
It’s fairly frequent to have a special PD stability on pitch and roll because of the totally different weight distribution. If that’s the case for you, take the Damping slider to the place you need for pitch, write down the pitch D acquire, then take the Damping slider to the place you need for roll, and alter the Pitch Damping slider to match the pitch D acquire you simply wrote down.
Typically it’s higher to be somewhat extra conservative and keep away from having D acquire too excessive. In case you are on the fence, at all times go along with much less D acquire (a better P/D ratio), so you’ll be able to increase your general PID good points increased on the finish since D is normally the limiting issue.
What I’ve discovered is that the step response software tends to be fairly delicate and the P/D stability could be decrease than what I’d personally want. So I usually bump up P/D stability by 5-10% after discovering a really perfect worth. That’s simply my private choice, you may give {that a} attempt if you’d like.
Drone dimension additionally impacts PD ratio, bigger drones are inclined to have increased P:D ratio. For instance a 5″ would possibly use 0.8-1.1 Damping slider whereas a tiny whoop would possibly use 1.4-1.6.
Discovering Max D Acquire
Do the identical take a look at for Grasp Multiplier slider at 0.2 steps, e.g. for five″ drone, that might be 0.8, 1.0, 1.2, 1.4, 1.6 1.8.
Be very cautious although, don’t stand too near the quad throughout this take a look at, since you would possibly hit some extent the place D is simply too excessive and the quad can shoot up. Pay shut consideration to motor noise, if you hear thrilling oscillation you must cease.
You would possibly discover the shapes of the step response don’t change a lot between totally different values, and the Peak values keep roughly the identical too. That’s as a result of the form of the response curve is principally decided by the P/D ratio. By growing the good points gained’t have a lot of an impact on the response, however by bumping up P/D good points can cut back Latency.
You’ve got reached the best Grasp Multiplier acquire when one of many following occurs:
- you hear thrilling oscillation – you’ll be able to’t improve D acquire anymore
- or the latency doesn’t lower anymore (or little or no) – which means it has reached the higher certain tuning window, motors are working on the hardest and you aren’t getting anymore efficiency out of them
How excessive your good points can go is set by how noisy your construct is and the way a lot filtering you’re utilizing. Much less filtering permits for increased PID good points. Typically it’s higher to be somewhat extra conservative and switch the Grasp Multiplier slider down a notch or two when you’ve gotten discovered the max worth, and to not push D acquire to the sting could be safer within the occasion of a bent prop. Notice that drones utilizing increased cell rely battery (increased voltage) have a tendency to permit decrease D good points, e.g. on a 6S quad, D good points could be within the 30’s, whereas on 4S they’re normally within the 40’s.
In my instance, 1.6 appears to be the worth that offers us the least quantity of latency, and there may be not a lot enchancment going as much as 1.8.
You would possibly or may not have the ability to hear the thrilling oscillations. To examine, merely go to Spectral Analyser and plot Dterm. Because the good points get increased, the motors will make an exciting sound that peaks round 40-80Hz (particularly as you ramp up throttle). Should you see noise at this frequency vary creeping up with increased good points, then for certain you’ve gotten an oscillation beginning that’s PID associated.
On this instance, you’ll be able to clearly see that peak round 60Hz for 1.4 (olive), 1.6 (inexperienced) and 1.8 (cyan). Though 1.6 reveals enchancment in latency, I personally wouldn’t danger it. I’d most likely go for 1.3 and even 1.2 on this instance simply to be secure.
It’s nonetheless controversial whether or not it’s higher to have extra Dterm filtering and better D acquire, or much less Dterm filtering and decrease D acquire. However by no means run much less Dterm filtering and excessive D acquire or disasters can occur if you hit a department or have bend a prop! It’s no joke 🙂 Talking from expertise right here:
Should you examine setpoint monitoring now (plot Gyro and Setpoint), you must discover the quad monitoring fairly effectively. The 2 line must be roughly parallel (that means the quad is accelerating and decelerating on the identical charge as Setpoint), however there’s nonetheless fairly a giant hole between them, which is latency! Within the subsequent step, we are going to cut back that hole utilizing Feedforward.
Tuning Feed Ahead
Feed Ahead accelerates your quad if you transfer the sticks, making your quad extra responsive and comply with setpoint nearer.
P time period is sort of sluggish in comparison with Feedforward as a result of it solely begins to react when there’s a PID error. Feedforward measures the speed of stick deflection – how briskly you’re shifting the sticks. It doesn’t depend upon gyro information, it will get the motors shifting as quickly because the the stick strikes, subsequently it’s rather a lot sooner than P time period.
When tuning Feed Ahead I want to do some snap rolls and flips and examine Gyro/Setpoint traces. Use your normal charge profile, or a default charge profile in Betaflight (simply swap to the unused charge profile) to get an honest max charge at full stick.
As an alternative of utilizing the step response software in PTB, we are able to simply examine setpoint/gyro traces in BE, the gyro must be monitoring setpoint even higher than earlier than (much less delay). In the perfect instances the gyro could also be proper on prime of setpoint. If Feedforward overshoots (gyro strikes earlier than setpoint), then feedforward is simply too excessive. Within the following demonstration, 0.5 is manner too low, 1.0 continues to be not excessive sufficient, however 1.5 is a tiny bit an excessive amount of and overshoots. I believe Feedforward at 1.3-1.4 ought to do it on this instance.
In case your feedforward acquire is manner too excessive, it is going to even trigger P time period to go the other way attempting to battle it 🙂
Doesn’t matter what your flying fashion is, feedforward could be helpful and doesn’t apply solely to sure varieties of flying. Even cinematic flying can profit from a very good quantity of feedforward, in case you are shifting your stick easily and slowly, then feedforward gained’t kick in anyway. If you want snappy response FF will cut back the latency between stick enter and quad response. If you’d like clean flying, simply use expo, extra RC smoothing or decrease your charge.
There’s an elective setting, Feedforward enhance (FF Enhance). You need to improve it if gyro lagging behind setpoint at first of a transfer, however catching up afterward. However you must cut back it if gyro will get forward of the setpoint at first of a transfer, however falls behind later.
Tuning I Acquire
The perfect I time period is just about a really feel factor to some extent, you don’t want a variety of I acquire when you’ve gotten optimum P and D good points, simply want a minimal quantity of I acquire to maintain the drone from drifting and wandering. Check out my methodology of tuning I right here. In case you are cruising ahead with minimal stick inputs, the drone ought to maintain its place for a time. If there’s any drifting then you definately want increased I acquire.
I time period has a REALLY WIDE tuning window particularly for highly effective 5″ quads, 0.5 to 1.5 within the I time period slider would most likely work fantastic. That’s why we are able to tune all the pieces else and tune I time period final. With a excessive I acquire your quad will really feel extra exact, however once I acquire is simply too excessive your quad could have sluggish oscillations and also you need to keep away from that.
In case you are attempting to push I acquire as excessive as attainable, you’ll be able to attempt shifting I acquire slider up till you’ve gotten sluggish bouncebacks and oscillations throughout quick strikes, then come again down a notch or two.
Since now we have added FeedForward, and the Gyro/Setpoint are monitoring so carefully, the Step Response software in PTB gained’t be efficient for locating the I time period. So I usually tune I acquire by wanting via the goggles and listening to the motors.
Due to the function “I-term loosen up” in Betaflight, you need to use very excessive I acquire with out a lot of the unfavorable results. What I discovered when setting I time period too excessive is it’ll make the traces look bumpy when doing flips and rolls. So I are inclined to set I on the decrease facet for my freestyle rigs, simply sufficient to maintain the quad from drifting as a consequence of wind. Utilizing Anti-Gravity can enhance your I acquire temporally throughout throttle pumps to scale back nostril wanders, so I normally don’t discover the necessity to have very excessive I acquire. For five″, I usually go away it just under 1.
With I time period loosen up, you’ll be able to alter the cutoff primarily based on its responsivenes. For freestyle drones, you’ll be able to usually go away it at default. For racing drones, improve it to 30. For heavier drones like cinelifters and seven″ lengthy vary carrying GoPro, you’ll be able to set cutoff to 10.
Dynamic Damping
Dynamic Damping boosts D acquire to the utmost throughout sharp strikes, however doesn’t enhance up throughout regular flight. This reduces motor warmth.
Decreasing Damping slider whereas shifting Dynamic Damping slider so D Max maintains the unique D acquire, however your Spinoff acquire is now decrease which is used throughout regular flights and preserve the motor cooler.
Different Settings
Anti Gravity Features
As talked about, if you punch out and let go of throttle, the drone would wobble and nostril dip. Anti Gravity (AG) can enhance I acquire temporally when throughout throttle pumps to scale back these undesirable dips. Nevertheless if you set AG acquire is simply too excessive, your quad could stutter if you let go of throttle (speedy oscillation), as a result of AG boosts each P and I.
Default is 8, cut back it in the event you see wobbles throughout quick throttle modifications. For five″ freestyle drones, I discovered 4 to eight a very good vary.
You’ll want to tune AG by wanting within the goggles.
Dynamic Idle
Dynamic Idle Worth 30 to 35
Dynamic Idle helps to enhance stability, higher propwash dealing with and decrease likelihood of ESC desync. The draw back is you could lose grasp time. By growing motor velocity when throttle is at zero, it improves management authority of the PID controller and low throttle enter responsiveness. There are additionally different advantages resembling sharper flip and roll stops, extra responsive in low throttle and more practical braking and many others.
When Dynamic Idle is ready, Static Motor Idle (in %) within the Motors tab is disengaged.
To setup Dynamic Idle, that you must
- allow bi-directional DShot within the Motor Tab (if you have already got RPM filter enabled, you’re all set)
- set an appropriate Idle RPM worth within the PID Tuning web page (enter 30 to 35 for five″)
The really helpful Idle RPM worth relies upon rather a lot on propeller dimension and pitch, smaller and decrease pitch propellers usually require increased worth. For 7″ you’ll be able to usually set this to 14-28, for five″ drones, 20-40, and for 3″ it’s increased at 33-66. When it’s windy you can even set this increased to counter.
Prop Sizes | Excessive Pitch Props | Low Pitch Props |
31mm/1.2″ | 84 | 167 |
40mm/1.6″ | 62 | 124 |
2″ | 50 | 100 |
2.5″ | 40 | 80 |
3″ | 33 | 66 |
3.5″ | 28 | 57 |
4″ | 25 | 50 |
5″ | 20 | 40 |
6″ | 16 | 33 |
7″ | 14 | 28 |
8″ | 12 | 25 |
10″ | 10 | 20 |
Worth too excessive, you lose grasp time if you let the drone fall the wrong way up (the motors push tougher in direction of the bottom). A excessive worth may even are inclined to make the quad “hover” somewhat extra even at zero throttle, making throttle administration somewhat tougher. When worth is simply too low, you danger low throttle instability.
To set the worth, is determined by what ESC idle you had beforehand (default is 5.5%), take a look at your motor within the motor tab, you need to use a smoke stopper or bench energy provide to restrict present in case it goes uncontrolled. Spin the motor on the ESC idle worth, e.g. for five.5%, transfer slider to round 1055, and see what the reported RPM worth is (it is going to solely present this in the event you allow bi-directional DShot). Then this RPM worth could be the best worth in your dynamic Idle worth (divide it by 100).
Throttle Enhance
Default worth is 5, works for many freestyle builds. It boosts your throttle worth if you end up shifting throttle stick up immediately to present you additional energy, it offers you an influence enhance but in addition makes throttle extra unpredictable. It doesn’t have any impact if you transfer throttle stick slowly although. Should you discover throttle is difficult to handle you’ll be able to cut back it. I do know some racers even disable throttle enhance completely by setting it to 0. You may experiment with smaller values and see what works for you.
Voltage Sag Compensation
It reduces the utmost motor drive worth when battery is full, and will increase it because the battery voltage goes down. It offers extra constant flight efficiency all through the entire flight.
Thrust Linearization
Allow Thrust Linearization, 20%.
This may enhance PID to enhance responsiveness and management authority at low throttle, whereas decreasing PID at prime throttle to scale back oscillations (identical impact as TPA). It could assist with nostril dip too. That is particularly really helpful for whoops and in the event you use 48KHz PWM frequency on ESC. It’s additionally helpful when TPA alone isn’t sufficient to deal with excessive throttle oscillation.
Because it boosts PID at low throttle, you would possibly need to drop the grasp multiplier slider down a notch or two if motors get sizzling.
TPA
Do a throttle sweep once more and examine freq vs throttle heatmap.
In case you are getting oscillations solely above sure throttle degree, TPA could be the answer. It additionally helps to push PID increased with out providing you with drawback within the excessive throttle vary.
Within the newest Betaflight it solely attenuates D acquire above sure throttle degree (which is normally the reason for the oscillations). Within the older Betaflight it attenuates each P and D, if you’d like you’ll be able to convey this again by typing in CLI: set tpa_mode = PD.
Usually I want to set throttle worth in TPA as excessive as attainable, so D acquire is extra fixed throughout a wider throttle vary. Be sure to set the throttle worth somewhat decrease than the place the place the D time period associated oscillations begin to present up. For instance, if oscillation begins round 1800 throttle, I might do one thing like this: TPA = 0.75, 1750.
Revisit D time period filtering
In any case these modifications, you’ll be able to examine D time period filtering once more and see if that you must cut back or improve it.
I Time period Rotation and Absolute Management
There’s no want to make use of these options for FPV Freestyle Drones. These options are largely useful for line of sight pilots.
Tuning Yaw
I don’t play with Yaw an excessive amount of, default acquire usually works effectively. The tuning window for Yaw is sort of huge.
Not like pitch and roll that are primarily based on thrust generated by propellers, yaw relies on the inertia generated by propeller rotation. Subsequently, yaw will inherently be too sluggish to overshoot setpoint, and there’s little have to tune yaw PID.
Yaw can be too sluggish for D phrases to have any significant impact and it’s usually not required. Nevertheless you’ll be able to allow it if you’d like, but it surely would possibly introduce extra drawback than it solves, like vibrations and many others. So we’re left with P and I phrases for Yaw.
You may tune Yaw utilizing the step-response evaluation like we did with Pitch and Roll. Moreover, if sluggish oscillations happen within the again a part of the graph, then I-Time period is simply too excessive. If quick oscillations happen, then P-Time period is simply too excessive.
When you have yaw shakes when doing throttle pump, you’ll be able to isolate yaw from the slider tuning, and set Yaw PID individually. To do that, go to the PID tuning tab, within the ‘Slider Mode’ dropdown record, choose RP (Roll Pitch), as an alternative of RPY (Roll Pitch Yaw). This may exclude yaw values from the sliders, and lets you enter PID numbers for yaw. For five″ freestyle and cinematic builds, attempt 100 for each P and I might be a very good start line. You can too attempt increased values as yaw tends to be fairly sluggish reacting.
There is no such thing as a excellent tune
How good is sweet sufficient? You may at all times spend extra time enjoying with filters and PID numbers, and you might even see enhancements however it may be situational and the time you put money into it may not be proportional to the consequence. I usually simply cease when it seems to be “ok” and go away it there until I’ve a selected drawback I need to clear up.
Troubleshooting Ideas
Dangerous Gyro
On default Betaflight settings, a 5-inch FPV drone ought to already fly fairly easily. In case your quad has vibration, it may both be mechanical or electrical associated. Typically the Gyro on the FC may cause issues too, although this isn’t frequent.
Right here’s what a nasty gyro would possibly appear like. What tends to occur with a nasty gyro, is that one axis is especially noisier than different axes, particularly within the decrease frequency spectrum under 200Hz. Should you rotate the FC by 90-degree, and the noisy axis follows the rotation, then that Gyro could possibly be defective.
On this instance, you’ll be able to see pitch axis is far noisier than roll and yaw. You can too see bursts of D time period noise within the pitch axis which is brought on by the noisy gyro.
Nevertheless, it doesn’t should be a nasty Gyro, different potential causes are: excessive energy wires close to the gyro, noisy energy to FC, unhealthy board design, and many others. You may attempt utilizing a 1000uF low ESR capacitor on the ESC energy. When you have already achieved that, attempt soldering an additional smaller 220uF-470uF cap to the ability of the FC (VBAT/VCC pad).
RC Smoothing
RC smoothing is a must have setting in Betaflight with a view to keep away from difficulty with feedforward. The suitable RC smoothing settings rely in your explicit RC hyperlink, I strongly advocate simply loading the suitable RC_Link preset, it’s the easiest way to keep away from consumer errors.
The Auto Issue is maybe one of the crucial essential values, decrease is extra twitchy and responsive whereas a better worth is softer and smoother however extra sluggish. Right here’s a normal rule I personally comply with:
- 20-25: Racing
- 30: Default worth, nice for Freestyle
- 50: Cinematic
- 90: Extraordinarily clean cruising, delay could be noticeable to some
- 120: The best smoothness attainable with out stepping into hassle, however delay is noticeable
Dangerous gear/pilot require increased RC smoothing too, e.g. Low high quality radio management tools, worn out gimbals, pilots with shaky fingers, and many others. Principally something which may contribute to jerkiness in RC instructions.
If attainable, examine black field logs to verify you’ve gotten clean setpoints, if the setpoint isn’t clean (has steppings from RC instructions), merely improve the smoothing barely.
When you have noise in setpoint that peaks round 50Hz, 150Hz, 250Hz or 500Hz, then there may be most likely an issue with RC smoothing. These frequencies are frequent packet charges in RC hyperlink. On this instance, it’s Crossfire 150Hz.
In case you are not utilizing sufficient filtering for the RC instructions, you may not have smoothed out the RC sign sufficient and it may create noise on the frequency of your radio hyperlink packet charge.
RC smoothing removes stepping and bumpiness in your set-point, it makes P time period hint much less jerky. Nevertheless it additionally provides delay to feedforward in addition to setpoint, so your quad would possibly really feel somewhat bit much less responsive. RC Smoothing is beneficial, however an excessive amount of smoothing defeats the aim of getting quick RC packet charges like ExpressLRS presents.
The purpose is to clean out the steppings however not including an excessive amount of delay. If you’d like smoother RC enter, attempt including some extra expo, it has comparable impact but it surely gained’t provide the latency penalty.
The easiest way is to only load the suitable RC Hyperlink preset as I talked about right here. Should you did not load the right RC_Link preset in your explicit RC hyperlink and packet charge, it may also trigger issues to Feedforward. On this instance, feedforward jitters because of the lack of stepping smoothing in RC instructions.
PID Sum too low?
PID_Sum hitting the default 500 restrict right here (50%) as a result of PID are set very excessive on this drone. You may increase it to 1000 (in CLI enter set pid_sum_limit=1000) to repair it, but it surely doesn’t at all times make a distinction in flight behaviour as motors would possibly saturate at this charge anyway.
ADC Filter Jitters Inflicting Oscillations
In case you are getting random vibrations and wobbles as a consequence of feed ahead jitters, although you’ve utilized the right RC Hyperlink preset or elevated RC smoothing, it could possibly be ADC filter!
Be sure to have turned it off in your radio’s system menu, {hardware} web page.
That is what the feedforward spikes appear like when ADC filter is tuned on.
I spent over 3 months scripting this 7000 phrases tutorial! Should you discover my content material helpful, please take into account supporting my work.