# step response in 3 scenarios: setting the initial reference voltage, shifting to another output voltage level

조회 수: 10 (최근 30일)
mostafa jabbari 2024년 3월 21일
댓글: Sam Chak 2024년 3월 22일
hello friends,
A buck converter with a PID controller has a transfer function. .By applying three different scenarios, the figure below is obtained, the blue line is the solution to the problem after three scenarios. In the first stage, the transfer function is applied by applying a Vref=12v from t=0 to 2e-6. In the second scenario, from the t= 2e-6 to 4e-6, the reference voltage has decreased to 6 volts(Vref=6v), and in the third scenario, a disturbance voltage of 1 volt has been applied the system. I wrote the step response for a reference voltage of 12V, but I don't know how to apply the next two scenarios to form the graph.
% Define the numerator and denominator coefficients of the transfer function
umerator_coeffs = [0.3571 605.8 42.27]; % Adjust coefficients as per your scaling factor
denominator_coeffs = [0.0000001 0.3573 606.8 42.27]; % Adjust coefficients as per your transfer function
% Create a transfer function object
sys = tf(numerator_coeffs, denominator_coeffs);
step(12*sys); % Simulate step response
xlabel('Time');
ylabel('Step Response');
title('Step Response');

댓글을 달려면 로그인하십시오.

### 채택된 답변

Sam Chak 2024년 3월 21일
편집: Sam Chak 2024년 3월 22일
Please note that only the first two stages can be simulated since it's unclear through which channel the disturbance is introduced into the system. If the disturbance follows the block diagram provided below, then the information provided for Stage 3 is insufficient.
• Additionally, the transfer functions for Gp (buck converter) and Gc (PID controller) have not been provided, which makes it challenging to proceed with accurate simulations.
• Furthermore, it is unclear whether the disturbance in Stage 3 is in the form of an impulse signal or a continuous-time signal. Clarification on this point would be helpful in refining the simulation.
• Lastly, you mentioned that the reference voltage Vref = 6 is only sustained from time t = 2e-6 to 4e-6. Can I assume that it drops to zero starting from t = 4e-6 onwards?
Edit: The block diagram and code have been updated according to the additional information provided by the OP. As the closed-loop system is a Linear Time-Invariant (LTI) system, we can apply the superposition principle. This principle states that the net output response resulting from the reference and disturbance signals is the sum of the individual responses caused by each signal separately.
%% Redefine the value of Heaviside function H(u) at u = 0.
newVal = 1;
oldVal = sympref('HeavisideAtOrigin', newVal);
%% time vector for simulation
tEnd= 6e-6;
t = linspace(0, tEnd, 6001);
%% Buck converter (plant), Gp
Gp = tf(216000, [0.0006, 1, 6000])
Gp = 216000 --------------------- 0.0006 s^2 + s + 6000 Continuous-time transfer function.
%% PID controller (compensator), Gc
Gc = pid(16.8278, 1.1742, 0.00992) % improper
Gc = 1 Kp + Ki * --- + Kd * s s with Kp = 16.8, Ki = 1.17, Kd = 0.00992 Continuous-time PID controller in parallel form.
%% closed-loop system, Gcl
Gcl = feedback(Gc*Gp, 1)
Gcl = 2143 s^2 + 3.635e06 s + 2.536e05 --------------------------------------------- 0.0006 s^3 + 2144 s^2 + 3.641e06 s + 2.536e05 Continuous-time transfer function.
%% reference voltage input
r = 12*heaviside(t) - 6*heaviside(t - 2e-6);
%% signal that disturbs the response at the output channel
do = 1*heaviside(t - 4e-6);
%% simulated time response
yr = lsim(Gcl, r, t); % output response due to reference
yd = lsim(Gcl, do, t); % output response due to disturbance at the output channel
yt = yr - yd; % true output response
ym = yt + do'; % measured output response
plot(t, [ym'; r; do]), grid on, ylim([0, 14])
xlabel('t'), ylabel('y(t)')
legend('Measured Output', 'Reference Input', 'Disturbance')
##### 댓글 수: 5이전 댓글 3개 표시이전 댓글 3개 숨기기
mostafa jabbari 2024년 3월 22일
Tanks a lot, your code is corroct.
Sam Chak 2024년 3월 22일
I'm glad to hear that it worked correctly. If you found the example on Superposition Principle helpful, please consider clicking 'Accept' ✔️ on the answer and voting 👍 for it.
By the way, you have another unclosed thread in the link below. You can comment or request more details if the solution described in the answer is unclear.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 PID Controller Tuning에 대해 자세히 알아보기

R2023b

### Community Treasure Hunt

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

Start Hunting!

Translated by