How can I plot an internal value in a state space model?

8 ビュー (過去 30 日間)
Zachary Olkin
Zachary Olkin 2017 年 12 月 18 日
回答済み: M 2019 年 3 月 8 日
I have a DC Motor model with a voltage and a torque disturbance as inputs, similar to this example (represented in code differently). I want to make sure that under no circumstances do I pass a voltage greater than 12 volts. So, I would like to plot, or saturate, the voltage value within my model so I get a more realistic representation. Given that the voltage is not a directly controlled input, I do no know how to get this value during a simulation.
In other words, if the image below represent my system, I would like to plot u during a simulation.
Currently my code looks like this:
%%Define Constants
j_motor = 0.01; % kg.m^2
j_load = 10; % kg.m^2
b_motor = 0.1; % N.m.s
b_load = 0.001; % N.m.s
k = 0.01;
r = 1; % ohms
L = .005; % henrys
G1 = 12;
G2 = 36;
j_t = j_motor + j_load*(G1/G2)^2;
b_t = b_motor + b_load*(G1/G2)^2;
%%Create State Space Representation
A = [-b_t/j_t k/j_t; -k/L -r/L];
B = [0 1/j_t; 1/L 0];
C = [1 0];
dcm = ss(A, B, C, 0);
%%Design with feed forward gains
Kff = 1./dcgain(dcm);
Kff = diag([Kff(1,1) 1]);
dcmff = dcm*Kff;
dcmff.InputName = {'voltage' 'disturbance torque'};
dcmff.OutputName = 'speed';
time = 0:.01:15;
Td = 50 * transpose((time>5 & time<7));
w_ref = 10* transpose(ones(size(time)));
u = [w_ref, Td];
figure
lsim(dcmff, u, time)
grid
title('Feed Forward Gain');
legend('Speed');
%%Design via pole placement
p1 = -10 + 10i;
p2 = -10 - 10i;
K = place(A,B,[p1 p2]);
dcm_cl = ss(A-(B*K), B, C, 0);
K_gain_cl = 1./dcgain(dcm_cl);
K_gain_cl = diag([K_gain_cl(1,1) 1]);
dcm_cl = dcm_cl * K_gain_cl;
dcm_cl.InputName = {'omega_ref' 'disturbance torque'};
dcm_cl.OutputName = 'speed';
figure
lsim(dcm_cl, u, time)
title('Pole Placement Compensator');
legend('Speed');

回答 (1 件)

M
M 2019 年 3 月 8 日
  • Given that the voltage is not a directly controlled input, I do no know how to get this value during a simulation.
Is u the voltage ? In this case, yes it is a controlled input.

カテゴリ

Help Center および File ExchangeMotor Drives についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by