Sie sind auf Seite 1von 55

AN OVERVIEW

With the imminent privatization of electricity distribution there has been a spurt in the demand of meters with advanced features. Induction type electromechanical energy meters are extensively used for measurement of energy in domestic and industrial ac circuits. They posses lower friction and higher torque to weight ratio. But they possess a lower level of reliability.

This calls for the introduction and use of high quality static meters that are highly reliable and user friendly. Static meters have a number of advantages. High reproducibility of the measured results due to the absence of moving components in the measuring circuit. Very narrow error band over a large load range Less dependency of the measuring properties on network and environmental influences

The other major enhancements that can be made to the static digital energy meter is the addition of the prepaid feature to it which supplements the above advantages over the induction meter

The present day technologies first measure and then charge the customer. This prepaid energy meter is loaded with advanced features to fulfill the requirements of the future so as to charge the customer beforehand for the

electricity they will be consuming hence avoiding huge losses due to nonpayment of bills to the electricity company. Our project "FUTURE ENERGY METER is an endeavor to construct such a meter, which is economical, reliable and secure and would prove to be beneficial for the electricity distribution and consumption and would minimize the huge losses due to non-payment of bills on time.

KEY FEATURES
The important features of this future energy meter are stated here:

Static
This meter is static in the sense that it does not depend on moving parts such as rotating ferry wheels (used in induction type meters) for its operation. All the advantages of static meters are present in this meter also.

Microcontroller controlled
This energy meter is designed around an AT89S52 microcontroller. The microcontroller is feeded by energy meters CAL LED (sensing LED elements), which indicates unit consumption (150 time glow indicate one unit). This yields a high degree of accuracy and reliability. The very use of microcontroller allows programmability, which is one of the most important and useful features of this meter.

User friendly
The meter is highly user friendly in the sense that the power used is monitored and the information is displayed through a 16 x 2 LCD module The LCD module also displays the balance amount. Thus the user is constantly informed of his power usage where upon he can control his power usage according to his budget.

Tamper proof
No one can tamper the equipment (which is a common case with ordinary meters) since all the measurements and calculations are done in the microcontroller, which is not accessible to an ordinary consumer.

Overloading
No one can temper this meter by overloading (which is a common case with ordinary meters). We set the load value in the micro controller; if someone overload meter by crossing the set value, the meter indicate three time buzzer alert after which the system gets blocked.

Low cost
One of our main objectives was to reduce the cost as far as possible. Every effort has been done to keep the hardware count to a minimum.

ABSTRACT
FUTURE ENERGY METER
This prepaid energy system works as our pre-paid mobile phone service works; if we have value in prepaid meter we can consume electricity and if we dont have it, microcontroller circuit automatically cuts off the power supply.

It is possible that our energy meter can act as a mobile and get connected with any mobile network service for instant charging as it works for mobiles. The pre-paid energy meter makes the use of pre-paid card (ENERGY CARD). This meter works according to the information (PASSWORD) stored in the ENERGY CARD. Energy cards are available as per unit and they are available on local retail shops. In this project we have two kinds of energy cards, one with five units as recharge and the other one with ten units on it.

The meter also takes care of OVERLOADING problem which is usually present in conventional meters. Our meter automatically shuts down the electricity supply if the power that is being consumed exceeds the specified power rating of the meter. In our project we have specified it as 100 watts.

SPECIFICATIONS
Microcontroller: ATMEL 89S52 24C02 Memory IC AC Single Phase two wire 240 volts,50 Hz Electronic meter Single Pole Double Throw(SPDT) Relay 16x2 LCD Crystal Oscillator with frequency 11.05 MHz 12 volt,750 milli ampere Centre tap Step Down Transformer LM7805 Power Supply Regulator Transistor: BC 548 12 volt Piezoelectric Buzzer Diodes Capacitors: 25 volt,1000F electrolytic capacitor 10 volt, 1000F electrolytic capacitor 27 pF ceramic capacitors 10 mF electrolytic capacitors Resistors 220 volt AC Power Supply LEDs Switch and Push Buttons 60 watt and 100 watt bulbs

ATMEL 89S52
Description
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels high -density nonvolatile memory technology and is compatible with the industrystandard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a sixvector two-level interrupt architecture, a full duplex serial port, onchip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM con-tents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.

