the average state space model system using the Euler method

3 views (last 30 days)
The unit step response of the average state space model system using the Euler method differs slightly in amplitude from the step response of the Buck converter transfer function. Which method would you prefer to use instead of Euler, which is not as complicated as the differential equation?
Best regards,
% Buck converter parameters
L = 1e-3; % Inductance in Henry
C = 100e-6; % Capacitance in Farad
R = 5; % Load resistance in Ohm
Vin = 40; % Input voltage in Volt
Vref = 20; % Desired output voltage in Volt
f = 200e3; % Switching frequency in Hz
Tfinal = 0.01; % Simulation time in seconds
% Time vector
Ts = 1e-6; % Simulation step size
t = 0:Ts:Tfinal; % Time vector
N = length(t); % Number of simulation points
% State-space matrices (average model)
A = [ 0 -1/L;
1/C -1/(R*C) ];
B = [ Vin/L;
0 ];
% Initial conditions
x = zeros(2, N); % x(1,:) = iL (inductor current), x(2,:) = Vo (output voltage)
% Duty cycle (assumed constant for open-loop case)
D = Vref / Vin; % Ideal duty cycle to achieve Vref at steady state
% Simulation loop using Euler integration
for k = 1:N-1
dx = A * x(:,k) + B * D;
x(:,k+1) = x(:,k) + Ts * dx;
end
% Plotting results
figure;
subplot(2,1,1);
plot(t, x(1,:), 'b', 'LineWidth', 1.5);
ylabel('i_L (A)');
grid on;
title('Buck Converter - Average Model Simulation');
subplot(2,1,2);
plot(t, x(2,:), 'r', 'LineWidth', 1.5);
ylabel('V_o (V)');
xlabel('Time (s)');
grid on;
Gvd=tf([Vin/(L*C)],[1 1/(R*C) 1/(L*C)]);
step(Gvd);

Accepted Answer

Sam Chak
Sam Chak on 22 Apr 2025
In the simulation of the transfer function Gvd, you forgot to multiply the transfer function with the Duty Cycle 'D'.
% Buck converter parameters
L = 1e-3; % Inductance in Henry
C = 100e-6; % Capacitance in Farad
R = 5; % Load resistance in Ohm
Vin = 40; % Input voltage in Volt
Vref = 20; % Desired output voltage in Volt
f = 200e3; % Switching frequency in Hz
Tfinal = 0.01; % Simulation time in seconds
% Time vector
Ts = 1e-6; % Simulation step size
t = 0:Ts:Tfinal; % Time vector
N = length(t); % Number of simulation points
% State-space matrices (average model)
A = [ 0 -1/L;
1/C, -1/(R*C)];
B = [Vin/L;
0];
Cout= eye(2);
sys = ss(A, B, Cout, []);
G = tf(sys)
G = From input to output... 40000 s + 8e07 1: ------------------- s^2 + 2000 s + 1e07 4e08 2: ------------------- s^2 + 2000 s + 1e07 Continuous-time transfer function.
% Initial conditions
x = zeros(2, N); % x(1,:) = iL (inductor current), x(2,:) = Vo (output voltage)
% Duty cycle (assumed constant for open-loop case)
D = Vref / Vin; % Ideal duty cycle to achieve Vref at steady state
% Simulation loop using Euler integration
for k = 1:N-1
dx = A*x(:,k) + B*D;
x(:,k+1) = x(:,k) + Ts*dx;
end
fun = @(T, X) A*X + B*D;
[T, X] = ode45(fun, t, [0; 0]);
% Plotting results
figure;
subplot(2,1,1);
hold on
plot(t, x(1,:), 'b');
plot(T, X(:,1), 'b--', 'LineWidth', 1.5);
hold off
legend('Euler', 'ode45', 'location', 'southeast')
ylabel('i_L (A)');
title('Buck Converter Current')
grid on;
subplot(2,1,2);
hold on
plot(t, x(2,:), 'r');
plot(T, X(:,2), 'r--', 'LineWidth', 1.5);
hold off
legend('Euler', 'ode45', 'location', 'southeast')
ylabel('V_o (V)');
xlabel('Time (s)');
title('Buck Converter Voltage')
grid on;
sgtitle('Buck Converter - Average Model Simulation');
figure
subplot(211)
Gid = G(1)
Gid = 40000 s + 8e07 ------------------- s^2 + 2000 s + 1e07 Continuous-time transfer function.
[y1, t1] = step(D*Gid, Tfinal);
plot(t1, y1, 'b'), grid on
title('Step Response of Buck Converter Current')
subplot(212)
Gvd = tf([Vin/(L*C)], [1 1/(R*C) 1/(L*C)])
Gvd = 4e08 ------------------- s^2 + 2000 s + 1e07 Continuous-time transfer function.
[y2, t2] = step(D*Gvd, Tfinal);
plot(t2, y2, 'r'), grid on
title('Step Response of Buck Converter Voltage')
sgtitle('Buck Converter - Simulation of Transfer functions');

More Answers (0)

Categories

Find more on Electrical Block Libraries in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!