2
\$\begingroup\$

I'm trying to test the bandwidth of a common emitter amplifier for an electronics practical using LTspice. I need to vary the frequencies from 10Hz, 20Hz, 50Hz then decade by decade up to 1MHz, using the .step param function, but I do not know how to go about it.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Why don't you run an ac analysis instead? You set the dc operating point and then excite the circuit with an ac source. You will then plot the magnitude and phase of your circuit automatically. \$\endgroup\$ Commented Aug 7 at 10:17

1 Answer 1

6
\$\begingroup\$

If you want to get the frequency response of a circuit you can run an AC analysis instead. For that, you'll need to configure your signal source:

enter image description here

And the simulation command:

enter image description here

Above is just an example i.e. you are free to change the values.

If you run the simulation and plot the output node, you'll get the frequency response (solid green: gain, dotted green: phase):

enter image description here

You can find the -3 dB point by putting a cursor on the frequency response plot and moving it manually, or you can ask LTspice to find it for you with .meas command:

.meas ac f find frequency when mag(V(out))=0.707

After the simulation you can open the SPICE Error Log and see the result:

enter image description here



If you still want to use a voltage source with varying frequency then you can define a function for the frequency interpolation and pass it to a behavioural source:

.param start_f 1
.param stop_f 1Meg
.func fot(sim_t) { start_f + time * (stop_f - start_f) / sim_t }

The function above makes a linear interpolation between start_f and stop_f which are the start and stop frequencies, respectively. sim_t is the simulation duration which is the value you pass to .tran function normally.

Now you can use the function in a behavioural source:

enter image description here

The result may look a bit off:

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ Thank you , this was very helpful. The graph I got was flipped however, and I'm getting almost double the gain I was getting when I took measurements of the practical circuit (around 30dB). \$\endgroup\$ Commented Aug 7 at 11:50
  • \$\begingroup\$ Okay , I fixed it. I accidentally connected my Vcc to ground . \$\endgroup\$ Commented Aug 7 at 12:50
  • \$\begingroup\$ @ColbyKlassen If this answer is satisfactory, then you should click on the checkmark under the answer score. More info here: meta.stackexchange.com/a/5235 \$\endgroup\$
    – Ste Kulov
    Commented Aug 8 at 2:50

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.