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

4 vues (au cours des 30 derniers jours)
Zachary Olkin
Zachary Olkin le 18 Déc 2017
Réponse apportée : M le 8 Mar 2019
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');

Réponses (1)

M
M le 8 Mar 2019
  • 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.

Catégories

En savoir plus sur Electrical Block Libraries dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by