You are on page 1of 81

CHAPTER 1

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

The scope of the project work is to introduce advanced technology in


converting dc voltage in to ac voltage and introducing prepaid energy metering
concept.
The energy meter used in this project work produces pulses according to the
load and this meter is converted as prepaid energy meter using smart card,
hence this meter can be called smart energy meter.
This kind of smart energy meters also can be installed at each and every house,
where the state electricity department going to supply the conventional energy.
Now a days energy Measurement and electric energy pilferage detection has
become prime importance for the state electricity department.
With the help of this project work lot of Manpower can be reduced and power
pilferage can be controlled. The overall system can be called as AMR
(Automatic Meter reading) system, the main advantage of AMR system is that
the consumed energy price can be calculated and at the same time price
(amount in rupees) can be displayed automatically.
Finally the simplest form of smart metering is a display meter, which allows
consumers to monitor consumption in money terms rather than kWh.

SeminarsTopics.com

1.2 Why Prepayment Energy Supplier?


Pay before use
Keep customers on supply
Recover money owed (debt)
Lower Overheads
No bill production
No bill distribution
No need to chase payments
No further actions such as disconnections

1.3 Why Prepayment The Customer?


No Bills
No hidden surprises
No having to find the money
No billing errors
No socially unacceptable
Disconnections

SeminarsTopics.com

CHAPTER-2
BLOCK DIAGRAM & ITS DESCRIPTION

2.1 BLOCK DIAGRAM: Card programmer

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

2.2 BLOCK DIAGRAM: Prepaid Energy Meter

When we enter a charged card in to a card reader of our main circuit,


micro controller will take data and store it inside a memory of
microcontroller
Micro controller also takes the pulses from the energymeter via
optocoupler IC MCT2E and counts the pulses upto 3200 because of the
meter specifications are 3200 pulses/KWh

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

3.1 Circuit Description


There are mainly two types of circuits:
3.1.1 Card programmer:
Card programmer is based on AT 89c2051 controller. it recharges the
card to Rs.50,100,150,200,250 etcby using the 4*3 matrix keypad we
can get the card programmed
Card is simply an AT24C02 EEPROM chip. it is a 2-wire Serial
Interface chip.

1.

How to program a new card?


For making a unit price card for Rs 2.50

1.Insert the card into the Programmer


Dial 1*0250#
The format is
1 for unit price
*for start process
0 Higher digit of the unit price
2 lower digot of the unit price
5 Higher digit of the unit paise
0 lower digot of the unit paise
The red led will blink for every key press
If the programming done sucessfully then the Green led will long Blink
finally.
If it fails then the RED led will give a long blink
2. For making a Recharge card for Rs 400
SeminarsTopics.com

Insert the card into the Programmer


Dial 2*0400#
The red led will blink for every key press
If the programming done sucessfully then the Green led will long Blink

finally.
If it fails then the RED led will give a long blink.

3.1.2 Main circuit:


Here in this circuit we have used 89s52 micro controller. This circuit takes data
from the card reader whenever we enter a card in to it and view the status of
the card on the lcd display.
Lcd display shows us the status of the card and what amount left on the card
and if the card is with the totally empty amount then it will shows Please
Recharge The Card
& if the card has sufficient amount then it microcontroller gives the control to
the meter & connect the whole path of the ckt & the current gets started
flowing & we have used bulb as a load it will blow.

3.2 LIST OF COMPONENTS

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

3.2. CIRCUIT DIAGRAM


3.2.1. CARD PROGRAMMER CIRCUIT

SeminarsTopics.com

3.2.2. MAIN CIRCUIT DIAGRAM

SeminarsTopics.com

SeminarsTopics.com

CHAPTER-5
PROGRAMMING IN ASSEMBLY LANGUAGE

PROGARMING: PREPAID ENERGY METER


RB0

EQU

000H

; Select Register Bank 0

RB1

EQU

008H

; Select Register Bank 1 ...poke to PSW to use

;PORT DECLERATION
SDA1 EQU P2.1

;SDA=PIN5

SCL1 EQU P2.0

;SCL=PIN6

WTCMD EQU 10100110B

;WRITE DATA COMMAND Note 3

RDCMD EQU 10100111B

;READ DATA COMMAND Note 3

WTCMD1 EQU 10100000B

;WRITE DATA COMMAND Note 3

RDCMD1 EQU 10100001B

;READ DATA COMMAND Note 3

RELAY

EQU P2.7

BUZZER

EQU P2.4

; ***LCD CONTROL***
LCD_RS
LCD_E

EQU
EQU

P0.0
P0.1

