Electronics

Getting Started With LTspice For Mac

LTspice For Mac
Written by John Woolsey

Skill Level: Beginner

Table Of Contents

Introduction

This tutorial will teach you how to create a circuit schematic, perform a simulation, and view circuit waveforms in LTspice for Mac. A basic understanding of electronics is expected.

LTspice is an extremely valuable tool for designing and simulating analog based circuits. It enables you to discover and correct issues before actually building your circuits in hardware.

The LTspice schematic created for this tutorial is available on GitHub for your reference.

What Is Needed

  • macOS Based Computer

Background Information

While doing a circuit simulation in KiCad for another article (Performing A Circuit Simulation In KiCad) and getting some strange results, I wanted to verify those results with a different SPICE simulator. While doing some research on what packages were available, LTspice kept popping up. I decided to download it and give it a try. By the way, the strange KiCad results I was getting turned out to be user error.

LTspice is a high performance SPICE simulator, schematic capture, and waveform viewer with enhancements and models for making simulation of analog circuits easier. It was originally created by Linear Technology, hence the LT in its name, and was later acquired by Analog Devices who continues to support it. LTspice is known for being the most widely used free SPICE simulator in the industry.

I began searching for tutorials and getting started guides and kept finding they were all focused on the Windows version. The Mac version works much differently, so those resources didn’t really apply. I figured out how to get things working and thought I would share my knowledge for others also working on Macs.

Installing LTspice

Download and install the application from the LTspice homepage on Analog Devices’ website if you have not done so already.

Click the Download for Mac OS X 10.7+ button within the Download LTspice section of the homepage to download the LTspice.dmg file.

Download LTspice Section Of LTspice Homepage
Download LTspice Section Of LTspice Homepage

Double-click the downloaded dmg file to mount the volume. Double-click the LTspice Installation volume to open it.

LTspice Installation Volume Window
LTspice Installation Volume Window

Drag LTspice.app to the Applications folder from within the volume’s window to install the application. Close the open volume window. Unmount the volume by right-clicking (also known as control-clicking or secondary-clicking) the volume and selecting Eject “LTspice Installation”. Delete the LTspice.dmg file when done.

Opening LTspice For The First Time

Open the LTspice application by double-clicking the LTspice.app application within your /Applications folder. You should see a notification that it was an app downloaded from the internet and asking if you are sure you want to open it.

Internet Download Window For LTspice
Internet Download Window For LTspice

Click the Open button to continue opening the application. NOTE: Sometimes you may need to right-click the application and open it from the contextual menu if the system states it was not able to open the application due to it being downloaded from the internet or from an unidentified developer. Once opened, you will be presented with a welcome window asking how you want to proceed.

LTspice Welcome Window
LTspice Welcome Window

Upon initial launch of the LTspice application, it will automatically create the ~/Documents/LTspice folder where your LTspice files will be stored. It will also add an examples folder within the LTspice folder that contains Educational and test jigs example circuits. These same example circuits are also located in the /Applications/LTspice.app/Contents/examples folder.

Creating A Schematic

Let’s create a new circuit schematic by clicking the Start a new, blank Schematic button from the Welcome to LTspice window. A new schematic capture window will open with the title of Untitled. If you are familiar with LTspice on Windows, you will notice that the schematic capture window looks completely different. The Mac version contains only three icons in the tool bar versus a multitude of icons for the Windows version. Instead of primarily using toolbar based commands, LTspice for Mac focuses on the use of contextual menus for its commands. This means that you will right-click on or in the area of interest and select your command in the contextual menu that appears.

The circuit we are going to build is a simple small signal bipolar junction transistor (BJT) common emitter amplifier. The completed schematic will eventually look like the one shown below.

Completed Schematic
Completed Schematic

Let’s begin by placing the transistor into the circuit. Right-click somewhere in the schematic window and select Draft > Component from the contextual menu that pops up. A sub-window will appear with available components listed at the bottom. Enter npn in the search bar to locate the Bipolar NPN transistor component. This component uses a basic generalized simulation model for a BJT NPN transistor.

Schematic Component Selection Window
Schematic Component Selection Window

Click the OK button to select the component. The sub-window will disappear and the component’s symbol will follow the mouse cursor until you click again where you want the symbol placed in the schematic. Once placed, the component will remain available for additional placements until you press the escape (ESC) key. During placement, you will see the Type Ctrl-R to rotate/Ctrl-E to mirror text appear in the middle of the toolbar. This area will provide additional options available during placement and other commands. In this instance, we could have pressed CTRL-R for example to rotate the transistor symbol clockwise by 90 degrees before clicking for placement. Press the ESC key to end placement.

