Thread: Fighting PID
View Single Post
  #1   Spotlight this post!  
Unread 20-02-2011, 22:04
Geek 2.0 Geek 2.0 is offline
Registered User
FRC #0107
Team Role: Programmer
 
Join Date: Sep 2009
Rookie Year: 2008
Location: Holland, MI
Posts: 120
Geek 2.0 will become famous soon enough
Re: Fighting PID

I'm actually in the process of doing that, and just found a strange problem...

I found this in the PIDController class in WPILibJ:
Code:
if (((m_totalError + m_error) * m_I < m_maximumOutput)
                        && ((m_totalError + m_error) * m_I > m_minimumOutput))
{
       m_totalError += m_error;
}

m_result = (m_P * m_error + m_I * m_totalError + m_D * (m_error - m_prevError));
m_prevError = m_error;
By the looks of it, it's saying that it won't add the error to the total error if the result would be outside the maximum and minimum output. Does that seem wrong to anyone else? Shouldn't it add the error no matter what, and then clip off the result to fit in the max and min output?