Multirate FIR coefficients

I am trying to port matlab filtering tools to labview and I need some help understanding the filter tools.
Creating a multirate FIR with labview I would like to use a set of predefined coefficients so that they match what I built in matlab exactly.
It appears that labview VIs create the coefficients based on the input. Is there a way to specify the coefficients?
The task seems simple enough on its face. I have a 22 bit adc, sampling at 30 KHz. We need to calculate rms counts at 100Hz. To do this the designers required the measurements made by the adc at its raw 30 KHz be filtered and decimated to 100Hz with a duration of 60s.
I don't have a license of matlab to use with the matlab module in the labview developer suite.
I am currently calling octave via the command call. Octave is able to run the matlab files. But the start time to make and command call is quite high (10seconds) for each instance. Then there is still the overhead of octave. This is too long for my purposes.
Any help on this would be appreciated.

I tried using the FIR Filter.vi with co-effiecents calculated in matlab and the results were not what I expected.
I tried using the same variables to build FIR Narrowband Coefficients VI. it produced different coeffiecents which can be expected. But it was 20 coefficents instead of 165.
fir1Sps.txt was from matlab.
So I am abondoning making the FIR filter coeffiecents in labview.
I will try again to use the FIR Filter.vi
Does the FIR Filter.vi remove the first N values from X. Where N is the  number of co-effiecents.
What format does FIR Filter.vi expect the co-effeicents in? 
Attachments:
fir1Sps100.txt ‏5 KB

