Home.


Learning LT Spice.
Lesson 2.

Click here to download a PDF of this page.

Table of Contents.

Lesson 1: Fundamental Drawing Skills and a Simple Simulation.
Lesson 2: Introduction to Frequency and transient Analysis. This page.
Lesson 3: Configuring LT Spice and more Drawing controls.
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: Finding, installing, and using, potentiometer symbols and models.
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 11: Making symbols and models.



Lesson 2
Introduction to frequency and transient analysis.

What you will learn in Lesson two. How to:

  1. Find and retrieve a previously saved file.
  2. Change the generator to deliver an AC signal.
  3. Set up an AC analysis.
  4. Obtain the graph of frequency response.
  5. Change the value of a component on the fly.
  6. Change the generator to deliver a square wave.
  7. Set up a transient analysis.
  8. Obtain the graph of the input and output versus time.
  9. Change an analysis parameter on the fly.
  10. Change a generator parameter on the fly.
  11. Examine the effect an RC high pass filter has on a square wave.
  12. Examine the effect an RC low pass filter has on a square wave.
  13. Examine the effect an RC low pass filter has on a mixture of AC and DC.
  14. Examine the effect an RC high pass filter has on a mixture of AC and DC.

Having trouble remembering all those syntaxes?
Here's a summary page that should help.

Control click on this link to open it in a new window. Control Tab will switch back and forth between the current lesson page and this help page.

Retrieving a Previously Saved File.

This involves the use of standard Windows hotkeys but I'll go through it for the sake of completeness.
Press ctrl-O, and find your saved file in the files dialog box.
If a large number of files show up and you can't remember what you called it press esc or click on cancel.

Press alt-F or click File. The files menu will open. Below Print Monochrome is a list of recent files with the most recent at the top. If you took my suggestion you should see the file named Lesson 01. As you can see my list is pretty full. Yours should have only one file in it unless you have been engaging in some extracurricular activity. Note: That's not a bad thing. Typing a leading zero before a single digit number is probably a good idea. If the number goes above 9 and and you haven't used leading zeros Windows will not put them in numerical order.

Figure 2.1 Recent files list.

Setting up a Generator for AC Output.

Refer to figures 2.2 and 2.3.

Figure 2.2 Old Generator Setting..

Right click on the generator symbol. Note that the number 10 is in the DC value[V] box and it is selected. Press the delete key and it will disappear.

Click the Advanced button.

Figure 2.3 Advanced Generator control box.

Note that the DC value box in the upper right corner still has a 10 in it. Erase it.
Then type a 1 in the AC Amplitude box below the DC value box. Click OK.

Press F7. Left click on the .op text. It will now move with the mouse. Move it to the right above the word out but still near the top of the window. Left click again to drop it there. Right click on it. Press the ESC key. In the box that comes up there are two radio buttons. Click the one before Comment and click OK. The text will turn blue.

The AC Analysis Spice Directive.

There is a directive editor built into LTspice which is very helpful for keeping the syntax straight. To access it press alt-S then up arrow which will cause the highlight to move to the bottom of the menu. It will be on "Edit Simulation Cmd". Press enter and you have the editor open. You will see something similar to figure 2.4 except that all the text boxes will be empty and a different tab will be selected. Select the "AC Analysis" tab and fill in the numbers as you see them.

But what if you don't remember these magic keys. You can search through the menus until you find it under Simulate. You could also look it up in the book you bought. But if you don't have the book and don't want to stop work to search the menus you can do this. Press S and in the box type .ac and click OK. Position the letters ac above the generator but near the top of the window. Then left click to drop them there. Now hover over the letters and the cross cursor will turn into an I beam. Right click. Figure 2.4 is what will come up. Enter the parameters as you see them and click OK.

Figure 2.4 Ac analysis control box.

Now you should have this.

Figure 2.5 Circuit now ready for AC analysis.

Now click on the little running man. The schematic window will grow smaller and a second window will appear above it. It will be empty. Move the mouse to the line that leads to the word OUT. The cursor will turn into a red scope probe. Left click. The window will now show this.

Figure 2.6 Gain and Phase plotted versus frequency.

Even though this circuit has only losses the term gain is universally applied to the ratio of output to input. An amplifier may have gain in part of the frequency spectrum and loss in another part. Rather than get all tangled up with gain here and loss there the whole thing is called gain. Now left click in the light blue area above the graph window. It will turn a darker blue. Then press ctrl-s. This will save the connection to the circuit so next time you run the simulation you won't have to connect the scope probe again.

Changing the Value of a Component on the Fly.

It is possible to change a component value without closing the graph window. That is, if the text on the reduced schematic is still readable. Select the schematic window by clicking on the area just above the window. It will turn a darker blue. Move the mouse over the resistor. The cursor will turn into a current clamp. We haven't learned that yet. Even so if you right click instead of left clicking the value dialog will open. Change it to 10 k ohms and click OK.

