Averaging effect in SNR - Page 1
Forum section: electronics / projects

author: ehilarioc
author_rank: Contributor
timestamp: October 09, 2015, 05:40:35 am
content: Hello, everyone.I've read this:http://ww1.microchip.com/downloads/en/AppNotes/00699b.pdf,this:http://www.ti.com/lit/an/slyt626/slyt626.pdfand this:http://elearning.vtu.ac.in/12/enotes/Ana_log_Mix_Mod_Des/Unit4-VPG..pdfIn the microchip pdf says that for a signal that has a BW of 1khz and is sampled with a 12bit SAR ADC at 20ksps I need an antialiasing filter. The requirements are:1. Cut-off frequency for filter must be 1kHz or higher.2. Attenuation of the signal to -74dB at nyquist frequency (in this case 10khz).3. The analog signal will only be filtered and not gained or inverted.The SNR formula is 6.02*N+1.76, where N is the number of bits of the quantization. However if I use averaging, the formula is a little different, SNR=6.02*N+1.76+10*log(K), where K is the number of samples averaged.If I use averaging (which is a kind of a digital filter+decimation all in one). Does that mean that the ideal antialiasing filter gain at the nyquist frecuency can to be 10*log(K) less?For example, if I have a 1khz BW signal, 12bit,32ksps. with K=16 samples. Do I only need -(6.02*12-1.76+10log(16) )dB gain (-61.95dB instead -72db) at 16khz for my antialiasing filter? Or that is not necessarily true?In the other hand, does the TI point of view, where the error of 1LSB at 1khz is the priority, is valid?... I mean, that is new stuff for me. I've never considered that in previous designs. In which situation the 1LSB error is more important than the attenuation of the filter at nyquist frequency?Regards,Edwin.

