đź—™

Sign up for a free Altium Designer License and Curriculum?

Introduction to SPICE


There’s a lot of information we’ve presented in the previous sections. A lot of this relates to finding and selecting components, as well as how to place the components into your schematics. Sometimes, when you’re placing components in your schematics and you’re designing circuits, you don’t always know the best values to use for components, or if the circuit will produce the exact behavior you want to see. Some of the electrical behavior in your circuits can be calculated rather easily, but other circuits are more difficult and may require some tools to automate these calculations


This is where simulations are very important. Most ECAD programs, including professional PCB design applications, include a circuit simulator that automates many calculations you might need to perform in circuit design. As you build up your circuits, there are times where you need to evaluate its behavior to ensure the components you choose will work properly. It’s important to know when to use circuit simulations and what they can tell you about your system.


In this lesson, we’ll look at some of the basic circuit simulation tools you can use in ECAD programs, including in Altium Designer. Circuit simulations are performed while you’re creating circuits in your schematics, and you can run them repeatedly as you try out different components for your circuits. One of the benefits of these skills is that they carry over to other areas of electronics design; circuit simulations aren’t just used for PCB design.



SPICE Simulations

The industry-standard simulation package is called “Simulation Program with Integrated Circuit Emphasis,” or simply SPICE. This simulation package is open source, and anyone can implement the basic SPICE algorithm in their own simulation application. The program was originally created to run as code, and you can implement SPICE in programs like MATLAB. Today, many ECAD applications use their own version of SPICE and will give it a modified name; two common packages that are taught in many universities are LTSpice and HSpice.


A SPICE simulation can be used to determine the voltage and current distributed throughout a circuit diagram. In other words, a SPICE simulation calculates the current flowing through each leg of a circuit, and the voltage drop across each component in a circuit.


Not all circuits will need simulations, but if you know you’ll need to run simulations for certain circuits, there are some strategies you can use to set up your schematics and use components to quickly run simulations and complete your designs.



Basic Components for Simulation

Remember that designs need real components if you ever want to manufacture your board. However, the best practice when running simulations is not to use real components. Instead you can use generic components, meaning components that aren’t associated with any specific MPN.


Inside Altium Designer, you can access generic components from the Simulation Generic Components library in the Components panel.

When you open this library, you’ll see a long list of devices you can use to create circuits for SPICE simulations. The components in this panel can be added into a schematic just like any other component, just drag them into a sheet and place them where you need them. Other ECAD applications have similar libraries of generic components that you can use to create simulations.


Inside a generic components library, you’ll typically find the following list of components:

  • Passive components
  • Transistors
  • Logic gates
  • Switches and relays
  • Some specialty semiconductors (varactors, thyristors, etc.)


In addition to these components, there are some important simulation objects called “sources.” These objects represent a type of power source (voltage source, current source, AC source, DC source, etc.). The output power (voltage or current) supplied by the source then gets used to solve Kirchhoff’s laws and Ohm’s law in your circuit diagram.


The basic source component you’ll use in most basic circuits is the VSRC component in the Simulation Generic Components library. This source is meant to represent a voltage source that does not a have a current limit (i.e., it can source an infinite amount of current if needed), so it does not represent a real voltage regulator.

How to Work in Schematics and Plan For Simulations

The best way to use your ECAD tools to run SPICE simulations is to use a set of schematic sheets that are not part of your main design project. Remember that you may need to do some experimentation when you run SPICE simulations, so it’s best to copy the circuit you want to simulate into a new sheet. This way, you have a separate area to play with the new circuit without affecting the existing portions of your design.


In Altium Designer, you can always create a new schematic that is not part of your current project by selecting the File → New option from the top menu and select Schematic. This will create a blank schematic sheet in the Free Documents section of the Projects panel.

Once you have a schematic open, you can start adding your components and sources from the Simulation Generic Components library.


Using Generic Components

Generic components are placed in the design just like any other component. They are meant to be a placeholder for a real component you would buy from a distributor. If you simulate your design and you find that it has the electrical behavior you want, you would then go and look for components that match the specifications of your generic components.


When using generic passive components, you have freedom to adjust the value of the component (resistance, capacitance, or inductance) as you work on the design. This is an important part of experimentation: you can adjust the values of generic passives to try and produce the electrical behavior you want in your system. In Altium Designer and other ECAD applications, there is a tool that will let you do these adjustments automatically.


To see how to use generic components, look through the Generic Simulation Components library in the components panel and add the Resistor part and a VSRC into your schematic and complete the circuit with wires. When this part is in the schematic, you’ll see a default value of 1K below the schematic symbol. This means the resistor you just added is a 1000 Ohm resistor. If you double click on the “1K” text below the symbol, a dialog will appear where you can change the value of this resistor.

This is the power of generic components: you can enter any number you want in the Value field in the above dialog, and you can change it later when you’re running simulations. ECAD applications use a specific format for suffixes for component values, something you’ll learn as you play with generic components in the schematic editor. The table below shows the standard suffixes used in ECAD software to denote different units on a generic component.

