Go to Post If regolith ever makes a return, I will jump out of a window. - Oblarg [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: 77 votes, 5.00 average. Display Modes
  #16   Spotlight this post!  
Unread 18-02-2015, 18:32
Jared's Avatar
Jared Jared is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Aug 2013
Rookie Year: 2012
Location: Connecticut
Posts: 602
Jared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond reputeJared has a reputation beyond repute
Re: PID Tuning Help

Here's what I've done for PID that seems to work very well for us.

We've used it for:
Velocity PID on flywheel shooter
Position PID on window motor for bridge stinger
Position PID on window motor for turret
Position PID on climber
Position PID on elevator

To avoid breaking things, I start with p = .00001, so nothing happens. I increase p by one order of magnitude until the thing starts moving. At this point, we make sure that the mechanism is heading in the right direction. Finally, we increase P until the steady state error is 3 to 5 times larger than our largest acceptable error. This value usually ends up being near half the P value that causes uncontrollable acceleration. At this point, we slowly increase I (start with .00001, increase by orders of magnitude until something happens, then by increasingly smaller amounts) until the mechanism reaches the setpoint, even if it oscillates on reaching the setpoint. Then, we increase D very slowly (start at .00001, increase by order of magnitudes).

If D ends up too large and causes oscillations, use more low pass filter on your sensor data (or use a moving average with more samples).
  #17   Spotlight this post!  
Unread 19-02-2015, 00:19
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,781
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: PID Tuning Help

Quote:
Originally Posted by Ether View Post
For completeness: if it's oscillating or not stable, then what.
It could be runaway, though that seems unlikely after passing through the previous steps in this process.
__________________

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.
  #18   Spotlight this post!  
Unread 19-02-2015, 00:55
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,141
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 Tuning Help

Quote:
Originally Posted by GeeTwo View Post
It could be runaway, though that seems unlikely after passing through the previous steps in this process.
The likelihood was not in question. The "ensure" part was open-ended.

  #19   Spotlight this post!  
Unread 23-02-2015, 07:57
Ian Curtis Ian Curtis is offline
Best Available Data
FRC #1778 (Chill Out!)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Puget Sound
Posts: 2,521
Ian Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond repute
Re: PID Tuning Help

Quote:
Originally Posted by jwhite View Post
Again, for more completeness, where should you start? We mostly gave up on trying for PI controllers, because we found that even apparently small values of I led to instability. (The 1114 guide to PID tuning suggests PD; a bunch of smart people I know swear by PI. I have no real experience other than sitting with students trying this for a few nights in a row).

We successfully tuned one with I, but only when our I was several orders of magnitude less than the P term.

Is there a rule of thumb? Start with an I that is X of P, and then increase slowly?

As a side note, if you're tuning I, one of the challenges you may face is that the smart dashboard allows a tiny number of significant digits. (Afair, the lowest we could go was 0.001). We ended up making a scaled pid output just to get around that problem.

And, again, any rule of thumb? As we were tuning PD, we tended to start D at the P value, or perhaps below, and then gradually increased from there.
The great thing about PI controllers is that they will drive your error to zero, and are relatively robust. Imagine trying to stay 100 feet behind another car using a P or PD controller to press the accelerator pedal. You will never reach a steady state -- when you have zero error and zero acceleration you won't be pressing on the accelerator! On top of that, real world signals are noisy - differentiating them makes them even noisier, and filtering slows them down. This doesn't make them unworkable -- just not always desirable.

I stay on the mechanical side of FIRST robots, so I am somewhat clueless as to the implementation in the default code. What are the units on the integrated error? Is it error*frame or error*second? error*frame would be a much larger value, and explain why you need such a small value for Ki.

The answer is often integrator management. This means, when the integrator is not helpful, you turn it off. The great thing about integrators is that they will do everything in their power to satisfy the command. The bad thing about integrators is that they will do everything in their power to satisfy the command. A step command of the full length of the field is going to wind up the integrator. Your robot can't satisfy the command of being 54 feet away in .1 second. One way to avoid this is to not command 54 feet in .1 second, instead ramp it in over several seconds. See this post by Ether. Another way to is to shut off the integrator for most of the travel -- just start counting when you are close to the final value to make sure you achieve the commanded position. Or you limit the integrator's authority to some fraction of the maximum command.
__________________
CHILL OUT! | Aero Stability & Control Engineer
Adam Savage's Obsessions (TED Talk) (Part 2)
It is much easier to call someone else a genius than admit to yourself that you are lazy. - Dave Gingery
  #20   Spotlight this post!  
Unread 23-02-2015, 08:32
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,781
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: PID Tuning Help

Quote:
Originally Posted by SousVide View Post
4. backoff I by a quarter of that value - ensure system is stable and not oscillating.

I read "and not oscillating" in OP above as a clarification; in some contexts (acoustics, radio, etc), oscillating is considered stable. This is not one of those contexts.
__________________

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.
  #21   Spotlight this post!  
Unread 26-02-2015, 13:26
SousVide SousVide is offline
Registered User
no team
 
Join Date: Jan 2011
Location: CA
Posts: 91
SousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to behold
Re: PID Tuning Help

Yeah, if OP need more than basic P with just a tad (or none) of I. They really need to get into how PID works and why each of the variables do what they do.. A simple generic manual tuning procedure isn't going to do it beyond some very basic system. I've had to tweak D in scenarios where I've had impulse spikes in the error, and I where there were ramps/drifts.

Without knowing the underlying system, it would be difficult to go beyond the generic manual tuning.
  #22   Spotlight this post!  
Unread 26-02-2015, 15:03
tr6scott's Avatar
tr6scott tr6scott is offline
Um, I smell Motor!
AKA: Scott McBride
FRC #2137 (TORC)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2005
Location: Oxford, MI
Posts: 541
tr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond repute
Re: PID Tuning Help

http://www.inpharmix.com/jps/PID_Con...ms_Robots.html

Simple and detail explanation about pid, tuning.

We wrote our own pid for the elevator this year, about a week into the debug, one of the students says, hey Labview has a PID instruction, why didn't we use that...

A week after that a mechanical mentor says, hey the Talon SRX does PID on the talon, why didn't we use that...

The answers are the same, because I wanted them to learn it. . .

We found the Kc and oscillation period, (we log elevator motor output and elevator encoder feed back to .csv file) to be pretty good values, we had to tweek them down a bit from the chart, but the same gains worked for both lifting loaded, unloaded, lowering loaded and unloaded. We also do the calcs in timed tasks loop with a 20ms metronome timer.
__________________
The sooner we get behind schedule, the more time we have to catch up.


Last edited by tr6scott : 26-02-2015 at 15:06. Reason: sp
  #23   Spotlight this post!  
Unread 26-02-2015, 16:45
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,141
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 Tuning Help

Quote:
Originally Posted by tr6scott View Post
The answers are the same, because I wanted them to learn it. . .
Nothing beats learning PID tuning on real hardware, but this comes close:

http://www.qxdesign.com/Download%20A...r%20CSDG2e.EXE

... and it's free.

Download, install (with admin privileges), read the user guide, and start learning by doing.


  #24   Spotlight this post!  
Unread 27-02-2015, 00:02
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,781
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: PID Tuning Help

Quote:
Originally Posted by SousVide View Post
They really need to get into how PID works and why each of the variables do what they do..
OK, time for an analogous case most people have seen to describe the terms: a coil spring and shock absorber suspension, as found on the front wheels of many cars.
  • P is the spring. The farther away you are from the set point, the harder P pushes towards it. Large magnitudes of P push even harder. P by itself causes oscillation unless there is physical damping (friction) in the system.
  • D is the shock absorber. D pushes against motion. The faster the motion, the harder D pushes back. If D is too small, oscillation continues a long time (really old shock absorber). Moderate values of D dampen the oscillation (fewer cycles). A too-large value for D slows the stabilization down more than necessary; this is called over damping. The most familiar case of over damping is probably a door closer that seem to take forever to get through that last inch. OBTW, If you've got too much physical friction in your system, you may want to use a negative value for D to compensate.
  • I doesn't have a good physical analog, though the closest might be those powered gas shocks like the L.A. low riders use. I helps compensate for "droop", which is when the system stabilizes either above or below the set point. Usually, you should leave I at zero unless you have a system that's pretty well tuned except for some droop.
__________________

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.
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 00:17.

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