# LT Spice In The Dark.

## Before one can teach, one must learn.

I couldn't come as far as fast as I have without this textbook.

THE LTSPICE IV SIMULATOR by Gilles Brocard

So far I haven't run into any user interface differences between Version IV and XVII. I suspect most of the changes were internal. I'm going to leave the link to the book up, because some of you might have the NFB reader or something similar. At first glance LT Spice did not appear to be blind friendly. However, because spice started in the days of punched card input and line printer output it still retains a method of text based input and data output. These are explained in the book Listed above. I have now written enough to keep the sighted folk busy. Now I'll start on a set of lessons for blind users.

Lesson 1: Creating a net list and a Simple Simulation. This page.
Lesson 2: Introduction to and applications of frequency analysis.
Lesson 3: Introduction to and applications of transient analysis.
Lesson 4: Locating, modifying, and installing vacuum tube models.
Lesson 5: Operating point of vacuum tube circuits. Introduction to stepping and plate curves.
Lesson 6: Using stepping to do frequency response of a tone control.
Lesson 7: Transient analysis of unregulated power supplies.
Lesson 8: Transient analysis of power supply regulators.
Lesson 9: Transient and frequency analysis of amplifiers with feedback.
Lesson 10: Lossless transformers.

# Lesson 1 Creating a Net List and a Simple Simulation.

## What you will learn in Lesson one.

1. How to open LT Spice.
2. Define a net list and briefly describe its contents.
3. Line's First Characters in a Net List.
5. Keeping Track of your Nodes.
6. knowing that Ground is Node zero.
7. Netlist syntax.
8. Listing of example netlist.
9. Understanding the .ac directive.
10. How to enter component values so LT Spice will recognize them.
11. Typing in a netlist made for this lesson.
12. Note on something that LTspice puts in a new netlist.
13. How to run a simulation and see the results.
14. List the most often used voltage sources and describe their syntax.
15. List the most often used spice directives and describe their syntax.

## Opening LT Spice. Ready, Set, go!

So you have downloaded LT Spice, installed it, and started it up. All of the functions are in the menus. You can use them if you like but I am going to emphasize hotkeys. After you use them for a while they will become second nature and they are so much faster than the menus. Until now I have been writing netlist as two words. You just heard what it sounds like when written as a single word. JAWS and NVDA seem to render, or rend, it in the same way. Throughout LT Spice it is written as a single word and that is something you or I cannot change. Get used to it.

Note: LT Spice itself is usually written as LTspice. I guess we should get used to that one as well.

## Definition of a Netlist.

A netlist is a text description of an electronic circuit. It takes the place of a schematic diagram when only text interface between user and computer is available. You might say it is a verbal description boiled down to the absolute minimum. Each line in a netlist represents a single component or directive (instruction to tell LTspice what to do). The term "node" is used throughout the world of spice. It is nothing more than a connection point where two or more components connect together. It is a word commonly used by electrical engineers.

## The first character in each line.

1. The first character in each line is important. It can be a star, a period, or a letter of the alphabet.
2. A star means that the line is a comment and LTspice just ignores it.
3. A period, often called a dot, precedes a directive.
4. A letter of the alphabet refers to a specific electrical or electronic component.
5. All but three letters have been assigned to specific components. The three that are not used are N, P, and Y.
6. N must be reserved because it can be used to designate a node number. I still don't know why P and Y aren't used.
7. For now we will learn 4.
1. C is for capacitor.
2. L is for inductor.
3. R is for Resistor.
4. V is for voltage source (generator).

If a semicolon is placed somewhere in a line it means the rest of the line is a comment. LTspice processes everything up to the semicolon and ignores the rest. That gives us a chance to insert comments such as second filter section or connects to C1 and R2. This could help you keep your nodes straight. The letter n isn't required before a node number but using one is a good idea to improve readability of the netlist.

THERE IS AN EXCEPTION. Node zero is ground. If you attach the letter n to the number 0 you will get an error message, when the simulation is run, that says something to the effect that you didn't indicate a ground node. Apparently leaving off the n says to spice that this is a ground. If you leave off the n from other node numbers there is no error message. Go figure.

## Netlist syntax.