For example, an entry of 10M would mean 10 million Ohms, while an entry of 10m would mean 0.01 Ohms.


In the image below, a simple circuit has been built up using some passives. Just like with the resistor, the inductor or capacitor you add to the circuit will have some default value, but you can change this value to anything you want. When creating these circuits, make sure you apply reference designators to each component and change the component values. See if you can build the circuit shown below only using components from the Generic Simulation Components library.

Defining Sources

In the above circuit, we have a simple 5 V DC source connected to some components. What if we needed a different type of voltage source, like an AC source? SPICE simulations support multiple types of sources, including sources like square waves or triangle waves that you might use in an electronics lab. Most simulations you run will use the VSRC component, so it’s important to see how this specific component can be configured and used in SPICE simulations.


To change the electrical functionality of the VSRC component, double click on the schematic symbol for VSRC. This will bring up a dialog where you can change the settings on the VSRC component. In particular, there is a dropdown menu named “Stimulus Type” where you can select from a range of possible voltage sources. The two main sources you’ll typically use in SPICE simulations are “DC Source” and “Sinusoidal.”

When you select one of these entries, you’ll see a preview of what the source waveform looks like on a graph in the lower half of the window. As you modify the parameters in the right side of the window, you’ll see the waveform change to reflect your selection. SPICE simulators from other ECAD applications have a similar tool you can use to define a source in your simulations. You can even define multiple sources in your design to perform more complex simulations, just make sure you give every component and source in your simulations a unique reference designator. For now, create circuit shown above and leave the source configured as a DC Source.


Wrapping Up

If you’ve been following along, you now have a circuit with a DC Source and some components that we’ll use to run a simulation. Now, open DemoProject from Lesson 3; we want to add the new sheet into this project. Once DemoProject is open, you can drag the new sheet into the new project (see below).

Save the new sheet in the DemoProject folder on your local computer (File → Save). Make sure to set unique reference designators on all the components in your new sheet before you save. Finally, save the project to your Altium 365 Workspace so you can access it later.


Simulation Models for Real Components

While generic components are the standard components for building simulations, they aren’t the only components you can use. When some manufacturers create components, they will also create a simulation model file (.subckt extension) that can be attached to the component in your ECAD software. This simulation model is what allows a real component to be used in a SPICE simulation.


If you download a SPICE simulation model file from a component manufacturer, or you write one of your own, you’ll see that it’s just a long text file. This file describes how electrical values at the component inputs are transformed into electrical values at the component outputs. The example below shows a code snippet for a SPICE simulation model.

Right now, you don’t need to know how to write SPICE models, there are specific classes you can take that will focus on this. It is important to note that the components in the Generic Simulation Components library have one of these files attached to them. When you create a component for one of your libraries, you’ll have a chance to attach a simulation model file to the component if you want to include the component in a SPICE simulation. You’ll be able to see this in the New Component dialog (refer to Lesson 6 in this unit).

Once you’ve built the circuit you want to simulate, you need to decide which type of simulation to perform. The type of simulation you need depends on what electrical behavior you want to examine and how you define sources in your design. We’ll look at this more in the next lesson where we start to show how to choose the right simulation for your design.


How Does SPICE Work?

With all this focus on SPICE, it’s worth asking the question: how do SPICE simulations work? The method in SPICE that is used to solve Kirchhoff’s laws and Ohm’s law for your circuit is called nodal analysis, which is used with another technique to solve a matrix equation. Unless you’re doing research on circuit solvers, you don’t need to know how to implement these calculations by hand.


Upon first glance, SPICE simulations are like a black box, but there is a specific numerical algorithm that is used to solve Kirchhoff’s laws and Ohm’s law for your circuits. In fact, the SPICE solution algorithm is based on matrix mathematics and could, in principle, be solved by hand with only pen and paper. However, in a circuit with hundreds of components, the SPICE solution algorithm becomes intractable to solve by hand, and it becomes easier to program a computer to solve these problems. This is a common theme in PCB design and electronics simulations in general, and it’s especially true when we look at using more advanced simulations.



SPICE Simulations in ECAD Software


All SPICE simulations operate under the same principle: calculate the voltage and current distribution throughout a circuit. SPICE simulations use Kirchhoff’s laws and Ohm’s law to relate the current and voltage generated in a simulation, and this information is mapped across the nets in your schematics.


In the previous section, we talked briefly about voltage sources (VSRC component) in SPICE simulations. Every SPICE simulation will need some kind of source defined in the schematics. Once the source is defined and the simulation is run, your simulation package will determine all nodes and nets in a SPICE simulation. Consider the simple circuit shown below from the previous unit. Here, we originally defined a 5 V DC source, and we’d like to know the voltage drop across each element in the circuit. SPICE simulations do this by defining nodes and nets in the circuit.