Pin Configuration
P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST (RXD) P3.0 (TXD) P3.1 (INT0) P3.2 (INT1) P3.3 (T0) P3.4 (T1) P3.5 (WR) P3.6 (RD) P3.7 XTAL2 XTAL1 GND 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 Vcc P0.0 (AD0) P0.1 (AD1) P0.2 (AD2) P0.3 (AD3) P0.4 (AD4) P0.5 (AD5) P0.6 (AD6) P0.7 (AD7) EA/VPP ALE/PROG PSEN P2.7 (A15) P2.6 (A14) P2.5 (A13) P2.4 (A12) P2.3 (A11) P2.2 (A10) P2.1 (A9) P2.0 (A8)

LM7805
Description
The MC78XX/LM78XX/MC78XXA series of three terminal positive regulators are available in the TO-220/D-PAK package and with several fixed output voltages, making them useful in a wide range of applications. Each type employs internal current limiting, thermal shut down and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output current. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents.

RELAY
A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches. Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical.

BLOCK DIAGRAM

BLOCK DIAGRAM OF FUTURE ENERGY METER

PCB LAYOUT

PCB LAYOUT OF FUTURE ENERGY METER

SOFTWARE
CODING
Hardware
#include<REG52.h> #include<string.h> #include<intrins.h> unsigned char code unsigned char code unsigned char code unsigned char code unsigned char code unsigned char code unsigned char code unsigned char code unsigned char code unsigned char code PASS5_1[]={"0000011111"}; PASS5_2[]={"1111122222"}; PASS5_3[]={"2222233333"}; PASS5_4[]={"3333344444"}; PASS5_5[]={"4444455555"}; //MAXIMUM PASS5_6[]={"5555566666"}; PASS5_7[]={"6666677777"}; PASS5_8[]={"7777788888"}; PASS5_9[]={"8888899999"}; PASS5_10[]={"9999900000"};

unsigned char code PASS10_1[]={"1111111111"}; unsigned char code PASS10_2[]={"1222222222"}; unsigned char code PASS10_3[]={"1333333333"}; unsigned char code PASS10_4[]={"1444444444"}; unsigned char code PASS10_5[]={"1555555555"}; unsigned char code PASS10_6[]={"1666666666"}; unsigned char code PASS10_7[]={"1777777777"}; unsigned char code PASS10_8[]={"1888888888"}; unsigned char code PASS10_9[]={"1999999999"}; unsigned char code PASS10_10[]={"2000000000"}; unsigned char code met_over[]={"METER OVERLOAD"}; #define PULSE 3 #define limit 3 #define timerlimit 30 #define lcd_port P0 sbit rs = P1^0; sbit en = P1^1; sbit METER_PIN = P3^2; sbit main1=P3^0; sbit buzzer=P3^3;

sbit colum1 = P2^0; sbit colum2 = P2^1; sbit colum3= P2^2; sbit colum4= P2^3; sbit row1 = P2^4; sbit row2 = P2^5; sbit row3 = P2^6; sbit row4= P2^7; typedef unsigned char uc; typedef unsigned int ui; // Header File : To implement i2c Driver for 89c51 device // Status : Running with full efficiency // Crystal used : 11.05 Mhz // Microcontroller used: AT89S52 //______________________________________________________________________ _______ #define HIGH 1 #define LOW 0 #define TRUE 1 #define FALSE 0 sbit sda= P1^3; sbit scl = P1^2; bit i2c_error; void i2c_devicew(int,unsigned int,unsigned char*,int,unsigned int ); void i2c_devicer(int ,unsigned int ,unsigned char *,int,unsigned int,unsigned int ); //first argument for selection of device second for position third for position forth for no of times to be write that data //************************************************ //first argument in reading for sending selectinon of device (0th position) second argument is for selection for //for address in the e2prom third argument is the address of the variable which is to be write forth is for no of times to be write //fifth argument is for for giving 0xa1 so on according to page no(page no from where to read for reading the data first time we have to write then read) first for write then for read last argument oxa0... so on (page no from where to read) we void store_data(unsigned char *,int); void read_data(unsigned char *,int); //adress of data to be stored & position in 12c where to store void send(int);

