# A Low-Pass filter for 12bit ADC . How to calculate?

Discussion in 'Embedded Systems and Microcontrollers' started by FrancescoC, Feb 16, 2016.

1. ### FrancescoC Thread Starter Member

Nov 22, 2014
30
5
Hi,
I need to connect an active Low_Pass filter to a PIC18F with a 12bit ADC.
I will use some software to make the appropriate calculation but I do not know what kind of
frequency do I need to filter so that the ADC get a reasonably low noise signal.
The signal to be converted is a dc voltage, but it is 12cm away from the PIC18F.

What should I consider? Is the conversion rate an issue?
The voltage range is from 0V to 5V and I will need to measure a minimum of 5mV.
Maybe a simple RC filter followed by a good OPAMP is best?

Any ideas to help me going?

Regards

Francesco C

2. ### thumb2 Member

Oct 4, 2015
92
6
The sampling theorem states that the sampling frequency must be greater than twice the signal frequency, so:

$f_s > 2 f_m$

For a 12 bit ADC, at the frequency $f_m = \frac{f_s}{2}$, the attenuation should be greater or equal to approx. 74 dB.

So in relationship with passband and stopband, you have to determine the order of the filter, and then decide what kind of approximation you need (gain response vs phase response) depending on your requirements.

3. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,514
514
2^12=4096
5000 mV/4096=1.22 mV
1.22 mV is your minimum measurement.

What is sampling rate/frequency of the ADC?

4. ### crutschow Expert

Mar 14, 2008
13,508
3,384
The frequency of the filter is determined by the maximum signal frequency you want to measure or alternately, how soon after a new DC input level is applied do you want to take a measurement.

5. ### FrancescoC Thread Starter Member

Nov 22, 2014
30
5
Hi,
Thank a lot to everyone for the replies.
I will be using an 8MHz clock on my PIC micro.
I have not been able to understand yet what will be the maximum sampling rate I can achieve.
However the the voltage I am reading is low-changing type. So i assume that will not be a problem.
I am only interested in filtering the noises present on the PCB especially those of few mV.

Say I opt for a simple low-pass RC filter, followed by a unity-gain Op Amp. Will that do the job?
And do I place the filter before or after the Op Amp?
In choosing the RC filter what kind of noises do I need to filter on the PCB?
By that I mean the range of frequencies.

6. ### shteii01 AAC Fanatic!

Feb 19, 2010
3,514
514
1.
RC filter does two things.
One, it filters out whatever YOU DESIGN to filter out.
Two, it attenuates signal somewhat.

2.
Unity-Gain op amp, Gain=1, also known as buffer. Normally you put it between the filter and the ADC. The reason for this placement is that you don't want to load the ADC. Regular op amp, by its nature, is seen as very small resistor which is negligible, and it can source very little current. The result is that ADC will not be altered by the external circuit and it will not be fried by suddenly receiving large current from the external circuit.

3.
Going back to 1. If your RC filter attenuates the signal too much, you might want to use op amp with a small gain to boost your signal to its original amplitude.

Other thoughts:
- Since I have no clue about the nature of your pcb, I have no clue which frequencies you would want to filter out.
- Just running by the numbers, if your ADC has 8 MHz frequency, then, by Nyquest Theorem, you can sample signals from 0 to 4 MHz.

7. ### crutschow Expert

Mar 14, 2008
13,508
3,384
As I stated, the frequency of the filter is determined by how fast you measure a change in the input signal (not the A/D sample frequency which is higher).
You've said that the signal a "low-changing type" but until you define what that is, I can't tell you what your filter response needs to be.

8. ### FrancescoC Thread Starter Member

Nov 22, 2014
30
5
Hi,
thank to all.
I am now designing the PCB and I will implement a an RC low-pass filter followed by unity-gain OP Amp.

Great forum.

Francesco C