Now I need to speak to the electronics novices in the class. You experienced folks keep your hands down. You probably know intuitively that the corner frequency, that is, where the phase crosses 45 degrees and the gain crosses -3 dB will change by a factor of 10. But which way will it change? Up or down. How many say up? How many say down? Alright let's run the simulation again to see what happens. Click the running man.

Alright, what happens if we make the capacitor 10 times bigger. Do I hear some people saying the cutoff frequency will go up. Some agree some disagree. Let's try it and see. We now have a 10 k ohm resistor and a 1.5 uf capacitor. How about that! It went down didn't it. If you really didn't know you need to do some studying of behavior of RC circuits in the presents of AC. My Electronics for Nonengineers has a good section and there are lots of other sites on the web where tutorials are posted.

But what about those messed up vertical scales. Move the cursor over the DB scale on the left. It will change to a ruler. and right click the mouse. Here is what you will see.

Figure 2.7 Adjusting dB Scale..

Figure 2.8 Adjusting Phase Angle Scale..

You don't have to type dB and you definitely don't have to insert the special degrees symbol. LT Spice will put them in the next time you open those dialog boxes. Look at your own screen to see the effect. If you are asking why LT Spice does that, I don't know. I guess it's to keep us on our toes.

Just to tie the ribbons on this topic try changing the capacitor to 0.015 uf. What do you know. It looks exactly like figure 2.6.

TRANSIENT ANALYSIS.

Changing the Generator to Deliver a Square Wave.

Close the graph window and maximize the schematic window. Right click on the generator. Click the pulse radio button in the upper left hand corner of the dialog. Fill in the values according to this picture.

Figure 2.9 Pulse, Generalized Square Wave, Settings.

Vinitial[V] is the bottom voltage of the wave. It is also the voltage that is the starting and ending value.

Von[V] is the voltage of the top of the wave.
Tdelay[s] is the time before the first pulse begins.
Trise[s] and Tfall[s] are the rise and fall times, respectively, of the wave.
Ton[s] is the time that the wave is on, at the high level.
Tperiod[s] is the period, 1/f of the wave. Setting Tperiod to twice the value of Ton creates a square wave.
Ncycles is the number of cycles that the generator will run. It will stop after that number and not start again until the simulation is run again.

Figure 2.10 Schematic showing long generator label..

You may be wondering why we don't change the font size. This is a very small schematic. As they get larger the zoom will have to be pulled back to show the entire diagram. The text and everything else will appear smaller. There are schematics in the LT Spice examples folder in which the text is so small as to be unreadable. You don't want to duplicate that in any of your drawings.

Right click on the line that begins .ac and press tab until the line of text at the bottom of the dialog box is selected. Press left arrow to get to the beginning and type a semi colon ; then click OK.

Start a new spice directive by pressing alt-S, then up arrow and enter. The dialog shown in figure 2.11 will open.
Select the "Transient" tab at the top of the box. Fill in the values and click OK or press enter. You will now have the entire directive controlled by the mouse. Place it where there is plenty of room and left click.

Figure 2.11 Transient Analysis Dialog Box.

Stop time is the ending time of the simulation. We set up the generator to run for 20 cycles with a period of 1 ms. That adds up to 20 ms so the entry here is 20m.
Time to start taking data is the delay after the simulation starts before data begins to be shown. This is often done because we want to see the steady state value so we wait for any startup transients to die down before we start looking at data. In this case we are going to look at startup transients and all, so the start taking data time is zero.
Maximum time step is the time between samples. If the input is a repetitive wave we want 100 samples for each cycle. In this case the input wave repeats every 1 millisecond so we want samples every 10 microseconds.

Displaying the graph of input and output.

Click on the run button.
Click on the wire just above the top connection of the generator.
Click again on the wire above the capacitor.
Look at your own LT Spice screen to see what you got.
The green trace is the generator voltage and the blue one is the voltage across the capacitor.

Changing a transient analysis parameter.

Right click on the word .tran.
Change the Stop Time to 22m.
Click OK.
Click the run button again.
The wave form generator starts and ends at -0.5 volts. After the simulation ends it holds that value for as long as you care to weight.

Changing a generator parameter.

Right click on the generator.
Change Tdelay to 1m.
Click OK.

High Pass Filters and Square Waves.

If you are returning to this page there is no need to retrieve your last circuit. We are going to start with a new set of values for the RC network and a new generator. If you are working through this page then close the circuit you have been working on and draw the one below.

The high pass filter should look familiar as the coupling circuit from the plate of one stage to the grid of the next. The resistor value in the circuit is the commonly used 470 k ohm grid resistor.

Figure 2.12 Square Wave Generator and High Pass Filter.

A high pass filter passes high frequencies and attenuates lower frequencies. We already know that when sine waves are involved that the higher frequencies will be attenuated only very slightly while lower frequencies will be attenuated more and more as the frequency goes down. Let's see what effect one has on square waves.

After you type it the long label of the generator will appear to the right of it. Use the open hand tool or F7 to move it to a location where it won't run over the resistor. The square wave is still at 1 kHz but the amplitude is now from -1 to 1 volt for a P-P voltage of 2 volts.

