Implementing PID regulator in multiple output system

4 visualizzazioni (ultimi 30 giorni)
Hi,
I have a problem with implementing PID regulator in my university project. I have to regulate the system and I think that means regulating the position of both masses 1 and 2. I have a state spece model of system, simulink model for system without PID and simulink model with a probably incorrectly installed PID controller. I'm not sure if the responses are correct and I need advice.
Can someone check my attempt and explain how to implement a PID controller for my problem?
Thanks guys :D .
Problem
State space model
Simulink without PID
m1 without PID
m2 without PID
With PID
m1 with PID
m2 with PID

Risposta accettata

Sam Chak
Sam Chak il 1 Set 2022
Since you have state-space model, it is recommended to implement linear state-space system using the State-Space Block. This may reduce human error when attempting to build a large system with many fundamental blocks. Troubleshoot is also easy.
By the way, what are the requirements of the responses in terms of desired settling time and percentage overshoot?
  2 Commenti
Nikola Smrecki
Nikola Smrecki il 2 Set 2022
The Professor did not say the necessary requirements, he only said that the system should be regulated with a PID controller. I think it's okay to have an overhang of 4-7%, but it would be ideal to have an aperiodic response.
Sam Chak
Sam Chak il 2 Set 2022
I added an example in the second Answer. The PID gains are tuned to achieve the shortest settling time (1.1 sec) for , but it exceeds 7% overshoot. You can tune the PID by setting . Overshot is less than 7%.

Accedi per commentare.

Più risposte (2)

Sam Chak
Sam Chak il 2 Set 2022
If you find the performances and tuning are acceptable, please consider voting 👍 the Answer. Thanks!
The Plants are 4th-order systems, but the PID is a 2nd-order compensator. Naturally, it is unable to satisfy all kinds of performance requirements. But we can try.
Since your Prof didn't specify the requirements, the PID gains are tuned across a range of the 0 dB gain crossover frequency [wc] of the tuned open-loop response to achieve the fastest settling time for the step response of without high overshoot and oscillatory transient response.
You can try this range if you want to converge within 10 seconds.
m1 = 2;
m2 = 1;
k1 = 2;
k2 = 1;
c1 = 6;
c2 = 3;
A = [0 1 0 0; -(k1+k2)/m1 -(c1+c2)/m1 k2/m1 c2/m1; 0 0 0 1; k2/m2 c2/m2 -k2/m2 -c2/m2];
B = [0; 1/m1; 0; 0];
C = [1 0 0 0; 0 0 1 0];
D = zeros(2, 1);
sys = ss(A, B, C, D);
G = tf(sys);
% Plant transfer function of Y2(s)/U(s)
Gp = G(2)
Gp = 1.5 s + 0.5 ---------------------------------- s^4 + 7.5 s^3 + 11.5 s^2 + 6 s + 1 Continuous-time transfer function.
% Design PIDF to achieve the shortest Settling Time for x2
wc = 3.5031;
Gc = pidtune(Gp, 'PIDF', wc)
Gc = 1 s Kp + Ki * --- + Kd * -------- s Tf*s+1 with Kp = 21.5, Ki = 7.31, Kd = 15.7, Tf = 0.0025 Continuous-time PIDF controller in parallel form.
% Closed-loop transfer function of Y2(s)/R(s)
Gcl2= minreal(feedback(Gc*Gp, 1))
Gcl2 = 9434 s^3 + 1.604e04 s^2 + 8688 s + 1463 ------------------------------------------------------------------------ s^6 + 407.8 s^5 + 3014 s^4 + 1.404e04 s^3 + 1.844e04 s^2 + 9088 s + 1463 Continuous-time transfer function.
% Closed-loop transfer function of Y1(s)/R(s)
Gcl1= minreal(feedback(Gc*G(1), 1))
Gcl1 = 3145 s^4 + 1.373e04 s^3 + 1.75e04 s^2 + 8688 s + 1463 ------------------------------------------------------------------------ s^6 + 407.8 s^5 + 6159 s^4 + 1.834e04 s^3 + 1.991e04 s^2 + 9088 s + 1463 Continuous-time transfer function.
S1 = stepinfo(Gcl1)
S1 = struct with fields:
RiseTime: 0.8186 TransientTime: 1.8087 SettlingTime: 1.8087 SettlingMin: 0.9010 SettlingMax: 1.0017 Overshoot: 0.1696 Undershoot: 0 Peak: 1.0017 PeakTime: 3.3561
S2 = stepinfo(Gcl2)
S2 = struct with fields:
RiseTime: 0.3853 TransientTime: 1.1218 SettlingTime: 1.1218 SettlingMin: 0.9279 SettlingMax: 1.0786 Overshoot: 7.8572 Undershoot: 0 Peak: 1.0786 PeakTime: 0.7973
Ts1 = S1.SettlingTime;
subplot(2, 1, 1)
step(Gcl1, round(3*Ts1)), grid on, title('Step Response of x_{1}')
subplot(2, 1, 2)
step(Gcl2, round(3*Ts1)), grid on, title('Step Response of x_{2}')
  1 Commento
