Night Light circuit

30,161

Night Light
Night Light

The Saver V5.0 operates a simple clock emulation program that controls a night light to turn on and off at preset times, specifically from 19:00 to 22:00 daily. This design is characterized by its low cost, easy installation, lack of battery backup, and minimal electromagnetic interference (EMI). The circuit utilizes an AT89C2051 microcontroller with an external oscillator generated by a Schmitt trigger gate (CD4093) operating at approximately 680 kHz. The reference frequency is derived from a 50 Hz main line. Time setting is facilitated by pressing a time set button once at 18:00. In the event of a power failure, a functioning LED will blink rapidly, indicating the need to repress the button due to the absence of battery backup. The output is capable of driving a load, such as a 25W incandescent lamp.

The power supply is transformerless, with R1 and C1 forming a simple current-limiting AC source. Diodes D1 and D2 convert AC to DC, while capacitor C2 serves as a reservoir. Diode D3 limits the voltage across the circuit to approximately 5V. The AT89C2051 circuitry includes capacitor C4 (33 µF) and resistor R4 (10 kΩ), which create a reset circuit that requires sufficient time to raise the logic level for at least two machine cycles. Switch S1 is a momentary button used to set the time to 18:00 by pulling P3.0 to a logic low state. The functioning LED is connected to P3.7. A small triac (MAC97A6), driven by a PNP transistor (Q1), is used to control the load through P1.7.

For frequency reference, resistor R3 and capacitor C3 integrate the 50 Hz main frequency and filter out unwanted transients, producing a triangle-like waveform that is fed into the U2 Schmitt gate. The output from pin 4 generates a clean 50 Hz square wave, which is connected to int0. The hex file, Saver5.hex, is compatible with Easy-Downloader V1.1 for programming the microcontroller with the necessary code. This code sets the time to 18:00 when S1 is pressed once, with the on and off times configured for 19:00 to 22:00 daily. The reference main frequency remains 50 Hz.

The original source program, SAVER5.C, was developed in C language. Users can modify the set time by pressing S1, allowing for flexibility in the on/off schedule. It is advisable to include a peak shaving period, such as from 20:00 to 20:30, depending on the living area, by adjusting the timeOn3 and timeOff3 variables in the comparetime() function of the source program. Recompilation of the source file requires a Micro-C Compiler from Dunfield Development System with a tiny memory model, along with modifications to the runtime file to incorporate an external interrupt service routine that increments the cputick variable.

The Saver is designed to function correctly even if the L and N connections are reversed in the circuit; however, it is recommended to ensure the correct AC line connection. Upon completing the installation, turning on the main switch will cause the functioning LED to blink rapidly. Pressing S1 once will turn on the lamp for one minute and then turn it off, assuming the current time is 18:00. After waiting for the clock to reach 18:00, pressing S1 again will set the timer. It is important to note that each press of S1 will only turn on the lamp for one minute. The following day, the lamp will automatically turn on and off at the preset times, with the functioning LED blinking at a low rate to indicate normal operation. If a high blink rate is observed upon returning home, this indicates a power failure. In this case, waiting until 18:00 and pressing S1 again will reset the system. If the LED does not blink, it may indicate that someone has turned off the main switch, necessitating a reset by turning it back on and waiting for 18:00. The Saver is not intended for use with energy-saving lamps, which typically utilize internal high-frequency inverters. Testing with a specific model from National has been successful, but results may vary with other energy-saving lamps. Feedback on such tests is appreciated.The Saver V5. 0 runs simple clock emulation program, turns a night light on and off with preset time, say 19:00 to 22:00 everyday. The design features low cost, easy installation, no battery backup and no EMI. The AT89C2051 uses external oscillator generated by schmitt trigger gate CD4093, ~680kHz. Reference frequency was derived from 50Hz main lin e. Time setting only allows at 18:00 by pressing time set button once. If main line has failed, functioning LED will blink at high rate. Since there is no battery backup, thus repressing the button is then needed. The output is capable of driving say, a 25W incandescent lamp. 1)Transformerless direct supply: R1 and C1 forms a simple current limitting AC source. D1 and D2 converts AC to DC with C2 performing a reservoir. D3 limits voltage across the circuit to ~5V. 3)89C2051 circuits: C4, 33uF and R4, 10k forms a reset circuit that need time for riasing logic at least two machines cycle. S1 is a momentary button for setting time to 18:00 by pulling P3. 0 to logic low. The functioning LED is connected to P3. 7. Q2 is a small triac MAC97A6, and is drived by Q1, PNP transistor sinking through P1. 7. 4)Reference frequency: R3 and C3 integrates a 50Hz main frequency and unwanted transients producing triangle-like waveform which is fed to U2 schmitt gate.

The output pin4 is clean 50Hz square wave tied to int0. Saver5. hex is HEX file suitable for Easy-Downloader V1. 1 for writing the code to the chip. This file sets time to 18:00 when press S1 once. Time on and off is set to 19:00 to 22:00 everyday. And finally the reference main frequency is 50Hz! The original source program SAVER5. C was written in `C` language. User may change set time when press S1 and change time on/off. It is a good idea to include peak shaving period, say 20:00 to 20:30 depending on living area. By placing timeOn3 and timeOff3 in the function comparetime(), see the source program. To recompile the source file you need a Micro-C Compiler from Dunfield Development System with tiny memory model and need some modification of the runtime file by putting external interrupt service routine that increments cputick variable. Although the Saver can operate even wrong connection of L and N to the circuit. The author suggests to correct AC line connection to L and N of the circuit. After finished installtion, turn the main switch on, functioning LED will blink at high rate. Let try press S1 once, the lamp will turn on 1 minute then off. The Saver assumes the current time is 18:00. Then wait for the clock at your home reachs 18:00, press S1 again. Note that everytime you press S1, the lamp will turn on 1 minute only once. The day after the lamp will then turn on and off at preset time. Functioning LED will blink at low rate indicating normal operation. If high blink rate is noticed when return home, power failed should happen, no problem just wait again 18:00 then press S1.

If the LED is not blinked, someone may turn main switch off, turn it back on again and wait for 18:00. The Saver was not designed for turning such energy saving lamps on and off. They mostly use internal high frequency inverter. I have been tested with one from National, it works! But I am not guarantee for your energy saving lamp. I would be grateful if you could test and let me know the result. 🔗 External reference