Maker Pro
Maker Pro

light sensor that doesn't bounce?

  • Thread starter Ingen Ingensteds
  • Start date
I

Ingen Ingensteds

Jan 1, 1970
0
I'm a beginner planning a project to control a lighting system based on
ambient light. I'd like to operate one light during the day, and
another at night. I've seen projects which use an LDR, but it appears
that a simple design would cause my device to switch rapidly between day
and night modes at dusk, or with noise in the ambient light level. I'd
like to "soak" the transition between light and darkness, for example so
that I will not change between day/night modes faster than (say) every
30 seconds. How do people usually deal with this? This is for use with
a 12v DC lighting system, btw.
 
C

CFoley1064

Jan 1, 1970
0
From: Ingen Ingensteds [email protected]
Date: 2/8/2004 8:40 PM Central Standard Time
Message-id: <[email protected]>

I'm a beginner planning a project to control a lighting system based on
ambient light. I'd like to operate one light during the day, and
another at night. I've seen projects which use an LDR, but it appears
that a simple design would cause my device to switch rapidly between day
and night modes at dusk, or with noise in the ambient light level. I'd
like to "soak" the transition between light and darkness, for example so
that I will not change between day/night modes faster than (say) every
30 seconds. How do people usually deal with this? This is for use with
a 12v DC lighting system, btw.

If you're just interested in getting the job done cheaply, reliably and
efficiently, I'd just get a 120 VAC lighting photocontrol from the hardware
store, use it to drive a 120VAC coil Form C relay, and then use the N.O. and
N.C. contacts to drive your 12VDC lighting loads. If the relay won't turn off
when it gets light, place a 25W 120VAC light bulb in parallel with the relay
coil. Plug the photocontrol in next to your 12VDC power supply, and have the
long wiring run as low voltage DC to your light/dark lamp loads.

Once it gets dark enough at dusk to turn on the control, it has to get a lot
lighter before it turns off again. Conversely, when the control turns off at
dawn, it has to get a lot darker before it turns on. This effect is called
hysteresis, and it is generally used instead of time delays in lighting
controls. After all, changes in sunlight happen a lot more slowly than 30
seconds. The time delay probably won't get you where you want to go.

I suppose if you're just having fun, you'd go to Radio Shack, and get their CdS
Photocell pack, along with an LM339 quad comparator, a 10K pot, a power NPN
darlington transistor, a 1N4002 diode and a big 12VDC coil relay. Put the pot
in series with the CdS photocell, and set the pot so there's about 4V at the
tap at the dusk switching point (experiment!). You'd then set up the
comparator with hysteresis (feedback) so it would switch off at 2V, and switch
on at 6V. You would then use the output to drive a power darlington
transistor, which would drive a big 12VDC coil relay controlling your lighting
load. Put the diode across the coil to avoid inductive kick when you turn it
off. (The lighting photocontrol and relay *is* simpler).

Look at National Semiconductor app note AN-74, pp. 2-5 for advice on how to do
this with an LM339. Be sure to tie off the other comparators by tying one
input to GND, the other input to your reference voltage, and leaving the
outputs disconnected.

http://www.national.com/an/AN/AN-74.pdf

Good luck
Chris
 
R

Robert C Monsen

Jan 1, 1970
0
Ingen Ingensteds said:
I'm a beginner planning a project to control a lighting system based on
ambient light. I'd like to operate one light during the day, and
another at night. I've seen projects which use an LDR, but it appears
that a simple design would cause my device to switch rapidly between day
and night modes at dusk, or with noise in the ambient light level. I'd
like to "soak" the transition between light and darkness, for example so
that I will not change between day/night modes faster than (say) every
30 seconds. How do people usually deal with this? This is for use with
a 12v DC lighting system, btw.

People use whats called hysteresis for this, as other posters have pointed
out.

Your circuit will use the voltage developed across a light dependent
resistor (LDR) as the input signal, and you want to set it up so that the
output doesn't flicker due to noise as the input gets near the switching
point.

This is generally done using a comparator, a reference voltage (the point at
which you want to switch,) and some positive feedback. Here is a typical
circuit:

VCC
|
.-.
| |R3
| |
Input Signal |\ '-'
----------------|-\ | output signal
___ | >----+-------------
Vref-|___|-+----|+/ |
R1 | |/ |
| |
| ___ |
+---|___|----+
R2

created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

The opamp symbol is really a comparator. Comparators are 'open collector',
meaning they can only pull the output voltage down, not up. Thus, you need
R3 to be able to pull the output up to VCC when V+ > V-.

Now, the comparator will switch when the inverting input (V-) equals the
noninverting input (V+). The way the 'hysteresis' works is that when the
output is high, R2 pulls the reference at V+ up a bit. When its low, V+ gets
pulled down a bit. Assuming that both R1 and R2 are much bigger than R3
(which is generally true,) we can just assume the output is either ground or
Vcc. If we make this simplification, then its easy to show that the total
'hysteresis', or difference between the voltage at V+ in the different
states, is

Vh = Vcc * R1/(R1 + R2)

(Do this by figuring out V+ when output is at GND, then at Vcc, then finding
the difference)

The hysteresis band will center around Vref, whatever that is.

For an example of how this works, assume your LDR is connected from GND to a
resistor R running to Vcc. Then, as it gets lighter, the voltage across the
LDR will get smaller, and so the input voltage at V- will go down. However,
it fluctuates as it goes down... Once it fluctuates so that V- is <
Vref-Vh/2, then the output will go high. However, until V- gets back up to
Vref+Vh/2, it'll stay high. So, as long as the fluctuations are less than
Vh, you don't have to worry about it changing state until the sun goes down,
and the voltage across the LDR climbs back up to Vref+Vh/2.

Regards,
Bob Monsen
 
A

Anand Dhuru

Jan 1, 1970
0
I designed pretty much the same circuit using the a2d in a 12F675 PIC;
the hysteresis and the thresholds are defined in software, and stored
in the on-board flash. Uses a minimum external components, and no pots
to mess around with!

Regards,

Anand Dhuru
 
R

Robert C Monsen

Jan 1, 1970
0
[I fixed the sequencing. Please don't top post]
I designed pretty much the same circuit using the a2d in a 12F675 PIC;
the hysteresis and the thresholds are defined in software, and stored
in the on-board flash. Uses a minimum external components, and no pots
to mess around with!

Regards,

Anand Dhuru

I'm the first person to reach for a PIC. However, the OP mentioned he was a
beginner, so I thought I'd write a little hysteresis tutorial, for the good
of the other beginners.

Its easy to use a single comparator, and if you aren't going to use the
other firepower of the PIC, its a cheaper solution.

Regards,
Bob Monsen
 
Top