How to control two values from a matrix with one PID-controller?

Hi, is it possible to control two values (velocities) at once from one matrix with a PID-controller? In this task, there is a car accelerated with the force F. A trailer is coupled with the car by a spring (k). The car has a velocity v1 (shown in matrix C = [0 1 0 0]) and the trailer has a velocity v2 (shown in matrix C = [0 0 0 1]).
g = 9.81;
M1=1000; % mass car in kg
M2=1000; % mass trailer in kg
k=10; % spring constant in N/m
F=2600; % accelerating force in N
u=0.015; % friction constant in s/m
A=[ 0 1 0 0; % matrix with dynamic equations
-k/M1 -u*g k/M1 0;
0 0 0 1;
k/M2 0 -k/M2 -u*g];
B=[ 0;
1/M1;
0;
0];
C=[0 1 0 0
0 0 0 1]; %Graphs velocities
D=[0];
v=ss(A,B,C,D);
stepplot (v, 100)
title(' v1 und v2')
hold on
[Eigenwerte, Eigenvektoren] = eig (A)
%-----> the following does NOT work to control both velocities (car and trailer)
Kp=350;
Ki=300;
Kd=5000;
contr= Kp;
sys_cl= feedback (contr*v, 1);
t = 0: 0.0001: 100;
step(sys_cl,100)

 Réponse acceptée

what do you mean when you say "control two velocities". You can have a PID controller on car speed or trailer speed that would bring both speeds to the same desired level in steady state.
D=zeros(2,1);
v=ss(A,B,C,D);
contr=pidtune(v(1,1),'pid');
feedin=[1];
feedout=[1];
ol=contr*v;
cloop=feedback(ol,1,feedin,feedout);
step(cloop(1,:));
hold on;
step(cloop(2,:),'r');
legend('car speed','trailer speed');

Plus de réponses (0)

Catégories

En savoir plus sur Control System Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by