Wednesday, 20 January 2016

c - Kp, Ki, Kd for software PID control


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

arduino - Can I use TI&#39;s cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...