void i2c_start(); void i2c_stop(); void i2c_nack(); void i2c_ack(); void i2c_send(int); int i2c_get(void); void delaytime(unsigned int); bit i2c_error; #define no_of_bytes 105 idata int *memptr; void i2c_devicew(int device,unsigned int i2c_base,unsigned char *i2c_s,int i2c_count,unsigned int page) { while(i2c_count) { i2c_start(); if(i2c_error == TRUE) { i2c_stop(); i2c_count = 0; } else { if(device == 0x00) i2c_send(page); else i2c_send(0xd0); if(i2c_error == TRUE) { i2c_stop(); i2c_count = 0; } else { i2c_send(i2c_base); i2c_base++; if(i2c_error == TRUE) { i2c_stop(); i2c_count = 0; } else { i2c_send(*i2c_s);

i2c_s++; if(i2c_error == TRUE) { i2c_stop(); i2c_count = 0; } else { i2c_stop(); i2c_count--; delaytime(2500); } } } } } } void i2c_devicer(int device,unsigned int i2c_base,unsigned char *i2c_s,int i2c_count,unsigned int page,unsigned int write_page) { i2c_start(); if(i2c_error == TRUE) { i2c_stop(); i2c_count = 0; } else { if(device == 0x00) i2c_send(write_page); else i2c_send(0xd0); if(i2c_error == TRUE) { i2c_stop(); i2c_count = 0; } else { i2c_send(i2c_base); if(i2c_error == TRUE) { i2c_stop(); i2c_count = 0; }

else { i2c_start(); if(i2c_error == TRUE) { i2c_stop(); i2c_count = 0; } else { if(device == 0x00) i2c_send(page); else i2c_send(0xd1); if(i2c_error == TRUE) { i2c_stop(); i2c_count = 0; } else { while(i2c_count) { *i2c_s = i2c_get(); i2c_s++; if(i2c_count == 1) { i2c_nack(); i2c_stop(); i2c_count = 0; } else { i2c_ack(); i2c_count--; } } } } } } } } void i2c_start(void) {

sda = HIGH; delaytime(10); scl = HIGH; delaytime(10); if(sda == 0 | scl == 0) { i2c_error = TRUE; delAytime(10); } else { sda = HIGH; delaytime(10); scl = HIGH; delaytime(10); while(!scl) ; i2c_error = FALSE; delaytime(10); sda = LOW; delaytime(10); scl = LOW; delaytime(10); } } void i2c_stop(void) { sda = LOW; delaytime(10); scl = HIGH; delaytime(10); while(!scl) ; sda = HIGH; delaytime(10); } void i2c_ack(void) { sda = LOW; delaytime(10); scl = HIGH; delaytime(10);

while(!scl) ; scl= LOW; delaytime(10); } void i2c_nack(void) { sda = HIGH; delaytime(10); scl = HIGH; delaytime(10); while(!scl) ; scl = LOW; delaytime(10); } void i2c_send(int a) { idata int i=0x80,j; for(j=0x08;j>0x00;j--) { if((a & i) != 0x00) { sda = HIGH; delaytime(10); } else { sda = LOW; delaytime(10); } scl = HIGH; delaytime(10); while(!scl) ; scl = LOW; delaytime(0x0a); i = i>>1; } sda = TRUE; delaytime(0x0a); /////////////////////////////////////

scl = HIGH; delaytime(10); while(!scl) ; if(sda == HIGH) i2c_error = TRUE; else i2c_error = FALSE; scl = LOW; delaytime(10); } //******************************************************************* //******************************************************************* int { i2c_get(void) idata int a=0,temp; sda = HIGH; delaytime(10);// for(temp=0x08;temp>0x00;temp--) { delaytime(0x0a);//2 scl = HIGH; delaytime(10);// while(!scl) ; a = a << 0x01; if(sda == HIGH) a = a | 0x01; else a = a | 0X00; scl = LOW; delaytime(10);// } return(a); } ///////////////////////////////////////// /////////// void delaytime(unsigned int i) { while(i--); }

///////////////////////////////////////////////// void read_data(unsigned char *p,int i) { unsigned int page1,page2; page1=0xa1; page2=0xa0; i2c_devicer(0x00,i,p,1,page1,page2);

} ///***************************************************** void store_data(unsigned char *p,int i) { unsigned int page1; page1=0xa0; i2c_devicew(0x00,i,p,1,page1); }

