29,99 €
LTspice, developed by Analog Devices, is a powerful, fast, and free SPICE simulator, schematic capture, and waveform viewer with a large database of components supported by SPICE models from all over the world. Drawing a schematic in LTspice is easy and fast. Thanks to its powerful graphing features, you can visualize the voltages and currents in a circuit, and also the power consumption of its components and much more. This book is about learning to design and simulate electronic circuits using LTspice. Among others, the following topics are treated: > DC and AC circuits > Signal diodes and Zener diodes > Transistor circuits including oscillators > Thyristor/SCR, diac, and triac circuits > Operational amplifier circuits including oscillators > The 555 timer IC > Filters > Voltage regulators > Optocouplers > Waveform generation > Digital logic simulation including the 74HC family > SPICE modeling LTspice is a powerful electronic circuit simulation tool with many features and possibilities. Covering them all in detail is not possible in a book of this size. Therefore, this book presents the most common topics like DC and AC circuit analysis, parameter sweeping, transfer functions, oscillators, graphing, etc. Although this book is an introduction to LTspice, it covers most topics of interest to people engaged in electronic circuit simulation. The book is aimed at electronic/electrical engineers, students, teachers, and hobbyists. Many tested simulation examples are given in the book. Readers do not need to have any computer programming skills, but it will help if they are familiar with basic electronic circuit design and operation principles. Readers who want to dive deeper can find many detailed tutorials, articles, videos, design files, and SPICE circuit models on the Internet. All the simulation examples used in the book are available as files at the webpage of this book. Readers can use these example circuits for learning or modify them for their own applications.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 196
Veröffentlichungsjahr: 2024
LTspice Essentials
An Introduction to Circuit Simulation
●
Dogan Ibrahim
●This is an Elektor Publication. Elektor is the media brand of Elektor International Media B.V.PO Box 11, NL-6114-ZG Susteren, The NetherlandsPhone: +31 46 4389444
●All rights reserved. No part of this book may be reproduced in any material form, including photocopying, or storing in any medium by electronic means and whether or not transiently or incidentally to some other use of this publication, without the written permission of the copyright holder except in accordance with the provisions of the Copyright Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licencing Agency Ltd., 90 Tottenham Court Road, London, England W1P 9HE. Applications for the copyright holder's permission to reproduce any part of the publication should be addressed to the publishers.
●Declaration
The author and publisher have used their best efforts in ensuring the correctness of the information contained in this book. They do not assume, or hereby disclaim, any liability to any party for any loss or damage caused by errors or omissions in this book, whether such errors or omissions result from negligence, accident or any other cause.
●ISBN 978-3-89576-622-0 PrintISBN 978-3-89576-623-7 eBook
●© Copyright 2024 Elektor International Mediawww.elektor.comPrepress Production: D-Vision, Julian van den BergPrinters: Ipskamp, Enschede, The Netherlands
Elektor is the world's leading source of essential technical information and electronics products for pro engineers, electronics designers, and the companies seeking to engage them. Each day, our international team develops and delivers high-quality content - via a variety of media channels (including magazines, video, digital media, and social media) in several languages - relating to electronics design and DIY electronics. www.elektormagazine.com
Contents
Preface
Chapter 1 • Introduction
1.1 Why simulate?
1.2 Electronic Simulation
1.3 The LTspice Simulator
1.3.1 Schematic capture
1.3.2 DC analysis
1.3.3 AC analysis
1.3.4 Transient analysis
1.3.5 Plotting the results
1.3.6 Transient noise analysis
1.3.7 Fourier analysis (FFT)
1.3.8 Digital simulation
1.3.9 Laplace transform based analysis
1.3.10 Expression editor
1.3.11 Parameter sweeping
1.3.12 AC sweep
1.3.13 DC sweep
1.3.14 SPICE models
1.3.15 Netlist
1.3.16 Online help
Chapter 2 • Getting Started with LTspice
2.1 Overview
2.2 Installing LTspice on Windows
2.3 Running LTspice
2.4 Creating a New Schematic
2.5 Simulator Settings
2.6 Example Schematics
2.7 Online Help
Chapter 3 • Basic DC Circuit Analysis and Simulation
3.1 Overview
3.2 Simple 4-Resistor Circuit
3.3 A More Complex Resistor Circuit
3.4 Resistive Potential Divider – Sweep a DC Voltage
3.5 Resistive Potential Divider – Sweep a Resistor Value
3.6 Power Dissipation in a DC Circuit
3.7 Resistor-Capacitor (RC) Transient Circuit
3.8 Resistor-Inductor-Capacitor (RLC) Transient Circuit
3.9 Input Resistance, Output Resistance, and Transfer Function
Chapter 4 • Basic AC Circuit Analysis and Simulation
4.1 Overview
4.2 Resistor – Capacitor Circuit
4.3 Resistor – Inductor Circuit
4.4 Resistor – Inductor – Capacitor Circuit
4.5 Thevenin’s Theorem – AC Circuit Analysis
4.6 Three-Phase Circuits
4.6.1 Star with resistive loads
4.6.2 Star with resistive and inductive loads
4.7 Mutual Inductance
4.7.1 Circuit with mutual inductance
4.8 Using a Transformer
4.9 Frequency Sweeping
4.10 Fast Fourier Transform (FFT)
4.11 Input & Output Impedance, and Gain
Chapter 5 • Diode Circuits
5.1 Overview
5.2 Half-Wave Rectifier
5.3 Full-Wave Rectifier
5.4 Full-Wave Rectifier with a Transformer
5.5 Zener Diode Voltage Regulator
5.6 Diode Clamp
5.7 Voltage Multiplier
5.8 I-V Characteristic of a Diode
Chapter 6 • Transistor Analysis, Design and Simulation
6.1 Overview
6.2 Bipolar Junction Transistor (BJT) I-V Curve
6.3 Common-Emitter Transistor Amplifier – Analysis
6.4 Common-Emitter Transistor Amplifier – Design
6.5 Audio Power Amplifiers
6.5.1 Class A audio power amplifier simulation
6.5.2 Class AB audio power amplifier
6.6 BJT Switch
6.7 JFET Common-Source Amplifier
6.8 MOSFET I-V Characteristic Curve
Chapter 7 • Thyristors, Diacs and Triacs – Importing a SPICE model
7.1 Overview
7.2 Thyristors, diacs, and triacs
7.2.1 Triac – diac phase control
7.3 Inserting a Potentiometer – Using a Potentiometer Model
Chapter 8 • Oscillators
8.1 Overview
8.2 Transistor Sinewave Oscillators
8.2.1 Colpitts oscillator
8.2.2 Hartley oscillator
8.3 Sine Wave Oscillators with Operational Amplifiers
8.3.1 Phase-shift oscillator
8.3.2 Wien bridge oscillator
8.3.3 Colpitts oscillator
8.5.4 Hartley oscillator
8.4 Op-Amp-Based Square Wave Oscillator
8.5 The 555 Timer
8.5.1 The 555 astable multivibrator
8.5.2 Blinking an LED
8.5.3 Metronome
8.5.4 Parametric sweep
Chapter 9 • Simulating Other Analog Circuits
9.1 Overview
9.2 The LT1086 Voltage Regulator
9.3 10 V Output
9.4 DC Boost Converter
9.5 Optocoupler Simulation
9.6 Operational Amplifier with Single Supply
9.7 Sweeping a Resistor Value
Chapter 10 • Filters – Hierarchical Blocks
10.1 Overview
10.2 Low-Pass Filter
10.3 Filter Design Tool
10.3.1 Low-pass active filters
10.4 Hierarchical Blocks – 2nd-Order Low-Pass Filter Block
10.4.1 Using the filter block
10.5 Passing Parameters to Hierarchical Blocks
10.5.1 Using the programmable block
10.6 Create Your Own Symbol
10.7 LTspice Filter Library
Chapter 11 • Digital Logic
11.1 Overview
11.2 Digital Components
11.3 Half Adder Using Logic Gates
11.4 Full Adder from Two Half Adders
11.5 Importing the 74HC Family
11.6 Two-Input Multiplexer
11.7 4-Bit Binary Counter
11.8 More Inputs
11.9 Full Adder
11.10 Monostable Multivibrator
11.11 Square Wave Oscillator
Chapter 12 • SPICE models
12.1 Overview
12.2 The Structure of SPICE Models
12.3 Passive Components
12.4 Active Components
12.4.1 Diodes
12.4.2 Bipolar transistors
12.4.3 MOSFETs
12.4.4 Creating a new diode model
12.5 Logic Gates
12.6 SPICE Directives
Chapter 13 • Some Useful Tools and Functions
13.1 Overview
13.2 Generating Triangular and Sawtooth Waveforms
13.3 Generating a Periodic Arbitrary Waveform
13.4 The Voltage-Controlled Switch
13.5 Laplace-Transform Based Simulation
Appendix A – Third-Party SPICE Models
Appendix B – Useful Resources
Preface
Electronic circuit simulation is essential in all branches of electrical and electronic engineering. Students put into practice the complex theory they have learned in their courses, and this gives them the chance to apply the theory to real-world experiments. Practicing engineers simulate and optimize electronic circuits before constructing them for final testing.
Circuit theory is a core subject that is the fundamental part of all electrical and electronic engineering courses. In conventional engineering laboratory experiments, electronic components and instruments must be purchased and then assembled to build circuits for experimentation and validation. Usually, it may be costly and sometimes difficult to obtain the real components required for an experiment, especially during the development cycle. Simulating a circuit is much cheaper and faster. Components and instruments cannot be broken and an unlimited amount of them is available.
LTspice, developed by Analog Devices, is a powerful, fast, and free SPICE simulator, schematic capture, and waveform viewer with a large database of components supported by SPICE models from all over the world. Drawing a schematic in LTspice is easy and fast. Thanks to its powerful graphing features, you can visualize the voltages and currents in a circuit, and also the power consumption of its components and much more.
LTspice is a powerful electronic circuit simulation tool with many features and possibilities. Covering them all in detail is not possible in a book of this size. Therefore, this book presents the most common topics like DC and AC circuit analysis, parameter sweeping, transfer functions, oscillators, graphing, etc. Although this book is an introduction to LTspice, it covers most topics of interest to people engaged in electronic circuit simulation.
The book is aimed at electronic/electrical engineers, students, teachers, and hobbyists. Many tested simulation examples are given in the book. Readers do not need to have any computer programming skills, but it will help if they are familiar with basic electronic circuit design and operation principles. Readers who want to dive deeper can find many detailed tutorials, articles, videos, design files, and SPICE circuit models on the Internet.
All the simulation examples used in the book are available as files at the webpage of this book. Readers can use these example circuits for learning or modify them for their own applications.
I hope you enjoy reading the book and use LTspice in your next electrical/electronic simulation project.
Prof Dogan Ibrahim
April 2024
London
Chapter 1 • Introduction
1.1 Why simulate?
One of the major differences of engineering courses from many other courses is that engineering courses highly depend on practical work, such as laboratory work. Laboratories are essential parts of every engineering course, and it is a major requirement for all students in such courses to complete all laboratory work successfully before they are allowed to graduate.
Students learn the mathematics and theories of electronics in classes, and they are then expected to apply this knowledge by carrying out relevant experiments in the lab. This is true for all engineering courses, whether it is chemical engineering, mechanical engineering, electrical/electronic engineering, etc. For example, electronic engineering students learn the circuit theory in great detail in the class. They are then expected to carry out experiments in laboratories using real components, real measuring tools, and real power supplies and put the learned theories into practice.
Although real laboratory experiments are very useful, they have some problems associated with them:
The purchase of real electronic components and instruments can be very costly. Many pieces of the same instruments are usually required for a class of students, and this can be very costly.The characteristics of electronic components and electronic equipment can change with aging and temperature and as a result, unexpected or wrong results can be obtained.It is not always easy to find the required components, and students may have to wait for long times before they can develop and test their projects. For example, an experiment may require a certain model of transistor and this transistor may not be available in the laboratory stock.Real components and real equipment can easily be damaged by improper use, for example by applying large voltages, or by passing large currents through them, or by short-circuiting them. It may be costly to replace or repair them in time.Students can get accidents (e.g. electric shock) in laboratories by not following the safety regulations. Thus, an instructor must always be present in a laboratory to make sure that students connect the components correctly and use the mains-powered instruments by following the established safety rules.Laboratory instruments usually need to be recalibrated from time to time and this can be costly and also inconvenient.Students following distant education courses may not be able to attend laboratories.Computer simulation is an alternative to carrying out experiments using real hardware. A simulator is basically a computer program that predicts the behavior of a real electronic circuit. Software models (e.g. SPICE models) of real components and virtual instruments are used in a simulation. Typically, in a simulation, students run the simulator program and pick the required components and virtual instruments from a software library. For example, the value of a resistor can be changed by the click of a button. Students then connect the components and the instruments by using the provided software tools to build the circuit. The simulation process is then activated and the AC- and DC response, transient response, noise response, Fourier transform, and many other responses of the circuit can easily be tabulated, plotted, or recorded.
Although simulation is an alternative and an invaluable tool in designing and developing electronic circuits. Some of its advantages are:
Any component, whatever its cost, can be modeled and simulated. Virtual instruments are computer programs and thus there are no cost issues.Virtual instruments and components used in a simulation cannot be damaged by connecting wrongly or by applying large voltages or passing large currents through them.Simulator instruments do not need calibration, since they’re simply computer programs. They are available at all times and always operate with the same specifications.Simulation allows measurements of internal currents and voltages in a circuit that can be complicated or even impossible to do when using real components. For example, the voltage across part of a circuit could be very large and provide a health hazard.Simulation can easily be used in distant education courses. Students can be supplied with copies of the simulator program, or they can be given access codes to use a simulator program over the web. LTspice is a freely available circuit simulator program, and it can be used by all students. Experiments can then be carried at e.g. home and at any moment.However, simulation also has some inconveniences:
A simulation is only as good as its model. Simulation does not usually consider the component tolerances, aging, or temperature effects. Users may think that all components are ideal at all times.Simulation results may not be accurate at very high frequencies. For example, concepts like the skin effect are not normally considered in a high-frequency simulation.A simulator may have bugs or particularities that may result in incorrect results when not dealt with properly.Simulation programs constantly evolve as new components and features are introduced and bugs are corrected. This requires updating the software from time to time.1.2 Electronic Simulation
The history of electronic simulation dates back to the 1970s. Before the availability of personal computers, electronic simulation was carried out in analog form using operational amplifiers and passive components. This type of simulation was very limited, was not accurate, and was mainly used in analyzing automatic control systems.
One of the earliest simulation programs was SPICE (Simulation Program with Integrated Circuit Emphasis), designed to simulate analog electronic circuits. Developed at the U. C. Berkeley in the late 1960s, version 2 of SPICE was released to the public domain. Version 3 was released in March 1985. This version was written in FORTRAN, which was the most commonly used programming language at the time.
Most professional electronic simulation programs nowadays are based on SPICE. There are many sources of information on SPICE modeling on the Internet, such as books, tutorials, videos, examples, and interested readers should refer to them. Also, Chapter 13 of this book is devoted to SPICE modeling.
1.3 The LTspice Simulator
There are many professional circuit simulators in the market, and some can be quite expensive. Some educational establishments or private individuals offer simulators free of charge that can be downloaded from the Internet. Some currently available popular circuit simulators are: LTspice, TINA, Altium, Proteus, PSPICE, SiMetrix, CircuitLab, Multisim, PLECS, CircuitLogix, and many others.
LTspice is a simulator developed by and made available for free by Linear Technology, now Analog Devices. Some features of LTspice are summarized in the next sections.
1.3.1 Schematic capture
Circuit diagrams are entered using an easy to use schematic editor. Component symbols chosen from the Component bar are positioned, moved, rotated and/or mirrored on the screen easily by the mouse and keyboard. LTspice’s component catalog includes many electronic components. Thousands of additional components can be added from many sources on the Internet. You can open any number of circuit files or subcircuits, cut, copy and paste circuit segments from one circuit into another, and, of course, analyze any of the currently open circuits. LTspice makes it straightforward to create blocks of electronic circuits (called subcircuits or hierarchical blocks) that can be included in other circuits so that large circuits can be constructed from simple blocks. For example, you can create a block of a second order low-pass filter and then make higher order low-pass filters by simply cascading such blocks.
1.3.2 DC analysis
The DC analysis calculates the DC operating point and the transfer characteristic of analog or digital circuits. The user can inspect the calculated (“measured”) DC nodal voltages and loop currents at any node or mesh by tabulating a list of all currents and voltages in the circuit.
1.3.3 AC analysis
The AC analysis allows calculating and plotting complex voltage, current, and power transfer functions. Bode diagrams with a logarithmic frequency axis and a decibel vertical axis are easily drawn.
1.3.4 Transient analysis
The transient analysis lets you calculate and then plot the circuit response against time. Users have the option of simulating using sine wave input, pulse input, piece-wise-linear input or any other type of user-defined input from a file.
1.3.5 Plotting the results
The waveform plotting options of LTspice are powerful. They allow the time or frequency responses to be plotted of any point in a circuit by simply clicking on the desired point. In addition to current and voltage plot, the power consumption can also be plotted easily by simply clicking on a component whose power dissipation is to be plotted. You can display the frequency of a waveform, its peak value and display the voltage or time at any point of a voltage, current, or power curve. You can zoom in or out any part of a waveform, change the color of waveforms plotted, insert text, plot multiple waveforms on the same graph, plot waveforms on top of each other in different graphs, etc.
1.3.6 Transient noise analysis
With LTspice you can analyze the noise at the input or output of a circuit and plot it.
1.3.7 Fourier analysis (FFT)
In addition to the calculation and display of the responses, the Fast Fourier Transform (FFT) of an output can easily be plotted.
1.3.8 Digital simulation
LTspice includes tools to simulate digital circuits. Although the supplied number of digital components is rather limited, thousands of digital components can easily be imported and used.
1.3.9 Laplace transform based analysis
LTspice enables a circuit transfer function represented in Laplace transform to be used in a simulation.
1.3.10 Expression editor
The Expression Editor is a powerful tool enabling mathematical operations to be performed on any waveform. For example, with the help of the Expression Editor, two waveforms can be multiplied and the result plotted.
1.3.11 Parameter sweeping
In addition to voltage sweeping, LTspice allows users to change the values of components and carry out parameter sweeping analysis by plotting the results.
1.3.12 AC sweep
LTspice allows AC sweeping to be carried out for linear, octave, and decade sweeps.
1.3.13 DC sweep
DC sweep allows you to do various sweeps of your circuit to see how it responds to various conditions. The sweep is available for voltage, current, and temperature.
1.3.14 SPICE models
There are thousands of freely available compatible SPICE component models that can be used with LTspice. Additionally, you can create and use your own models.
1.3.15 Netlist
You can export SPICE the netlist of your schematic so that they can be used for example with a PCB design program.
1.3.16 Online help
Detailed online help is available by pressing the F2 button. Additionally, there are many tutorials, books, YouTube videos, example simulations, and articles on the Internet free of charge for interested readers.
Chapter 2 • Getting Started with LTspice
2.1 Overview
In this chapter, you will be learning how to install the latest version of LTspice on a computer running Windows (it can also be installed on macOS 10.14 and forward). Additionally, you will be learning how to use some of its menu options. At the end of this chapter, we will draw the schematic of an interesting multivibrator circuit and then simulate it using LTspice. In the remaining chapters of the book, detailed schematic drawing and simulation techniques will be discussed starting from the first principles.
2.2 Installing LTspice on Windows
At the time of writing this book, the latest version of LTspice was 24.0.9, known as Version 24. The installation steps are:
Go to the website:
https://www.analog.com/en/resources/design-tools-and-calculators/LTspice-simulator.html
Scroll down and click on the Download link to download the installation file (Figure 2.1). At the time of writing this book, the installation file was named (for 64-bit PCs): LTspice64.msiFigure 2.1 Click to download the installation file
Double-click on the file to install LTspice. After the installation, the icon shown in Figure 2.2 should appear on your desktop,Figure 2.2 LTspice icon
2.3 Running LTspice
Double-click on the icon to start LTspice. Figure 2.3 shows the start-up screen. At this stage, you will see that almost all the menu options are grayed out and are not available, except for File, View, Tools, and Help. We will cover these options in a later chapter. For now, click Help→About LTspice to display the version number (Figure 2.4)
Figure 2.3 LTspice startup screen
Figure 2.4 LTspice version number
2.4 Creating a New Schematic
Before creating a new schematic, it is important to know how to specify the values of resistors, capacitors, and inductors to be used in our circuit. Table 2.1 shows the available value prefixes. Note that they are not case-sensitive. For example, k and K are both interpreted as kilo.
Prefix
Name
Multiplier
T
tera
1012
G
giga
109
Meg
mega
106
k
kilo
103
m
milli
10-3
u
micro
10-6
n
nano
10-9
p
pico
10-12
f
femto
10-15
Table 2.1 LTspice units
To create a new schematic, click File→New Schematic, or press Ctrl+N, or click the icon with the ‘+’ sign at the left-hand side of the top menu. You will be presented with a screen as shown in Figure 2.5. At the top part of the screen, we have the menu items and below them are the buttons or icons (in the figure, the screen is cut into two for clearness). A function brief is shown for each button as a quick reference.
Figure 2.5 New schematic screen
The following key combinations can be used to access the menu buttons (in between parentheses are the LTspice XVII ‘classic’ keyboard shortcuts. They can be activated through the Tools→Settings menu, on the Schematic tab and then the Keyboard Shortcuts button):
New schematic
- Ctrl+N
Open
- Ctrl+O
Save
- Ctrl+S
- Ctrl+P
Configure analysis
- A (n/a)
Zoom
- Z (Ctrl+Z)
Zoom back
- Shift+Z (Ctrl+B)
Zoom to fit
- Space (n/a)
Wire
- W (F3)
Ground
- G
Resistor
- R
Capacitor
- C
Inductor
- I
Diode
- D
Component
- P (F2)
Label net
- N (F4)
Text
- T
Spice directive
- . (S)
Delete mode
- DEL (DEL or F5)
Duplicate mode
- Ctrl+C (F6)
Move mode
- M (F7)
Stretch mode
- S (F8)
Search
- Ctrl+F
Example schematic
Perhaps the easiest way to learn how to create a schematic is to go through an example circuit. The schematic we will be drawing is a multivibrator circuit (also known as an astable circuit), taken from the LTspice Educational Examples folder. The multivibrator is a simple square wave oscillator circuit with two transistors, four resistors, and two capacitors, and of course, a power supply (e.g. a battery). The actual operation of the circuit is not relevant at this stage, and the author assumes that most readers are familiar with multivibrator circuits. A step-by-step approach is given below that explains how to draw and then simulate the circuit shown in Figure 2.6.
Figure 2.6 Example multivibrator circuit
Start LTspice.Click File→New Schematic.We will make the wire color black, and the screen background color white, to improve visibility for this book. To change the wire color, click Tools→Color Preferences, Select Wires as the Selected item and set the red, green and blue to 0 so that the wire color is black. Also, select Background as the Selected item and set Red, Green and Blue to 255 so that the background color is white.You can also make the graph lines thicker by clicking Tools→Settings and then click to select tab Waveforms. Set the Data trace width to a higher value (e.g. 3).Click on the resistor symbol and place resistors R1, R2, R3 and R4 approximately at the same positions as in Figure 2.6 (See Figure 2.7). Press ESC on the keyboard or do a right-click to exit. You can zoom in or out by scrolling the mouse wheel. Move the drawing by pressing the left mouse button and keeping it pressed down. If you want to change the position of a component, click on button Move Mode (M), click on the component to be moved and move it to the desired position. (Use Stretch Mode to move a part while keeping it connected) Press ESC on the keyboard or do a right mouse click to exit Move Mode.Figure 2.7 Place the resistors
Now, we will place the two capacitors. Click on the capacitor symbol. In our drawing, the capacitor should be rotated by 90 degrees. This is done by pressing Ctrl+R before it is placed in its final position. Place capacitors C1 and C2 as in Figure