# LTspice

Written by

One of the key design tools we use in electronic design is circuit simulation. For analog electronics LTspice is the industry standard go-to tool for a number of reasons, not least of which is the price, which is zero. It is provided by Analog Devices (previously Linear Technology after which it is named) and it ships with a huge range of device models for Analog Devices, Linear Technology and Maxim devices. You can easily add models for devices from any manufactured (most provide them).

The “spice” part of the name comes from the original Fortran “Simulator Program with Integrated Circuit Emphasis” released in 1973. LTspice was first released in 1999 and has been regularly updated ever since. It is a very stable and well-proven platform. On the downside, its fair to say the user interface is clunky, and its roots as a text-based application are still evident in many ways.

Its quite a powerful program and the learning curve can be a bit steep, but there is a huge amount of helpful information available to help, including plenty of how-to videos and tutorials. I don’t intend to cover this ground here, but I do want to give a couple of examples of real-life use of LTspice taken from my own experience. You can simulate entire circuits of course, but I find its often more helpful just to simulate certain subsections – especially where a new circuit is concerned, or where its difficult to calculate things mathematically.

The first example is a simple comparison of a standard two-transistor current mirror with a Wilson current mirror with changing compliance voltage. This is relatively easy to calculate but modelling it serves to reinforce the theory and demonstrate that the BJT model is pretty comprehensive.

Both circuits are simulated in Figure 1. Each is configured to have a reference current of about 1mA through R1 and R3 respectively. We expect to see the same current mirrored in the collectors of Q1 and Q5. In both cases the compliance voltage is ramped from 2V to 40V over 10 seconds. The 1Ω resistors R2 and R4 provide a convenient place to measure the mirrored currents.

Figure 2 shows the result. The top panel shows that the reference currents are fixed at about 1 mA as we would expect. The lower panel shows the current in the Wilson mirror remains constant with voltage (blue trace), but the current through the simple mirror increases by about 25% over the voltage range.  This is due to the Early effect occurring in Q1. We don’t see this effect in the Wilson mirror because the cascode connected transistor Q5 clamps the VCE of the mirror transistor Q3 to a fixed value.

The second example is a bit more complex. It involves the estimation of the ripple current in the filter capacitors of a 3kW power converter. The 240V single-phase mains is rectified and filtered to produce a DC supply to the converter. This architecture results in significant ripple current in the filter capacitors that must be within the capacitors’ ratings.

Figure 3 shows the circuit being simulated. The load current of the converter is complex, and rather than try to simulate it in LTspice, I have used an independent current source with its value defined by a piecewise linear approximation in an external CSV file. The values in this file were created using a Python script and are just a long list of timesteps and associated current values.

The results are shown in Figure 4. The green trace shows the current through one of the filter capacitors. You can ignore the spike on the left – this is an inrush current which can be ignored for the purposes of this analysis (but not in real life!). The red trace is the load current which is described in the CSV file.

You will also note a few lines beginning “.MEAS …” which allow the calculation of values like the RMS, average or peak-to-peak value of certain parameters within a particular window. The resuls are printed in the log file, a portion of which is shown in Figure 5. Here you can see the capacitor current is about 5.7A rms, the input current is 12.5A and the DC bus has an average voltage of 314V with 64V of peak-to-peak ripple. From memory, this finding resulted in me using a larger number of lower value capacitors in parallel to get the individal capacitor currents down to a reasonable level. Given the complex load current, calculating these values mathematically would be extremely difficult.

Of cousre, you can do a huge amount more than this with LTspice, including frequency response, Monte Carlo analysis , noise analysis and even modelling of temperature effects.  Its pretty easy to add new models provided by device manufatureres or model your own re-usable sub-circuits. If you are not already using this tool, I highly recommend that you take a look at it.

References

“LTspice.” In Wikipedia, March 21, 2023. https://en.wikipedia.org/w/index.php?title=LTspice&oldid=1145908583.

“LTspice Information Center | Analog Devices.” Accessed April 11, 2023. https://www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.html.

 Keep up-to-date with our FREE Weekly Newsletter! Don't miss out on upcoming issues of Circuit Cellar. Subscribe to Circuit Cellar Magazine Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine. Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.