LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stacking reentrant DSP filters: point-by-point problem

Solved!
Go to solution

I’d like to “stack” the same DSP filter on a LabVIEW Waveform, meaning I’d like to run the same filter twice with different cutoff parameters. The first time, I’d get an intermediate Waveform, then I run it again with different parameters on that intermediate Waveform and get my final Waveform.

 

This is pretty straightforward until I try to run it on a point-by-point basis.

 

For example, I’m using a simple LabVIEW DSP filter (\vi.lib\Analysis\3filter.llb\Butterworth Filter.vi). The way it works on a point-by-point basis is that it is reentrant so it remembers its filter state between points. But if I switch cutoff frequencies every point, that would get the filter’s internal state confused.

 

I was thinking I’d just make a copy of the filter VI, and use the original VI for one set of cutoff frequencies, and the copy of the VI for the other. Hopefully that would keep the two internal filter states separate. Would that even work?

 

Even if it did work, it seems wrong to make a copy of a built-in LabVIEW VI. Once I upgrade LabVIEW versions, I’d be using two different versions of the filter VI.

0 Kudos
Message 1 of 6
(2,670 Views)
Solution
Accepted by topic author bmihura

The existing filter will work fine so long as you place separate instances of the filter VI on the block diagram (ie, don't put it in a for loop with different parameters for each iteration).  This works because it's reentrant (and set to pre-allocate clones).  If it were not reentrant, then you would have the problem you think you're going to encounter.

Message 2 of 6
(2,654 Views)

The LabVIEW Field Journal had a good series about VI states and reentrancy.  It might be a good thing for you to read up on.  The series starts here:http://labviewjournal.com/2012/02/maintaining-state-1/


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 6
(2,652 Views)

That's right, thanks.

0 Kudos
Message 4 of 6
(2,649 Views)

Hi,

 

I am trying to use the point by point filters as well and have run into a problem that seems fairly similar to this.  What I am doing is trying to filter multiple channels (48 to be exact).  Instead of having 48 different filters all over the block diagram I created a case statement that has 48 identical cases that run through to filter each channel - so it will miss a small amount of samples but loop runs fast enough this is not a concern.  Just to note this code is being using in a custom device in VeriStand and the interface with VeriStand works just fine so I don't think it has anything to do with that. Unforunately none of the channels are being filtered at all.

 

I originally had two channels with two filters outside of this case statement running this morning and everything worked great (I compared the output of the filter I made in LabVIEW to the same filter using a calculated channel in VeriStand - thay matched nearly perfectly).  I'm not sure what happened or why enumerating through several channels would cause everything to be unfiltered.

 

Maybe one of you might have a suggestion for a better way of doing thing - or I have attached the portion of the code that does the filtering - maybe an error can be spotted?


Thanks in advance for the help.

0 Kudos
Message 5 of 6
(2,586 Views)

I don't think you're showing us enough code to tell you what's going wrong.  If you're updating the inputs on every loop cycle, you're discarding a lot of data.  You might want to put the filtering case structure inside a for loop so it gets every channel every time.

0 Kudos
Message 6 of 6
(2,580 Views)