You need to use EasyEDA editor to create some projects before publishing
Attaching a .subckt to a symbol
2299 13
joaoff 8 years ago

Hi!

I am trying to simulate a simple voltage regulator circuit (see image below). I found that there is no spice model associated with LM7812CT schematic symbol of the library (the symbol contributor is KiCad). I was following the tutorial "Attaching a .subckt to a symbol 02" in https://easyeda.com/example/Spice_tutorials_02-YxrJ1Vd7p. But, when I paste the model description in the text box, the model turns to a single line (as in the figure). What am I doing wrong? do I have to enter model line by line?

Thank you!

enter image description here

Comments
dillon 8 years ago

You can copy the subckt to notepad, then copy from notepad to EasyEDA , this will maybe help you to fix it.

Reply
joaoff 8 years ago

I've already tried this. But I'm working on Linux, so I copied to gedit and libreoffice and back to EasyEDA, but none worked. The textbox seems to simply drop all newline characters.

Reply
dillon 8 years ago

Can you post your subckt to here?

Reply
joaoff 8 years ago
  • Spice model for the voltage regulator LM7812CT

.SUBCKT LM7812CT 1 2 3
QT6 23 10 2 Q_NPN 0.1
QT7 5 4 10 Q_NPN 0.1
QT5 7 6 5 Q_NPN 0.1
QT1 1 9 8 Q_NPN 0.1
QT3 11 8 7 Q_NPN 0.1
QT2 11 13 12 Q_NPN 0.1
QT17 1 15 14 Q_NPN 10
C2 10 23 4P
R16 12 5 500
R12 16 2 12.1K
QT18 17 23 16 Q_NPN 0.1
D1 18 19 D_D
R11 20 21 850
R5 22 3 100
QT14 24 18 2 Q_NPN 0.1
R21 6 2 2.67K
R20 3 6 5.22K
DZ2 25 26 D_5V1
R19 1 26 16K
R18 14 3 250M
R17 25 14 380
R15 25 15 1.62K
QT16 1 20 15 Q_NPN 1
QT15 2 24 21 Q_PNP 0.1
*OFF
R14 21 24 4K
C1 27 24 20P
R13 19 2 4K
QT13 24 27 18 Q_NPN 0.1
QT12 20 25 22 Q_NPN 1
*OFF
QT11 20 28 2 Q_NPN 0.1
*OFF
QT10 20 11 1 Q_PNP 0.1
R10 17 27 16.5K
R9 5 4 1.9K
R8 4 23 26
R7 10 2 1.2K
R6 29 2 1K
QT9 11 11 1 Q_PNP 0.1
QT8 27 16 29 Q_NPN 0.1
QT4 15 6 17 Q_NPN 0.1
DZ1 2 9 D_5V6
R4 1 9 80K
R3 28 2 830
R2 13 28 4.97K
R1 8 13 7K
*
.MODEL D_5V1 D( IS=10F N=1.16 BV=5.1 IBV=0.5M CJ0 = 1P TT = 10p )
.MODEL D_5V6 D( IS=10F N=1.16 BV=5.6 IBV=5U CJ0 = 1P TT = 10p )
.MODEL Q_NPN NPN( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P

  •   TF=10P TR=1N )
    

.MODEL Q_PNP PNP( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P

  •  TF=10P TR=1N )
    

.MODEL D_D D( IS=1F N=1.16 CJ0 = 1P TT = 10p )
*
.ENDS LM7812CT
*==================================

Reply
joaoff 8 years ago
  • Spice model for the voltage regulator LM7812CT