;LCD REGISTER SELECT LINE


;LCD ENABLE LINE

LCD_DB4 EQU

P0.2

;PORT 1 IS USED FOR DATA

LCD_DB5 EQU

P0.3

;USED FOR DATA

LCD_DB6 EQU

P0.4

;FOR DATA

LCD_DB7 EQU

P0.5

; FOR DATA

; ***CURSOR CONTROL INSTRUCTIONS***


OFFCUR

EQU

0CH

BLINKCUR EQU

SeminarsTopics.com

0DH ;

***DISPLAY CONTROL INSTRUCTIONS***


CLRDSP EQU

01H

ONDSP

0CH

EQU

; ***SYSTEM INSTRUCTIONS***
CONFIG

EQU

28H

ENTRYMODE EQU
DSEG
ORG

; 4-BIT DATA,2 LINES,5X7 MATRIX LCD


6

; INCREMENT CURSOR DON'T SHIFT DISPLAY

; This is internal data memory


20H

; Bit adressable memory

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

; Code begins here

; Main routine. Program execution starts here.


ORG 00H

SeminarsTopics.com

; Reset

AJMP MAIN
ORG 0003H
PUSH PSW
PUSH ACC
MOV PSW,#RB1

; Select register bank 0

CALL INC_COUNTER
POP ACC
POP PSW
RETI
MAIN: MOV SP,#50H
MOV PSW,#RB0

; Select register bank 0

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

;RELAY ON/OFF BYTE

CALL AMT_RECHARGE
CALL SYSTEM_RESET
CALL DELAYYS

BYPASS: CALL READ_COUNTER


CALL READ_PRICE
CALL READ_BALANCE
MAINS: CALL TITLE1
CALL DELAYY
MOV A,BALANCE
CJNE A,#00H,FG1
CLR RELAY
CALL RECHAGRE
CALL DELAYY
SETB BUZZER
AJMP MAINS
FG1: SETB RELAY
MOV A,BUZZ_COUNT

;CHK TO SWITCH OFF THE BUZZER

CJNE A,#00H,AZX1
CLR BUZZER
AJMP AZX2
AZX1: DEC BUZZ_COUNT
AZX2: MOV R1,#READING

;GET DATA IN BYTES(RAM)

MOV R4,#05H

;DATA ADDRESS IN EEPROM

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

;GET DATA IN BYTES(RAM)

MOV R4,#0AH

;DATA ADDRESS IN EEPROM

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

;GET DATA IN BYTES(RAM)

MOV R4,#0EH

;DATA ADDRESS IN EEPROM

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

;GET DATA IN BYTES(RAM)

MOV R4,#10H

;DATA ADDRESS IN EEPROM

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

;Starting Address IN EEPROM

MOV R6,#2

;STORE 2 BYTES

CALL STORE_EEPROM
CALL DELAY
AJMP DVB1
DCV2:

MOV R1,#COUNTER

;store COUNT

MOV R4,#0EH

;Starting Address IN EEPROM

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

; SUBTRACT AMT0 FROM TOTAL0

CLR C
SUBB A,PRICE+1
CALL BCD_CONV
MOV AMOUNT+2,A
MOV A,AMOUNT+1

; SUBTRACT AMT1 FROM TOTAL1

SUBB A,PRICE
CALL BCD_CONV
MOV AMOUNT+1,A
MOV A,AMOUNT
SUBB A,#00h

; SUBTRACT AMT2 FROM TOTAL2

CALL BCD_CONV
MOV AMOUNT,A
MOV R1,#AMOUNT

; store AMOUNT

MOV R4,#0AH

; Starting Address IN EEPROM

MOV R6,#3; STORE 2 BYTES


CALL STORE_EEPROM
CALL DELAY
MOV A,AMOUNT+1
CJNE A,#40H,FCX1
MOV BUZZ_COUNT,#02H
SETB BUZZER
FCX1:

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:

MOV A,AMOU NT+2

; SUBTRACT AMT0 FROM TOTAL0

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

;SUBTRACT AMT1 FROM TOTAL1

SETB TBIT
POP1:

CJNE A,#00H,BACK
JNB TBIT, BACK
MOV BALANCE,#00H
MOV R1,#BALANCE

; store COUNT

MOV R4,#15H

; Starting Address IN EEPROM

MOV R6,#1
CALL STORE_EEPROM
CALL DELAY
CLR RELAY
SETB BUZZER
BACK:

RET

BCD_CONV: CLR BCDCARRY


CLR CARRY
JNC LOP2
SETB CARRY
LOP2:

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

;READ PULSE COUNTER FROM MEMORY

