Go to Post People will only work toward common goals when they are part of the goal-setting process. - GaryVoshol [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 22-01-2016, 16:57
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 236
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Tuning PID

On our robot is an arm with 3 positions

Up
Middle
Down

Middle is about 1/4 the way between down and up (closer to down)

We control the arm with encoders on AM-2971 motors. When we tell the arm to go from up to middle, it gets to the position fine, but when we go from down to middle, it undershoots and only goes about halfway.

The current PID is 2, 0, 0.

What can we change to make the arm not undershoot when moving the short distance between down and middle?
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
  #2   Spotlight this post!  
Unread 22-01-2016, 17:00
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 502
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: Tuning PID

After you tune your P value, tune the I until the arm gets about to where it should be. The D value may not be necessary at all (0).
  #3   Spotlight this post!  
Unread 22-01-2016, 17:05
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 236
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Tuning PID

Quote:
Originally Posted by Hitchhiker 42 View Post
After you tune your P value, tune the I until the arm gets about to where it should be. The D value may not be necessary at all (0).
How much do I increase it by? 1?

And how do I know when the P value is tuned? It seems to work, but is there a way I could make it work "better"?
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP

Last edited by TimTheGreat : 22-01-2016 at 17:07.
  #4   Spotlight this post!  
Unread 22-01-2016, 17:43
plnyyanks's Avatar
plnyyanks plnyyanks is offline
Data wins arguments.
AKA: Phil Lopreiato
FRC #1124 (The ÜberBots), FRC #2900 (The Mighty Penguins)
Team Role: College Student
 
Join Date: Apr 2010
Rookie Year: 2010
Location: NYC/Washington, DC
Posts: 1,114
plnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond reputeplnyyanks has a reputation beyond repute
Re: Tuning PID

Quote:
Originally Posted by TimTheGreat View Post
How much do I increase it by? 1?

And how do I know when the P value is tuned? It seems to work, but is there a way I could make it work "better"?
There's going to be a lot of guesswork involved, no matter what you do.

A good method to start with (it's in no way optimal, but often good enough), is the Ziegler-Nichols method.

Basically, set all three of P, I, and D to 0. Then, raise P (this can be by any amount, again, see guesswork) until there is oscillation around the setpoint. Then, increase D until the oscillation stops. If you're noticing a lot of friction in the system so it never quite gets to the setpoint, add some I to compensate.

Take note, however, that long arms are tricky. The gravitational forces acting to pull the arm down vary nonlinearly based on the arm position - this makes it difficult to control, since it's difficult to model. That's not saying it's uncontrollable, but it'll take more work to make smooth.
__________________
Phil Lopreiato - "It's a hardware problem"
Team 1124 (2010 - 2013), Team 1418 (2014), Team 2900 (2016)
FRC Notebook The Blue Alliance for Android

Last edited by plnyyanks : 23-01-2016 at 12:34.
  #5   Spotlight this post!  
Unread 22-01-2016, 22:40
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,639
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Tuning PID

Your initial problem is not that surprising. For an arm with a large angular displacement, the gravity torque is directed and proportional to the cosine of the arm's angle to the horizontal. This is going to give very different behavior up vs down. As stated above, tune P (and possibly I) so that the oscillation center is correct, then increase D to dampen the oscillations. P and I may require minor mods after increasing D, but probably not too severely.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
  #6   Spotlight this post!  
Unread 23-01-2016, 08:31
CryptoStorm's Avatar
CryptoStorm CryptoStorm is offline
EIC Tech
AKA: Joshua Stilwell
FRC #5056 (MegaHurtz)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2004
Location: Buchanan MI
Posts: 26
CryptoStorm is an unknown quantity at this point
Re: Tuning PID

Sounds like a feedback error more than a PID issue. If the PID isn't making setpoint it should still be hunting and/or oscillating.

Are you trying to sense angular motion or linear motion?
  #7   Spotlight this post!  
Unread 23-01-2016, 09:49
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
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: Tuning PID

Quote:
Originally Posted by CryptoStorm View Post
If the PID isn't making setpoint it should still be hunting and/or oscillating.
For the benefit of those new to PID who may be confused by the above statement, it is not true as a general proposition.

There are many combinations of values for the gains which will cause the system to do exactly as described in the original post:

When we tell the arm to go from up to middle, it gets to the position fine, but when we go from down to middle, it undershoots and only goes about halfway.



  #8   Spotlight this post!  
Unread 23-01-2016, 12:05
CryptoStorm's Avatar
CryptoStorm CryptoStorm is offline
EIC Tech
AKA: Joshua Stilwell
FRC #5056 (MegaHurtz)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2004
Location: Buchanan MI
Posts: 26
CryptoStorm is an unknown quantity at this point
Re: Tuning PID

I actually read the issue incorrectly.

Thank you for being condescending without any elaboration.
  #9   Spotlight this post!  
Unread 23-01-2016, 12:22
dellagd's Avatar
dellagd dellagd is offline
Look for me on the field!
AKA: Griffin D
FRC #2590 (Nemesis) #2607 (The Fighting Robovikings)
Team Role: Mentor
 
Join Date: Sep 2011
Rookie Year: 2011
Location: PA
Posts: 890
dellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond reputedellagd has a reputation beyond repute
Re: Tuning PID

Quote:
Originally Posted by CryptoStorm View Post
I actually read the issue incorrectly.

Thank you for being condescending without any elaboration.
When you combine a PID control solution with a real device, there are many situations that result it stabilizing at a point that is not the setpoint. To elaborate, if you were using only P to attempt to get to a setpoint when lifting an object, the system would most likely stabilize below the setpoint. The small power generated when near but not at the setpoint in this case would likely be too little lift the load the last bit.

Also, one of the main purposes of this forum is to help people with problems. That wasn't condescension, it was being helpful.
__________________
Check out some cool personal projects in computers, electronics, and RC vehicles on my blog!

2016 MAR DCMP Engineering Excellence Award
2016 MAR Westtown Innovation in Control Award
2016 MAR Hatboro-Horsham Industrial Design Award
2015 Upper Darby District Winners - Thanks 225 and 4460!
2015 Upper Darby District Industrial Design Award
2015 Hatboro-Horsham District Winners - Thanks 2590 and 5407!
2014 Virginia Regional Winners - Thanks so much 384 and 1610, I will never forget that experience!
2014 Virginia Quality Award
2014 MAR Bridgewater-Raritan Innovation in Control Award
2014 MAR Hatboro-Horsham Gracious Professionalism Award
2013 MAR Bridgewater-Raritan Innovation in Control Award
2012 MAR Lenape Quality Award
  #10   Spotlight this post!  
Unread 23-01-2016, 15:31
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 803
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Tuning PID

Quote:
Originally Posted by TimTheGreat View Post
How much do I increase it by? 1?

And how do I know when the P value is tuned? It seems to work, but is there a way I could make it work "better"?
There are a couple answers I usually give to this.

1) Don't use I unless you have tried P and D extensively and can't get it to converge to the actual goal but can get it to converge close but not close enough. I rarely use I on 971's robots, and when I do, the loops end up being much more complicated and hard to reason about.

2) Start with 0.00001 for P (then D then I) and multiply them by a factor of 2 each time. I tend to round from 4 to 10 when multiplying to keep it easy. You'll quickly cover the space and learn what matters. One of my colleagues just multiplies by 10 each time.

3) Use the method recommended by plnyyanks


You can also choose to gain-schedule your PID gains based on if you are above or below the goal. That would mean that you have 2 different coefficients depending on if the arm is below or above your setpoint. Unless you have mastered normal PID, I wouldn't try this. (I needed to do this on 254's 2011 elevator and claw to get them to converge nicely with PD)
  #11   Spotlight this post!  
Unread 23-01-2016, 15:39
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,086
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: Tuning PID

Quote:
Originally Posted by AustinSchuh View Post
...Start with 0.00001 for P (then D then I) and multiply them by a factor of 2 each time. I tend to round from 4 to 10 when multiplying to keep it easy.
Boy does that bring back old memories. Way back in the mid 70s I was taught the 1-2-5 rule by a graybeard engineer:

0.00001
0.00002
0.00005
0.00010
0.00020
0.00050
0.00100
0.00200
0.00500
...


Closed Thread


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 06:05.

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