2
\$\begingroup\$

I created a device from schematic - asy file + sub file. I wanted to encrypt this device, so I used a command ltspice.exe -encrypt "file path". But LTspice return the error ".lib statements should not be in a 3rd party encrypted file". I do not know what to do, because I used operational amplifier (UniversalOpAmp2.lib) and diode (standard.dio) inside my device, so obviously .lib statement will be present in this sub file. Could someone please advice how to convert a device included a diode and OpAmp, i.e. .lib statement?

\$\endgroup\$
0

1 Answer 1

2
\$\begingroup\$

The easiest thing to do to solve this would be to remove the .lib's and manually copy/paste the .subckt for level2 from UniversalOpAmp2.lib into the custom .sub file you want to encrypt. You can just paste the text at the end after the existing .subckt / .ends for your custom device. Do the same thing with the diode .model(s) you used from standard.dio. Here is an example of what your .sub should look like before you attempt to encrypt it.

.subckt MyCustomDevice 1 2 3 4 5
...
...
...
.ends

.subckt level2 1 2 3 4 5
S1 5 3 X 5 Q
S2 4 5 5 X Q
A1 2 1 0 0 0 0 X 0 OTA G={Avol/Rout} ref={Vos} Iout={slew*Cout} Cout={Cout} en={en} enk={enk} in={in} ink={ink} incm={incm} incmk={incmk} Vhigh=1e308 Vlow=-1e308
C3 5 4 1p
C4 3 5 1p
R2 X 4 {2*Rout} noiseless
R1 3 X {2*Rout} noiseless
R3 3 1 {2*Rin} noiseless
R4 3 2 {2*Rin} noiseless
R5 2 4 {2*Rin} noiseless
R6 1 4 {2*Rin} noiseless
B1 X 0 I=if(V(x,3)<0,0,({2*slew*Cout}*V(x,3))**2)
B2 0 X I=if(V(x,4)>0,0,({2*slew*Cout}*V(4,x))**2)
D1 5 3 X
D2 4 5 X
.param Rout=100Meg
.param Cout={Avol/GBW/2/pi/Rout}
.model Q SW(Ron=10 Roff=10Meg Vt=0 Vh=-.1 Vser={Rail} ilimit={Ilimit} noiseless level=2 epsilon={Rail/10})
.param Avol=1Meg GBW=10Meg Slew=10Meg ilimit=25m rail=0 Vos=0
.param en=0 enk=0 in=0 ink=0 incm=0 incmk=0 Rin=1G
.model X D(Ron=1 epsilon=10 noiseless)
.ends level2

.model 1N4148 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)

.model BAT54 D(Is=.1u Rs=2.2 N=1 Cjo=12p M=.3 Eg=.69 Xti=2 Iave=300m Vpk=30 mfg=Vishay type=Schottky)

You can alternatively include the extra models within the existing subcircuit definition, usually at the end (see below). This might actually be safer, in case (for example) someone defines a .model 1N4148 in the top-level schematic which could conflict with the one defined within your .sub. Doing it this way restricts scope/access to the .model within your custom subcircuit only. Might be a good idea to label your .ends statement to avoid confusion when doing nested subcircuits like this.

.subckt MyCustomDevice 1 2 3 4 5
...
...
...
.subckt level2 1 2 3 4 5
S1 5 3 X 5 Q
S2 4 5 5 X Q
A1 2 1 0 0 0 0 X 0 OTA G={Avol/Rout} ref={Vos} Iout={slew*Cout} Cout={Cout} en={en} enk={enk} in={in} ink={ink} incm={incm} incmk={incmk} Vhigh=1e308 Vlow=-1e308
C3 5 4 1p
C4 3 5 1p
R2 X 4 {2*Rout} noiseless
R1 3 X {2*Rout} noiseless
R3 3 1 {2*Rin} noiseless
R4 3 2 {2*Rin} noiseless
R5 2 4 {2*Rin} noiseless
R6 1 4 {2*Rin} noiseless
B1 X 0 I=if(V(x,3)<0,0,({2*slew*Cout}*V(x,3))**2)
B2 0 X I=if(V(x,4)>0,0,({2*slew*Cout}*V(4,x))**2)
D1 5 3 X
D2 4 5 X
.param Rout=100Meg
.param Cout={Avol/GBW/2/pi/Rout}
.model Q SW(Ron=10 Roff=10Meg Vt=0 Vh=-.1 Vser={Rail} ilimit={Ilimit} noiseless level=2 epsilon={Rail/10})
.param Avol=1Meg GBW=10Meg Slew=10Meg ilimit=25m rail=0 Vos=0
.param en=0 enk=0 in=0 ink=0 incm=0 incmk=0 Rin=1G
.model X D(Ron=1 epsilon=10 noiseless)
.ends level2
.model 1N4148 D(Is=2.52n Rs=.568 N=1.752 Cjo=4p M=.4 tt=20n Iave=200m Vpk=75 mfg=OnSemi type=silicon)
.model BAT54 D(Is=.1u Rs=2.2 N=1 Cjo=12p M=.3 Eg=.69 Xti=2 Iave=300m Vpk=30 mfg=Vishay type=Schottky)
.ends MyCustomDevice
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.