PID

From MultiWii
Jump to: navigation, search

MultiWii uses closed loop controllers to ensure its stability and maneuverability.

Like most multirotors, it uses Proportional-Integral-Derivative (PID) controllers.

PID : Roll, Pitch, Yaw

When the MultiRotor orientation is changed in any pitch/roll/yaw axis, the gyros indicate an angular change from it's initial position. The MultiRotor controller tries to correct the error calculated between a measurement at the controller output (measured by the gyros) and an input set point (position of the stick), and drives the motors to attempt to return the MultiRotor to its initial position.

This combination of the measured angular deviation and sampling the change over time provides enough information for the controller to drive the motors to return equilibrium with only a gyroscope : this is the default Acro Mode

Basic PID Tuning

Default values should be used as a starting point, this will help you to know the difference after changing some parameters. Those value are well suited for the average multirotor.

  1. Ensure CofG is in the middle of your copter, move battery to get it there.
  2. Set motors running at approx 50% if you have props on be very careful, check GUI trace for an almost flat line from gyro and acc
    1. if trace is dancing all over the place you have vibrations issues and it needs to be sorted before proceeding.

Keep in mind that P is the dominant part of PID and gets you in the ballpark for good flight characteristics.

With props on:

  1. Set PID to the their default value
  2. Hold the MultiRotor securely and safely in the air
  3. Increase throttle to the hover point where it starts to feel light
  4. Try to lean the MultiRotor down onto each motor axis
    1. You should feel a reaction against your pressure for each axis.
    2. Change P until it is difficult to move against the reaction.
    3. Now try rocking the MultiRotor along the Pitch axis (front to back). Increase P until it starts to oscillate and then reduce a touch.
  5. Repeat for Yaw Axis.

Without the auto-stabilisation mode engaged, you will feel it allow you to move over a period of time. That is OK.

Your settings should now be suitable for flight.

Advanced Tuning - understanding impact of P, I and D

P : this is the amount of corrective force applied to return the MultiRotor back to its initial position

The amount of force is proportional to a combination of the the deviation from initial position minus any command to change direction from the controller input. A higher P value will create a stronger force to resist any attempts to change it's position. If the P value is too high, on the return to initial position, it will overshoot and then opposite force is needed to compensate. This creates an oscillating effect until stability is eventually reached or in severe cases becomes completely destabilised.

Increasing value for P:

  • It will become more solid/stable until P is too high where it starts to oscillate and lose control.
  • You will notice a very strong resistant force to any attempts to move the MultiRotor.

Decreasing value for P:

  • It will start to drift in control until P is too low when it becomes very unstable.
  • Will be less resistant to any attempts to change orientation.

Aerobatic flight: Requires a slightly higher P value

Gentle smooth flight: requires a slightly lower P value


I : this is the time period for which the angular change is sampled and averaged

The amount of force applied to return to initial position is increased by the I factor the longer the deviation exists until a maximum force value is reached. A higher I will increase the angular hold capability.

Increasing value for I:

  • Increase the ability to hold overall initial position and reduce drift, but also increase the delay in returning to initial position.
  • Will also decrease the importance of P.

Decreasing value for I:

  • Will improve reaction to changes, but increase drift and reduce ability to hold position.
  • Will also increase the importance of P.


Aerobatic flight: Requires a slightly lower I

Gentle smooth flight: Requires a slightly higher I


D : this is the speed at which the MultiRotor is returned to its original position

Increasing value for D: Improves the speed at which deviations are recovered

  • With fast recovery speed comes a higher probability of overshooting and oscillations
  • Will also increase the effect of P

Decreasing value for D:

  • Reduces the oscillations when returning any deviations to their initial position
  • Recovery to initial position becomes slower
  • Will also decrease the effect of P

Aerobatic flight: Increase D

Gentle smooth flight: Decrease D

Advanced Tuning - practical implementation

You will have to accept a compromise of optimal settings for stable hover and your typical mode of flying. Obviously factor it towards your most common style.

For Aerobatic flying

  1. Increase value for P until oscillations start, then back off slightly
  2. Change value for I until hover drift is unacceptable, then increase slightly
  3. Increase value for D until recovery from dramatic control changes results in unacceptable recovery oscillations
  4. P may now have to be reduced slightly

For stable flying (RC)

  1. Increase value for P until oscillations start, then back off slightly
  2. Change value for I until recovery from deviations is unacceptable, then increase slightly
  3. Decrease value for D until recovery from dramatic control changes becomes too slow. Then Increase D slightly
  4. P may now have to be reduced slightly

For stable flying ( AP / FPV)

  1. Increase value for P until oscillations start, then back off slightly
  2. Change value for I until recovery from deviations is unacceptable, then increase slightly
  3. Decrease value for D until recovery from dramatic control changes becomes too slow. Then Increase D slightly
  4. P may now have to be reduced slightly

Other factors affecting PID

Taking known good PID values from an identical configuration will get you close, but bear in mind no two MultiRotors will have the same flying characteristics and the following items will have an impact on actual PID values:

  • Frame weight /size / material / stiffness
  • Motors - power / torque /momentum
  • Position - Motor-->motor distance
  • ESC / TX - power curves
  • Prop - diameter / pitch / material
  • Balancing
  • Pilot skills

PID : Level

This will influence the flight characteristic with an accelerometer : this is Level Mode

  • P is the dominant part of autolevel mode.
  • I will tell how much force must be applied when the mesured angle error persit
  • D is used to clamp the maximum correction for autolevel mode

Increase value for P will make the autolevel mode stronger

For smooth operation the sum of P axis + P level should stay near the default value : if you decrease P for Roll and Pitch axis you can increase P Level