SeminarsTopics.com

; STORE 2 BYTES

READ_BALANCE: MOV R1,#BALANCE

; GET DATA IN BYTES(RAM)

MOV R4,#15H

;DATA ADDRESS IN EEPROM

MOV R6,#1

; NUMBER OF BYTES

CALL READ_EEPROM
RET
READ_COUNTER: MOV R1,#COUNTER

; GET DATA IN BYTES(RAM)

MOV R4,#0EH
MOV R6,#2

; DATA ADDRESS IN EEPROM


; NUMBER OF BYTES

CALL READ_EEPROM
RET
READ_PRICE:

MOV R1,#PRICE

; GET DATA IN BYTES(RAM)

MOV R4,#10H

; DATA ADDRESS IN EEPROM

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

;BOTH NOT EQUAL TO ZERO

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

;LOAD WRITE COMMAND

CALL OUTS

;SEND IT

MOV A,#20H

;GET LOW BYTE ADDRESS

CALL OUT

;SEND IT

BXLP: MOV A,@R1

;GET DATA

CALL OUT

;SEND IT

INC R1

;INCREMENT DATA POINTER

DJNZ R6,BXLP

;LOOP TILL DONE

CALL STOP

;SEND STOP CONDITION

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

; GET LOW BYTE ADDRESS

CALL OUT

;SEND IT

MOV A,@R1

SeminarsTopics.com

; LOAD WRITE COMMAND

;GET DATA

CALL OUT

;SEND IT

INC R1

;INCREMENT DATA POINTER

DJNZ R6,BALP

;LOOP TILL DONE

CALL STOP

;SEND STOP CONDITION

CALL DELAY
RET
RESET_BALANCE:
MOV BALANCE,#0FFH
MOV R1,#BALANCE

;store COUNT

MOV R4,#15H

;Starting Address IN EEPROM

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

;Starting Address IN EEPROM

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

;Starting Address IN EEPROM

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

;Starting Address IN EEPROM

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

;Starting Address IN EEPROM

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

S5P3: MOV F2,#0fFH


S5P2: MOV F3,#0FFH
S5P1: DJNZ F3,S5P1
DJNZ F2,S5P2
DJNZ F1,S5P3
RET

DSP1:JB TBIT1,DSP3A
CALL TITLE3
CALL DELAYS
CALL DELAYS
CALL CARD_READ
MOV A,READ_BYTE
CJNE A,#00H,DSP2
CALL TITLE4

;NEW UNIT PRICE

MOV PRICE,READ_BYTE+1
MOV PRICE+1,READ_BYTE+2
MOV R1,#PRICE

;store COUNT

MOV R4,#10H

;Starting Address IN EEPROM

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

;GET DATA IN BYTES(RAM)

MOV R4,#0AH

;DATA ADDRESS IN EEPROM

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

;Starting Address IN EEPROM

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

;LOAD WRITE COMMAND

CALL OUTS

;SEND IT

MOV A,#20H
CALL OUT
BBLP: MOV A,@R1

;GET LOW BYTE ADDRESS


;SEND IT
;GET DATA

CALL OUT

;SEND IT

INC R1

;INCREMENT DATA POINTER

DJNZ R6,BBLP

;LOOP TILL DONE

CALL STOP

;SEND STOP CONDITION

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

; GET DATA IN BYTES(RAM)

MOV R6,#3

;NUMBER OF BYTES

MOV A,#WTCMD1

SeminarsTopics.com

;LOAD WRITE COMMAND TO SEND

CALL OUTS

;SEND IT

MOV A,#20H

;GET LOW BYTE ADDRESS

CALL OUT

BXDLP:

;SEND IT

MOV A,#RDCMD1

;LOAD READ COMMAND

CALL OUTS

;SEND IT

CALL IN

;READ DATA

MOV @R1,a

;STORE DATA

INC R1

;INCREMENT DATA POINTER

DJNZ R6,AXLP

;DECREMENT LOOP COUNTER

CALL STOP
RET
AXLP: CLR SDA1

;IF DONE, ISSUE STOP CONDITION


;DONE, EXIT ROUTINE
;NOT DONE, ISSUE ACK

SETB SCL1
NOP

;NOTE 1

NOP
NOP
NOP ;NOTE 2
NOP
CLR SCL1
JMP BXDLP

;CONTINUE WITH READS

;READ DATA FROM EEPROM


READ_EEPROM:
MOV A,#WTCMD

; LOAD WRITE COMMAND TO SEND


;ADDRESS

CALL OUTS

;SEND IT

MOV A,R4

;GET LOW BYTE ADDRESS

