LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Needed: Example to computer FFT of IIR filter from coefficients

Hi,

I am looking for a simple example that will calculate the frequency response of a filter of the format:

-1
H(z) = b0 + b1*Z
-----------
-1
1 + a1*Z

I want to use b0, b1, and a1 as the inputs. All of the examples I can find expect a constructed filter and they run white noise through it. I don't want to do that (empirically). I want to do it directly. Are there any modules in the library that will do essentially the same thing as the "freqz" command in MATLAB?

Thanks much,

Jason
0 Kudos
Message 1 of 6
(3,443 Views)
This example may help.

C:\Program Files\National Instruments\LabVIEW 7.1\examples\measure\maxmpl.llb\Frequency Analysis of a Filter Design.vi.
Message 2 of 6
(3,433 Views)
Thanks, I have looked at this and it does provide a nice display of the response. The thing that I can't figure out is how to use filter coefficients as the input because this example takes in filter design parameters, not the filter design and I can't seem to find anywhere in there where coefficients are generated. Any ideas?

Thanks,

Jason
0 Kudos
Message 3 of 6
(3,418 Views)
Hi Jason,

There is a subVI located at ...\vi.lib\measure\macond.llb\ma_Compute H(w) from IIR Cluster.vi that should handle your case. Please note that the input is the filter coefficients in cascade second order form. The online help (VI and Function reference->Analyze VIs->Signal Processing VIs->Additional Information->Digital Filtering->Cascade Form IIR Filtering) describes this structure in some detail, but your problem is small enough to fit inside a single stage. You could also use ...\vi.lib\measure\macond.llb\ma_Compute H(w) from h(n).vi to compute the frequency response of the numerator and denominator separately, and then divide (using appropriate complex division) to obtain the overall response. This allows you to work with direct form coefficients as opposed to cascade second order, but requires a little more coding.
Message 4 of 6
(3,409 Views)
Hopefully the attachment is what you need exactly. It is not recommended to use the subVIs of LabVIEW. They are not exposed on the function palette and may change in the future version of LabVIEW.
Message 5 of 6
(3,389 Views)
Hey, thanks, that's great! I had tried two other methods as well but I think yours is the best. I have attached what I have done so far. Perhaps it will be of benefit to someone in the future. I tried to modify the filter routine to handle direct coefficients instead of a filter cluster but haven't gotten that to work yet. So, this is what I have so far.

As far as using LabView VI's, thanks for the information. If I ever decide to do that I will make sure that I copy them into my workspace instead of relying on LabView's libraries.

Thanks much,

Jason
0 Kudos
Message 6 of 6
(3,378 Views)