File "switch.lib"

Full Path: /home/analogde/www/XTRAIL/Share/Document/Lectures DCDC/switch.lib
File size: 9.43 KB
MIME-type: text/plain
Charset: utf-8

**********************************************************
*** Library of PSpice averaged switch models           ***
*** Supplement to the textbook                         *** 
*** Fundamentals of Power Electronics                  ***
*** by R.W.Erickson and Dragan Maksimovic              ***
*** Kluwer, 2000                                       ***
*** Version: 4/8/03                                    ***
**********************************************************
* 2/14/08 corrected CCM-DCM1 by use of Chapter 11 DCM models
* This version improves convergence of PSpice in DCM
* 4/08/03 Ra=1K changed to Ra=10K in CCM-DCM1, CCM-DCM2 for improved convergence
* 2/10/03 corrected CCM-DCM1 and CCM-DCM2: i(Et) replaced by i(Va)

**********************************************************
* MODEL: CCM1
* Application: two-switch PWM converters
* Limitations: ideal switches, CCM only, no transformer
**********************************************************
* Parameters: none
**********************************************************
* Nodes:
* 1: transistor positive (drain of an n-channel MOS)
* 2: transistor negative (source of an n-channel MOS)
* 3: diode cathode
* 4: diode anode
* 5: duty cycle control input
**********************************************************
*$
.subckt CCM1 1  2  3  4  5
Et 1 2 value={(1-v(5))*v(3,4)/v(5)}
Gd 4 3 value={(1-v(5))*i(Et)/v(5)}
.ends
*$
**********************************************************

**********************************************************
* MODEL: CCM2
* Application: two-switch PWM converters, includes 
*              conduction losses due to Ron, VD, Rd
* Limitations: CCM only, no transformer
**********************************************************
* Parameters:
*      Ron=transistor on resistance
*      VD=diode forward voltage drop (constant)
*      RD=diode on resistance
**********************************************************
* Nodes:
* 1: transistor positive (drain of an n-channel MOS)
* 2: transistor negative (source of an n-channel MOS)
* 3: diode cathode
* 4: diode anode
* 5: duty cycle control input
**********************************************************
.subckt CCM2 1  2  3  4  5
+params: Ron=0 VD=0 RD=0
Er 1 1x value={i(Et)*(Ron+(1-v(5))*RD/v(5))/v(5)}
Et 1x 2 value={(1-v(5))*(v(3,4)+VD)/v(5)}
Gd 4 3 value={(1-v(5))*i(Et)/v(5)}
.ends
*$
**********************************************************

**********************************************************
* MODEL: CCM3
* Application: two-switch PWM converters, 
*              with (possibly) transformer
* Limitations: ideal switches, CCM only
**********************************************************
* Parameters:
*     n=transformer turns ratio 1:n (primary:secondary)
**********************************************************
* Nodes:
* 1: transistor positive (drain of an n-channel MOS)
* 2: transistor negative (source of an n-channel MOS)
* 3: diode cathode
* 4: diode anode
* 5: duty cycle control input
**********************************************************
.subckt CCM3 1  2  3  4  5
+params: n=1
Et 1 2 value={(1-v(5))*v(3,4)/v(5)/n}
Gd 4 3 value={(1-v(5))*i(Et)/v(5)/n}
.ends
*$
**********************************************************


**********************************************************
* MODEL: CCM4
* Application: two-switch PWM converters, includes 
*              conduction losses due to Ron, VD, RD
*              and (possibly) transformer
* Limitations: CCM only
**********************************************************
* Parameters:
*      Ron=transistor on resistance
*      VD=diode forward voltage drop (constant)
*      Rd=diode on resistance
*      n=transformer turns ratio 1:n (primary:secondary)
**********************************************************
* Nodes:
* 1: transistor positive (drain of an n-channel MOS)
* 2: transistor negative (source of an n-channel MOS)
* 3: diode cathode
* 4: diode anode
* 5: duty cycle control input
**********************************************************
.subckt CCM4 1  2  3  4  5
+params: Ron=0 VD=0 RD=0 n=1
Er 1 1x value={i(Et)*(Ron+(1-v(5))*RD/n/n/v(5))/v(5)}
Et 1x 2 value={(1-v(5))*(v(3,4)+VD)/v(5)/n}
Gd 4 3 value={(1-v(5))*i(Et)/v(5)/n}
.ends
*$
**********************************************************

