SwitcherCad / Pspice SUBCKT calls?

I see no way to add an arbitrary device and use X to call its use. Not even if it happens to be a zener defined with a .SUBCKT .. Good thing i kept my DOS version of TopSpice!

Reply to
Robert Baer
Loading thread data ...

You must be doing something wrong.

Please give an example of what isn't working.

...Jim Thompson

-- | James E.Thompson, P.E. | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona Voice:(480)460-2350 | | | E-mail Address at Website Fax:(480)460-2142 | Brass Rat | |

formatting link
| 1962 | I love to cook with wine. Sometimes I even put it in the food.

Reply to
Jim Thompson

"Robert Baer" schrieb im Newsbeitrag news:cFGEe.7450$ snipped-for-privacy@newsread2.news.pas.earthlink.net...

Hello Robert,

LTspice can handle subcircuits of course. Maybe you haven't correctly setup your subcircuit or symbol.

There are in general differences between the SPICE varieties when it comes to parameter passing to subcircuits. LTspice is mostly compatible to PSPICE regarding parameters.

Why haven't you posted your LTspice schematic and subcircuit? Now I have to make some guess what you have done wrong. I have assumed that you try to use Z-diode subcircuit models from ONSEMI. They provide two models for each Z-diode. Prefer to use the PSPICE compatible models(.lib) and not the SPICE3 models(.sp3) from ONSEMI, because SPICE3 has a different syntax for the model statement of resistors. Normally you don't have or need .model statements for resistors.

PSPICE: RBV 6 0 MDRBV 1749.5 ..MODEL MDRBV RES TC1=-0.000940267

SPICE3: RBV 6 0 1749.5 MDRBV ..MODEL MDRBV R TC1=-0.000940267

LTspice allows you to have the tempco in the same line. RBV 6 0 1749.5 TC1=-0.000940267

I have made an example for you with a Z-diode(4.7V) from ONSEMI. It is defined with a subcircuit. The only important thing with the ONSEMI library is to use the PSPICE compatible ".lib" file and not the SPICE3(.sp3) file.

Save the attached schematic file with name "zdiode_test.asc" and save the model file as "bzx84b4v7lt1.lib". Please keep both files in the same directory. I have also attached a few instructions how to change symbols which are designed for models so that they can be used for subcircuits. So you don't have to draw an extra symbol.

Best regards, Helmut

------ INSTRUCTIONS FOR SUBCIRCUIT( ZENER-)DIODES ------

  1. Add a diode to the schematic.

  1. Move the cursor over the placed diode. Press RightMouseButton Change Prefix D to X OK

Now this diode expects a ".SUBCKT ..." definition, because of the X.

  1. Change the value D of the diode in your schematic to bzx84b4v7lt1.

  1. Place the subcircuit definition in the schematic or load it from a file.

In the ladder case add a ".include bzx84b4v7lt1.lib" to the schematic. Save the subcircuit definition file "bzx84b4v7lt1.lib" in the same directory where your schematic has been saved.

------------------------------------------------------------

Schematic: zdiode_test.asc

Version 4 SHEET 1 1488 1540 WIRE -240 192 -240 128 WIRE -240 320 -240 272 WIRE -160 128 -240 128 WIRE 16 128 -160 128 WIRE 160 128 96 128 WIRE 160 192 160 128 WIRE 160 320 160 256 FLAG -240 320 0 FLAG 160 320 0 FLAG -160 128 vp FLAG 160 128 vz SYMBOL voltage -240 176 R0 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 SYMATTR InstName V1 SYMATTR Value PULSE(0 10 5n 5n 5n 1u 2u) SYMBOL res 0 144 R270 WINDOW 0 32 56 VTop 0 WINDOW 3 0 56 VBottom 0 SYMATTR InstName R1 SYMATTR Value 100 SYMBOL zener 176 256 R180 WINDOW 0 -20 72 Left 0 WINDOW 3 5 -5 Right 0 SYMATTR InstName D1 SYMATTR Value bzx84b4v7lt1 SYMATTR Prefix X TEXT -248 16 Left 0 !.tran 10u TEXT -256 -24 Left 0 !.include bzx84b4v7lt1.lib

Model from ONSEMI: bzx84b4v7lt1.lib

..SUBCKT bzx84b4v7lt1 2 1

**************************************
  • Model Generated by MODPEX *
*Copyright(c) Symmetry Design Systems*
  • All Rights Reserved *
  • UNPUBLISHED LICENSED SOFTWARE *
  • Contains Proprietary Information *
  • Which is The Property of *
  • SYMMETRY OR ITS LICENSORS *