.SUBCKT LM7812CT 1 2 3
QT6 23 10 2 Q_NPN 0.1
QT7 5 4 10 Q_NPN 0.1
QT5 7 6 5 Q_NPN 0.1
QT1 1 9 8 Q_NPN 0.1
QT3 11 8 7 Q_NPN 0.1
QT2 11 13 12 Q_NPN 0.1
QT17 1 15 14 Q_NPN 10
C2 10 23 4P
R16 12 5 500
R12 16 2 12.1K
QT18 17 23 16 Q_NPN 0.1
D1 18 19 D_D
R11 20 21 850
R5 22 3 100
QT14 24 18 2 Q_NPN 0.1
R21 6 2 2.67K
R20 3 6 5.22K
DZ2 25 26 D_5V1
R19 1 26 16K
R18 14 3 250M
R17 25 14 380
R15 25 15 1.62K
QT16 1 20 15 Q_NPN 1
QT15 2 24 21 Q_PNP 0.1
*OFF
R14 21 24 4K
C1 27 24 20P
R13 19 2 4K
QT13 24 27 18 Q_NPN 0.1
QT12 20 25 22 Q_NPN 1
*OFF
QT11 20 28 2 Q_NPN 0.1
*OFF
QT10 20 11 1 Q_PNP 0.1
R10 17 27 16.5K
R9 5 4 1.9K
R8 4 23 26
R7 10 2 1.2K
R6 29 2 1K
QT9 11 11 1 Q_PNP 0.1
QT8 27 16 29 Q_NPN 0.1
QT4 15 6 17 Q_NPN 0.1
DZ1 2 9 D_5V6
R4 1 9 80K
R3 28 2 830
R2 13 28 4.97K
R1 8 13 7K
*
.MODEL D_5V1 D( IS=10F N=1.16 BV=5.1 IBV=0.5M CJ0 = 1P TT = 10p )
.MODEL D_5V6 D( IS=10F N=1.16 BV=5.6 IBV=5U CJ0 = 1P TT = 10p )
.MODEL Q_NPN NPN( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P

  •   TF=10P TR=1N )
    

.MODEL Q_PNP PNP( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P

  •  TF=10P TR=1N )
    

.MODEL D_D D( IS=1F N=1.16 CJ0 = 1P TT = 10p )
*
.ENDS LM7812CT
*==================================

Reply
joaoff 8 years ago

Sorry, the system is changing the comments for bullets. I will exclude all comments.

.SUBCKT LM7812CT 1 2 3
QT6 23 10 2 Q_NPN 0.1
QT7 5 4 10 Q_NPN 0.1
QT5 7 6 5 Q_NPN 0.1
QT1 1 9 8 Q_NPN 0.1
QT3 11 8 7 Q_NPN 0.1
QT2 11 13 12 Q_NPN 0.1
QT17 1 15 14 Q_NPN 10
C2 10 23 4P
R16 12 5 500
R12 16 2 12.1K
QT18 17 23 16 Q_NPN 0.1
D1 18 19 D_D
R11 20 21 850
R5 22 3 100
QT14 24 18 2 Q_NPN 0.1
R21 6 2 2.67K
R20 3 6 5.22K
DZ2 25 26 D_5V1
R19 1 26 16K
R18 14 3 250M
R17 25 14 380
R15 25 15 1.62K
QT16 1 20 15 Q_NPN 1
QT15 2 24 21 Q_PNP 0.1
R14 21 24 4K
C1 27 24 20P
R13 19 2 4K
QT13 24 27 18 Q_NPN 0.1
QT12 20 25 22 Q_NPN 1
QT11 20 28 2 Q_NPN 0.1
QT10 20 11 1 Q_PNP 0.1
R10 17 27 16.5K
R9 5 4 1.9K
R8 4 23 26
R7 10 2 1.2K
R6 29 2 1K
QT9 11 11 1 Q_PNP 0.1
QT8 27 16 29 Q_NPN 0.1
QT4 15 6 17 Q_NPN 0.1
DZ1 2 9 D_5V6
R4 1 9 80K
R3 28 2 830
R2 13 28 4.97K
R1 8 13 7K
.MODEL D_5V1 D( IS=10F N=1.16 BV=5.1 IBV=0.5M CJ0 = 1P TT = 10p )
.MODEL D_5V6 D( IS=10F N=1.16 BV=5.6 IBV=5U CJ0 = 1P TT = 10p )
.MODEL Q_NPN NPN( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P

  •   TF=10P TR=1N )
    

.MODEL Q_PNP PNP( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P

  •  TF=10P TR=1N )
    

.MODEL D_D D( IS=1F N=1.16 CJ0 = 1P TT = 10p )
.ENDS LM7812CT

Reply
joaoff 8 years ago

Last try.