1. A line for a component begins with the alphabetic letter assigned to that component followed by a number with no space between. There must be a space after the component number.
2. next a number a space another number and another space. The two numbers are the node numbers that the component connects to. If the device has more than two terminals such as a tube or transistor, there are three or more numbers.
3. Next is the component value. For example, a resistor's value might be 470k. No space allowed between the number and the k. A transistor's 2N3906, for a tube 6L6.
4. So it's, part, node, node, value, semicolon, comment.
Comments are strongly encouraged even if they seem obvious. What seems obvious today may not seem so a year from now. Good comments will greatly increase the reusability of a netlist.

## Our example netlist.

* Single section, (first order) RC filter
*
V1 0 n1 AC1 ; 1 volt AC generator.
R1 n1 n2 1k ; horizontal resistor.
C1 n2 0 .15uf ; Vertical capacitor.
.ac dec 3 1 1Meg ; plot from 1 hz to 1 Mhz.
.end

## Understanding the .ac directive.

1. Dec is the type of plot, decade in this case. This is a logarithmic plot of frequency by decade.
2. 3 is the number of points per decade. Now a sighted user will usually put 100 in this position. However the frequency range covers 6 decades which means 600 points. The text readout reads each point. You don't want to sit through that many points read out to 15 significant digits. For circuits such as RC filters, tone controls, and amplifiers, 3 points per decade is plenty to give you the sense of the frequency response.
3. 1 is the beginning frequency, one Hz.
4. 1Meg is the end frequency, 1 megahertz. Spaces not allowed.
There are many other spice directives. This is one that audio designers will use a lot.

## The Proper Way to Enter Numeric Values.

LTspice and all incarnations of spice are not case sensitive. Standard notation in electronics calls for a lower case m to mean milli as in millihenrys and a capitol M to mean mega as in megahertz. Without case sensitivity some other means must be provided. The solution is the loan character m means milli, while the word meg means mega. What this means is that when typing spice directives or component values it makes no difference whether you type them in upper or lower case. However it does make a difference whether you type m or meg. In the list below the number sign, known to some as hash tag, will be used to indicate a numeric value. Both JAWS and NVDA speak this as number.

Voltage value in volts.z.
Micro volts #u
Milli volts #m
Volts #
Kilo volts #k

Current in amperes or amps.
Micro amps #u
Milli amps #m
Amps #

Frequency value in hertz.
Hertz, #.
Kilo hertz, #k.
Mega hertz, #Meg.

Time in seconds.
Pico seconds, #p.
Nano seconds, #n.
Milli seconds, #m.
Seconds, #.

Resistor Values in ohms.
Ohms, #.
Kilo ohms, #k.
Meg ohms, #Meg.

Inductor values in henrys.
Nano henrys, #n.
Micro henrys, #u.
Milli henrys, #m.
Henrys, #.

You can add a letter for the units such as V for volts, s for seconds, or f for farads, and apparently it won't do any harm. Although I have not formed the habit of doing so I probably should.

## Entering the netlist.

1. After you start LTspice press ctrl-N.
2. Press alt-V.to open the view menu.
3. Press down arrow to move down through the view menu.
4. When you get to spice netlist, press enter.
5. Be sure num lock is off.
6. Press the right mouse button which is the key above the number 9 key to bring up the context menu for this window.
7. This is a short menu. Move to the second item which is Edit as Independent netlist.
8. Press enter. Weight for a few seconds while a save file box opens.
9. The directory will be set to LTspice and the typing cursor will be in the filename box.
10. Type lesson 1 and tab to the save button.
11. The Netlist file is now open. The first line begins with a star and contains the path to the LTspice directory on your machine.
12. The file name is after the back slash following the LTspice folder name and it is wrong.
13. Due to a programming oversite it is not the name you typed in but is the word draft followed by a number and then the extension dot asc. My advice is to change this to lesson 1. Leave the extension as is.
14. Type in the netlist that was given above.
15, After you finish typing you will find two lines at the end that were inserted by LTspice. They are,
.backanno
.end
You already typed the word end. When LTspice finds that word it stops processing the file so the extra lines won't do a thing. A search in LTspice help, came up with an explanation that indicates that the backanno directive causes LTspice to refer a netlist back to the schematic that caused its creation. However when you create a netlist from scratch a schematic diagram is not created. The process doesn't work in that direction. The directive is pointless for a stand alone netlist. Feel free to delete it.
16. Press ctrl-S to save what you just typed.
It will be saved under the file name you typed in step 10.

## Running the simulation and viewing the results.

