How to tune a rate PID

Here's a tutorial on exactly what PID control does for this type of system. I know I'm probably preaching to the choir for most of this, but for anyone that's never had any formal training on control systems, maybe this will help put things together. This is a brief discussion of how to do PID yaw control on a traditional heli's rate yaw controller, but it works with all axes in rate mode.

This tutorial is based on a discussion about the problem of traditional helis not holding heading the way they're supposed to with the APM in control. The problem we're seeing is that the heading drifts, and the heli makes slow circles against the direction of rotor spin. Here's how PID fixes it.

PID stands for Proportional, Integral, Derivative control. The controller takes the system error (the desired value - the actual value), and assigns a system response based on the error, applying feedback to reduce the error to zero over time (basically, making it do what you want it to do).

Each component of the controller does something different. The Proportional control is assigned directly to the error variable we're trying to control (in this case, the yaw rate, or the speed that the helicopter is turning at), and directly assigns a response based on the error in the system. The intergal component integrates the error (adds it up over time) to force the error to zero when the proportional controller can't correct every error perfectly. The derivative component monitors how fast the error is changing, and applies feedback to slow that change down to stop oscillations, or dampen the system.

Basically, the proportional component directly assigns a response based on how large the system error is (desired rate - actual rate). For yaw, the reason the heli spins is because a proportional controller can't adjust its self for non-linearities in how a helicopter flies. If the response isn't modeled perfectly (which it can't be because helis are so non-linear), there will be a constant rate error in the output. Basically, it will always slowly spin.

The integral component is what's designed to fix that. Just like a mathematical integral, the error integral adds up over and over every cycle. The response of the integral controller gets stronger and stronger the longer the error sticks around. For nonlinear systems, this positive feedback makes up for imperfections in the proportional control, and forces the error to zero.

The drawback of integral control is that while that error is building up, once the system hits zero error, that integral component is still built up, and applying its control to the system. As a result, the integral controller causes the system to fly through the target desired value and overshoot. This causes oscillations in the system, necessitating a third controller component to counter those unwanted effects.

That's what the D component is for. The D component just looks at how fast the error is changing, and applies negative feedback against that change. The end result is when the error is approaching zero very quickly as a result of the I component doing its job properly, the D component subtracts against the error that's driving the other controllers, giving them a smaller value to work with. This makes the other controllers slow their roll as they approach the disired value, eliminating the oscillations. One example of a mechanical derivative controller is the shock absorbers in your car's suspension.

 

"Get to the point, Chris! How do I tune the yaw rate controller!?"

 

Ok fine! Start by setting the I and D components to zero. Then, set the P component at something fairly low. The result will be that the heli will make slow circles to one direction or the other, opposite of which way the blades spin.

Then, start raising that P value. You're not going to get rid of the spinning completely, so don't try. Just increase P intil the heli starts shaking. Then back it down just until the shaking stops.

At this point, the P component is set, and you'll probably never touch it again, unless something in your rig changes significantly.

Now, start raising the I component, because that's what's going to get rid of the drift in your heading. Take it up until the drift goes away completely. While you're doing this, the heli is going to shake back and forth when you put in stick inputs. If it starts shaking and doesn't stop after a second or two, start taking I back down, but as long as the shaking settles after a second or so, you're ok. We're going to use the D component to get rid of it, so don't worry.

Once the drifting is gone, all you have to do is bring up the D component until that annoying hunting goes away. At that point, it should be solid as a rock.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Generally whats the ratio relationship between the three values P , I and D for an average (if that makes any sense at all). Is it fair to say P > I > D  is there are ratio between them like P = ~ 2I = ~4 D ?

  • Assume I've found Stabilize and Rate PID settings, what should I write in Loiter Speed and Loiter PID and WP PID?

    Should I also try to calibrate and do hand test for Loiter and WP part? How I can set them from PIDs I found out working well for Stabilize?
  • Developer

    Nice tutorial!

  • Thanks for this - it makes a lot of sense. Getting my head around PIDs has been the hardest part of this whole journey.

This reply was deleted.

Activity