CALL OUT

;SEND IT

MOV A,#RDCMD

;LOAD READ COMMAND

SeminarsTopics.com

CALL OUTS
BRDLP:CALL IN

AKLP:

;SEND IT
;READ DATA

MOV @R1,a

;STORE DATA

INC R1

;INCREMENT DATA POINTER

DJNZ R6,AKLP

;DECREMENT LOOP COUNTER

CALL STOP

;IF DONE, ISSUE STOP CONDITION

RET

;DONE, EXIT ROUTINE

CLR SDA1

;NOT DONE, ISSUE ACK

SETB SCL1
NOP

;NOTE 1

NOP
NOP
NOP

;NOTE 2

NOP
CLR SCL1
JMP BRDLP

;CONTINUE WITH READS

;STORE DATA IN EEPROM


STORE_EEPROM:

BTLP:

MOV A,#WTCMD

;LOAD WRITE COMMAND

CALL OUTS

;SEND IT

MOV A,R4

;GET LOW BYTE ADDRESS

CALL OUT

;SEND IT

MOV A,@R1

;GET DATA

CALL OUT

;SEND IT

INC R1

;INCREMENT DATA POINTER

DJNZ R6,BTLP

;LOOP TILL DONE

CALL STOP

;SEND STOP CONDITION

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

; LCD REGISTER SELECT LINE

CLR

LCD_E

; ENABLE LINE

MOV

R4, #CONFIG

; FUNCTION SET - DATA BITS,


; LINES, FONTS

CALL

WRLCDCOM4

MOV

R4, #ONDSP ; DISPLAY ON

CALL

WRLCDCOM4

MOV

R4, #ENTRYMODE ; SET ENTRY MODE

CALL

WRLCDCOM4

MOV

R4, #CLRDSP

CALL

WRLCDCOM4

; INCREMENT CURSOR RIGHT, NO SHIFT


; CLEAR DISPLAY, HOME CURSOR

RET
; SOFTWARE VERSION OF THE POWER ON RESET
RESETLCD4:

SeminarsTopics.com

CLR

LCD_RS

; LCD REGISTER SELECT LINE

CLR

LCD_E

; ENABLE LINE

CLR

LCD_DB7

; SET BIT PATTERN FOR...

CLR

LCD_DB6

; ... POWER-ON-RESET

SETB

LCD_DB5

SETB

LCD_DB4

SETB

LCD_E

; START ENABLE PULSE

CLR

LCD_E

; END ENABLE PULSE

MOV

A, #4

CALL

MDELAY

SETB

LCD_E

; START ENABLE PULSE

CLR

LCD_E

; END ENABLE PULSE

MOV

A, #1

CALL

MDELAY

SETB

LCD_E

; START ENABLE PULSE

CLR

LCD_E

; END ENABLE PULSE

MOV

A, #1

CALL

MDELAY

CLR

LCD_DB4

; SPECIFY 4-BIT OPERATION

SETB

LCD_E

; START ENABLE PULSE

CLR

LCD_E

; END ENABLE PULSE

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

; CLEAR DISPLAY, HOME CURSOR

CALL

WRLCDCOM4

MOV

R4,#ENTRYMODE ; SET ENTRY MODE

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

; SELECT READ COMMAND

PUSH

ACC

; SAVE ACCUMULATOR

MOV

A, R4

; PUT DATA BYTE IN ACC

MOV

C, ACC.4

; LOAD HIGH NIBBLE ON DATA BUS

MOV

LCD_DB4, C

; ONE BIT AT A TIME USING...

MOV

C, ACC.5

; BIT MOVE OPERATOINS

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

; PULSE THE ENABLE LINE

; SIMILARLY, LOAD LOW NIBBLE

MOV

LCD_DB7, C

CLR

LCD_E

SETB

LCD_E

CLR

LCD_E

; PULSE THE ENABLE LINE

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

; SELECT READ DATA

PUSH

ACC

; SAVE ACCUMULATOR

MOV

A, R4

; PUT DATA BYTE IN ACC

MOV

C, ACC.4

; LOAD HIGH NIBBLE ON DATA BUS

MOV

LCD_DB4, C

; ONE BIT AT A TIME USING...

MOV

C, ACC.5

; BIT MOVE OPERATOINS

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

; PULSE THE ENABLE LINE

; SIMILARLY, LOAD LOW NIBBLE

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

; PULSE THE ENABLE LINE

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

; Get byte pointed by Dptr

INC DPTR

; Point to the next byte

JZ LCD_Msg9

; Return if found the zero (end of stringz)

CJNE A,#01H,Lcd_Msg1

; Check if is a Clear Command

MOV R4,A
CALL WRLCDCOM4

;If yes, RECEIVE it as command to LCD

JMP LCD_MSG

;Go get next byte from stringz

Lcd_Msg1: CJNE A,#0FFH,FLL

;Check for displaying full character

MOV R4,A
CALL WRLCDDATA
JMP LCD_MSG
FLL: CJNE A,#080h,$+3

SeminarsTopics.com

; Data or Address? If => 80h then is address.

JC

Lcd_Msg_Data

; Carry will be set if A < 80h (Data)

MOV R4,A
CALL WRLCDCOM4
JMP Lcd_Msg

; Carry not set if A=>80, it is address


; Go get next byte from stringz

Lcd_Msg_Data:
MOV R4,A
CALL WRLCDDATA

; It was data, RECEIVE it to Lcd

JMP Lcd_Msg

; Go get next byte from stringz

Lcd_Msg9:
RET

; Return to Caller

; 1 MILLISECOND DELAY ROUTINE


MDELAY:
PUSH

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:

;One second delay routine

MOV R6, #00H

;put 0 in register R6 (R6 = 0)

MOV R5, #04H

;put 5 in register R5 (R5 = 4)

LOOPB:
INC R6

;increase R6 by one (R6 = R6 +1)

ACALL DELAYMS

; call the routine above. It will run and return to here.

MOV A, R6

;move value in R6 to A

JNZ LOOPB

;if A is not 0, go to LOOPB

DEC R5

;decrease R5 by one. (R5 = R5 -1)

SeminarsTopics.com

MOV A, R5

;move value in R5 to A

JNZ LOOPB

;if A is not 0 then go to LOOPB.

RET

DELAYMS:

;millisecond delay routine

MOV R7,#00H

;put value of 0 in register R7

LOOPA:
INC R7

;increase R7 by one (R7 = R7 +1)

MOV A,R7

;move value in R7 to Accumlator (also known as A)

CJNE A,#0FFH,LOOPA

;compare A to FF hex (256). If not equal go to


; LOOPA

RET

;return to the point that this routine was called from

;THIS ROUTINE SENDS OUT CONTENTS OF THE ACCUMULATOR


; to the EEPROM and includes START condition. Refer to the data sheets
; for discussion of START and STOP conditions.
OUTS: MOV

R2,#8

;LOOP COUNT -- EQUAL TO BIT COUNT

SETB SDA1

;INSURE DATA IS HI

SETB

;INSURE CLOCK IS HI

SCL1

NOP

;NOTE 1

NOP
NOP
CLR

SDA1

NOP

;START CONDITION -- DATA = 0


;NOTE 1

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

R2,OTSLP ;DECREMENT COUNTER

SETB

SDA1

NOP
SETB

;CLOCK LOW

;TURN PIN INTO INPUT


;NOTE 1

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

;LOOP COUNT -- EQUAL TO BIT COUNT

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

;TURN PIN INTO INPUT


;NOTE 1

SCL1

NOP

;CLOCK ACK
;NOTE 1

NOP
NOP
CLR

SCL1

RET
STOP: CLR

SDA1

NOP

;STOP CONDITION SET DATA LOW


;NOTE 1

NOP
NOP
SETB

SCL1

NOP

;SET CLOCK HI
;NOTE 1

NOP
NOP
SETB

SDA1

;SET DATA HIGH

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

;LOAD READ COMMAND

CALL OUTS

;SEND IT

CALL IN

;READ DATA

MOV

;STORE DATA

R1,A

SeminarsTopics.com

CALL STOP

;SEND STOP CONDITION

RET
; THIS ROUTINE READS IN A BYTE FROM THE EEPROM
; and stores it in the accumulator
IN:

MOV

R2,#8

;LOOP COUNT

SETB

SDA1

;SET DATA BIT HIGH FOR INPUT

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

;SET CARRY IF DATA = 1

INL1: RLC

;ROTATE DATA INTO ACCUMULATOR

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

; LOAD WRITE COMMAND TO SEND


; ADDRESS

SeminarsTopics.com

MOV
CLR

R2,#8
SDA1

NOP

;LOOP COUNT -- EQUAL TO BIT COUNT


;START CONDITION -- DATA = 0
;NOTE 1

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

;TURN PIN INTO INPUT

NOP
SETB

;NOTE 1
SCL1

NOP

;CLOCK ACK
;NOTE 1

NOP
NOP

EXIT:

JNB

SDA1,EXIT

;EXIT IF ACK (WRITE DONE)

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.