Schematic Component Placement
Schematic Component Placement

Let’s update the transistor model from the generalized model to one describing an actual transistor in common use. Right-click the transistor symbol and click the Pick new transistor button in the pop-up window that appears. Select the 2N2222 model and click OK. You should now see the 2N2222 model designation shown next to the transistor symbol.

Click and drag the mouse cursor to move the schematic around in the window. For zooming in and out, use two finger pinching and spreading, or alternately, two finger scrolling. You can even show grid dots to help you with placement by selecting View > Grid Dots from the contextual menu.

Next, let’s place our resistors in a similar fashion to the way we placed the transistor above (Draft > Component). This time, however, we will select the A resistor (res) component, keep clicking (placing resistors) until all resistors are placed, and then end our placement by pressing the ESC key. You should end up with five resistors (R1 through R5) placed generally in the same locations as those shown in the Completed Schematic above.

To change the value of a resistor, hover the mouse cursor over a resistor (you should see Right-click to edit R1. in the toolbar when hovering over R1) and then right-click on the resistor. A pop-up window appears that allows you to change the value. Update all resistor values to match those in the Completed Schematic shown above. For instance, enter 110k, with no spaces, for the value of R1. Note, you also have the option to change a resistor’s value by right-clicking on the value label (R). This option, along with the reference designator name (R1), also give you the capability of changing label parameters.

If you make a mistake, you can delete symbols by selecting Edit > Delete from the contextual menu (cursor changes to scissors) and then clicking on the component(s) you want to delete. You can also move symbols with Edit > Move. Make sure to press the ESC key when you are done.

Now add the two decoupling capacitors (cap/Capacitor) to the schematic. You will need to press CTRL-R before placement to rotate the capacitors to their preferred orientation. When updating the values, you only need to update the Capacitance[F] field and can ignore the others.

Next we need to wire up our circuit. Select Draft > Wires from the contextual menu and connect the components by clicking at each point where you want to connect a wire, beginning and end of wires. Don’t forget to press ESC when done.

We also need to add some wire (net) labels that will help us during simulation later on. The orientation of the labels will change based on how they are connected to wires or components and are not user adjustable. For this reason, I like to add wire extensions (just additional wires) to the schematic where you want to place the labels. Although this is not required, I do believe it makes the schematic look nicer. Add the wire extensions to the schematic, if you so choose. Select Draft > Net Name to place net labels for the GND, Vcc (Input Port Type), Vin (Input Port Type), and Vout (Output Port Type) nets. The graphic representation for the net label in the associated pop-up window will change according to the Port Type selected and the net name entered in the text field.

Your circuit should now look very similar to the Completed Schematic shown above. Let’s save our work by selecting File > Save As from the main menu (not the contextual menu), entering amplifier for the file’s base name, leaving .asc as the extension, and saving the schematic to the LTspice directory within our Documents folder.

Preparing The Schematic For Simulation

Our circuit is looking good, but to run a simulation, we need to add power supplies and let LTspice know what type of simulation we want to perform. Our updated schematic will eventually look like the one shown below.

Schematic For Simulation
Schematic For Simulation

To add a voltage source, select and place (Draft > Component) a voltage/Voltage Source component in an empty area of the schematic and then change its DC value (right-click on the voltage component) to 20 volts. You can ignore the Series Resistance[Ω] field. Add a GND net name to its negative terminal and a Vcc (Output Port Type) net name to its positive terminal. These net names will virtually connect those named terminals to the same named terminals of our amplifier. This voltage source will supply DC power to the amplifier circuit.

Next, add an additional voltage source in the same fashion, but use Vin this time for the positive terminal name and don’t add a DC value. This voltage source will be the input of the amplifier and its value is a bit more complicated than the standard 20 volts DC used for the Vcc power supply. This one will be an AC voltage source. Right-click on the Vin voltage source component to edit its value. Instead of entering a DC value, click the Advanced button to give us more options. Select Sine(…) as the style, enter 0 for DC Offset[V], 1m for Amplitude[V], and 1k for Freq[Hz], and then click the OK button. This will make the Vin voltage source a 1 KHz sine wave with a 1 mV amplitude.

We could have just connected the positive terminals of the voltage sources to the appropriate connections on the amplifier circuit, but I wanted to illustrate the use of named nets for connecting across circuits and this is also a common practice for connecting power supplies.