Similar Messages

  • FIR coefficients (Hamming window)

    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:
    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):
    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."
    Solved!
    Go to Solution.

    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 () 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
    National Instruments
    Czech Republic
    Attachments:
    FIRComparisionLVvsMatlab.vi ‏28 KB

  • Unwired 'Upper PB' Parameter in FIR Coefficients VI

    Hello everyone,
    I am using the NI_MAPro.lvlibigital FIR Filter.vi to do a Low Pass.
    Does anyone know what the coefficients and filter algorithms do when I leave the 'Upper PB' parameter unwired (0)?
    I am  using the Digital FIR Filter vi to do a windowed low pass filter, and am not wiring the upper PassBand parameter, as I want to do simple Low Pass.  however, in the FIR Coefficient generation logic, the 'NI_MaPro.livlib:ma_Design FIR Coeff.vi' vi uses both the Upper PB and Lower PB for the Windowed FIR filter type no matter what the type of filter I am using (band pass, low pass, etc.).  I am assuming that if you don't wire the 'Upper PB' parameter in conjuction with selecting 'Low Pass', the algorithm assumes that the upper limit is infinity.  HOWEVER, the implementation of the FIR filter is a code interface node.  Does anyone know explcitily the behavior in this case?
    Thanks,
    Wes
    Wes Ramm, Cyth UK
    CLD, CPLI

    Hello Wes,
    I am not sure if the Digital FIR Filter vi can be used to do a windowed low pass filter and not using the upper BandPass. However, there is a great example with low pass filters and the and the FIR digital filter called FIR filtering and Response.vi it shipped with LabVIEW and you can set up the properties for the Low Pass filter.
    If you are going to use the "Digital
    FIR Filter" function of LabVIEW. This function has two main inputs: the
    input signal to be filtered, obviously, and a cluster named "FIR filter
    specification". You have to set the parameters of this cluster
    according to what your filter must do; but this, doesn't
    concern with LabVIEW, it is instead bound to the general theory of FIR
    filtering signals.
    For general information, to create a frequency filter (let it be low-pass, high-pass, band-pass
    or notch) in a software environment, you have to use one of two
    different methods, FIR or IIR. By using these filters with different
    parameters, you are able to recreate any type of filter desirable.
    In
    LabVIEW you have the option of specifying parameters of the raw FIR or
    IIR filter or to use already defined filters like Butterworth,
    Chebyshev, Bessel etc. Basically, these filters are still using the IIR
    algorithm.
    All of the filters described will have a
    filtering effect in the frequency domain represented by the FFT. FFT is
    not a filter by itself, but a transformation technique from time domain
    to the frequency domain.
    Please read more about filters here:
    http://zone.ni.com/devzone/nidzgloss.nsf/73771f0cc7381bc986256879000d6a1e/829980731a4cd570862568c50006ab83?OpenDocument
    I hope this answers your question. If not, please let me know,
    Regards,
    Message Edited by Juan G on 02-04-2008 01:23 PM
    Juan Galindo
    Applications Engineer
    National Instruments

  • Decimating for novice help

    1) I have 3 channels sampling at 30,000 samples per second for 60 seconds. I am handling the acquisition and putting the data in arrays of integers (I32).
    2) I need to decimate them down to 100 samples per second in order to get rms noise from the white noise generated by the input of the shorted ADC.
    To do this I need to ...
    1) I have been given 3 filter coeffiecents files which I need to use in a multirate FIR filter.
    2) The product of this needs to be used to calculate RMS and Mean.
    I am not asking someone to solve this for me. But to state the feasability of using labview to run a multirate FIR with predetermined co-effiecents.
    This is my first attempt at using FIR filters and my calculus is a little rust. So be gentle.
    I have attached the first of 3 sets of coeffients.
    Solved!
    Go to Solution.
    Attachments:
    fir1Sps100.txt ‏5 KB

    Hi BeanBoy,
    You can see how the FIR Filter VI works in the detailed help here, which says:
    The FIR Filter VI obtains the elements of Filtered X using the following equation.
    where y is Filtered X, Nb is the number of FIR Coefficients, and bj is FIR Coefficients.
    The inputs of the FIR Filter .vi are a 1-D array of X values and a 1-D array of coefficients. All of the coefficients are used for EACH value of X calculated. The dimensions of the arrays do not need to line up. I threw together a quick example with 3 coefficients and 6 values in my input array. The output was a 1-D array of 6 values.
    So, in answer to your questions:
    Does the FIR Filter.vi remove the first N values from X, where N is the number of coefficients?
    No, FIR Filter.vi uses the coefficients to approximate for each value of X.
    What format does FIR Filter.vi expect the coefficients in? 
    A 1-D array of numeric data.
    Note: For Multi-rate FIR Filters, you may need to use the Digital Filter Design toolkit, to be able to use the Multirate FIR Design Express VI.
    Joey S.
    Software Product Manager
    National Instruments

  • Reading, filtering and playing large WAV files

    Hi!
    I want to build an application that reads LARGE wavefiles, filters them and plays them via the soundcard.
    I tried to build something with the standard blocks available in Labview 7.0, but I keep running out of memory. The files I want to filter and play are simply too large The filesize is typ. 650Mb = 1 hour of stereo CD quality audio. The files I am using just won't play even on a WIN XP machine with 1Gb of memory.
    Next step was to build a function that loads the WAV files in blocks of ~16kB. This works fine, but now the filtering does not work anymore; after each block, the 'FIR Filter' block seems to reset its states. The result is a very bad repeating artifact in the sound. The repetition-rate is related to the buffer size.
    Does anyone have experience with this type of application? Help and examples are -very- welcome (as I am new to Labview... .
    Many thanks,
    Dr.dB

    I have created a VI that will do the continuous FIR filtering you need. I assume you want to filter a 'stereo' signal so the VI takes an array of waveforms as input. In this version the FIR filter coefficients (kernel) is common to all channels. If this is not what you need you can correct the VI accordingly.
    The control 'algorithm' specifies whether the FIR convolution is internally performed in the time or frequency domain. Changing the 'algorithm' does not affect your result but affects your performances. Select time domain (direct) if your kernel size (number of FIR coefficients) is, say less than 100, otherwise select 'frequency domain'.
    Try the attached example and let me know if you have any problems.
    Attachments:
    continuous FIR filtering on multiple channels.llb ‏79 KB

  • What does the "option" input of the FIR Windowed Coefficients VI do?

    Here's the LV Help entry:
    option specifies whether to scale the FIR Windowed Coefficients. The default is 0.
    0 not scaled—Does not scale the FIR Windowed Coefficients.
    1 scaled—Scales the FIR Windowed Coefficients.
    Well that's....unhelpful. Scales them by what? Why?
    Solved!
    Go to Solution.

    Sorry, you are correct. I was looking at the data for FIR Filter.vi.
    For this one, if you double click the VI icon (this tip works for most VIs with white backgrounds) you can bring up the block diagram for that VI. In this, you can see that when the value is "not scaled" the VI produces coefficients based on the "FIR Windowed (uniform) Filter coeficient.vi" which then passed them to the "symmetric filter.vi".
    When the filter is “scaled”, then the program goes through a different process depending on the type of filter. When it is a low pass filter, the end coefficients are scaled by the sum (Coef/Sum). In the high pass filter, it weights the coefficients based on a ramp function and then sends them through an exponential so that looks like:
    coef / abs (sum (exp(ramp*-i*pi*0.5)*coef)). 
    In short, the coefficients are scaled by themselves and/or the cutoff frequencies (in the case of the bandpass filter)
    Hope this helps,
    Kurt P
    Automated Test Software R&D

  • FIR filter delay for multistage multirate filter

    I know that a FIR filter with N taps has a delay of (N -1 ) / 2 samples.
    If this filter decimates of a M factor, the decimated signal has a delay of (N - 1) / (2 * M) samples.
    I used this approach several times to calculate the exact delay of a FIR filter, when I know the number of taps.
    How can I calculate this delay if I design my filter using the vi "DFD NStage MRate Filter Design"?
    Vix
    In claris non fit interpretatio
    Using LV 2013 SP1 on Win 7 64bit
    Using LV 8.2.1 on WinXP SP3
    Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
    Using CVI 6.0 on Win2k, WinXP and WinXP Embedded

    if I'm right, this is what is called "group delay" or "phase delay" of the filter.
    Is there a LV function to get this info?
    Vix
    In claris non fit interpretatio
    Using LV 2013 SP1 on Win 7 64bit
    Using LV 8.2.1 on WinXP SP3
    Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
    Using CVI 6.0 on Win2k, WinXP and WinXP Embedded

  • FIR Maximum Frequency

    Hi,
    I try to design FIR filters with 501 coefficients (single symmetric coefficient set) an with max frequency > 650 MHz.
    Guess it should work because DSP48E1 max frequency is 740 MHz for 7-series -3 devices.
    Actually, it works fine if the number of DSP48E1 is very low, but max frequency decreases drastically as the number of DSP48E1 increases.
    Timing analysis gives the following results Constraint period is set to 1.425ns (700 MHz) :
    For a 13 coefficients FIR filter, timings are correct :
    Setup slack : 0.088 ns (748 MHz)
    Min Pulse width : 0.075 (741 MHz)
    For a 61 coefficients FIR filter, timings are :
    Setup slack : -0.142 ns (638 MHz)
    Min Pulse width : 0.075 (741 MHz)
    Worst setup timing is between DSP48_X0Y19 PCOUT and DSP48_X0Y20 PCIN, that is at a clock region boundary.
    Setup slack increases to 0.022ns, which is fine, if the FIR DSP slice column option is set to 20, 11 instead of the default value 31. Doing that, all DSP48 are in the clock region X0Y0.
    Unfortunately, that strategy doesn't work for 501 coefficients!
    Is there a way to improve the timing between PCOUT and PCIN at clock region boundaries?

    You can try to use Xilinx FIR compiler IP

  • Error in synthesizing SysGen FIR compiler

    Hi
    We have a SysGen project, which includes a bunch of FIR filters. We have defined their coefficients as MATLAB floating point arrays, which are quantized by the FIR Compiler block. When we try to synthesize the core (either through generate netlist or generate IP Block), we encounter a strange error when the core is being compiled. This does not happen when we generate a simple project including just one or two of these cores.
    The error is as follows:
    ERROR: array index -1 out of range
    ERROR: Illegal unconstrained array declaration "ci_rnd_const"
    Thanks in advance

    Hi
    Which version of vivado and Matlab are you using?
    Is this seen with 2015.2

  • ISE issues based on versions and FIR filters

    Hi:
    I am using Xilinx ISE 14.7 version and generated two port RAMS for Spartan 6 FPGA in VHDL.   When I generate my two port RAM, the RAM generated a signal called”Wea” with the type of STD_LOGIC_VECTOR (0 downto 0). My present VHDL signal type is STD_LOGIC which is connecting the this pin in the port map. So I have some type error when I compile. I try to change the type to STD_LOGIC in the generated RAM code, but I could remove the errors in type because the *. ngc file is made for STD_LOGIC VECTOR and not allow me to change to STD_LOGIC. Please give me any suggestion to my problem as soon as possible. I am struggling with this error more than two weeks now. It is kind of rotating.
    The ideal solution would be, if I can set “wea” pin with a bit, but I have not found the way of doing this in COREGEN. Please suggest
    I also have another question. Have anyone used the FIR compiler to generate FIR filter? Can I use this along with C code or VHDL code? How do I use this to customize my FIR filter?
    the sooner you reply the better would be?
    Thanks
    Hari

    Hi Hari,
    So you basically need to connect a std_logic signal to a port of type std_logic_vector(0 downto 0), is that right?
    How about
    std_logic_vector(0) <= std_logic
    I also have another question. Have anyone used the FIR compiler to generate FIR filter? Can I use this along with C code or VHDL code? How do I use this to customize my FIR filter?
    Yes, many many people use the FIR compiler. It's an IP core, so it will be delivered from coregen as a NGC netlist with a VHDL or verilog wrapper. It's not software; it's hardware.
    How exactly do you want to customize it? The core provides you with a ton of options including specifying different coefficients, reloading them, different architectures, etc. Make sure to read the doc for it and play with it in the GUI to get an idea.

  • ADjusting the sampling rate on a FIR filter?

    How do I adjust the sampling rate on a digital FIR filter? Thanks in advance.
    -David

    You should really start a new thread instead of posting to one that is 5 years old.
    To answer your question, it depends on your data. I don't use the DFD but with the filter functions in LabVIEW, if you pass a waveform data type to the function, then the waveform data type contains a dt value. So, set the DAQmx Read to return waveform data. If you are using low level filter functions where the input is a 1D DBL array, then the filter has to be configured. With the low level functions in LabVIEW, you use the various coefficients functions that have a sampling frequency input.

  • Forward and reverse coefficients

    Hi all, I am a newbie here.
    I am currently working on a filter project. I am required to design a filter in LabView based on the filter circuit and a list of coefficients given. (i have 512 coefficients here, so i dun think it is the 1 that i need)
    I was thinking of using IIR filter to achieve this. The problem that i am facing now is i do not know how to determine the reverse coefficients and the forward coefficients input to IIR filter.
    I would like to know if there is any formula or way to find these two coefficients? Is there any better way to create this filter in Labview?
    I would really appreciate if anyone can help me in this. thanks thanks =)
    Regads,
    Hauo Wah

    Hai,
    FIR or IIR filters are generic models that can be used to create other filters.
    Dive into dspguru.com website to get detailed info on digital filters.  I am attaching the smothing filter co-efficients vi along with this mail.  This vi ships along with the professional development system of LabVIEW not sure about 6.1 having this VI.
    The VI i have attached is converted to 8.0 version (i was able to convert up to that only!!) try converting to the version required.
    Feel free to post for any queries. 
    With regards,
    JK
    (Certified LabVIEW Developer)
    Give Kudos for Good Answers, and Mark it a solution if your problem is solved.
    Attachments:
    Smoothing Filter Coefficients.vi ‏21 KB

  • Fir notch filter design.(us​ing DFD tool kit)

    Hi
    We used standard narrow band lowpass FIR filter design vis to desin a filter which can filter out any signal between 0.1 hz to 5hz. This does generate a filter design but is of a very high order, hence takes a very long time to process the raw data. Our raw data is of about 5000 samples and probably need to have higher samples when acqiring in the lower band frequencies,(say 0.1 hz or 0.5 hz). 
    Presently the need is to design a filter with folllowing characteristics:
    1. Phase linearity to be maintained in the pass band.
    2. sharp cut off freq band (can be the best possible to optimize speed of computation).
    3. speed should be optimized.(require fast)
    4. signal is mostly sign waves with noise riding on it.
    5. High sampling rate is necessary to maintain the shape of the sign wave since we are more concerned with the phase of the input signal.
    I have attached the snap of our design, (we used "DFD Narrowband Filter Design.vi"), which already uses the cascading technique.
    thanks and regards,
    sunil
    Apna Technologies and Solutions
    Bangalore,
    Karnataka,
    India
    Attachments:
    snap of FIR narrow LPF.JPG ‏63 KB

    Hi,
    Thanks for the reply.
    The vi is designed but we are having an issue of speed of processing.
    This filter takes a long time to process.
    We are looking for the following:
    Since our signal can range from 0.1Hz to 5Hz our sampling freq needs to be higher, about 8000 samples/s, this is necessary since the shape needs to be maintained for accurate phase measurements (the signal is always sinewave and with noise on it).However you may suggest this sampling rate based on your experience.
    Since the phase in the pass band needs to be linear we have to select FIR and since the filter roll off needed is very sharp as provided in the attachment, the resulting design has a large number of taps(coefficients), this makes the processing slow.
    --What would be the appropriate sampling frequency for such a filter design.
    --Is it that such filters are slow, if so how can they be put in the front end filtering of signals acquired from a daq (PCI-6229)analog channel in a continuous acquisition mode.
    we would be thankful for a quick response.
    PLS refer to the attachment for filter characteristics.
    thanks & regards,
    sunil
    Apna Technologies and Solutions
    Bangalore,
    Karnataka,
    India

  • Taps in digital FIR filter.vi

    I'm trying to use the digital fir filter.vi and while most things seem to behave in a reasonable fashion, the number of taps does not. Using the FIR filter help  I implemented the vis shown in the help section  with the digital FIR filter.vi and the results (magntidue) agree very well with what is asked for in terms of cut-offs and drop off rate. However, given that I'm using a unit impulse function as the input waveform, the output of the filter vi should be the coefficients of the filter. When I graph those, it is immediately apparent that it is using way more coefficients than I asked for. It quickly became apparent that it is completely ignnoring whatever number you put in for # of taps. Now to a certain extent I understand that. In order to get ever sharper cut-offs you should need more and more points. The question is, why is the number of taps an input if it is ignored or am I missing something?
    The other somewhat worrying question has to do with the convolution process. If the filter is using a very large number of taps, there should be a massive delay at the start. I don't think I'm seeing that.

    Hello Russo,
    Your code looks like it is set up effectively. I spoke with our development team about your question regarding the Digital Filter VI.  They confirmed that when Topology is FIR by Specification, the VI reads the filter specification and estimates an order. Then, it calls Parks-McClellan VI to design the filter. That is to say, #Taps is actually not used in this case. When Topology is Equi-ripple FIR or Windowed FIR, the #Taps is used for filter design. You can verify it by checking the order which is equal to #Taps - 1 in filter information output.
    If you are interested in a more advanced filter design application, I would suggest you consider checking out the LabVIEW Digital Filter Design Toolkit.
    Here is a link to an informative article comparing the LabVIEW Development VIs and the Toolkit VIs:
    http://www.ni.com/white-paper/4851/en/#toc2
    Warm Regards,
    Josh

  • Mathscript​/Matlab fir1 function vs. LabVIEW FIR coefficien​t?

    I'd like to convert some Matlab/LabVIEW Mathscript function into LabVIEW block functions, because it's faster.
    One of the function I'm not sure is the FIR function: I have a Mathscrip function fir1(n,W), is "FIR windowed coefficients" its LabVIEW equivalent?  If yes, how should I match the parameters (e.g. is W the high or low curoff frequency? is Order n the same as the number of taps)? If no, which LabVIEW function should I use?
    Thanks.

    Hi pji,
    I don't have LabVIEW, but I found some really useful resources in LabVIEW Help (open labVIEW>>Help>>search the LabVIEW Help>>search)
    Search for fir1 and it contains the syntax, paramter definition and some example codes which you can simply copy and paste and run
    b = fir1(n, w)
    n: Specifies the filter order. n is a nonnegative integer.
    n must be even for filters with a non-zero gain at the Nyquist
    frequency. If n does not meet this condition, LabVIEW increases
    n by 1.
    w: Specifies the cutoff frequency of the filter. w is real number
    between 0 and 1. 1 represents the Nyquist frequency.LabVIEW Help has abundant information, check it out!!!
    Van L
    NI Applications Engineer

Maybe you are looking for