Jump to content
  • Advertisement
Sign in to follow this  
FFMG

PID controller questions - (Autopilot).

This topic is 3413 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have been looking at various PID functions on the net as well as trying to get up to speed with what it actually does, (I did not what a PID controller was until yesterday :)) Before I go too far in my reading I was hoping to ask a few questions to make sure I understand what it is used for. 1- The algorithm takes a 'current' value, a 'target' value as well as some elapsed time. What is the 'control' value been returned? For example, (in an aircraft), if my current heading is 0 and my target heading is 45, what is the control value going to tell me? 2- In the example above, how would I use the control value to set my aileron value? 3- Some documents mention a 'self tuning' algorithm, how would they work? Can any one point me to some C/C++/C#/VB code? Many thanks FFMG

Share this post


Link to post
Share on other sites
Advertisement
1: I would need to see the algorithm you're looking at, but I would expect the return value to be what you should pass as the 'current' position for the next timestep.

2: 'Control value' - 'current position' specifies the angle the heading should change with during the next timestep, so the aileron angle should be set to the value needed to achieve that heading change according to your aircraft dynamics model.

3: You're probably thinking of the Ziegler Nichols method (I think it was written like that). It's basically just a cookbook with empirical ratios for the three parameters in a PID controller that will give you an "OK" stability. It'll usually cause some overshoot and ocillation though, which isn't exactly desirable in an aircraft autopilot, but it is a decent basis for further manual tuning.

Share this post


Link to post
Share on other sites
Quote:
Original post by olemars
1: I would need to see the algorithm you're looking at, but I would expect the return value to be what you should pass as the 'current' position for the next timestep.

2: 'Control value' - 'current position' specifies the angle the heading should change with during the next timestep, so the aileron angle should be set to the value needed to achieve that heading change according to your aircraft dynamics model.

3: You're probably thinking of the Ziegler Nichols method (I think it was written like that). It's basically just a cookbook with empirical ratios for the three parameters in a PID controller that will give you an "OK" stability. It'll usually cause some overshoot and ocillation though, which isn't exactly desirable in an aircraft autopilot, but it is a decent basis for further manual tuning.


1- When that's part of the problem, I am don't really have many functions to look at. I see there are a few here, (http://www.gamedev.net/community/forums/topic.asp?topic_id=401501&whichpage=1�), but I am not 100% sure how I must use such a class. It does output a number and the closer I am to my target heading the smaller the number, (until it reaches 0), but I am not sure how to translate that number into an aileron position.

2- Make sense.

3- I was thinking of some function that would allow me to 'tweak' my own PID function/class. For example, I would run it myself and do a 360 degree turn in 1 minute and it would output some values. But I guess I don't need to worry about it for now.

FFMG

Share this post


Link to post
Share on other sites
Ok I looked at a few functions and the 'basic' formula seems to be the same for all.

For example, using this topic as an example.


m_E2 = m_E1;
m_E1 = m_E0;
m_E0 = target - current;

float const e01 = m_E0 - m_E1;
float const e12 = m_E1 - m_E2;
float const p = m_P * e01;
float const i = m_I * m_E0 * dt;
float const d = m_D * ( e01 - e12 ) / dt;

m_ControlValue += p + i + d;



the error, (m_E0), is the difference between the target value and the current value. The others m_Ex are 'previous' error values.

But what are m_I, m_P and m_D used for? How can I use them to 'tweak' my autopilot?

Using my turn example, I want to set my turn bank between -18 and +18 degrees, (that's pretty much the same for most aircrafts).
I will then set the ailerons to match that turn value.

In the formula above, my 'target' is always 0, (I don't want to turn anymore) and my 'current' is the number of degrees away I am from my target heading.
So if I am currently heading 180 and my target heading is 135 then my target heading difference is 0 and my current heading difference is -45

So what values would I set for m_I, m_D and m_P to achieve this?

Many thanks

FFMG

Share this post


Link to post
Share on other sites
The m_P, m_I and m_D coefficients determines the controllers response to a given input variable (P, I and D refers to the Proportional, Integral and Differential(?) components of the controller). The values are not intuitive and you basically have to tune them until you get the behaviour you want. That's where the Ziegler-nichols method is useful. A bit of googling will probably turn up lots of tuning examples and guides.

A quick look over at wikipedia turns up this:
http://en.wikipedia.org/wiki/PID_controller

that should provide a starting point at least.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!