Twilight switch

twilight_switch_board


The circuit shown here is a twilight switch (photo- sensitive switch). It uses a light depended resistor (photoresistor), a constant current source and a Schmitt trigger (a comparator which uses hysteresis) to activate a relay at a precise ambient darkness level. The light depended resistor (LDR1) is used as a light sensor and the circuit can be used for automatic activation and deactivation of any device at any ambient darkness level. Since we use a SPDT relay (double switch), the circuit can be used and vice versa, i.e. for activating a load at ambient light (dawn switch) instead of darkness. Indicatively, many have used this circuit as an innovative wake – alarm device which is activated at dawn.

The electronic schematic of the Twilight switch
The electronic schematic of the Twilight switch

A constant current source is implemented from the IC1-A op-amp and the TR1. This source is used to bias LDR11. The constant current source works as follows:

Resistors R1 and R2 implement a voltage divider and they are used to apply voltage Vin, which is equal to about 9.8V, on terminal 5 of IC1-A (the non-inverting input of the op amp).

Vin = [Vcc * R2 / (R1 + R2)] = 12 * 10000 / (10000 + 2200) = 9.836V

Since the IC1-A op-amp works in its linear region (as a very high gain differential amplifier), the potential difference between its inputs (terminals 5 and 6) is approximately equal to zero. Thus, the Vin voltage which is applied on terminal 5 is approximately equal with the voltage on terminal 6, which, at the same time, is connected at the lower end of R3. Thus, R3 is biased with a fixed voltage that is equal to Vcc- Vin. Therefore, according to the law of OHM, the current that flows through R3 is also constant and equal to (Vcc- Vin) / R3 = (12 – 9.836) /1000=2.1mA. The same constant current flows also through the parallel combination of R6 // LDR1 which is connected in series to R3. The parallel combination of R6 // LDR1 gives a total resistance Rt = LDR1 * R4 / (LDR1 + R4).

  • In absolute darkness, LDR1 has a very high resistance (about 1 Meg) and Rt becomes about 4.6-4.7K.
  • In medium ambient light, LDR1 has a resistance of approximately 50K. Therefore, Rt becomes approximately equal to 4.3K.
  • In extreme brightness, LDR1 resistance drops to about 100 Ohm and Rt becomes approximately equal to 100 Οhm.

According to OHM’s law, voltage = current x resistance, thus setting a 2mA constant current and a resistance equal to Rt, we note that the voltage on pin 2 of IC1-B is approximately equal to:

  • 9.8V at darkness
  • 9V in medium ambient light
  • 0.2V at bright ambient light

To create a switch that is activated from ambient light or during ambient darkness, we make use of this light-depended voltage. A comparator which is built around IC1-B is used to compare the light-depended voltage to a known reference voltage. In order to avoid any bounce problems, we use a Schmitt trigger instead of a simple comparator. A Schmitt trigger uses the concept of voltage hysteresis.

The printed circuit board of the Twilight switch
The printed circuit board of the Twilight switch (copper side view)

The light-depended voltage is applied to the inverting input (pin 2) of the IC1-B comparator. This voltage is compared with a reference voltage which is applied to the non inverting input (pin 3). The values of R5 and R7 are selected in such a manner so that when the wiper of potentiometer R6 is located in its terminal position towards R5, the reference voltage becomes equal to about 10.2V. In the opposite terminal position (towards R7), the reference voltage becomes equal to about 0.45V.

In order to produce some hysteresis, we use R8 and R9 to add to the reference voltage some small negative feedback from the output of the op-amp. The output of IC1-B takes only two possible values (because IC1-B is used as a comparator). These two values are approximately 0 and 11V during negative and positive saturation, respectively.

Hysteresis is essential in order to avoid any bounce problems. Bouncing is an undesired oscillation condition which may occur in simple comparators when the reference voltage and the control voltage are almost equal (too close to the transition region). In a Schmitt Trigger (comparator with hysteresis), bouncing effectively avoided because once the comparator changes condition from one state to another, appropriate feedback slightly shifts the reference voltage in such a direction in order to make “more difficult” any new transition to the opposite direction. Essentially, that makes the comparator to switch from one state to the other at different levels (while a single comparator uses only one comparison level). The difference between the two voltage thresholds defines a so-called hysteresis region.

Obviously you have notice that the sensitivity of the twilight switch can be adjusted from R6. In a certain twilight level, which is adjusted from R6, the output of IC1-B goes to its negative saturated state (at about 0V) and energizes the relay through TR2 (a PNP type transistor). Thus, the relay is activated at darkness. So for example, you can activate the lights of your garden at sunset, if you connect your garden lights to the LP1 output. Alternately, if you want to activate a load at dawn you must connect this load at LP2. In conclusion, devices that are connected on LP1 are activated at sunset, and those that are connected on LP2 are activated at dawn. The relay is actually activated only at sunset, but we can also control loads at dawns because we use a SPDT relay as seen in the schematic.

You may build the unit on a test board (breadboard) or on the printed circuit provided above. You may easily assemble all the components on the specific printed circuit board, by following the assembly drawing provided here:

Assembly guide for the Twilight switch board
How to assemble the Twilight switch

 

 

List of the comments:
No comments have been posted yet.
You must be registered in order to post a comment