LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filter signal problem

Hello,

 

In the VI below I try to filter noised staircase-shaped sinusoidal signal.

As you can state after having run the VI at the filter output no any signal (i.e. zero signal).

Starnge ... because generated signal frequency is 0.1Hz, cut-off frequency is 1Hz.

 

Where is a problem.

 

Thanks

 

Pavel

 

filter_noised_staircase_SIN (0).png

 

0 Kudos
Message 1 of 24
(4,637 Views)

Pavel,

 

you really have to learn to use Shift Registers. Your code with the array in the second loop makes no sense at all.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 24
(4,629 Views)

I may be wrong, but I think the Filter wants segments of a Waveform, not "sliding windows".  For example, if I have a waveform with 10,000 points, I can pass 1000 points at a time through the filter (that would be 10 passes, 10,000 points in and 10,000 points out).  What you are doing is passing the first 1000 points in, then points 2 .. 1001, then points 3 .. 1002, or something like 9,000,000 points in, with almost no change between the first 1000 points and the second.

 

Did you notice that the X axis of the filter is increasing much faster than the X axis of the signal being filtered?

 

Bob Schor

0 Kudos
Message 3 of 24
(4,622 Views)

Bob,

 

good observation with the segment and the faster running loop.

 

However, there are the Point-by-Point filter functions available in LV which would address this 'issue'.

But the code in the screenshot uses the "normal" filter. That's why i wrote that the array meddling doesn't make any sense....

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 24
(4,607 Views)

... and I completely agree with you, Norbert.  I think we were replying at about the same time (I didn't see your post before I sent mine).  

 

The key step is that if users need to process signals, then not only do they need to understand something about DataFlow (in order to understand how to use LabVIEW), but they also need to understand "signal flow" and "signal processing".  Just because NI gives you an "Express VI" which "looks easy, I don't have to know anything to use this, just connect the wires", that doesn't make it so.  Understanding what you want to do should always precede slapping some Express VIs and LabVIEW functions together!

 

Bob Schor

0 Kudos
Message 5 of 24
(4,582 Views)

Norbert_B a écrit :

Bob,

 

good observation with the segment and the faster running loop.

 

However, there are the Point-by-Point filter functions available in LV which would address this 'issue'.

But the code in the screenshot uses the "normal" filter. That's why i wrote that the array meddling doesn't make any sense....

 

Norbert


Thanks Norbert,

 

The Point-by-Point filter does the job.

Concerbing shift registers ... I didn't catch your idea. You mean "create" several shift registers at the left side of while loop and, using corresponding multiplying coefficients, add all members to create filter output. Correct ?

If so, such solution implies user-defined filter synthesis (instead of using ready-to-use blocks, provided by LabVIEW).

Thanks for clarification.

Best Regards

 

Pavel

0 Kudos
Message 6 of 24
(4,522 Views)

Your problem is your array handling.  Each iteration of the while loop, you are intializing an array of 100 elements, all zero.  Then you proceed to take the single scalar from your notification, and insert it into the array at some point along its length (based on iteration counter MOD 100).   So now you have a 101 element array that is almost all zeroes, and one element actual data.

 

Then the next iteration, you throw all of that away and start over.

 

A shift register maintains your array between loop iterations.  And you almost certainly don't want insert into Array.  You should probably be using build array.  Even that will cause the array to grow indefinitely, so following it up with an array subset to keep it at 100 elements is probably what you want.

 

(Have you taken any of those tutorials yet?)

 

The point by point filters that Norbert and Bob are referring to are a good idea because it takes the data one point at a time, and maintains the history of that data inside using shift registers internal to the subVI.

0 Kudos
Message 7 of 24
(4,514 Views)

RavensFan a écrit :

Your problem is your array handling.  Each iteration of the while loop, you are intializing an array of 100 elements, all zero.  Then you proceed to take the single scalar from your notification, and insert it into the array at some point along its length (based on iteration counter MOD 100).   So now you have a 101 element array that is almost all zeroes, and one element actual data.

 

Then the next iteration, you throw all of that away and start over.

 

A shift register maintains your array between loop iterations.  And you almost certainly don't want insert into Array.  You should probably be using build array.  Even that will cause the array to grow indefinitely, so following it up with an array subset to keep it at 100 elements is probably what you want.

 

(Have you taken any of those tutorials yet?)

 

The point by point filters that Norbert and Bob are referring to are a good idea because it takes the data one point at a time, and maintains the history of that data inside using shift registers internal to the subVI.


Thanks RavensFan,

 

Indeed, array handling caused problem ... and shift register confirmed its omnopotence.

Here is an example with Low-Pass Filter from NI_AALBase library (not Point-by-Point).

Seems to work. The only problem - I didn't find how to put both curves on the same chart.

Apparently Waveform chart doesn't support bundled array-based curves.

 

Thanks

 

Pavel

 

 

filter_noised_staircase_SIN (1).png

0 Kudos
Message 8 of 24
(4,498 Views)

One thing I'd be worried with using the Replace Array Subset is that once you've been through the array once and start over at the beginning, you'll have a discontinuity in your data where you are currently writing.  Let's say you are half way through, and assuming a 100-element array like you originally had.  Then elements 50-99 are the oldest data, then element 0 would be the next point that immediately follows #99.  But it is now at the far end.  0-49 would all be newer elements that are preceding the older elements of 50-99.  That could make the filtering ugly.  Add to the end, and take away from the beginning would keep the order of the elements the same as they had come in.

 

For putting two lines on one chart.  I would consider using a Waveform Graph instead.  Look at the examples for Waveform graph to see how to structure the data (there are several possible ways) to plot the two on the same graph.   (the unfiltered array and the filtered array)

Message 9 of 24
(4,476 Views)

Yes, I noticed some strange phenomena ... some sort of translation that occured time to time.

Here is corrected version ...

What do you think about ?

 

filter_noised_staircase_SIN (2).png

0 Kudos
Message 10 of 24
(4,466 Views)