Help on photoresistor - how to reverse?

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
rea5245
Posts: 4
Joined: Thu Aug 07, 2008 5:57 pm
Contact:

Help on photoresistor - how to reverse?

Post by rea5245 »

Hi,

I'm designing my first circuit - a PIC controlled digital clock. The PIC is currently sensing a photo resistor via A/D and changing the brightness of the LEDs with PWM. But I had an idea of a different way to do it...

The PIC can operate at 3.3V or less. The LEDs need 2.7V. I'm currently driving things at 5V. But what if I powered it from an LM317 and made the R2 resistor dependent on the level of light in the room? A darker room drops the voltage to 3.3V, a brighter room boosts it to 5V. The LED brightness would change accordingly without PWM.

So first I figured I'd use a digital potentiometer as the LM317's R2. But then I thought, what if I put a photo resistor as R2? The LM317's output voltage would then be controlled by the light level.

The only problem is, it would be controlled backwards from how I want: brighter light in the room would decrease the Vout and dim the LEDs.

So, is there any way to have a resistance vary inversely from another resistor? Is there a different component that will do what I want? Will this idea of varying the voltage work at all?

Thanks,
Bob
User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Post by MrAl »

Hi there,


This is an interesting idea, however there are a couple problems.

The first is that the way to get the LM317 (or similar) voltage to go
up instead of down with decreasing resistance is to use the decreasing
resistance as the 'other' resistor (the one that is usually around 200
ohms). Decreasing this resistor makes the output voltage go up.

The other problem though is finding a light sensitive resistor that
is the right value. It should be around 200 ohms and vary a bit
as the light hits it, and this is going to be hard to find i think because
most of them are much higher resistance than that.
The reason this resistor has to be around 200 ohms is to make sure
there is at least 5ma (approximate) flowing so that the bias current
(set internally by the LM317) is negligible compared to this 5ma,
and this keeps the temperature stability on track.
There is some chance that a higher value could be used as long as
the load is always around 5ma or better (probably the case here)
but the voltage might change rather drastically with temperature.
There are specs on the change of bias with temperature on the
data sheet and also the formula for the output voltage (including
that bias current) so you could do a few calculations to see what
the max resistor value could be (for this 'other' resistor) in order
to keep the output voltage within some reasonable range when
you want it stable, such as 4.9v to 5.0v or something like that.
This would be wayyyyy out of spec for a 'normal' application, but
since you want the voltage to vary some anyway it probably wont
hurt for your app if it changes even 10 percent.

Take another look at the data sheet and if you have any problems
just yell. It would help if you could find a part number for the
light sensitive resistor too, trying to find the lowest possible
resistance for this part and go from there.
LEDs vs Bulbs, LEDs are winning.
User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Post by MrAl »

Hello again,


I took a look at the data sheet and found that the temperature variation
in bias current doesnt affect the output voltage too much (for this app)
if the lower resistor is around 20k or so. This means the top resistor
can be made to vary from about 40k (dark) to about 10k (light) and
this might work.

Jameco sells a CDS cell that goes from 200k to 12k, so perhaps
putting that in parallel with a 50k resistor would do the trick.
This would require a bit of experimentation though, as the exact
resistance of the CDS cell is hard to nail down.
The idea would be to purchase a cell, connect it with a 50k resistor
in parallel, connect it to the LM317 as the upper resistor, then connect
a 20k resistor as the lower resistor, then test it with the required light
levels.

I should mention however that it may be hard to get the exact
response that might be best for the application because this setup
requires a bit of tuning and hopefully the CDS cell reacts enough
with the expected light levels. This could be very hard to acheive.

A better idea would be to put the CDS cell in series with a resistor
to +5v and measure the center voltage at the junction of the two
with the uC's AD converter. This would allow programing a much
more perfect response as the light level varies.

Just to note, as the lower resistor of the LM317 gets up to about 40k
the output voltage starts to vary quite a bit with temperature.
With 21k lower and 10k upper, the variation is about 0.2 volts,
but with a lower of 46k and upper of 41k (higher value resistors)
the variation is 0.5 volts.
Also note that a min of 1k load resistor is required, or else the
normal load should draw at least 5ma of current or the circuit
wont regulate at all with the high value resistors.

