EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Digital PID controller in velocity form

Started by steven01 5 years ago4 replieslatest reply 4 months ago1804 views

Hello all,

I have been facing a problem how to implement digital PID controller. I have 

studie a lot of books and articles about that and in all the books I have read 

so far it is mentioned that velocity form of PID controller (which is described 

by the below given difference equation) is the most sutaible implementation of 

the digital PID controller because of easy antiwind up and bumpless transfer 

implementation.


$$ \Delta u(k)  = \Delta u_p(k) + \Delta u_i(k) + \Delta u_d(k) $$

$$ \Delta u_p(k) = u_p(k) - u_p(k-1) = K_p\cdot[e(k) - e(k-1)] $$

$$ \Delta u_i(k) = u_i(k) - u_i(k-1) = K_p\cdot T/T_i\cdot[e(k) + e(k-1)] $$                      

(in case the trapezoidal integration is used)

$$ \Delta u_d(k) = u_d(k) - u_d(k-1) = K_p\cdot T_d/T\cdot[e(k) - 2\cdot  e(k-1) + e(k-2)] $$

(in case the backward difference is used, filtering pole 

has been omitted)                                                          

$$ u(k) = u(k-1) + \Delta u(k) $$

Unfortunately I haven't found any example how to implement neither antiwind-up

nor bumpless transfer mechanism for the PID controller in velocity form so I have 

been attempting to invent that by myself.


Here are my ideas:

a) how to implement antiwind-up

If {([u(k-1) == umax] && [du(k) > 0]) || 

    ([u(k-1) == umin] && [du(k) < 0])} 

then u(k)=u(k-1)

b) how to implement bumpless transfer  

In my opinion for bumpless transfer it is sufficient to update the u(k-1) with

value set in manual mode.

Please can anybody tell me whether my ideas are correct? Thank you for any suggestions.

[ - ]
Reply by jeffgableAugust 13, 2019

Yes, both of your ideas are correct.

That said, I really don't like implementing anti-windup by limiting the integrator state.  I much prefer to have limits on the total controller output that match the downstream actuator limits, and then avoid updating the integrator when the controller as a whole (P + I + D) would exceed the limits.

I had actually never heard of the "velocity form" of the PID controller before this question, despite having been a controls specialist for 15 years.  I personally don't see the benefit, but that may be because I learned it the old-fashioned way, and have trouble looking at it from the beginner's perspective.

[ - ]
Reply by matthewbarrAugust 13, 2019

Interesting approach to anti-windup, I've not seen this before and it makes great sense. If I understand correctly, the idea is to prevent integral state accumulation when there is significant P or D contribution as well as a significant I accumulation. This is consistent with the idea that the purpose of I is to prevent running along with a small but constant error, a case that occurs when very near the set point with small P and D contributions.

It seems worth noting that if the decision is to stick with the originally suggested anti-windup method, it makes sense to use:

u(k-1) >= umax  and:

u(k-1) <= umin

A PID control simulation is always a great approach. That said, modeling PID control is usually straightforward while a modeling a complex plant response can be challenging.

[ - ]
Reply by mr_banditAugust 13, 2019

I'm not a PID expert. What I would suggest is to write the code && simulate it. run the code in a loop, and "inject" a value, then watch what the code does.

[ - ]
Reply by MatthewEshlemanAugust 13, 2019

I would second mr_bandit's advice.

I recently implemented a PID controller with many of the features you mention, but it is owned by my client. But, one thing I did, which you might want to do as well, was create a PC Qt based application with a "real time" graph output of the PID controller's output. The app contained all the necessary controls, widgets, and selectors to allow the mechanical engineer to play with the various values, inputs, and magic numbers, while visually watching the impact on the PID controller output in real time. The client loved it and it allowed the mechanical engineer to create the first set of adjustments without hardware. Obviously later the final adjustments were made with the real system/hardware.

Anyhow, using a PC to create the first code for this will let you experiment and perhaps move faster to solve these issues...  Good luck!


Matthew

https://covemountainsoftware.com/consulting/

[ - ]
Reply by MartinMohanaDecember 13, 2023

Hey Steven,


I know that this is a bit late, but I just came across this. To give you my two cents on your question about antiwind-up and bumpless transfer.


Antiwind up for the PID controller in velocity form is just simply limiting the control output to between min and max values.


Bumpless transfer happens "automatically", or naturally if you will, when the SP is set as current PV. Then the error must be zero as SP = PV and therefore the output of the PID controller in velocity form is 0, i.e. the requested change of the actuator is 0.


Hope it helps anyone else coming across this.

Martin


Reference: https://controlguru.com/integral-reset-windup-jack...

The 2024 Embedded Online Conference