3
\$\begingroup\$

How are the Ltspice library optocouplers modeled? E.g. PC817 has this one:

.subckt PC817 1 2 3 4
R1 N003 2 2
D1 1 N003 LD
G1 3 N004 N003 2 {Igain}
C1 1 2 18p
Q1 3 N004 4 [4] NP
.model LD D(Is=1e-20 Cjo=18p)
.model NP NPN(Bf=1200 Vaf=140 Ikf=100m Rc=1 Cjc=19p Cje=7p Cjs=7p C2=3e-15)
.ends PC817

It looks like the input diode is connected in series with a resistor and voltage across the resistor is fed to a voltage-controlled current source. The source is connected between the base and collector of the output transistor.

If this interpretation is correct, how much is the source A/V gain? I can only see {Igain} but no link to anything. And what does [4] mean? My search for the general meaning of curly and square braces failed to deliver results.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ The general meaning of curly braces is to evaluate whatever's in the braces before running any simulation. Here, it just means to get the value of the parameter Igain, as defined elsewhere in the netlist, either as a parameter when instantiating a PC817 device (as in X1 a b c d PC817 Igain=10) or as part of a .param statement \$\endgroup\$
    – Hearth
    Jul 15, 2022 at 14:51

1 Answer 1

7
\$\begingroup\$

Okay, so first one of the last questions:

{Igain} is a replacement. You can do this on your own and it is quite useful for stepped circuit analysis where you want to see the results when changing a parameter. On the schematic, you'd use .param Igain=500 or something similar.

In this example it's noteworthy that there are different variants to select from, but only one subcircuit .sub exists. This leads to the guess that the parameter is set, depending on which variant you are using.

And you can find this in the .asy file for the variants.

This is taken from PC817A.asy:

...
SYMATTR SpiceModel PC817.sub
SYMATTR Value2 PC817 Igain=1m
...

So we can see, that Igain will be replaced by 1m (0.001). For the B variant it's 1.5m.

I'm currently not sure what the [4] notation means. In descriptions it often means an optional parameter. For a bipolar transistor it's in the position of the substrate node - and in the help it's written like this:

Syntax: Qxxx Collector Base Emitter [Substrate Node] model [area] [off] [IC=<Vbe, Vce>] [temp=]

But I haven't seen an example with the substrate node being used, so I'm not sure if that is all...

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Whoever made the model probably felt like being a bit pedantic by keeping the square braces, as in the syntax that you're showing. It has no special meaning. It would have had if it was part of a bus, but it's not. \$\endgroup\$ Jul 15, 2022 at 11:47
  • 2
    \$\begingroup\$ @aconcernedcitizen Wait. I thought that leaving out the 4th entry for a BJT ties its substrate to the zero node. In MOSFETs is where it dupes the 3rd pin to 4th. As for why the brackets are there...imagine if you were to make a subcircuit by drawing a schematic in LTspice and then copy/paste out the netlist. The schematic -> netlist generator automatically throws the brackets in whenever you place an npn4 or pnp4 or lpnp down. That's my guess to how it made it in there. \$\endgroup\$
    – Ste Kulov
    Jul 15, 2022 at 22:11
  • 1
    \$\begingroup\$ @SteKulov Oops, you're right. I was considering the above netlist and got mixed up. But I don't see the automatically added pin in the View > Netlist. If I place the default 3-pin NPN, for example, the netlist entry shows, by default, 4 pins. But if I place a SPICE directive with (e.g.) q a b c n (and an appropriate .model), the netlist shows exactly what is typed. That means that the bipolar symbols will all use the 4-pin netlist entry, but the 3-pin is also supported. When you said "automatically", did you mean that the 4th pin entry is considered for the 3-pin symbol? \$\endgroup\$ Jul 16, 2022 at 7:17
  • 1
    \$\begingroup\$ @aconcernedcitizen Oh, I meant that if you put one of those 4-terminal BJT symbols I listed, then the netlist will show the substrate pin within brackets. The brackets will stay unless that pin is connected to the zero node (oddly enough). Therefore, I believe this subcircuit was created in schematic with an npn4 symbol and they connected substrate to the emitter. Since Iss is not defined (default is zero) there will be no diode equation there, but there is a junction capacitance due to Cjs=7p. It makes sense in an opto to float everything. \$\endgroup\$
    – Ste Kulov
    Jul 17, 2022 at 6:20
  • 1
    \$\begingroup\$ @SteKulov Aha, now I see. Good thing there's such a thing as synchronization. :-) Yes, that's most probably the cause. (it shows how often I used the 4-pin symbol...) \$\endgroup\$ Jul 17, 2022 at 7:30

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.