PID – Intuitive / Interactive
We can also write the controller in transfer function form:
U(z) B
0
+ B
1
*z
-1
+ B
2
*z
-2
B
0
z
2
+ B
1
*z + B
2
------ = ------------------------- = ----------------------
E(z) 1 - z
-1
z
2
– z
Compare with the General 2P2Z transfer function:
U(z) B
0
+ B
1
*z
-1
+ B
2
*z
-2
B
0
z
2
+ B
1
*z + B
2
------ = --------------------------- = ----------------------
E(z) 1 + A
1
*z
-1
+ A
2
*z
-2
z
2
+ A
1
*z + A
2
We can see that PID is nothing but a special case of 2P2Z control where:
A
= -1 and A
= 0
// Coefficient init
Coef2P2Z_1[0] = Dgain * 67108; // B2
Coef2P2Z_1[1] = (Igain - Pgain - Dgain - Dgain)*67108; // B1
Coef2P2Z_1[2] = (Pgain + Igain + Dgain)*67108; // B0
Coef2P2Z_1[3] = 0; // A2
Coef2P2Z_1[4] = 67108864; // A1
Coef2P2Z_1[5] = Dmax[1] * 67108; // Clamp Hi limit (Q26)
Coef2P2Z_1[6] = 0x00000000; // Clamp Lo
Change PID coeff. “on fly” in back-ground loop