Discretization of a PID controller | pressku.com

Trending 5 months ago

I've been fixed a works transportation usability to power trough a PID. The transportation usability is:

$G_{\small{p}}(s) = \frac{1}{(1+s)(1+2s)}$

Doing a small activity pinch matlab I sewage this PID controller transportation function:

$G_{\small{c}}(s) = 3 + \frac{1}{s} + \frac{2s}{1+\frac{s}{60}}$

So $K_{\small{p}} = 3, K_{\small{i}} = 1, K_{\small{d}} = 2$ (note that I needed to put an precocious wave rod into derivative word to support it real)

Checking nan measurement consequence connected matlab everything seems to activity really fine.

blue is Gc, orangish Gc without hf pole

Now I request to discretize specified controller usability and supply anti-windup functionality, I'm not an master but since I request an antiwindup I deliberation I request to disagreement nan integral action from nan proportional and derivative action.

Using Tustin method and a sampling clip of 1e-3 I sewage these:

uP[k] = 3*e[k] uI[k] = 0.0005*(e[k] + e[k-1]) + uI[k-1] uD[k] = 116.5*(e[k] - e[k-1]) + 0.9417 * uD[k-1]

of people nan resulting bid will beryllium u[k] = uP[k] + uI[k] + uD[k]

The C codification become:

double control(const double y, const double r) { fixed double e[2] = { 0, 0 }; // e[0] -> e_k-1, e[1] -> e_k fixed double uD[2] = { 0, 0 }; // uD[0] -> uD_k-1, uD[1] -> uD_k fixed double uI[2] = { 0, 0 }; // uI[0] -> uI_k-1, uI[1] -> uI_k double uP, u; e[1] = r - y; uP = Kp * e[1]; uI[1] = Ki * (e[1] + e[0]) + uI[0]; uD[1] = Kd1 * (e[1] - e[0]) + Kd2 * uD[0]; u = uP + uI[1] + uD[1]; // Cut-Off if(u>MAX_CMD){ u = MAX_CMD; } other if(u<MIN_CMD) { u = MIN_CMD; } // e[0] = e[1]; uD[0] = uD[1]; uI[0] = uI[1]; return u; }

I deliberation each measurement is correct but I don't consciousness very comfortable pinch specified precocious derivative position and debased integral. And moreover I cannot fig retired an effective antiwindup characteristic (I ever utilized it connected PI controllers ne'er connected PID). Something for illustration that should work?

// Cut-Off if(u>MAX_CMD){ u = MAX_CMD; uI[1] = 0; // Antiwindup } other if(u<MIN_CMD) { u = MIN_CMD; uI[1] = 0; // Antiwindup } //
More
close