I am discretizing the PID equation so we have this equation

enter image description here

Now if we separate the integral term we get

enter image description here

Applying backward euler method

enter image description here

Now as we already have a differentiation , by applying backward euler method enter image description here

and the end equation is something like this

enter image description here

I just want to ask if I did something mathematically wrong or did I miss a step ?

  • 3
    \$\begingroup\$ Include \$\small P(k)=K_p\:e(k)\$ and it's fine. The bilinear transform normally gives more accurate results, though. \$\endgroup\$ – Chu Jul 4 '18 at 11:46
  • \$\begingroup\$ Note that in this form the equation produces derivative spikes when setpoint changes. You need to account for it in software if your application allows highly variable setpoint. \$\endgroup\$ – Maple Jul 4 '18 at 20:27

There's nothing wrong with the equations as far as I can tell. Backward Euler is the easiest way to approximate the derivative, so it is suitable for real-time calculations.

Some tips that can still help:

  • Limit I(k)
    When implementing a PID controller with analog components, the integrated signal is usually naturally limited by the supply voltages. Not limiting this factor will sometimes severely lengthen the recovery time.
  • Beware of delays
    When sampling a signal, you inherently introduce some delay in the loop which causes it to be slightly less stable. In extremis, the sampling frequency is too slow to capture the dynamics of the system to be controlled. Any controller you design will not be a good one at that point. Next to that, the extra conversion time for the ADC and DAC can also introduce a delay, having the same effect on the stability/performance of the system.
  • Keep an eye out for aliasing
    Whenever you sample a signal using an ADC, you have to keep the Nyquist–Shannon sampling theorem in mind. If your system has a frequency content that extends beyond the Nyquist frequency (\$f_N = \frac{1}{2T_s}\$) then you will want to limit it first to avoid aliasing, by means of an anti-alias filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.