02-15-2019 12:51 PM
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 ?????
Solved! Go to Solution.
02-15-2019 01:55 PM
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.
02-15-2019 02:02 PM
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
02-15-2019 02:04 PM
Write them to a shift register.
02-15-2019 02:36 PM
""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.
02-17-2019 11:33 AM - edited 02-17-2019 11:35 AM
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…