Azzera filtri
Azzera filtri

step function with rise and fall times?

10 visualizzazioni (ultimi 30 giorni)
CD
CD il 24 Gen 2019
Commentato: Stephen23 il 24 Gen 2019
I'm looking for something similar to a step function where I can adjust the rise time, fall time and magnitude of the step height.
Suggestions?

Risposte (2)

CD
CD il 24 Gen 2019
How exactly does one us the lsim function?
I added "step(Zo)" and "lsim(Zo, u, t)" below to compare results.
With step I see results that I am expecting though I cannot modify step rise/fall times.
I'm not seeing any results with lsim.
Used the first examplefrom the lsim page:
https://www.mathworks.com/help/control/ref/lsim.html
%% Closed Loop Zo(s) = Zout(s)/(1 + T(s))
% Zout(s) Transfer Function Setup
L1 = 1e-6; % inductance
C1 = 200e-6; % output filter capacitance
Rs = 30e-3; % series resistance RL + Ron
Resr = 0.8e-3; % capacitor equivalent series resistance
R = 1e3; % load resistance
%% Zout(s) transfer function salient features
woD = 1/(sqrt(L1*C1));
QoD = 1/( woD*((Rs+Resr)*C1 + (L1/R)));
Z0 = Rs; % Zout(s) DC gain
woN = 1/(sqrt((Resr/Rs)*L1*C1));
QoN = 1/(woN*(Resr*C1 + (L1/Rs)));
w1N = QoN*woN;
w2N = woN/QoN;
%% Open-loop output impedance transfer function
s = tf('s');
Zout = Z0*( ((1 + s/w1N)*(1 + s/w2N))/(1+(1/QoD)*(s/woD)+(s/woD)^2) );
%% Loop gain T
L1 = 1e-6; % inductance
Rs = 30e-3; % series resistance RL + Ron
C1 = 200e-6; % output filter capacitance
Resr = 0.8e-3; % capacitor equivalent series resistance
Vg = 5; % input voltage
R = 1e3; % load resistance
VM = 1; % PWM saw-tooth amplitude
Vref = 1.8; % reference voltage
H = 1; % sensing gain
%% Gvd transfer function salient features
wesr = 1/(C1*Resr); % esr zero
wo = 1/sqrt(C1*L1); % center frequency of the pair of poles
Qload = R/sqrt(L1/C1);
Qloss = sqrt(L1/C1)/(Resr+Rs);
Q = Qload*Qloss/(Qload+Qloss); % Q factor
%% Open-loop control-to-output transfer function
s = tf('s');
Gvd = Vg*(1+s/wesr)/(1+(1/Q)*(s/wo)+(s/wo)^2);
%% PID compensator (see lecture slides)
R2 = 16e+3; % Compensator
R1 = 3e+3; % Compensator
R4 = 360e+0; % Compensator
C2 = 1.3e-9; % Compensator
C4 = 1.5e-9; % Compensator
Gc0 = R2/R1;
wL = 1/(C2*R2);
wz = 1/(C4*R1);
wp1 = 1/(C4*R4);
fL = wL/(2*pi);
fz = wz/(2*pi);
fp1 = wp1/(2*pi);
wp2 = 2*pi*1e6; % Added to protect OP AMP Gain BW product
%% Open-loop Gc(s) transfer function
s = tf('s');
Gc = Gc0*(1+wL/s)*(1+s/wz)/(1+s/wp1);
T = minreal( H*(1/VM)*Gvd*Gc );
Zo = minreal( Zout/(1 + T) );
figure(1)
step(Zo)
figure(2)
[u,t] = gensig('square',4,10,0.1);
lsim(Zo, u, t)

CD
CD il 24 Gen 2019
I understand how u is "shaped".
Why did you multiplied Zo by 200 (y*200)? "plot(t,y*200)"
What does function "tlim" do? Looks like you could replaced 51:end with 51:max(t)?
Ideally I would like to create a step like (trapezoid) function with various length rise and fall times:
  1. Trapezoid: Rise/fall times = 1 us, On time = 20 us,
  2. Trapezoid: Rise/fall times = 10 us, On time = 20 us.
  3. .... on so on (shorter/longer rise/fall times)
Appears as though sample time (time step per t element/column) comes from step ([y,t] = step(Zo)).
if t(0) = 1.2884e-7 seconds then
u "on time" would be (668-50)*1.2884e-7 seconds or 79 useconds.
u "rise time" would be 50*1.2884e-7 seconds or 6.4 useconds.
If I want to get rise/fall times of .001 useconds then I would need smaller sample time.
How can adjust sample time?
I'd probably need to set sample time before running the step function.
Thank you,
Craig
figure(1)
[y,t] = step(Zo);
tlim = [min(t) max(t) numel(t)];
plot(t,y)
figure(2)
u = [t(1:50)/t(50); ones(size(t(51:end)))];
[y,t] = lsim(Zo, u, t);
plot(t,y*200)
hold on
plot(t,u, ':k')
hold off
legend('y(t)', 'u(t) \cdot 200')
  1 Commento
Stephen23
Stephen23 il 24 Gen 2019
@Craig Dekker: please write comments in a comment field. Answers are for answering the question (and can move around, which makes them unsuitable for a discussion thread).

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by