03-15-2012 07:35 AM
Hello everyone. I'm currently trying to filter a signal by using the Butterworth filter vi included with LabView. The problem I have is that it's a real-time signal which get sampled at a certain rate with a certain block of samples. The filter seems to be doing its work fine for all the samples in the middle of the block, but for the first part it doesn't.
I've attached two picture to show the difference with and without the filter. It's basically a sine wave.
I believe the problem comes from the filter convolving with the input signal and distorting the signal this way. I was hoping people could affirm this is the problem and help me find a way to a solution.
I can show you my code as well, but I believe this is a general problem with filtering, rather than my code. If you think I am wrong please tell me.
David.
Solved! Go to Solution.
03-15-2012 08:35 AM
I think what you see is the step response of the filter because the waveform doesn't start at zero.
Cheers
Edgar
03-15-2012 09:33 AM
There is an initialize input on the filter (init/cont). If you are acquiring into a loop, this must be set to FALSE the first time throught the loop and TRUE after that. This may be the problem.
Can you post your code?
03-15-2012 09:51 AM
The code is in a consumer loop of a producer/consumer loop which acquires signals from several channels.
I've attached the code.
03-21-2012 08:25 AM - edited 03-21-2012 08:33 AM
Hi, I've just retested the code and it doesn't actually seem to work, even with the init/cont thing changing after the first iteration.
I'm not sure why I thought it worked last time.
EDIT: I figured out why. It's because I am using multiple channels, so the filter's last settings are using the wrong channel's settings. Any idea how to fix this.
At first I was testing with just one channel. It works with that.
03-21-2012 08:39 AM
Your digital input is outside of the loop and therefore will not change once the program starts. Try this.
03-21-2012 08:50 AM
Thanks Mr Pursley, but that is not the problem, this is a subVI, so the Boolean is one of the connectors inside another while loop.
03-22-2012 06:34 AM
Any more ideas ?
I still don't know how to make this work. The only way I can think of is to filter each individual channel with a different filter. But that defeats the purpose of having nice clean code...
03-22-2012 10:19 PM
OK, now I understand.
I believe in LabVIEW 2009 they introduced For Loop Iteration Parallelism.
If you right-click the edge of the For Loop and select 'Configure Iteration Parallelism' and enable it, this will solve your problems. If it doesn't check and make sure the Filter VI is set for re-entrant. It is in later versions, but I can't check LV 2009 right now.
Enabling this, will create a clone of the filter function for each iteration.
03-23-2012 06:03 AM
Hi,
Thanks. That would work if the number of channels are always the same I think as you need to predefine the number of instances generated.
Am I wrong in thinking that ?
I still need to test it, but I think I might have managed in another way by using a more basic version of the filter.
The IIR Filter VI allows for multiple signals and according to the help :
"If you are filtering multiple waveforms, the VI maintains separate filter states for each waveform."
So I'm crossing my fingers. Please let me know what you think 🙂