PID: How To...

News, rumors, and other broad discussion topics.
Post Reply
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

PID: How To...

Post by jojoguy14 »

hello everyone!

So...I want to start learning PID (just because it's a good skill to have). So, is there a PDF guide I can use to learn PID for the NXT specifically? Or just a website? Or you could just help me right here.

Thnaks!

jojoguy10
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
firstcoolbreeze
Posts: 1
Joined: 17 Jan 2011, 23:09

Re: PID: How To...

Post by firstcoolbreeze »

Hi,

The website A PID Controller For Lego Mindstorms Robots is good.
I also Googled "PID Without a PhD" and followed those links and eventually found a very nice PDF that I printed (that's why I don't have the link anymore).

I've done a little PID using leJOS.

Walt
stryker001
Posts: 125
Joined: 29 Sep 2010, 18:07
Contact:

Re: PID: How To...

Post by stryker001 »

Well, I can give a basic description of what they do, and then explain P.

PID is used to keep track of variables that can change over time, as well as adjust how much things react to a given variable. Let's say, for example, you've just built an NXT Segway using the light sensor, and it's 8:00 in the morning. You start out with a few readings right at the beginning to get an idea of what light level represents "balanced". From there, you compare each new reading to the first one and make a decision.
Let's say your robot is leaning forward a little: your reading will be higher, so you make the motors move forward a little. Let's say that your robot is leaning forward a lot: now you make the motors move forward a lot. This is P. (P stands for Proportional, so this makes sense.)
Now assuming your robot responds with enough proportion to keep itself standing up, you're good to go: your robot can stay balanced. But as time goes on, the room might get progressively brighter (the sun's till rising, right?). So your robot will start drifting forward more and more. Why? Well, if your sensor reads brighter (leaning forward), it drives forward to compensate. So as the room brightens, the calibration you did at the beginning is now useless. This is where "I" (integral) and "D" (derivative) come into play.
I'm not very good with those two yet, so you'll have to find someone who really knows what they're talking about and have then explain it. Basically, they watch for things like a drift in compensation (you lean forward more than backward, for example) and compensate for it. This could correct things like sunlight levels, or even light readings being affected by your batteries being slowly drained (a probably much more realistic problem than sunlight). As far as I understand it, "I" watches for a drift in "P", and "D" watches for a drift in "I".

Some great places to learn PID in NXT-G here (for 1.0) and here (2.0).
hergipotter
Posts: 48
Joined: 12 Jan 2011, 18:40
Contact:

Re: PID: How To...

Post by hergipotter »

stryker001 wrote: Let's say your robot is leaning forward a little: your reading will be higher, so you make the motors move forward a little. Let's say that your robot is leaning forward a lot: now you make the motors move forward a lot. This is P. (P stands for Proportional, so this makes sense.)
Now assuming your robot responds with enough proportion to keep itself standing up, you're good to go: your robot can stay balanced. But as time goes on, the room might get progressively brighter (the sun's till rising, right?). So your robot will start drifting forward more and more. Why? Well, if your sensor reads brighter (leaning forward), it drives forward to compensate. So as the room brightens, the calibration you did at the beginning is now useless. This is where "I" (integral) and "D" (derivative) come into play.
I'm with you on the P part but afaik what you said about I and D is not true. Controller adjust the value they are controlling as a function of the setpoint minus the actual value. So they are always trying to reach the setpoint. So in our example, if the ambient light changes, there's no chance for the controller to know that it needs a new setpoint. I and D have nothing to do with that. I stands for Integral. It's the part of the controller that keeps track of the sum of the error (setpoint minus actual value). D stands for Derivative, so it keeps track of the change of the error. Imo it's really good described here: http://www.inpharmix.com/jps/PID_Contro ... obots.html
link to my youtube channel under my avatar!
gloomyandy
Posts: 323
Joined: 29 Sep 2010, 05:03

Re: PID: How To...

Post by gloomyandy »

To create a really good PID controller there are a lot of things you may have to deal with. This chapter is a pretty good description of some of the issues and how to deal with them...
http://www.cds.caltech.edu/~murray/cour ... om-ch6.pdf

Andy
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: PID: How To...

Post by HaWe »

what values would be the best choice for P,I,D to start with using RotateMotorPID() ?

Code: Select all

void RotateMotorPID  ( 
  byte  outputs,  
  char  pwr,  
  long  angle,  
  byte  p,  
  byte  i,  
  byte  d   
 ) 
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests