Toolbox: Tune & Fly

Tools

Tune & Fly

The sliders in Betaflight do not tell you what they do. You move one, fly a pack, and try to remember whether the quad felt better. This is the same maths the flight controller runs, wired to a quad you can watch.

Everything is a rate. Your sticks ask for a rotation speed, the gyro measures what you got, and the PID loop closes the gap by changing motor speeds. The catch is that motors take about twenty milliseconds to change speed, so every correction arrives slightly late. Nearly everything a tune can get wrong comes out of that one fact.

A quad flying one manoeuvre over and over, so you can move a slider and see what changed.

0 / 0 / 0 deg/s
level
0 km/h, 7.0 m
Motors
1 2 3 4
Flown by

The amber outline is where the sticks asked the quad to be. On a good tune the quad sits in it. A soft tune trails behind it, and a hot one swings past and comes back. Locked watches from beside the axis you picked below, which is the only camera that holds still while the quad moves.

What you asked for, and what you got

Setpoint, what the sticks asked for Gyro, what the quad did

Start from

PID sliders

1.00

Scales the whole tune at once. Up if the quad feels loose and disconnected, down if it is buzzing or the motors are hot.

1.00

How hard the quad argues with the air. Too low and it wanders off the stick; too high and it oscillates.

1.00

The brake on P. It stops the correction overshooting, at the cost of amplifying gyro noise into the motors.

1.00

How much extra D is allowed when the quad is actually moving. Lets you run low D while hovering and more during a flip.

1.00

Holds the attitude against wind and an off-centre centre of gravity. Too much and it bounces back after a hard move.

1.00

Acts on stick movement rather than on error, so it moves the motors before the quad has fallen behind. Costs nothing at a standstill.

1.00

Pitch carries more inertia than roll on almost every frame, so it usually wants slightly more than roll.

1.00

Same idea for D. Configurator calls this the pitch:roll D ratio.

Filter sliders

1.00

Moves every gyro cutoff at once. Lower is quieter and slower; the delay it adds is what a too-high P oscillates on.

1.00

Same for the D term, which is the noisiest part of the loop. Most hot-motor problems are D and this slider, not P.

What that sets

P I D D Max F
roll 45 80 30 40 120
pitch 47 84 34 46 125
yaw 45 80 0 0 120
Paste this into the CLI
 

Rates

Rates decide what you are asking for. PIDs decide how well you get it.

Fly it with your own radio

Put your transmitter into USB Joystick mode and plug it in. On EdgeTX that is the USB page in the radio settings, or the prompt that appears when you connect the cable. The browser then sees it as a game controller, which means this works in Chrome, Firefox and Safari alike.

Nothing here is written to the radio and nothing leaves your machine. The values you see are your channels after mixes and expo, which is what the flight controller would have received.

Looking for a radio. If one is plugged in, move a stick or flick a switch so the browser reveals it.

What each one is doing

P is the size of the correction, in proportion to how far off the rate is right now. It is the only term that has to be there. On its own it always overshoots, because by the time the quad has reached the rate you asked for, the motors are still spinning up.

D is the brake. It acts on how fast the error is closing rather than on the error, so it starts backing off before the quad arrives. Set the D slider to zero on the model above and the step response grows a bounce on the front of it. The cost is that D also multiplies gyro noise, and the motors have to play that noise back. That is where hot motors come from.

I is memory. It accumulates whatever error P and D leave behind and pushes until it is gone, which is what holds an attitude in wind or with a battery mounted off centre. Take it away and the quad tracks the stick but will not hold a line. Too much and it keeps pushing after the error has gone, which is the bounce back you feel at the end of a hard roll.

Feedforward is the only term that is not reacting to anything. It watches the sticks rather than the gyro, so when you move a stick it moves the motors immediately instead of waiting for the quad to fall behind first. It does nothing at all when the sticks are still, which is why it costs nothing in a hover and why it cannot rescue a bad tune.

D Max exists because the right amount of D during a flip is more than the right amount in a hover. It lets D rise only when the quad is actually moving, so you get the braking where it matters without paying for the noise the whole flight.

The filter sliders are the other half of the same argument. Filtering removes the noise D would otherwise amplify, but every filter delays the signal, and delay is exactly what makes a loop oscillate. Pull the gyro filter slider down on the model and the motors get quieter and the step gets worse.

What this is not

The controller is ported from the firmware: simplified_tuning.c for the sliders, pid.c for the loop, mixer.c for the mixer, rc.c for the rate curves. The gain scales, the iTerm relax, the D Max boost, the airmode normalisation and the pid sum limits are the real ones.

The airframe under it is not your airframe. It is a five inch freestyle quad at roughly 650 grams with generic motors, and it does not know about your frame's resonances, your bent prop, or your ESC firmware. Use it to understand which direction a slider moves things and what that looks like. Do not copy numbers off it onto a real quad.

It also flies in acro only, which is the mode PIDs are tuned in. There is no self levelling to hide behind, so if you fly it with your own radio it will get away from you exactly like the real thing does.