MAIN
#include"lcd.c" #define reload1 20 #define psw_character 10 unsigned char user_psw[10]; unsigned int reload; unsigned char count_second; unsigned char display_value[3]; unsigned char display_value1[4]; unsigned char code first_display[]=" plz Recharge "; unsigned char code second_display[]="Ur Prepaid Meter"; unsigned char code third_display[]=" Enter pin no "; unsigned char code four_display[]=" Psw ok "; unsigned char code five_display[]="Recharge unit 05"; unsigned char code six_display[]="Recharge unit 10"; unsigned char code seven_display[]=" Psw not ok "; unsigned char code eight_display[]="1000 100 10 1 "; unsigned char meter_read_low,meter_read_high; unsigned char timepluseext=0; unsigned char reload2=reload1;

unsigned char timer_limit=0; unsigned char overload=0; unsigned char memory_store[50]; unsigned int meter_reading; bit calling_flag=0; bit data_change=0; bit psw_ok5=0; bit psw_ok10=0; bit cal_flag=0; bit buzzeroverload_flag=0; unsigned char position=0,validkeyno; unsigned char unit ; unsigned char counter=0; unsigned char count=0; void send_teledata(unsigned char); void display(); void convert_bcd(); void display1(); void convert_bcd1(); void keysense(); void keyserve(); void initialize_system(); void main() { unsigned char j,k,temprary1,temprary2; unsigned char temp_memory; initialize_system(); TF1=1; main1=0; cal=0; buzzer=0; std=0; initialize_lcd(); read_data(&temp_memory,22); unit=temp_memory; read_data(&meter_read_high,23); read_data(&meter_read_low,24); meter_reading=meter_read_high; meter_reading=meter_reading<<8; meter_reading=meter_reading | meter_read_low; for(j=0;j<20;j++) read_data(& memory_store[j],j+1); for(k=1;k<=10;k++) {

read_data(&memory_store[20+k],26+k); calling_no[k-1]=memory_store[20+k]; } if(unit==0) { lcd_write_aray(first_display); lcd_gotoxy(2,0); lcd_write_aray(second_display); } else { data_change=1; if(unit==1) { TH0=0X3C; TL0=0XB0; reload=reload1; TR0=1; main1=1; } else if(unit>0) main1=1; } TR1=1; while(1) { if(unit>0) relay_flag=0; if( buzzeroverload_flag==1) { buzzer=1; delay(10000); buzzer=0; delay(10000); buzzeroverload_flag=0; } if(overload>=3) { main1=0; EA=0; lcd_clr(); lcd_write_aray(met_over); main1=0; buzzer=1; delay(10000); buzzer=0;

relay_flag=0; goto next; } keysense(); keyserve(); if(calling_flag==0) { if(data_change==1) { position=0; lcd_clr(); lcd_write_aray(eight_display); convert_bcd(); display(); convert_bcd1(); display1(); data_change=0; temp_memory=unit; store_data(&temp_memory,22); if(unit==0) { lcd_clr(); lcd_write_aray(first_display); lcd_gotoxy(2,0); lcd_write_aray(second_display); } meter_read_low=meter_reading; meter_read_high=meter_reading>>8; store_data(&meter_read_high,23); store_data(&meter_read_low,24); } if(psw_ok5==1) { TR0=0; buzzer=0; cal=0; main1=1; lcd_write_aray(four_display); unit=unit+5; delay(50000); lcd_clr(); lcd_write_aray(five_display); } else if(psw_ok10==1) {

TR0=0; buzzer=0; cal=0; main1=1; lcd_write_aray(four_display); unit=unit+10; delay(50000); lcd_clr(); lcd_write_aray(six_display); } else { //main1=0; lcd_clr(); lcd_write_aray(seven_display); delay(50000); delay(50000); if(unit==0) { lcd_clr(); lcd_write_aray(first_display); lcd_gotoxy(2,0); lcd_write_aray(second_display); } } delay(50000); delay(50000); for(j=0;j<20;j++) store_data(& memory_store[j],j+1); if(unit>0) { lcd_clr(); lcd_write_aray(eight_display); data_change=1; //TR0=1; } enter=0; psw_ok5=0; psw_ok10=0; } }//if calling_flag }//while } //************************************************************* void initialize_system() {

P0 = 0XFF; P1 = 0XFF; P2 = 0XFF; P3 = 0XFF; EX0=0x01; EA = 0x01; // IE=0X83; // TMOD =0X01; IE=0X8b; TMOD =0X11; TH1=0X3C; TL1=0XB0; TH0=0X3C; TL0=0XB0; IT0=0x01;

//set interrupt enable

} //******************************************* void ext0isr() interrupt 0 using 1 { timepluseext++;

if(timepluseext>=limit) { buzzeroverload_flag=1; overload++; timer_limit=0; timepluseext=0; reload2=reload1; }

if(++counter%PULSE==0) { counter=0; if(unit>0) meter_reading++; unit--; count=0; data_change=1; main1=1; } if(unit==1) { buzzer=1; cal_flag=1;

TH0=0X3C; TL0=0XB0; reload=reload1; TR0=1; } if(unit==0) main1=0; } //********************************************* void timer0 (void) interrupt 1 using 2 { TH0=0X3C; TL0=0XB0; if(--reload==0) { reload=reload1; buzzer=0; // { count_second=0; buzzer=1; } } } //*********************************** void timer1 (void) interrupt 3 using 3 { if(--reload2==0) { reload2=reload1; if(timer_limit<timerlimit) timer_limit++; if(timer_limit==timerlimit) { //if(timepluseext>limit) // { buzzeroverload_flag=0; //overload++; //} // else if(unit<2); if(++count_second==10)

overload=0; timepluseext=0; timer_limit=0; } } } //***************************************** void send_teledata(unsigned char a) { unsigned char data1; data1=P1; data1=data1<<4; data1=data1>>4; a=a<<4; data1=data1 | a; P1=data1; } //******************************************* void keyserve(void) { char i,j; switch(validkeyno) { case 05: calling_flag=1; enter_pin=0; lcd_clr(); lcd_write_aray(nine_display); lcd_gotoxy(2,6); for(i=0;i<psw_character;i++) calling_no[i]=0; position=0; break; case 04: if(!key4done) { key4done = 1; switch(count) { case 0: if(enter_pin==1) { if(position< psw_character) { user_psw[position]='3';

