Using LTSpice I'd like to simulate a L-C parallel resonant circuit; I'd like to check its .tran behavior, but I don't know how to simulate a frequency variable voltage source similar to a Frequency Signal Generator in which I turn the frequency value to look for the tuning value. How can I do ? Is it an example I could use to do it?

  • 4
    \$\begingroup\$ Why not run an AC analysis? \$\endgroup\$
    – Andy aka
    Mar 31, 2017 at 13:04
  • 2
    \$\begingroup\$ You could use the .step facility \$\endgroup\$
    – PlasmaHH
    Mar 31, 2017 at 13:09

4 Answers 4


Add a B source with a time value in the parameter"

For example put this in for the value of the B-source:

V=0.00205*sin(2 * pi * time * (1 + (2 * time)))

time is a system variable, so you are essentially doing this:

$$ V = A\sin(2\pi t*(1+\beta t))$$

The amplitude can be varied with A and the frequency with \$\beta\$, you can also choose other equations, there are if statements and other neat things you can do to generate a source.

You either have to do math or play with the values to get the starting frequency and ending frequency.

enter image description here


If you want a .tran analysis of a swept frequency, besides the already given answers, you can also use [SpecialFunctions]/modulate or modulate2. It's easier to use than a behavioural source and it handles large dynamic ranges much better, despite needing two additional sources for that. You may also need some buffer at the output since it defaults to Rout=1, but it can be lowered/raised as needed.

For example, for a 1s, 10Hz - 100Hz sweep, from 1V - 2V, you can add a PWL(0 10 1 100) source to the FM input, and a PWL(0 1 1 2) source to the AM input, with mark=1 space=0 added to the modulate.

You can also combine the two inputs to a single source. In this case, the amplitude will be directly controlled by the source, thus it will have to be PWL(0 1 1 2), while the two parameters will need to be calculated from the formula: f = space + (mark - space)*V(FM), which, for 1V initial and 2V final results in mark=10 and space=-80.

Here's a quick setup:


The input is flat 1V until 0.5s, ramps up to 2V until 1.5s, then stays flat, to make the frequency detector show clearly the final values.

  • \$\begingroup\$ I would try solution you suggest: where I can find U1 as component to put into my schematic? \$\endgroup\$ Apr 5, 2017 at 7:10
  • \$\begingroup\$ You don't need U1, that's just some home-brew frequency detector. All the setup is made of A1 and V1. If you can't combine the two inputs (FM and AM) to be driven by one source, only, then you'll need two, driving each input, separately. \$\endgroup\$ Apr 6, 2017 at 6:01

If you want to run a .tran simulation with a varying frequency, parameterise the voltage source freqeuncy as {expression}, where expression is a function of the 'time' variable. The 'time' variable takes the time of the present simulation step in seconds. Check your documentation for the exact format, it may be capitalised.

It may be cleaner to set the frequency to zero, and control the phase as an expression of 'time'.


There are already a few different examples/ways given to do this, but since it exists and it's a little different with a logarithmic frequency step in time, here's another.

enter image description here Image source, explanation, and simulation download: eewiki

I figured it may help someone else who stumbles on this while searching.

  • \$\begingroup\$ nonya_business, you have been creating a new account every time you log in here, rather than using the original one. This is why you can't edit "your" posts -- the system believes that they actually belong to a different account. This practice also makes it impossible for us to communicate with you privately, which is why I'm leaving this as a public comment, in hopes that you will see it. If you really want to contribute meaningfully to this site, please stop creating multiple accounts and try to work within the rules established by StackExchange. \$\endgroup\$
    – Dave Tweed
    Aug 2, 2017 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.