The mode of payment by the consumers can be extended to credit cards,


internet based payments, ATM Centers etc. This makes the recharging
system simpler and eliminating the need for customers to go to the
recharge centers allowing the user any time recharge.

Instead of recharging the chip, the readily available recharge cards


(smart cards) used in cell phones can be introduced which will enable
easier recharging of meters. These cards can be made available at all
super markets, grocery shops etc.
With these extensions customers can be relieved of the burden of
recharging the meter only at the recharging centres. Using these other

SeminarsTopics.com

mechanisms, they can recharge their meters at their convenience and


making the system much more user friendly.

CONCLUSION

Prepaid energy meter with tariff indicator is a concept to minimize the


Electricity theft with a cost efficient manner.
The users are not bound to pay excesses amount of money, users have to
pay according to their requirement.
It can reduce problem associated with billing consumer living in isolated
area and reduces deployment of manpower for taking meter
readings.

Prepaid energy meter with tariff indicator is more reliable and user
friendly

SeminarsTopics.com

BIBLIOGRAPHY
Reference Books

o The 8051microcontroller and embedded systems:


MUHAMMAD ALI MAZIDI
JANICE GILLISPIE MAZIDI
o The 8051 microcontroller: KENNETH J. AYALA
Website
o www.datasheets4u.com
o www.8051.com
o www.google.com
o www.primegroupindia.com
o www.indianengineer.wordpress.com
o www.wikipedia.org

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. Data Sheet of AT89S52:A2.1 Features:


Compatible with MCS-51 Products
8K Bytes of In-System Programmable (ISP) Flash Memory
Endurance: 1000 Write/Erase Cycles
SeminarsTopics.com

4.0V to 5.5V Operating Range


Fully Static Operation: 0 Hz to 33 MHz
Three-level Program Memory Lock
8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Full Duplex UART Serial Channel
Low-power Idle and Power-down Modes
Interrupt Recovery from Power-down Mode
Watchdog Timer
Dual Data Pointer
Power-off Flag

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.

A2.3 Block Diagram:

SeminarsTopics.com

A2.4 Pin Discription:SeminarsTopics.com

VCC: Supply voltage.


GND: Ground.
Port 0: Port 0 is an 8-bit open drain bidirectional I/O port. As an output
port, each pin can sink eight TTL inputs. When 1s are written to port 0
pins, the pins can be used as highimpedance inputs. Port 0 can also be
configured to be the multiplexed loworder address/data bus during
accesses to external program and data memory. In this mode, P0 has
internal pullups. Port 0 also receives the code bytes during Flash
programming and outputs the code bytes during program verification.
External pullups are required during program verification.
Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pullups.
The Port 1 output buffers can sink/source four TTL inputs. When 1s are
written to Port 1 pins, they are pulled high by the internal pullups and
can be used as inputs. As inputs, Port 1 pins that are externally being
pulled low will source current (IIL) because of the internal pullups. In
SeminarsTopics.com

addition, P1.0 and P1.1 can be configured to be the timer/counter 2


external count input (P1.0/T2) and the timer/counter 2 trigger input
(P1.1/T2EX), respectively, as shown in the following table. Port 1 also
receives the low-order address bytes during Flash programming and
verification.

Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pullups.


The Port 2 output buffers can sink/source four TTL inputs. When 1s are
written to Port 2 pins, they are pulled high by the internal pullups and
can be used as inputs. As inputs, Port 2 pins that are externally being
pulled low will source current (IIL) because of the internal pullups. Port
2 emits the high-order address byte during fetches from external
program memory and during accesses to external data memory that use
16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses
strong internal pull-ups when emitting 1s. During accesses to external
data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the
contents of the P2 Special Function Register. Port 2 also receives the
high-order address bits and some control signals during Flash
programming and verification.

SeminarsTopics.com

Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pullups.


The Port 3 output buffers can sink/source four TTL inputs. When 1s are
written to Port 3 pins, they are pulled high by the internal pullups and
can be used as inputs. As inputs, Port 3 pins that are externally being
pulled low will source current (IIL) because of the pullups. Port 3 also
serves the functions of various special features of the AT89S52, as
shown in the following table. Port 3 also receives some control signals
for Flash programming and verification.

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.

ALE/PROG: Address Latch Enable (ALE) is an output pulse for


latching the low byte of the address during accesses to external memory.
This pin is also the program pulse input (PROG) during Flash
programming. In normal operation, ALE is emitted at a constant rate of
1/6 the oscillator frequency and may be used for external timing or
clocking purposes. Note, however, that one ALE pulse is skipped during

SeminarsTopics.com

