Implementation of Integrator in PID control

49 Views Asked by At

I have a doubt in implementing PID control. I referred many documents and video tutorials regarding this. But I am quite confused regarding the implementation of integrator in PID control. I could see that there are two ways used for implementing the integrator.

  1. Method 1 IntegralError = IntegralError + error;

  2. Method 2 pid->integrator = pid->integrator + 0.5f * pid->Ki * pid->T * (error + pid->prevError);

    I found this code above from this example

The first method is straight forward. I can understand it. But the second method is not clear to me. What is the role of pid->prevError? How integration is achieved here? Which of the above methods are more efficient?

Please help me on this

Thanks, Varun

I tried the first method. It works. But I cannot understand the second method.

0

There are 0 best solutions below