Wednesday, 26 September 2012

Light Sensor with Twilight Detection

This is not the first light sensitive circuit to be published in Elektor magazine. This circuit however, distinguishes itself that in addition to light and dark it can also signal twilight (dusk). This lets you automatically turn on a light in the living room when it becomes dark and turn on a lamp in a dark hallway when dusk sets in.


The circuit described here generates a logic signal on three separate out-puts for light, twilight and dark. The transition thresholds are set with two trimpots.The part of the circuit that is to the left of the dashed line can be located outside, on the roof, for example. This is possible because the LM258 can withstand frost, unlike the LM358, for instance. R1 and R2 together form a light dependent voltage divider, the voltage variations of which are damped by R3 and C1. This is desirable so that the circuit is less sensitive to birds that could cause the curtains to be closed when they fly across the sensor.
Opamp IC1a is wired as a buffer, so that the voltage that is seen by the remainder of the circuit does not deviate too much from the voltage ‘on the roof’. Any arbitrary LDR is suitable for R1, but do make sure that the voltage level at pin 3 of IC1a is at least 2 V below the power supply voltage when it is light. This is because that is the maximum voltage that IC1 and IC2 can tolerate at their inputs. Otherwise fit an additional resistor of, for example, 2.2 kΩ between R1 and the power supply. Two comparators (IC2a and IC2b) compare the incoming voltage with the threshold voltages set by P1 and P2. R4 and R6 (R5 and R7) prevent that that output of IC2a (IC2b) will jitter around the threshold. R8 and R9 have been added because IC2 has open-collector outputs.
It is actually already possible to determine whether it is light, dark or twilight by looking at the outputs of IC2a and IC2b, but the four gates of IC3 turn these into three separate signals. To make the adjustment easier, there are three LEDs of different colour connected to the outputs: green for light, yellow for twilight and red for dark. In the box is a description of the steps that are necessary to adjust the circuit.
It is best to do this towards the evening, that is when it is still light outside before the fall of dusk.To adjust the threshold values, P1 is intended for the transition from light to twilight and P2 for the transition from twilight to dark. With a correctly adjusted circuit, the voltage at the wiper of P1 has to be lower than the voltage at the wiper of P2.Because the outputs of the CMOS gates can-not drive heavy loads, low-current LEDs are essential. These have enough with only 2 mA, while ordinary LEDs will often need 20 mA. The power supply voltage can be from 9 VDC to 15 VDC.
Adjustment :
  1. First turn the wipers of both P1 and P2 to ground. If all is well only the green LED should be on.
  2. Wait until dusk falls.
  3. Now turn P1 just to the point where the green LED turns off and the yellow LED just turns on.
  4. Now wait until it is dark.
  5. Turn P2 just to the point where the yellow LED turns off and the red LED turns on. The adjustment is now complete.