lcd_putc('3'); position++; } } if(calling_flag==1) { if(position< psw_character) { calling_no[position]=3; lcd_putc('3'); position++; } } break; case 1: if(enter_pin==1) { if(position< psw_character) { user_psw[position]='7'; lcd_putc('7'); position++; } } if(calling_flag==1) { if(position< psw_character) { calling_no[position]=7; lcd_putc('7'); position++; } } break; case 3: for(j=0;j<20;j++) { memory_store[j]=0; store_data(& memory_store[j],j+1); } unit=0; meter_reading=0; data_change=1; position=0; break; case 2:

if(calling_flag==1) { calling_flag=0; lcd_clr(); data_change=1; position=0; for(j=1;j<=10;j++) { memory_store[20+j]=calling_no[j-1]; store_data(&memory_store[20+j],j+26); } } if(enter_pin==1) { enter=1; for(i=0;i<20;i++) { if(psw_ok5==0 && psw_ok10==0) { switch(i) { case 0: if(memory_store[0]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_1[j]) goto out; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[0]=1; } } out:break; case 1: if(memory_store[1]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_2[j]) goto out1; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[1]=1;

} } out1:break; case 2: if(memory_store[2]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_3[j]) goto out2; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[2]=1; } } out2:break; case 3: if(memory_store[3]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_4[j]) goto out3; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[3]=1; } } out3:break; case 4: if(memory_store[4]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_5[j]) goto out4; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[4]=1; } } out4:break; case 5:

if(memory_store[5]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_6[j]) goto out5; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[5]=1; } } out5:break; case 6: if(memory_store[6]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_7[j]) goto out6; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[6]=1; } } out6:break; case 7: if(memory_store[7]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_8[j]) goto out7; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[7]=1; } } out7:break; case 8: if(memory_store[8]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_9[j])

goto out8; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[8]=1; } } out8:break; case 9: if(memory_store[9]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS5_10[j]) goto out9; if(j==10) { lcd_clr(); psw_ok5=1; memory_store[9]=1; } } out9:break; case 10: if(memory_store[10]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS10_1[j]) goto out10; if(j==10) { lcd_clr(); psw_ok10=1; memory_store[10]=1; } } out10:break; case 11: if(memory_store[11]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS10_2[j]) goto out11; if(j==10) { lcd_clr();

psw_ok10=1; memory_store[11]=1; } } out11:break; case 12: if(memory_store[12]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS10_3[j]) goto out12; if(j==10) { lcd_clr(); psw_ok10=1; memory_store[12]=1; } } out12:break; case 13: if(memory_store[13]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS10_4[j]) goto out13; if(j==10) { lcd_clr(); psw_ok10=1; memory_store[13]=1; } } out13:break; case 14: if(memory_store[14]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS10_5[j]) goto out14; if(j==10) { lcd_clr(); psw_ok10=1; memory_store[14]=1; } }

out14:break; case 15: if(memory_store[15]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS10_6[j]) goto out15; if(j==10) { lcd_clr(); psw_ok10=1; memory_store[15]=1; } } out15:break; case 16: if(memory_store[16]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS10_7[j]) goto out16; if(j==10) { lcd_clr(); psw_ok10=1; memory_store[16]=1; } } out16:break; case 17: if(memory_store[17]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS10_8[j]) goto out17; if(j==10) { lcd_clr(); psw_ok10=1; memory_store[17]=1; } } out17:break; case 18: if(memory_store[18]==0) {

for(j=0;j<10;j++) if(user_psw[j]!=PASS10_9[j]) goto out18; if(j==10) { lcd_clr(); psw_ok10=1; memory_store[18]=1; } } out18:break; case 19: if(memory_store[19]==0) { for(j=0;j<10;j++) if(user_psw[j]!=PASS10_10[j]) goto out19; if(j==10) { lcd_clr(); psw_ok10=1; memory_store[19]=1; } } out19:break; } } } break; } } } break; case 03: if (!key3done) { key3done = 1; switch(count) { case 0: if(enter_pin==1) { if(position< psw_character) { user_psw[position]='2'; lcd_putc('2');

position++; } } if(calling_flag==1) { if(position< psw_character) { calling_no[position]=2; lcd_putc('2'); position++; } } break; case 1: if(enter_pin==1) { if(position< psw_character) { user_psw[position]='6'; lcd_putc('6'); position++; } } if(calling_flag==1) { if(position< psw_character) { calling_no[position]=6; lcd_putc('6'); position++; } } break; case 2: if(position>0) { position--; if(enter_pin==1) user_psw[position]='0'; else if(calling_flag==1) calling_no[position]=0; switch(position) { case 9: lcd_gotoxy(2,15);

lcd_putc(' '); lcd_gotoxy(2,15); break; case 8: lcd_gotoxy(2,14); lcd_gotoxy(2,14); break; case 7: lcd_gotoxy(2,13); lcd_putc(' '); lcd_gotoxy(2,13); break; case 6: lcd_gotoxy(2,12); lcd_putc(' '); lcd_gotoxy(2,12); break; lcd_putc(' ');

case 5: lcd_gotoxy(2,11); lcd_putc(' '); lcd_gotoxy(2,11); break; case 4: lcd_gotoxy(2,10); lcd_putc(' '); lcd_gotoxy(2,10); break; case 3: lcd_gotoxy(2,9); lcd_putc(' '); lcd_gotoxy(2,9); break; case 2: lcd_gotoxy(2,8); lcd_putc(' '); lcd_gotoxy(2,8); break; case 1: lcd_gotoxy(2,7); lcd_putc(' '); lcd_gotoxy(2,7); break; case 0: lcd_gotoxy(2,6); lcd_putc(' '); lcd_gotoxy(2,6);

break; } } break; case 3: for(j=0;j<20;j++) { memory_store[j]=0; store_data(& memory_store[j],j+1); } break; } } break;

