Let me ask you a question
“Is it required to indicate electricity failure?”
Probably you will say “No”. Because when electricity fails, all the appliances running on electricity (like fan, bulb, tube light, TV, AC, desktop computers etc) will be turned off. So certainly you will know the electricity has gone – means fails. This is the scenario in the home or office.
What about the industry? In the industry also, the motors, the machines etc will stop as electricity fails. But now a days, industries the load is operated partially through electricity and partially through generator or inverter with battery backup. By this means they are trying to save heavy electricity bills. In such cases it is required to keep track of electricity failure as when electricity fails the entire load has to be operated by generator or inverter. It requires either manual switch over or automatic switch over
If the load is very critical that it cannot be switched off for even few seconds also then definitely there must be automatic switch over. For example
1. life supporting system in ICU/ICCU of any hospital
2. Centralized monitoring and controlling room of DCS in any industry
3. Main web server
But if load is not so critical that it can tolerate switch off period, in that case manual switch over can do the job. But here it is required to give audio/visual alarm – indication of electricity failure.
Not only for this reason but some time it is required to find out the reason of electricity failure. In that case also it is required to indicate electricity failure by audio or visual means. There may be also the case that the electricity does not fail but the MCB (main circuit breaker) has tripped and due to that the load is switched off. So in all such cases it is required to give a kind of indication like sound or buzzer or an alarm whenever electricity fails.
The circuit given here gives audio-visual indication of electricity failure. It operates on battery. It uses 20 pin micro controller AT89C4051 and it gives audio alarm as well as LED indication whenever electricity fails. It uses ZCD (Zero cross detector) circuit to generate 50 Hz pulses out of 230 V AC mains. Let us first understand the system block diagram.
System block diagram:
The major building blocks of system are ZCD, micro controller and IC NE555. Let us understand function of each block.
Transformer: it steps down 230 VAC to 12 VAC so that it can be given to ZCD circuit
ZCD: its zero cross detector circuit. It generates one short duration positive pulse and negative pulse whenever AC wave crosses zero mark. That means if there is AC input – pulses output from ZCD and when no AC input – no pulse output from ZCD
Fig. 1: Block Diagram of 8051 Microcontroller and 555 IC based Electricity Failure Detector
Micro controller: its main building block of system. It keeps track of pulses from ZCD. If it gets continuous pulses it turns on GREEN LED but when it does not get pulses from ZCD it turns on RED LED to indicate electricity failure. Also it gives signal multivibrator IC NE555 to generate audio alarm
Battery: it gives continuous supply to micro controller and IC NE555
NE555: it generates audio tone of 1000 Hz when it gets signal from micro controller
System circuit diagram
As shown in figure transformer T1 step downs 230 VAC in to 12 VAC and this is given to Diode Bridge. This rectified output is directly fed to base of Q1 through diode D3, resistors R1 & R2 (of 1 KΩ each). Same rectified output is filtered through C1 (1000 uF) to produce pulsating DC output. This unregulated DC is given as input to voltage regulator LM7805. It gives +5 V regulated supply that is given to both transistors Q1 & Q2 as biasing. Blue LED indicates supply is ON. Both transistors are connected in switch configuration. The collector output from Q2 is given to external interrupt input pin INT1 (7) of AT89C4051. This pin is pulled high through external pull up resistor R11 (1 KΩ). two LEDs – RED and GREEN, are connected to PORT3 pins P3.0 and P3.1 in current sinking configuration. Resistors R7 and R8 are current limiting resistors. IC NE555 is connected in astable mode. It generates audio tone of 1 KHz. Its output frequency is determine by RC components R9, R10 and C5. PORT P1 pin P1.5 of AT89C4051 drives reset input pin of NE555. Whenever AT89C4051 gives logic high input to this pin, the NE555 will be enabled and it will generate 1 KHz tone. A 12 MHz crystal with two 33 pf capacitors is connected to crystal input pins (4 & 5) of AT89C4051. Both AT89C4051 and NE555 ICs are given supply through 6 V battery.
Circuit operation:
First see how ZCD works. Let us understand it with the help of waveforms.
Fig. 2: Graph showing Zero Crossing Detection with respect to an AC voltage
· As shown in figure the first wave form is full rectified wave produce by diode bridge given to base of Q1 (position ‘A’ in schematic)
· Q1 is configured in switch configuration so whenever this voltage falls below 0.7 V it is switched off. So its output goes high. This will produce one short positive pulse at the collector output ‘B’ as shown in figure as second waveform
· This positive pulses are fed to base of Q2 which is again connected in switch configuration
· It will produce one negative pulse at ‘C’ of same width of positive pulse. This is shown as third waveform
· These negative pulses are fed to external interrupt of AT89C4051. So it will generate interrupt after every 10 ms
· AT89C4051 keeps track of these pulses through interrupts. It turns ON green LED till it gets pulses
· As the electricity fails, no more pulse output from ZCD
· So AT89C4051 does not get any interrupt. If it does not get any interrupt till 50 ms, it turns OFF green LED and turns ON red LED. Also it sends high output to reset pin of NE555 for 3-5 sec. So the audio tone is heard
· Thus when electricity fails this circuit gives audio-visual indication
· Again when electricity resumes. ZCD gives output pulses. So AT89C4051 gets regular interrupts and it turns OFF red LED and turns ON green LED.
This entire working and operation is due to the program embedded into the internal ROM (FLASH) of micro controller. The micro controller performs all the tasks due to this program
Software program and logic explanation:
The program is the soul of entire system. The logic is very simple. The program starts timer that generates interrupt after 50 ms when it expires. But this timer is reset after every 10 ms when pulses generates external interrupt. This means till the program gets pulses, the timer cannot expires. But when program does not get pulses till 50 ms, the timer cannot be reset. So it expires and it generates another interrupt. This timer interrupt will turn ON red LED and sounds buzzer for 3-5 sec. the program is written C language for MCS51 family of micro controller and it is compiled using KEIL (IDE) software tool. It consists of two ISRs (interrupt service routines) one for external interrupt (intr()) and other for timer interrupt (timer()), one main function and one delay function. The complete code is given here with necessary comments
Project Source Code
###
#include <reg51.h>
#define ON 0;
#define OFF 1;
sbit light_led = P3^0; //green LED pin
sbit light_gone_led = P3^1; // red LED pin
sbit buz = P1^5; // buzzer pin
unsigned int light_fail_flag=0;
/////////////////////// function for 3-5 sec delay //////////////////////////
void delay()
{
int y,z;
for(y=0;y<500;y++)
for(z=0;z<1000;z++);
}
//////////////////////// timer ISR //////////////////////////////////////////
void timer() interrupt 1
{
TR0=0; // stop timer
light_led = OFF; // green LED OFF
light_gone_led=ON; // red LED ON
buz = 1; // buzzer ON
delay(); // delay for 3-5 sec
buz = 0; // buzzer OFF
light_fail_flag=1; // set flag
}
///////////////////// external interrupt ISR ////////////////////////////////
void intr() interrupt 2
{
TH0=0x3C; // reset timer
TL0=0xAF;
light_led = ON // green LED ON
if(light_fail_flag==1) // if flag set
{
light_fail_flag=0; // reset the flag
light_gone_led = OFF; // turn OFF red LED
TR0=1; // start timer again
}
}
///////////////////// main function ///////////////////////////////////////
void main()
{
TMOD=0x01; // configure and initialize
TL0 = 0xAF; // timer to expire after 50 ms
TH0 = 0x3C;
TR0 = 1; // start timer
P3=0x08; // PORT P3 pins as output
P3 = 0x0F; // turn OFF both LEDs first
IE = 0x86; // enable both interrupts
while(1) // continuous loop
{
light_led = OFF;
}
}
###
Circuit Diagrams
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.