* Z:\home\khalils\Downloads\files\data\raw_asc\451c31da45f6_BUCK_CONVERTER.asc
* Generated by LTspice 26.0.1 for Windows.
* *-----------------------------------------------------------\n*User Values\n*-----------------------------------------------------------\nInput = 12V \nOutput = 5V a 1A\nTs = 20us \nTon = 8.33us \nVripple = 15%\n*-----------------------------------------------------------\n*Calculations\n*-----------------------------------------------------------\nD = Ton/Ts = 41.65% \nILoad = Vout / RLoad = 5 A\nRload = Vout / ILoad = 5V/1A = 5 Ohms\nF = 1/Ts = 1/20u = 50KHz\nLmin = ([1-D)*R]/(2*f) =29.18uH\nL = Lmin * 1.25 = 29.18uH * 1.25 = 36.47 uH\nC = (1-D)/[8*L(Delta_Vout/Vout)f**2] = 5.33uF\n \n*-----------------------------------------------------------\nDelta Vout = Vout * Vripple = 5V * 15% = 750mV \nDelta ILoad = 1.59A \nI_load_max = 1.795A \nI_load_min = 0.205A
*----------------------------------------------------------------
*Measaurements
*----------------------------------------------------------------
*.INCLUDE BUCK_CONVERTER.meas
*.lib BUCK_CONVERTER.asc
*----------------------------------------------------------------
*Parameters: User Input
*----------------------------------------------------------------
*Vctrl Parameters
*----------------------------------------------------------------
*----------------------------------------------------------------
*Parameters: Automatic Calculation
*----------------------------------------------------------------
RLoad out 0 {Rload_cal}
S1 N001 in ctrl 0 SW
D1 0 N001 D
Vctrl ctrl 0 PULSE({p_Vinitial} {p_Von} {p_Tdelay} {p_Trise} {p_Tfall} {p_Ton} {p_Ts})
C1 out 0 {C_cal}
L1 N001 out {L_cal}
Vin in 0 {p_Vin}
.model D D
.lib C:\users\khalils\AppData\Local\LTspice\lib\cmp\standard.dio
.MODEL SW VSWITCH(VON=5V VOFF=0V RON=0.01 ROFF=1MEG)
.MODEL DSCH D( IS=0.0002 RS=0.05 CJO=5e-10 )
.tran 10m
.lib A:\meas_from_perl.meas ; from pearl and connect with ubuntu
.PARAM p_Vinitial 0
.PARAM p_Von 5
.PARAM p_Tdelay 0
.PARAM p_Trise 0.01u
.PARAM p_Tfall=0.01u
.PARAM p_Vin 12V
.PARAM p_Vout 5V
.PARAM p_iout 1A
.PARAM p_Ts 20us
.PARAM p_Ton 8.33us
.PARAM p_Vripple 0.15
.PARAM D_cal {p_Ton/p_Ts}
.PARAM Rload_cal {p_Vout/p_iout}
.PARAM Freq_cal {1/p_Ts}
.PARAM Lmin_cal {((1-D_cal)*Rload_cal)/(2*Freq_cal)}
.PARAM L_cal {Lmin_cal*1.25}
.PARAM C_cal {(1-D_cal)/(8*L_cal*(p_Vripple)*Freq_cal*Freq_cal)}
.backanno
.end