case 02: if (!key2done) { key2done = 1; switch(count) { case 0: if (enter_pin==1) { if(position< psw_character) { user_psw[position]='1'; lcd_putc('1'); position++; } } if(calling_flag==1) { if(position< psw_character) { calling_no[position]=1; lcd_putc('1'); position++; } }

break; case 1: if(enter_pin==1) { if(position< psw_character) { user_psw[position]='5'; lcd_putc('5'); position++; delay(100); } } if(calling_flag==1) { if(position< psw_character) { calling_no[position]=5; lcd_putc('5'); position++; } } break; case 2: if(enter_pin==1) { if(position< psw_character) { user_psw[position]='9'; lcd_putc('9'); position++; } } if(calling_flag==1) { if(position< psw_character) { calling_no[position]=9; lcd_putc('9'); position++; } } break; case 3:

lcd_clr(); lcd_write_aray(third_display); lcd_gotoxy(2,6); for(i=0;i<psw_character;i++) user_psw[i]=0; position=0; enter_pin=1; calling_flag=0; } }

break;

case 01:

// here enter keys opration is taken whether first tim

if(!key1done) { key1done = 1; switch(count) { case 0: if(enter_pin==1) { if(position< psw_character) { user_psw[position]='0'; lcd_putc('0'); position++; } } if(calling_flag==1) { if(position< psw_character) { calling_no[position]=0; lcd_putc('0'); position++; } } break; case 1: if(enter_pin==1)

{ if(position< psw_character) { user_psw[position]='4'; lcd_putc('4'); position++; } } if(calling_flag==1) { if(position< psw_character) { calling_no[position]=4; lcd_putc('4'); position++; } } break; case 2: if(enter_pin==1) { if(position< psw_character) { user_psw[position]='8'; lcd_putc('8'); position++; } case 3: if(enter_pin==1) { if(position< psw_character) { user_psw[position]='*'; lcd_putc('*'); position++; } } if(calling_flag==1) { } break; } }

break; }//end of switch

} //keyserve //************key sensing routine************** // here each key is checked for whether the pin is low and first time routine goes // back without giving any output next time if the key is still pressed and the flag // which indicates that the key was pressed last time also , then valid key is assumed // to be sensed and its key no is sent to the main loop. // here key1flag,key2flag,key3flag,key4flag are used . // and these flag and valid key no are cleared when no key is pressed.

void keysense(void) { if(count==0) { row1=0; row2=1; row3=1; row4=1; } if(count==1) { row1=1; row2=0; row3=1; row4=1; } if(count==2) { row1=1; row2=1; row3=0; row4=1; } if(count==3) { row1=1; row2=1;

row3=1; row4=0; } if(colum1 == 0) { if(key1flag == 1) { validkeyno = 1; delay(40); } else key1flag = 1; } else if(colum2 == 0) { if(key2flag == 1) { validkeyno = 2; delay(40); } else key2flag = 1; } else if(colum3 == 0) { if(key3flag == 1) { validkeyno = 3; delay(40); } else key3flag = 1; } else if(colum4 == 0) { if(key4flag == 1) { validkeyno = 4;

delay(40); } else key4flag = 1; } else if(individual_key == 0) { if(key5flag == 1) { validkeyno = 5; delay(40); } else key5flag = 1; } else { key1flag=0; key2flag=0; key3flag=0; key4flag=0; key1done=0; key2done=0; key3done=0; key4done=0; key5done=0; key5flag=0; validkeyno=0; if(++count==4) count=0; } } //*********************************************** void convert_bcd() { unsigned char sensor_value; unsigned int loop=2; unsigned char temp;

sensor_value=unit; while(sensor_value>0)

{ temp=sensor_value%10; display_value[loop]=temp; sensor_value=sensor_value/10; loop--; } } //*********************************** void display() { unsigned int i; lcd_gotoxy(2,13); for(i=0;i<3;i++) { lcd_putc(display_value[i]+48); }//for for(i=0;i<3;i++) display_value[i]=0; } //************************************************** void convert_bcd1() { unsigned int sensor_value; unsigned int loop=3; unsigned char temp;

sensor_value=meter_reading; while(sensor_value>0) { temp=sensor_value%10; display_value1[loop]=temp; sensor_value=sensor_value/10; loop--; } } //*********************************** void display1() { unsigned int i;

for(i=0;i<4;i++) { if(i==0) lcd_gotoxy(2,2); else if(i==1) lcd_gotoxy(2,5); else if(i==2) lcd_gotoxy(2,8); else if(i==3) lcd_gotoxy(2,11); lcd_putc(display_value1[i]+48); }//for for(i=0;i<4;i++) display_value1[i]=0; }