.SUBCKT LM7812CT 1 2 3
QT6 23 10 2 Q_NPN 0.1
QT7 5 4 10 Q_NPN 0.1
QT5 7 6 5 Q_NPN 0.1
QT1 1 9 8 Q_NPN 0.1
QT3 11 8 7 Q_NPN 0.1
QT2 11 13 12 Q_NPN 0.1
QT17 1 15 14 Q_NPN 10
C2 10 23 4P
R16 12 5 500
R12 16 2 12.1K
QT18 17 23 16 Q_NPN 0.1
D1 18 19 D_D
R11 20 21 850
R5 22 3 100
QT14 24 18 2 Q_NPN 0.1
R21 6 2 2.67K
R20 3 6 5.22K
DZ2 25 26 D_5V1
R19 1 26 16K
R18 14 3 250M
R17 25 14 380
R15 25 15 1.62K
QT16 1 20 15 Q_NPN 1
QT15 2 24 21 Q_PNP 0.1
R14 21 24 4K
C1 27 24 20P
R13 19 2 4K
QT13 24 27 18 Q_NPN 0.1
QT12 20 25 22 Q_NPN 1
QT11 20 28 2 Q_NPN 0.1
QT10 20 11 1 Q_PNP 0.1
R10 17 27 16.5K
R9 5 4 1.9K
R8 4 23 26
R7 10 2 1.2K
R6 29 2 1K
QT9 11 11 1 Q_PNP 0.1
QT8 27 16 29 Q_NPN 0.1
QT4 15 6 17 Q_NPN 0.1
DZ1 2 9 D_5V6
R4 1 9 80K
R3 28 2 830
R2 13 28 4.97K
R1 8 13 7K
.MODEL D_5V1 D( IS=10F N=1.16 BV=5.1 IBV=0.5M CJ0 = 1P TT = 10p )
.MODEL D_5V6 D( IS=10F N=1.16 BV=5.6 IBV=5U CJ0 = 1P TT = 10p )
.MODEL Q_NPN NPN( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P TF=10P TR=1N )
.MODEL Q_PNP PNP( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P TF=10P TR=1N )
.MODEL D_D D( IS=1F N=1.16 CJ0 = 1P TT = 10p )
.ENDS LM7812CT

Reply
dillon 8 years ago

It is OK for me.

enter image description here

Reply
joaoff 8 years ago

Hi, Dillon! Thank you for the replay!

Maybe I'm doing something wrong.

I came to think that the problem was due to the fact that Linux and Windows use different line ending characters, but I tryed in Linux (Firefox) and Windows (Chrome), and the behavior is the same.

I do the following:

  1. I press the "t" key in keyboard to add a text element to the schematic;
  2. Press scape to text insertion;
  3. Select the text element and copy the model above to the "Text" field of the "Text Attributes";
  4. Select "spice" in the "Text type" field.

When I press "Enter" to break lines in the "Text" field of the "Text Attributes", nothing happens. So, what I can conclude is that the text field do not accept line breaks.

Reply
andyfierman 8 years ago

Hi Joaoff,

Ah!

Don't try to enter it into the "Text" field of the "Text Attributes" in the right hand panel.

Once you have placed a "Text" filed in the schematic and escaped from it, simply double click on that "Text" filed in the schematic itself, paste the text into the box that opens and then click back onto the schematic canvas anywhere outside the text box.

Done.

That should fix it.

BTW: Can you post the link to where you downloaded your LM7812CT subckt?

Then I can look at the formatting for you.

I too use Linux and occasionally come across models that end up formatted into a single line.

(I have also found some that do this in Windows too!)

:)

Reply
andyfierman 8 years ago

The reason your subckt is messed up in the comments here is because Markdown is interpreting the various * characters as italics markers.

It does the same with + characters.

To avoid this, paste the whole of the original subckt into the forum page, then select it all and click on the {} icon on the forum post toolbar.

The text should come out like this:

