Documentation/HOWTO

/PID

How to set up the PID Controller

{i} This page is under construction!

As there are many different possibilities on how to construct and set up your copter you may need to set up the PID setting on your own. Many users who visit the IRC-channel ask how to find the correct values for the PID. In the next chapters i'm trying to explain what PID is and how to set it up correctly.

Note

Make sure to follow the instructions rested and concentrated to avoid accidents and injuries!
Make sure not to use a heading hold controller!

Chapter 1 - PID or the meaning of P,I and D

P - Proportional

P stands for proportional. In terms of controlling it means:

OUTPUT = P * INPUT

What does it mean for our control behavior?

- In general P is what keeps the copter in place. If your copter is leveled and you try to move it out of that position P will work against it and lock the copter in the leveled position. The higher P is the more the controller will try to keep the current orientation!

I - Integral

I stands for integral. In terms of controlling it means:

OUTPUT = 1/T * integral( INPUT from 0 to t )

with the transfer function: U/E*(s) = 1/(T*s) = I/s

If we put that together for a constant deviation(INPUT):

OUTPUT = I * INPUT(const) * t

T is the time we give the controller to compensate the deviation. For example we set T to 5 seconds and move the stick of our transmitter to 45°. After 5 seconds the copter should reach an angle of 45°.

What does it mean for our control behavior?

- I is what tells your copter what attitude to choose. It's essentially what pulls your copter to the horizontal position. Beside that, I can be influenced and is assigned to the sticks of your transmitter. The higher you set I the more aggressive the copter will follow, as we control the INPUT variable with the stick (giving a deviation) the copter will follow faster or slower (OUTPUT)

D - Differential

D stands for differential, it can only work in combination with a P or I controller

In terms of controlling a differentiator is:

OUTPUT = T * d/dt(INPUT)

with the transfer function: U/E*(s) = T * s

As you can see D can not control, D can only differentiate, this means D works as kind of a dampening factor in our PI controller. D watches the alternation of deviations and limits them.

Chapter 2 - Putting the stuff together

We learned in chapter one that P keeps us in place, I pulls us to a location and D softens the movement

PI Controller:

Example: The copter is currently at 45° to the left and we let the stick snap back to the middle at t=0, what happens?

At t = 0 we have a deviation of 45°, that means I shoots to the maximum. The left motor will now go to full power to compensate the error. At an angle of 0° the deviation is 0, so is I. BUT due to the inertia of the copter, it may overshoot a little. This is the point where P comes into play. If it is high enough the copter will lock into that 0° angle position and stay there, if not, the copter will overshoot 0° and go 10° to the right maybe. Now we have deviation again and I that is pushing the right motor to go back to 0° while P tries to hold it at that position but is not strong enough to hold it there. In the end we have a copter that is shaking around the hover position.

What happens if you set I too high?

- If you set I too high the copter will overshoot it's destination and start shaking

What happens if you set P too high?

- We always have small errors while hovering, maybe wind, maybe imbalanced props, maybe slight temperature differences etc. etc. to keep the orientation of the copter as good as possible P must be as high as possible. If you set it too high the copter will overreact on small errors and start working against his own movements, this may result in shaking or even a rocket like launch into the skies as we are not able to brake the motors and can only give more power to handle an error. It can also happen that your P is so strong, that your I is not able to pull your copter fully horizontal.

What if we had set a D for our example?

- If we had set a D, I would not be able to shoot to maximum in no time, this would result in a less accelerating motor and a smoother movement. The angular velocity of the copter may have been less as well so P may have been able to lock the copter in the 0° position

What happens if you set D too high?

- If you set D too high I will do basically nothing as you don't allow it to change. The other bad thing is that a too high D will ripple up the motor signal as the differential of the measured noise is always bigger than the noise itself. Amplifying this with a high D will result in a much higher load on the controllers and can even lead to burning controllers/motors/batteries while just hovering.

I'm confused, what works against what again?

I works against P, D works against I. P and I can control D can only dampen

Chapter 3 - Possibilities to change the flying characteristics

Now that we understand the basics of control technology let's take a look at our possibilities on the copter

What can be changed to optimize the flying characteristics?

PID:

P.nick

P.roll

P.yaw

I.nick

I.roll

I.yaw

D.nick

D.roll

D.yaw

RC:

RC.fact.nick

RC.fact.roll

RC.fact.yaw

Standard Features:

HW.use.dtc

Enable the use of the Dynamic Throttle Control (default: yes)

HW.use.acc

Enable the use of the Accelerometer (default: yes)

Extended Features:

HW.use.PT1.comp

HW.PT1.comp.k1

HW.PT1.comp.t1.down

HW.PT1.comp.t1.up

Chapter 4 - Setting up the PID

/!\ For the next chapters you will need a copter that has no vibration issues on the sensorboard, make sure to set up your hardware accordingly!

First of all we differentiate between yaw and nick/roll. On Yaw we control proportional (we control the angular velocity here, the more stick, the faster the copter is turning! ) On nick and roll we control the angle ( the more stick, the bigger the angle! ).

set the PID to

P.nick 10

P.roll 10

P.yaw 10

I and D to 0 on all axes.

All other options can be left to defaults.

/!\ Calibrate the copter on a flat surface, make sure the copter isn't moving while calibrating the gyros, make sure the copter is leveled while calibrating the accelerometer!

Now take the copter in your hand above your head, start the engines and the controller.

Increase throttle until the copter feels light in your hand and try to move the copter out of the leveled position.

Increase the P.nick and P.roll values until the copter starts to feel really stiff and doesn't want to leave it's orientation anymore.

For I we need to give a deviation, this is done with the sticks of your transmitter. You want your copter to follow the sticks as fast as possible but you don't want the copter to overshoot it's target. Go to about hover again and start playing on your sticks while increasing I, you will notice that the copter will follow quicker with a higher I.

For D we need to create a fast deviation difference, go to about hover again, hold the copter with one hand, with the other one you punch the copter right below one of the motors and watch how it behaves. Without D the copter should go back to the leveled position in 2-3 dampened sinus waves. Increase D till the copter absorbs the shock and simply goes back to zero without overshooting.

Congratulations, you have set up your nick and roll axes!

The yaw axis can easily be calibrated during test-flights. Yaw is only a proportional factor as long as you don't use a compass, so only P.yaw counts! Increase P.yaw until the copter holds it's orientation

Chapter 5 - Setting up your RC

You know that I and RC belong together, for that reason a high I will result in aggressive and nervous reactions on your stick input. So if you have to drive back from your airport by car and therefor you are not able to drink enough beer to calm down, simply lower the RC facts until you feel comfortable.

/!\ Too low RC facts may result in a situation where you are not able to control your copter in an appropriate way. Imagine a wind gust that takes your copter away and you are not able to counter steer, as your setting is just too smooth!

Documentation/HOWTO/PID (last edited 2011-06-23 22:58:33 by AmirGuindehi)