How to create Kp as a function of model output(s)
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi,
I have a feedback model with the following parameters
2 inputs (i and fs)
4 states (x1, x2, x3, x4)
4 outputs (y1=x1, y2=x2, y3=x3, y4=x4)
fs depends on the output y2 and y4. Basically it should oscillate between 0 and fs-Max based on the output y2 and y4. I am providing this input as fs-Max and will have a feedback loop to control its input.
if true
G = suspension_setting_selection; % Gain function based on suspension setting
[fs] = repmat(G,[m,n]); % hybrid damper force function
A = [0 1 0 -1; -1*ks/Ms -1*bs/Ms 0 bs/Ms; 0 0 0 -1; ks/Mu bs/Mu kt -1*bs];
B = [0 0; 0 1/Ms; 1 0; 0 -1];
C = eye(4);
D = zeros(4,2);
states = {'susp deform', 'Ms velocity', 'tire deform', 'Mu velocity'};
inputs = {'Road velocity', 'Semi-active damper force'};
outputs = {'susp deform', 'Ms velocity','tyre deform', 'Mu velocity'};
sys_mimo = ss(A, B, C, D, 'statename',states,...
'inputname',inputs,...
'outputname',outputs); % state space model
size(sys_mimo) % Gives information of the MIMO state space model
sys_mimo_tf = tf(sys_mimo); % convert state space model to transfer function
%{
Feedback strategies
***********REFERENCE******************************************************
sys_mimo_tf(1,1) % TF i/p Road velocity to o/p Suspension Deformation
sys_mimo_tf(1,2) % TF i/p SA Damper Force to o/p Suspension Deformation
sys_mimo_tf(2,1) % TF i/p Road Velocity to o/p Ms Velocity
sys_mimo_tf(2,2) % TF i/p SA Damper Force to o/p Ms Velocity
sys_mimo_tf(3,1) % TF i/p Road velocity to o/p tyre deformation
sys_mimo_tf(3,2) % TF i/p SA Damper Force to o/p tyre deformation
sys_mimo_tf(4,1) % TF i/p Road Velocity to o/p Mu velocity
sys_mimo_tf(4,2) % TF i/p SA Damper Force to o/p Mu velocity
-------------------------------------------------------------------------
%}
% PID control for sys_mimo_tf(1,2)
Kp=0;
if y(2)*[y(2)-y(4)] > 0
Kp = G*alpha*y(2) % y(2) = velocity at that instant
end
H = pid(Kp);
sys_mimo_tf(1,2) = feedback(sys_mimo_tf(1,2),H);
% PID control for sys_mimo_tf(3,2)
Kp=0;
if -1 * y(4)*[y(2)-y(4)] > 0
Kp = G*alpha*y(4) % y(4) = velocity at that instant
end
H = pid(Kp);
sys_mimo_tf(3,2) = feedback(sys_mimo_tf(3,2),H);
end
The if block has syntactical errors but what I want to achieve is this:
1. Kp should be a dynamic value which depends on the instantaneous values of y2 and y4.
How do I create the Kp from the PID controller as a function of y2 and y4 from the output vector.
Thanks. Shilp
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!