*Commercial Use or Resale Restricted *
  • by Symmetry License Agreement *
**************************************
  • Model generated on Dec 11, 03
  • MODEL FORMAT: PSpice
  • anode cathode
*node: 2 1
  • Forward Section D1 2 1 MD1 ..MODEL MD1 D IS=5.21532e-16 N=1 XTI=1 RS=0.5
  • CJO=1.3e-10 TT=1e-08
  • Leakage Current R 1 2 MDR 1e+07 ..MODEL MDR RES TC1=0 TC2=0
  • Breakdown IZG 4 2 0.12 R4 4 2 2000 D3 2 4 MD3 ..MODEL MD3 D IS=2.5e-12 N=2.70127 XTI=0 EG=0.1 D2 5 4 MD2 ..MODEL MD2 D IS=2.5e-12 N=8.46982 XTI=0 EG=0.1 EV1 1 5 6 0 1 IBV 0 6 0.001 RBV 6 0 MDRBV 1749.5 ..MODEL MDRBV RES TC1=-0.000940267
*-- PSpice DIODE MODEL DEFAULT PARAMETER
  • VALUES ARE ASSUMED
*IS=1E-14 RS=0 N=1 TT=0 CJO=0 *VJ=1 M=0.5 EG=1.11 XTI=3 FC=0.5 *KF=0 AF=1 BV=inf IBV=1e-3 TNOM=27 ..ENDS bzx84b4v7lt1
Reply to
Helmut Sennewald

Huh ?????

I use subcircuits to handle the IRF MOSFETs etc. In the schematic, they look like a MOSFET symbol so the schematic is easy to understand but they, in fact call out a SUBCKT in the net list. Is this the sort of thing you are trying to do?

--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith

Thanks; i will try exactly as you suggested. I attempted many variations, and it is possible that i got "close", but not exactly as you described. One of the possible problems was i tried to use a .LIB directive (more familiar with TopSpice) than the .INCLUDE you mentioned. And i did try embedding the .SUBCKT descriptions, but may not have tried the variant you mentioned on the device itself.

Reply to
Robert Baer

I am trying a zener diode, but the method should be the same.

Reply to
Robert Baer

As far as I know, .LIB and .INCLUDE do exactly the same thing in ltspice. I do something different from the method you are learning. Rather than confusing things with another set of instructions, I'll come by and check this thread again in tomorrow to see if you've got it working.

--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith

As I said elsewhere, I won't confuse matters by giving you another set of instructions on how to do it differently. I'll check back tomorrow and see how you are getting on.

--
--
kensmith@rahul.net   forging knowledge
Reply to
Ken Smith

"Ken Smith" schrieb im Newsbeitrag news:dc2qnb$kq5$ snipped-for-privacy@blue.rahul.net...

snipped-for-privacy@rahul.net forging knowledge

Hello Ken and Robert,

There is an important difference between .LIB and .INCLUDE in LTspice and in other SPICE programs as well.

..LIB filename

------------- Only extract subcircuits and models from the given file. All lines which are not part of a subcircuit or a model are omitted.

..INCLUDE filename

----------------- Include evrey line of the given file into the netlist.

The filename may be any valid name your OS can accept. The file extension (.lib, .mod, .sub, .xyz ...) has no special meaning with the .lib and .include command.

Best regards, Helmut

PS: .inc is the abbreviation of .include .

Reply to
Helmut Sennewald

I tried embedding the whole library (it is short) and it does not work; error message is "not found". The bad thing is that line is over 2000 characters long... However, one could trim the line to have only the first .SUBCKT which i tried to no avail. .LIB and .INC also fail exactly the same way.

Version 4 SHEET 1 1192 2740 WIRE -32 192 -32 144 WIRE -32 400 -32 272 WIRE 16 144 -32 144 WIRE 16 304 16 144 WIRE 16 400 -32 400 WIRE 16 400 16 384 WIRE 144 144 16 144 WIRE 144 208 144 144 WIRE 144 304 144 272 WIRE 144 400 16 400 WIRE 144 400 144 384 WIRE 144 416 144 400 FLAG 144 416 0 SYMBOL current -32 272 R180 WINDOW 0 24 88 Left 0 WINDOW 3 24 0 Left 0 SYMATTR InstName I1 SYMATTR Value 20µA SYMBOL zener 160 272 R180 WINDOW 0 24 72 Left 0 WINDOW 3 -105 -4 Left 0 SYMATTR InstName X SYMATTR Value DDZ9689 SYMBOL res 128 288 R0 SYMATTR InstName R1 SYMATTR Value 0.001 SYMBOL res 0 288 R0 SYMATTR InstName R2 SYMATTR Value 1E9 TEXT -130 506 Left 0 !.dc I1 20uA 500uA 1uA TEXT 288 8 Left 0 !*SRC=DDZ9689;Diodes;Zener

