LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Lowpass filtering an array of waveforms with different cutoff frequencies

I'm trying to take an array of waveforms and have seperate filter settings for each individual waveform. For example, I want to have a 2 hz cutoff frequency on my thermocouple inputs and a 100 hz cutoff frequency on a strain gage input.

 

When I try to accomplish this using the Butterworth filter (as shown in the image) I get weird results. The VI seems to be setup to only handle 1 waveform at a time. If I set the init/cont to F for init, the beginning of each waveform segment is reset to 0 which wrecks the data files. If I set the init/cont to "T" for continuous, the data is completely wrecked because the waveforms are interferring with each other.  Clearly this VI is not setup for muliple instances (for use in a for loop).

 

There are the Waveform filters, but I seem to only be able to use 1 cutoff frequency for the entire set of waveforms.

 

In the subVI image below, I input an array of waveforms into a for loop with the settings collection for each channel (element in the waveform array). I pass the cutoff frequency to the butterworth filter with the Y data array from the segment of the waveform.  Waveform data is supplied continuously (I need a live data filter).

 

Thanks for your input.

 

0 Kudos
Message 1 of 12
(6,589 Views)

I think you need to do two things to make it work:

1. Make the subVI containing the filter reentrant, pre-allocated clone.

2. Use Start Asynchronous Call and Wait on Asynchronous Call to call the reentant filter VI and recover the data.

 

To make 2 work over the array of waveforms an index variable is also required.

 

Please read multiple pages of the detailed help for these functions and modes. Those will explain much better than I can the reentrancy and call by reference processes.

 

To make this example work you will need to set VI path to the location of Filter Duplicator.vi on our system. You may also need to re-link the type specifier reference at Open VI reference. Pop up on the reference: Select VI Server Class >> Browse... and browse to Filter Duplicator.vi.

 

The init/cont line on the filter VI must be True the first time each clone is called so that the cutoff frequencies are entered. It should be False on subsequent calls to avoid the filter transient.

 

Lynn

Download All
Message 2 of 12
(6,543 Views)

Brilliant!  Thank you so much for your work on this.

0 Kudos
Message 3 of 12
(6,536 Views)

I think you may have your true/false mixed up.  From the help:

 

"To process a large data sequence that consists of smaller blocks, set this input to FALSE for the first block and to TRUE for continuous filtering of all remaining blocks. "

 

But maybe I'm missing something.

0 Kudos
Message 4 of 12
(6,533 Views)

You are correct (about the true/false on the cont/init input).  Not sure I follow what the help is saying to do...

 

Is there anyway to verify the number of instanced "Filter Duplicates" are running? I'm still having a lot of issues with my implimentation and I'm wondering if I'm not initializing everything correctly.  I've even added a button that should push a new re-initialization.  I'm trying to have an interface that allows the user to turn off and on the filter while data is be aquired.  Here is some of my code that I'm using to try and accomplish that, but after I've enabled the filter on multiple waveforms and hit my "re-initialize" button I still get bizarre data artifacts (like spikes) that would not be indicative of data on the other side of a low pass filter.  Thanks for any additional feedback.

 

I've modified your Filter Duplicate to have an "Enable" feature so that the waveforms that I do not want any filtering of are just passed through.

 

filter duplicate.png

 

I've tried to re-create the functionality of your Test multi-filter VI Server, but with the added boolean option to not have the filter performed:

calling function for filter duplicate.png

 

So when "True" is on init/cont input the VI is re-open by VI server and the true signal propagates to the Filter Duplicate Asynchronous call.  Here is a snippit from my main window call:

snippet of main window.png

 

Lastly, here is the noisy data I'm dealing with:

noisy data.png

 

Here is the data after I apply a 5Hz filter to each one:

filtered data still sucks.png

 

Clearly data from one is being imposed on the other.  Hitting my "re-initialize" button to send a "true" signal through doesn't fix it.  How can I verify that my filters are working independently as desired?

 

Thanks!

 

0 Kudos
Message 5 of 12
(6,520 Views)

Are you reading the inputs in from consecutive channels by chance?

 

If so, read through this: http://digital.ni.com/public.nsf/allkb/73CB0FB296814E2286256FFD00028DDF

0 Kudos
Message 6 of 12
(6,479 Views)

I don't think this is related to ghosting or channel cross-talk.  If I apply my filter to just one of the signals, it looks fine.  The problem occures when I apply my filter to multiple channels.  I suspect that I'm not seperating the filter VI out into multiple threads properly and there is some memory "ghosting".

0 Kudos
Message 7 of 12
(6,453 Views)

Hi Johnsold - I don't think the code you provided is working correctly.  I think it only appears to work, but it is coincidental because the input is the same regardless of which is filtered.  I'm not 100% sure about this.  What I've done is added an offset to each of the 4 input waveforms in your "Test multi-filter VI Server.vi", and my observations are consistent with what I'm receiving in my application with live data (from physical sources).

 

The results appear to be consistent with what I would describe as "memory scrambling" between the various calls to the filter.

 

Below is the modification I did to your code.  I've added different offsets to the data.  Then I've collected the data into a window for presentation on a plot.  The original signal appear just fine in my plot but the filtered appear to be suffering from "crosstalk".

 

modifications to Johnsold VI.png

 

result plot from multiple runs.png

0 Kudos
Message 8 of 12
(6,442 Views)

I'm honestly considering just padding my input signal to the filter VI with a "mean" and then cropping it out before I reform the waveform....

0 Kudos
Message 9 of 12
(6,439 Views)

I just want to clarify.  You choose the clones, not just reentrant. 

0 Kudos
Message 10 of 12
(6,405 Views)