1. Type ctl-R to run the simulation.
2. When the simulation is finished a new window will open causing JAWS or NVDA to announce the file name.
3. To access the correct menu the focus must be on the correct window. After the simulation runs it should be correct. Press alt-F and a menu will open. Down arrow through it until you hear print monochrome. The next down arrow should land you on Export data as text. If instead you hear a file name press esc twice. Then press control tab. You will hear the file name announced. Press alt-F again and down arrow through the menu. This time you should find export data as text file just below print monochrome. Press enter on it.
4. You will hear select trace to export.
5. Press tab until you hear extended select list box.
6. There are only 5 items in the list. Use down and up arrows to step through them. The one you want this time is the second one V(n2), voltage at node 2. Set to that one and press enter.
7. If this is your second or higher time to run through these steps you will get a message to the effect that the file already exists and do you want to over right it? Answer yes.
8. Press windows key and M. This will expose the desktop. May be optional on your computer. Now you need to open a text processing program. Note pad is the best for this purpose but whatever you are familiar with will do and I assume you know how to use it.
9. Open the program and press ctrl-o. First find the folder LTspiceXVII. In this folder find the file with the file name you gave to the netlist but with the extension .txt. Open this file.
10. Read the data. There are three columns in the file. Frequency in Hz, Magnitude in dB, and Phase angle in degrees. For the first point at 1.0000 etc. Hz the magnitude is a negative number very close to zero. That is what it should be. The dB of output divided by input at 1 hz could be called zero but if the accuracy is high enough it shows as a slightly negative number. At 1 MHz the magnitude could be called minus 60 dB but it's just a little off from that.

Congratulations. You have just entered a circuit and "viewed" the analysis results without ever touching a mouse or seeing the screen. While this procedure is long it is the only way a blind person can use LTspice as far as I know. Try making up your own circuit. If you need help, if necessary, I will give all I can by email or telephone. An email link is at the bottom of this page.

## Most Often Used Voltage Sources.

Voltage sources are what you would think they are. They deliver a constant voltage at their terminals. Electrical engineers think of voltage sources as being ideal, That is they will maintain a constant voltage even if they have to provide an infinite amount of current to do it. Do I need to state the obvious? Oh well, I might as well. There's no such thing as an ideal voltage source in the real world. To turn an ideal voltage source into a real one, connect a resistor in series with it. An AC source is likely to require an inductor and/or capacitor or even a complex RLC network. LTspice has ideal voltage sources but the complete set of specifications includes parameters that will make them real world.

### The General Syntax for a voltage source.

V# n# 0 value

This is the same for almost any voltage source. Voltage sources usually have one terminal connected to ground. Occasionally it is necessary to use a floating voltage source but such things are difficult to do in the real world so should not be used in a simulation if at all possible.

To specify different voltage sources the only thing that changes is the value.

### DC voltage sources.

To provide plate power to our tube circuits a simple DC source is all we need. The value is just a number.

For example, 12, 150, 250, 500, etc.

### AC sine wave sources.

The simplest AC source is that used for a frequency response. The value is,
AC 1
There must be a space between the AC and the number 1. This sets an AC source with an output of 1 volt and an indeterminate frequency. The frequency range is set in the spice directive that tells spice to run a frequency response.

A sine wave source for transient analysis and Fourier analysis looks like this.
Sine(DCoffset PeakVoltage Frequency)
DCoffset is a DC value that will be added to the wave.
PeakVoltage is the voltage at the peak of the wave measured from the vertical center. Peak to Peak is twice the peak voltage.
Frequency is the frequency. What more is there to say.
You will probably use this syntax most of the time.
There is a way to limit the number of cycles if you need it for the transient analysis. The syntax is,
Sine(DCoffset PeakVoltage Frequency 0 0 0 Cycles)
The three zeros are time delay, phase, and something I haven't yet figured out. Cycles is the number of cycles the generator will run. If you don't need to limit the number of cycles you can stop typing with the first three parameters and the generator will run indefinitely.

### Square Wave Generator.

A square wave source is often needed to test am amplifier for ringing. It looks like this.
PULSE(Vlow Vhigh Delay Tr Tf Ton Period Cycles)
Vlow is the voltage of the low part of the wave.
Vhigh is the voltage of the high part of the wave.
Delay is the amount of time before the generator starts.
Tr is the rise time of the wave, (can be entered as zero).
Tf is the fall time of the wave, (can be entered as zero).
Ton is the on time or the time that the wave is in the high state.
Period is the total time from one rise to the next. If Period=2* Ton, you've got a square wave. If it doesn't you've got a pulse.

### Other Functions Available.