**********************************************************
* MODEL: CCM-DCM1
* Application: two-switch PWM converters, CCM or DCM
* Limitations: ideal switches, no transformer
**********************************************************
* Parameters:
*      L=equivalent inductance for DCM
*      fs=switching frequency
**********************************************************
* Nodes:
* 1: transistor positive (drain of an n-channel MOS)
* 2: transistor negative (source of an n-channel MOS)
* 3: diode cathode
* 4: diode anode
* 5: duty cycle control input
**********************************************************
.subckt CCM-DCM1 1  2  3  4  5
+ params: L=100u fs=1E5
Et 1 2 value={MIN((1-v(5))*v(v2)/v(5), i(Va)*2*L/(V(5)*V(5))*fs)}
Gd 4 3 value={MIN((1-v(5))*i(Va)/v(5), i(Va)*i(Va)*2*L*fs/(V(5)*V(5)*V(v2)))}
Ga 0 a value={MAX(i(Et),0)}
Va a b
Ra b 0 10k
Ef v2 0 value={MAX(V(3,4),0)}
Rb v2 0 1k
.ends
*$
**********************************************************

**********************************************************
* MODEL: CCM-DCM2
* Application: two-switch PWM converters, CCM or DCM
*              with (possibly) transformer
* Limitations: ideal switches
**********************************************************
* Parameters:
*      L=equivalent inductance for DCM, 
*        referred to primary
*      fs=switching frequency
*      n=transformer turns ratio 1:n (primary:secondary)
**********************************************************
* Nodes:
* 1: transistor positive (drain of an n-channel MOS)
* 2: transistor negative (source of an n-channel MOS)
* 3: diode cathode
* 4: diode anode
* 5: duty cycle control input
**********************************************************
.subckt CCM-DCM2 1  2  3  4  5
+params: L=100u fs=1E5 n=1
Et 1 2 value={(1-v(u))*v(3,4)/v(u)/n}
Gd 4 3 value={(1-v(u))*i(Et)/v(u)/n}
Ga 0 a value={MAX(i(Et),0)}
Va a b
Ra b 0 10K
Eu u 0 table {MAX(v(5),
+ v(5)*v(5)/(v(5)*v(5)+2*L*n*fs*i(Va)/v(3,4)))}(0 0) (1 1)
.ends
*$
**********************************************************


**********************************************************
* MODEL: CPM
* Current-Programmed-Mode controller model.
* Computes duty ratio based on averaged inductor 
* current, voltages applied to the inductor, and amplitude 
* of the artificial ramp. The CPM controller model
* is valid for CCM and DCM operation of the power 
* converter. All parameters and inputs are referred to 
* the primary side. 
**********************************************************
* Parameters:
*     L=equivalent inductance, referred to primary
*     fs=switching frequency
*     Va=amplitude of the artificial ramp, Va=Rf*ma/fs
*     Rf=equivalent current-sense resistance
**********************************************************
* Nodes:
* control: control input, v(control)=Rf*ic
* current: sensed average inductor current v(current)=Rf*iL
* 1: voltage across L in interval 1, slope m1=v(1)/L
* 2: (-) voltage across L in interval 2, slope m2=v(2)/L
* d: duty cycle (output of the CPM controller)
**********************************************************
.subckt CPM control current 1 2 d
+params: L=100e-6 fs=1e5 Va=0.5 Rf=1
*

* generate d2 for CCM or DCM, see Eq.(B.31)
Ed2 d2 0 table 
+ {MIN(
+ L*fs*(v(control)-va*v(d))/Rf/(v(2)),
+ 1-v(d)
+ )} (0,0) (1,1)
*

* generate inductor current slopes, see Eqs.(B.24) and (B.26) 
Em1 m1 0 value={Rf*v(1)/L/fs}
Em2 m2 0 value={Rf*v(2)/L/fs}
*

* compute duty cycle d, see Eq.(B.32)
Eduty d 0 table 
+ {
+ 2*(v(control)*(v(d)+v(d2))
+ -v(current)-v(m2)*v(d2)*v(d2)/2)
+ /(v(m1)*v(d)+2*va*(v(d)+v(d2)))
+ } (0.01,0.01) (0.99,0.99)
*

.ends ; end of subcircuit CPM  
*$
**********************************************************



**********************************************************
* MODEL: transformer
* Application: transformer model suitable for averaged 
*              circuit models 
* Limitations: no losses, no leakages, two windings
**********************************************************
* Parameters:
*      Lm=primary (magnetizing) inductance
*      n=transformer turns ratio 1:n (primary:secondary)
**********************************************************
* Nodes:
* 1: primary-dot
* 2: primary-undot
* 3: secondary-dot
* 4: secondary-undot
**********************************************************
.subckt transformer 1  2  3  4
+params: Lm=100u n=1
Lm 1 2 {Lm}
Gp 2 1 value={n*i(Es)}
Es 3 4 value={n*v(1,2)}
.ends
*$
**********************************************************


**********************************************************
* MODEL: idealtran
* Application: ideal transformer
* Limitations: two windings
**********************************************************
* Parameters:
*      n=transformer turns ratio 1:n (primary:secondary)
**********************************************************
* Nodes:
* 1: primary-dot
* 2: primary-undot
* 3: secondary-dot
* 4: secondary-undot
**********************************************************
.subckt idealtran 1  2  3  4
+params: n=1
Gp 2 1 value={n*i(Es)}
Es 3 4 value={n*v(1,2)}
.ends
**********************************************************

*$