I am trying to use the Vishay-provided spice models of the 6N137 high-speed optocoupler in LTSpice. (Source: http://www.vishay.com/optocouplers/list/product-84732/)
Both the "PSpice" model and the "Spice" model fail however.
With the "PSpice" model:
WARNING: Can't resolve .param dpwr=$g_dpwr
WARNING: Can't resolve .param dgnd=$g_dgnd
Fatal Error: Port(pin) count mismatch between the definition of subcircuit "and2" and instance: "xx1:u2"
The instance has more connection terminals than the definition.
With the "Spice" model:
Too few nodes: au1.a [1] [du1.a] adc_a
What do I need to do to make either of these work in LTSpice?
Best Answer
Indeed, the model is not appropriate for LTSpice (as usual...).
Here is the tweaked 6N137 model. What was wrong was the use of the internal AND gate that combines the enable and the opto input. It was using PSpice syntax. Also, there was a Td (delay) specified for the internal opto switch, and this is unsupported by LTspice on the ISWITCH model.
So, basically, I redefined a new AND2 subcircuit to replace the existing one (using a basic IF function and the & operator), and added a DELAY20n subcircuit to simulate the missing delay from the switch (using a small RC filter). I had to slightly modify the main subcircuit according to this, of course.
Now, I can't guarantee the new model behaves exactly as the original one (actually, I can guarantee it does not behave exactly as the original one), but I think the deviations are minor. I checked the various delays with a test circuit, and they seem to be within spec.
Here you go:
And as a bonus, a simple asy symbol file that can be used with it:
For the LTSpice users that don't know how to use the whole thing (because it's not straightforward): copy/paste the asy symbol file contents in a file named 6N137.ASY and copy/paste the whole spice model details from above in a file called 6N137.LIB. Then, from you schematic, place the 6N137 component (from the ASY file). Also add a
.include 6N137.lib
directive somewhere in your schematic. You're done. Just note that all files must be located in the same folder.