LCD
//#include"memory.c" #include"hardwaredtmf.c" //#include<intrins.h>

//void delay(unsigned int); void delay(unsigned int); void initialize_lcd(); void lcd_clr(); void lcd_gotoxy(char,char); void lcd_write_aray(char *); void lcd_putc(unsigned char); //*************************** void lcd_write_aray(char *ptr) { while(*ptr!=0) { lcd_port=*ptr; rs=1; //rw=0; en=0; en=1;

delay(30); ptr++; } } //******************************************* void initialize_lcd() { lcd_port=0X38; rs=0; //rw=0; en=0; en=1; delay(1000); lcd_port=0X0E; rs=0; //rw=0; en=0; en=1; delay(1000); lcd_port=0X01; rs=0; //rw=0; en=0; en=1; delay(1000); lcd_port=0X80; rs=0; //rw=0; en=0; en=1; delay(1000);

} void lcd_clr() { lcd_port=0X0E; rs=0; en=0; en=1;

delay(1000); lcd_port=0X01; rs=0; //rw=0; en=0; en=1; delay(1000); } //********************************** void lcd_gotoxy(char row,char col) { unsigned char j; if(row==1) j=128; if(row==2) j=192; j=j+col; if(row==1) { lcd_port=0X80; rs=0; en=0; en=1; delay(1000); } if(row==2) { lcd_port=0Xc0; rs=0; en=0; en=1; delay(1000); } lcd_port=j; rs=0; en=0; en=1; delay(1000); } //****************************************** void lcd_putc(unsigned char data1) {

lcd_port=data1; rs=1; //rw=0; en=0; en=1; delay(30); } //********************* void delay(unsigned int l) { while(l--); }

WORKING
In this project, we are sensing digital meter (cal 2/75) part and we are using this calibration part as a unit form to demonstrate our model.

ABOUT METER
When we put load over on our pre-paid meter, it reduces the unit value of the meter. When we have two units remaining, it produces buzzer alarm to inform the user about the impending recharge.

INPUT VOLTAGE TO THE CIRCUIT


The transformer steps down the AC voltage to 12 volts which is the rectified by a full wave rectifier. A 25 volts, 1000F electrolytic capacitor then removes the ripples.

89S52 ATMEL MICROCONTROLLER


This is core of our FUTURE ENERGY METER the software part is in C language which is then burned. The microcontroller acts as an interface between the hardware and software part of the system.

24C02 MEMORY IC
It is used as an external memory in case of power supply failure.

16x2 LCD DISPLAY


It is used to display the number of consumed units along with the units remaining.

SPDT RELAY
It acts as main switch of the system

HOW TO RECHARGE OUR METER


The recharging is done by 4x4 push button matrix.

CIRCUIT DIAGRAM

CIRCUIT DIAGRAM OF FUTURE ENERGY METER

ADVANTAGES AND DISADVANTAGES


Advantages:
Pay before use. Recover money owed (debt). Lower Overheads. No bill production. No bill distribution. No need to chase payments. No further actions such as disconnections. Eliminates the ill-practice of overloading.

Disadvantages:
The main disadvantage of the system is, because of huge electronic hardware involved in the system, the overall system consumes more electric energy Remedy: When the system is converted into engineering module, the bulky hardware can be converted into a small-integrated chip. When the hardware is minimized naturally the system would consume less power. Since it is a prototype module, the huge hardware of the system occupies more space.

APPLICATIONS
In homes. In festivals where electricity is required just for a few days. Rental accommodation. In industries and factories. In malls.

REFERENCES
Electronic Devices and Circuit Theory by Bolystead and Nashelsky. Electronic Devices and Circuits by Jacob Milman and Christos C.
Halkias.

8051 Microcontroller and Embedded Systems by Mohammed Ali Mazidi


and Janice Gillispie.

Advanced Microprocessors and Peripherals by A.K. Ray and K.M.


Bhurchandi

Electronic Devices and Circuits by Bogart. Integrated Circuits by Botkar. The 8051 Microcontroller by Kenneth Ayala. The Atmel corporation website www.atmel.com for all the data sheets. www.wikipedia.com.

Das könnte Ihnen auch gefallen