Nikola Smrecki
Nikola Smrecki il 3 Set 2022
Thanks man :D, thanks, this is really helpful for comparing my code, I tried implementing the problem in Matlab code and got similar results. Another question, Do you know how to simulate sinusoidal response in matlab code?

Accedi per commentare.


Sam Chak
Sam Chak il 3 Set 2022
Thanks for your vote. You can use the gensig() function to generate the sine wave input, and then use lsim() to produce the output responses.
% parameters
m1 = 2;
m2 = 1;
k1 = 2;
k2 = 1;
c1 = 6;
c2 = 3;
A = [0 1 0 0; -(k1+k2)/m1 -(c1+c2)/m1 k2/m1 c2/m1; 0 0 0 1; k2/m2 c2/m2 -k2/m2 -c2/m2];
B = [0; 1/m1; 0; 0];
C = [1 0 0 0; 0 0 1 0];
D = zeros(2, 1);
sys = ss(A, B, C, D);
G = tf(sys);
% Plant transfer function of Y2(s)/U(s)
Gp = G(2)
Gp = 1.5 s + 0.5 ---------------------------------- s^4 + 7.5 s^3 + 11.5 s^2 + 6 s + 1 Continuous-time transfer function.
% Design PIDF to achieve the shortest Settling Time for x2
wc = 3.5031;
Gc = pidtune(Gp, 'PIDF', wc)
Gc = 1 s Kp + Ki * --- + Kd * -------- s Tf*s+1 with Kp = 21.5, Ki = 7.31, Kd = 15.7, Tf = 0.0025 Continuous-time PIDF controller in parallel form.
% Closed-loop transfer function of Y2(s)/R(s)
Gcl2= minreal(feedback(Gc*Gp, 1))
Gcl2 = 9434 s^3 + 1.604e04 s^2 + 8688 s + 1463 ------------------------------------------------------------------------ s^6 + 407.8 s^5 + 3014 s^4 + 1.404e04 s^3 + 1.844e04 s^2 + 9088 s + 1463 Continuous-time transfer function.
% Closed-loop transfer function of Y1(s)/R(s)
Gcl1= minreal(feedback(Gc*G(1), 1))
Gcl1 = 3145 s^4 + 1.373e04 s^3 + 1.75e04 s^2 + 8688 s + 1463 ------------------------------------------------------------------------ s^6 + 407.8 s^5 + 6159 s^4 + 1.834e04 s^3 + 1.991e04 s^2 + 9088 s + 1463 Continuous-time transfer function.
tau = 10; % one period cycle of the sine wave
[u, t] = gensig('sine', tau, 2*tau, 0.01);
subplot(2, 1, 1)
lsim(Gcl1, u, t), ylim([-1.5 1.5]), grid on, title('Step Response of x_{1}')
subplot(2, 1, 2)
lsim(Gcl2, u, t), ylim([-1.5 1.5]), grid on, title('Step Response of x_{2}')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by