LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple software filter

So I've been exploring filtering, averaging, and anti-aliasing techniques to implement within our test lab due to the EMF noise that we inevitably pick up. I ran into this simple little algorithm that I thought would be easy to implement in Labview and gave it a shot. Basically, it looks something like this;

 

NV = LV + ((LV/1) * (NV - LV))

 

NV = New value

LV = Last value

 

Here's a snippet I threw together to try it out. It seems to work well, but I wanted to get other, more experienced with filters, etc... opinions before I overlook something important. 

 

 

 

-Ian

0 Kudos
Message 1 of 9
(3,279 Views)

Hi Ian,

 

"opinions before I overlook something important."

- The BD doesn't reflect your formula...

- You can join the reciprocal (which is available as primitive too) and the multiplication to just one primitive...

- You don't need extra numeric displays, the charts already offer them...

- It doesn't work for random numbers...

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(3,261 Views)

Ian,

 

One other point.  Anti-aliasing MUST be done in hardware, before the analog to digital conversion or any other sampling.  It cannot be done in hardware.

 

Lynn

0 Kudos
Message 3 of 9
(3,254 Views)

Mr. Lynn: 🙂

 

I think you meant to say 'It cannot be done in software." in your last sentence.

 

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
Message 4 of 9
(3,243 Views)

Correct.  Anti-aliasing cannot be done in software.

 

Just read what I meant, not what I typed.

 

Lynn

0 Kudos
Message 5 of 9
(3,226 Views)

Lynn, 

 

Not arguing the point, but could you explain why you say that? I actually use a similar bit of code in AB ladder logic to handle a noisy signal for an industrial controller that sits directly next to a 350HP, VFD driven, three phase motor, and it's generally worked pretty well for me as long as the signal stays positive (a problem which I'll readily admit will be an issue with this.) 

 

-Ian

0 Kudos
Message 6 of 9
(3,214 Views)

Ian,

 

If you look at the theory behind sampled data systems, you will find that if some interfering signal is aliased into your data it is impossible to separate it from the desired signal.

 

As an example suppose your desired signal varies from 9 to 11 Hz.  You are sampling at 50 Hz.  Some 60 Hz interference from the power line reaches your A/D converter.  That interfering signal will appear at 10 Hz and you cannot distinguish it from a "real" signal at 10 Hz.

 

Depending on the nature of the signal and of the interference or noise, a smoothing algorithm like that may help, but it does not eliminate the aliasing.  If you get into a situation where the aliased signal looks a lot like the desired signal, you will have problems.

 

Can you tell us more about the measurements you want to make and the nature of the noise or interference?

 

Lynn

0 Kudos
Message 7 of 9
(3,202 Views)

@johnsold wrote:

Ian,

 

If you look at the theory behind sampled data systems, you will find that if some interfering signal is aliased into your data it is impossible to separate it from the desired signal.

 

As an example suppose your desired signal varies from 9 to 11 Hz.  You are sampling at 50 Hz.  Some 60 Hz interference from the power line reaches your A/D converter.  That interfering signal will appear at 10 Hz and you cannot distinguish it from a "real" signal at 10 Hz.

 

Depending on the nature of the signal and of the interference or noise, a smoothing algorithm like that may help, but it does not eliminate the aliasing.  If you get into a situation where the aliased signal looks a lot like the desired signal, you will have problems.

 

Can you tell us more about the measurements you want to make and the nature of the noise or interference?

 

Lynn



Entirely true for uniformly sampled data.  HOWEVER, a sowftware anti-aliasing approach does exist by variy the sample rate between two related rates.  for instance a wafeform sampled at 100Hz becomes "Folded" at the sample rate so 20Hz, 120hz, 220hz .... are indistunguishable whereas sampling at 100hz and 66.66Hz (a 3:2 ratio) permits discovery of the "Folded" components doubling the effective range of frequencies that can be resolved.  3:4 and 4:5 ratios are also common in doppler weather radars to extend the range of radial velocity that can be recovered. 

 

Arguably. the sample clock is a hardware component but the anti-aliasing is done in software.


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 9
(3,165 Views)

Jeff,

 

Thanks for the tip.

 

This will work for stationary single frequency components.  For broad band noise or rapidly varying frequency signals like a chirp or spread spectrum, it will still be quite difficult or impossible to fully reconstruct the input.

 

There are a number of examples where additional knowledge of the signal can be used to recover data which appear to be beyond the Nyquist limit.  Undersampling is done intentionally in some radio systems to detect signals which are at a higher frequency than the sampling frequency.  In those cases there is essentially no signal energy in the "normal" Nyquist band so that only the alias is recovered.

 

Lynn

 

Message 9 of 9
(3,154 Views)