Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Buck Converter Simulation in Python

VektorElektor

Newbie
Joined
Jun 29, 2023
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
21
Hey everybody, first time here!

As a personal project I am implementing a Buck Converter simulation in Python. My basic idea is to give a constant Vs supply and simulate the switch on/switch off steps in each switching period, calculate the increase/decrease in inductor current and calculate an output voltage Vo. The duty cycle is an input and the output voltage Vo should be a result.

I started with a Vo = 0 and Vs = 230V. I expected the current in the inductor to gradually grow until it would reach steady-state operation. However, I am incorrectly updating the Vo, so it remains constant all the way and the current keep growing and growing forever. I based switch on and switch off steps on my notes from the picture:

1688066503185.png


So in my simulation I'm following this process for each step (switch on for instance):
- Calculate the voltage drop in the inductor VL = Vs - Vo
- Calculate the current increase as /\iL = ( VL/ L ) * t_on
- Update the inductor current as iL = iL_past + /\iL

However, since the idea of a Buck Converter is to downstep the voltage, I'm also updating Vo like so:
- VL = L * ( /\iL / t_on )
- Vo = Vs - VL

This is where the Vo does not get updated and remains constant. I understand that I'm using the same formula to calculate iL from Vo and to calculate Vo from iL, so it's obviously redundant and wrong. Can someone help me rethink this? I'm also worried that a capacitor would be necessary in the output side, parallel to Vo.

Also please let me know if this should be in another subforum instead of here! thank you!!
 
The Inductive time constant ought to be included as a factor somewhere.
L/R

Low R, long TC
High R, short TC

What ohmic resistance is in the first half of the cycle? The second half?

The answer is down that path.
 
Modeling converter load as voltage source makes no sense. In a typical converter setup, Vo is a function of load impedance and average converter output current. There will be also an output capacitor, the relation between voltages and currents has to be described by a second order differential equation, respectively difference equations in a time discrete simulation.

You have to decide if you want to model an ideal synchronous buck converter or a switch + diode converter.

I believe that this circuit can be much easier simulated in full featured tool like LTspice.
 
Special math algorithms are needed for SMPS simulators.....due to the need for resolving things at the nanosecond level, and at the millisecond + level.
The Dr from old linear.com invented the "modified trap" method for the LTspice simulator.
Dr Mike Engelhardt..........he does public talks on his excellent invention of LTspice.
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top