Go to Post ... One of the things I happen to like about the Chief Delphi community is that at every competition I go to, someone recognises me and comes over to say hi ... I meet someone new, they meet someone new, and it's win/win. - EddieMcD [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 25 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 24-04-2013, 19:46
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
PID

I have been working with new sensors a lot lately and what I have noticed is that for a lot of them you need to use PID. I know that it is for feedback of some sort, but what does the P, I, and D do and how do you configure them to meet your robots needs. That is what I am having a hard time understanding?
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 24-04-2013, 20:06
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PID

Quote:
Originally Posted by tuXguy15 View Post
what does the P, I, and D do and how do you configure them to meet your robots needs. That is what I am having a hard time understanding?
Click Here.



Reply With Quote
  #3   Spotlight this post!  
Unread 24-04-2013, 21:50
Tanaythan's Avatar
Tanaythan Tanaythan is offline
Programmer
AKA: Tanay Nathan
FRC #3256 (Warriorborgs)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: San Jose
Posts: 27
Tanaythan is an unknown quantity at this point
Re: PID

PID (stands for proportional, integral, and derivative) is a control loop where the feedback is used as an adjustment for the next iteration. It takes in a setpoint that the loop will try to adjust for and the sensors that you stated will give you back a current value. You can subtract your current from your setpoint to get your error.

The way that most people understand PID is thinking about it as a function graph where the x-axis is the number of iterations and the y-axis is your error (setpoint - current). Now this function (let's call it f(x)) is your basic function for your error versus iterations that is constantly growing as your PID loop continues. Your proportional value will be a constant (kP) multiplied by f(b) where b is equal to your last iteration. The integral (if you have not taken calculus) is the area underneath the curve of the function, which can be simply done by adding all the error terms. Then, you can multiply your constant (kI) by the sum of your error to find your integral constant. The derivative term is the slope of the function and is given by your point slope formula: (f(b) - f(a)) / (b - a). The derivative value is given by multiplying this slope and the constant (kD). You add all of these together to get a PID value to send to your motor.

Now, the proportional value is pretty self-explanatory. It decreases as the error becomes smaller or as you approach your setpoint. Thus, it gives a huge boost at the beginning and reduces its effectiveness as the error decreases. A P-only loop will result in oscillation. The integral term provides an extra boost that will get the PID loop to the setpoint required. Since it is the sum of the errors, it can "predict" where the power level will go next and try to compensate. The derivative portion speeds up (or slows down if your constant is negative) the loop because it multiplies a constant by your slope and adds it to the system.
__________________
Tanay Nathan
Programmer
Team #3256 Warriorborgs
Reply With Quote
  #4   Spotlight this post!  
Unread 24-04-2013, 22:11
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 7,006
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: PID

Cruise control in a car is one example of PID. As you approach the setpoint (the speed you want), the car accelerates less and less until it is at the right speed, as opposed to accelerating at maximum until it hits the speed and then lets off the gas suddenly. Then it keeps that speed, even if there's a hill. The further below the set speed you are, the greater the acceleration - to a point: There is a maximum acceleration value that the car won't exceed (maybe about 40% of the car's maximum performance).

P is the gradual lessening of acceleration as the "error" (the difference between the set speed and the actual speed)

I is what keeps the speed constant, even when the error is very small

D is what limits the maximum acceleration to a safe and reasonable value.

In robotics, often P is all you need. Maybe I, rarely D.

Here on CD, look for a paper called "PID without a PhD", as well as the several dozen posts on the topic.
__________________

I am N2IRZ - What's your callsign?
Reply With Quote
  #5   Spotlight this post!  
Unread 24-04-2013, 22:22
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: PID

Quote:
Originally Posted by rawrxp View Post
PID (stands for proportional, integral, and derivative) is a control loop where the feedback is used as an adjustment for the next iteration.
If your control algorithm does input/process/output, then the feedback is used as an adjustment for the present iteration.

Quote:
the sensors that you stated will give you back a current value. You can subtract your current from your setpoint to get your error.
the OP may think you are talking about amps here.

Quote:
The way that most people understand PID is thinking about it as a function graph where the x-axis is the number of iterations and the y-axis is your error (setpoint - current). Now this function (let's call it f(x)) is your basic function for your error versus iterations that is constantly growing as your PID loop continues.
The error should be decreasing, not growing, if the controller is working properly.

Quote:
You add all of these together to get a PID value to send to your motor.
True for the WPILib Java implementation, but other languages (like LabVIEW) use a different form of PID. The 2013 WPILib PID also has a feedforward term.


Quote:
Now, the proportional value is pretty self-explanatory. It decreases as the error becomes smaller or as you approach your setpoint. Thus, it gives a huge boost at the beginning and reduces its effectiveness as the error decreases. A P-only loop will result in oscillation.
Not true as an unqualified general statement. It depends on what you are controlling, and how high you crank up the gain.


Quote:
The integral term ... can "predict" where the power level will go next and try to compensate.
I think you are confusing the integral term with the derivative term.


Reply With Quote
  #6   Spotlight this post!  
Unread 25-04-2013, 00:01
Tanaythan's Avatar
Tanaythan Tanaythan is offline
Programmer
AKA: Tanay Nathan
FRC #3256 (Warriorborgs)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: San Jose
Posts: 27
Tanaythan is an unknown quantity at this point
Re: PID

Quote:
Originally Posted by Ether View Post
I think you are confusing the integral term with the derivative term.

How I was taught PID was that the integral takes the current accumulation of the error, which could be translated into the state of the system. Thus, if you tune the I term properly, it could be properly used to correct the loop. I even heard the word "predict" when I was learning PID. Now I realize that my mentor probably meant that it was for correction rather than prediction.

Quote:
The error should be decreasing, not growing, if the controller is working properly.
My bad, I meant that the number of iterations is growing, not the error. My fault.
__________________
Tanay Nathan
Programmer
Team #3256 Warriorborgs

Last edited by Tanaythan : 25-04-2013 at 00:06.
Reply With Quote
  #7   Spotlight this post!  
Unread 26-04-2013, 23:12
Teamcodeorange's Avatar
Teamcodeorange Teamcodeorange is offline
Registered User
FRC #3476
 
Join Date: Jan 2011
Location: US
Posts: 236
Teamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant futureTeamcodeorange has a brilliant future
Quote:
Originally Posted by Ether View Post
It's funny because recursion.
__________________
Try Code Orange's electronics tutorials!
---------------------------------------------------------
2015 - Tesla Division Champions
2015 - Inland Empire Engineering Inspiration Award
2015 - San Diego Regional Chairman's Award
2014 - San Diego Regional Chairman's Award
2013 - Newton Division Champions
2012 - San Diego Regional Winners
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:36.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi