Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

What is the use of RC filter in front of Analog port pin while using port pin for analog to digital conversion in pic 16f877A and in most pic controller the RC filter is advised to be used?

share|improve this question
add comment

3 Answers 3

The idea is to filter out noise and bandlimit the signal to avoid aliasing. You therefore want to set the corner frequency of the filter above the maximum signal frequency, but make sure you have no significant signal or noise above half of the sampling rate. With a single-pole filter you will have 3dB of attenuation at the corner frequency and 20dB per decade of frequency rolloff above that. The corner frequency for an RC filter is f = 1/(2*pi*R*C), so choose your components so as not to interfere with your signal. You may need more than a single pole filter to avoid aliasing depending on your signal and noise frequency content.

Of course if you're just taking a sample of some slowly varying signal like a temp sensor or something like that a single pole filter will be fine.

share|improve this answer
add comment

A lot of MCUs take a pulse of current to "charge" the internal sample and hold circuitry (part of the integrated ADC). If the series resistance of the signal source is too high, it won't charge the internal cap sufficiently and there will be an error in the conversion.

Applying a capacitor from the pin to ground means that there is a much greater chance of this working because the external cap can supply the current needed. See this SE post (relating to PIC input impedance) and check out the answer.

enter image description here

Of course this makes a low pass filter that is also useful for anti-aliasing.

share|improve this answer
    
Maybe I'm mis-reading/understanding this but you seem to be saying that, if the signal source impedance is too high to charge the internal cap, adding another cap makes that better? –  John U Apr 1 at 7:36
1  
@JohnU Yup that's what I'm saying and maybe you have to consider that there is a small time-slot for the internal sampling capacitor whereas the external cap is being charged throughout the conversion cycle. –  Andy aka Apr 1 at 7:51
    
Ah, I wasn't thinking about that sort of setup. –  John U Apr 1 at 7:53
add comment

Two reasons:

  • Impedance
  • anti-aliasing

Impedance: as said by @Andy aka, you ADC has a small capacitor inside to provide the sample and hold functionality of the ADC. You have to quickly provides the charges to that capacitor. You may use a low impedance buffer in front of the ADC. Or use a capacitor that is several times bigger than the one into the ADC.

Anti-aliasing: You will often see that you have to ensure that the frequency content of the signal at the input of your ADC is at least half the sampling rate (fin < fs/2). But why? Because of the signal processing theory. The Nyquist–Shannon sampling theorem said that if you want to be able to sample your signal without any information loss, then the sampling frequency should at least twice that frequency.

Ok, fine. But do I need this?

Good question! Two answers:

No: If you use the signal that enters the ADC to compare against a threshold (for instance when a tank reaches a certain level). Fine. You got a sample that said that the tank was at that level, this is fine. The sample reflects the reality. At least if the noise level on your signal is low.

Yes: If you plan to use any signal processing computations. Then your samples are not just numbers, they represents a signal. And this representation matches the reality only if the Nyquist–Shannon sampling theorem is verified.

Then it's up to you. You want to know the voltage at certain time: the ADC will tell you this with or without an anti-aliasing filter. You want to consider your input as a signal and perform things such as filtering: You need the anti-aliasing filter.

share|improve this answer
    
To be complete: when I said "you need the anti-aliasing filter" I want to say that you have to ensure that the frequency content of the signal at the input of your ADC is at least half the sampling rate. One way is the anti-aliasing filter. If the signal is already frequency limited, you may not need it. –  Blup1980 Apr 1 at 11:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.