* LTspice schematic (.asc):
Version 4
SHEET 1 2520 1752
WIRE -32 -48 -240 -48
WIRE 192 -48 -32 -48
WIRE 192 -16 192 -48
WIRE 48 0 -32 0
WIRE 144 0 48 0
WIRE 144 48 112 48
WIRE -240 64 -240 -48
WIRE -32 64 -32 0
WIRE 112 80 112 48
WIRE 192 128 192 64
WIRE 256 128 192 128
WIRE 368 128 336 128
WIRE 480 128 368 128
WIRE 192 160 192 128
WIRE 368 160 368 128
WIRE 480 160 480 128
WIRE -240 176 -240 144
WIRE -32 176 -32 144
WIRE 192 272 192 224
WIRE 368 272 368 224
WIRE 368 272 192 272
WIRE 480 272 480 240
WIRE 480 272 368 272
WIRE 368 304 368 272
SYMBOL cap 352 160 R0
SYMATTR InstName C1
SYMATTR Value {C_cal}
SYMBOL sw 192 80 M180
SYMATTR InstName S1
SYMBOL diode 208 224 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D1
SYMBOL voltage -32 48 R0
WINDOW 3 612 304 Right 2
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR Value PULSE({p_Vinitial} {p_Von} {p_Tdelay} {p_Trise} {p_Tfall} {p_Ton} {p_Ts})
SYMATTR InstName Vctrl
SYMBOL ind 240 144 R270
WINDOW 0 32 56 VTop 2
WINDOW 3 5 56 VBottom 2
SYMATTR InstName L1
SYMATTR Value {L_cal}
SYMBOL res 464 144 R0
SYMATTR InstName RLoad
SYMATTR Value {Rload_cal}
SYMBOL voltage -240 48 R0
WINDOW 123 0 0 Left 0
WINDOW 39 0 0 Left 0
SYMATTR InstName Vin
SYMATTR Value {p_Vin}
FLAG 368 304 0
FLAG 112 80 0
FLAG -32 176 0
FLAG -240 176 0
FLAG -32 -48 in
FLAG 48 0 ctrl
FLAG 480 128 out
TEXT -312 384 Left 2 !.MODEL SW   VSWITCH(VON=5V VOFF=0V RON=0.01 ROFF=1MEG)\n.MODEL DSCH D( IS=0.0002 RS=0.05 CJO=5e-10  )
TEXT -312 432 Left 2 !.tran 10m
TEXT -920 -48 Left 2 ;*-----------------------------------------------------------\n*User Values\n*-----------------------------------------------------------\nInput = 12V \nOutput = 5V a 1A\nTs = 20us          \nTon = 8.33us \nVripple = 15%\n*-----------------------------------------------------------\n*Calculations\n*-----------------------------------------------------------\nD = Ton/Ts = 41.65% \nILoad = Vout / RLoad = 5 A\nRload = Vout /  ILoad = 5V/1A = 5 Ohms\nF = 1/Ts = 1/20u = 50KHz\nLmin = ([1-D)*R]/(2*f) =29.18uH\nL = Lmin * 1.25 = 29.18uH * 1.25 = 36.47 uH\nC = (1-D)/[8*L(Delta_Vout/Vout)f**2] = 5.33uF\n \n*-----------------------------------------------------------\nDelta Vout = Vout * Vripple = 5V * 15% = 750mV \nDelta ILoad = 1.59A \nI_load_max = 1.795A \nI_load_min =  0.205A
TEXT 680 -88 Left 2 !*----------------------------------------------------------------\n*Measaurements\n*----------------------------------------------------------------\n*.INCLUDE BUCK_CONVERTER.meas \n.lib A:\\meas_from_perl.meas ; from pearl and connect with ubuntu\n*.lib BUCK_CONVERTER.asc\n*----------------------------------------------------------------\n*Parameters: User Input\n*----------------------------------------------------------------\n*Vctrl Parameters\n.PARAM p_Vinitial 0 \n.PARAM p_Von 5\n.PARAM p_Tdelay 0 \n.PARAM p_Trise 0.01u \n.PARAM p_Tfall=0.01u\n*----------------------------------------------------------------\n \n.PARAM p_Vin 12V \n.PARAM p_Vout 5V\n.PARAM p_iout 1A\n.PARAM p_Ts 20us\n.PARAM p_Ton 8.33us     \n.PARAM p_Vripple 0.15\n \n*----------------------------------------------------------------\n*Parameters: Automatic Calculation\n*----------------------------------------------------------------\n.PARAM D_cal {p_Ton/p_Ts}\n.PARAM Rload_cal {p_Vout/p_iout}\n.PARAM Freq_cal {1/p_Ts}\n.PARAM Lmin_cal {((1-D_cal)*Rload_cal)/(2*Freq_cal)}\n.PARAM L_cal {Lmin_cal*1.25}\n.PARAM C_cal {(1-D_cal)/(8*L_cal*(p_Vripple)*Freq_cal*Freq_cal)}