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.
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:
All illustrated version is shown in the plot below:
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:
The complete solution for this differential equation for the sinusoid input consist of both transient and steady state components:
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.
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:
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: