Go Down

Topic: Arduino PID Library (Read 59 times) previous topic - next topic

br3ttb

Quote
- Some autopilot claims that they are adaptive. They can learn the characteristics of the boat. I know you cannot give us an adaptive controller, you told us that,  but can you hint to me how this is done. Is it still a PID regulator that is used with some other program tuning the parameters or do they use some other type of controller? "


I don't think you need an adaptive controller for this situation per se.  I'm assuming that what they mean when they say "Adaptive" is that you can put it in a big boat or a small boat, and it will figure out if it needs to control aggressively or conservatively.  once the controller dials in on what type of control it needs, I would guess that it doesn't do much adapting.  this is good news for you.  you can use a pid controller and have a tuning period. "this control is a little too aggressive, let me back it off" or whatever.  after that, you should be all set.

Quote
- I have seen that some boat autopilots does not need a rudder feed-back. I suppose that all PID regulators do need some sort of feed-back. Do you have any idea how they can do this?


ok, first let me put both single-loop and cascade into words.
single loop:  "I'm not on heading.  let me adjust my signal to the rudder until I get the heading I need"
cascade: "I'm not on heading.  I need the rudder to be 5degrees off center. rudder controller, look at the rudder position and adjust until I get what I asked for"

so what's the difference?  well, in the first situation, there's no guarantee that you'll get the same rudder position every time you send, say, 50%.  actually, it's likely that you won't, because of "slop" or play in the rudder.  in the second situation, we have a dedicated controller whose job it is to make sure we get exactly what the heading controller asks for.

so the cascade is more precise because you get the rudder position you want really quickly.  does that mean that it won't work the other way?  nope.  in the single-loop setup, the heading controller is going to keep adjusting it's output until it gets what it wants.  so if sometimes centered is 50%, and other times it's 55%, it doesn't really matter. the controller will eventually find the output that gets it what it wants.

the problem is that it will have more trouble getting to the desired heading than the cascaded way.  so cascade is more complicated, but if done right it gives you better control.

(a note on nomenclature.  the cascaded controllers can be referred to as Master-Slave, Outer-Inner, or Primary-Secondary depending on who you ask.)

hope this helps


Flotec

Thank you very much br3ttb for your answer. The more expensive autopilots are really adaptive in a way that they automatically figure out the boats characteristics and adjust for that. They can even adjust for changing weather conditions. So my question is do they still use a PID controller with some intelligent program to change Kd, Ki and Kp or do they use some completely different controller? What is exactly an adaptive controller?

br3ttb

Quote
So my question is do they still use a PID controller with some intelligent program to change Kd, Ki and Kp or do they use some completely different controller? What is exactly an adaptive controller?


adaptive control is an umbrella term for a controller that changes its behavior on the fly.  how do they do this?  I have no idea.  they could use a neural network and it would fit this definition! (although fitting one on a microcontroller would be an impressive task)

the pid library has been designed with adaptive control in mind.  Example 2 on the wiki uses a form of adaptive control, switching between aggressive and conservative tunings on the fly.

so, while I don't know how they do it, I have a feeling you could use pid.  as long as you're ok with some experimentation you should be fine.  "I know that THESE parameters work well in calm seas, while these work well in 5ft swells.  I'll automatically switch between them, or even interpolate between them, depending on the situation I'm in." if that isn't enough you can even bring in some Feed Forward control, but it's probably better to cross that bridge when we come to it.

now I should add here that I'm not a seaman, so I have very limited knowledge of "changing weather conditions" and how they affect the navigation of the boat.  my intuition is that the pid library should give you
the tools you need. if not, you've spent 0$ and learned a little about control.  ;)

RodW

#38
Mar 15, 2009, 11:45 am Last Edit: Mar 15, 2009, 11:45 am by rodw Reason: 1
Hi guys, I am a newcomer to the Arduino and this is my first post. I purchased one to do a few chores as part of a Car PC installation and have just about got the main hardware and software elements sorted out enought to actually start putting some stuff together.

I was actually thinking about addng a climate control system to my car while driving earlier today and new there were some intergrative vcontroller solutions out there and now I have found one for the Arduino! By the sound of this thread, this is exactly the sort of software I would need to add climate control.

However, in the case of airconditioning, there are two parameters to adjust, one is the temperature setting and the other is the fan speed. Could this library be adapted to control two variables in unison? to achieve the desired temperature setting?

br3ttb

#39
Mar 15, 2009, 02:32 pm Last Edit: Mar 15, 2009, 03:18 pm by br3ttb Reason: 1
Quote
However, in the case of airconditioning, there are two parameters to adjust, one is the temperature setting and the other is the fan speed. Could this library be adapted to control two variables in unison? to achieve the desired temperature setting?


I don't see why not.  you would probably just need to do some Post-Processing on the output.  so the pid would still be computing one number, but you would massage it a little.  the easiest example of this would be to take the output of the controller and send it to BOTH the fan speed and temp setting.  so as the pid output gets larger, you ask for colder air and more of it, simultaneously.

SO:

Code: [Select]
void setup()
{

  pid.SetOutputLimits(0,255); //tell the PID to range the output from 0 to 255 (this is the default range, so this really isn't necessary(
  Output = 0; //start the output at ALL off and vary from there
  pid.SetMode(AUTO); //turn on the PID
}


void loop()
{
  //give the PID the opportunity to compute if needed
  Input = //cabin temp
  Setpoint = //desired temp
  pid.Compute();

  FanSpeed = Output;
  TempSetting = Output;
}


note, you could also set this output massaging to first speed up the fan, then adjust the temp, or vice-versa, but that would make tuning the controller (finding the right P_Param, I_Param, D_Param) a bit more difficult.

Brett

Go Up