Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

It is negligible. Figure 9-4 of the datasheet specifies the equivalent currents and capacitances.

Linearization - good question. It would be quite hard for you to design a circuit that would perform phenomenally better than your A/D software approach.

No, if you will use operation amplifier betwen resistors ladder and MCPU input in any other case yes it is negligible. Read also the datasheed which will tell you what is the minimum recommended source resistance of your resistors ladder to reach 10 bit ADC resolution. Second answer is yes it is possible to reach 12 bit resolution but not with one ADC measurment and only if you know what and haw are you measuring!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top