each access to external data memory. If desired, ALE operation can be


disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is
active only during a MOVX or MOVC instruction. Otherwise, the pin
isweakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode.
PSEN:Program Store Enable (PSEN) is the read strobe to external
program memory. When the AT89S52 is executing code from external
program memory, PSEN is activated twice each machine cycle, except
that two PSEN activations are skipped during each access to external
data memory.
EA/VPP:External Access Enable. EA must be strapped to GND in order
to enable the device to fetch code from external program memory
locations starting at 0000H up to FFFFH. Note, however, that if lock bit
1 is programmed, EA will be internally latched on reset. EA should be
strapped to VCC for internal program executions. This pin also receives
the 12-volt programming enable voltage (VPP) during Flash
programming.
XTAL1:Input to the inverting oscillator amplifier and input to the
internal clock operating circuit.
XTAL2:Output from the inverting oscillator amplifier.
Special Function Registers: A map of the on-chip memory area called
the Special Function Register (SFR) space is shown in Table 1. Note
that not all of the addresses are occupied, and unoccupied addresses may
not be implemented on the chip. Read accesses to these addresses will in
general return random data, and write accesses will have an
indeterminate effect. User software should not write 1s to these unlisted
locations, since they may be used in future products to invoke new
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

Dual Data Pointer Registers: To facilitate accessing both internal and


external data memory, two banks of 16-bit Data Pointer Registers are
provided: DP0 at SFR address locations 82H-83H and DP1 at 84H-85H.
Bit DPS = 0 in SFR AUXR1 selects DP0 and DPS = 1 selects DP1. The
user should always initialize the DPS bit to the appropriate value before
accessing the respective Data Pointer Register.
Power Off Flag: The Power Off Flag (POF) is located at bit 4
(PCON.4) in the PCON SFR. POF is set to 1 during power up. It can
be set and rest under software control and is not affected by reset.

SeminarsTopics.com

A3. DATA SHEET OF AT89C2051:


A3.1 Features
Compatible with MCS-51Products
2K Bytes of Reprogrammable Flash Memory Endurance: 10,000
Write/Erase Cycles
2.7V to 6V Operating Range
Fully Static Operation: 0 Hz to 24 MHz
Two-level Program Memory Lock 128 x 8-bit Internal RAM
15 Programmable I/O Lines
Two 16-bit Timer/Counters
Six Interrupt Sources
Programmable Serial UART Channel
Direct LED Drive Outputs
On-chip Analog Comparator
Low-power Idle and Power-down Modes
Green (Pb/Halide-free) Packaging Option

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

provides a highly-flexible and cost-effective solution to many embedded


control applications. The AT89C2051 provides the following standard features:
2K bytes of Flash, 128 bytes of RAM, 15 I/O lines, two 16-bit timer/counters,
a five vector two-level interrupt architecture, a full duplex serial port, a
precision analog comparator, on-chip oscillator and clock circuitry. In addition,
the AT89C2051 is designed with static logic for opera-tion 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 hardware reset.
A3.3 Block Diagram:

SeminarsTopics.com

A3.4 Pin Description:

SeminarsTopics.com

VCC: Supply voltage.


GND: Ground.
Port 1: The Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2 to
P1.7 provide internal pull-ups. P1.0 and P1.1 require external pull-ups.
P1.0 and P1.1 also serve as the positive input (AIN0) and the negative
input (AIN1), respectively, of the on-chip precision analog comparator.
The Port 1 out-put buffers can sink 20 mA and can drive LED displays
directly. When 1s are written to Port 1 pins, they can be used as inputs.
When pins P1.2 to P1.7 are used as inputs and are externally pulled low,
they will source current (IIL) because of the internal pull-ups. Port 1
also receives code data during Flash programming and verification.
Port 3: Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/O pins
with internal pull-ups. P3.6 is hard-wired as an input to the output of the
on-chip comparator and is not accessible as a gen-eral-purpose I/O pin.
The Port 3 output buffers can sink 20 mA. When 1s are written to Port 3
pins they are pulled high by the internal pull-ups and can be used as
inputs. As inputs, Port 3 pins that are externally being pulled low will
source current (IIL) because of the pull-ups. Port 3 also serves the
functions of various special features of the AT89C2051 as listed below:

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

running resets the device. Each machine cycle takes 12 oscillator or


