With Time Varying Sources
University of Evansville
In addition to LTspice IV, this tutorial assumes that you have installed the University of Evansville Simulation Library for LTspice IV. This library extends LTspice IV by adding symbols and models that make it easier for students with no previous SPICE experience to get started with LTspice IV.
A Sinusoidal Voltage Source
In this short tutorial you will learn how to set up various time-varying voltage sources for use in transient analysis. The example circuit shown in Figure 1 will be used. We want to compare the output voltage (the voltage across RL) to the input voltage (the voltage generated by source V1). Labels have been added to the output and input nodes for convenience.
Figure 1: Example Circuit
Let us set up source V1 to generate a 1 kHz (1ms period) sine wave with a 1 V amplitude. Right click on the source in the schematic window and then click on the Advanced button in the dialog that appears. The dialog window shown in Figure 2 should appear. A series of radio buttons on the left side of the window allows you to select a particular source. Select the SINE source to set up a sinusoidal source. (Note: The AC Amplitude, and AC Phase on the right side of the window are ignored in transient analysis. They are used in AC Analysis.)
For times less than Tdelay or times after completing Ncycles the output voltage is given by:
At all other times the output voltage is given by:
DC offset is the DC offset in volts, Amplitude is the amplitude in volts, Freq is the frequency in Hertz (the reciprocal of the period), Tdelay is the time delay in seconds before the sine wave source turns on, Theta is the damping factor in reciprocal seconds, Phi is the phase shift in degrees, Ncycles is the total number of waveform cycles to generate. u(t) is the unit step function. The damping factor is a reciprocal time constant so the sine wave will decay to 0 V in approximately 5/Theta seconds.
We want to generate a sinusoid of the form:
so set Amplitude to 1, Freq to 1000 and set all other parameters to 0 (or leave blank). These parameter settings are shown in Figure 2.
Figure 2: Setting up the Sine Wave Voltage Source
After setting up the voltage source, click on the icon that starts the simulation. The Edit Simulation Command window show in Figure 3 should appear. Here a Stop Time of 10 ms has been entered. This corresponds to 10 periods of the input waveform (at a frequency of 1 kHz). Click on the OK button. You will be returned to the schematic where the simulation command can be placed on the schematic with a left button click.
After the simulation run completes, probe the input and output nodes. Results should appear as shown in Figure 4. The smaller input waveform oscillates between -1 V and 1 V while the larger output waveform swings between -10 V and 10 V. The theoretical voltage gain of the circuit is -10 V/V. It can clearly be seen from the simulation that the output is indeed negative when the voltage is positive.
Figure 3: The Transient Analysis Limits Window
Figure 4: Sine Wave Source Results
A Pulse Waveform
Let us change the voltage source to generate a square wave that swings from -1 V to 1 V with a period of 1 ms. Right click on the voltage source in the schematic window. The Voltage Source parameter selection window should appear as in Figure 6. Select the PULSE function. The parameters of the pulse waveform are defined as in Figure 5. Vinitial and Von are the pulse low and high voltage values. Tdelay is the time until the pulse waveform begins, Trise is the pulse rise time (here defined as the time it takes for the voltage to change from Vinitial to Von), Ton is the time that the pulse is at voltage Von, Tfall is the pulse fall time, and Tperiod is the period of the waveform. The values in Figure 6 define a pulse waveform that swings from -1 V to 1 V with a period of 1 ms. Notice that Tdelay, Trise, and Tfall are all equal to 0. The simulation results are shown in Figure 7. Again, it is easy to see that the output voltage waveform is -10 times the input voltage.
Figure 5: Definition of Pulse Parameters
Figure 6: Pulse Waveform Parameters
Figure 7: Square Wave Source Results
A Triangular Waveform
A triangular waveform can be generated by setting Ton equal to 0 and using values of Trise and Tfall equal to one-half the period. Figure 8 shows parameter values for a triangular waveform that swings from -1 V to 1 V with a period of 1 ms. The resulting input and output waveforms are shown in Figure 9.
Figure 8: Triangular Waveform Parameters
Refer to the Voltage Source section of the online documentation (see the Circuit Elements chapter of the LTspice book) for information on the other voltage sources. LTspice IV allows a wav file to be used as input.
Current sources can be set to generate sine waves or pulse waves similarly.
You may find it useful to set the Mark Data Points option. This will show the actual points at which LTSpice IV does a circuit analysis. You can set this option by right-clicking on the background of the waveform viewer window.
The Transient simulation command has a Maximum Timestep option. You can reduce the time interval between samples of waveforms by reducing this value. This option is ignored if waveform compression is on (and it is on by default). Turn off waveform compression in the LTspice IV Control Panel. (Wavefrom compression gives smaller simulation files.)
Figure 9: Triangular Waveform Results