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