clock cycles.
XTAL1: Input to the inverting oscillator amplifier and input to the
internal clock operating circuit.
XTAL2: Output from the inverting oscillator amplifier.
Oscillator Characteristics: The XTAL1 and XTAL2 are the input and
output, respectively, of an inverting amplifier which can be configured
for use as an on-chip oscillator, as shown in Figure 5-1. Either a quartz
crystal or ceramic resonator may be used. To drive the device from an
external clock source, XTAL2 should be left unconnected while XTAL1
is driven as shown in Figure 5-2. There are no require-ments on the duty
cycle of the external clock signal, since the input to the internal clocking
circuitry is through a divide-by-two flip-flop, but minimum and
maximum voltage high and low time specifications must be observed.

SeminarsTopics.com

Special Function Registers: A map of the on-chip memory area called


the Special Function Register (SFR) space is shown in the table below.
Note that not all of the addresses are occupied, and unoccupied
addresses may not be implemented on the chip. Read accesses to these
addresses will in general return random data, and write accesses will
have an indeterminate effect. User software should not write 1s to these
unlisted locations, since they may be used in future products to invoke

SeminarsTopics.com

new features. In that case, the reset or inactive values of the new bits
will always be 0.

A4. DATA SHEET OF AT24C02/4:


A4.1 Features:
Low-voltage and Standard-voltage Operation
o 2.7(VCC = 2.7V to 5.5V)
o 1.8 (VCC = 1.8V to 5.5V)
Internally Organized 128 x 8 (1K), 256 x 8 (2K), 512 x 8 (4K),
1024 x 8 (8K) or 2048 x 8 (16K)
Schmitt Trigger, Filtered Inputs for Noise Suppression
Bidirectional Data Transfer Protocol
100 kHz (1.8V) and 400 kHz (2.7V, 5V) Compatibility
Write Protect Pin for Hardware Data Protection
8-byte Page (1K, 2K), 16-byte Page (4K, 8K, 16K) Write Modes ,Partial
Page Writes Allowed
Self-timed Write Cycle (5 ms max)
High-reliability
Endurance: 1 Million Write Cycles
Data Retention: 100 Years
Automotive Devices Available
8-lead JEDEC PDIP, 8-lead JEDEC SOIC, 8-lead Ultra Thin Mini-MAP
(MLP 2x3), 5-lead

SeminarsTopics.com

SOT23, 8-lead TSSOP and 8-ball dBGA2 Packages


Die Sales: Wafer Form, Waffle Pack and Bumped Wafers

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.

A4.3 Block Diagram:

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.

DEVICE/PAGE ADDRESSES (A2, A1, A0): The A2, A1 and A0 pins


are device address inputs that are hard wired for the AT24C01A and the
AT24C02. As many as eight 1K/2K devices may be addressed on a
single bus system (device addressing is discussed in detail under the
Device Addressing section). The AT24C04 uses the A2 and A1 inputs
for hard wire addressing and a total of four 4K devices may be
addressed on a single bus system. The A0 pin is a no connect and can be
connected to ground. The AT24C08A only uses the A2 input for
hardwire addressing and a total of two 8K devices may be addressed on
a single bus system. The A0 and A1 pins are no connects and can be
connected to ground. The AT24C16A does not use the device address
pins, which limits the number of devices on a single bus to one. The A0,
A1 and A2 pins are no connects and can be connected to ground.

WRITE PROTECT (WP):

The AT24C01A/02/04/08A/16A has a

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. DATA SHEET OF ULN2003:


HIGH VOLTAGE AND HIGH CURRENT DARLINGTON TRANSISTOR
ARRAY
A5.1 DESCRIPTION:
The ULN2003 is a monolithic high voltage and high current Darlington
transistor arrays. It consists of seven NPN darlington pairs that features highvoltage outputs with common-cathode clamp diode for switching inductive
loads. The collector-current rating of a single darlington pair is 500mA. The
darlington pairs may be parrlleled for higher current capability. Applications
include relay drivers,hammer drivers, lampdrivers,display drivers(LED gas
discharge),line drivers, and logic buffers.
The ULN2003 has a 2.7kW series base resistor for each darlington pair
for operation directly with TTL or 5V CMOS devices.

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. Data sheet of MCT2E (Optocoupler, Phototransistor Output,


With Base Connection)

Figure 2.2 IC MCT2E

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.

A6.3 Absolute Maximum Ratings:

SeminarsTopics.com

Tamp = 25 C, unless otherwise specifiedStresses in excess of the absolute


Maximum Ratings can cause permanent damage to the device. Functional
operation of the device is not implied at these or any other conditions in excess
of those given in the operational sections of this document. Exposure to
absolute Maximum Rating for extended periods of the time can adversely
affect reliability.

A6.4 Package Dimensions in Inches (mm)

SeminarsTopics.com

SeminarsTopics.com

You might also like