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:
The two I want to highlight are the ones named
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.
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:
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.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
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.
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.
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
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.
UniversalOpamp1 are equivalent, as are