I also tried to use (and uncovered) the same problems with the Vishay model for the 6N137. I then tried the solution provided by Dim, without good success (sorry, but there it is.) So this left me with either spending time fixing the errors (there are a few areas that got my attention and curiosity, but I wasn't sure about) or else checking in with the Yahoo Groups site for LTspice. I decided to start there and was able to find a nice symbol and a model that worked for me.
I then made a few small changes related to how the symbol specifies the library. (The symbol can specify it so that one does not need to use a .include on the schematic to find it.) I also set it up so that it is possible to place multiple models (similar ones, anyway) into the same model file and LTspice will automatically provide a drop-down selection list. (This uses an undocumented 'feature' of LTspice.)
Here is the symbol, to start. Copy and paste it into a file located in the ../lib/sym folder (or in any other directory you please.) Use the filename 6N137.ASY when saving it.
Version 4
SymbolType CELL
LINE Normal -96 -48 -56 -48
LINE Normal -56 -16 -56 -48
LINE Normal -56 16 -56 48
LINE Normal -96 48 -56 48
LINE Normal -80 -16 -32 -16
LINE Normal -56 16 -32 -16
LINE Normal -56 16 -80 -16
LINE Normal -80 16 -32 16
LINE Normal 128 -32 112 -32
LINE Normal 24 0 12 -4
LINE Normal 24 0 20 -12
LINE Normal 20 -4 24 0
LINE Normal 112 49 128 49
LINE Normal 112 16 112 49
LINE Normal 96 16 112 16
LINE Normal 96 -23 96 25
LINE Normal 112 -16 96 -16
LINE Normal 112 -32 112 -16
LINE Normal 91 25 91 -23
LINE Normal 80 0 91 0
LINE Normal 55 25 55 -23
LINE Normal 44 1 55 1
LINE Normal 44 -64 44 1
LINE Normal 128 -64 44 -64
LINE Normal 64 -22 64 -96
LINE Normal 102 12 108 16
LINE Normal 102 20 108 16
RECTANGLE Normal -96 -96 128 64
ARC Normal -4 12 20 -12 16 -4 -4 0
ARC Normal -28 12 -4 -12 -28 4 -4 0
ARC Normal 34 -23 80 25 55 25 55 -23
TEXT 105 -77 Left 2 E
TEXT 28 -77 Left 2 V+
WINDOW 0 -32 -112 Left 2
WINDOW 38 -16 80 Left 2
SYMATTR SpiceModel 6N137
SYMATTR Description High Speed Photocoupler
SYMATTR Prefix X
SYMATTR ModelFile 6N137.SUB
PIN -96 -48 NONE 0
PINATTR PinName A
PINATTR SpiceOrder 1
PIN -96 48 NONE 0
PINATTR PinName K
PINATTR SpiceOrder 2
PIN 128 48 NONE 0
PINATTR PinName S
PINATTR SpiceOrder 3
PIN 128 -32 NONE 0
PINATTR PinName C
PINATTR SpiceOrder 4
PIN 64 -96 NONE 8
PINATTR PinName V
PINATTR SpiceOrder 5
PIN 128 -64 NONE 8
PINATTR PinName E
PINATTR SpiceOrder 6
Also note that I've used CELL and not BLOCK, above. This is how a symbol should be set up, nominally. (The BLOCK type is for times when the symbol represents another page of a hierarchical schematic.)
Now for the model file. But just for a moment, first, go up and take a look for a line that says SYMATTR ModelFile 6N137.SUB
and note the same there. That's the name of the file you need to use for the model file, when saving it. If you want to use a different name, you will need to modify that line in the above symbol file so that it matches up. That said, here is the model file:
.subckt 6N137 A K S C V E
D1 A N001 LED
C1 A K 1p
V1 N001 K 0
R2 ta S 100
C2 ta S 200p
B2 S ta I=TABLE(I(V1), 0,0,2.5m,50m,15m, 55m)
C10 A C 0.1p
C11 K S 0.1p
M1 C ga S S NMOS1
C5 C ga 10p
De1 E V Dd1
R6 V E 6k
R7 E S 100k
B4 0 en I=TABLE(V(E,S), 0,0,1.4,0,1.5, 1m)
R4 en 0 1k
R5 V S 1.5k
C6 C S 10p
C4 en 0 10p
B3 S ga I=V(ta,s)*V(en)*10m
R3 ga S 100
C3 ga S 20p
.model LED D(Is=1e-17 Rs=4 N=1.5 Eg=1.7 CJO=5p Tt=5n)
.model NMOS1 NMOS(Vt0=2 Kp=0.03 Rs=5 Rd=5 lambda=0.02)
.model Dd1 D(Is=1e-7 Rs=10 Cjo=5p Tt=5n)
.ends
Save that file in the .../lib/sub folder (or in any other directory you please... though you may need to use the full file specification in the symbol file unless LTspice has otherwise been informed about the folder.)
The above should work with LTspice.
If you want to have several related models (ones that use the same symbol without confusion, but perhaps have either different approaches or else somewhat different behaviors), you can add them to the model file above. Just paste them above or below (or between) other .SUBCKT/.ENDS subcircuits. Make sure they are named differently, of course! If you do this, LTspice will provide a drop-down on the symbol that will the user to select the device from a list. Which is nice.
Typically, this means the symbol name must be placed on the SYMATTR SpiceModel
line in the symbol and not on the SYMATTR Value
line. (The SYMATTR Value
line needs to be blank, I think.) And this means the symbol itself probably needs to be edited so that the SpiceModel is shown and not the Value.
Just a few notes about creating symbols with lists that LTspice can handle in a drop-down.
I wish I'd been able to get Dim's stuff working quickly. But it went badly enough that only a cursory glance then convinced me to start with something that had been thoroughly tested by LTspice aficionados. And it just worked. Which is nice.