A man measures a suit with a ruler, focusing intently on the fabric and ensuring precise measurements.

Importing Op Amp Models in LTspice: When All Else Fails, Customize the Symbol: Part 3 of 3

I explore a technique to repurpose the opamp2 symbol with slight modifications – all in the interest of efficiency. I will demonstrate how to edit an existing symbol to create an op amp symbol that has seven pins (rather than five), in part three of this blog series on importing op amp models in LTspice.

Start with a Working Schematic

Similar to the previous post, we will use a working example that will simulate correctly – the AD8656 model has a pinout that is compatible with the opamp2 symbol.

Schematic File: Imported AD8656 Schematic.asc

 Starting with a Simple Working Example

Figure 1: Starting with a Simple Working Example

Replace the Model Contents and Inspect the Pin List

To explore a scenario where the model isn’t compatible with the opamp2 symbol, download the ADA4817 SPICE macromodel.  With the model file (ada4817.cir) opened in a text editor, select all the model text and copy to the clipboard (usually right-click → Copy, or CTRL-C in a text editor). 

Click on your schematic to make it active.  Zoom out (Shift+Z) to expose some blank space on the schematic.  Add a SPICE directive by selecting from the menu Edit → SPICE Directive (or pressing .).  The Edit Text on the Schematic dialog will appear; paste the clipboard contents into the text entry box.  Click OK and click on the schematic to place the model contents.

 Adding the ADA4817 Macromodel to the Schematic

Figure 2: Adding the ADA4817 Macromodel to the Schematic

Link the Symbol to the New Model

We’ve imported a new model, but the simulation results won’t change until we point the opamp2 symbol to the new model. 

To link the symbol to the newly added ADA4817 model, right-click on the device name below the symbol (AD8656) – enter ADA4817 for the U1 symbol value and click OK.

 Linking the opamp2 Symbol to the New Model

Figure 3: Linking the opamp2 Symbol to the New Model

Try to Simulate – Error Reported

What happens when we try to simulate with this new model? Run the simulation by clicking the green play button (or press ALT-R).  When the simulation fails, the SPICE Output Log will pop up with the following message:

Number of nodes (5) does not match number of pins (7) of sub-circuit "ada4817".
X§U1 IN OUT +V -V OUT ADA4817
    ^^^^^^^^^^^^^^^^^

The method for importing an op amp model using the built-in opamp2 symbol won’t work in this case – we need a symbol with seven pins.

Make a Copy of the opamp2 Symbol

Right-click on the op amp symbol – this brings up the Component Attribute Editor.  Click Open Symbol – this will open the opamp2 symbol in the Symbol Editor.

 Opening the opamp2 Symbol in the Symbol Editor

Figure 4: Opening the opamp2 Symbol in the Symbol Editor

With the opamp2.asy file open in LTspice, select File -> Save As.  Give the symbol a new file name – I will use opampWithFBandPD.asy as a file name.  Click save and verify that your new symbol has been saved in the same directory as the schematic file you are currently working with.

With the newly saved symbol open, select Edit -> Attributes -> Edit Attributes to change the “Value” and “Description” fields.  Click OK, and then select File -> Save to ensure changes are retained.

 Changing Attributes of Newly Created Symbol

Figure 5: Changing Attributes of Newly Created Symbol

Add Pins to the New Symbol

Select Edit -> Add Pins/Ports to add pins.  To place the FB pin on the top and the PD pin on the bottom of the symbol, see below for settings that were selected.  Add the pins in order, FB first and then PD, to maintain the proper ordering required by the model SUBCKT header.

    Adding Pins to Newly Created Symbol

Figure 6: Adding Pins to Newly Created Symbol

For added clarity, you can use the Draw features to add lines, shapes, and extra text.

 Using Drawing Tools to add Details to New Symbol

Figure 7: Using Drawing Tools to add Details to New Symbol

Select File -> Save to ensure all changes are saved.

Place the New Symbol and Link it to the Model

To place the newly created symbol, select Edit -> Component.  Click on the Show dropdown list and select the Schematic Directory – this will allow you to place symbols from your schematic directory.

 Placing New Symbol in Schematic

Figure 8: Placing New Symbol in Schematic

Select the newly created symbol, click Place, and click on the schematic to place the symbol.

Right click on the symbol to link it to the imported model – change the value to ADA4817 (or the name of the model as it is listed in the model SUBCKT header).

 Linking Symbol to ADA4817 Model

Figure 9: Linking Symbol to ADA4817 Model

Complete Wiring and Verify Supply Voltages

Rewire the feedback path so that the FB pin is used for feedback and connect PD to V+.  Double check the supplies to ensure they are compatible with the requirements of the ADA4817 – keep the input and output voltage margins in mind.  The ADA4817 has an input margin that’s 2.8 V below +Vs, as well as output margins that are roughly 1.5 V from both +Vs and -Vs.  At lower supply voltages, you might think signal clipping is due to a faulty model, but it’s actually representing the true behavior of the device.

Simulate!

Now that you have everything connected and adjusted properly, click the green play button to simulate.

 Adjusting connections in Feedback Path, PD Pin, and Supply Voltages

Figure 10: Adjusting connections in Feedback Path, PD Pin, and Supply Voltages

Can I Create a New Symbol from Scratch?

Sure – you can do that!  There’s an article that includes instructions on how to create a custom symbol, LTspice How to: Importing Third Party Models.

What's next?

Hopefully, this blog series has provided you with a straightforward and simple method for incorporating an op amp model into your LTspice schematic, as well as a straightforward strategy for accommodating extra pins in your model.  If you are struggling to get the most basic configuration to work with your imported model, you may need to contact the model vendor for guidance. 

Support is also available at  LTspice 

Read all the blogs in A Pinch of LTspice series.