Run the simulation by clicking on the running man tool or pressing F10. The graph window always comes up blank. Click on the top of the schematic window and move your cursor over the line labeled "out". It will turn into a scope probe. Click. To add interest move the cursor over the line that connects the generator to the capacitor. Click. If you haven't changed the colors, the output wave will appear in green and the generator wave in blue. From the file menu select Save as and "Lesson-02-02". Click in the graph area and check to make sure that the file name you just typed appears in the upper left corner of the graph window, just outside the graph area. If the name is different run the simulation again. Then press ctrl-S to save the connections to the graph so you won't have to connect them each time you run the simulation.

A square wave is made up of an infinite series of sine waves that have the form

1/n sin(nωt) for n = 1, 3, 5, etc, etc.

For the values of C and R in the diagram calculate the frequency where Xc = R. This is variously known as the "corner frequency", "Cutoff frequency", "half power frequency", or "-3 dB frequency", just to name a few.

Change the capacitor value to 100 pf and run the simulation again. The original square wave has been reduced to a series of narrow spikes. They can be made even narrower by reducing the value of the capacitor even more. When digital circuits were being built out of discrete transistors and resistors this technique was often used to generate the narrow trigger pulses these circuits required.

Now increase the value of the capacitor in the following sequence. 0.001 uf, 0.0033 uf, 0.01 uf, 0.033uf, etc, etc. What is the smallest value that will pass a perfect square wave? You will know perfection because the green trace will be completely hidden behind the blue trace. How does this compare with values commonly used in high fi amplifiers?

Low Pass Filters and Square Waves.

The low pass filter may not look familiar as part of the plate circuit of an amplifier. The resistor value in the circuit is the plate resistance of the commonly used 12AX7 triode. The capacitor never appears on the schematic because it is made up of inter electrode capacitance of the tube, stray wiring capacitance and the miller capacitance of the following stage. The latter is usually the lions share of the total.

You are going to find editing the diagram a little more trouble than you think. The reason is that the resistor and capacitor symbols aren't the same length so you can't just delete the capacitor and drop a resistor in its place. The capacitor is shorter than the resistor. Once you get everything redrawn you will have something resembling figure 2.13. We don't have to use standard values because R1 is not a real resistor and C1 is not a real capacitor.

Figure 2.13 Square Wave Generator and Low Pass Filter.

Save your schematic under the name Lesson 02-03

A low pass filter passes low frequencies and attenuates higher frequencies. We already know that when sine waves are involved that the lower frequencies will be attenuated only very slightly while higher frequencies will be attenuated more and more as the frequency goes up. Let's see what effect one has on square waves.

Calculate the corner frequency of R1 and C1 as they are shown on the schematic. Run the simulation.
Change the capacitor to 0.02 uf and run it again. This is not a bad way to get a triangular wave either in LTspice or on the workbench if you don't have a function generator. LTspice does not include a triangular wave generator. Now find the maximum value of C1 that will give a pretty good but less than perfect square wave.

Calculate the corner frequency for your choice for C1 and R1.
Is your choice physically realistic.
A corner frequency of 20 kHz might seem to be a good value but remember that a 20 kHz sine wave is 3 dB down from mid band. You would be better off moving your corner frequency up to 60 kHz or higher.

AC plus DC and Low Pass Filters.

We are assuming we are working with the file Lesson 02-03. Right click on the generator and change the radio button from PULSE to SINE. Set the text boxes as follows. DC Offset to 10, Amplitude to 1, Frequency to 1kHz, the next three to 0, and the last one blank. Click OK. Press F7, click and drag the generator, do not hold, to the left. Notice that the label moves along with it. Put it where you want it by clicking again. Put a resistor where the generator was. They are the same length. Continue drawing and modifying the diagram to match figure 2.14.

Figure 2.14 DC + AC Generator and Low Pass Filter.

As soon as you finish drawing this figure save it under the name Lesson 02-04. Run the simulation. Attach scope probes to "out", "Ref", and the line between the generator and R3, in that order.

Note: LTspice has built in a routine to ignore DC offsets. The Ref node is my way of tricking it into putting zero on the vertical scale of the graph. LT won't let you connect a scope probe to ground. Now you see how the DC remains unattenuated while the sine wave is attenuated. If the capacitor were made 22 uf the green line would appear as a flat line.

AC plus DC and High Pass Filters.

Update your diagram to match figure 2.15. Remember to change the resistor value from 4.7 k to 470 k. Then save it as Lesson 02-05.

Figure 2.15 DC + AC Generator and High Pass Filter.

Run the simulation. Because the diagram was changed the scope probes have been disconnected. Reconnect them in the order "out", "Ref", and top of the generator. This is how the DC plate voltage is blocked from the following grid while the signal is passed unattenuated.

When I taught at the University I would go over these two circuits in class and explain how they worked. Unfortunately I didn't have enough lab time to give this as a lab experiment. I wish I had because I was constantly amazed at how many students got the exam questions wrong. Now that you have seen it you would get the questions right. Right?

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


Back To Table of Contents.


This page last updated May 6, 2022.

Home.