10-07-2015 01:46 AM
Not sure if I already mentioned it, but I am comparing the exponential weighted moving averager (EWMA) with the "normal" moving averager (MA) to filter noise from a signal which is at 0Hz. The noise is white noise, maybe sometimes a disturbing signal at from the environment at any frequency as I am measuring an acoustical signal. The SNR is around -50dB after pre amplifying and AA.
I am using these, as I am building a digital Lock In Amplifier and those two filters only have one value to change (e.g. alpha) to change TC and by cascading multiple MAs or EWMAs I can change the slope from 20dB/decade to integer multiples of that. That is why I dont use xxx tapped FIR filter or IIR filter which could get unstable.
My sample frequency is 48kHz and I am downsampling it with two 2 stage CIC filters to 93,75Hz (factor 512).
For the Moving Average, the problem is storing these values. As fs increases the number of samples, which has to be averaged to get the same TC as with a lower fs, are increasing, too. And with the BlockRam I am close to the limit. In order to get TC of 10s and higher with roll offs of 80dB/decade or more, I even have to decrease fs further.
For the EWMA it is different, the only problem here are the really small alphas. If alpha is getting smaller than 0,001 I decrease fs.
So 2 questions:
1, Maybe it is a stupid question, but averaging with 16 x fs is causing 4 more bits, as 2^4 is 16, right? 🙂
2, Any comment about the decimation factor or my lock in setup? (The 512 are copied from an other lock in made on a dsp)
kind regards
Slev1n
10-07-2015 03:14 PM
1. Yes. For every 2X, add one LSB (if you didn't already).
2. I don't understand the application enough to say.
I'm not that familiar with CIC filters, and would need to experiment quite a bit to discuss their details well. From what I've seen, they look like they would introduce some aliasing, especially with audio and noise. They probably do fantastic for video.
The EWMA is actually an IIR filter ( feed forward = [alpha, 0], feed backward = [1-alpha] ). I don't remember the procedure, but you can convert a double-stage EWMA into a slightly larger IIR, too.
----
It would take a little trial & error, but you may have better results from just a EWMA, then queue one sample out of 512, instead of the CIC, then EWMA.
----
A signal that is truely at 0Hz is DC, and most acoustical signals don't include 0Hz (the transducers usually filter it out). I'm assuming you mean less than 1 Hz, which is difficult but manageable.
The filters may be over-complicating the problem. If all you ultimately need is to lock in on a sub-Hz signal, there may be easier methods. For example multiply the input by cos(wt) and by sin(wt) (or use complex numbers, and multiply by r=1, theta=wt), and integrate the results over several seconds, or go through the EWMA with a much lower alpha.
10-09-2015 03:15 AM
Hey,
the acoustical signal is at 4kHz but by demodulating it with a sine and cosine at the same frequency, I shift the signal to 0 Hz and 8kHz (both having half the amplitude compared to before) now I filter everything above 0Hz. This demodulation is important to get rid of the noise by low pass filtering.
I use multiple stages of EWMA and MA to have a variable roll off. The multiple stage feature is not shown in the VI discussed here but the feedback is just delayed once more every additional stage and the input runs through the filter more than once.
The decimation factor of the cic is also variable, but as the rates are powers of two, the 0Hz gain of the CIC can set to 1 by bit shifting the output. Therefor I always get 24 bits at the input of the EWMA and I think 40bits should be enough at the EWMA. 🙂
The advantage of EWMA and MA are, that you can easily adapt alpha or the filter length M to get your wanted time constant. Using multistage makes variable roll offs (20, 40, 60...db/decade) possible.
The advantage of the CIC are unity gain at DC (but powers of 2 and bitshifting have to be applied) and variable rate change factors. Not having any multipliers is definitly good, too, regarding ressource issues. The aliasing introduced can be controlled or at least quantified by the number of stages used. I can only recommend the book I mentioned in my first post. Here implementing CIC, EWMA or MA are explained very detailed. Last point to mention, the lock in works with this setup at least at a SNR of -60dB.
kind regard and thanks for your precious time 🙂
Slev1n