7 views (last 30 days)
Elli on 28 Feb 2024
Answered: Sam Chak on 1 Mar 2024
I have set up a control loop, see attachment, and can't find any values for the PID controller once I install the sensor. I adjusted the values without the sensor using the frequency response method and verified them with Nyquist criterion. These methods are valid without a measuring device. The autotuning feature of Simulink keeps giving me incorrect values. In this system, an electromagnet is used to try to keep a metal ball suspended in air. The control loop consists of a controller, current controller (cascade control), process, and sensor. The upper control loop represents the actual control loop, while the lower one represents the linearized form. In both, the sensor is not installed, and the process is still stable.

Sam Chak on 29 Feb 2024
Hi @Elli,
The 3rd-order linearized system is unstable because the second transfer function has a pole located in the right half of the s-plane. Consequently, even though the PIDF controller block has auto-tuning capabilities, it may be unable to stabilize the system due to its limited number of poles (only 2).
The dynamics of the system can be described by a 3rd-order differential equation. If all three states can be measured, it is possible to design a full-state feedback controller. However, if only the output (state ) is available, an observer-based controller needs to be manually designed using the separation principle.
Plant
Full-state feedback controller (if all states are measurable)
%% Plant
s = tf('s');
G1 = 0.1/(0.03*s + 1)
G1 = 0.1 ---------- 0.03 s + 1 Continuous-time transfer function.
G2 = tf(0.884, [-0.01 0 39.07])
G2 = -0.884 ---------------- 0.01 s^2 - 39.07 Continuous-time transfer function.
Gp = minreal(series(G1, G2));
Gp = compreal(Gp);
Gp = ss(Gp.A', Gp.C', Gp.B', Gp.D')
Gp = A = x1 x2 x3 x1 0 1 0 x2 0 0 1 x3 1.302e+05 3907 -33.33 B = u1 x1 0 x2 0 x3 -294.7 C = x1 x2 x3 y1 1 0 0 D = u1 y1 0 Continuous-time state-space model.
%% Call ode45 solver
[t, x] = ode45(@odefcn, [0 4], [0; 0; 0]);
plot(t, x(:,1)), grid on, xlabel('t'), ylabel('x(t)')
%% Differential equations
function dxdt = odefcn(t, x)
% Full-state feedback controller
xref = 1;
u = (0.03/8.84)*((24 - 1/0.03)*x(3) + (3907 + 192)*x(2) + 512*(((3907/0.03 + 512)/512)*x(1) - xref));
% Plant
dxdt(1,1) = x(2);
dxdt(2,1) = x(3);
dxdt(3,1) = 3907/0.03*x(1) + 3907*x(2) - 1/0.03*x(3) - 8.84/0.03*u;
end
Observer-based controller (if only the output can be measured)

Sam Chak on 1 Mar 2024
I faced difficulties in effectively stabilizing the unstable 3rd-order system using solely the PID controller. Even though the closed-loop system was technically 'stable', the transient response did not meet my expectations. As a result, I had to employ a 3rd-order Compensator and a Pre-filter to achieve the desired outcome. The figure below illustrates a comparison with the Observer-based Controller (which I designed yesterday). Both approaches were designed to meet the settling time requirement of ≤ 1 second.
s = tf('s');
%% Plant, Gp
G1 = 0.1/(0.03*s + 1);
G2 = tf(0.884, [-0.01 0 39.07]);
Gp = minreal(series(G1, G2))
Gp = -294.7 ----------------------------------- s^3 + 33.33 s^2 - 3907 s - 1.302e05 Continuous-time transfer function.
%% Compensator, Gc
cz = [-32.9308607744069 + 2.19341926182744i, -32.9308607744069 - 2.19341926182744i];
cp = [-2.3880571645169 + 67.9271543482382i, -2.3880571645169 - 67.9271543482382i, -34.0524593508891];
ck = -63840.8149251998;
Gc = tf(zpk(cz, cp, ck))
Gc = -6.384e04 s^2 - 4.205e06 s - 6.954e07 ------------------------------------- s^3 + 38.83 s^2 + 4782 s + 1.573e05 Continuous-time transfer function.
%% Prefilter, Gf
fz = [];
fp = [-32.9308607744069 + 2.19341926182744i, -32.9308607744069 - 2.19341926182744i];
fk = 0.160883340684378;
Gf = tf(zpk(fz, fp, fk))
Gf = 0.1609 -------------------- s^2 + 65.86 s + 1089 Continuous-time transfer function.
%% Filtered closed-loop system, Gclf
Gcl = feedback(Gc*Gp, 1);
Gclf= minreal(series(Gf, Gcl))
Gclf = 3.026e06 ------------------------------------------------------------------------------- s^6 + 72.16 s^5 + 2170 s^4 + 3.479e04 s^3 + 3.138e05 s^2 + 1.51e06 s + 3.026e06 Continuous-time transfer function.
%% Step response
step(Gclf, 4), grid on
%% Root locus
rlocus(Gc*Gp), grid on, axis([-80 80 -40 40])