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().