I am implementing a PID controller for motor speed control. I am done with implementing the PI control and it works perfectly fine for me. In the specification I have been told to implement a filtering technique by using the following equation for the D part:
Now what I understand so far, is that
"dx/dt" generally which corresponds to the rate of change of error, but here I can relate it with the rate of change of feedback.
Td/N is for limiting the overall gain output (hope I got this right).
Now to represent this in terms of C code, I tried the following way:
s = (CurrentFeedback()-Old_Feedback)*100/(MaxFeedback()); //to calculate the % change in feedback s = s*1000/sampleTime; //1000 is multiplied because sampleTime is in milliseconds D = (Td*s)/(1+(s*Td/N)); D = D*KP; //Kp is multiplied as per the standard pid equation. Old_Feedback = CurrentFeedback(); PID = P+I-D;
Well the results by adding D are not what I have predicted.
I just want to know if I implemented the D portion equation correctly? Am I making any mistakes in my understanding of the basic maths of differentiation?
NOTE: I am not in liberty to change the recalculate the kp,ti,td as it comes directly from the VFD.