Introduction LTspice is a free SPICE simulation software tool with schematic capture, waveform viewer, and many enhancements that runs on both Windows and Mac OS X. I use it to research circuit behavior and quickly experiment with new circuits for my lab before prototyping a PCB (Printed Circuit Board) design. The learning curve is easy to conquer thanks to support by Analog Devices, Yahoo's LTspice Support Group and its compatibility with most common SPICE models supplied by chip vendors. This Instructable will demonstrate how to go beyond the component library supplied with LTspice by incorporating an LMV321 op-amp model from three different chip vendors to create a simple amplifier schematic as shown in the drawing. Each of these models highlight different methods available within LTspice for use with the wide variety of component models supplied from various vendor websites. Each of these models present different performance features as well. To highlight these performance issues I reuse these three models in a Current-to-Voltage design as well.
The target audience are those with some experience placing components on a schematic and running a simulation. By the end of this tutorial you will know how to interpret the.SUBCKT command within manufacturer models for use with LTspice's opamp2 Pin Table and Attribute editors to use manufacturer parts within your simulations. Manufacture's SPICE Models We are going to incorporate three SPICE models based on the LMV321 op-amp in this tutorial. Follow along as I outline the steps. Create a folder for your upcoming LTspice schematics, symbols, and models. I will refer to this directory as our working directory going forward. Visit these chip vendor websites to extract the SPICE models for the LMV321 op-amp:.
See the three associated diagrams for specific files to download as of the writing of this instructable. In the future you may have to search for the model names if they have been moved by the chip vendors to new web pages. For TI and STMicro you would copy the model from the downloaded zip files into your working directory. For the Maxim model you would right-click on the LMX321.FAM file at their website and save it to your LTspice working directory. At the end of this step you should have these three spice model files in your working directory:. LMV321.MOD. LMX321.FAM.
LMV3xmacromodel.mod Each of these files can be opened with a text editor to see a common stucture:. documentation at the top,.SUBCKT command,. spice commands building out the model.
Opamp2.asy Is Reusable From the LTspice File menu Open the opamp2.asy symbol from your install directory. For Windows default installation this would be: C - LTC - LTspiceXVII - lib - sym - Opamps - opamp2.asy The opamp2 symbol has no op-amp model assigned to it. So it won't run in a simulation. For this reason it is a good starting block as it does contain the drawing and links for us to create any op-amp that uses the five common pins:. In+. In-. V+.
V-. Out Take care not to open one of these similar symbol files by mistake:. opamp.asy (similar to opamp2.asy but without the two power pins). UniversalOpamp2.asy (a fully functional opamp with generic model).
Pin Table Assignment Using.SUBCKT Open the LMV321 opamp model previously saved as LMV321.MOD in your working directory using your favorite text editor. Near the top we can find the.SUBCKT statement. A.SUBCKT defines a reusable SPICE netlist - similar to a function with it's name and associated parameters in software languages. The subcircuit syntax for an op-amp supplied by a manufacturer looks like this:.SUBCKT. Element statements.ENDS Op-amp name is the external reference to the name of the op-amp and the 5 N's are a list of ordered electrical connections to the op-amp as described directly above the.SUBCKT command.
Opamp Symbol Attribute Assignment One last step before saving the symbol file is to name the symbol using the Attributes Editor. We will use the same name as shown in the.SUBCKT line: LMV321. Open the Attribute Editor from the menu: Edit - Attributes - Edit Attributes Make the following changes:. Change Value to: LMV321 (use the same name as in.SUBCKT command line). Change Description to: Include LMV321.MOD in schematic (more on this later) Click OK and save the opamp2.asy as LMV321.asy in your working directory.
Notes:. Leave the X next to Prefix to indicate that the symbol will display in schematic,. Leave the Symbol Type as Cell so the model file will be interpreted correctly,. Don't save the modified opamp2.asy symbol back into the LTspice library or other schematics that may rely on this file may be corrupted,. If you did make this mistake (like I did once), you can restore the original opamp2.asy file with a re-sync using the command: Tools - Sync Release. Your working directory should have these files now:.
LMV321.asy. LMX321.FAM. LMV321.MOD. LMV3xmacromodel.mod.
Need Help Simulating A Subcircuit Op Amp In Ltspice For Mac Free
Test LMV321 Op-amp Model in a Simulation Open a new schematic from within LTspice: File - New Schematic We will create an op-amp test circuit based on a non-inverting amplifier with a gain of 2: Gain = 1 + Rf / Rin Add our newly created LMV321.asy component from your working directory using the LTspice ribbon menu component command. Hint: Many LTspice users are not aware that they have to change the symbol's directory to their working directory. To manage access to the new files, switch the item 'Top Directory' to their working directory.
Power the op-amp with a 5 volt supply using the voltage component. Test the op-amp with repeating pulses ranging between 0.2 and 2.3 volts to the non-inverting input using a second voltage component. Set up a transient analysis over a 500 microsecond interval using the LTspice ribbon menu.Op SPICE directive command. Create LMX321.asy Symbol With Correct Attributes and Pin List / Netlist Order Go to your working directory and open the LMX321.FAM model with your favorite text editor to view the.SUBCKT information (see diagram). We repeat the last two steps to build a new op-amp component and test circuit. Open our previously created LMV321.asy symbol from LTspice located in your working directory: File - Open - LMV321.asy Note: If you did not create the LMV321.asy symbol earlier then you can open the opamp2.asy symbol instead. Use the Attributes Editor to change the symbol Value and Description (see diagram): Edit - Attributes - Attributes Editor.
Value: LMX321. Description: Include LMX321.FAM in schematic Click OK Use the Pin Table to change the order of connections to correctly line up with the.SUBCKT command (see diagram): View - Pin Table The connection list from 1 to 5 is in a different order than the list for our previous LMV321 op-amp so we will have to change the Pin Table for LMX321 symbol as follows:.
In+ = 1. In- = 3.
V+ (Vcc) = 5. V- (Vee) = 2. Out = 4 Click OK Why?
Need Help Simulating A Subcircuit Op Amp In Ltspice For Machine Learning
In the.SUBCKT description within the model we find that In+ is assigned to '1' so we assign In+ to 1 in our Pin Table. But In- is assigned to '3' in the.SUBCKT description so we assign In- to 3 in our Pin Table. Save the new symbol to your working directory as LMX321.asy Your working directory should have these files now:. testLMV321.asc. LMX321.asy. LMV321.asy. LMX321.FAM.
LMV321.MOD. LMV3xmacromodel.mod.
Test LMX321 Op-amp Model in a Simulation Open our previous test circuit and change the op-amp references to the LMX321: File - Open - testLMV321.asc Delete the reference to the LMV321 op-amp in our schematic. Use the component option on the LTspice ribbon menu to place the LMX321.asy op-amp. Replace the reference to the model by right clicking on the.INC command in the schematic drawing with:.INC LMX321.FAM Replace the title to reflect our new schematic purpose: Maxim LMX321 model: Non-Inverting Amplifier All the other elements of the schematic will remain the same. Save the schematic in your working directory as testLMX321.asc Run the simulation for the Maxim LMX321 op-amp model. Click the Run icon on the LTspice ribbon menu Measure V(out) and V(In+) using your cursor over the associated wires Note that the gain is shown as 2, as we predicted above. Your working directory should have these files now:.
testLMX321.asc. testLMV321.asc.
LMX321.asy. LMV321.asy. LMX321.FAM. LMV321.MOD. LMV3xmacromodel.mod. Create LMV3x.asy Symbol With Correct Attributes and Pin Table Go to your working directory and open the LMV3xmacromodel.mod model with your favorite text editor to view the.SUBCKT information (see diagram). Open our previously created LMV321.asy symbol from LTspice located in your working directory: File - Open - LMV321.asy Note: If you did not create the LMV321.asy symbol earlier then you can open the opamp2.asy symbol instead.
Use the Attributes Editor to change the symbol Value and Description (see diagram): Edit - Attributes - Attributes Editor. Value: LM3x.
Description: Include LMV3xmacromodel.mod in schematic Click OK Use the Pin Table to change the order of connections to correctly line up with the.SUBCKT command (see diagram): View - Pin Table The connection list does not have numbers and the parameters are in yet another different order than the list for our previous two op-amp.SUBCKT's. There is no need for numeric entries in the.SUBCKT command, but we will have to change the Pin Table for LM3x symbol to line up with our original opamp2.asy order as follows:. In+ = 2. In- = 1. V+ (Positive Power Supply) = 4.
V- (Negative Power Supply) = 5. Out = 3 Click OK Why? The.SUBCKT description of the 5 pins are in a specific order. We take the first entry to be pin 1, which is the Inverting Input (In-) parameter.
So we mark the In- entry using the Pin Table as number 1. The second entry will be pin 2, which is labled as the Non-Inverting Input (In+). So we mark the In+ entry using the Pin Table as number 2. Save the new symbol to your working directory as LMV3x.asy Your working directory should have these files now:.
testLMV321.asc. LMV3x1.asy. LMX321.asy. LMV321.asy. LMX321.FAM. LMV321.MOD.
LMV3xmacromodel.mod. Complete LMV3 Op-amp Model and Test in a Simulation Open our original test circuit and change the op-amp references to the LMV3x: File - Open - testLMV321.asc Delete the reference to the LMV321 op-amp in our schematic. Use the component option on the LTspice ribbon menu to place the LMV3x.asy op-amp Replace the reference to the model by right clicking on the.INC command in the schematic drawing with:.INC LMV3xmacromodel.mod Replace the title to reflect our new schematic purpose: STMicroelectronics LM3x model: Non-Inverting Amplifier All the other elements of the schematic will remain the same.
Save the modified schematic as testLMV3x.asc in your working directory. Run the simulation for the STMicroelectronics LMV3x op-amp model. Click the Run icon on the LTspice ribbon menu Measure V(out) and V(In+) using your cursor over the associated wires Note that the gain is shown as 2, as we predicted above.
Need Help Simulating A Subcircuit Op Amp In Ltspice For Mac Download
Your working directory should have these files now:. testLMV3x.asc. testLMX321.asc.
testLMV321.asc. LMX321.asy. LMV321.asy. LMX321.FAM. LMV321.MOD. LMV3xmacromodel.mod. Review Simulation Models in a Current to Voltage Circuit The non-inverting amplifier op-amp simulations we have explored so far show consistent results for each of the three models.
Namely a voltage gain of 2, as we predicted. I would like to leave you with one more circuit simulation using each of the three models.
A 'poorly' designed current to voltage converter. The schematic shows a predicted Vout = Iin. R1. For minimum error due to bias current the suggested value for R2 should be the same as R1. In my circuit I purposely use a much lower value for R2 in an attempt to expose model differences outside of normal design practices. The simulation should also help us visualize the poor design error predicted through variance in bias because R1 and R2 are not the same.
In the three simulations the Maxim LMX321 performs most differently in that the Vout seems low and no variance in bias or ringing. While the other two models, STMicro's LMV3x and National Semi's LMV321 show the expected Vout results along with some differences in variance in bias or ringing behavior. In conclusion I have shown three different methods encountered when importing manufacturer op-amp models using the LMV321 family for LTspice. We reviewed the National Semiconductor LMV321 model from TI's web site, STMicroelectronics LMV3x model, and MAXIM LMX321 model. These three methods should help you to import op-amp models for any other part using the model's.SUBCKT command along with LTspices' Attributes and Pin Table editors. I have also shown that some models perform better than others as demonstrated with the voltage to current converter schematic.
Testing two or more models in your simulation designs may help you get more reliable results for your needs. References: LTspice Download and Documentation LTspice group - Yahoo Groups: lots of files shared, active support for questions SPICE Quick Reference Sheet v1.0, Standford EE133 - Winter 2001: reference to.SUBCKT pp7-8 Op Amp Circuit Collection: National Semiconductor Application Note 31, September 2002: reference to non-inverting amplifier and current to voltage conversion op-amp circuits All files related to this instructable are available for download as a zip file below. Ltspicelmv321simulationfiles.zip Attachments.
With the definition of 'input offset voltage' I wanted to find it in simulation for LM358 op amp. Here is the definition: 'Input offset voltage is the differential input voltage that would have to be applied to force the opamp's output to zero volts.' In simulation by using 5V dual supply, I swept the non-inverting input from -500uV to +500uV and marked the point where the output becomes zero.
Below shows this sweep setup and the plot: I concluded from the sim that LM358 has around 35uV input offset voltage. Then I go to the to verify it. Here what the data-sheet shows: Typically the input offset voltage should be 2mV. But in sim I get 35uV. This is a big difference, so I wasn't sure what I am doing is correct. 1-) Is my way of measuring input offset voltage correct?
If it is correct what could be the reason there is such big difference? 2-) I have found LM358 OPERATIONAL AMPLIFIER 'MACROMODEL' SUBCIRCUIT. Where and how is this input offset voltage is mentioned in these SPICE models? Or is it mentioned at all?
Yes - your simulation profile is correct, provided you have sufficient resolution in the transfer region (at least 3.5 data points). This can be verified uisng the slope of the transfer line, which roughly must be identical to the open-loop DC gain. Please note that the given figures in the data sheet are typical values only (since the offset voltage is a kind of tolerance parameter), which can be expected. Hence, an actual value of 35µV for a given specification of 2mV is within specification (and very good). EDIT (comment): You cannot expect to see a parameter EOS in the model description. This would be the case for a 100% symmetric opamp model only.
However, most opamp models contain realistiv transistor models which are NOT symmetric by nature. Therefore, you cannot expect to have zero output for zero input (symmetric supply). This effect creates a kind of unsymmetry which determines the offset.