There are other functions. They will be listed but no syntax will be given. They will not be on the test.
• EXP (Exponential rise and fall).
• SFFM
• PWL
• PWLFile with a box to enter the file name.

## Most Often Used Spice Directives.

### Frequency Response.

To run a frequency response the generator line will look like this.
V1 n1 0 ac 1

To obtain the frequency response of an amplifier or tone control you use the .ac directive.
.ac SweepType PointsPerType StartFrequency StopFrequency
SweepType set what kind of sweep you select. There are four types to choose from. They are,
1. Octave,
2. Decade, the one you will probably use most often,
3. Linear, second most used, and
4. List, you provide a list of all the frequencies where you want a measurement to be taken.
PointsPerType. The first three types have their own definition. They are,
1, Octave, Points Per Octave,
3. Linear, Total Number of Points.

As mentioned earlier a sighted person will set the number of points as large as practical. (The more points the longer the simulation will take). We who are blind cannot see the smooth curve of a graph but must read the numeric value of each point. We don't want hundreds of points. For a decade plot, more often called a log plot, 3 points per decade seems to be enough because the responses being plotted on such a graph change rather slowly and in a geometric manner.

The octave plot is likely to be used by musical instrument designers. If the plot doesn't cover very many octaves he or she might want to use 12 points and set the start and end frequencies so the points fall on the frequencies of the musical notes. This has the potential to generate a lot of printed pages particularly if sent to a Braille printer. The user will have to use his own judgment.

The linear plot could be problematic. Linear plots are made over very small frequency spans as compared to the center frequency. A typical example would be the IF amplifier in a radio receiver. For this application the list might be a better choice for the blind user. The points of interest in an IF amplifier or filter are the center frequency, the two minus 6 dB points which is how engineers define the bandwidth, and the two minus 60 dB points which is the definition of form factor which can be thought of as adjacent channel rejection. The desired five frequencies could be placed in the list and the actual DB values of the filter design could be compared to the desired performance.

### Square Wave Response.

To obtain the square wave response of an amplifier the generator must have a square wave output. This is the generator line.
V1 n1 0 pulse(-.5 +.5 0 0 0 .5m 1m)
The amplitude is changed by changing the first two numbers inside the parenthesis. They must be kept symmetrical about zero.

To see the square wave response of an amplifier you use the spice directive for transient analysis. It goes like this.
.tran SymStartTime SymEndTime StartTakingData TimeBetweenPoints
For example with a 1 kHz square wave the tran directive might have this form.
.tran 0 2.1m .9m 100u
We might need to give it more than 0.9 ms for the starting transient to settle down but we only want to look at data for just a little over 1 cycle, 1 ms in this case.

## Measuring Distortion.

The measurement of distortion requires two directives.
1 .tran (transient), and
2 .four (Fourier).
First of all the generator has to be a sine wave. The usual test frequency is 1 kHz. The amplitude of the input will have to be adjusted so that you are testing the amplifier at its intended output level. The syntax of the Fourier directive for a 1 kHz signal source is this.
.four 1k V(n#).
The directive is mister literal when it comes to node numbers. If the output node of the amplifier is n6 you need to put n6 in the parentheses. If you typed it as n006 you must type exactly n006.

The .tran directive needs to be set up correctly for best results. I found that the time over which data is taken should be 2 or 3 cycles of the input wave. The mathematics of probability tells us that the longer the analysis time the more accurate the reading. The facts of spice seem to disagree. If the analysis time gets greater than 10 cycles the readings start to increase and a 1 second time, 1000 cycles, distortion value is much larger than for a few cycles. The Maximum time step should be set to permit approximately 10 points for one cycle of the highest harmonic to be included. 9 is the default.

After running the simulation you press alt-v and down arrow until you find spice error log. The error log may seem like a funny place to find valid data but that's the way it is. When the log opens the cursor will be on the first line and you will need to down arrow to find the readings. You will see the data for the first 9 harmonics which is the default value. After the 9th harmonic you will find total harmonic distortion. There are two values given, the second value is in parentheses. I can't find what this means either in the book or the LTspice help topics. Some testing I did with a generator fed directly into the analyzer showed the one not in parentheses is the one to be believed.

## Conclusion.

I realize that I have given you a lot to digest. If you feel you are coming down with indigestion don't worry. I'll reinforce this material over the next several lessons. I'd like to hear from you. Feel free to email me.

If you can honestly checkoff each item on the list under the heading "What you will learn in lesson 1", you can go on to lesson 2, assuming I have written it by then.