Go to Post 1) Field reset will want to do mean things to you. They have to remove the tubes. - EricH [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 01-03-2010, 13:46
FRC4ME FRC4ME is offline
Registered User
FRC #0339
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Fredericksburg, VA
Posts: 324
FRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant future
WPI PIDController doesn't account for varying dT?

I was looking through WPI's PIDController code and noticed that they do not incorporate dT into the calculations anywhere. For example, the calculate() method contains the line:

Code:
m_totalError += m_error;
Shouldn't it be like this?

Code:
m_totalError += m_error * m_period;
The way it is now, changing the period of the PID loop would require resetting of the I and D constants. Multiplying the integral by the period and dividing the derivative by the period would remove this inconvenience.
__________________
Go directly to queue. Do not pass pit.
  #2   Spotlight this post!  
Unread 01-03-2010, 14:00
yoyodyne yoyodyne is offline
Registered User
AKA: Greg Smith
FRC #0116 (Epsilon Delta)
Team Role: Engineer
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Reston, VA
Posts: 61
yoyodyne is a splendid one to beholdyoyodyne is a splendid one to beholdyoyodyne is a splendid one to beholdyoyodyne is a splendid one to beholdyoyodyne is a splendid one to beholdyoyodyne is a splendid one to beholdyoyodyne is a splendid one to behold
Re: WPI PIDController doesn't account for varying dT?

I'm no PID expert, but the output of the PID (at least the P part) has no bearing on the dT. I think that you want to set dT long enough so that the physical system will have started to respond to the last setting and more or less leave it alone and then adjust the gains. We typically test this by running a motor at control setting X and then jump to setting Y and plot the output of the sensor providing feedback. We then set dT to the time it takes the system to reach about 60% response. There is probably a better way to determine the right value for dT but it seems to allow us to stay stable and respond reasonably fast.

Greg
  #3   Spotlight this post!  
Unread 01-03-2010, 14:10
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: WPI PIDController doesn't account for varying dT?

Quote:
Originally Posted by FRC4ME View Post
I was looking through WPI's PIDController code and noticed that they do not incorporate dT into the calculations anywhere. For example, the calculate() method contains the line:

Code:
m_totalError += m_error;
Shouldn't it be like this?

Code:
m_totalError += m_error * m_period;
The way it is now, changing the period of the PID loop would require resetting of the I and D constants. Multiplying the integral by the period and dividing the derivative by the period would remove this inconvenience.
How often do you change the period?
  #4   Spotlight this post!  
Unread 01-03-2010, 14:18
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: WPI PIDController doesn't account for varying dT?

Quote:
Originally Posted by FRC4ME View Post
Shouldn't it be like this?
You could always change this and recompile it for yourself.

Or better yet, you could change this and submit it to the sourceforge project. If there's not a specific reason they left this functionality out, I'm sure it will get accepted.
  #5   Spotlight this post!  
Unread 01-03-2010, 16:08
FRC4ME FRC4ME is offline
Registered User
FRC #0339
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Fredericksburg, VA
Posts: 324
FRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant futureFRC4ME has a brilliant future
Re: WPI PIDController doesn't account for varying dT?

Quote:
Originally Posted by TomBot View Post
You could always change this and recompile it for yourself.

Or better yet, you could change this and submit it to the sourceforge project. If there's not a specific reason they left this functionality out, I'm sure it will get accepted.
We have changed it for our team's use, and I feel like changing the library would be a bad idea as it would break the PID loops that teams have already tuned.

I understand that it isn't a big deal and there aren't many reason to change the period. I was just curious to see if, as you say, there is a specific reason WPI left this out that I'm not seeing.

Sorry if I sounded rude in any way by mentioning this.
__________________
Go directly to queue. Do not pass pit.
  #6   Spotlight this post!  
Unread 01-03-2010, 16:24
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: WPI PIDController doesn't account for varying dT?

I believe that the reason that WPI left the dT part out is that since VxWorks is a real time OS, it's perfectly reasonable to assume that dT won't change very much.

A good exercise is to measure dT and see how much it actually varies.

If you were to submit a patch, you could scale the constants up and down internal to the loop by 50.0. KI should be 50 times larger, and KD should be 50 times smaller (provided I'm doing my math right, and assuming 50 Hz). That would preserve backwards compatibility.
  #7   Spotlight this post!  
Unread 01-03-2010, 16:46
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: WPI PIDController doesn't account for varying dT?

It is a matter of preference. If you update your 50Hz PID to be 100Hz, do you want to scale your Ki and Kd, or do you want the API to do it for you?
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
RobotDrive + PIDController = possible? oddjob C/C++ 4 14-01-2010 23:33
Can I get my account name changed or my account deleted? bendh18 CD Forum Support 4 14-06-2009 19:21
WPI Lib Source Code from subversion at WPI Sourceforge steinra Programming 6 02-12-2008 16:34
Code for sensor still doesn't work Ianuser Programming 3 14-02-2007 10:17
Varying levels of enforcement... Gui Cavalcanti General Forum 9 28-03-2002 16:29


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

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