Board index FlightGear Development Aircraft Autopilot and route manager

Why no Ki or Kd in PID controller?????

Designing a stable autopilot is one of the hardest things. Need help?

Why no Ki or Kd in PID controller?????

Postby Octal450 » Wed Jan 25, 2017 8:35 pm

As the title said, how come FGFS's PIDs don't use Ki or Kd?

I know PI simple has Ki.
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Why no Ki or Kd in PID controller?????

Postby zakalawe » Wed Jan 25, 2017 11:24 pm

My understanding is the original author, who was versed in control theory, felt the values provided in our PID controller were the ones normally used in industry and standard practice. I must admit I have never questions this statement, but I have often wondered about having simple Ki and Kd terms. The PI controller does have Ki (from memory), which gives a rather odd contrast between the two
zakalawe
 
Posts: 1152
Joined: Sat Jul 19, 2008 4:48 pm
Location: Edinburgh, Scotland
Callsign: G-ZKLW
Version: next
OS: Mac

Re: Why no Ki or Kd in PID controller?????

Postby curt » Wed Jan 25, 2017 11:36 pm

The controller uses the Ti and Td parameters to control the integral and differential behavior. Roughly: Ki = Kp / Ti and Kd = Kp * Td. If you look around the web for basic PID tutorials and tuning tutorials you may see a few places that suggest that a controller with specific fixed Ti and Td values will have a specific behavior (in terms of convergence versus overshoot.) So the end result is you can pick Ti and Td ahead of time without knowing anything about your system and then tune a single Kp number to scale for your specific application. Often people suggest a value of 3 for Ti as a good balance between convergence speed and overshoot. PID tuning is a deep deep rabbit hole, but this is the logic behind the choice of configuration parameters.

All that said, in my own real world UAV work, I've moved to a more standard formulation of the PID controller and actually like it better. I haven't proposed it to the FlightGear project, but it might bring FlightGear gain tuning strategies more in line with the literature.

The velocity form of the PID algorithm (which is the flightgear default) doesn't suffer from any integrator wind up issues (one of it's strengths), but is very sensitive to a noisy input signal.
Aerospace Engineering and Mechanics
University of Minnesota
curt
Administrator
 
Posts: 1174
Joined: Thu Jan 01, 1970 12:00 am
Location: Minneapolis, MN

Re: Why no Ki or Kd in PID controller?????

Postby Octal450 » Thu Jan 26, 2017 3:25 am

Hmm. Interesting.
I think it might be a nice thing to add Ki and Kd, at least optionally.

I've noticied it's very very sensitive to noisy input signal, I'm trying to use a conditional max-rate-of-change to address this, as it cause some stability issues for really complex 3 or 4 stage PIDs I'm trying to build for ITAF.
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Why no Ki or Kd in PID controller?????

Postby curt » Thu Jan 26, 2017 12:11 pm

Hi itouchpods, the pid code is constructed around the Ti and Td parameters, but there is an equivalency between Ti and Ki as well as Td and Kd via the formulas in my previous message. The advantage to this approach is that Kp becomes something like a global gain on the whole system. FlightGear does support a simple PI controller which is the more classic form, however, it's very simple and there are many improvements that could be made to it (for example I don't think it has any anti-integrator windup protection.) Longer term it would be good to improve the simple pi controller to be a full fledged pid controller in the classic form.

By the way, I'm slightly curious where you are using 4 cascading stages in your controller? I've never used more than 2.
Aerospace Engineering and Mechanics
University of Minnesota
curt
Administrator
 
Posts: 1174
Joined: Thu Jan 01, 1970 12:00 am
Location: Minneapolis, MN

Re: Why no Ki or Kd in PID controller?????

Postby Octal450 » Thu Jan 26, 2017 1:21 pm

Makes sense.

I'm doing this in for more realistic FLCH in my ITAF. In reality, FLCH CLB minimums is not a set pitch angle, but 100fpm. So I do it this way:

Target speed/10sec predict airspeed/mach to VS.
VS to target pitch degree.
Target pitch degree to elevator.

That is three 3 stage one.
The four stage is a secret. I can't leak it quite yet.
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Why no Ki or Kd in PID controller?????

Postby Soitanen » Thu Jan 26, 2017 2:59 pm

Pitch channel can be easily controlled via normal load factor, that requires PID for elevator control. All other inputs can be calculated via normal equations, without magic PID controllers.
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 6:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: Why no Ki or Kd in PID controller?????

Postby Octal450 » Thu Jan 26, 2017 5:01 pm

Care to explain more about normal equations?
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Why no Ki or Kd in PID controller?????

Postby Soitanen » Sun Jan 29, 2017 10:16 am

it0uchpods wrote in Thu Jan 26, 2017 5:01 pm:Care to explain more about normal equations?

Sure, I'll show in reverse direction.

1. Elevator control.
Input - target G-load
Reference - current G-load
Output - elevator position
Here we really need PID controller. Though in my 738 autopilot I use only simple PI controller without D.

2. G-load calculation.
Input - target pitch
Reference - current pitch
Output - target G-load
Simple gain + correction for bank angle (1/cos(roll)).

3. Target pitch calculation.
Input - target vertical speed, alpha, TAS.
Output - target pitch.
Expression, which uses relationship between TAS, alpha and vertical speed.

This chain is stable independent on any mode (VS, LVL CHG or something else). You just feed target VS into calculation and get aircraft follow this value.

