08-21-2014 03:29 PM
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.
08-22-2014 08:09 AM
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
08-22-2014 09:35 AM
Brilliant! Thank you so much for your work on this.
08-22-2014 10:24 AM
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.
08-22-2014 03:54 PM
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.
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:
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:
Lastly, here is the noisy data I'm dealing with:
Here is the data after I apply a 5Hz filter to each one:
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!
08-25-2014 04:04 PM
Are you reading the inputs in from consecutive channels by chance?
If so, read through this: http://digital.ni.com/public.nsf/allkb/73CB0FB296814E2286256FFD00028DDF
08-27-2014 09:19 AM
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".
08-27-2014 12:11 PM
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".
08-27-2014 12:13 PM
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....
08-28-2014 04:53 PM
I just want to clarify. You choose the clones, not just reentrant.