2

I am implementing PID control for motor speed control. In the specification I have been told to implement filtering technique using the following equation for D part. I am done with Implementing the PI control and it works perfectly fine for me.

enter image description here

Now what I understood so far is that s represents "dx/dt" generally which corresponds to the rate of change of error but here i can relate it with rate of change of feedback. Td/N is for limiting the all over gain output(hope i got this right). Now to represent this in terms of C code I tried with 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 is not what I have predicted. I just want to know that ..did I implement the D portion equation correctly? Am I making in mistake in the understanding 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. Thanks a lot in advance. Sorry for the bad english.

Jonas
  • 121,568
  • 97
  • 310
  • 388
SPandya
  • 1,161
  • 4
  • 26
  • 63
  • Shouldn't percent change be `(current-old)/old`? Why do you have `max` in the denominator? – thelaws Nov 18 '15 at 19:30
  • well i put max because max possible change in feedback is the mx feedback it self.... – SPandya Nov 18 '15 at 19:34
  • I would suspect integer division. How big is `N` compared to `s*Td`? If it is bigger, your lower term is rounded to 1. and if `N` is smaller than `Td`, the whole formula is truncated to 0. – AShelly Nov 18 '15 at 19:38
  • N is usually 5 but in the system there is a limit it wont go beyond 10 – SPandya Nov 18 '15 at 19:40
  • my doubt is in the realization of the equation. I am not good in maths :D – SPandya Nov 18 '15 at 19:43
  • What are the types of your variables? Is `N` an `int`? – thelaws Nov 18 '15 at 19:46
  • my final D Term is S32, N is U8, Feedback is S32, diff time is U32 as well – SPandya Nov 18 '15 at 19:50
  • @AShelly.. I suspected the same...i took sample at different change in feedback and recalculated everything...at no point it;s being rounded 0. I took care of the 2 point decimal precision but proper multiplication and division...but i havent added here so that people dont get confused by seeing all that stuff – SPandya Nov 18 '15 at 20:02
  • I'm confused by not seeing "that stuff". You say the types are integral, but then you say you have 2 decimal point precision. GIve at least one concrete example of inputs, expected outputs , and actual output. – AShelly Nov 18 '15 at 20:48
  • 1
    @AShelly I suspect the integer values are scaled x100 to get the 2 decimal points of precision ? Scaling like that is often used for integer calculation, e.g. in control loops. – Morten Jensen Nov 18 '15 at 20:57
  • You are right @Morten Jensen – SPandya Nov 18 '15 at 21:46

1 Answers1

0

Whenever the sample time is high enough and the sensibility of the measure is high the D will only add noise, because any small change will be inmediately attacked by the D control, creating an awful ripple at the end. In most systems you don't need a D if you can live with a slower control. If you still want to use a D then be sure that it's far smaller than P and I.

And maybe you can change your last symbol.

Santiago
  • 109
  • 4
  • Mostly D will remain the off only..but if user activates it system should be capable enough to deal with it – SPandya Nov 18 '15 at 19:54