LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filter signal problem

You are using Insert Into Array to insert at the beginning.  Then proceeding to take the beginning of the array and cutting off the end.

 

First, there is no reason to use Insert Into Array which is the wrong function to use about 95% of the time.  When you want to put an element at either the beginning or the end, use Build Array.   Much simpler.

 

But by putting it at the beginning, you are building your array in reverse.  It is much more logical to put new data at the end of the array.  Plus I think you'd want filter to work on the array working forwards rather than backwards.

 

 

0 Kudos
Message 11 of 24
(1,761 Views)

@RavensFan wrote:

You are using Insert Into Array to insert at the beginning.  Then proceeding to take the beginning of the array and cutting off the end.

 

First, there is no reason to use Insert Into Array which is the wrong function to use about 95% of the time.  When you want to put an element at either the beginning or the end, use Build Array.   Much simpler.

 

But by putting it at the beginning, you are building your array in reverse.  It is much more logical to put new data at the end of the array.  Plus I think you'd want filter to work on the array working forwards rather than backwards.

 

 


Thank you for hint,

 

But I think here is better solution: array is created on each iteration, but only 1 element is delated (instead of 100 as in your example).

The only "obscure" detail - the staircase step is about 75ms instead of 100ms as imposed by lower loop delay (please, see the screenshot below).

Any ideas ?

signal_filtering_works (0).png

 

 

staircase_sin_step_ambiguity.JPG

0 Kudos
Message 12 of 24
(1,726 Views)

That way works.  Delete from Array provides two outputs.  One is the deleted part, the other is the array that is left after the part marked for deletion is removed.  So changing the inputs and using the other output gives the same result.

 

Delete from Array can be tricky because you can put in special constants to expand its capabilities such as a negative index or negative length.  Leaving one input, or the other, or both unwired can give different results even from if you just wired up whatever the default input would be.  So those things combined with looking at the function from the opposite direction (i.e. "delete" what you actually are looking to keep) can be more powerful than looking at it straight up with positive values.  For me, I can't ever use it without experimenting to make sure it is giving me exactly what I want.

 

As for your graph, when I ran your VI by draggin and dropping the snippet to a new block diagram, the steps occurred 100 apart, not the 75 you are showing.  Double check the properties of the graph. Maybe you have a dT value set in there that is different from default.  That when I copied in the snippet, it may have just created a "default" waveform graph.

 

0 Kudos
Message 13 of 24
(1,719 Views)

I didn't find any dT option. Where is it ?

Another question - filtered signal doesn't evolve as original signal: original signal "floats" from right to left, whereas filtered has left end always attached to origin (please, see screenshot below)

Do you have the same behavior on your VI ?

 

staircase_sin_filtered_signal_attached_to_origin.JPG

 

 

0 Kudos
Message 14 of 24
(1,711 Views)

I've just tried your .png ... still 75ms Smiley Sad

0 Kudos
Message 15 of 24
(1,703 Views)

Mine still looks like 100.  Try attaching your VI instead of a snippet so I can be sure I'm running the exact same thing as you are.

 

The property I am talking about is actually called offset & multiplier.  Part of the X-axis properties.

 

 

 

I didn't know there was a second plot.  The visibility was turned off.  But yes, it starts at 0.  That's because the filter inherently starts from a zero condition.  You need it to remember the last state so the new iterations through the filter will be based on the previous iteration.  Wire a True constant into Init/Cont input so that it maintains that state.  (The default is False or Init which re-initializes that filter on every call.)

 

 

0 Kudos
Message 16 of 24
(1,697 Views)

Here it is (I added some other staff, that I'm actually working on).

Concerning X-axis properties, offset: 0, multiplier: 1.

0 Kudos
Message 17 of 24
(1,685 Views)

I realize what the problem is with the timing.  I noticed mine wasn't always 100.

 

You are using Get Notifier Status.  It has no wait or timeout input to it.  Your upper loop is running as fast as it can.  The bottomm loop is running every 100 msecs.  So depending on how fast the upper loop runs determines how many datapoints it gets out of the status before it detects the notifier was updated.  Mine is runnng faster and ran nearly 100 times.  Your is running slower and only ran about 75 times.

 

Why are you using Get Notiifier Status?  Why not Wait on Notification?  Or use a queue?

0 Kudos
Message 18 of 24
(1,679 Views)

@RavensFan wrote:

I realize what the problem is with the timing.  I noticed mine wasn't always 100.

 

You are using Get Notifier Status.  It has no wait or timeout input to it.  Your upper loop is running as fast as it can.  The bottomm loop is running every 100 msecs.  So depending on how fast the upper loop runs determines how many datapoints it gets out of the status before it detects the notifier was updated.  Mine is runnng faster and ran nearly 100 times.  Your is running slower and only ran about 75 times.

 

Why are you using Get Notiifier Status?  Why not Wait on Notification?  Or use a queue?


I've already tried with "Wait on Notification", frankly speaking I've started with this option. Unfortumately with "Wait on Notification" I can't obtain staicase-shaped sinus because upper loop wait for notification from lower loop and doesn't effectuate its proper iterations, that are more rapid.

I'll try with queue.

 

Concerning filtered signal, that is "stuck" to the origin, you were right, with Point-by-Point filter filtered signal evolves "properly".

0 Kudos
Message 19 of 24
(1,673 Views)

Sinus?  As in a nasal cavity?  Or sine wave.

 

 

For what you are doing, even a notifier is overkill.  It is a glorified version of a local variable.  A local should be okay be cause you'd be writing in only 1 spot.  And you don't seem to care, or actually you want to get duplicate values.  And you aren't going to lose values because your consumer/slave loop is running much faster than the producer loop.

 

You need to see how long your loop actually takes to run.  You have a 1 msec wait in there.  But with only ~75 samples for every 100 msec update of the notifier, your loop must actually be running about 1.33 msec per iteration.

 

Try increasing your wait to 2 msec per iteration to get consistency on the lengths of the stair steps.

0 Kudos
Message 20 of 24
(1,659 Views)