Reply to
Robert Baer

Hello Robert,

You have wrongly changed the value of the "InstName" to X instead to change the "Prefix" to X. The "InstName" is the reference designator whereas the "Prefix" tells LTspice to search for a diode ".model ..." if it's D and to look for a subcircuit if it's X. LTspice looks in your circuit for a ".MODEL DDZ9689 D(....)" statement but not for a ".SUBCKT DDZ9689 ...". When you follow my previously given instructions above, then a "Component Attribute Editor"-window pops up after you do the RightMousClick. Here change the value of the "Prefix" from D to to X. Then press OK. You should also change the "InstName"(reference designator) back to D1 in your schematic as it was originally.

Please try the corrected circuit below. I have splitted your design now into two files "zdio.asc" and "z_diodes.lib" to avoid this super long line for the subcircuits. It's simply more convenient to share the design this way when posting it in an ASCII message.

Best regards, Helmut

Schematic "zdio.asc"

--------------------

Version 4 SHEET 1 1200 2740 WIRE -32 192 -32 144 WIRE -32 400 -32 272 WIRE 16 144 -32 144 WIRE 16 304 16 144 WIRE 16 400 -32 400 WIRE 16 400 16 384 WIRE 144 144 16 144 WIRE 144 208 144 144 WIRE 144 304 144 272 WIRE 144 400 16 400 WIRE 144 400 144 384 WIRE 144 416 144 400 FLAG 144 416 0 SYMBOL current -32 272 R180 WINDOW 0 24 88 Left 0 WINDOW 3 24 0 Left 0 SYMATTR InstName I1 SYMATTR Value 20µA SYMBOL zener 160 272 R180 WINDOW 0 4 67 Right 0 WINDOW 3 -90 -3 Left 0 SYMATTR InstName D1 SYMATTR Value DDZ9689 SYMATTR Prefix X SYMBOL res 128 288 R0 SYMATTR InstName R1 SYMATTR Value 0.001 SYMBOL res 0 288 R0 SYMATTR InstName R2 SYMATTR Value 1E9 TEXT -58 66 Left 0 !.dc I1 20uA 500uA 1uA TEXT -56 24 Left 0 !.lib z_diodes.lib

Z-Diode library file "z_diodes.lib"

----------------------------------

*SRC=DDZ9689;Diodes;Zener
Reply to
Helmut Sennewald

--------- SNIPped for brevity ------ *That* is the magic! A Component Editor!! Thanks; it works now. I imported the subcircuit for the part i wanted to study this time (makes the last line only 346 characters) and then "built" the circuit i had in mind. But it seems there may be something wrong with the model, so i added the "short" you see to "home in" to the problem. In TopSpice,the maximum temperature that works is 77C; the error message at higher temperatures is meaningless to a user, only to the original programmer. In LTspice, it seems to work to about 105C and at 125C it runs forever in a Newton-Rapheson(sp?? ) loop, and at 185C the zener voltage is just plain wrong. At 135C an error message is generated that may give a clue as to what the problem in the model may be. With this info, could you determine what is needed to fix it?

