LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FIR coefficients (Hamming window)

Solved!
Go to solution

Dear Sir/Madam,

 

I am trying to evaluate a simple convolution filter (LOWPASS), to produce the coefficients that will be used for FIR filtering signal on the ARM microcontroller.

 

I used two different softwares to design a proper filter:

 

1. Labview (Digital filter design)

2. Matlab (Signal processing toolbox)

 

I am confused, since the result coefficients are not the same (the attached image below). Both Matlab (100% sure) and Labview (not 100% sure) use nomalized frequency as the input for the design. The normalized frequency is:

 

fn = fcutoff / fsampling;

 

I tested this in Labview on some signal with different fcutoff and fsampling, BUT with the same normalized frequency and the result was always the same (so I assume that Labview uses the normalized frequency also).

 

The parameters of the filter:

 

fn = 0.2

type = lowpass

window = Hamming

filter order = 24

ntaps/coefficients = 25 (filter order + 1)

 

The result:

 

untitled.png

It looks like as though the filters are not of the same order - the main lobe width is smaller in the Labview example, and the side lobe height is larger. To my knowledge this suggest that the filter order is higher than one in the Matlab. But both filters produce the same number of coefficients...

 

Labview "code" (only numerator coefficients, since it is not a recursive filter):

 

 

HTPA16x4_FIR filter design_BD.png

 

and the corresponding Matlab code:

 

coeffML = fir1(24,0.2);

 

Does anybody know the reason for this? Or am I just making some silly mistake?

 

Thank you and best regards,

K

 


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 1 of 4
(5,015 Views)
Solution
Accepted by topic author Klemen

Hello Klemen,

 

I had a look at your problem and found short explanation. The difference is how do you understand normalized frequency and how Matlab does.

You can normalize frequency by fs or by nyquist frequency (fs/2 as Matlab does). Therefore your result for LV is different because you

expext normalization by fs.

 

Details can be found here:

http://www.mathworks.com/help/signal/ref/fir1.html

"Wn is a number between 0 and 1, where 1 corresponds to the Nyquist frequency"

 

http://en.wikipedia.org/wiki/Normalized_frequency_(digital_signal_processing)

"Some programs (such as MATLAB) that design filters with real-valued coefficients use the Nyquist frequency (\scriptstyle f_s/2) as the normalization constant"

 

 To solve your problem, whenever you want to compare Matlab results of FIR filters coefficients with LV you have to multiply fs in LV by 2 prior to normalization.

 

I also attached sample program with comparision where are default values computed according to recommendation above.

 

Have a nice weekend.

Daniel Haupt
Message 2 of 4
(4,944 Views)

Hello,

 

thank you very much for your explanation and the attached example.

 

So to sum it up:

 

- Labview uses normalized frequency with valid values from 0 to < 0.5 (where 0.5 is fs/2)

- The analogy in Matlab is the normalized frequency from 0 to < 1 (where 1 is fs/2)

 

So for example 0.25 normalized in Labview is equal to 0.5 normalized in Matlab.

 

Should have been paying more attention to the documentation.

 

Thanks again and have a nice weekend.

 

K

 

 


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 3 of 4
(4,932 Views)

Hello, 

 

To explain: the problem is not in our documentation since VI FIR Windowed Coefficients does not use normalized frequency as Matlab does. 

You, as the developer, have to create your own normalization in case of using this VI according to fs and cutoff frequency. 

 

Therefore direct comparision of Matlab function fir1 and FIR Windowed Coefficients.vi is not relevant. 

 

 

Regards,

 

 

Daniel Haupt
0 Kudos
Message 4 of 4
(4,908 Views)