2
\$\begingroup\$

I need to model a boost circuit with the following topology:

schematic

simulate this circuit – Schematic created using CircuitLab

I am interested in the resistor voltage, so I found the differential equation of each state and solved them by Euler's implicit method, alternating the equation to be solved as the state was changed.

I compared the results with a circuit simulator. Each differential equation is right alone, but when I put them together, one after the other, forming the boost switched dynamic, the result is wrong.

These are my steps:

'ON state' differential equation (just the capacitor discharge)

$$\frac{dV_{out}}{dt} = -\frac{V_{out}}{RC}$$

'OFF state' differential equation

$$\frac{d^2V_{out}}{dt^2} + \frac{1}{RC}\frac{dV_{out}}{dt} + \frac{1}{LC}V_{out} = \frac{V_{in}}{LC}$$

This is my (MATLAB) code:

R = 10; 
L = 1e-5; 
C = 1e-4;
Vin = 10; 

h = 1e-6;   % time step
sizeVector = 10000; % number of steps
t = 0:h:sizeVector*h-h;  % time vector

Vout = zeros(1,sizeVector); % output voltage vector
dVout = zeros(1,sizeVector); % first derivative vector

freqSw = 5e3; % switching frequency
D = zeros(1,sizeVector); % State of switch for each simulation step (duty cycle = 0.5)
D = sign(cos(2*pi*freqSw.*t + pi/2 + 0.001));
D(D<0) = 0;

for k=2:sizeVector
    if D(k) == 0
        % Off state
        Vout(k) = (Vout(k-1) + h*((dVout(k-1) + (h/(L*C))*Vin)/(1 + h/(R*C))))/(1 + (h^2/(L*C))/(1 + h/(R*C)));
        dVout(k) = (dVout(k-1) + h*(Vin/(L*C) - Vout(k)/(L*C)))/(1 + h/(R*C));
    end
    if D(k) == 1
        % On state
        Vout(k) = Vout(k-1)/(1+h/(R*C));
        dVout(k) = (Vout(k)-Vout(k-1))/h; % just for convenience
    end

end


figure(1)
plot(t,Vout)
xlabel('Time (s)')
ylabel('Voltage (V)')
hold on

These are the comparations between PSIM results (red) and my code in MATLAB (blue). (For the capacitor discharge, I considered in both cases a initial voltage of 10V)

Open state:

enter image description here

Closed state:

enter image description here

Boost converter as in the code above:

enter image description here

I can never get steady state voltage superior than my input voltage (10V, in this case), but the waveform seems to consistent with each one of the states waveforms separately..

There must be an error in my code or am I missing some important point? Is this kind of solving possible?

Edited after answers:

Following the sugestions, I changed the second order differential equation into a system of two first order equations, in order to calculate the inductor's current, which is necessary because when the 'off state' begins, the inductors current must be a initial condition. In the previous model, I wasn't considering the current change on the 'on state'.

The 'off state' system:

\begin{equation} \begin{bmatrix} \frac{dV_{out}}{dt}\\ \frac{dI_{ind}}{dt} \end{bmatrix} = \begin{bmatrix} -\frac{1}{RC} & \frac{1}{C}\\ -\frac{1}{L} & 0 \end{bmatrix} \times \begin{bmatrix} V_{out}\\ I_{ind} \end{bmatrix} + \begin{bmatrix} 0\\ \frac{Vin}{L} \end{bmatrix} \end{equation}

