|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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; Code:
m_totalError += m_error * m_period; |
|
#2
|
||||
|
||||
|
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
|
|||
|
|||
|
Re: WPI PIDController doesn't account for varying dT?
Quote:
|
|
#4
|
|||
|
|||
|
Re: WPI PIDController doesn't account for varying dT?
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
|
|||
|
|||
|
Re: WPI PIDController doesn't account for varying dT?
Quote:
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. |
|
#6
|
|||
|
|||
|
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
|
|||||
|
|||||
|
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?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |