# Measure voltage with PIC18F97J94 (resistor divider)

I want to measure the input voltage (range from 4V-10V) with AD converter on my PIC18F97J94. I need to use resistor divider to scale the voltage between 0V-3.3V to work with my ADC.

I used voltage calculator and came up with values below:

Vin = 10V (max voltage) R1 = 7.5k R1 = 3.7k Vout = 3.3V

Will this schematics work and how do I calculate capacitors value to filter the supply noise? Please find picture attached.

How do I make sure the impedance is within datasheet value? If Im right, maximum impedance on ADC would be 2.5kohm?

Optimism can be good but in this instance you need to be more realistic. The ADC input of your PIC may have a theoretical range of 0 to 3V3 but, in practise, this will be more like 50mV to 3.25 volts. Read the data sheet on the ADC and it will tell you what the zero and full-scale errors might be on any particular channel of the device. These errors are equivalent to the digital end-stops of the conversion process and as a rule of thumb I ensure that my biggest and smallest signals are within 50 mV of the specified front-page-of-the-datasheet range.

Other than that your calculation looks accurate enough but why not give a little bit more headroom on the 10V end of the signal? Also, you only need the capacitor to ground to cut-down on noise i.e. C1 is not needed.

• C1 is not wanted. Nov 14, 2015 at 10:58

The impedance is less than 2.5K if the input is always connected to a low impedance source. If it is left open, the impedance is 3.7K looking out from the ADC input.

The -3dB cutoff freqency of the single pole filter is

$f_c= \frac{ (R_1 || R_2) C_2}{2\pi}$

So the input will be attenuated by about 30% at fc- you can calculate C2 from that. You don't need or want C1 generally.

As Andy points out, you should attenuate a bit more because your 3.3V reference will have a tolerance as will the resistors and the ADC will have a maximum error spec, and you should accommodate worst-case conditions for all simultaneously to be sure of being able to measure 10V without the ADC saturating. ~10% lower value for R2 might be reasonable, but you should run the numbers.