• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Anti-Aliasing Filter

Status
Not open for further replies.

Dsp121

New Member
Hello,

I have a question regarding the application of anti-aliasing filters.
When we sample a DC voltage using an ADC or microcontroller, do we need to apply an anti-aliasing filter like in the case of AC voltages, please?

Thanks
Dan
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
That largely depends on the signal quality and noise.. Most of the time you will need some sort of anti-aliasing..

Take a resistive load ie a loadcell for example.. the analouge output will be very noisy... You will need to filter.
Take an output that passes by a noisy cable... This too will need filtering... In fact! The only time you wouldn't is when really fast sampling is required...
 

OBW0549

Active Member
When we sample a DC voltage using an ADC or microcontroller, do we need to apply an anti-aliasing filter like in the case of AC voltages, please?
Yes, unless you know for a fact that the DC voltage does not include any significant signal content above the Nyquist frequency (i.e., half your sampling rate).
 

Dsp121

New Member
Hi,

Great thanks for your help, Ian and Obw0549. Regarding my application then I surely need anti-aliasing, since it is a DC/DC power converter with relatively high current switching, therefore it is a noisy environment.
 

MikeMl

Well-Known Member
Most Helpful Member
Think of it this way: if the signal is dc (or slowly varying), then it is easy to filter. Usually just a series resistance and a low-leakage shunt capacitor placed right at the ADC input pin form an RC filter. Sometimes, you can utilize the output impedance of the voltage being measured instead of adding an extra resistor...

I use this all the time to sense battery voltage using Arduino and PIC. I want a high-impedance voltage divider that reduces the battery voltage to something within the ADC's range. So as not to load the battery, the divider output impedance is on the order of 50K or more. The ADC should be driven from an impedance less than 10K.

Rather than put an opamp follower between the divider and the ADC to satisfy the source impedance requirement, I use the shunt capacitor, which presents a very low source impedance to the ADC. The "low-pass anti-alias filter" is the time-constant formed by the product of divider output resistance and the shunt capacitor.

Since the battery voltage varies slowly, the time constant is chosen based on ADC sampling rate; not necessarily based on the battery voltage rate-of-change.
 
Last edited:

Dsp121

New Member
I think your idea is a very neat solution Mike, thanks. I was going to work using an LEM transducer followed by an opamp follower, and using a 2nd Order Butterworth filter for anti-aliasing. But your idea of a simple RC filter could do the trick as well, probably with less complications.
 

NorthGuy

Well-Known Member
If you're making a DC/DC switching converter, you need to be careful with the filter for measuring the output DC voltage. You certainly cannot treat it as DC, because if you don't control it correctly then it won't be DC. Instead, use a fast low-pass filter based on your sampling frequency. Also make sure that your sampling is not coherent with your switching/ripple - if you only measure the peaks of the ripple you will overestimate your voltage, if you only measure the valleys you will underestimate it.
 

Dsp121

New Member
Thanks NorthGuy. I was thinking of using a switching frequency of 10kHz and make a low pass filter with a bandwidth of 2.5kHz.
 

Tony Stewart

Well-Known Member
Most Helpful Member
At some point in the future measuring the Vpp AC ripple might be useful, if you have an open channel.
 

atferrari

Well-Known Member
If you're making a DC/DC switching converter, you need to be careful with the filter for measuring the output DC voltage. You certainly cannot treat it as DC, because if you don't control it correctly then it won't be DC. Instead, use a fast low-pass filter based on your sampling frequency. Also make sure that your sampling is not coherent with your switching/ripple - if you only measure the peaks of the ripple you will overestimate your voltage, if you only measure the valleys you will underestimate it.
Sorry for the question: by fast do you mean "steep"?
 

Tony Stewart

Well-Known Member
Most Helpful Member
Last edited:

crutschow

Well-Known Member
Most Helpful Member
....................
Since the battery voltage varies slowly, the time constant is chosen based on ADC sampling rate; not necessarily based on the battery voltage rate-of-change.
I agree if "sampling rate" is how often you want to take a voltage reading to see a change, and not the intrinsic sample rate of the ADC, which is generally much higher.
 

crutschow

Well-Known Member
Most Helpful Member
Typically Nyquist filters are defined by pass.band ripple <1dB and stop band attenuation> 80dB hence steep slope. These are used in telephony 8ksps with brick wall filters to pass below 3KHz , i.e. 7th order or so.
---------------------
or an 11 pole Elliptical filter
Such steep filters are only needed if the upper signal frequency is close to 1/2 the sample rate.
Otherwise you can use a slower roll-off analog filter, and use a high order digital filter for any noise between the upper signal frequency and the Nyquist frequency.
In that case the analog filter just has to roll-off any noise or undesired signal such that it's below the intrinsic ADC noise at the Nyquist frequency.
 

Tony Stewart

Well-Known Member
Most Helpful Member
BEfore the advent of mobile phone's I had the pleasure of working on a state-of-the-art digital network with ISDN full digital services and 1.544MBps full duplex to the home in '79.*

I learnt that such filters were necessary so that global phone calls could sound like the person was just down the street with >75dB SNR audio quality using 8 bit log ADC/DAC. No hiss, hum , pops or distortion.

These days cell phones use DSP firmware for filtering optimise bandwidth efficiency but can sound terrible at times.

But in those* days , these chips were cheaper and necessary. However if the OP is just sampling DC ,,who cares.

For those who do, I have another example of a digital antialiasing filter in the late 70's on another project (we classify as SCADA today)

I just wanted to sample "DC" from a DC motor current sensor and send it on the digital stream to a remote location in a continuous synchronous stream. But all the ADC channel words were used up, except for a message word, so I allocated 1 bit for DC motor current. Then I used a voltage controlled timer to generate pulses from 0 to 1kHz for DC , 0 to full scale from the current shunt signal. Then at the receiving end for an analog edge meter, it would convert the logic 1 tach signals to an analog meter to show the operator servo-motor current, in case of a jam.

The only problem was it was aliasing on the edge meter with a frame rate of something like 100k "frames" of data per second. So then I thought, but this is only DC? Then I remembered my class in Shannon's Law. So instead of sampling the tach signal to be sent down the stream, I used it to clock or edge trigger a FF instead, thus it would only be reset if the "bit" had been sent, which was a safe bet. Voila! No more aliasing.

With this method your frame rate can be as low as the max tach frequency but no lower
... rather than 2x the pulse rate.

my digital anti-aliasing solution.
 
Last edited:

NorthGuy

Well-Known Member
Sorry for the question: by fast do you mean "steep"?
No, I meant fast (higher frequency). So that it removes noise above Nyquist frequency, but doesn't smooth out the sampling too much. As opposed to much slower (lower frequency) filter which you would want to use for DC.
 

misterT

Well-Known Member
Most Helpful Member
Nyquist frequency is the "critical point" where aliasing "begins to occur". If you sample 50 Hz sine wave at 100 Hz, the signal can alias to 0 Hz. And even if it does not alias, it is very hard to reconstruct the original sine wave from the samples.

Good system should sample about 10 times faster than the Nyquist frequency.
Or design the filter so that the attenuatioin at Nyquist frequency matches the signal-to-noise ratio of the ADC (for 12bit ADC this is -74dB), and the cut-off frequency matches the bandwidth you are interested.

There is a good example design in this appnote (page 7). The bandwidth they are interested is 1 kHz and they are sampling at 20 kHz (12 bit ADC). They show three different active filter designs and compare them.
http://ww1.microchip.com/downloads/en/AppNotes/00699b.pdf
 
Last edited:

NorthGuy

Well-Known Member
Good system should sample about 10 times faster than the Nyquist frequency.
His task is opposite. He wants to remove unwanted noise. This pretty much can be done in software by some sort of smoothing, such as FIR filer. However any high frequency components (above the Nyquist frequency, which is the sampling rate divided by two) cannot be filtered out of the signal after the sampling is done (no matter how sophisticated your software is). Thus, it is necessary to have a hardware filter which will remove everything above the Nyquist frequency before the signal is sampled. Using hardware filters to remove components with lower frequencies is not a good idea because even if you want to remove them, you can do it in software without any need for hardware changes, which gives you much more flexibility.
 

misterT

Well-Known Member
Most Helpful Member
His task is opposite. He wants to remove unwanted noise. This pretty much can be done in software by some sort of smoothing, such as FIR filer. However any high frequency components (above the Nyquist frequency, which is the sampling rate divided by two) cannot be filtered out of the signal after the sampling is done (no matter how sophisticated your software is). Thus, it is necessary to have a hardware filter which will remove everything above the Nyquist frequency before the signal is sampled. Using hardware filters to remove components with lower frequencies is not a good idea because even if you want to remove them, you can do it in software without any need for hardware changes, which gives you much more flexibility.
Well, yeah. Of course you can't sample 10 times faster than the Nyquist frequency, because the Nyquist frequency is defined as half the sample rate :). What I meant to say that sampling at twice the bandwidth is only barely enough. You should sample much higher rate than the signal bandwidth is (cutoff frequency of the low-pass filter).

Noise above the cutoff frequency should also be below the Nyquist frequency.. and at the Nyquist frequency the noise should be attenuated "enough", because that noise will be aliased and cannot be removed with software.
 
Last edited:

MikeMl

Well-Known Member
Most Helpful Member
So back to my battery voltage measurement scenario: The battery voltage changes at the rate of no faster than 1mV per second, so with an ADC whose resolution (relative to the battery voltage) is about 10mV, I could sample about every 5ms and meet Nyquist. However, I found that during charging, the battery voltage has about 250mV of 120Hz noise induced by the full-wave rectifier, so I needed an RC filter that knocks the 120Hz ripple down to less than 10mV so as not to effect the ADC reading...

So you see, it is about "filtering" the ripple (Nyquist takes care of himself)...
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top