Professional Documents
Culture Documents
Electricity Billing System
Electricity Billing System
Electricity Billing System
INTRODUCTION
1.1 OVERVIEW
A scheme of Electricity billing system called PREPAID ENERGY METER
WITH TARIFF INDICATOR can facilitate in improved cash flow
management in energy utilities and can reduces problem associated with
billing consumer living in isolated area and reduces deployment of manpower
for taking meter readings. Every consumer can buy a memory card (is nothing
but an EEPROM IC) with a password stored inside it using a MC program.
The memory card is available at various ranges (ie. Rs 50, Rs 100, Rs 200
etc).In our project we have given the name for memory card as smart card.
When the consumer insert a smart card into the card reader which is connected
in prepaid energy meter with tariff indicator kit. Then the card reader will
read the stored information and delete the information from the EEPROM IC
(smart card) using the MC program. So that the smart card cannot be reused by
others. Suppose if a consumer buys a card for Rs.50/- he / she can insert this
amount through the card reader so that prepaid energy meter with tariff
indicator kit will be activated. According to the power consumption the
amount will be reduced. When the amount is over, the relay wills
automatically shutdown the whole system. In our project we also have a
provision to give an alarm sound to consumer before the whole amount is
reduced.
SeminarsTopics.com
SeminarsTopics.com
SeminarsTopics.com
CHAPTER-2
BLOCK DIAGRAM & ITS DESCRIPTION
When we give the dial a code from 4*3 Matrix keypad then the unit
price & recharge amount are stored in side the EEPROM AT24C02.
If card is completely recharged then and then the green led will glow
and if it fails then the red led will glow for a long period
SeminarsTopics.com
SeminarsTopics.com
And whenever the pulse count reaches the 3200 then it decreases the
charged amount and it will increases the meter reading by 1 and displays
it on the LCD screen.
And whenever the chaged amount reading reaches the minimum amount
then it will send pulse to the ULN 2003 driver Ic and it will turn of the
relay.and when relay off then the power will off.
If the user do not recharge the card then we will not get the energy.
SeminarsTopics.com
CHAPTER 3
SCHEMATIC DIAGRAM
1.
finally.
If it fails then the RED led will give a long blink.
AT 89s52 microcontroller
AT89c2051microcontroller
IC AT24c02
IC ULN2003
4*3 matrix keypad
16*2 LCD display
MCT2E 1 Ph meter
Buzzer
Resisters, capacitors,
SeminarsTopics.com
12 v/30 A Relay
SeminarsTopics.com
SeminarsTopics.com
SeminarsTopics.com
CHAPTER-5
PROGRAMMING IN ASSEMBLY LANGUAGE
EQU
000H
RB1
EQU
008H
;PORT DECLERATION
SDA1 EQU P2.1
;SDA=PIN5
;SCL=PIN6
RELAY
EQU P2.7
BUZZER
EQU P2.4
; ***LCD CONTROL***
LCD_RS
LCD_E
EQU
EQU
P0.0
P0.1
LCD_DB4 EQU
P0.2
LCD_DB5 EQU
P0.3
LCD_DB6 EQU
P0.4
;FOR DATA
LCD_DB7 EQU
P0.5
; FOR DATA
EQU
0CH
BLINKCUR EQU
SeminarsTopics.com
0DH ;
01H
ONDSP
0CH
EQU
; ***SYSTEM INSTRUCTIONS***
CONFIG
EQU
28H
ENTRYMODE EQU
DSEG
ORG
FLAGS1: DS 1
BCDCARRY BIT FLAGS1.0
CARRY BIT FLAGS1.1
TBIT BIT FLAGS1.2
TBIT1 BIT FLAGS1.3
READING: DS 2
AMOUNT: DS 3
COUNTER: DS 2
TEMP:DS 1
PRICE: DS 2
BALANCE: DS 1
BUZZ_COUNT: DS 1
READ_BYTE: DS 3
F1: DS 1
F2: DS 1
F3: DS 1
STACK: DS 1
CSEG
SeminarsTopics.com
; Reset
AJMP MAIN
ORG 0003H
PUSH PSW
PUSH ACC
MOV PSW,#RB1
CALL INC_COUNTER
POP ACC
POP PSW
RETI
MAIN: MOV SP,#50H
MOV PSW,#RB0
MOV IE,#10000001B
CALL RESETLCD4
CALL TITLE1
CLR BUZZER
SETB RELAY
CLR TBIT1
MOV BUZZ_COUNT,#00H
MOV READ_BYTE,#0FFH
CALL READ_COUNTER
MOV A,COUNTER
CJNE A,#0FFH,BYPASS
CALL RESET_READING
CALL RESET_AMT
CALL RESET_COUNTER
CALL RESET_PRICE
CALL RESET_BALANCE
CALL STORE_UNIT_PRICE
SeminarsTopics.com
CALL AMT_RECHARGE
CALL SYSTEM_RESET
CALL DELAYYS
CJNE A,#00H,AZX1
CLR BUZZER
AJMP AZX2
AZX1: DEC BUZZ_COUNT
AZX2: MOV R1,#READING
MOV R4,#05H
MOV R6,#2
;NUMBER OF BYTES
CALL READ_EEPROM
CALL DISP_READING
MOV TEMP,READING
SeminarsTopics.com
CALL SEP_DISP
MOV TEMP,READING+1
CALL SEP_DISP
CALL DELAYY
MOV R1,#AMOUNT
MOV R4,#0AH
MOV R6,#3
;NUMBER OF BYTES
CALL READ_EEPROM
CALL AMT_READING
MOV TEMP,AMOUNT
CALL SEP_DISP
MOV TEMP,AMOUNT+1
CALL SEP_DISP
MOV R4,#'.'
CALL WRLCDDATA
CALL MDELAY
MOV TEMP,AMOUNT+2
CALL SEP_DISP
CALL DELAYY
MOV R1,#COUNTER
MOV R4,#0EH
MOV R6,#2
;NUMBER OF BYTES
CALL READ_EEPROM
CALL COUNT_READING
MOV TEMP,COUNTER
CALL SEP_DISP
MOV TEMP,COUNTER+1
CALL SEP_DISP
SeminarsTopics.com
CALL DELAYY
MOV R1,#PRICE
MOV R4,#10H
MOV R6,#2
;NUMBER OF BYTES
CALL READ_EEPROM
CALL READ_PRICE
CALL UNIT_PRICE
MOV A,PRICE
ADD A,#30h
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV R4,#'.'
CALL WRLCDDATA
CALL MDELAY
MOV TEMP,PRICE+1
CALL SEP_DISP
CALL DELAYY
AJMP MAINS
;INCREMENT COUNTER BY 1
;IF COUNT=3200 THEN INCREMENT READING
INC_COUNTER: MOV A,COUNTER+1
ADD A,#01
DA A
MOV COUNTER+1,A
JNC DCV2
MOV A,COUNTER
ADD A,#01
SeminarsTopics.com
DA A
MOV COUNTER,A
CJNE A,#32h,DCV2
MOV COUNTER,#00H
MOV COUNTER+1,#00H
MOV R1,#COUNTER
;store COUNT
MOV R4,#0EH
MOV R6,#2
;STORE 2 BYTES
CALL STORE_EEPROM
CALL DELAY
AJMP DVB1
DCV2:
MOV R1,#COUNTER
;store COUNT
MOV R4,#0EH
MOV R6,#2
;STORE 2 BYTES
CALL STORE_EEPROM
CALL DELAY
RET
DVB1:
MOV A,READING+1
;INCREMENT READING BY 1
ADD A,#01
DA A
MOV READING+1,A
JNC DCS1
MOV A,READING
ADD A,#01
DA A
MOV READING,A
DCS1:
MOV R1,#READING
MOV R4,#05H
SeminarsTopics.com
;store READING
;Starting Address IN EEPROM
MOV R6,#2
;STORE 2 BYTES
CALL STORE_EEPROM
CALL DELAY
MOV A,AMOUNT+2
CLR C
SUBB A,PRICE+1
CALL BCD_CONV
MOV AMOUNT+2,A
MOV A,AMOUNT+1
SUBB A,PRICE
CALL BCD_CONV
MOV AMOUNT+1,A
MOV A,AMOUNT
SUBB A,#00h
CALL BCD_CONV
MOV AMOUNT,A
MOV R1,#AMOUNT
; store AMOUNT
MOV R4,#0AH
CJNE A,#38H,FAX1
MOV BUZZ_COUNT,#02H
SETB BUZZER
FAX1:
CJNE A,#41H,FAAX1
SeminarsTopics.com
MOV BUZZ_COUNT,#02H
SETB BUZZER
FAAX1:
CJNE A,#20H,FCX2
MOV BUZZ_COUNT,#03H
SETB BUZZER
FCX2:
CJNE A,#19H,FAX2
MOV BUZZ_COUNT,#03H
SETB BUZZER
FAX2:
CJNE A,#21H,FAAX2
MOV BUZZ_COUNT,#03H
SETB BUZZER
FAAX2:
CJNE A,#10H,FCX3
MOV BUZZ_COUNT,#04H
SETB BUZZER
FCX3:
CJNE A,#11H,FCX4
MOV BUZZ_COUNT,#04H
SETB BUZZER
FCX4:
CJNE A,#09H,FAX4
MOV BUZZ_COUNT,#04H
SETB BUZZER
FAX4:
CLR C
SUBB A,PRICE+1
CALL BCD_CONV
MOV A,AMOUNT+1
SUBB A,PRICE
MOV A,AMOUNT
CLR TBIT
JNC POP1
SeminarsTopics.com
SETB TBIT
POP1:
CJNE A,#00H,BACK
JNB TBIT, BACK
MOV BALANCE,#00H
MOV R1,#BALANCE
; store COUNT
MOV R4,#15H
MOV R6,#1
CALL STORE_EEPROM
CALL DELAY
CLR RELAY
SETB BUZZER
BACK:
RET
JNB AC,LOP1
SETB BCDCARRY
CLR C
SUBB A,#06H
LOP1:
JNB CARRY,LOP3
CLR C
SUBB A,#60H
LOP3:
CLR C
JNB CARRY,LOP4
SETB C
LOP4:
RET
SeminarsTopics.com
; STORE 2 BYTES
MOV R4,#15H
MOV R6,#1
; NUMBER OF BYTES
CALL READ_EEPROM
RET
READ_COUNTER: MOV R1,#COUNTER
MOV R4,#0EH
MOV R6,#2
CALL READ_EEPROM
RET
READ_PRICE:
MOV R1,#PRICE
MOV R4,#10H
MOV R6,#2
; NUMBER OF BYTES
CALL READ_EEPROM
RET
SEP_DISP1:
MOV A,AMOUNT
ANL A,#0F0H
SWAP A
CJNE A,#00H,DAP1
MOV A,AMOUNT
ANL A,#0FH
AJMP DAP3
DAP1:
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
DAP2:
MOV A,AMOUNT
ANL A,#0FH
SeminarsTopics.com
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
DAP4:
MOV A,AMOUNT+1
ANL A,#0F0H
SWAP A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
DAP5:
MOV A,AMOUNT+1
ANL A,#0FH
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV R4,#'.'
CALL WRLCDDATA
CALL MDELAY
MOV A,AMOUNT+2
ANL A,#0F0H
SWAP A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV A,AMOUNT+2
SeminarsTopics.com
ANL A,#0FH
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
RET
DAP3: CJNE A,#00H,DAP2
;CHK 2 DIGIT
MOV A,AMOUNT+1
ANL A,#0F0H
SWAP A
CJNE A,#00H,DAP4
AJMP DAP5
SEP_DISP:
MOV A,TEMP
ANL A,#0F0H
SWAP A
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
MOV A,TEMP
ANL A,#0FH
ADD A,#30H
MOV R4,A
CALL WRLCDDATA
CALL MDELAY
RET
SeminarsTopics.com
;CHK 3 DIGIT
AMT_RECHARGE:
MOV READ_BYTE,#01H
MOV READ_BYTE+1,#00H
MOV READ_BYTE+2,#10H
MOV R1,#READ_BYTE
MOV R6,#3
;store COUNT
;STORE 2 BYTES
MOV A,#WTCMD1
CALL OUTS
;SEND IT
MOV A,#20H
CALL OUT
;SEND IT
;GET DATA
CALL OUT
;SEND IT
INC R1
DJNZ R6,BXLP
CALL STOP
CALL DELAY
RET
STORE_UNIT_PRICE: MOV READ_BYTE,#00H
MOV READ_BYTE+1,#01H
MOV READ_BYTE+2,#00H
MOV R1,#READ_BYTE
;store COUNT
MOV R6,#3
;STORE 2 BYTES
MOV A,#WTCMD1
CALL OUTS
BALP:
;SEND IT
MOV A,#20H
CALL OUT
;SEND IT
MOV A,@R1
SeminarsTopics.com
;GET DATA
CALL OUT
;SEND IT
INC R1
DJNZ R6,BALP
CALL STOP
CALL DELAY
RET
RESET_BALANCE:
MOV BALANCE,#0FFH
MOV R1,#BALANCE
;store COUNT
MOV R4,#15H
MOV R6,#1
;STORE 2 BYTES
CALL STORE_EEPROM
CALL DELAY
RET
RESET_PRICE:
MOV PRICE,#02H
MOV PRICE+1,#00H
MOV R1,#PRICE
;store COUNT
MOV R4,#10H
MOV R6,#2
;STORE 2 BYTES
CALL STORE_EEPROM
CALL DELAY
RET
RESET_COUNTER:
MOV COUNTER,#00H
MOV COUNTER+1,#10H
MOV R1,#COUNTER
;store COUNT
MOV R4,#0EH
MOV R6,#2
;STORE 2 BYTES
SeminarsTopics.com
CALL STORE_EEPROM
CALL DELAY
RET
RESET_AMT:
MOV AMOUNT,#00H ;
MOV AMOUNT+1,#05H
MOV AMOUNT+2,#00H
MOV R1,#AMOUNT ;store READING
MOV R4,#0AH
MOV R6,#3
;STORE 2 BYTES
CALL STORE_EEPROM
CALL DELAY
RET
RESET_READING:
MOV READING,#00H
MOV READING+1,#05H
MOV R1,#READING;store READING
MOV R4,#05H
MOV R6,#2
;STORE 2 BYTES
CALL STORE_EEPROM
CALL DELAY
RET
DELAYY: MOV F1,#0FH
SEP3: MOV F2,#0fFH
SEP2: MOV F3,#0FFH
SEP1: DJNZ F3,SEP1
DJNZ F2,SEP2
CALL CARD_READ
SeminarsTopics.com
MOV A,READ_BYTE
CJNE A,#0FFH,DSP1
CLR TBIT1
DSP3:DJNZ F1,SEP3
RET
DELAYYS:
MOV F1,#0FH
DSP1:JB TBIT1,DSP3A
CALL TITLE3
CALL DELAYS
CALL DELAYS
CALL CARD_READ
MOV A,READ_BYTE
CJNE A,#00H,DSP2
CALL TITLE4
MOV PRICE,READ_BYTE+1
MOV PRICE+1,READ_BYTE+2
MOV R1,#PRICE
;store COUNT
MOV R4,#10H
MOV R6,#2
;STORE 2 BYTES
CALL STORE_EEPROM
CALL DELAYS
SeminarsTopics.com
SETB TBIT1
AJMP RESETX_CHIP
DSP2: CJNE A,#01H,DSP3
CALL TITLE5
;NEW RECHARGE
MOV R1,#AMOUNT
MOV R4,#0AH
MOV R6,#03h
;NUMBER OF BYTES
CALL READ_EEPROM
MOV A,AMOUNT
ADD A,READ_BYTE+1
DA A
MOV AMOUNT,A
MOV A,AMOUNT+1
ADDC A,READ_BYTE+2
DA A
MOV AMOUNT+1,A
MOV R1,#AMOUNT
;store READING
MOV R4,#0AH
MOV R6,#03h
;STORE 2 BYTES
CALL STORE_EEPROM
CALL DELAYS
SETB TBIT1
CALL RESET_BALANCE
RESETX_CHIP:
MOV READ_BYTE,#0AAH
MOV READ_BYTE+1,#0FFH
MOV READ_BYTE+2,#0FFH
SeminarsTopics.com
;ERASE AMOUNT
MOV R1,#READ_BYTE
;store COUNT
MOV R6,#3
;STORE 2 BYTES
MOV A,#WTCMD1
CALL OUTS
;SEND IT
MOV A,#20H
CALL OUT
BBLP: MOV A,@R1
CALL OUT
;SEND IT
INC R1
DJNZ R6,BBLP
CALL STOP
CALL DELAY
RET
DSP3: CJNE A,#0AAH,DSP4
CALL TITLE6
;NEW RECHARGE
CALL DELAYS
SETB TBIT1
DSP4: RET
DELAY:MOV R6,#0FFH
RE1: MOV R7,#0FFH
RE:
NOP
DJNZ R7,RE
DJNZ R6,RE1
RET
CARD_READ:
MOV R1,#READ_BYTE
MOV R6,#3
;NUMBER OF BYTES
MOV A,#WTCMD1
SeminarsTopics.com
CALL OUTS
;SEND IT
MOV A,#20H
CALL OUT
BXDLP:
;SEND IT
MOV A,#RDCMD1
CALL OUTS
;SEND IT
CALL IN
;READ DATA
MOV @R1,a
;STORE DATA
INC R1
DJNZ R6,AXLP
CALL STOP
RET
AXLP: CLR SDA1
SETB SCL1
NOP
;NOTE 1
NOP
NOP
NOP ;NOTE 2
NOP
CLR SCL1
JMP BXDLP
CALL OUTS
;SEND IT
MOV A,R4
CALL OUT
;SEND IT
MOV A,#RDCMD
SeminarsTopics.com
CALL OUTS
BRDLP:CALL IN
AKLP:
;SEND IT
;READ DATA
MOV @R1,a
;STORE DATA
INC R1
DJNZ R6,AKLP
CALL STOP
RET
CLR SDA1
SETB SCL1
NOP
;NOTE 1
NOP
NOP
NOP
;NOTE 2
NOP
CLR SCL1
JMP BRDLP
BTLP:
MOV A,#WTCMD
CALL OUTS
;SEND IT
MOV A,R4
CALL OUT
;SEND IT
MOV A,@R1
;GET DATA
CALL OUT
;SEND IT
INC R1
DJNZ R6,BTLP
CALL STOP
SeminarsTopics.com
RET
;DISPLAY ROUTINES
TITLE1:
MOV DPTR,#MSAG1
CALL LCD_MSG
RET
MSAG1:
DB 1H,84H,'PREPAID',0C2H,'ENERGY METER',00H
DISP_READING:
MOV DPTR,#MSAG2
CALL LCD_MSG
RET
MSAG2:
DB 1H,82H,'METER READING',0C6H,00H
AMT_READING:
MOV DPTR,#MSAG3
CALL LCD_MSG
RET
MSAG3:
DB 1H,81H,'BALANCE AMOUNT',0C3H,'Rs.',00H
COUNT_READING:
MOV DPTR,#MSAG4
CALL LCD_MSG
RET
MSAG4:
DB 1H,82H,'PULSE COUNT',0C6H,00H
UNIT_PRICE:
MOV DPTR,#MSAG14
SeminarsTopics.com
CALL LCD_MSG
RET
MSAG14:
DB 1H,83H,'UNIT PRICE',0C4H,'Rs ',00H
RECHAGRE:
MOV DPTR,#MSAG5
CALL LCD_MSG
RET
MSAG5:
DB 1H,80H,'Please Recharge',0C2H,'your Account',00H
TITLE3:
MOV DPTR,#MSAG6
CALL LCD_MSG
RET
MSAG6:
DB 1H,84H,'New Card',0C1H,'** DETECTED **',00H
TITLE4:
MOV DPTR,#MSAG7
CALL LCD_MSG
RET
MSAG7:
DB 1H,81H,'NEW UNIT PRICE',0C1H,'** STORED **',00H
TITLE5:
MOV DPTR,#MSAG8
CALL LCD_MSG
RET
MSAG8:
DB 1H,83H,'NEW AMOUNT',0C1H,'** RECHARGED **',00H
SeminarsTopics.com
TITLE6:
MOV DPTR,#MSAG9
CALL LCD_MSG
RET
MSAG9:
DB 1H,82H,'INVALID CARD',0C0H,'****************',00H
SYSTEM_RESET:
MOV DPTR,#MSAG91
CALL LCD_MSG
RET
MSAG91:
DB 1H,80H,'System Restored',0C0H,'****************',00H
; INITIALIZE THE LCD 4-BIT MODE
INITLCD4:
CLR
LCD_RS
CLR
LCD_E
; ENABLE LINE
MOV
R4, #CONFIG
CALL
WRLCDCOM4
MOV
CALL
WRLCDCOM4
MOV
CALL
WRLCDCOM4
MOV
R4, #CLRDSP
CALL
WRLCDCOM4
RET
; SOFTWARE VERSION OF THE POWER ON RESET
RESETLCD4:
SeminarsTopics.com
CLR
LCD_RS
CLR
LCD_E
; ENABLE LINE
CLR
LCD_DB7
CLR
LCD_DB6
; ... POWER-ON-RESET
SETB
LCD_DB5
SETB
LCD_DB4
SETB
LCD_E
CLR
LCD_E
MOV
A, #4
CALL
MDELAY
SETB
LCD_E
CLR
LCD_E
MOV
A, #1
CALL
MDELAY
SETB
LCD_E
CLR
LCD_E
MOV
A, #1
CALL
MDELAY
CLR
LCD_DB4
SETB
LCD_E
CLR
LCD_E
MOV
A, #1
CALL
MDELAY
MOV
R4, #CONFIG
CALL
WRLCDCOM4
MOV
R4, #08H
CALL
WRLCDCOM4
MOV
R4, #1
SeminarsTopics.com
; DELAY 4 MILLISECONDS
; DELAY 1 MILLISECOND
; DELAY 1 MILLISECOND
; DELAY 1 MILLISECOND
; FUNCTION SET
; DISPLAY OFF
CALL
WRLCDCOM4
MOV
ACALL
WRLCDCOM4
JMP INITLCD4
; SUB RECEIVES A COMMAND WORD TO THE LCD
; COMMAND MUST BE PLACED IN R4 BY CALLING PROGRAM
WRLCDCOM4:
CLR
LCD_E
CLR
LCD_RS
PUSH
ACC
; SAVE ACCUMULATOR
MOV
A, R4
MOV
C, ACC.4
MOV
LCD_DB4, C
MOV
C, ACC.5
MOV
LCD_DB5, C
MOV
C, ACC.6
MOV
LCD_DB6, C
MOV
C, ACC.7
MOV
LCD_DB7, C
SETB
LCD_E
CLR
LCD_E
MOV
C, ACC.0
MOV
LCD_DB4, C
MOV
C, ACC.1
MOV
LCD_DB5, C
MOV
C, ACC.2
MOV
LCD_DB6, C
MOV
C, ACC.3
SeminarsTopics.com
MOV
LCD_DB7, C
CLR
LCD_E
SETB
LCD_E
CLR
LCD_E
CALL MADELAY
POP
ACC
RET
; SUB TO RECEIVE A DATA WORD TO THE LCD
; DATA MUST BE PLACED IN R4 BY CALLING PROGRAM
WRLCDDATA:
CLR
LCD_E
SETB
LCD_RS
PUSH
ACC
; SAVE ACCUMULATOR
MOV
A, R4
MOV
C, ACC.4
MOV
LCD_DB4, C
MOV
C, ACC.5
MOV
LCD_DB5, C
MOV
C, ACC.6
MOV
LCD_DB6, C
MOV
C, ACC.7
MOV
LCD_DB7, C
SETB
LCD_E
CLR
LCD_E
MOV
C, ACC.0
MOV
LCD_DB4, C
MOV
C, ACC.1
MOV
LCD_DB5, C
SeminarsTopics.com
MOV
C, ACC.2
MOV
LCD_DB6, C
MOV
C, ACC.3
MOV
LCD_DB7, C
CLR
LCD_E
SETB
LCD_E
CLR
LCD_E
NOP
NOP
POP
ACC
RET
;SUB TAKES THE STRING IMMEDIATELY FOLLOWING THE CALL ;AND
; DISPLAYS ON THE LCD. STRING MUST BE TERMINATED WITH A
; NULL (0).
LCD_MSG:
CLR A
; Clear Index
MOVC A,@A+DPTR
INC DPTR
JZ LCD_Msg9
CJNE A,#01H,Lcd_Msg1
MOV R4,A
CALL WRLCDCOM4
JMP LCD_MSG
MOV R4,A
CALL WRLCDDATA
JMP LCD_MSG
FLL: CJNE A,#080h,$+3
SeminarsTopics.com
JC
Lcd_Msg_Data
MOV R4,A
CALL WRLCDCOM4
JMP Lcd_Msg
Lcd_Msg_Data:
MOV R4,A
CALL WRLCDDATA
JMP Lcd_Msg
Lcd_Msg9:
RET
; Return to Caller
ACC
MOV
A,#0A6H
MD_OLP:
INC
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNZ
MD_OLP
NOP
POP
ACC
SeminarsTopics.com
RET
MADELAY:
PUSH
ACC
MOV
A,#036H
MAD_OLP:
INC
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNZ
MAD_OLP
NOP
POP
ACC
RET
DELAYS:
LOOPB:
INC R6
ACALL DELAYMS
MOV A, R6
;move value in R6 to A
JNZ LOOPB
DEC R5
SeminarsTopics.com
MOV A, R5
;move value in R5 to A
JNZ LOOPB
RET
DELAYMS:
MOV R7,#00H
LOOPA:
INC R7
MOV A,R7
CJNE A,#0FFH,LOOPA
RET
R2,#8
SETB SDA1
;INSURE DATA IS HI
SETB
;INSURE CLOCK IS HI
SCL1
NOP
;NOTE 1
NOP
NOP
CLR
SDA1
NOP
NOP
NOP
CLR
OTSLP: RLC
JNC
SCL1
;CLOCK = 0
;SHIFT BIT
BITLS
SeminarsTopics.com
SETB
JMP
SDA1
OTSL1
;DATA = 1
;CONTINUE
BITLS: CLR
SDA1
;DATA = 0
OTSL1: SETB
SCL1
;CLOCK HI
NOP
;NOTE 1
NOP
NOP
CLR
SCL1
DJNZ
SETB
SDA1
NOP
SETB
;CLOCK LOW
SCL1
NOP
;CLOCK ACK
;NOTE 1
NOP
NOP
CLR
SCL1
RET
;THIS ROUTINE SENDS OUT CONTENTS OF ACCUMLATOR TO EEPROM
; without sending a START condition.
OUT: MOV
R2,#8
OTLP: RLC
;SHIFT BIT
JNC
SETB
BITL:
BITL
SDA1
;DATA = 1
JMP
OTL1
;CONTINUE
CLR
SDA1
;DATA = 0
SCL1
;CLOCK HI
OTL1: SETB
NOP
NOP
SeminarsTopics.com
;NOTE 1
NOP
CLR
SCL1
;CLOCK LOW
DJNZ
R2,OTLP
;DECREMENT COUNTER
SETB
SDA1
NOP
SETB
SCL1
NOP
;CLOCK ACK
;NOTE 1
NOP
NOP
CLR
SCL1
RET
STOP: CLR
SDA1
NOP
NOP
NOP
SETB
SCL1
NOP
;SET CLOCK HI
;NOTE 1
NOP
NOP
SETB
SDA1
RET
;THIS ROUTINE READS A BYTE OF DATA FROM EEPROM
; From EEPROM current address pointer.
; Returns the data byte in R1
CREAD: MOV
A,#RDCMD
CALL OUTS
;SEND IT
CALL IN
;READ DATA
MOV
;STORE DATA
R1,A
SeminarsTopics.com
CALL STOP
RET
; THIS ROUTINE READS IN A BYTE FROM THE EEPROM
; and stores it in the accumulator
IN:
MOV
R2,#8
;LOOP COUNT
SETB
SDA1
INLP: CLR
SCL1
NOP
;CLOCK LOW
;NOTE 1
NOP
NOP
NOP
SETB
SCL1
;CLOCK HIGH
CLR
;CLEAR CARRY
JNB
SDA1,INL1
;JUMP IF DATA = 0
CPL
INL1: RLC
DJNZ
R2,INLP
;DECREMENT COUNTER
CLR
SCL1
;CLOCK LOW
RET
; This routine test for WRITE DONE condition
; by testing for an ACK.
; This routine can be run as soon as a STOP condition
; has been generated after the last data byte has been sent
; to the EEPROM. The routine loops until an ACK is received from
; the EEPROM. No ACK will be received until the EEPROM is done with
; the write operation.
ACKTST: MOV A,#WTCMD
SeminarsTopics.com
MOV
CLR
R2,#8
SDA1
NOP
NOP
NOP
CLR
AKTLP: RLC
SCL1
;CLOCK = 0
;SHIFT BIT
JNC
AKTLS
SETB
SDA1
JMP
;DATA = 1
AKTL1
;CONTINUE
AKTLS: CLR
SDA1
;DATA = 0
AKTL1: SETB
SCL1
;CLOCK HI
NOP
;NOTE 1
NOP
NOP
CLR
SCL1
;CLOCK LOW
DJNZ
R2,AKTLP
;DECREMENT COUNTER
SETB
SDA1
NOP
SETB
;NOTE 1
SCL1
NOP
;CLOCK ACK
;NOTE 1
NOP
NOP
EXIT:
JNB
SDA1,EXIT
JMP
ACKTST
;START OVER
CLR
SCL1
;CLOCK LOW
CLR
SDA1
;DATA LOW
NOP
SeminarsTopics.com
;NOTE 1
NOP
NOP
SETB
SCL1
;CLOCK HIGH
SDA1
;STOP CONDITION
NOP
NOP
SETB
RET
END
SeminarsTopics.com
CHAPTER-6
ADVANTAGES & DISADVANTAGES
6.1 ADVANTAGES:
The Prepaid Energy Meter for India. described in this Project has many
advantages.
Reduced Chance of Meter Tampering: The project uses electronic
energy meters with built in tamper detection facility which eliminates
any chance of mechanical tampering
Reduced Meter Reading Costs: Since the burden of traveling to read and
recharge the energy meters is eliminated by using wireless media, the
costs are significantly reduced.
Better Energy Usage: Since the energy billing is pre paid, the consumers
will now use electricity in a better planned manner thereby reducing
wastage.
Fast Resolution of Account Queries: As there can be no meter reading
transcription errors, customer complaints will be lower.
Improved Customer Care Facilities: The customer can get full details of
his energy consumption as a database for every customer is being
maintained.
Adaptable to Change in Power Tariff: The energy meter will be
processes only units and not rupees (money). Thus when there is a
SeminarsTopics.com
change in power tariff there is no need to chang the meter code. The
operator at the substation will calculate the number of units based on the
existing tariff and recharge the meters in terms of KWh.
Better Energy Management: Since the load pattern of a particular area
and customers is available through the database, it facilitates load
shedding in case of energy shortfall. The system will enable easy energy
audits.
Reduction in Power Theft: Because of the real time theft detection
system power thefts can be drastically reduced or removed.
6.2 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 consumes less power.
Since it is a prototype module, because of huge hardware the system
occupies more space.
The consumer or the electrical department has to spend more amounts
for installing this kind of smart energy meters. Economically it is not
advised.]
SeminarsTopics.com
The present energy billing system provides employment for nearly 8-10
people in every distribution station for jobs like billing, processing etc.
The presently installed energy meters should be either modified or
replaced with the new meter, which consumes time, labor and money.
The prepaid system will leave the customer without power, if he could
not recharge his meter in time due to some unavoidable reason.
The prepaid system will provide power only to those who can afford to
prepay.
Compared to the advantages, the above disadvantages are minimal in
their impact.
SeminarsTopics.com
CHAPTER-7
APPLICATION
The Prepaid Energy Meter designed in this paper could find application
in every state distribution company for energy billing apart from intelligent
load shedding and theft detection. It can also be extended for metering and
monitoring other utility commodities, such as Internet access, prepaid
drinking water, etc.
SeminarsTopics.com
CHAPTER-8
FUTURE SCOPE
The Prepaid Energy Meter for India, has the potential to change the future of
the energy billing system in India. It could help the energy distribution
companies reduce costs and increase profits, improve billing accuracy and
efficiency, and contribute to the energy sustainability
The recharge method used here can be replaced with the GSM Modems
and can be extended to make the energy billing system more wide
spread and make it one system for the entire state.
SeminarsTopics.com
CONCLUSION
Prepaid energy meter with tariff indicator is more reliable and user
friendly
SeminarsTopics.com
BIBLIOGRAPHY
Reference Books
APPENDIX
A1. Component Cost Details
SeminarsTopics.com
COMPONENTS
RANGE
PRIZE(Rs.)
Resister Box
All Types
30.00
16 *2 LCD Display
120.00
4 *4 Keypad
50.00
Crystal
12 MHz
15.00 * 3=45
IC AT89S52
25.00
IC AT24C02
15.00 * 3=45
IC AT89C2051
20.00
IC ULN2003
25.00
Capacitor
1F/16V
01.00
Capacitor
33pF
06.00
Energy Meter
500.00
LED (red)
03.00 *2 = 06.00
LED (green)
03.00 *2 = 06.00
10 K Register Network
10.00
Buzzer
30.00
Total Cost
915.00
A2.2 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
SeminarsTopics.com
is compatible with the industry- standard 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 six-vector two-level interrupt architecture, a full duplex serial
port, on-chip 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 contents but
freezes the oscillator, disabling all other chip functions until the next interrupt
or hardware reset.
SeminarsTopics.com
SeminarsTopics.com
RST: Reset input. A high on this pin for two machine cycles while the
oscillator is running resets the device. This pin drives High for 96
oscillator periods after the Watchdog times out. The DISRTO bit in SFR
AUXR (address 8EH) can be used to disable this feature. In the default
state of bit DISRTO, the RESET HIGH out feature is enabled.
SeminarsTopics.com
features. In that case, the reset or inactive values of the new bits will
always be 0.
Timer 2 Registers: Control and status bits are contained in registers
T2CON (shown in Table 2) and T2MOD (shown in Table 3) for Timer 2.
The register pair (RCAP2H, RCAP2L) are the Capture/Reload registers
for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.
Interrupt Registers:The individual interrupt enable bits are in the IE
register. Two priorities can be set for each of the six interrupt sources in
the IP register.
SeminarsTopics.com
SeminarsTopics.com
A3.2 Description:
The AT89C2051 is a low-voltage, high-performance CMOS 8-bit
microcomputer with 2K bytes of Flash programmable and erasable read-only
memory (PEROM). The device is manufactured using Atmels high-density
nonvolatile memory technology and is compatible with the industry-standard
MCS-51 instruction set. By combining a versatile 8-bit CPU with Flash on a
monolithic chip, the Atmel AT89C2051 is a power-ful microcomputer which
SeminarsTopics.com
SeminarsTopics.com
SeminarsTopics.com
RST: Reset input. All I/O pins are reset to 1s as soon as RST goes high.
Holding the RST pin high for two machine cycles while the oscillator is
SeminarsTopics.com
SeminarsTopics.com
SeminarsTopics.com
new features. In that case, the reset or inactive values of the new bits
will always be 0.
SeminarsTopics.com
A4.2 Description:
The AT24C01A/02/04/08A/16A provides 1024/2048/4096/8192/16384 bits of
serial electrically erasable and programmable read-only memory (EEPROM)
organized as 128/256/512/1024/2048 words of 8 bits each. The device is
optimized for use in many industrial and commercial applications where lowpower and low-voltage operation are essential. The
AT24C01A/02/04/08A/16A is available in space-saving 8-lead PDIP, 8-lead
JEDEC SOIC, 8-lead Ultra Thin Mini-MAP (MLP 2x3), 5-lead SOT23
(AT24C01A/AT24C02/AT24C04), 8-lead TSSOP, and 8-ball dBGA2 packages
and is accessed via a Two-wire serial interface. In addition, the entire family is
available in 2.7V (2.7V to 5.5V) and 1.8V (1.8V to 5.5V) versions.
SeminarsTopics.com
SeminarsTopics.com
Pin Description:
SERIAL CLOCK (SCL): The SCL input is used to positive edge clock
data into each EEPROM device and negative edge clock data out of
each device.
SeminarsTopics.com
SERIAL DATA (SDA): The SDA pin is bidirectional for serial data
transfer. This pin is open-drain driven and may be wire-ORed with any
number of other open-drain or opencollector devices.
Write Protect pin that provides hardware data protection. The Write
Protect pin allows normal Read/Write operations when connected to
ground (GND). When the Write Protect pin is connected to VCC, the
write protection feature is enabled and operates as shown in Table 2.
SeminarsTopics.com
A5.2 FEATURES:
500mA rated collector current(Single output)
High-voltage outputs: 50V
Inputs compatibale with various types of logic.
Relay driver application.
SeminarsTopics.com
SeminarsTopics.com
SeminarsTopics.com
A6.1 Features:
Interfaces with common logic families
Input-output coupling capacitance < 0.5 pF
Industry Standard Dual-in line 6-pin package
5300 VRMS isolation test voltage
A6.2 Description:
Standard Single Channel Phototransistor Couplers. The MCT2/ MCTE family
is an Industry Standard Single Channel Phototransistor.Each optocoupler
consists of gallium arsenide infrared LED and a silicon NPN phototransistor.
SeminarsTopics.com
SeminarsTopics.com
SeminarsTopics.com