The 'on state' system: (it's actually not a system, but I keep it matricial for simplicity)

\begin{equation} \begin{bmatrix} \frac{dV_{out}}{dt}\\ \frac{dI_{ind}}{dt} \end{bmatrix} = \begin{bmatrix} -\frac{1}{RC} & 0\\ 0 & 0 \end{bmatrix} \times \begin{bmatrix} V_{out}\\ I_{ind} \end{bmatrix} + \begin{bmatrix} 0\\ \frac{Vin}{L} \end{bmatrix} \end{equation}

There is still one problem. In this way, I can't prevent the inductor's current from being negative in the 'off state', so I inserted an if statement in every 'off state' iteration. If \$I_{ind} < 0\$, solve the system again imposing \$I_{ind} = 0\$. This can be made just setting to zero the elements related to \$I_{ind}\$ in the matrix.

Below are the result comparison (PSIM, first, MATLAB second) and the code.

enter image description here

R = 10; 
L = 1e-3; 
C = 1e-4;
Vin = 10; % DC input voltage

h = 1e-7;                % step
sizeVector = 120000;     % number of steps
t = 0:h:sizeVector*h-h;  % time vector

X = zeros(2,sizeVector); % state vector 

A = [-1/(R*C) 1/C ; -1/L 0]; % off state matrix
b = [0; Vin/L];              % off state vector

Aaux = [-1/(R*C) 0 ; 0 0];   % off state auxiliar matrix
baux = [0 ; 0];              % off state auxiliar vector

A2 = [-1/(R*C) 0; 0 0];      % on state matrix
b2 = [0; Vin/L];             % on state vector

freqSw = 5e3;               % switching frequency
D = zeros(1,sizeVector); % State of switch for each simulation step (duty cycle = 0.5)
D = sign(cos(2*pi*freqSw.*t + pi/2 + 0.001));
D(D<0) = 0;

for k=2:sizeVector

    if D(k) == 0 % off state 
        X(:,k) = (inv(eye(length(A)) - h*A))*(X(:,k-1) + h*b);
        if X(2,k) < 0 % avoid Iind < 0
            X(:,k) = (inv(eye(length(Aaux)) - h*Aaux))*(X(:,k-1) + h*baux);
        end

    end
    if D(k) == 1 % on state
        X(:,k) = (inv(eye(length(A2)) - h*A2))*(X(:,k-1) + h*b2);
    end
end


figure(1)
plot(t,X(1,:))
hold on
plot(t,X(2,:))
xlabel('Time (s)')
ylabel('Voltage (V)\Current(A)')
legend('V_{out}','I_{in}')
ylim([-6 36])
grid
hold on
\$\endgroup\$
4
  • \$\begingroup\$ Welcome to EE.SE. What is the value of 'L' ? Did you forget that with the switch closed L charges up as a magnetic field, and dumps its charge as a 'boost' when the switch is open. Normally a mosfet is the switch running at tens of KHZ, and L is 10uH or greater. 'C' filters out the ripple so the load sees a smooth DC voltage. The diode is a high-speed type. \$\endgroup\$
    – user105652
    Jan 16, 2018 at 3:23
  • \$\begingroup\$ You need to have an equation for what happens to the inductor current in the "on state". \$\endgroup\$
    – The Photon
    Jan 16, 2018 at 3:36
  • \$\begingroup\$ In this example, L = 0.01 H. As I am just interessed in output voltage, I completely missed the inductor charging in the 'on state'. I got the point, now I just need to think how to take the inductor energy into account every time the 'off state' is reached. Thank you very much, Sparky256 and The Photon! \$\endgroup\$ Jan 16, 2018 at 3:50
  • \$\begingroup\$ Yeah when you are running the "Off state" part of the simulation you need to start with the inductor current not zero but equal to where the "On state" left it. The challenge is how to express that IC (initial condition) to your (Matlab) simulation. \$\endgroup\$
    – user16324
    Jan 16, 2018 at 11:34

2 Answers 2

0
\$\begingroup\$

I can see at least one thing wrong with your equations (I haven't reviewed your code):

  • There should be an equation describing the evolution of the inductor current during the "on state".

I would probably just keep a system of two first-order equations rather than try to write a 2nd order equation. It won't take Matlab any longer to solve it that way.

\$\endgroup\$
0
\$\begingroup\$

One way to analyze boost conversion is to compute the energy stored in the inductor based on Switch time, Ton, current, I inductance,L when the switch is closed then equate that to the energy dissipated in the load in a regulated loop.

P_in = 0.5 * L I²/T ( Energy/time when switch is ON)
Pout = 0.5 * I * Vin * Toff/T (Power Out)
Assuming lossless switching
output voltage \$Vo=Vin\sqrt{\dfrac{kR_LT_{on}}{2L}}\$ for 0< k< 1 with a regulated loop

\$\endgroup\$
5
  • \$\begingroup\$ Perharps I didn't emphasized, but I need a time domain representation of voltage, including its transient. I am working on an algorithm to handle real time interstep delays which occur in switched circuit simulations. This model is for evaluating the algorithm and is supposed to run on an embedded environment, aiming real time simulation. \$\endgroup\$ Jan 16, 2018 at 11:25
  • \$\begingroup\$ Then your motives are certainly unclear. Reinvent the wheel? or improve existing models and simulators? \$\endgroup\$ Jan 16, 2018 at 17:01
  • \$\begingroup\$ My purpose is to study algorithms that handle switching delays in real time simulations. In a first approach, I will try to reproduce some papers' results regarding this subject, like this: link. The boost model will be used as a case study for evaluating the algorithms performance. \$\endgroup\$ Jan 16, 2018 at 20:08
  • \$\begingroup\$ So you want to compare EMT, ATP, PSCAD, etc... \$\endgroup\$ Jan 16, 2018 at 20:38
  • \$\begingroup\$ Perhaps what you need instead is PLECS software plexim.com/sites/default/files/flyers/flyer_smps_letter.pdf \$\endgroup\$ Jan 16, 2018 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.