I am designing a software PID control. Logic is almost final but I wonder how do I decide the value of \$k_p\$, \$k_i\$ and \$k_d\$. Also, I need to determine the max and min value for the Pterm Item and Dterm. How do I do that?. Also, I am trying to implement the inverse control. Also, am I going in the right way in designing the software PID? Also, if integral time and \$k_i\$ both are same? The code I wrote so far is given below.
Calculate_Error();
P_Term = Percnt_Error;
P_Term = KP * P_Term;
if(P_Term >= PMAX)
{
P_Term = PMAX;
}
else if(P_Term <= PMIN)
{
P_Term = PMIN;
}
// Integral calculation
if(Integraltime==1) // Take integration at every 1s
{
Integraltime = 0;
Error_Accum = Error_Accum + Percnt_Error; // Error Accumulation over time
if(Error_Accum >= MaxAccumError)
{
Error_Accum = MaxAccumError;
}
if(Error_Accum <= -MinAccumError)
{
Error_Accum = -MinAccumError;
}
I_Term = (Error_Accum)*KI;
if(I_Term >= IMAX)
{
I_Term = IMAX;
}
else if(I_Term <= IMIN)
{
I_Term = IMIN;
}
}
No comments:
Post a Comment