author: jrward
author_rank: Newbie
timestamp: October 09, 2015, 06:19:27 am
content: They go hand in hand. TI's article about 1 LSB error is just about where to put the corner frequency. If your signal is at 1 kHz, your corner frequency can't be a 1 kHz because it would be -3dB down and that would be counted as an error term. You need to balance the design of your filter so that it starts to roll off after your desired pass band (within the 1 LSB it mentioned) and has rolled off more than the desired dynamic range by the time you hit the Nyquist frequency.Any signal left after the Nyquist frequency will be aliased or "folded" back into your region of interest. When aliasing happens, it is generally considered noise (although it really isn't) and reduces your SNR.

author: coppice
author_rank: Super Contributor
timestamp: October 09, 2015, 07:11:49 am
content: As well as the analogue filter causing a 3dB roll off at the top of the 1kHz band, the averaging will cause additional roll off. Average 10 samples to make 1 is pretty similar to a ZOH sampler, and will have a similar sinc like response. Now you are about 6dB down at the top of the band.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 09, 2015, 09:30:09 am
content: Odd. That's not right, 72dB attenuation (i.e., 20*log(2^12)) at Fs/2 only applies if you need < 1 LSB error (due to aliasing of higher frequencies) exactly at the highest frequency you can sample. But that's not the point where it becomes a problem. If your signal is baseband, then the 0-1kHz range has the first in-band alias product at 19kHz, which gives quite a bit of help to your filter design. The insufficiently filtered 10-19kHz range will alias to 10-1kHz, which can be filtered digitally.So yes, as long as you include the aliasing effect -- you are quite correct, filtering can be traded off both before and after the converter.There should be a theorem about bandwidths -- you only want as much as you need, at each stage of the signal path, period. What's the first thing you should do after conversion? More filtering, of course! Depending on platform, that could be quite rich, or fairly modest. Even the most basic platform can do a simple sliding average (boxcar filter, has a sinc(f) response) at that sample rate; an AVR or PIC at typical speeds (10s MHz) should be able to do even more (e.g., several stages of biquad IIR filters, in a suitable filter characteristic -- from among the usual suspects, Butterworth / Bessel / Chebyschev / etc.). Even if it's just a simple 1-2-2-1, or 8 or 16 length sliding average, it's good practice.And what you're doing depends on how much noise the output should have. If only 0-1kHz signals are counted as output, then perhaps you won't even bother with digital filtering! The analog filter needs only to go from <pass band tolerance> dB at 1kHz, down to -72dB (ish) at 19kHz (for which a 5th order filter should do well enough, I think?).If the output needs to be clean -- essentially, whatever's reading that digitized 1kHz signal actually has more bandwidth than 1kHz -- and it needs to be cleaned up first, then you need either a very aggressive analog filter (it rolls off as sharply as necessary, just above 1kHz), or whatever product of digital and analog gives the same result (the dB's add, so you can trade attenuation in one filter for the other, making note of course of where aliasing causes it to fold back on itself).An example of "high bandwidth" and therefore sensitive signal processing might be, a zero-crossing detector for phase or frequency detection (the tight filter is effectively required because the zero-crossing decision is only made based on the samples nearest to zero: the filter incorporates proceeding samples as well, putting more data into that decision and making it more robust).Or a mixer process (like an audio effects pedal that does a ring modulator effect, or what have you), where aliasing again shows up, and you need to control the sidebands carefully.And if you don't truly need 1 LSB freedom from "noise", you can make the filter that much looser in capability. (Example: a more sophisticated zero-crossing detector that does a line or curve fit to the samples near zero; or best of all, a Hilbert or Fourier transform, which computes its answers from the totality of all samples in the array and is its own filter!)If your signal source isn't even that dirty, you might not need much if any filtering -- and indeed, aliasing might even be beneficial, too. If the source frequency and sample rate are harmonically locked, then no beat frequencies will be produced, and you can get something akin to equivalent time sampling. In that case, digital averaging (especially if it's done over an array of samples, binned based on a trigger time) effectively limits the bandwidth as usual, but it tightens the bandwidth to the same amount around every multiple of the sample rate (including 0, i.e., the original baseband fundamental signal).And if your signal is aperiodic in the first place (e.g., control loops), aliasing isn't a concern, and all those extra filters are only slowing down your loop -- in this case, you still want filtering, but only to reduce interference (especially e.g. switching ripple), with a minimal impact on response time.Tim

author: splin
author_rank: Frequent Contributor
timestamp: October 09, 2015, 03:24:43 pm
content: Quote from: T3sl4co1l on October 09, 2015, 09:30:09 amIf you are oversampling by a factor of 10 then you should see a reduction in noise of up to 10dB thus the antialiasing filter will need to be 82dB (ish) (72dB + 10dB) down by 19kHz assuming the passband is 1kHz and the sampling frequency is 20kHz.

author: AF6LJ
author_rank: Unknown
timestamp: October 09, 2015, 03:49:53 pm
content: Good discussion.following along.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 09, 2015, 06:06:13 pm
content: Quote from: splin on October 09, 2015, 03:24:43 pmExcellent point. Narrowing bandwidth effectively increases the bits (assuming the quantization is being disturbed by a sufficient amount of noise). Which by the way is still true of  hi- or band-pass type filters, not just low pass (i.e., averaging in the conventional sense).Tim

author: mark03
author_rank: Frequent Contributor
timestamp: October 09, 2015, 06:24:26 pm
content: Some information is missing: What is the spectrum of the original signal? If it is really bandlimited to 1 kHz (or 10 kHz), you don't need any antialias filtering at all. Of course, when we say "1 kHz BW" in the real world, that is often an approximation, as it may be in your case. But the requirements for antialias filtering will depend on the PSD of the junk out past 10 kHz, compared to your desired signal.You may not be interested in ways to make this even MORE complicated, but, there are alternatives to simple averaging in the microcontroller. You could implement a proper decimator using a low-pass filter followed by sub-sampling. Simple averaging is just a first-order approximation to that.I recently used similar techniques to squeeze 16 good bits out of the ADC on an Cortex-M MCU, starting with a datasheet ENOB of ~12 bits. We only needed output data rates on the order of tens of Hz. No antialias filtering was used.(Edit: Often a simple antialias filter is justified, merely to keep wideband noise from folding back into your signal upteen times.)