View Single Post
  #9   Spotlight this post!  
Unread 06-01-2013, 11:52
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 588
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
Re: Questions about Encoders and PIDControllers

As has been pointed out the problem with PID controlling velocity directly is that as the motor speed reaches the setpoint, the motor speed goes to zero.

New for 2013 is the addition of a feedforward term (4th parameter on the constructors) that is a baseline value that is added to the output value. This term is multiplied by the setpoint so that it scales with differing speeds. The feedforward term will prevent the motor speed oscillation as the motor speed approaches the setpoint.

Here's the code that actually computes the final value in the PID controller class:
Code:
m_result = m_P * m_error
               + m_I * m_totalError
               + m_D * (m_error - m_prevError) 
               + m_setpoint * m_F;
where m_P, m_I, m_D, and m_F are the P, I, D, and F constants. The m_error is the difference between the current value and the setpoint, and the m_prevError is the value of the error from the previous iteration.

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote