I'm trying to measure ambient brightness values with a CdS light-dependent resistor (R2 in the below diagram.) R1 is a known value, and the resistance of R2 has an inverse log relationship with the current ambient brightness.
I can use the voltage in the middle of the voltage divider to calculate the value of R2, and therefore the brightness, in software. I intend to use the A-D capabilities of my PIC chip to measure that voltage. Although CdS cells are inherently a bit imprecise, I'd like to get the best precision possible. Is the input current flowing into pin AN0 negligible?
Vdd ---
|
R1
| -|--|-
+------ AN0-|IC|-
| -|--|-
R2
|
Vss ---
Bonus question - anyone know how I can linearize the inverse log response of my LDR? At 1 lux it's 1 megaohm, at 10 lux it's 100k, at 100 lux it's 10k etc. I need to calculate values as accurately as possible between 10 and 600 lux, so if I just plug it into my A-D I'm going to have to pick one end that has much crappier resolution.
In your schematic, A/D "sees" your LDR as source resistance. PIC datasheet specifies that source impedance shouldn't be more than 2.5k. If your range of light levels begins at 10lux, then the max source resistance you'll see will be 100k, which is well above required source impedance.
You can add an OpAmp buffer with high impedance inputs. The output impedance of most OpAmps is below 2.5k.
You can add a capacitor (0.1uF or so) from A/D input to ground. It will lower source impedance that sample and hold in the A/D sees.
To bring up your circuit and firmware, you could use a fixed 100k resistor in place of LDR.