Author Topic: LTSpice XVII sweeping or stepping subckt parameters  (Read 2232 times)

0 Members and 1 Guest are viewing this topic.

Offline chris_leysonTopic starter

  • Super Contributor
  • ***
  • Posts: 1549
  • Country: wales
LTSpice XVII sweeping or stepping subckt parameters
« on: September 04, 2020, 09:04:05 pm »
I'm trying to do monte carlo and/or worst case analysis for a digital transistor and I would like to step the resistor values over their tolerance range but after googling for a day I've got nowhere. Last resort would be removing the resistors from the sub circuit and just save the transistor model into standard.bjt and then tweak external resistors. Do I need to edit the model and add a PARAM variable to the following, R1 2 Base Rb 10k, R2 Base 3 Re 10k ? DTC114EE sub circuit, courtesy of ROHM below.

Code: [Select]
* DTC114EE DIGITAL NPN BJT model
* Date: 2007/01/11
* BJT with resistors
*****************C B E
.SUBCKT DTC114EE 1 2 3
R1 2 Base Rb 10k
R2 Base 3 Re 10k
Q1 1 Base 3 QDTC1
.MODEL Rb RES
+ R=1
.MODEL Re RES
+ R=1
.MODEL QDTC1 NPN
+ IS=20.000E-15
+ BF=198.80
+ VAF=15
+ IKF=.28787
+ ISE=20.001E-15
+ NE=1.6289
+ BR=8.4556
+ VAR=100
+ IKR=.2645
+ ISC=8.0686E-12
+ NC=2.3678
+ NK=.75224
+ RE=.2
+ RB=10.670
+ RC=1.1274
+ CJE=11.342E-12
+ MJE=.38289
+ CJC=4.0230E-12
+ MJC=.34629
+ TF=500.00E-12
+ XTF=580.91
+ VTF=195.13
+ ITF=19.351
+ TR=200.00E-9
+ XTB=1.5000
.ENDS DTC114EE
« Last Edit: September 04, 2020, 09:09:03 pm by chris_leyson »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13218
Re: LTSpice XVII sweeping or stepping subckt parameters
« Reply #1 on: September 04, 2020, 09:55:08 pm »
That's what you *should* do if you want it clean.   See LTspice help file: '.PARAM -- User-Defined Parameters' for an example of passing parameters to a subcircuit.  You'd probably also want to parameterize the gain.

Its already been half-way set up for it with:
Code: [Select]
.MODEL Rb RES
+ R=1
.MODEL Re RES
+ R=1
The '1' in those two model statements is a unity multiplier for the values in the R1 and R2 component lines respectively.

Try:
Code: [Select]
* DTC114EE DIGITAL NPN BJT model
* Date: 2007/01/11 mod. 2020/09/04 Ian.M
* BJT with resistors, parameterized for Monte Carlo
*****************C B E
.SUBCKT DTC114EE 1 2 3
.params Krb=1 Kre=1 Kbeta=1 ; default to unit multiplier
R1 2 Base Rb 10k
R2 Base 3 Re 10k
Q1 1 Base 3 QDTC1
.MODEL Rb RES
+ R={Krb}
.MODEL Re RES
+ R={Kre}
.MODEL QDTC1 NPN
+ IS=20.000E-15
+ BF={198.80*Kbeta}
+ VAF=15
+ IKF=.28787
+ ISE=20.001E-15
+ NE=1.6289
+ BR=8.4556
+ VAR=100
+ IKR=.2645
+ ISC=8.0686E-12
+ NC=2.3678
+ NK=.75224
+ RE=.2
+ RB=10.670
+ RC=1.1274
+ CJE=11.342E-12
+ MJE=.38289
+ CJC=4.0230E-12
+ MJC=.34629
+ TF=500.00E-12
+ XTF=580.91
+ VTF=195.13
+ ITF=19.351
+ TR=200.00E-9
+ XTB=1.5000
.ENDS DTC114EE

Then you can pass in per-instance parameters to your DTC114EE model, set in the generic Component Attribute Editor:
e.g.
Code: [Select]
Krb=1.1 Kre=0.9 Kbeta=0.8
which gives you a DTC114EE with its series base resistor 10% high, its shunt base resistor 10% low and 20% below nominal gain, or for your specific application you'd need to use multipliers derived from your Monte Carlo or Worst Case functions.

« Last Edit: September 05, 2020, 01:43:36 am by Ian.M »
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2766
  • Country: ca
Re: LTSpice XVII sweeping or stepping subckt parameters
« Reply #2 on: September 04, 2020, 10:12:50 pm »
Hi,

Here is one solution:




and the results:





I have attached the LTspice model

Regards,
Jay_Diddy_B

* parameter sweep digital transistor.asc (1.79 kB - downloaded 72 times.)
 
The following users thanked this post: Ian.M

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13218
Re: LTSpice XVII sweeping or stepping subckt parameters
« Reply #3 on: September 04, 2020, 10:25:14 pm »
Yes, but my way you don't need to know at the schematic level that the internal  R1 (Rb)and R2 (Rbe) are meant to be 10K, just use:
Code: [Select]
Krb=mc(1,0.1) Kre=mc(1,0.1)
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2766
  • Country: ca
Re: LTSpice XVII sweeping or stepping subckt parameters
« Reply #4 on: September 04, 2020, 10:33:24 pm »
Hi,

@Ian.M

+1

Both will get the job done for the OP.

I have expanded my version to include BF variation:




I would encourage you to but the model on the schematic, so that it is portable.

Jay_Diddy_B

* parameter sweep digital transistor with BF.asc (2.09 kB - downloaded 80 times.)
 

Offline chris_leysonTopic starter

  • Super Contributor
  • ***
  • Posts: 1549
  • Country: wales
Re: LTSpice XVII sweeping or stepping subckt parameters
« Reply #5 on: September 05, 2020, 01:41:39 am »
Thanks Ian.M and Jay_Diddy_B  :-+ I'm kicking myself for missing that. R1 and R2 variation could be 30% and R2/R1 ratio has 20% limit. I had a sneaky feeling that a model edit might be in order to pass parameters. Thanks again guys.
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2766
  • Country: ca
Re: LTSpice XVII sweeping or stepping subckt parameters
« Reply #6 on: September 05, 2020, 02:54:03 am »
Chris,

You need to do something like this:

.param para_R1={mc(10,0.3)}

R1 = 10K 30%

and

.param para_R2={mc(1.0417*para_R1,0.2)}

1.0417 is the average of 1/0.8 and 1/1.2

This randomizes R1 and the sets R2 with a random ratio up to 20%

Jay_Diddy_B
 

Offline chris_leysonTopic starter

  • Super Contributor
  • ***
  • Posts: 1549
  • Country: wales
Re: LTSpice XVII sweeping or stepping subckt parameters
« Reply #7 on: September 05, 2020, 10:15:58 am »
Thanks J_Diddy_B, I've been doing some Monte Carlo on a few circuit blocks just to make sure the designs are 100% guaranteed to work, it's important if you're manufacturing by the hundreds of thousands. The company use a fair amount of digital transistors as well, either for drivers or level shifters, so I thought it might be wise to look at those as well. Thanks, that has helped my understanding of LTSpice and params. I think Bob Pease absolutely hated SPICE but I think SPICE3 is a great tool for sanity checking designs. 
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf