PID Tuning - rotorflight/rotorflight GitHub Wiki

:exclamation: This page is outdated

Rotorflight Wiki is replaced by www.rotorflight.org.


Important: It is essential to get a good Filter Setup before you begin tuning your model.

Rotorflight differs from the commercial FBL controllers in its philosophy. Rather than offering a simplistic setup with few options (remember the first FBL boxes with two dials on them?), Rotorflight gives total control to the user to tune the helicopter to oblivion.

Eventually, there will be good default values and examples for various types of helicopters... but right now it's totally up to the end-user to choose the right parameters and tune the control loops.

This is not easy.

This Wiki page gives some insight how the tuning can be performed.

Background

Rotorflight PID-controller works slightly differently from Betaflight. Because of this, some details in the Betaflight tuning guides (Wiki, YouTube, etc) do not apply.

LIST HERE FEATURES THAT DIFFER

Setpoint, P, I, D and FF terms explained

In this guide we will discuss these terms:

  • Setpoint: This is the desired rotational rate of your model, and this comes directly from your sticks. The goal of any PID tune is to make the actual rotation of the helicopter match the desired Setpoint in the roll, pitch and yaw axes.
  • Error: The simple difference between the Setpoint and the actual rotation rate (measured by the Gyro).
  • PID sum: The combined output of the PID controller at any moment. At every cycle of the PID controller, the resulting PID sum value is translated directly into servo/motor commands.
  • P-term: The Proportional term is some percentage of the current Error. This is used to make fine corrections in the tracking of the Setpoint.
  • I-term: The Integral is a representation of the Error over time. This is typically used to counter outside forces e.g. wind, or in the tail to counteract the torque of the main motor.
  • D-term: The Differential is calculated from the difference between the current Error and the previous Error, and acts to decrease that change. This acts as a dampener.
  • FF: The Feed-Forward is the only component which is not derived from the Error. It is simply your stick movements translated directly into a value for inclusion into the PID sum.

The beginning of this video contains an excellent explanation of these concepts: https://www.youtube.com/watch?v=WoxDbIbpP_Q

Basic Tuning

Tuning of the cyclic and tail are different processes, and must be approached in different ways. To begin with, use these safe initial values that will allow you to fly your model while tuning:

         P    I   D   FF
=========================
ROLL:    5   25   0   50
PITCH:   5   25   0   50
YAW:    10   25   0    0

Cyclic Tuning

Cyclic tuning is a 4-stage process:

  1. Adjust your Feed Forward so that your cyclic response matches the inputs from your sticks.
  2. Adjust your D-term until it has negative interactions with the inherent vibrations of your model.
  3. Adjust your I-term to account for imbalances and external factors such as wind.
  4. Adjust P-term to fine tune your Setpoint tracking.

A final optional step is to reduce your D-term if the flight characteristics feel "stiff".

At each of these steps you will increase the values until you see oscillations in your model, and then reduce them until the oscillations disappear. At any point you should use a Blackbox in order to observe these small oscillations. You will not be able to see the beginnings of issues without observing the traces. If tuning without a Blackbox, you must turn down your terms significantly once you see the oscillations on your model.

Important: You must tune roll and pitch axes independently, and the PID values on the roll axis will likely be lower than for pitch. This is because most helicopters have a higher moment of inertia along the pitch axes, due to the tail boom, battery, ESC etc.

Adjust Feed Forward

The primary control from stick to swash happens with the feedforward. Increase your FF term until it gives exactly the right amount of angular velocity for each stick position.

With the default PID gains the heli should be flyable, but feel rather unstable. Regardless, do a test flight with large roll and pitch movements, with BB logging enabled. Then, study the logs - compare the setpoint to the gyro trace. If the gyro trace is "larger", decrease FF gain - or vice versa. Repeat until the gyro trace and the setpoint are matching.

The Feed Forward value is often in the range of 50-100.

Adjust D-term

The D-term acts to dampen oscillations which occur in the PID controller. Selecting the correct D-term will allow you to use higher P and I-terms. However, the D-term will amplify any vibrations in your helicopter, so the correct value will largely depend on the mechanical setup of your model.

Increase your D-term until you start to see it oscillating during simple flight. Once this becomes visible in your logs, reduce its value by 10%.

The D-term will usually be very small, often below 50.

Adjust I-term

The I-term allows your model to counter persistent forces which are causing it to deviate from the Setpoint. For example this could be wind, lateral flight, or even a poor swashplate level.

Increase your I-term and conduct simple fast forward flight. Eventually you will see low-frequency oscillations or overshoot in your cyclic inputs. At this point, reduce the value until these behaviours completely disappear.

For a smaller helicopter the I-term could be as high as 150. Larger models will have smaller I-terms.

Adjust P-term

The P-term allows the PID controller to make fine adjustments to the Setpoint tracking, but it is the term which is most prone to high-frequency oscillations. These are hard to detect, and can cause damage to servos and tail motors. A strong P-term will cause the model to feel more precise and "robotic". Increase your P-term until your Setpoint tracking is sufficient and pay close attention to any high frequency oscillations.

A strong I-term is usually around 50.

Tail Tuning

Follow the tuning guide as for the Cyclic, but with the following changes:

  • Feed Forward: Most pilots report good response with very low or zero FF. Feed Forward can contribute to significant overshoot in the tail.
  • P-term: This primarily affects your tail's ability to track your stick inputs and respond to events such as large collective changes.
  • I-term: This term mostly affects the tail's ongoing counter-torque duty.
  • D-term: The D-term can quickly cause oscillations in the tail and should be fairly low.

TODO: Pictures