View Single Post
  #8   Spotlight this post!  
Unread 05-02-2013, 09:50
jwakeman jwakeman is offline
Registered User
FRC #0063 (Red Barons)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: 16510
Posts: 182
jwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nice
Re: Call to PIDController::GetError() and ::OnTarget() locks program.

I don't have the code in front of me right now but i think i ended up using this:

Code:
float PIDController::GetError() 
{
   float error;
   CRITICAL_REGION(m_semaphore)
   {
      error = m_setpoint - pidInput->PIDGet();
   }END_REGION;
}
return error;
Also in the OnTarget() method I do the same calculation to get the error instead of calling GetError().

Even with this updated implementation of GetError() I also learned last night not to call GetError() within PIDWrite().
Reply With Quote