Zener library problem in library files: Fatal error: .ends without matching .subckt

I have one big file with c.a. 800 zener diodes models from LTSpice.

When I import zener diode model:

.subckt 1N4728A 1 2
D1 1 2 DF
DZ 3 1 DR
VZ 2 3 0.972
.MODEL DF D ( IS=125p RS=0.620 N=1.10 CJO=364p VJ=0.750 M=0.330 TT=50.1n )
.MODEL DR D ( IS=25.0f RS=1.24 N=3.00 )
.ends

to create Qspice Zener symbol, symbol created works without any problerm.

I was trying to create symbols with independent library txt files.

Error messages:
Warning: library has a .ends without matching .subckt
Fatal error: .ends without matching .subckt
or
Fatal error: Unresolved subcircuit in: X1 0 OUT 1N4728A

Why it’s not working with that zener diode simulation?

The problem is only with that kind of model - and it’s may be a problem with CRLF character (Carriage Return Line Feed) in txt files of any kind.

Have you any idea, how to run a symbol model connected to the external txt library?
zener-TEST.cpp (6.3 KB)

cpp ext change on zip and unpack to test.

˙Ř˙Ű«symbol
  «type: X»
  «description: Zener Diode»
  «library file: zener.txt»
  «shorted pins: false»
  «line (80,80) (-80,80) 7 0 0x1000000 -1 -1»
  «line (0,200) (0,80) 7 0 0x1000000 -1 -1»
  «line (0,-200) (0,-70) 7 0 0x1000000 -1 -1»
  «line (80,80) (130,130) 7 0 0x1000000 -1 -1»
  «line (-130,30) (-80,80) 7 0 0x1000000 -1 -1»
  «triangle (0,80) (100,-70) (-100,-70) 7 0 0x1000000 0x2000000 -1 -1»
  «text (100,200) 0.5 7 0 0x1000000 -1 -1 "X"»
  «text (100,-200) 0.5 7 0 0x1000000 -1 -1 "1N4728A"»
  «pin (0,-200) (0,0) 1 0 0 0x0 -1 "1"»
  «pin (0,200) (0,0) 1 0 0 0x0 -1 "2"»
»

That symbol is not working with txt file zener.txt

.subckt 1N4728A  1 2
D1 1 2 DF
DZ 3 1 DR
VZ 2 3 0.972 
.MODEL DF D ( IS=125p RS=0.620 N=1.10 CJO=364p VJ=0.750 M=0.330 TT=50.1n )
.MODEL DR D ( IS=25.0f RS=1.24 N=3.00 )
.ends

You are trying multiples extension of library and I haven’t fully test each one. But here things to review.

  • In Qspice installation directory, C:\Program Files\QSPICE, you can find a library as Zener.txt. Therefore, it will take the priority and you should name your library (.txt) with a name not already used by Qspice.
  • Your .lib, .sub and .txt encoding is UTF-8, change it to ANSI. You can use Notepad++ to do it by Encoding > ANSI and save
1 Like

Yes, in one small zener model saving from utf-8 to ANSII works - good solution.
The problem is when we want big list of models in one single file.
That file can not be converted to ANSI.
Or I don’t know how to convert that big txt file to ANSI.
Or the problem is in Qspice, that all such zener models in one txt file
zener_test2.cpp (36.2 KB)
can not run in Qspice.

Change cpp ext into zip and test if uploading will be ok, or create new file an test from this code:.

*1N4728A 1N4728A Diodes Zener less_10V  2.80V  1.00W 
.subckt 1N4728A  1 2 D1 1 2 DF DZ 3 1 DR VZ 2 3 0.972 
.MODEL DF D ( IS=125p RS=0.620 N=1.10 CJO=364p VJ=0.750 M=0.330 TT=50.1n ) 
.MODEL DR D ( IS=25.0f RS=1.24 N=3.00 ) 
.ends

*1N4729A 1N4729A Diodes Zener less_10V  3.60V  1.00W
.subckt 1N4729A  1 2
*        Terminals    A   K
D1 1 2 DF
DZ 3 1 DR
VZ 2 3 1.30
.MODEL DF D ( IS=114p RS=0.620 N=1.10 CJO=319p VJ=0.750 M=0.330 TT=50.1n )
.MODEL DR D ( IS=22.9f RS=0.923 N=3.00 )
.ends

*1N4730A 1N4730A Diodes Zener less_10V  3.90V  1.00W
.subckt 1N4730A  1 2
*        Terminals    A   K
D1 1 2 DF
DZ 3 1 DR
VZ 2 3 1.63
.MODEL DF D ( IS=106p RS=0.620 N=1.10 CJO=283p VJ=0.750 M=0.330 TT=50.1n )
.MODEL DR D ( IS=21.1f RS=0.645 N=3.00 )
.ends

*1N4731A 1N4731A Diodes Zener less_10V  4.30V  1.00W
.subckt 1N4731A  1 2
*        Terminals    A   K
D1 1 2 DF
DZ 3 1 DR
VZ 2 3 2.18
.MODEL DF D ( IS=95.8p RS=0.620 N=1.10 CJO=244p VJ=0.750 M=0.330 TT=50.1n )
.MODEL DR D ( IS=19.2f RS=0.377 N=2.82 )
.ends

*1N4732A 1N4732A Diodes Zener less_10V  4.70V  1.00W
.subckt 1N4732A  1 2
*        Terminals    A   K
D1 1 2 DF
DZ 3 1 DR
VZ 2 3 2.99
.MODEL DF D ( IS=87.7p RS=0.620 N=1.10 CJO=214p VJ=0.750 M=0.330 TT=50.1n )
.MODEL DR D ( IS=17.5f RS=0.333 N=2.28 )
.ends

*1N4733A 1N4733A Diodes Zener less_10V  5.10V  1.00W
.subckt 1N4733A  1 2
*        Terminals    A   K
D1 1 2 DF
DZ 3 1 DR
VZ 2 3 3.69
.MODEL DF D ( IS=80.8p RS=0.620 N=1.10 CJO=189p VJ=0.750 M=0.330 TT=50.1n )
.MODEL DR D ( IS=16.2f RS=0.296 N=1.87 )
.ends
1 Like

The major issues is in line#6012, these characters should be removed.

image

In addition, diode 1N4728A line#2 mess up and requires proper separation.
Correct these two things and library should work in Qspice.

Qspice accepts .ends without model name, but in Qspice HELP, syntax of .subckt should end with .ends <model name> (this change is not necessary)

image

By the way, you only need one generic symbol and assign model name in schematic level if you are using a common library.

Here is an example with library fixed first two issues and modified with format changed to .ends <model name> in zenerki.txt, and a generic symbol and a simulation example.
Zener-subckt.qsym (600 Bytes)
Parent.Zener-subckt.qsch (6.8 KB)
zenerki.txt (227.8 KB)

2 Likes

One more comment, .model MMBZ5226BT which giving you error, missing .model for DR.
This model is incorrect and will run into a warning with DR be forced to Qspice default diode model.

1 Like

Everything is working perfect now. I’m impressed!
Thank you very much for Your help!!!