Part Number: MSP432P401R
Other Parts Discussed in Thread: ENERGIA
Tool/software: Code Composer Studio
Hi
I appreciate it if anyone can direct me to a firmware developed to implement PID controller in c language. I have developed my own that can be found in the below snippet of code but doesn't converge. The output of the function is actually the duty cycle of the PWM signal.
uint_fast16_t PID1 (float e1)
{
e_dot1 = e1 - e_old1;
E1= E1 +e1;
/*printf("E: %d\n",(int)E1);*/
u1 = (10*e1+0.001*e_dot1 + 4*E1);
e_old1 = e1;
if (u1>127){u1=127;}
if (u1<0){u1=0;}
u1=127-u1;
duty1=(uint_fast16_t)u1;
return duty1;
}
Regards
Saber
