Problem PD control vs PID control, integral term help

Zatnikitelman

Addon Developer
Addon Developer
Joined
Jan 13, 2008
Messages
2,303
Reaction score
6
Points
38
Location
Atlanta, GA, USA, North America
In building a simple autopilot for my launcher, I've [somehow] been able to figure out Proportional Derivative control which has worked well for the single-axis roll program, and single-axis pitch commands. However, when I pitch back from 90 degrees there's a slight heading offset from my target. During manual flight, it's a simple matter to add some yaw and get spot-on, but I've been unable to tune the yaw-controller using PD. So I'm wondering if an integral term would help? Just throwing it in there would be fairly trivial at this point, but I'm a bit unsure on a few things.

This is the reference I'm using: [EDIT] link no longer works :( [/EDIT]
When it explains the Integral term, it talks about iMin and iMax. What exactly do these do? Since I'm concerned about heading, would these be 0 and 360 respectively? Or 180 and -180 becasuse the error of a heading can never be more than 180 degrees?

Also, it mentions that integral control is sensitive to sampling rate (derivative too, but since Orbiter spits it out nice and clean with getAngularVelocity, it doesn't seem to hurt too much). Just how sensitive? It'd be pretty impossible to guarantee an even sampling rate for the end-user unless they ran Orbiter in fixed time-steps.

And finally, would I tune this controller the same as the PD controller? I've gotten the hang of altering one gain value one way, then if that didn't work, go the other way and keep going until I got the desired results, then go back to the other gain, then come back to the first one etc. until it worked well enough for me. Will this just be a matter of the same thing? Alter one, alter next one, alter third, then come back to first until it works?
Thanks for any help,
Zatman

P.S. if you're wondering why I skipped over Integral in the first place, it was because I didn't understand the terms, but had seen PD controllers elsewhere and started there which has worked well so far.
 
Last edited:
Yes, adding the integral will remove steady state error. It will also decrease the stability of the system

With tuning it You can a) do some nice and complicated maths or b) the same what you did before

You can change the sampling rate by only sampling at certain times. Make sure your sampling rate is at least twice the frequency of any inputs.

As with your heading iMax and iMin, Try them both and see what happens

Basically I can assure you , unless you want to do some complicated maths, guess and check is the best way.
 
In building a simple autopilot for my launcher, I've [somehow] been able to figure out Proportional Derivative control which has worked well for the single-axis roll program, and single-axis pitch commands. However, when I pitch back from 90 degrees there's a slight heading offset from my target. During manual flight, it's a simple matter to add some yaw and get spot-on, but I've been unable to tune the yaw-controller using PD. So I'm wondering if an integral term would help? Just throwing it in there would be fairly trivial at this point, but I'm a bit unsure on a few things.

This is the reference I'm using: http://www.embedded.com/2000/0010/0010feat3.htm
When it explains the Integral term, it talks about iMin and iMax. What exactly do these do? Since I'm concerned about heading, would these be 0 and 360 respectively? Or 180 and -180 becasuse the error of a heading can never be more than 180 degrees?

Also, it mentions that integral control is sensitive to sampling rate (derivative too, but since Orbiter spits it out nice and clean with getAngularVelocity, it doesn't seem to hurt too much). Just how sensitive? It'd be pretty impossible to guarantee an even sampling rate for the end-user unless they ran Orbiter in fixed time-steps.

And finally, would I tune this controller the same as the PD controller? I've gotten the hang of altering one gain value one way, then if that didn't work, go the other way and keep going until I got the desired results, then go back to the other gain, then come back to the first one etc. until it worked well enough for me. Will this just be a matter of the same thing? Alter one, alter next one, alter third, then come back to first until it works?
Thanks for any help,
Zatman

P.S. if you're wondering why I skipped over Integral in the first place, it was because I didn't understand the terms, but had seen PD controllers elsewhere and started there which has worked well so far.

AFAIK, those iMax and iMin values are there to avoid run-away conditions in the controller. I.e. if the controlling value (e.g. RCS) is not strong enough to change the controlled value (e.g. heading), the integrator part would build up too far and thus overshoot the setpoint. Turning the other way 'round, the build up would be even higher and overshoot even more...
It is just a kind of safety device, but IMHO a bad approach to put them in right from start. It is better to tune the loop without limiters and put those dampers in later on, just to ensure stable conditions in all scenarios.

If you want to play with a PID controller in Orbiter to get the hang of the parameters, you can try this - source included.

As for the tuning... start with very low I and D, just use P to get to stable conditions (how much "uumpf" you need to get to your setpoint). Then adjust D to compensate dynamics (how fast your system should react to changes). At last adjust I to compensate for delays and offsets in the system (how fast the actual value should try to "climb" to the setpoint).

regards,
Face
 
First, thanks so much for the help, even if it's not working yet, I am at least starting to understand more about this.
However, I still can't seem to tune it. I've tried tuning the P_Gain with I and D set to both 0 and 0.01 and no matter what P value I set, it always overshoots and oscillates, but not at a constant frequency. I've used values from 0.001 up to 10e20, and it seems the higher I go, it oscillates a bit less initially, but how high is too high? Should I try max double?
Thanks again for any and all help,
Zat
 
First, thanks so much for the help, even if it's not working yet, I am at least starting to understand more about this.
However, I still can't seem to tune it. I've tried tuning the P_Gain with I and D set to both 0 and 0.01 and no matter what P value I set, it always overshoots and oscillates, but not at a constant frequency. I've used values from 0.001 up to 10e20, and it seems the higher I go, it oscillates a bit less initially, but how high is too high? Should I try max double?
Thanks again for any and all help,
Zat

What is your actuator value (e.g. elevator deflection) and what is your controlling value (e.g. aircraft pitch)? You can't use PID controllers to control arbitrary long control loops.

Best is to go over 2 steps. I.e. if you want to hold a certain heading, first you have to control your turn rate. You can control your turn rate with aircraft roll, which in turn is controlled by aileron deflection.
So you could make a loop for controlling deflection to reach a certain roll level. This roll level is commanded by a second loop to reach a certain turn rate. This turn-rate is commanded by a third loop to reach a certain heading.

Of course you can try to do it by combining 2 loops into one, but this would make your controller sensitive to changes in environment. E.g. changing mass or inertia may cause your perfectly tuned loop to oscillate like crazy.

Also, how did you implement the controller? There are some pitfalls you could fall into when implementing digital PIDs...

regards,
Face
 
Back
Top