Go to Post and the only thing i see as a disadvantage to those long hours of hard work is a little less time to spend with my girlfriend - h1n1is4pigs [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-02-2013, 01:04
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Mentor, LRI, MN RPC
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,835
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
PIDController tuning

First, physical setup:
We've got a set up with 3 motors, each getting feedback from a different potentiometer. Two motors are AndyMark PG-71's, mated with a 1-turn potentiometer. For one of them (we'll call it the A motor), we cover about 3/4 of the potentiometer, and the second (we'll call it the B motor) uses about half of the turn. Lastly, we have a Mini-CIM hooked up through a toughbox mini and an additional 2-1 reduction (we'll call this the C motor), with a 10 turn potentiometer going through about 8 turns total.

Friday we spent an ungodly amount of time trying to tune the PID constants for each of these motors, and simply could not get it to stop oscillating horribly at whatever setpoint we wanted it to be at. Getting fed up and wanting to see some progress before going home, we finally replaced the PIDController class with our own little function that implemented some simple rate-smoothing feedback, which mostly works. However, we've now discovered that the battery voltage really affects our function (It was working perfectly smoothly and predictably... then we replaced the battery and started getting some oscillation in the movement we didn't have before). We can add in a term for that to compensate (along with sufficient testing to ensure it does what its supposed to do), but I'd really rather just have the PIDController class working correctly.

So, who has experience working with this class, and can give us some pointers on roughly what values we should be passing in for our P, I, and D constants? Is it worth spending more time trying to get that class to work, or should we continue down the path with our own custom class? Would the PIDController class have the same issue with varied behavior based on battery voltage?
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA

Last edited by Jon Stratis : 18-02-2013 at 01:11.
  #2   Spotlight this post!  
Unread 18-02-2013, 01:34
artdutra04's Avatar
artdutra04 artdutra04 is offline
VEX Robotics Engineer
AKA: Arthur Dutra IV; NERD #18
FRC #0148 (Robowranglers)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2002
Location: Greenville, TX
Posts: 3,078
artdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond reputeartdutra04 has a reputation beyond repute
Re: PIDController tuning

The actual coefficients depend heavily on the actual mechanism. For starters, set I and D to zero, and set P really really low. You want it to start very conservatively and not oscillate. Then continue increasing P until it starts to oscillate; if you back off from this the P alone is enough for many mechanisms.

If you want to get to your set point faster without overshoot, You can begin tweaking in D. If you have high friction causing a steady-state error, use I to overcome it.
__________________
Art Dutra IV
Robotics Engineer, VEX Robotics, Inc., a subsidiary of Innovation First International (IFI)
Robowranglers Team 148 | GUS Robotics Team 228 (Alumni) | Rho Beta Epsilon (Alumni) | @arthurdutra

世上无难事,只怕有心人.
  #3   Spotlight this post!  
Unread 18-02-2013, 09:11
jwakeman jwakeman is offline
Registered User
FRC #0063 (Red Barons)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: 16510
Posts: 182
jwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nice
Re: PIDController tuning

Quote:
Originally Posted by Jon Stratis View Post
First, physical setup:
We've got a set up with 3 motors, each getting feedback from a different potentiometer. Two motors are AndyMark PG-71's, mated with a 1-turn potentiometer. For one of them (we'll call it the A motor), we cover about 3/4 of the potentiometer, and the second (we'll call it the B motor) uses about half of the turn. Lastly, we have a Mini-CIM hooked up through a toughbox mini and an additional 2-1 reduction (we'll call this the C motor), with a 10 turn potentiometer going through about 8 turns total.

Friday we spent an ungodly amount of time trying to tune the PID constants for each of these motors, and simply could not get it to stop oscillating horribly at whatever setpoint we wanted it to be at. Getting fed up and wanting to see some progress before going home, we finally replaced the PIDController class with our own little function that implemented some simple rate-smoothing feedback, which mostly works. However, we've now discovered that the battery voltage really affects our function (It was working perfectly smoothly and predictably... then we replaced the battery and started getting some oscillation in the movement we didn't have before). We can add in a term for that to compensate (along with sufficient testing to ensure it does what its supposed to do), but I'd really rather just have the PIDController class working correctly.

So, who has experience working with this class, and can give us some pointers on roughly what values we should be passing in for our P, I, and D constants? Is it worth spending more time trying to get that class to work, or should we continue down the path with our own custom class? Would the PIDController class have the same issue with varied behavior based on battery voltage?
I had some success this year using "method a" at this link. You will need some way to collect data and graph it. Using PID should allow you to get consistent operation under varying battery charge.
  #4   Spotlight this post!  
Unread 18-02-2013, 09:26
ProgrammerMatt ProgrammerMatt is offline
Programmer-Electrical-Mechanical
FRC #0228 (Gus)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Southington
Posts: 138
ProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really niceProgrammerMatt is just really nice
Re: PIDController tuning

Hi, PID is a very nice tool when you get the hang of it, the first thing i would suggest is to not use I, I can cause oscillation over time because I adds power over time if the setpoint is not reached, P and D are what you want to use, I would suggest starting at about 0.01 for both P and D and work your way up. D will help you solve your overshooting problem because it will slow down the motor as you approach your setpoint.

Hope it helps,

-Matt
__________________
2015-2016 CSA
Software Engineering Student @ Johnson & Wales University
Team 228, Gus Robotics Inc.
Facebook
FLL Mentor for 1107, Edison Eagles!
2015- CT State Champions
2012- WPI Finalist(Thanks 1884 and 549), Spirt, Best Website
2011- WPI Chairman's award winners!
2010- WPI Champions! (thanks 230 & 20), WPI Engineering Inspiration, CT Best Website, CT VEX Champions (VRC228, VRC228b) (21-1-0)
2009- QCC VEX Champions (VRC228) (11-0-0), Innovate Award (VRC228)
  #5   Spotlight this post!  
Unread 18-02-2013, 09:43
engunneer's Avatar
engunneer engunneer is offline
Alumni turned Mentor
AKA: Branden Gunn
FRC #4761
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1996
Location: Reading, MA
Posts: 877
engunneer has a reputation beyond reputeengunneer has a reputation beyond reputeengunneer has a reputation beyond reputeengunneer has a reputation beyond reputeengunneer has a reputation beyond reputeengunneer has a reputation beyond reputeengunneer has a reputation beyond reputeengunneer has a reputation beyond reputeengunneer has a reputation beyond reputeengunneer has a reputation beyond reputeengunneer has a reputation beyond repute
Re: PIDController tuning

Be sure your PID is not stuck in a loop. We had wild oscillation yesterday because the PID was in a loop that was being called by periodic tasks. I strongly advocate a 'no loops' architecture.

to determine what range of number makes sense - let's say your position feedback is in degrees, so your setpoint is also in degrees. the motor velocity is in the range of -1 to 1. By definition, your P gain is applied to the difference between commanded and actual (your p error) so if you are off by 5 degrees, and you want to apply a 0.5 motor speed to correct for it, your P gain should be around 0.1, as a starting point. If it still oscillates too much, then back it off a bit.

for integral gain (our PID is on an arm where the load changes based on position, so we use I to close the gap), remember that it is a time parameter measured in minutes. In our case, we ended up with about 0.01 for I.

it is really handy if you can have it graph position in real time. Tell it to do a step move (say from 100 to 150 degrees) and see the shape of how it gets from one to the other. If it doesn't get to exactly the right point, make I smaller (more powerful). If overshoots too far, make P smaller (weaker).

Most systems build in FRC don't need D gain, IMO
__________________
Student FRC23 (1996-1999), Mentor FRC246 (2000), Mentor FRC1318 (2007-2009), Mentor FRC93 (2011), Mentor FRC2151 (2012), Mentor FRC23 (2013), Mentor FRC4761 (2014-2017)
1998 - National Chairman's Award and Woodie Flowers Award (FRC23, Mike Bastoni ) | 2007 - PNW SF (488, 1595) | 2008 - Oregon RCA - Seattle #2 Seed, SF (488, 1696) | 2009 - Oregon #1 Seed, Winners (1983, 2635) - Seattle SF (945, 2865) - Galileo #2 Seed, SF (973, 25) | 2012 Midwest F (111, 71) | 2014 RIDE Winners (78, 125), Inspector - NEU #24, QF (3479, 3958) - NECMP #35 | 2015 Reading #11, SF (1058, 190), Inspector - RIDE #17, QF(4055, 5494), Inspector - NECMP #57 | 2016 Reading #4, SF (133, 4474), DCA, Inspector - Ride #22, SF (1735, 2067), Creativity, Inspector - NECMP #48, RCA - Archimedes
  #6   Spotlight this post!  
Unread 18-02-2013, 10:15
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,906
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: PIDController tuning

Just an alternate note. This may or may not apply to your setup.
It can be untunable if the three PID loops are operating independently of one another, but are affected by one another. They can't forecast the blind-siding they get from the other loops and end up fighting the others for position.

In such an interdependent system one simple approach might be to have one of the motors act as the master (one ring to rule them all) with the others slaving themselves to it's position. Feed the master pot to the slaves as their continually changing setpoint (normalized to match the range of the slave pots and applying any relationship equation).That provides sort of a cooperative feed forward term to the slaves. I typically make the slowest mechanism the master (sometimes purposely slowing it down) and the faster mechanisms the slaves, because you can structure it so that the slaves reach equilibrium quickly and have reduced affect on the master. Overall thrashing is eliminated as the slaves make smaller incremental changes as they trail along behind the master instead of racing ahead.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 18-02-2013 at 11:10.
  #7   Spotlight this post!  
Unread 18-02-2013, 10:28
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,745
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: PIDController tuning

Quote:
Originally Posted by engunneer View Post
fit is really handy if you can have it graph position in real time. Tell it to do a step move (say from 100 to 150 degrees) and see the shape of how it gets from one to the other. If it doesn't get to exactly the right point, make I smaller (more powerful). If overshoots too far, make P smaller (weaker).
I believe you mean to make I larger. The PIDController class multiplies the integrated error by I, so larger I means stronger integral action.

Also, changing battery voltage will change the performance of your PIDController unless you're using a CANJaguar in Voltage Mode, which would add another bit of control action in the Jaguar itself which might confuse things. The reason is that all speed controller commands are in percentage of battery voltage. Higher battery voltage means stronger motor action, which is the equivalent of turning up all your gains slightly. To compensate for this, your best option is to tune with a freshly charged battery and no other systems running. If your system is stable under these conditions, it will most likely be even more stable as battery voltage drops under load during a match.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #8   Spotlight this post!  
Unread 18-02-2013, 11:57
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
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: PIDController tuning

Quote:
Originally Posted by Kevin Sevcik View Post
I believe you mean to make I larger. The PIDController class multiplies the integrated error by I, so larger I means stronger integral action.
Depends on the form of PID being used. Java seems to use the parallel form. The LabVIEW help seems to imply that it uses the academic form. I've not been able to look inside the LabVIEW VI to see what it's actually doing.


Attached Thumbnails
Click image for larger version

Name:	PID Ti.png
Views:	38
Size:	54.5 KB
ID:	14095  

Last edited by Ether : 18-02-2013 at 17:02. Reason: added screenshot
  #9   Spotlight this post!  
Unread 19-02-2013, 00:16
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Mentor, LRI, MN RPC
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,835
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: PIDController tuning

A big thanks to everyone who chimed in here. We managed to get it working flawlessly for all but 1 setpoint tonight, and the tips and thoughts shared here certainly helped! We'll tackle that last one before we bag tomorrow
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
  #10   Spotlight this post!  
Unread 19-02-2013, 00:38
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,745
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: PIDController tuning

Quote:
Originally Posted by Ether View Post
Depends on the form of PID being used. Java seems to use the parallel form. The LabVIEW help seems to imply that it uses the academic form. I've not been able to look inside the LabVIEW VI to see what it's actually doing.
Looked for myself out of curiosity. Labview multiplies the integrated error by Kp/Ki and multiplies the derivative by Kp x Kd. Definitely the academic form of a PID there. Which is probably unsurprising, really.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
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 03:30.

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