LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

best way to implement IIR vi

Solved!
Go to solution

First,  no signal processing toolbox!!

 

I have an IIR filter to implement in a vi.  My only trouble is that the filter has stored data states that must be maintained between calls.  This vi will only handle one signal source so it can store the filter state in the vi.  It should have one input and one output.  So for the data kept between calls to this vi should I use global variable or ?????

 

 

0 Kudos
Message 1 of 6
(2,599 Views)

You are writing the code so you can do it any way you want to. You can read it from a file and place it in memory somehow. You can set up an ini file and send it to a global. You can make it a constant and read it when you need to. There are many ways to accomplish this. You have to decide which way works best for you. If you think the filter will ever change or you want flexibility then I would read it from a file. If it will never change then make it a constant. There is no right way to do this unless you write a document that specifies the use somewhere.

 

This is the beautiful part of writing your own code. You can do what ever you want to do.

Tim
GHSP
0 Kudos
Message 2 of 6
(2,582 Views)

Sorry i wasn't clear.  My understanding is the every time a VI is called the variables inside it are cleared.  I need a way to preserve the values between calls.

 

Thanks

0 Kudos
Message 3 of 6
(2,578 Views)

Write them to a shift register.

Tim
GHSP
0 Kudos
Message 4 of 6
(2,576 Views)

""Write them to a shift register.""

 

Will that work within a vi that is called repeatedly?

Sorry I am amateur LV programmer.

 

could I use a string of feedback node in the sub vi.  That would have the effect of accomplishing the necessary shift.

0 Kudos
Message 5 of 6
(2,566 Views)
Solution
Accepted by topic author snarkysparky

Hi sparky,

 

So for the data kept between calls to this vi should I use global variable or ?????

The "usual" way is to use a shift register (or feedback node).

No need for additional files to store data or globals!

 

Will that work within a vi that is called repeatedly?

Yes, sure!

 

Sorry I am amateur LV programmer.

No need to say "sorry". You should take those beginner tutorials offered in the "Training" section in the header of this LabVIEW board as a beginner…

 

Hint: your filter VI should be made reentrant - as are the filter VIs coming with LabVIEW…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 6
(2,544 Views)