*Spice model for the voltage regulator LM7812CT
.SUBCKT LM7812CT 1 2 3
QT6 23 10 2 Q_NPN 0.1
QT7 5 4 10 Q_NPN 0.1
QT5 7 6 5 Q_NPN 0.1
QT1 1 9 8 Q_NPN 0.1
QT3 11 8 7 Q_NPN 0.1
QT2 11 13 12 Q_NPN 0.1
QT17 1 15 14 Q_NPN 10
C2 10 23 4P
R16 12 5 500
R12 16 2 12.1K
QT18 17 23 16 Q_NPN 0.1
D1 18 19 D_D
R11 20 21 850
R5 22 3 100
QT14 24 18 2 Q_NPN 0.1
R21 6 2 2.67K
R20 3 6 5.22K
DZ2 25 26 D_5V1
R19 1 26 16K
R18 14 3 250M
R17 25 14 380
R15 25 15 1.62K
QT16 1 20 15 Q_NPN 1
QT15 2 24 21 Q_PNP 0.1 OFF
R14 21 24 4K
C1 27 24 20P
R13 19 2 4K
QT13 24 27 18 Q_NPN 0.1
QT12 20 25 22 Q_NPN 1 OFF
QT11 20 28 2 Q_NPN 0.1 *OFF
QT10 20 11 1 Q_PNP 0.1
R10 17 27 16.5K
R9 5 4 1.9K
R8 4 23 26
R7 10 2 1.2K
R6 29 2 1K
QT9 11 11 1 Q_PNP 0.1
QT8 27 16 29 Q_NPN 0.1
QT4 15 6 17 Q_NPN 0.1
DZ1 2 9 D_5V6
R4 1 9 80K
R3 28 2 830
R2 13 28 4.97K
R1 8 13 7K
.MODEL D_5V1 D( IS=10F N=1.16 BV=5.1 IBV=0.5M CJ0 = 1P TT = 10p )
.MODEL D_5V6 D( IS=10F N=1.16 BV=5.6 IBV=5U CJ0 = 1P TT = 10p )
.MODEL Q_NPN NPN( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P
+ TF=10P TR=1N )
.MODEL Q_PNP PNP( IS=10F NF=1.16 NR=1.16 BF=80 CJC=1P CJE=2P
+ TF=10P TR=1N )
.MODEL D_D D( IS=1F N=1.16 CJ0 = 1P TT = 10p )
.ENDS LM7812CT
*==================================

You can check formatting using the little stubby pencil icon towards the right hand end of the same toolbar.

Reply
andyfierman 8 years ago

Sorry ... in the line for QT11 in my post above, there should be no * character in front of OFF.

:)

Reply
joaoff 8 years ago

Hi, Andy!

Thanks a lot! the procedure described in your first message enabled me to paste the model to the canvas as expected.

I downloaded the LM7812CT model from: http://ltwiki.org/files/LTspiceIV/lib/sub/regulators.lib. It seems that the model is present in the LTspice library, but no copyright notice is present. Still, the same model can be found in github: https://github.com/ssfrr/proxlamp/blob/master/sim/lm78xx.lib. Yet, an alternative model can be found in: http://forum.allaboutcircuits.com/threads/lm7824-orcas-pspice-model.58928/

Generally, this problem of a multiline text ending in a single line is due to the different text file line endings of linux and windows. Fortunately, there are some tools that can make the proper conversion.

%%%%%

Package: dos2unix (6.0-1)

convert text file line endings between CRLF and LF

This package contains utilities dos2unix, unix2dos, mac2unix, unix2mac to convert the line endings of text files between UNIX (LF), DOS (CRLF) and Mac (CR) formats.

Text files under Windows and DOS typically have two ASCII characters at the end of each line: CR (carriage return) followed by LF (line feed). Older Macs used just CR, while UNIX uses just LF. While most modern editors can read all these formats, there may still be a need to convert files between them.

This is the classic utility developed in 1989.

%%%%%

I'm glad you explained about the stars and plus signals being converted to bullets. I tried to use "Code Sample" button, but I first clicked on it and then tried to paste the code in the place holders, but it did not work.

The "off" optional parameter in transistors QT15, QT12 and QT11 appears as comment in the model. Earlier, I completed the netlist by hand and simulated the circuit in NGSpice without the off parameter and it converged without problems and presented the expected result.

Reply

Login or Register to add a comment
goToTop
你现在访问的是EasyEDA海外版,建议访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
联系我们:https://docs.lceda.cn/cn/FAQ/Contact-Us/index.html不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus-@1x -mockplus-

Cookie Notice

Our website uses essential cookies to help us ensure that it is working as expected, and uses optional analytics cookies to offer you a better browsing experience. To find out more, read our Cookie Notice