4. This is calculation of vertical speed. It depends on selected AFDS mode. Simpliest - just VS hold.
If we say about LVL CHG, I use relationship between TAS, alpha, total thrust and total drag, weight of aircraft and target speed difference. You can see example in 738 737-fcc-a.xml lines 485-527. No PID. Earlier I used PID for this, but it's good for automatic, but bad for FD mode. If you don't follow FD bar very good, it start to go somewhere in bad position, due to nature of PID controller.
Boeing 737-300. Reworked cockpit, FDM, autopilot and much more. WIP.
Boeing 737-800. WIP. Canvas PFD and ND.
Antonov An-24B. Made from scratch. Very good FDM. 3D model by Adrian. WIP.
Project Russia (some cities, based on OSM with custom objects).
Soitanen
 
Posts: 489
Joined: Sat Jun 16, 2012 6:50 am
Location: Saint-Petersburg, Russia
Version: git
OS: Linux Mint 17

Re: Why no Ki or Kd in PID controller?????

Postby Thorsten » Sun Jan 29, 2017 10:42 am

To give a visual picture of what Soitanen just said:

If you want to make a ball follow a certain curve, you can create a suitably formed trough, and it's always going to roll down the lowest point of that trough eventually - but it might oscillate around that or bounce now and then. It has a lot of dynamics. That's the PID controller.

However, if you know the curve up-front and don't need to adapt to anything, you can set it on a rail and simply move it along, giving it no dynamics. That's the equation.

You use a PID controller only if you need to adapt so something which you can't compute in your equation, otherwise it's an overkill.
Thorsten
 
Posts: 11090
Joined: Mon Nov 02, 2009 8:33 am

Re: Why no Ki or Kd in PID controller?????

Postby zakalawe » Sun Jan 29, 2017 2:44 pm

Soitanen wrote in Sun Jan 29, 2017 10:16 am:Sure, I'll show in reverse direction.

This chain is stable independent on any mode (VS, LVL CHG or something else). You just feed target VS into calculation and get aircraft follow this value.

4. This is calculation of vertical speed. It depends on selected AFDS mode. Simpliest - just VS hold.
If we say about LVL CHG, I use relationship between TAS, alpha, total thrust and total drag, weight of aircraft and target speed difference. You can see example in 738 737-fcc-a.xml lines 485-527. No PID. Earlier I used PID for this, but it's good for automatic, but bad for FD mode. If you don't follow FD bar very good, it start to go somewhere in bad position, due to nature of PID controller.

That's a really nice explanation, thanks for providing it!
zakalawe
 
Posts: 1152
Joined: Sat Jul 19, 2008 4:48 pm
Location: Edinburgh, Scotland
Callsign: G-ZKLW
Version: next
OS: Mac

Re: Why no Ki or Kd in PID controller?????

Postby Octal450 » Sun Jan 29, 2017 4:09 pm

I agree!
Thanks @Soitanen, @Thorsten

I'll try to work on this, and report how it goes.

Cheers
J
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm

Re: Why no Ki or Kd in PID controller?????

Postby curt » Sun Jan 29, 2017 4:19 pm

Beware, it seems like any time I have a conversation with anyone about PID and flight controllers it causes me a lot of work (and rework)! :-)
Aerospace Engineering and Mechanics
University of Minnesota
curt
Administrator
 
Posts: 1174
Joined: Thu Jan 01, 1970 12:00 am
Location: Minneapolis, MN

Re: Why no Ki or Kd in PID controller?????

Postby Octal450 » Tue Jul 04, 2017 2:08 am

Quick update....

I actually disagree with Soitanen here about building the pitch axis almost fully with expressions filters...

Let me explain:
* ALT HLD, G/S, V/S, LAND/FLARE modes command a vertical speed demand of either altitude deviation/glideslope deviation/direct input/linear to height. These are done with a filter, or just a different <reference>.

* FLCH Speed/Mach by Pitch/FPA require a PID controller, since that offers the best compromise between accuracy/smoothness/stability. The most important here is the FLCH controller, which takes the input by the lookahead airspeed/mach, and reference of a smoothed airspeed/mach FCU. This is output as a vertical speed demand, and I find a Kp of -50, Ti 2.5, Td 0.001 makes this very stable. This PID works well even if the V/S demand is not followed to closely, and is quick enough to sense faster inputs, and error change by winds, etc.

* Vertical Speed demand is converted to pitch degree by another PID controller, and the integrator can be left as before, sincethis is only used by the autopilot! When the APs are off, and the Flight Director is being flown manually. I use a filter which takes the different V/S demands, and depending on the active AFDS mode, outputs to a common V/S demand. This current V/S is then subtracted from the common V/S demand, giving the difference in target V/S, and current V/S. Since I need to output this as a pitch degree demand, This is also not linear, so I multiply by a number, which changes depending on mach. At higher mach, the V/S changes quicker with the same pitch rate, as in lower speed. This makes a PID free V/S command, and the PIDs driving the V/S demand do not need much integrator, so the "drift" problem is almost gone, and unlike target pitch from V/S, the FD can move quickly, so even if a drift occurs, when the pilot begins to correct, the bar corrects rather fast, and the experience is still smooth.

I took this a step farther, and in my A320Family, I actually have a FBW system which commands a pitch-rate and roll-rate demand, so we can simply drive the target-roll-rate and target-pitch-rate directly from the autopilot, instead of driving the elevator and aileron directly. This way further reducing this effect, as pitch-rate is closer to linear than pitch-degree is, as a pitch rate of 0, will generally have a FPM rate of near 0.

Kind Regards,
Josh
Waste of time. Goodbye forever.
Octal450
 
Posts: 4398
Joined: Tue Oct 06, 2015 12:51 pm


Return to Autopilot and route manager

Who is online

Users browsing this forum: No registered users and 1 guest