Frequency Response Analysis (.bode) Study Guide

I saw questions about how to use frequency response analysis (.bode). Actually, the help in Qspice is quite clear, but people may still find challenge as commands to control .bode behavior are separated in .bode and .option

Therefore, I prepared a guide for .bode for those who interested in .bode but have difficulty in setting up a simulation or getting a frequency response curve as you expect. But .bode is not an easy topic to explain, this is so far the best present I can come up with.

I am a user same as you, therefore, I cannot guarantee all information in my work is correct.

You can find the .bode guide in this Github link. In addition, it also include an Entry guide, Device guide and a Reference guide. I still work on updating all these guidelines. Feel free to let me know if typo or mistake in them.

Qspice/Guideline at main · KSKelvin-Github/Qspice

8 Likes

I look forward to reading this. Thanks Kelvin!

1 Like

Hi Kelvin,

I have a suspicion that the .bode does not actually run the transient analysis and apply the perturbation one frequency at a time. I guess some fancy algorithm like multitone is used instead Multi-Tone AC Analysis Theory

Reasons:
I noticed some weird result and clear cut differences between using .bode and .meas fra + .step.
perhaps you can find my mistake for how I implement .bode in this file.
FRA_SMPS_STUDY.zip.txt (2.5 KB)

Thanks
Arief,

I can guarantee .bode run a .tran to collect time domain data for frequency response analysis.

For Qspice demo circuit FRA_SMPS, I setup a .step for frequency from 1KHz to 80kHz, this allow to plot the .meas, to generate a bode plot.

Next step I change simulation directive to .bode, and results between FRA and .bode compared in below.

I start simulation from 1kHz instead of 100Hz, as 1kHz already with 40dB gain. To start with lower frequency down to 100Hz, higher gain is expected and may easily saturate the controller. For this circuit, bode between 1kHz to 80kHz should be good enough to cover enough design information.

This is simulation files for reference
Qspice/Forum/15954 at main · KSKelvin-Github/Qspice

Hi KSKelvin,

I am not doubting if real .tran is used for .bode, however, I am thinking if the analysis is performed using multi-tone or not.

To my knowledge a sweep of the single frequency perturbation should be the more accurate approach, though a lot slower.

Please refer to this article
Frequency Response of Switching DC_DC Converters from a Single Simulation in the Time Domain.pdf (1.5 MB)

Arief,

oh, sorry that I misunderstood your first message. I didn’t investigate the maths behind .bode.

My major focus is just to document my study and share with community. The simulation time for a time domain bode offers by .bode is amazing. That why I think it worth the effort to learn and to use it.

I am also interest to the math behind. But as Qspice help doesn’t explain that, and if Mike not further explain that, I just leave it aside at the moment. How to use it to achieve my goal is my major focus in using Qspice. Thanks for sharing the article, will look into that.
On the other hand, I also see you are working on a project to develop an approach for frequency response analysis in Qspice. :+1:

1 Like

Kelvin, this is what I been looking for. Thank you for posting this. Robert

Hello,

I am trying for a simple common-emitter amplifier to get the overall frequency response of the circuit. I am new to spice and QSPICE, and I am likely messing up the directive to make it run properly.

Below is the circuit, I teach basic Analog and have never used a SPICE program, so I apologize if this is a stupid problem to solve. I want to learn this simulator to better show the theory in class.
Below is the circuit in QSPICE, do not laugh at my directives, I read KSKelvins how to guides, but I am still struggling.

I left off the ground on the V2 as if it is present it gives me an error(below).

This is what I get for the plot. with the ground on V2

This is a generic frequency response I would expect to see, for the overall response.
image

This subject is hard for the student to visualize and I was hoping that QSPICE could help show it. I know for some of you this is a simple solution.

I would appreciate any help on this.

Darrell

.bode is not the best tool to handle your request. In QSPICE, two directive for frequency response analysis, .ac and .bode, you can go to Qspice Help for more information, here is a quick summary

  • .ac : small-signal ac analysis linearize the circuit at dc operation point, this is equivalent to what the standard textbook do for a BJT circuit
  • .bode : use a perturbating source to inject ac signal and run time domain simulation, use FFT to get frequency response from time domain data. This technique is normally for switching circuit

You didn’t attach your schematic, therefore, I am not quite sure if your have .model to support Q1 as 2N3904, just beware that 2N3904 is not in standard Qspice library, you can add a .model for that, but in following demonstration, I changed to MMBT3904, you can right click on Q1, to select a model from there.

As you mentioned for teaching purpose, and you are new in SPICE, let me give you a brief example of what you can do with Qspice.

This single schematic can run a .op, .tran, .ac and .bode analysis. What you need to do is that, you only let one directive active before run simulation. If you switch directive, close the waveform viewer first. To switch directive, mouse hover the directive, press “;” to toggle comment or not. I add a Vdummy 0V source in series Vpert, the reason is that, .bode must have the source disconnect from GND. In series a 0V source can do the trick.

BJT-Circuit.qsch (9.8 KB)

DC Operation Point
As I changed Q1, I have to re-adjust bias condition. .op with .step can give V(c) vs R4 relationship, which help to quickly identify what R4 should be. Midpoint is at R4=3.7kohms, and in standard E12, R4 is selected as 3.9kohms in following analysis

Transient Simulation
In Vpert, sin 0 10m 1k is used, A sine wave 1kHz, 10mV is injected from V(in), and transient can help to ensure what is proper input signal range for .bode.

AC Analysis
OK, this is to answer your question. Here, Vpert with AC 1, which means we have a magnitude 1V, phase 0 degree AC source at Vpert. As circuit is linearized in .ac analysis, this “1V” magnitude will never saturate the circuit (if you put a 1V in sine function in .tran, you will see amplifier is saturated). The ac directive in here is to sweep freq from 10Hz to 1GHz, 100 points per decade. And this is the result you are looking for.

Frequency Response Analysis
Finally is .bode analysis. Actually, in your case, you don’t have to use .bode, but as demonstration, I still give you this example of how to use .bode to generate frequency response. However, to use .bode, you must be familiar with all setting in .bode

  • in this simulation, need to force constant perturbating amplitude, use .option bodeampfreq=0. you have to prevent saturating output as it will no longer be small-signal frequency response
  • .bode run very slow if Fstart to Fstop apart more than 3 decade. therefore, to sweep freq from 10Hz to 1GHz, I use .step to separate into 4 .bode sweeps and recombine the result

3 Likes

WOW, Thank you for taking the time to show/explain this.

Darrell

Qspice - Bode Frequency Response Analysis (.bode).pdf is updated in my Github : KSKelvin-Github/Qspice/Guideline.

On 26-Oct, Qspice updated help of .bode, and currently .bode can keep its time domain waveform with “DEBUG” and excitation source with Square wave instead of Sine wave with “SQUARE” as positive number.

Here is a demo schematic for following example in demonstrate DEBUG and SQUARE
bode-example-controlblockset.qsch (5.5 KB)

Demonstrate the use of debug, with sine wave perturbing source

Demonstrate the use of debug, with square wave perturbing source

3 Likes