LTspice Lesson 4a: Generate Waveforms used in Electric Circuits: SINE

Kashif Javaid

Instead of cut-and-paste of LTspice help file as some of LTspice tutorials on the internet has done, I think best way to learn nitty and gritty of this tool is to solve a circuit by hand, predict it’s output by varying some parameter and verify it using LTspice. If it’s complicated circuit, often it can broken down to simpler block.

LTspice has various options to generate pulses, sine waves, exponential and piece wise linear (PWL) and built-in Frequency modulation sources as shown in below diagram.

Screen Shot 2019-12-02 at 11.16.14 AM.png

We will look at one source at a time and look at the relevant circuit, solve it by hand and predict it behavior and verify it using LTspice. In the process we will master each source syntax.

Generate a Sine wave:

Generating a sine wave is easy and given by following equation 1:

Voffset+Vamp*exp(-(time-Td)*Theta)*sin(2*p*Freq*(time-Td)+p*Phi/180)……………[1]

Screen Shot 2019-10-14 at 4.00.46 PM.png

Screen Shot 2019-10-14 at 3.53.50 PM.png

All illustrated version is shown in the plot below:

Screen Shot 2019-10-14 at 3.23.50 PM.png

True to spirit of these tutorials, we will predict the output using calculation and intuition. Then we will verify it using LTspice.

Total Response of a RC circuit to suddenly apply sinusoid:

In this example, we will simulate output response of RC circuit for a sinusoid input. Typical approach is to convert the circuit into frequency domain and find the steady state response. In order to capture the total response which include both Transient and Steady state response, I chose to employ a harder approach to calculate the response to suddenly applied sinusoid. First I wanted to review my math, but most importantly both calculation and simulation will allow us to capture the total response to suddenly applied sinusoid input. I calculated the total response from following differential equation of the RC circuit:

Screen Shot 2019-11-20 at 9.54.21 PM.png

where Vs=cos(2*pi*f*t)

The complete solution for this differential equation for the sinusoid input consist of both transient and steady state components:

Screen Shot 2019-11-20 at 9.55.10 PM.png

If you are interested in math behind it, check out here, but important thing to note is that there will be some interesting transient effects which dies out as time progresses. I want to capture this behavoir using simulation and possible on the bench. For capturing transient behavior we need to define the initial condition on the capacitor using              .ic V(vc)=0V command along with uic directive. uic is stand for Use Initial Conditions. This directive need to be used carefully as DC operating point analysis is typically performed before starting the transient analysis, but this command can bypass it. So if you have a situation where a voltage source is hooked up directly to a cap and we used similar initial condition as ic V(vc)=0V and uic, then LTspice will complain as voltage on the cap cannot be change instantaneously because this will require a infinite amount of current (I = C dv/dt).

Results from the formula, simulation and bench are shown below. The agreement between formula and simulation is excellent as it should be. The bench results show similar behavior and close to theoretical value.

Screen Shot 2019-11-20 at 9.33.36 PM.png

The difference between math/simulation and bench on peak numbers are most likely due component tolerances as wells as my scope cursor resolution. The important thing to note is the shape of the actual bench response from real component is very close our theoretical results:

Screen Shot 2019-11-20 at 9.36.10 PM.png

In conclusion, steady state response can be found very easily using simple Laplace transformation, but I wanted to capture what happens during initial time period and how can we model it using the LTspice while creating a sinusoid as a stimulus. In general, a flexible sinusoid (sine or cos) with option to vary different parameters can be created using the LTspice SINE directive.

To discuss or provide a comment:

https://www.eevblog.com/forum/projects/ltspice-lesson-4-generate-waveforms-used-in-electric-circuits/new/#new

 

 

About ExploreSilicon

My name is Kashif. I live in the heart of silicon valley and have been living here for a very long time. My passion is engineering, technology and traveling. My email is kashifjavaid@hotmail.com. Please feel free to contact if you have any suggestion or comments on any of my posts.
This entry was posted in LTspice for EE students and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s