LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IIR Cascade Filter Implementation with imported coefficients

hi, here ya go. 
0 Kudos
Message 11 of 26
(2,569 Views)

Hi, Alias77,

Thanks for the VI. It seems that you saved the input data and filter coef to some text files. Could you please attach the files as well? Thanks!

And I try a bit butterworth filter in LabVIEW and Matlab with your specification. The coefficients from LV and Matlab are quite close. Please see the attached VI for details.

What does "unstable" mean in your post? Could you explain a bit more?

帖子被DSPmchen在08-22-2007 10:28 PM时编辑过了

0 Kudos
Message 12 of 26
(2,558 Views)
hi, yeah, i can see why that would be helpful.  i've attached the Matlab m-file that generates the coefficients and as well as the input and output.  the text files which are called in LabVIEW are from this program.  regarding "stable," i mean that the output after filtering using IIR Filter.vi in my program FiltTest.vi blows up and reaches a magnitude on the order of greater that 10.  the samples at the beginning of the output roughly coincide with what i see in Matlab.  because of this, i guess that the culprit is a transient response that grows and grows.

Message Edited by Alias77 on 08-23-2007 10:28 AM

Message Edited by Alias77 on 08-23-2007 10:29 AM

0 Kudos
Message 13 of 26
(2,550 Views)
well, i've narrowed it down.  i took your reverse (A) coefficients and used in my program.  i now get a stable output.  i'm not sure i know why...

LabVIEW needs more significant digits?

Message Edited by Alias77 on 08-23-2007 10:59 AM

0 Kudos
Message 14 of 26
(2,546 Views)

Hello all,

 

I too have that problem and on top of that, Labview keeps changing the last few numbers of my coefficients that i put in *from Mathlab*.

This creates the difference between the Mathlab and Labview filter *Butterworth Highpass 0,1Hz Cut off, 5th Order at 1000Hz Sampling* and possibly the unstable filter from Mathlab into Labview.

I experimented with removing some SOS coefficients decimals in the Labview filter and this works until i reput them into the filter bundle. At that point, Labview creates some numbers *up to the E-17th decimal* which i haven`t asked for nor want to have.

As an answer to "More Significant Numbers" , the Labview filter only needed 6 till 9 decimals to be stable *depending on the order etc*. But as i said above, Labview adds or changes some of these numbers so my findings are not 100% accurate.

Can somebody explain me why this happens and how to cancel the creation of those numbers?

Greets,

MstrES



Message Edited by MstrES on 02-25-2008 07:47 AM
0 Kudos
Message 15 of 26
(2,381 Views)
MstrES,

I want you to check out the LabVIEW 8.5 help document on Numeric Data.  This may give you some insite into why LabVIEW is exhibiting this behavior. 
Mark
NI App Software R&D
0 Kudos
Message 16 of 26
(2,355 Views)
Thanks for the reply,
 
I`ve read the Numeric Data link and i`m not sure i can "blame" the changing numbers on Floating Point standards. Correct me if i`m wrong, but doesn`t the floating point "changes" the number after a calculation? In my case, i put the numbers in an array-control and when i`m finished, the last number and the ones behind it *untill the E^-17 decimal* change. Not in a 2,4 to 2,3999 way, but in a 0,998 to 0,997893 kind of way. On the other hand, if i move the decimal indicator in the number a bit to the right *like multiplying by a thousand* the last few numbers are different from the first ones.
 
Nontheless i`m trying to search for the cause of the differences between Matlab Filters and Labview Filters. I`ve noticed you can`t pick the filter structure when making a Filter, only converting it to another structure. Matlab and Labview both use a different type of structure, that means i can`t compare the Filters without converting one of them first and thus inducing a possible calculation error causing the difference. *I`m using Matlab: IIR Direct Form II, Labview: Cascaded Second-Order Sections Form II Transposed, Butterworth: Highpass 0,1Cut off 1000Sampling 5th Order; Unstable in Matlab; Stable in Labview*
 
Perhaps if anybody has any experience in Filters and hopefully with Matlab and Labview both, i would like to know what the possible reasons could be why they are different.
 
Many thanks in advance,
 
MstrES
0 Kudos
Message 17 of 26
(2,345 Views)
Hi, MstrES:
 
Let's make your question more clear. You are using two filters:
1. Matlab: IIR Direct Form II,
2. Labview: Cascaded Second-Order Sections Form II Transposed, Butterworth: Highpass, 0.1 Cut off, 1000 Sampling, 5th Order;
then you found the filter in Matlab unstable while the filter you get in LabVIEW is stable? Is that right?
 
 Another point unclear is how the floating point number can change from 0.998 to 0.997893, it's true that 0.998 is represented as 0.997999999999999998 in LabVIEW(double precision) but I am not sure why it would be 0.997893? Could you show me under what circumstance can the 0.998 be changed so much?
 
As the question "Multiply a floating point number by a thousand, the last few numbers are different from the first ones", I think this is quite a common phenomenon because of the nature of floating point arithmetic. I am not sure whether you are using the single precision floating point numbers for computation, since this 'shift' effect is quite trivial for double precision computations.
 
Thanks.
0 Kudos
Message 18 of 26
(2,324 Views)

Hello Strong@NI,

I`m using/The generated filter is using double precision floating point. One of the coefficients from the Matlab filter i put in Labview is for example -4,997966718532833. When i put this in the array-controle, it says -4,99796671853283314. I just found it strange that the last 3 numbers would be 314 instead of 300 or 299 for that matter, but apparently it still is normal behavior from a floating point.

>Let's make your question more clear. You are using two filters:
>1. Matlab: IIR Direct Form II,
>2. Labview: Cascaded Second-Order Sections Form II Transposed, Butterworth: Highpass, 0.1 Cut off, 1000 Sampling, 5th Order;
>then you found the filter in Matlab unstable while the filter you get in LabVIEW is stable? Is that right?
 
That is correct. I want to examine the overal differences between the filters with the same proporties. I converted the Matlab filter structure to the Labview one and then it became stable. Labview to Matlab structure made the Labview filter unstable, but on both occations they weren`t alike the other filter. So i`m trying to figure out why they differ, but no succes sofar.
0 Kudos
Message 19 of 26
(2,317 Views)
Hi, MstrES:
I would like to explain the cause for your first question. The double floating point you got is -4.997966718532833, it's in fact unable to be represented by a IEEE compatible computer, a computer only can represent those numbers around it. To make it clear, the two representable numbers around it are:

        -4.99796671853283314 (precise, representable number)
        -4.997966718532833 (unable to be represented)
        -4.99796671853283225 (precise, representable number)

so when you input the number -4.997966718532833, it will be natural to use the nearest representable one to represent it, which is what you got in LabVIEW. This does not means Matlab have wrong results, if you use more digits to show the number -4.997966718532833 in Matlab, I suppose it will also be -4.99796671853283314.

As to the second question, I will reply it later. Thanks.

Message Edited by strong@ni on 02-27-2008 08:02 PM
0 Kudos
Message 20 of 26
(2,296 Views)