LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IIR Cascade Filter Implementation with imported coefficients

I'm currently trying to implement a 5th-order Butterworth bandpass filter in LabVIEW, whereas before I was using Matlab.  I've noticed Matlab and LabVIEW do not have the same coefficient calculation algorithm, and I'd like to exackly replicate the filter from Matlab in LabVIEW.  I've imported the coefficients (B,A) and have attempted to send them into bundle also with the filter type constant.  After sending the bundle into the IIR Cascade vi, i receive error -20066.  I looked up the error code, and found the following:

–20066 IIRFilterInfoErr The information in IIR filter structure is not correct

however, i'm not clear on what to do.  i removed the 1.00 coefficient for A.  The lengths of my A and B vectors are now both 10.  some help would be great. 

0 Kudos
Message 1 of 26
(5,313 Views)

Hi Alias,

Couple of questions for you. How do you know the algorithm is different? Could you attach a screenshot of your code and the results of the same functionality in another program to show the difference (i.e. what do you expect vs. what you are getting)? What version of LV are you using? Thanks!

Stephanie

0 Kudos
Message 2 of 26
(5,292 Views)
hi Stephanie, thanks for your response.  I've figured out what my problem was:  using the IIR Cascade VI as opposed to the plain IIR Filter VI.  The coefficients were presumably recalculated so as to conform to a multi-stage filtering process.  I now see a match between a filtered signal in Matlab and that same signal filtered in LabVIEW. 
0 Kudos
Message 3 of 26
(5,288 Views)

Glad to hear it! Good luck with your application!

Stephanie

0 Kudos
Message 4 of 26
(5,275 Views)
ugh. hi Stephanie, I'm having another issue that I thought had been solved.  If you could give me some advice, I'd appreciate it.

With the same filter coefficients and input signal, I get a stable output signal in Matlab using the 'filter' command, and I get an unstable output signal using the IIR Filter. VI.  I have absolutely no idea why this is happening - I didn't encounter it when I had thought I'd solved the entire problem earlier.  I've tried different specs and hence different coefficients but to no avail.  Does it seem possible that the filter could be stable in Matlab but unstable in LabVIEW?  If I switch over to just the Butterworth Filter VI using the same specs, I receive the same as I do in Matlab.  I figure I must be just implementing IIR Filter.vi incorrectly, but there doesn't seem like a whole lot that one can screw up.

Message Edited by Alias77 on 08-16-2007 05:50 PM

Message Edited by Alias77 on 08-16-2007 05:52 PM

0 Kudos
Message 5 of 26
(5,273 Views)
oh, and my signal is only 512 samples long, so i'm interested in just running the entire 512 samples into the filter at once.  therefore, i don't think i need to mess with the initialization input option on IIR Filter.vi.  Still, I gave it a shot, but the output signal became even more unstable after each iteration.
0 Kudos
Message 6 of 26
(5,269 Views)
My guess is that the "filter" command does what our Butterworth Filter does, but I can't check that. You can always open up our VIs and the llbs they call from within LabVIEW to compare. If you want you can post the code for me to take a look at and maybe the results you were getting with the filter command. Thanks!
0 Kudos
Message 7 of 26
(5,248 Views)
Hi, Alias77
Have you ever tried the function filter in MathScript?
0 Kudos
Message 8 of 26
(5,232 Views)
Alias, could you please post your VI so that we can have a look?
0 Kudos
Message 9 of 26
(5,199 Views)
hello,

yeah, i've tried mathscript.  it is too slow for my application, however.  i have to implement 13 bandpass filters on 160 channels of EEG data in as real-time as possible.  i was able to get mathscript to use the 'filter' command, but it was just too darn slow.
0 Kudos
Message 10 of 26
(5,185 Views)