Nodes and nets extracted from a schematic.



The nodes are shown in black dots, and the nets are shown in colored bars. One important point to note: all components have nodes defined on each side of the component. In other words, the ends of the resistor symbol (for example) are defined as nodes. This is important because it gives a place to take measurements with probes (see below).


Normally if you want to display some calculated results for this circuit, you will select the current in a specific component and net, and the results will be displayed on the schematic or some kind of graph. When you view results from your simulation, you’ll be looking at the voltage and current along specific nets in your schematic. Voltages are all defined with respect to a reference node, or a specific node that is defined as 0 V (also known as ground). In the above schematic, the GND symbol below VSRC designates the reference node for this simulation.


To take specific measurements on components, or to take a measurement across multiple components, we use objects called probes in a SPICE simulation. 




Sources and Probes in a SPICE simulation

A probe acts like its name suggests: it provides a specific measurement at a node (current) or the voltage drop between two nodes (voltage). All SPICE simulation packages use probes to define specific measurements. In Altium Designer, you can access different types of probes in an open schematic from the Simulate menu (see below).

You’re not required to place probes in a schematic to view results, but the probes are useful as they can be used to gather very specific measurements in your circuits. If you don’t use probes, you’re only limited to looking at measurements on specific nets with respect to ground, rather than across specific components or groups of components. To see how this works, we’ll look at an example below.


Probes are placed on specific nodes (or ends) of a component in a schematic. Take a look at the schematic below. All the different types of probes in the Simulate menu have been placed in this schematic.

  • P (Power): This probe measures the complex power dissipated by a portion of the circuit. In the above schematic, the placement of P will measure power dissipated across resistor R1.
  • V (Voltage): This probe measures the voltage between a specific node and ground. In the above placement, this probe measures the voltage supplied to V as measured with respect to ground.
  • VD+ and VD- (Voltage Diff): These probes measure the voltage across two points. Note that VD- does not need to be connected to GND. In the above placement, the VD+ and VD- probes are measuring the total voltage drop across L1 and D1. If, for example, we only wanted to measure the voltage drop only across L1, we would put the VD- probe on the other side of L1.
  • I (Current): This will measure the current coming into a specific node in the design. In the above placement, the I probe is measuring the current flowing to capacitor C1.


The probes V and VD+/VD- are intended to mimic the way you would use a multimeter to measure voltage. The V probe is equivalent to having the negative probe of the multimeter connected to GND. When using VD+/VD-, the VD- probe in the schematic acts just like the negative probe on your multimeter. VD+/VD- probes and the I probe are the most versatile for measuring current and voltage in specific points in a circuit.


Once you’ve defined the measurements you need and placed probes, you can start to think about which types of simulations you need to perform.


Types of SPICE Simulations

In general, there are four types of SPICE simulations you’ll find in any ECAD application:


Operating point: This is the simplest type of SPICE simulation. In this simulation, the steady-state values you want to measure are calculated for a single voltage (DC). The results are displayed on the schematic and will show you how the DC operation values in the circuit with fixed values. As an example in the image below, we can see how the voltage drop is distributed around the R1-L1-D1 net. The voltage measured at L1 with VD+ is 692.9 mV, so we know that 4.3071 V is dropped across the 1 kOhm resistor (R1). By placing probes around the circuit, you can generate other electrical values with this simulation.

DC sweep: As its name suggests, this type of simulation involves taking multiple measurements (such as with probes) while the voltage from a DC source is ramped between two values. In other words, the voltage from your source starts at a low value (say, 0 V) and is changed up to some maximum value in small steps. The output measurements are plotted with the source voltage on the x-axis. The graph below shows the DC sweep results for the above circuit.

Transient analysis: This type of SPICE simulation can be used with AC or DC. In the case of DC, you’re simulating a step input, just like you would in an RLC circuit or similar reactive circuit. The results are shown on a graph with time on the x-axis. This is normally used to look at the transient response of a circuit, meaning how the quantities you want to measure will change when the circuit transitions between two states (such as OFF and ON for digital states). In the image below, we can see how the current drawn into capacitor C1 in the above circuit changes over time.

Frequency sweep: A frequency sweep is used with an AC source to examine how the circuit responds to different AC frequencies. Think about how impedance can vary with frequency; an AC sweep will let you see how the resulting voltage and current also vary with frequency when a circuit has some inductors or capacitors. The results are shown on a graph with frequency on the x-axis. In the image below, we can see the power dissipated in R1 and the voltage drop across D1 at various frequencies. From looking at this graph, we can see that the above circuit acts like a low-pass filter up to very high frequencies (about 10 MHz).

Some ECAD applications have access to more specialized SPICE simulations, but they are based on one of the above fundamental SPICE simulations shown above. To see a tutorial on how to use SPICE simulations, you can follow along with the video below. This video shows how to run a SPICE simulation for a filter circuit, but you can follow the same steps in Altium Designer with your own circuits.