LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

low pass filter help

Hi all, 

 

I'm trying to read in a channel, filter the noise out (supposedly the noise is about 10Hz), and then provide visual feedback for forces. Without the filter, everything works as it's supposed to, with the connection being between the data output of the DAQmx read and the input of the array. But when I add the filter, I get the error: Analysis:  The following conditions must be met:  0 < f_low <= f_high <= fs/2. I'm not sure why I am getting this error and why it stops my feedback from occurring. I also have a version with a "nonexpress" filter but my feedback isn't working on this version either. both are attached!

 

Thank you!

Download All
0 Kudos
Message 1 of 13
(6,328 Views)

You have not wired any timing information to the filter VI. If nothing is wired to the fs (sampling frequency) input, the default value is 1 sample per second. The Nyquist criterion then makes the maximum frequency the filter can process less than 0.5 Hz. So 10 Hz violates that.

 

Wire the sampling rate value to fs.

 

Lynn

0 Kudos
Message 2 of 13
(6,305 Views)

Do you mean for the nonexpress filter VI version? I'm not getting that error with the nonexpress filter. I just don't get any feedback from my forces and the filter test waveform chart doesn't display anything. Could I have my cutoff frequency in the wrong place?

 

If it's the express filter one, I'm not sure how to change its sampling frequency. I didn't see fs under the detailed help anywhere, just the lower cutoff for the lowpass. 

 

I'm still new to Labview, so I apologize if my questions are silly and I seem a little dense... 😕

0 Kudos
Message 3 of 13
(6,271 Views)

I take part of that back! I have feedback for my filter test waveform, just not peak force 🙂

0 Kudos
Message 4 of 13
(6,268 Views)

We still have an issue going on. To further explain the program, the program displays peak ground reaction force (GRF) on a chart of someone hopping on a force plate. The program finds the peak GRF by using shift registers, essentially it displays force only when the GRF at the i-1 iteration is greater than GRF at both the previous and next iteration (Aim2Hop2014_v4run.vi). This works until we add a filter (Aim2Hop2014_filt_test.vi). We're not sure what the problem could be, but the case structure is always false for Aim2Hop2014_filt_test.vi, when we didn't have this problem for Aim2Hop2014_v4run.vi. The problem seems to be some lack of compatibility between the case structure and the data coming out of the filter. Does anyone have any ideas about how we can fix this?

 

Thank you!

Download All
0 Kudos
Message 5 of 13
(6,227 Views)

You still have not told the filter VI what the sampling frequency is. If you do not wire the fs input, it defaults to 1 Hz. For sampling at 1 Hz, the filter cutoff frequency must be less than 0.5 Hz.

 

Also, the cutoff frequency for a lowpass filter must be wired to the low cutoff freq: fl input. Read the Detailed Help for the filter VI for more information.

 

With those two errors the filter will return an error and an empty array.  You do not check for either of those conditions.

 

Lynn

0 Kudos
Message 6 of 13
(6,213 Views)

Thanks for your response Lynn. We actually had wired the sampling frequency into the Butterworth filter subVI, but the wires in that area of the diagram weren't very clear (I am working with emmaline35 on this project). I have cleaned up the wire diagram a bit (attached) and also labeled the troubleshooting charts we've included as to whether or not they give a data output. These charts output expected data except for filter_test_2, which is inside the case structure, so I'm pretty sure that the problem doesn't occur until inside the case structure. Unfortunately, we still haven't been able to figure what the problem with the case structure might be. The case structure works well until we put the filter in (see attached file from emmaline35's previous message on this topic), and the filter seems to be removing mostly noise rather than the real force data. Does any one have any suggestions as to what the problem might be with the case structure now that the filter is included? Thank you for your time.

-Brian Selgrade

0 Kudos
Message 7 of 13
(6,185 Views)

One major problem I see with your code is that you are doing calculations and comparisons coming out of the shift register.   But you never put any values into the shift register on the right hand side.  So the only things that come out are zeroes.  Zero is never greater than zero, so the result of the comparisons is always false, and nothing ever goes to the chart.

0 Kudos
Message 8 of 13
(6,162 Views)

There is a 1 in the shift register on the first iteration - the constants are hidden behind the timed loop inputs. This does not change the logic.

 

The filter is still not wired correctly. Wire the cutoff frequency value (10?) to the low freq cutoff: fl input, NOT the fh input! Please read the Detailed Help file for the filter VI. Here is what it says about the fh input:


high cutoff freq: fh is the high cutoff frequency in Hz. The default is 0.45 Hz. The VI ignores this parameter when filter type is 0 (Lowpass) or 1 (Highpass). When filter type is 2 (Bandpass) or 3 (Bandstop), high cutoff freq: fh must be greater than low cutoff freq: fl and observe the Nyquist criterion.


 

 

Other questions:

Do you really need a timed loop? The DAQ device probably controls the timing.

Will you be using other channels of data for other purposes? If not, why not change the DAQmx Read to 1Chan, NSamp?

Why not extract the timing information from the waveform and feed it to the filter VI? Then you do not need to change the program if the sample rate changes.

 

Lynn

 

Filter fixes.png

0 Kudos
Message 9 of 13
(6,156 Views)

You're right.  Those constants are seriously buried under the timed loop input nodes.  I didn't realize how bad that VI needed a block diagram cleanup.  Also, I now see there is a wire that goes to the right hand shift register.

 

I hope the original poster realizes this as a lesson in how important it is to have a clean diagram.

0 Kudos
Message 10 of 13
(6,147 Views)