LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

filter distorting signal

Solved!
Go to solution

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.

Download All
0 Kudos
Message 1 of 17
(2,738 Views)

 

I think what you see is the step response of the filter because the waveform doesn't start at zero.

 

Cheers

Edgar

Message 2 of 17
(2,732 Views)

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?

 

 

Randall Pursley
Message 3 of 17
(2,729 Views)

The code is in a consumer loop of a producer/consumer loop which acquires signals from several channels.

I've attached the code.

0 Kudos
Message 4 of 17
(2,729 Views)

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.

0 Kudos
Message 5 of 17
(2,695 Views)

Your digital input is outside of the loop and therefore will not change once the program starts.  Try this.

 

filter mod.png

Randall Pursley
Message 6 of 17
(2,693 Views)

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.

0 Kudos
Message 7 of 17
(2,692 Views)

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...

0 Kudos
Message 8 of 17
(2,677 Views)

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.

Randall Pursley
Message 9 of 17
(2,658 Views)

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.

Filter.png

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 🙂

0 Kudos
Message 10 of 17
(2,648 Views)