We are done adding components and wiring up our schematic. It is now time to tell LTspice what kind of simulation we want to perform. To add a SPICE command, select Draft > Spice directive from the contextual menu, enter .op in the text box, click the OK button, and then click somewhere in the schematic to place the text. The .op directive requests that an Operating Point Analysis be performed. It is the simplest SPICE simulation that can be performed and will only look at the DC domain ignoring any AC attributes. It will provide us the various DC based node voltages and component currents in the circuit.

Your schematic should now look like the Schematic For Simulation shown above when complete. Save your schematic (File > Save) when you are happy with it.

Running A Simulation

Now that our schematic is all prepped, we can run our first simulation. Click the Run! button (running person icon at the far left of the toolbar). A blank (black) window will pop up with the title amplifier.raw. This is where the circuit waveforms will be displayed, but let’s ignore it for now. Right-click in a blank area within the schematic window and select View > SPICE Netlist from the contextual menu. A new window will appear with the title of amplifier.net. This is the SPICE circuit netlist file that is used as the basis for all SPICE circuit simulations. You could have just created this text file by hand and run the simulation without even creating a schematic, but a visual representation of the circuit is usually much more useful.

SPICE Circuit Netlist
SPICE Circuit Netlist

The text file creates a circuit by specifying the components (e.g. Q for transistors, R for resistors, C for capacitors, etc.), the nodes to which the component terminals are connected, and the component values. I won’t go into the details of the SPICE language, but for those of you interested, check out SPICE on Wikipedia or The Spice Page for more information. Traditionally, the .cir extension is used for SPICE circuit netlist files and this extension is also recognized by LTspice if you decide to create your circuits in this fashion.

Next, let’s take a look at the simulation output. This is accomplished by selecting View > SPICE Error Log from the contextual menu from within the schematic. A pop-up window (amplifier.log) will appear containing the log file. It will display the values calculated (simulated) for the various node voltages and component currents in the circuit. This file is also known as the simulation output log file as it can contain much more information than just possible errors.

SPICE Simulation Output/Error Log
SPICE Simulation Output/Error Log

Looking at the log’s contents, we see that values of Ic = 969 µA and Vce = 9.34 V were calculated for the collector current and collector to emitter voltage of the 2n2222 transistor. The line beginning with I(R3) tells us that the current flowing through resistor R3 is approximately 969 µA, which properly matches with the value of Ic.

Note, if you happen to see unexpected negative currents, for instance through a resistor, you can rotate that component by 180 degrees in the schematic. This is done by pressing CTRL-R twice during a move (Edit > Move). You do not, however, have to make the rotations if you do not mind seeing the negative currents. It does not cause any issues with the simulation results.

Viewing Circuit Waveforms

Let’s change our focus to viewing circuit values in the waveform viewer. Make the schematic window active by clicking somewhere within the window. If you hover your cursor over a wire or component while the waveform viewer is visible, you will see the cursor change to either a probe or an ammeter respectively. Clicking a wire will display the voltage of the circuit node associated with that wire in the waveform viewer. Likewise, clicking a component will display the current (in the direction of the arrow in the cursor) through that component. The text in the middle of the toolbar will let you know what you are about to plot. For example, hovering the cursor (ammeter) over the R3 resistor will display the text Click to plot device current: I(R1).

Click on the R3 resistor and you should see a line appear in the waveform viewer just below the 1.0mA tick mark. This matches the the value of Ic we saw previously in the SPICE log. Now click on the node at the collector of the transistor (just below R3) with the probe cursor. The value of V(N001) should now be plotted as well with the left axis showing voltage and the right axis showing current.

Waveform Viewer Showing V(N001) Voltage And I(R3) Current
Waveform Viewer Showing V(N001) Voltage And I(R3) Current

You can change the scale of an axis by hovering over it until the cursor turns into a ruler then right-clicking on the axis to manually update its values.

Plots are removed by selecting Edit > Delete from the contextual menu within the waveform viewer (cursor changes to scissors) and then clicking the labels, e.g. V(N001) and I(R3), you want to delete that are displayed above the plot. Press the ESC key when done. An alternative method is to click the probe or ammeter cursor in the schematic twice on a value of interest. This will remove all other plots and show you only that one.

You can even view the instantaneous power dissipation of a component by pressing the Option key (cursor changes from an ammeter to a thermometer in the schematic) before clicking on the component. Doing this for R1 provides a value of about 3.1 mW.

