09-09-2021 07:50 AM
Hi I am currently trying to implement a low pass butterworth filter in my labview program and it reduces the spikes as I wish however it changed the position of the y scale value. Is there anyway this can be resolved so it can maintain thesame y scale value.
09-09-2021 08:38 AM
Nope, that is not how filters work, y-axis value cannot remain exactly the same. Even in the passband, there is some attenuation based on the filter type.
Can you share the VI with some sample data for review?
09-09-2021 08:38 AM
I take it you have not had a class in Signal Theory, correct? Low-pass filters introduce a phase lag, meaning the filter's response comes later than the response in the signal.
Suppose I have a signal that is zero up to time t, then becomes 1 thereafter. I make a "Box-car averager" (a simple low-pass filter) by replacing every data point with the average of that point and the previous 4 points. [I can't "center" the Box-Car on the current point as I haven't yet acquired the next two, unless you've got a way to sample future data ...]. So my filter output is 0 up to time t, then becomes 1, 2, 3, 4, 5, 5, 5, 5, ... Do you see how the "time delay" (or shift of the Y value to the right) occurs? All Low Pass filters introduce a Phase Lag, which shows up as a Time delay (or shift to the right).
Bob Schor
09-09-2021 08:39 AM
Hi Obed,
@Obed41 wrote:
implement a low pass butterworth filter in my labview program …
Is there anyway this can be resolved so it can maintain the same y scale value.
No.
A (butterworth/low pass) filter will always influence the amplitude values. That's how those filters work…
09-09-2021 09:23 AM
Everyone's responses are right, but let me approach from another angle.
Your question is far too vague to give rock solid advice, but based on the very tiny hint we get from your photo, there are 2 (or kinda 3) separate factors that can make the first element of the filter's output so much smaller than the first element of its input.
One factor is simply about amplitude gain. And others have already said that the gain for a simple Butterworth filter will ALWAYS be < 1. However, it's also usefully close to 1 for frequency content well below the cutoff freq. I carry a little rule of thumb in my head that at about 1/3 the cutoff freq, the filter only attenuates by about 0.5%.
A second factor relates to a combo of Bob Schor's discussion on phase lag and the fact that a filter will also exhibit a transient response. The time it takes to work out its transient response more-or-less corresponds to the amount of phase lag you get. The *very first* output value from the filter that you focused on is almost certainly being affected by this transient.
A kinda third factor is that you never defined your data's sample rate or the filter's cutoff frequency in your call to the Butterworth function. It's just using default values that probably bear no particular resemblance to your actual sample rate or cutoff freq needs. You *also* need to wire appropriate values as inputs to the function. (Note: for lowpass filtering, only the "low cutoff" input is used.)
-Kevin P
09-09-2021 10:49 AM - edited 09-09-2021 11:02 AM
You've already got some good advice but most seem to be missing the point. You seem to have two channels that you are trying to chart, meaning you only get one scalar point each per iteration and "filtering" an array with two element (one for each channel!) Makes absolutely no sense. To filter each trace, maybe feed each through a ptbypt filter instead.
Do you only what to filter for the chart display or also for the data accumulating in the shift registers?
Beside signal theory, I would also recommend a refresher in LabVIEW programming. It would help to see the entire VI and also some typical data that you are trying to filter. "Noise" and "spikes" are two very different things. Do you know what causes them? Maybe a simple analog filter would be more appropriate.
Why are there so many local variables? Where are their terminals?
Converting a 1D array to a 2D array with one row it not needed for charting two scalars. A bundle is more typical.
Index array is resizable?
Properties only need to be written when they change. Why would you hammer the yscale property with them same constant over and over? Shouldn't that belong before the loop (or even configured for the chart directly)?
etc.
06-17-2022 02:32 PM - edited 06-17-2022 02:58 PM
Hi knights of NI-
I feel like many NI customers are not posting their questions in here because of the kind of responses they get from many of you.
E.g., "I take it you have not had a class in Signal Theory, correct?", "Beside signal theory, I would also recommend a refresher in LabVIEW programming" etc.
I know you guys can do better helping people use NI products and keeping the forums a safe intellectual harbor for NI users.
There is no need to belittle someone or imply that he/she is uneducated because he/she doesn't know something. Spoiler alert, you guys don't know everything either.
Thanks for reading (end of rant)
06-17-2022 03:19 PM
Erwin,
Your point is well-taken. It is frustrating when trying to help someone to learn LabVIEW (as opposed to "do my assignment for me") and there appear to be glaring gaps in their knowledge base that leads them to ask "the wrong question" (or, perhaps, what seems to be the wrong question because we are "talking past each other").
I will try to be more patient.
Anonymous BS
06-20-2022 02:49 AM
@EFranz wrote:
Hi knights of NI-
...
Thanks for reading (end of rant)
Three "Knights" contributed to this (quite old!) thread, so we all take offense in a (self described) long rant that does not really belong here, because it does not answer the question. There are probably better places to showcase your Monday morning rant than in an old technical discussion.
It is often difficult to strike a delicate balance between paragraphs of cheerful empty platitudes and encouragements and bluntly telling the truth. Nobody is an expert in doing that. Posts are just text and interpretation can vary wildly based on many factor (time of day, mood of reader, education, native language, etc.) No amount of smileys can fix that.