How to plot frequency vs gain for a filter?

Click For Summary

Discussion Overview

The discussion revolves around how to plot a frequency versus gain graph for a filter, specifically focusing on the creation of a program that can visualize this relationship. Participants explore concepts related to transfer functions, gain, and frequency, with references to both analog and digital filters.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification
  • Homework-related

Main Points Raised

  • One participant seeks to understand how to plot a bandpass filter curve using gain and frequency, expressing confusion over transfer functions and their application.
  • Another participant clarifies that H(z) represents the transfer function for digital filters, with z being the frequency variable, and contrasts this with the use of s for analog filters.
  • A participant mentions their familiarity with complex arithmetic and expresses willingness to revisit it for plotting purposes, while also discussing their choice of programming languages (C# or Python) for the project.
  • References to external resources, such as a PDF on Bode plots, are provided to assist in understanding the plotting process.
  • Participants discuss the challenge of obtaining the correct transfer function for a desired filter based on user-defined parameters like center frequency and gain.
  • Additional resources are shared to inspire ideas for creating an interactive visualization tool for manipulating filter parameters.

Areas of Agreement / Disagreement

Participants generally agree on the need for a transfer function to plot the frequency response, but there is no consensus on the specific approach or tools to use for implementation. Multiple views on the best programming language and method for plotting remain present.

Contextual Notes

Participants note the complexity of converting transfer functions and the potential difficulties in obtaining explicit parameters for filters. There is an acknowledgment of the learning curve associated with complex arithmetic and filter design.

Who May Find This Useful

This discussion may be useful for individuals interested in audio processing, filter design, or programming related to signal processing and visualization.

trip6
Messages
6
Reaction score
0
Hello,

I am trying to understand how this graph http://en.wikipedia.org/wiki/File:Bandwidth_2.svg
gets plotted. My goal is to write a small program that takes the center frequency/bandwidth and a (cut/boost) gain values and plot the curve.

I initially assumed, all I needed to find was an equation of gain in terms of frequency to plot it. I have been searching for a few weeks now and I keep running into transfer functions and many different types of them. But I don't understand how this translates into a gain(yaxis) vs freq(xaxis) plot.

For example, I found the following equation at http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt

b0 + b1*z^-1 + b2*z^-2
H(z) = ------------------------ (Eq 1)
a0 + a1*z^-1 + a2*z^-2


the a0,a1,a2,b0,b1,b2 are calculated in terms of frequency/gain/bandwidth. On plotting H(z) I get something that looks like a bandpass filter curve but what does H(z) and z represent?

I don't have an electrical engineering/math background but am really interested in understanding how this bandpass curve gets drawn. Any advice on how to go about this would be greatly appreciated. Thanks!
 
Engineering news on Phys.org
What programming language do you intend to use to write your plotting program?

The function H(z) is simply the transfer function itself. The z is the frequency variable. The symbol z is customarily used for digital filters. For analog filters, it's customary to use the variable s, so your transfer function might be denoted H(s).

Do you understand complex arithmetic? The plotting of frequency responses from given transfer functions is most conveniently done using complex arithmetic.

It is possible to convert typical transfer functions to a form that doesn't involve complex arithmetic, but they then become very much more complicated.
 
Thanks for the response. I have done complex arithmetic in college, but have never found a use for it since. I don't mind dusting out the cobwebs if it makes plotting the curve simpler. I am just not very sure where to start.

As to the language, I would use C# or python. I have seen audio apps where the user interface allows graphical manipulation of the wave by picking a center frequency, setting a db level and the pass band. I would like to do something like that.
 
Have a look at this:

http://jegyzet.sth.sze.hu/ftp/!BSc/Szabalyozastechnika/BodePl.pdf

This reference should help a lot.

Usually one uses an application like Matlab to do these kind of plots. It has built-in functions for the purpose. It certainly can be done in C# or Python, but it won't be as easy.

Here is a program to do Bode plots. I don't know if the author's source code is available, but maybe you can contact him about it.

http://www.bode.cg.yu/

Part of your problem beyond just learning how to do the plots will be how to get the transfer function for your desired filter with explicit parameters for center frequency/bandwidth and (cut/boost) gain values.
 
Last edited by a moderator:
The Electrician said:
Have a look at this:

http://jegyzet.sth.sze.hu/ftp/!BSc/Szabalyozastechnika/BodePl.pdf

Thanks for the pdf. Very useful though its taking a while to fully digest...

Part of your problem beyond just learning how to do the plots will be how to get the transfer function for your desired filter with explicit parameters for center frequency/bandwidth and (cut/boost) gain values.

I don't really have a "desired filter". I really just want to provide an (interactive) visualization, where the user picks a center frequency, chooses to cut or boost gain and then sets a pass band. Should be basically able to manipulate the curve through this interface.
 
Last edited by a moderator:

Similar threads

Replies
3
Views
5K
  • · Replies 4 ·
Replies
4
Views
10K
Replies
4
Views
4K
Replies
3
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
7
Views
4K
  • · Replies 7 ·
Replies
7
Views
2K