Another cool feature we can use is plotting the voltage difference across nets (nodes). Let’s do this to determine the value of Vce (Vc – Ve). Delete all of your current plots so that we have a clean slate. Hover the cursor over the collector voltage (the node just below R3) in the schematic until you see the probe. Click and hold the mouse button, drag the cursor (the cursor changes from red to gray) to the emitter voltage (the node just above R4), and then release the button when the cursor changes from gray to black. The plot title should be V(N001,N003) and the value plotted should be around 9.34 V, which matches the Vce value we saw previously in the log file.

Let’s now look at running a different type of simulation. A Transient Analysis simulation will look at a circuit’s behavior over time. To change the SPICE directive, right-click the mouse over the .op SPICE statement and an edit window will appear. Add an * and a space before the .op to comment out that directive. This still leaves it available for reference or later use. On the next line (Control-Return starts a new line), add .tran 100u 5m and then press the OK button when done. This specifies that a transient analysis simulation will be performed starting at time 0, ending at 5 ms, and using a step of 100 µs.

Final Schematic
Final Schematic

Close the existing waveform viewer window and click the Run! button again to start the new simulation. Probe the Vout node, then the Vin node, and you should see about five periods of both the input and output voltage waveforms.

Waveform Viewer Showing V(vout) And V(vin) Voltages
Waveform Viewer Showing V(vout) And V(vin) Voltages

The voltage gain of our amplifier design is expected to be

\(\large Voltage\ Gain = \frac{Vout}{Vin} = \frac{R3 \parallel R5}{R4} = \frac{R3 \cdot R5}{(R3 + R5) \cdot R4} = \frac{10 \cdot 100}{(10 + 100) \cdot 1} \approx 9\)

The Vin voltage source was specifically set to 1 mV. Let’s check Vout to see how close our design came to expectations. We see from looking at the graph that the peaks of the Vout voltage curve are around 9 mV. Zoom in for a closer look by dragging a box with your cursor over the peak. Overlay a plot grid by selecting View > Grid from the contextual menu. We should see the peaks topping out at about 8.8 mV. Not bad. You can zoom back out by selecting View > Zoom to Fit from the contextual menu or clicking the Zoom to Fit button at the far left of the toolbar.

You can save a plot settings file (.plt) by making the waveform viewer the active window and then selecting File > Save As from the main menu (not the contextual menu). This will save the current waveform view such that this view will automatically load the next time this type of simulation is run. You can test it out by closing the waveform viewer and rerunning the simulation. Your view should look exactly the same when the waveform viewer reappears.

Wrapping Up

If you happen to view the SPICE log file after running simulations other than the basic Operating Point Analysis (.op), you will not see the DC domain data that we viewed earlier. This data is only available (within LTspice) when running an operating point analysis. It is sometimes available when using other SPICE simulators.

When exiting the application, all files that are easily created (e.g. .net, .log, etc.) are automatically deleted, leaving only your pertinent files (.e.g. .asc, .plt, etc.).

Exit the application by selecting LTspice > Quit LTspice from the main menu.

Additional Resources

The following is a list of resources you may find helpful.

Summary

In this tutorial, we learned how to use LTspice For Mac to

  • build a simple small signal BJT common emitter amplifier in the schematic editor,
  • prepare the schematic for simulation by adding voltage sources and SPICE directives,
  • perform simple Operating Point Analysis and Transient Analysis simulations,
  • view SPICE netlist and output log files, and
  • view various circuit data waveforms in the waveform viewer.

The final schematic used for this tutorial is available on GitHub.

Thank you for joining me in this journey and I hope you enjoyed the experience. Please feel free to share your thoughts in the comments section below.

About the author

John Woolsey

John is an electrical engineer who loves science, math, and technology and teaching it to others even more.
 
He knew he wanted to work with technology from an early age, building his first robot when he was in 8th grade. His first computer was a Timex/Sinclair 2068 followed by the Tandy 1000 TL (aka really old stuff).
 
He put himself through college (University of Texas at Austin) by working at Motorola where he worked for many years after that in Research and Development.
 
John started developing mobile app software in 2010 for himself and for other companies. He has also taught programming to kids for summer school and enjoyed years of judging kids science projects at the Austin Energy Regional Science Festival.
 
Electronics, software, and teaching all culminate in his new venture to learn, make, and teach others via the Woolsey Workshop website.

Leave a Comment