The difference between the two methods (using the CDS cell with
a LM317 vs using a CDS cell and resistor and the ADC of the uC)
is that when using the LM317 it might be very very hard to get
the desired resonse because selecting the right resistor might
get you there for the dark response while the light response isnt
good enough or vice versa, while the ADC and uC approach
will allow you to program just about any response with almost
any CDS cell (as long as min ADC input impedance is observed),
as long as you dont mind changing the set points on a cell to cell
basis.
To put this another way, the LM317 approach might not work too
well while the cell+resistor+ADC will always work.
LEDs vs Bulbs, LEDs are winning.
Engineer1138
Posts: 458
Joined: Thu Feb 05, 2004 1:01 am
Location: Minneapolis, MN
Contact:

Post by Engineer1138 »

It's a clever idea but I see a few problems:
1) Where is your reference coming from? If it's derived from Vcc then your design won't work.
2) Most digital pots won't handle much current. Make sure that the current through the LM317 resistor isn't more than the pot can dissipate.
3) Question: why not just use PWM? Varying power supply voltage will cause other things to vary and complicate the circuit with no benefit.

You are certainly creative, but I'd consider redirecting the creativity.
Dean Huster
Posts: 1263
Joined: Wed Dec 05, 2001 1:01 am
Location: Harviell, MO (Poplar Bluff area)
Contact:

Post by Dean Huster »

If using PWM, will not slapping an inverter on the PWM output effectively reverse the action of the LDR?

And if using an LDR in a voltage divider application, swapping it and the "fixed" resistance should reverse the action.

Dean
Dean Huster, Electronics Curmudgeon
Contributing Editor emeritus, "Q & A", of the former "Poptronics" magazine (formerly "Popular Electronics" and "Electronics Now" magazines).

R.I.P.
rea5245
Posts: 4
Joined: Thu Aug 07, 2008 5:57 pm
Contact:

Thanks to all

Post by rea5245 »

Thank you all for your advice. It does, indeed, seem easier to just stick with a constant voltage and use PWM.

My motive for exploring the LM317 alternative was that it seemed as if it would be cool to replace a big chunk of code with a single semiconductor. But if it won't work well, that settles the issue.

Thank you again.

- Bob
User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Post by MrAl »

Hi again Bob,


You're quite welcome.

Just to note, they do use the CDS cells in automatic night lights and
things like that (night only security lights), but in those apps the
value of the resistance of the CDS cell is not that critical mostly because
it's an on/off application rather than one that has to use that value to
determine some fairly exact level of brightness.
LEDs vs Bulbs, LEDs are winning.
rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Post by rshayes »

A double emitter follower could be used to raise the impedance of the voltage divider providing the feedback signal to the LM137. A PNP emitter follower could be used to drive the LM137 with a 200 ohm load resistor between the output of the LM137 and its adjustment terminal. This would require less the 350 microamps of base current. A second emitter follower using an NPN transistor would compensate for part of the offset and most of the temperature coefficient of the first emitter follower. The base current for this stage would be less than than 25 microamps, which will be more compatible with a photoconductor in the 10K to 100K range.
k7elp60
Posts: 226
Joined: Wed Dec 05, 2001 1:01 am
Location: Ivins, UT
Contact:

Post by k7elp60 »

I built a digital clock with a clock chip (NTE2061). My displays are 4 inch 7 segment that uses about 12V for the displays. The display has its own regulator. I used a photoresistor to sense ambient lighting, and when the room gets darker the voltage to the displays is decreased. I used an op amp with a gain pot to set the trip point. The op amp triggers a comparator that turns on a 2N3904 that shorts out a resistor in the display 3 terminal regulator voltage adjust string.
User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Post by MrAl »

Hi again,

Some good ideas, but i still prefer the programmed uC technique because
that allows you to set precisely two or more set points for the ambient
lighting vs display intensity. With only one adjustment (analog) you
have to get lucky or else simply settle for the second set point. With
the programmed uC you can even set three or more points to be exactly
what you want them to be, and all at the cost of a photo sensor and
a resistor (and of course an I/O pin on the uC).
If there are no pins left then i guess you have to go analog.

With the programmed uC method if you have a dim light resistance of
12k, 20k, or 40k, and a lighter light resistance of 4k, 20k, or 40k you
can still get your two set points correct and interpolate in between.
It's just a matter of changing the programmed code a little bit.
LEDs vs Bulbs, LEDs are winning.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 30 guests