Version 4 SHEET 1 1408 2740 WIRE -32 192 -32 144 WIRE -32 400 -32 272 WIRE 16 144 -32 144 WIRE 16 304 16 144 WIRE 16 400 -32 400 WIRE 16 400 16 384 WIRE 32 144 16 144 WIRE 128 144 96 144 WIRE 144 400 16 400 WIRE 144 400 144 336 WIRE 144 416 144 400 WIRE 224 144 192 144 WIRE 272 336 144 336 WIRE 272 336 272 320 WIRE 288 336 272 336 WIRE 320 144 288 144 WIRE 320 240 272 240 WIRE 320 240 320 144 WIRE 384 176 384 144 WIRE 384 272 384 240 WIRE 384 336 352 336 FLAG 144 416 0 SYMBOL current -32 272 R180 WINDOW 0 24 88 Left 0 WINDOW 3 24 0 Left 0 SYMATTR InstName I1 SYMATTR Value 20µA SYMBOL zener 96 128 R90 WINDOW 0 67 31 VBottom 0 WINDOW 3 70 21 VTop 0 SYMATTR InstName D1 SYMATTR Value DDZ9694 SYMATTR Prefix X SYMBOL res 0 288 R0 SYMATTR InstName R2 SYMATTR Value 1E9 SYMBOL zener 192 128 R90 WINDOW 0 67 31 VBottom 0 WINDOW 3 95 24 VTop 0 SYMATTR InstName D2 SYMATTR Value DDZ9694 SYMATTR Prefix X SYMBOL zener 288 128 R90 WINDOW 0 67 31 VBottom 0 WINDOW 3 70 21 VTop 0 SYMATTR InstName D3 SYMATTR Value DDZ9694 SYMATTR Prefix X SYMBOL zener 320 160 R270 WINDOW 0 36 32 VTop 0 WINDOW 3 91 32 VBottom 0 SYMATTR InstName D4 SYMATTR Value DDZ9694 SYMATTR Prefix X SYMBOL zener 368 176 R0 WINDOW 3 50 33 Left 0 SYMATTR InstName D5 SYMATTR Value DDZ9694 SYMATTR Prefix X SYMBOL zener 368 272 R0 WINDOW 3 48 31 Left 0 SYMATTR InstName D6 SYMATTR Value DDZ9694 SYMATTR Prefix X SYMBOL zener 352 320 R90 WINDOW 0 67 31 VBottom 0 WINDOW 3 70 21 VTop 0 SYMATTR InstName D7 SYMATTR Value DDZ9694 SYMATTR Prefix X SYMBOL res 256 224 R0 SYMATTR InstName R1 SYMATTR Value .001 TEXT -58 66 Left 0 !.dc I1 20uA 500uA 1uA TEXT -48 104 Left 0 !.TEMP 27 135 TEXT 528 112 Left 0 !*SRC=DDZ9694;Diodes;Zener

Reply to
Robert Baer

----- Original Message ----- From: "Robert Baer" Newsgroups: sci.electronics.cad Sent: Wednesday, July 27, 2005 10:31 PM Subject: Re: SwitcherCad / Pspice SUBCKT calls?

Hello Robert,

The problem has been caused by the low value of N in your diode model. I assume it results in too large exponent values in the diode equations used in SPICE. Normal diodes have N=1 to 2 .

Your model. ..MODEL DR D ( IS=5.02f RS=34.5 N=0.223 )

Please change N to at least 0.3. ..MODEL DR D ( IS=5.02f RS=34.5 N=0.3 )

The simulation has been ok with N=0.3 even for Temp=185C.

Best regards, Helmut

Reply to
Helmut Sennewald

Thanks. Perhaps Diodes Inc gave the wrong value in their model. Is there some electrical testing that could be used to determine N, and is it relatively constant over current and /or temperature?

Reply to
Robert Baer

Hello Robert,

Let's take a look to the datasheet curve on page 3 of 6 (bottom left).

formatting link
DDZ9694

The model in question is for the diode DR used in Zener-region.

From the datsheet:

----------------- delta_V = 0.17V, 1u->10m Let's assume Rs=5Ohm as we see later. delta_V_internal = 0.12V

Diode equations:

---------------- I1 = Is*exp(V1/(N*Vt)) I2 = Is*exp(V2/(N*Vt)) I2/I1= exp((V2-V1))/(N*Vt)) log(I2/I1)=(V2-V1)/(N*Vt)

N=(V2-V1)/(Vt*log(I2/I1))

Values from datsheet:

V2-V1 = 0.12V, I2/I1=1e4

N = 0.12/(0.025*log(10000))= 0.2/0.025*9.21)

N = 0.5

Rs=.15V/30m = 5Ohm

My guess:

---------------------------------- ..MODEL DR D ( IS=5.02f RS=5 N=0.5)

----------------------------------

Sorry, I will not spend more effort into this diode model.

Best regards, Helmut

The original model:

formatting link
*SRC=DDZ9694;DI_DDZ9694;Diodes;Zener

Reply to
Helmut Sennewald

Thanks for the good tutorial as how one gets N. I will be getting some samples, so i can make measurements as indicated, and calculate values that match reality and not some fakey datasheet. It seems that N can indeed change over temperature.

Reply to
Robert Baer

Excellent point, most especially in making measurements above 125C.

Reply to
Robert Baer

Hello Robert,

I recommend to use 10uA and 1mA to evaluate N. Higher current will result in a significant temperature rise of the diode which may lead to a high measurement error.

Maybe a pulsed measuremet is necessary for higher currents like 10mA.

Best regards, Helmut

Reply to
Helmut Sennewald

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.