1
\$\begingroup\$

How do you use an op-amp in a design in LTSpice?

I am trying to build my first circuit using an Op-amp, i.e., a subtractor in LTSpice.

However, do I need to build the circuit with my components around the op-amp model, as shown in image (1) or within its macromodel's test fixture, shown in image (2)? This is not quite clear to me. Please see below images!

(1) Circuit with components around op-amp model

(2) Op-amp macromodel

\$\endgroup\$
4
  • 2
    \$\begingroup\$ You must supply power to the opamp, otherwise it will not work as can be expected. So leaving the opamp's supply pins unconnected like in the first schematic is not going to work. If you use Google to search for "opamp LTSpice" you get many hits showing you how to do this, there is really no need to ask here. \$\endgroup\$ Commented Oct 27, 2020 at 20:59
  • \$\begingroup\$ Thanks for that. So, just so that I've understood you correctly. As long as provide power to the op-amp pins, the circuit should work? But, doesn't the macromodel imply that the pins have a 15V supply to them already or can I simply ignore those? \$\endgroup\$
    – aLoHa
    Commented Oct 27, 2020 at 21:05
  • 1
    \$\begingroup\$ How would you use that opamp in an actual circuit on a PCB? Will the opamp then supply it's own +/- 15V supply rails? I don't think so. Would it make sense to have a model that includes +/- 15V supply rails? Suppose I want to use the opamp with +/- 10 V supply rails or a single +5 V rail. Then I cannot use the model. Go simulate without the supply connections (first schematic) and probe the supply pins of the opamp. Do they have +/- 15 V? \$\endgroup\$ Commented Oct 27, 2020 at 21:10
  • 1
    \$\begingroup\$ But, doesn't the macromodel imply that the pins have a 15V supply to them already or can I simply ignore those? Why don't you just try it and see what happens. LTSpice is a simulator so nothing can be damaged. Does the opamp work better if you connect proper supply voltages to the supply pins? Again, there is no need to ask, see how others do this or experiment and see what works. \$\endgroup\$ Commented Oct 27, 2020 at 21:12

1 Answer 1

19
\$\begingroup\$

If you're just getting started with opamps, especially if you are learning via a traditional electronics course, I suggest using the more generic opamp models within LTspice. These more closely approximate the "ideal opamp" which is usually taught to beginners. I personally always start with one of these and then add more parameters to get a more accurate model (as needed), and/or eventually swap it out for a model supplied from the manufacturer for the exact part I intend on using. The generic models also have the advantage of having a much faster simulation time.


Anyway, if you navigate the component library under [Opamps] and scroll to the end, you will see something like this:

enter image description here

The two I want to highlight are the ones named opamp and UniversalOpamp2. I use opamp a lot, especially in filter design when first checking my calculations. It's a 3-pin symbol without power rails and has a single-pole gain-bandwidth characteristic....but since it requires an extra step and you can get the same results with UniversalOpamp2, we'll just focus on that one instead.

After you select UniversalOpamp2 and put one on your schematic, you have to configure it. If you right-click on the symbol, you'll see a window that looks like this.

enter image description here

Under SpiceModel it indicates a level.x. By default, it's level.2. If you double-click this box it becomes a drop-down menu with 4 different levels to choose from, as shown:

enter image description here

You can find detailed descriptions of all the levels by loading the example found in Documents\LTspiceXVII\examples\Educational\UniversalOpamp2.asc, but I'm just going to focus on level.1 and level.2 since those are the most useful. I actually never used the other two to this day. Anyway, level.1 is almost exactly like opamp, which means it doesn't use the power rails and only has a few settable parameters which are (ignoring the ones related to noise modeling):

Avol = DC open-loop gain
GBW = gain-bandwidth product
Vos = input offset voltage
Rin = input resistance

I'm going to change this opamp to a level.1 for now. In the same window where you select the level, you'll see some other fields called Value2, SpiceLine, and SpiceLine2 where these parameters are already set to some defaults. I'm going to leave almost everything default, but increase my GBW to 1g (1 GHZ) to make it closer to ideal in terms of frequency response. Now, my window should look like this and I'll hit OK to proceed.

enter image description here

I then used this opamp to create a non-inverting amplifier to illustrate I can amplify 1V to 100V without any limitation since this model ignores power rails.

enter image description here


Now, if I go back into the right-click window and change this to a level.2, there are new things to consider. First, there are three new parameters that come into play:

Slew = slewrate limit
ilimit = output current limit
rail = output stage saturation voltage

Let's leave these at default, but the last one in the list reminds us that now the power rails come into play. We need to add voltage sources to the remaining two pins on the opamp symbol, and this is where I think you are getting hung up on your original attempt. The easiest way to not clutter your schematic is to define your voltage sources off to the side and then add net-name labels to logically connect the nodes together. The red-colored labels in your 2nd screenshot (black by default, but looks like you adjusted your color scheme in the settings menu) are these labels. You can add them by pressing the F4 key, typing in a name, and then placing the resultant label down on the schematic in one or more places just like any other component. Here is the schematic and resultant waveforms after adding +5V & -5V rails and naming them Vcc & Vee, respectively.

enter image description here

Notice how the opamp output saturates at ±5V. If I set the rail parameter to 0.5, it would saturate at ±4.5V since that is 0.5V from the supplied rail voltages. Try doing it as an additional exercise and see if you get the expected result.


UPDATE: As of December 2nd 2021, LTspice was updated such that it broke out each UniversalOpamp2 level to its own symbol, so you no longer have to (and are no longer able to) select the level from the drop-down menu. You would just select the specific symbol for each level you wish to use, as shown below.

Note: UniversalOpamp and UniversalOpamp1 are equivalent, as are UniversalOpamp3 and UniversalOpamp3a.

enter image description here

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Very nice introduction. Especially since the UniversalOpamp2 can be used as a replacement for just about any opamp out there, and it will be a ton faster, lighter, and damn close to the original response if you take a little bit of time to tune it. \$\endgroup\$ Commented Oct 28, 2020 at 8:32
  • 1
    \$\begingroup\$ @aconcernedcitizen Thanks, man. Totally agree. I try my best to push people towards using UniversalOpamp2, but they seem to always think the manufacturer-supplied model (which struggles to converge due to several B-sources and/or POLY(5) E-sources) is always "better". \$\endgroup\$
    – Ste Kulov
    Commented Oct 28, 2020 at 9:10
  • 1
    \$\begingroup\$ I found out that there are two main reasons behind it: poor reasoning and comfort (or some other word). The former is an alias for "if the manufacturer made this model, it must work anytime". The latter is either lack of info (too few people know about it and what it can do) and it's at the end of the [Opamps] list. Who would bother scrolling that much when you can go to the manufacturer's site, download the model, maybe also the symbol to go with it, if not create your own, edit attributes, and then simulate -- only to risk ending up praying? Maybe I say this because I'm not religious. \$\endgroup\$ Commented Oct 28, 2020 at 10:25

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.