Understanding the PIC16F1823 ADC process

Thread Starter

cmartinez

Joined Jan 17, 2007
8,220
I'm planning to interface the output from a pressure sensor such as this one, to an ADC pin on a PIC16F1823. The advantage is that both devices work at 5V, and the sensor delivers a signal varying between 0.5 and 4.5V, according to its specs. Now, the PIC16L1823 ADC has a 10 bit resolution, and since the sensor will be working within 80% of the total 5V range of the ADC, I expect this will result in measurements spanning 819 divisions, approximately. Which is more than enough for my application.

Question, should an RC filter such as shown below be placed between the sensor's output and the ADC pin?

1593645804419.png


If using this sort of filter is recommended, what values would be considered typical for this sort of application?
 
Last edited:

OBW0549

Joined Mar 2, 2015
3,566
Question, should an RC filter such as shown below be placed between the sensor's output and the ADC pin?
Yes. No. Maybe. The answer depends on what you need the sensor to do.

Does the sensor produce a lot of broadband voltage noise on its output? If it does, then a filter may be needed to chop off the high frequencies and keep the noise from producing "jitter" in your ADC readings.

Does the pressure your measuring change rapidly and periodically (like at a pump outlet), and you don't want to see these rapid variations in your ADC readings? Then a filter is needed.

Does the pressure change rapidly and you DO want the ADC output to faithfully track those pressure changes? Then heavy filtering may not be appropriate.

Does the pressure change rapidly at a rate above the Nyquist frequency (1/2 of your ADC sample rate)? Then you need to design an anti-aliasing filter to get rid of those higher frequencies so they don't alias down into your passband.
If using this sort of filter is recommended, what values would be considered typical for this sort of application?
That depends entirely on what you need the filter to do-- reducing high frequency interference, smoothing out ADC readings to eliminate pressure fluctuations, kill aliasing, or whatever. There are no "typical" values for R and C.
 

Delta Prime

Joined Nov 15, 2019
1,311
If using this sort of filter is recommended, what values would be considered typical for this sort of application?
Hi there & welcome to AAC! :p Save it for the joke thread right. Sorry couldn't help myself
The old standby my buddy the
discriminator. this is pretty good read .It helped me get ideas
 

Attachments

Thread Starter

cmartinez

Joined Jan 17, 2007
8,220
Hi there & welcome to AAC! :p Save it for the joke thread right. Sorry couldn't help myself
The old standby my buddy the
discriminator. this is pretty good read .It helped me get ideas
Gee DP, thanks.. you've made me feel comfy and right at home... :p

Seriously now, thanks for posting that doc. I'll give it a thorough read and come back with either more questions or to report my results.

Thank you both for your help.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,220
From this document:

1593697927510.png

That being said, I found out that passive filtering is not the optimal technique for this sort of thing. Either a Butterworth, Bessel or Chebyshev filter would work much better ... gee, I almost sound as if I knew what I was talking about...

Either way, I don't want to add more components to the board than strictly necessary. So I'm going to try the RC filter first and then determine if I need to use any of those English, French or Russian guys' approaches.
 

BobaMosfet

Joined Jul 1, 2009
2,110
I'm planning to interface the output from a pressure sensor such as this one, to an ADC pin on a PIC16L1823. The advantage is that both devices work at 5V, and the sensor delivers a signal varying between 0.5 and 4.5V, according to its specs. Now, the PIC16L1823 ADC has a 10 bit resolution, and since the sensor will be working within 80% of the total 5V range of the ADC, I expect this will result in measurements spanning 819 divisions, approximately. Which is more than enough for my application.

Question, should an RC filter such as shown below be placed between the sensor's output and the ADC pin?



If using this sort of filter is recommended, what values would be considered typical for this sort of application?
In the documentation for the PIC16L1823, it should show you how the ADC pin handles input. This is how you determine whether or not you need a filter beforehand.

I believe this is the info you need to review in the datasheet for the PIC you've specified:

1593699677837.png
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,220
In the documentation for the PIC16L1823, it should show you how the ADC pin handles input. This is how you determine whether or not you need a filter beforehand.

I believe this is the info you need to review in the datasheet for the PIC you've specified:

View attachment 211244
From what I gather, the analog input of said chip, other than protected by the shown diodes from over and under voltages, is practically unfiltered. Which is to be expected, I guess. The chip will make as sensitive readings as possible, and it's the user responsibility to filter and condition the source accordingly.
 

BobaMosfet

Joined Jul 1, 2009
2,110
From what I gather, the analog input of said chip, other than protected by the shown diodes from over and under voltages, is practically unfiltered. Which is to be expected, I guess. The chip will make as sensitive readings as possible, and it's the user responsibility to filter and condition the source accordingly.
No... Cpin is your filter. Along with Rs. If you want to get the full 1024 resolution out of your circuit, you can use a transistor to amplify your signal.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,220
No... Cpin is your filter. Along with Rs. If you want to get the full 1024 resolution out of your circuit, you can use a transistor to amplify your signal.
Right ... I did see them the first time around, but I didn't take those components seriously because of their very low value, and because Cp is labeled as "input capacitance" which I interpreted as a value inherent to the input circuit itself, and not to a separate component. OTH, maybe those values are there to filter the ADC input from frequencies that are considered noise or that it wouldn't respond to anyway.
 

OBW0549

Joined Mar 2, 2015
3,566
I didn't take those components seriously because of their very low value, and because Cp is labeled as "input capacitance" which I interpreted as a value inherent to the input circuit itself, and not to a separate component.
That's correct. Cpin comprises the capacitance of the pin itself, the chip bond wires, the bonding pad on the chip, the capacitance of the protection diodes, and the capacitance of the track leading up to Ric. It is the capacitance any external circuitry "sees" looking at the pin.

OTH, maybe those values are there to filter the ADC input from frequencies that are considered noise or that it wouldn't respond to anyway.
No, they are not. That capacitance is so small that you'd need an enormous external series resistance to get any meaningful filtering action from it; and that resistance would totally trash the DC accuracy of the ADC (because of pin leakage current) as well as stretch out the minimum Tacq time to an unreasonable length.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi cm,
If you have a rough idea of the measured pressure profile, it would be possible to produce a closer simulation of the PIC's ADC response .
E

For reference only this Sim shows the effect of an external 1n0 and a Rsource of 1R thru 1k in 100R steps.
Using a 0V to +5V Step input voltage.
 

Attachments

Thread Starter

cmartinez

Joined Jan 17, 2007
8,220
No, they are not. That capacitance is so small that you'd need an enormous external series resistance to get any meaningful filtering action from it; and that resistance would totally trash the DC accuracy of the ADC (because of pin leakage current) as well as stretch out the minimum Tacq time to an unreasonable length.
So I was right the first time around? That Cpin does not serve any filtering purpose? and therefore neither does Ric (interconnect resistance)...
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,220
hi cm,
If you have a rough idea of the measured pressure profile, it would be possible to produce a closer simulation of the PIC's ADC response .
E
It's for the rather mundane application of measuring a water pump/pressure tank output. So a sluggish response of, say, between 1/10 and 1/4 of a second would be not only acceptable but also desirable.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi c,
So could the pressure/voltage be 'pulsing' in sync with the water pump.
How often will you sample the pressure.?
E

Update:
I think this is one of those occasions where a scope reading of the pressure voltage when the pump is running, will give the best guide on the level of filtering required and the sample interval.
 
Last edited:

Thread Starter

cmartinez

Joined Jan 17, 2007
8,220
hi c,
So could the pressure/voltage be 'pulsing' in sync with the water pump.
How often will you sample the pressure.?
E
As fast as possible, because I'd measuring it along with other parameters. Buy I'd like the filtering to be applied in hardware, because I want to keep the programming as simple as possible.
 

OBW0549

Joined Mar 2, 2015
3,566
It's for the rather mundane application of measuring a water pump/pressure tank output. So a sluggish response of, say, between 1/10 and 1/4 of a second would be not only acceptable but also desirable.
In that case, 1 kΩ and 100 μF, or 4.7 kΩ and 22 μF, would give you a 100 ms time constant which will probably be adequate.
 
Top