Date post: | 06-Apr-2018 |
Category: |
Documents |
Upload: | khelen-waikhom |
View: | 218 times |
Download: | 0 times |
of 74
8/3/2019 Automatic Power Saving Energy Meter
1/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
1. INTRODUCTION
The Automation of Public Service Sectors is the current trend, which
transforms the manpower oriented services to semi-automatic or full automatic
Sectors. As the country is opened to globalization, peoples income is rising. And the
Busy word is now become essential part of everybodys life. So, governments prefer
not only to give quality service but also the corrupt & error free services to its
citizens. As a result, this project proposed here is an advanced system, which sits in
consumers home and helps Electricity Boards or Electricity Corporations to handle
the Billing system smoothly. This project helps them to give quality service to its
customer without any kind of problems.
In Brief:
The present trend of tariff collection suffers from inefficient system of billing
and collection in the way of wasting of valuable man power. So our aim is to
overcome these problems with the introduction of MICRO-CONTROLLER
BASED POWER CARD- A NEW APPROACH TO TARIFF COLLECTION.
In this Power Card system the consumer purchases the pre-paid Power Card,
which is available in three designations viz., 100 units, 150 units, & 200 units, as per
his requirements. This MICRO-CONTROLLER BASED POWER CARD project is
fitted inside the consumers home, before the energy meter. When user inserts the
Power Card in his Power Card Systems Card Holder, the Card Detector takes care of
verifying the authenticity of the Power Card inserted. If it is found OK then his total
units consumed is started counting and accordingly his cards units are decremented.
At the same time his home gets power supply through Energy Meter. Simultaneously,
the Card Analyzer checks the designation of the Power Card inserted and makes the
corresponding output line high. When the total consumption reaches 80% of the
designated unit value, this project alerts consumer by beeping the buzzer. If consumer
notices it, he can buy another card of his requirement to avoid any future power-cut.
Else, after total power consumption reaches the Power Cards designation unit value
the system automatically disconnects the supply.
Dept of E.E.E. |R.Y.M.E.C Bellary. 1
8/3/2019 Automatic Power Saving Energy Meter
2/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
This system is efficient [as it uses Micro-controller PIC IC for monitoring
Number of Units Consumed], therefore accurate assessment of energy audit program
and also necessary to promote a goodwill and consumer relation and thereby ensuring
exact revenue collection, which is exact proportion to the generation of electrical
energy.
MICRO-CONTROLLER IN DAILY LIFE
Micro-controller has elevated electronics to a great height. It is being used in
many industrial instruments, medical equipment, microcomputers and programmable
logic controllers. Its speed of operations is amazing. Electronic equipment can be used
in efficient man-machine interface, making the communications faster.
Having helped the industry, electronics has entered the house. Transistor,
radio, tape recorders, television sets, toy and educational equipment are commonly
household items. All these products have made the life more comfortable. Personal
computers are being used in homes in many countries to keep track of accounts,
family health details and such other information.
Remote controllers for TVs and VCRs enable viewers to switch off the set or
change the channel from a distance. Bigger houses have intercoms so that a person
need not get to another room for communication. Burglar alarm is energized before
leaving the house. Whoever enters the house has to first put off the system by
resetting it. The location is known available to disable it is only 10 to 25 seconds. An
unauthorized visitor will not be able to reset the switch in that time and the alarm will
alert the neighbors. Fire sensors, gas alarm are the other gadgets, which take care of
fire mishaps. Time switches turn on and off any electrical appliance at the preset time.
Video games and electronic toys help in providing leisure and comfort at
home. However, these systems cannot generally be combined together for economical
compatibility
.
Dept of E.E.E. |R.Y.M.E.C Bellary. 2
8/3/2019 Automatic Power Saving Energy Meter
3/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
AUTOMATION AT INDUSTRIES
Micro-controller based Industrial Automation is aimed to reduce supervision
of human and to create a comfortable & safe working environment. There are several
big companies who are engaged in this Micro-controller Based Industrial Automation
field. For example Allen Bradley, ABB, Siemens are producing Programmable Logic
Controllers [PLLs] and their related instruments, software, hardware and controlling
panels. These PLLs are capable of controlling the small, medium or big industries
with less human intervention.
Micro-controller based Industrial Automation (IA) comprises four sub-
systems to perform different functions [of course with the help of Computer]:
Industrial keeping system: -
A module called Home Terminal which comprises a telephone/intercom
master unit, master and room monitor controller, TV, door and phone controllers and
indicators is the heart of security & safety keeping system.
This sub-system controls temperature of water in furnace, keeps record of the
consumption of electricity and water gets signals from burglar alarms, gas leaks,
flame sensors etc, and gives warning. Besides, it receives the incoming phone calls,
answers or sends messages at appropriate time and turns on/off time-punch machines
for attendance purpose, lighting & vigilant cameras etc. Intercom at the main door lets
the security person know the identity of a visitor. It ensures that the employee has
enough safety and comfort by taking care of security of the industry, energy control,
equipment control etc. It has modular construction and should be installed cent rally,
mainly in new buildings as the wiring involved is to be taken care of.
INTERFACE SYSTEM
Also known as communication system, it allows the user to communicate with
others. It works with high definite TV, cable TV (CATV), direct broadcasting system
(DBS) etc. one can get the news or special announcements through video or audio or
text form.
Dept of E.E.E. |R.Y.M.E.C Bellary. 3
8/3/2019 Automatic Power Saving Energy Meter
4/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
People in some countries now do field work sitting in the comfort of their
chamber through a personal computer connected to the office. On can also use it to
control the instruments and share the status of the instruments with another field
engineer who is far away & connected to the computer database system.
Dept of E.E.E. |R.Y.M.E.C Bellary. 4
8/3/2019 Automatic Power Saving Energy Meter
5/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
2. BLOCK DIAGRAM & ITS DESCRIPTION
The section explains how the MICRO-CONTROLLER BASED POWER
CARD A New Approach to Tariff Collection really works.
In Brief:
This Micro-controller Based Power Card System sits in between the incoming
Mains Power Supply lines and consumers Energy Meter. When consumer inserts his
Power Card inside the Card Holder, first it is verified for authenticity. As every Power
Card has Code Generator circuit which creates unique ID for each Power Card. When
it is inserted inside the Card Holder, it gets its working voltage from this project andstarts emitting IR coded signals to Card Detector. If Card Detector finds the valid IR
coded signals from the Power Card, then it switches ON MCB [Main Circuit Breaker]
of the Home. That means as-soon consumer inserts his Power Card, if it is valid one,
then he will start getting the power supply from that instant only.
The second part of the signal coming from Card Holder goes to Card Analyzer
section for identification of Power Cards designation. This Section makes thecorresponding designations pin high, which in turn passes through Buffer & Driver
stages. This signal is further sent to Logic Stage for processing.
The Logic Stage acts as a brain of the system and receives two reference
signals for decision making. First reference signal comes from card reader section,
which reads consumers Power Card and produces unique reference signal depends
upon the Power Card rating [i.e., designation it holds-whether 100 units or 150 units
or 200 units card]. The second reference signal is taken from the Micro-controller
Chip based Energy Meter section. This signal tells the Logic Stage, how much units
are consumed by the consumer till now. If the total power consumption units equal to
80% of the Power Card designation, then it activates the Tone Generator, which in
turn beeps the buzzer. If both these reference signals equals to each other then Logic
Stage trips the MCB [Main Circuit Breaker], through which home supply is supplied.
Thus power supply will disconnected until another new Power Card is inserted. As
Dept of E.E.E. |R.Y.M.E.C Bellary. 5
8/3/2019 Automatic Power Saving Energy Meter
6/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
consumer inserts new Power Card of any designation, the power supply to home will
be restored for the intended period the Power Card permits.
This Power Card System is divided into three sections for the clarity sake,
which is shown as dotted box in block diagram Fig 2.1. The first section, Card Reader
Section, consists of Card Holder, Card Detector, Card Analyzer, Buffer & Driver. The
Energy Meter section has four blocks: Energy Meter, Schmitt Trigger, Micro-
controller Based Consumed Unit Monitor & Buffer. The Main Section comprises of
Logic Stage, Driver, Tone Generator & Power Supply Unit blocks.
Before explaining these three sections, take a look at Power Card.
POWER CARD:
Every Power Card bears its unique IR Code number and its designation value
with it. The Code is generated by an oscillator inherited inside the Power Card. When
consumer inserts this Power Card inside the Card Holder, it receives the working
voltage from the Card Holder and starts emitting its unique card code. This Power
Cards ID code is decoded by the Card Detector and confirms that the card inserted is
authorized one or not. This Card offers unique IR code to Card Analyzer for
identification of designation of the card. This two-layer system makes this card very
robust and reliable.
Let us see the details of each block under three headings as follows:
1. Card Reader Section
2. Energy Meter Section
3. Main Section
Dept of E.E.E. |R.Y.M.E.C Bellary. 6
8/3/2019 Automatic Power Saving Energy Meter
7/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
CARD READER SECTION
CARD HOLDER: Basically it is just a Card Holder, which holds the Power Card
inserted by the consumer and helps the system to read it. This block supplies the
working voltage to the Power Card, so that it can transmit its unique code to Card
Detector block and Card Analyzer block.
CARD DETECTOR: This block verifies the authorization of the inserted Power Card
by checking the IR packets across the IR Sensor. If it found valid IR packets or
signals then switches MCB [Main Circuit Breaker] ON. By this action, consumer gets
power supply as soon he inserts valid Power Card. This section is nothing but an IR
Receiver, which decodes Infra Red signal Packets for communication.
CARD ANALYZER: The Power Card inserted inside the Card Holder offers certain
unique Rx resistance to this Card Analyzer. This unique Rx resistance depends on the
designation of the Power Card, which it bears. Here this block makes the decision
with the help of popular Comparator IC, whether inserted Power Card is having 100
units or 150 units or 200 units designation value. According to the detected value, it
activates the respective Buffer block.
BUFFER: This stage of the system is used to isolates the driver section from the Card
Holder & its associated blocks and also to match the impedance of Input and Output
circuits. Here, hex buffer IC is used to achieve the required goal. Each designation of
Card has its own Buffer & Driver block. Any one Buffer block gets activated depends
on the Card Analyzers output. The output of that Buffer is fed to respective Driver
Block.
DRIVER: The Driver Block is used to carry the first reference signal [i.e., designation
of the Power Card]. The Darlington Transistor Pair is used in unity gain amplifier
mode, which in turn activates the relay connected across it. The relay outputs are
connected to Logic Stage for decision taking action.
Dept of E.E.E. |R.Y.M.E.C Bellary. 7
8/3/2019 Automatic Power Saving Energy Meter
8/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
ENERGY METER SECTION
ENERGY METER: This is an Energy Meter, which shows the total units consumed
by the user in digital form. That means it produces signals whenever any units
consumption takes place. The output of this Energy Meter is fed to Schmitt Trigger
block for further processing.
SCHMITT TRIGGER: This receives the current unit consumed by Energy Meter, to
which it is connected. The information coming out of Energy Meter should be
converted into digital pulses, so that rest of the digital circuit should process it further.
So this unit consumed information of Energy Meter is converted into predefinedpulses using this Schmitt Trigger Stage. That means this stage produces a pulse for
every unit the Consumer consumes. The output of this stage is given to Consumed
Unit Monitor block.
MICRO-CONTROLLER BASED CONSUMED UNIT MONITOR: This block
counts the number of pulses coming from the Schmitt Trigger and keeps the total unit
consumption record. The output of this stage is given to Buffer stage.
BUFFER: The buffer is basically a unity gain amplifier, which is used to match the
input & output impedances. This helps us in compensating the signal disorders caused
by the improper circuit impedances. The output of this block goes to Logic Stage for
decision making purpose.
Dept of E.E.E. |R.Y.M.E.C Bellary. 8
8/3/2019 Automatic Power Saving Energy Meter
9/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
MAIN SECTION
LOGIC STAGE: This decision making stage is built using logic ICs and receives two
inputs, one from Card Reader Section & other from Energy Meter Section. If Energy
Meter Sections output is 80% of the Card Reader Section, then it activates the Tone
Generator to beeps the buzzer. If it founds that two inputs are equal, then activates
driver block to switch OFF the MCB. This block is built around logic ICs
DRIVER: As the name of itself indicates, the driver stage is used to drive the relay.
Since the digital ICs cannot drive the heavy voltage MCB or electromagnetic relay [of
12 V], this driver circuit is used. This block actually cuts the power supply as soon isit gets coil current. This driver circuit is configured in Darlington Driver Mode.
TONE GENERATOR: This block is used to produce the alert beeps whenever total
units consumed by the user reaches the 80% of the Power Cards designation value.
POWER SUPPLY UNIT: This MICRO-CONTROLLER BASED POWER CARD
project needs three working voltages, +12Volts for driving relays, +9V for Op-amp
IC and +5 Volts for other circuits. So, special power supply is designed to generate
these triple, fixed and regulated voltages.
Dept of E.E.E. |R.Y.M.E.C Bellary. 9
8/3/2019 Automatic Power Saving Energy Meter
10/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Fig 2.1 BLOCK DIAGRAM OF POWER CARD [using PIC]
Dept of E.E.E. |R.Y.M.E.C Bellary. 10
POWERSUPPLY
UNIT
ENERGYMETER
Card Reader Section
Buzzer
LOGIC STAGE
DRIVER
DRIVER I
DRIVER II
DRIVER III
BUFFER I
BUFFER II
BUFFER III
Energy Meter Section
BUFFER I
BUFFER II
BUFFER III
SCHMITTTRIGGER
CARDDETECTOR
CARDANALYZER
CONSUMED UNITMONITOR
[Micro-controller Chip]
CARDHOLDER
Code Generator
TONEGENERATOR
POWERSUPPLY
UNITMAIN
CIRCUITBREAKER
ID CARD
X a b Y
8/3/2019 Automatic Power Saving Energy Meter
11/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
3. CIRCUIT DIAGRAM & ITS DESCRIPTION
This MICRO-CONTROLLER BASED POWER CARD project generates two
reference signals and processes them intelligently so that exact designated units must be
consumed by the consumer. The Power Card is the Key Input device, which in turn
causes to generate first reference signal. The second reference signal is produced at
Energy Meter side.
Except the Power Card this MICRO-CONTROLLER BASED POWER CARD
system is divided into three parts: Card Reader Section, Energy Meter Section & Main
Section. These three parts are further divided into sub-sections, based on the circuitblocks each are constructed. The Circuit Description of each part along with Power Card
is discussed in separate headings for clarity sake.
POWER CARD
This Power Card has two layer design: one is to confirm that this Power Card is
an Authorized one [which is achieved by implementing IR Transmitter circuit]; and
second is to tell the Card Reader that how much the Power Cards designation is. ThePower Card comes in three designations 100 units, 150 units & 200 units. This
designation is set by the resistance or impedance value fitted inside this Power Card. As
this point is very clear, there is no need of any further explanation is required. Below
section explains about IR Communication & transmitter circuit and its working.
Dept of E.E.E. |R.Y.M.E.C Bellary. 11
8/3/2019 Automatic Power Saving Energy Meter
12/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
CARD HOLDER
The function of this circuit block is to hold the Power Card, which is inserted by
the Consumer. This Card Holder block not only holds it but also provides power supplyto IR Transmitter and gives the reference resistance Rx to Card Analyzer circuit.
Circuit Description:
This circuit block is very simple. The Card Holder Slot has four active lines, X a b Y, as
shown in circuit diagram. The points X & Y offers pre-defined unique IR Coded signal to
Card Analyzer Circuit for further processing. The points a & b gives +Vcc and Gnd
connections to IR Transmitter, which are coming from Power Supply Unit.
Dept of E.E.E. |R.Y.M.E.C Bellary. 12
CIRCUIT DIAGRAM OF CARD HOLDER
C1
Working VoltageFrom
Power Supply Unit
+Vcc Gnd
X a b Y
To Card Analyzer Circuit
Card Holder Slot
8/3/2019 Automatic Power Saving Energy Meter
13/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
CARD ANALYZER with BUFFER & DRIVER
This module analyzes the Power Card for its designation, i.e., whether it bears 100
units or 150 units or 200 units designation. Then this power card section is isolated from
the Logic stage by introducing a Buffer stage. And the output of this Buffer stage is fed to
driver circuit to drive the low impedance relay.
The heart of this card analyzer is the popular Operational Amplifier IC. Here
every Power Card offers some unique amount of resistance to the card analyzer block.
Depends upon the resistance the card offers, card reader comes to know what designation
the card holder got.
Before the detailed description of this Card Analyzer circuit, let us familiarized
with the basic terms & components used in this circuit.
Operational Amplifier: Designed originally for analogue computer and control
applications, the operational amplifier has found its way into almost every field of
electronics. Todays Integrated Circuit Op-Amps offer many advantages over their
discrete component predecessors. Circuit design is greatly simplified with the addedbonus that the characteristics of the latest generation of Op-Amps, far exceed those of
their predecessors.
An Op-amp is a direct coupled high gain amplifier, usually consisting of one or
more differential amplifiers and usually followed by a level translator and an output stage.
Output stage is generally a push-pull or push-pull complementary symmetry pair. An Op-
amp is available as single IC package. The maximum common mode voltage that can be
applied to an Op-amp without disturbing its proper function is of the order +13 V or 13
V.
THE DESIRABLE CHARACTERISTICS OF OP-AMPS ARE:
a) The open-loop voltage gain should be very high (ideally infinity).
b) The input resistance should be very high (ideally infinity).
c) The output resistance should be very low (ideally zero).
d) Full power bandwidth should be as wide as possible.
Dept of E.E.E. |R.Y.M.E.C Bellary. 13
8/3/2019 Automatic Power Saving Energy Meter
14/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
e) Slew rate should be as large as possible.
f) Input offset should be as small as possible.
g) CMRR should be as large as possible.
ELECTRICAL PARAMETERS OF OP-AMP:
1. I/p off-set voltage (Vio) :
It is the voltage that must be applied between the two input terminals of an op-amp to
verify the output to be null.
2. I/p off-set current (Iio):
The algebraic difference between the current into the inverting and non inverting
terminal is reffered as input Off-set current.
3. I/p Bias current:
It is the average of the current that flow into inverting and non-inverting input terminalsof
the Op-amp.In the equation form:
IB= (IB1+IB2) / 2
4. Differential I/p resistance:
It is the equivalent resistance that can be measured at either terminal connected to group.
5. I/p capacitance:
It is the equivalent capacitance that can be measured at either the inverting or non-
inverting input terminal with the either terminal connected to ground .
6. CMRR (Common Mode Rejection Ratio ):
The CMRR is defined as the ratio of differential voltage gain Ad to the common
voltage gain Acm , i.e.,
CMRR = Ad / Acm .
The higher the value of CMRR ,better is the matching between two input terminals and
smaller is the output common mode voltage .
7. SVRR (Supply Voltage Rejection Ratio ):
The change in OP-amps input OFF SET voltage Vio caused by variation in supply
voltages is called the SVRR . These are expressed in v / v or in dBs
Dept of E.E.E. |R.Y.M.E.C Bellary. 14
8/3/2019 Automatic Power Saving Energy Meter
15/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
SVRR = Vio / V .
Where ,
Vio = input offset voltage & V= supply voltage
8. Input Voltage Range:
It is the maximum common mode voltage that can be applied to an Op-amp without
disturbing its proper function. It is of the order +13 V or 13 V
9. Large Signal Voltage Gain:
Since the OP-amp amplifies difference voltage between two input terminals, the voltage
gain of the amplifier is defined as,
A= o/p Voltage / Diff. i/p Voltage = Vo / Vid.10. Gain Bandwidth Product:
It is the bandwidth of the Op-amps when the gain is unity.
11. Slew Rate :
It is defined as max. rate of change of output voltage / unit of time and is expressed in
volts / sec.
| V / sec
SR = dvo / dt |
| max.
POWER DRIVING CIRCUITS:In many applications, a relay will require some form of
interface to the circuit to which it is connected. Often such an interface need consist of
nothing more than a single transistor. Almost any n-p-n transistor with a current gain of
50 or more can be used in the circuit. However, it is important to ensure that it is operated
within its maximum collector current (IC(max)) rating. The coil resistance of relay andpreferred transistors are as follows: 50 ohm to 200 ohm - T1P31 (or equivalent), 200
Ohm to 400 Ohm - BC142 (or equivalent), 400 Ohm to 1.2 K Ohm - BC108 (or
equivalent). The circuit requires an input current of about 0.5 mA when operated from a
5V source. In some applications it may be desirable to increase the sensitivity of the
circuit, in which case a Darlington driver stage can be used. A Darlington driver based on
two (discrete) n-p-n devices requires a current of only a mere 40 A at 5V in order to
operate the relay. This circuit can be used with relays having coil resistance as low as
about 200 ohm and will also operate reliable with an input current of as little as 40 A.
Dept of E.E.E. |R.Y.M.E.C Bellary. 15
8/3/2019 Automatic Power Saving Energy Meter
16/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
RELAY: The traditional method of switching current through a load, which requires
isolation from the controlling circuit, involves the use of an electromechanical relay. Such
devices offer a simple, low-cost solution to the problem of maintaining adequate isolation
between the controlling circuit and the potentially lethal voltages associated with an a.c.
main supply. The coils, which provide the necessary magnetic flux to operate a relay, are
available for operation on a variety of voltages between 5V and 115V d.c. and 12V to
250V a.c. at currents of between 5 mA and 100 mA.
OPTO-COUPLER IC MCT 2E: Buffers does not affect the logical state of a digital signal
(i.e. logic 1 input results into logic 1 output where as logic 0 input results into logic 0
output). Buffers are normally used to provide extra current drive at the output are used in
interfacing applications. This 6-pin DIL packaged IC MCT 2E acts as Buffer as-well-as
Isolator. The input signals may be of 2.5 to 5V digital TTL compatible or DC analogue
the IC gives 5V constant signal output. The IC acts as isolator and provides isolation to
the main circuit from varying input signals. The working voltage of IC is fed at pin-5 and
input to pin-1. The pin-2 is ground and pin-4 is output. Note that pin-3 and pin-4 are not
available pins, which must be left free. And the isolated circuit must have its own ground
connection.
The Opto-coupler IC has a photo diode which illuminates whenever input signal
appears at pin-1. A photo transistor, whose Base-lead open, receives the signal from the
blinking photo diode and passes it intact to the output pin-4. As this switching action is
very fast, in term of micro seconds, the signal transfer is successfully done without any
delay and signal loss. As there is any physical contact between photo diode and photo
transistor is observed, it is used for isolating two sections of the circuit. Especially the
delicate digital circuits or signal sensitive stages whose output is supposed to drive a
fluctuating stage or mains operated load.
Since the digital outputs of the some circuits cannot sink much current, they are
not capable of driving relays directly. So, high-voltage high-current Darlington arrays are
added to this opto-coupler IC for interfacing low-level logic circuitry and peripheral
power loads. Typical loads include relays, solenoids, stepping motors, magnetic print
hammers, multiplexed LED and incandescent displays, and heaters.
Dept of E.E.E. |R.Y.M.E.C Bellary. 16
8/3/2019 Automatic Power Saving Energy Meter
17/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Circuit Description:
COMPARATOR STAGE:
When consumer inserts Power Card inside the Card Holder, it measures
impedance of the Rx fitted inside the Power Card smartly by accessing X Y points and
decides what the designation it holds. The circuit diagram shows that three operational
amplifiers compare the drop across the test leads to a fixed voltage and indicate which of
the two is highest by switching their output to the positive supply level or ground [see the
accompanying table].
STATUS 100 Units 150 Units 200 UnitsComparator A1
Comparator A2
Comparator A3
Indicator LED
Relay Activated
0
0
0
D2
RLA
1
0
0
D3
RLB
1
1
0
D4
RLC
The three comparators A1, A2 & A3 of IC1 are used to compare the Power Card
input and decide, whether it got 100 Units denomination or 150 Units or 200 Units. This
circuit accepts the Unknown Resistance Rx of Power Card across the resistors R1 & R4.
Out of these two inputs one is fed to Inverting pin of comparator A1 and other input is fed
to Non-Inverting pin of comparator A2 and Inverting pin of comparator A1. Depends
upon the Unknown resistance Rx value, any one comparators output goes High.
Dept of E.E.E. |R.Y.M.E.C Bellary. 17
I N P U
G N
N / C
1
2
3
6
5
4
N / C
V c
O U T P
M C 2 E O P C O U P L
8/3/2019 Automatic Power Saving Energy Meter
18/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
CIRCUIT DIAGRAM OF CARD READER
Dept of E.E.E. |R.Y.M.E.C Bellary. 18
D4LED
D3
R19
R16
R13
D5
T5T6
T1T2
D2LED
A1
A2A2
115
12
5
21
14
13
3
R7
R10
R8
D1
D6
4
76
P1 P2
R12R11R6R4
R5 R2R1R3
A3
A2
A12
T3T4
R17
100
R18
R20
R21
Rx
R14100
RL A100 units
R15
A1 TO A3 = IC1
R9
OPTO-COUPLER IIC2
COMPARATORSTAGE OPTOCOUPLER DRIVER STAGE
RL B150units
RL C200 units
DRIVER IOUTPUT
DRIVERIIOUTPUT
DRIVER IIIOUTPUT
OPTO-COUPLERII
IC3
OPTO-COUPLERIII
IC4
8/3/2019 Automatic Power Saving Energy Meter
19/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Parts List:
Dept of E.E.E. |R.Y.M.E.C Bellary. 19
SEMICONDUCTORSIC1 [A1-A2-A3] LM324 Op-Amp 1
IC2 MCT 2E Opto-coupler 3
T1 TO T6 BC547 NPN Transistor 6
RESISTORSR1-R4, R13,R16,R19 1 K Ohm, Watt, Carbon Type 7
R5, R6 10 K Ohm, Watt, Carbon Type 2
R7 to R10 470 Ohm, Watt, Carbon Type 4
R11 1 Mega Ohm, Watt, Carbon Type 1
R12 2.7 Mega Ohm, Watt, Carbon Type 1
R14,R17,R20 100 Ohm, Watt, Carbon Type 3
R15,R18,R21 33 K Ohm, Watt, Carbon Type 3
P1 & P2 500 K Ohm, Preset 2
DIODES
D1& D6 1N4148 SIGNAL Diodes 2
D2 to D5 Red Indicator LEDs 4
MISCELLANEOUSRL A, RL B, RL C 12 V, 700 Ohm DPDT Reed Relays 3
8/3/2019 Automatic Power Saving Energy Meter
20/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
If the inserted Power Card has 100 units designation, then comparator A1s output
at pin-7 goes High. If inserted Card is of 150 Units then comparator A2s output at pin-1
goes High. Finally comparator A3s output at pin-14 goes High when 200 Units Power
Card is used.
OPTOCOUPLER:
The Comparator output is fed to Opto-coupler stage, which is used when the main
circuit is supposed to isolate itself from the relay driven stages. The output of comparator
is applied at input pin-1 and at pin-4 output is observed. Since the biasing voltage need
very high current path, two signal diodes D1 & D6 are used along the other biasing
resistors, viz., R7,R8,R9, & R10. There is one indicator LED D5, which is optional and
indicates the one more condition other than the three levels. The output at pin-4 of each
opto-coupler IC is taken out to driver stage, by supplying biasing voltage through R15,
R18, & R21.
The 100 Units High signal makes Opto-coupler I IC-IC2 to conduct and in result
transfers the signal to Driver I stage. The 150 Units High signal makes Opto-coupler II
IC-IC3 to conduct and thus drives Driver II stage. Finally 200 Units High signal makes
Opto-coupler III IC-IC4 to conduct and thus drives Driver III stage.
DRIVER STAGE:
Now the Comparator circuit is totally isolated from this relay driver circuit. But
this signal level is not strong enough to drive the low impedance relay. So, Darlington
driver is created using two NPN transistors [T1 & T2, T3 & T4, T5 & T6 transistor pairs]
and boost the signal level. The output signal from the Darlington driver stage is strong
Dept of E.E.E. |R.Y.M.E.C Bellary. 20
8/3/2019 Automatic Power Saving Energy Meter
21/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
enough to actuate relays [RL A, RL B & RL C]. These relays N/O [Normally Open]
pins are used to give first reference signal. The red LEDs [D2, D3 & D4] indicate whether
the relay is energized or not. The resistors R13, R14 and R15 are current limiting
resistors.
The 100 Units High signal coming out of Opto-coupler I is used to drive Driver I
comprised by T1 & T2 transistor pairs. This switching circuit actuates relay RL A and
simultaneously makes Driver I output as High signal for further processing.
The 150 Units High signal coming out of Opto-coupler II is used to drive Driver II
comprised by T3 & T4 transistor pairs. This switching circuit actuates relay RL B and
simultaneously makes Driver II output as High signal for further processing.
The 200 Units High signal coming out of Opto-coupler III is used to drive Driver
III comprised by T5 & T6 transistor pairs. This switching circuit actuates relay RL C
and simultaneously makes Driver III output as High signal for further processing.
CALIBIRATION:
The ranges of indicator LEDs D1 and D2 are adjusted with presets P1 and P2.
There are two presets P1 & P2 allowing user to set the reference value. The first preset P1
is biased with R5 & R6 and its variable end goes to Non-inverting pin of Comparator A1.
The second preset P2 is biased similarly using R2 & R11 and its variable end is connected
to Inverting end of Comparator A2. Clip the test leads to a 5 resistor, and adjust P1 so
that D1 just goes out and D2 just lights. Similarly, use a 100k resistor for adjusting P2
until D3 and D4 just go out and light respectively.
NOTE: It is recommended to decouple R11 with a 22 F electrolytic capacitor when the
supply voltage is relatively low.
Dept of E.E.E. |R.Y.M.E.C Bellary. 21
8/3/2019 Automatic Power Saving Energy Meter
22/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
4. ENERGY METER SECTION
SCHMITT TRIGGER
This Schmitt Trigger produces the pulses, which are directly proportional to the
units consumed by the consumers energy meter. That means output of Energy Meter is
fed to this stage as trigger pulse. This circuit converts the data coming out of Energy
Meter into digital pulse form for easy processing. This stage built around popular timer
IC is essential as the rest of the circuit deals with digital pulses only. The output of this
stage is given to Consumed Unit Monitor for further processing.
The basic function of the Schmitt trigger circuit is to convert / generate a chain of
square wave from any regular or irregular signal input. The triggering pulse generator
produces a series of square waves using signals produced by Energy Meter, and acts like
a clock signal generator to the further section. Here the square waves generated by the
Trigger pulse generator are fed to the Consumed Unit Monitor.
Introduction:
Digital circuits often require a source of accurately defined pulses. The
requirement is generally for a single pulse of given duration (i.e. a one shot) or for a
continuous train of pulses of given frequency and duty cycle. Rather than attempt to
produce an arrangement of standard logic gates to meet these requirements, it is usually
simpler and more cost-effective to make use of one of the range of versatile integrated
circuits known collectively as timers. The greater level of accuracy and stability with
long Monostable periods is possible only with timer IC. The 555 timer is a neat mixture
of analogue and circuitry but its applications are virtually limitless in the world of digital
pulse generation. These devices can usually be configured for wither Monostable orAstable operation and require only a few external components in order to determine their
operational parameters.
Dept of E.E.E. |R.Y.M.E.C Bellary. 22
8/3/2019 Automatic Power Saving Energy Meter
23/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
INTERNAL ARRANGEMENT OF 555 TIMER IC
The timer comprises two operational amplifiers (used as comparators) together
with an RS Bistable element. In addition, an inverting output buffer is incorporated sothat a considerable current can be sourced or sunk to/from a load. A single transistor
switch, TR1, is also provided as a means of rapidly discharging the external timing
capacitor.
The standard 555 timer is housed in an 8-pin DIL package and operates from
supply rail voltages of between 4.5V and 15V. This encompasses the normal range for
TTL devices and thus the device is ideally suited for use in conjunction with TTL
circuitry.
PIN OUT DIAGRAM OF TIMER IC 555
Dept of E.E.E. |R.Y.M.E.C Bellary. 23
RESET
OUTPUT
TRIGGER
VCC
555
8
7
6
5
2
3
1
4
DISCHARGE
THRESHOLD
GROUND
CONTROL
8/3/2019 Automatic Power Saving Energy Meter
24/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
CIRCUIT DIAGRAM OF SCHMITT TRIGGER USING 555 TIMERIC
Parts List:
Dept of E.E.E. |R.Y.M.E.C Bellary. 24
SEMICONDUCTORS
IC1 555 Timer IC 1R1 47 K Ohm Watt 1
R2 10K Ohm Watt 1
P1 100K Ohm Preset 1
CAPACITORSC1 0.001 f Ceramic Disc type 1
C2 0.01F Ceramic Disc type 1
R2
P1
C1
4 87
3
1
6
25
+Vcc
To Counter
C2
R1 47K
555
GND
Trigger pulse fromEnergy Meter
8/3/2019 Automatic Power Saving Energy Meter
25/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Circuit Description:
An electronic circuit that generates square waves using positive feedback is
known as a Multivibrator. This switching circuit is basically a two stage amplifier and
operates in two states (ON and OFF) controlled by external circuit conditions. There are
three types of Multivibrator: Astable or Free Running Multivibrator, Monostable or One
Shot Multivibrator and Bistable or Flip-flop Multivibrator.
An oscillator circuit which generates square wave of its own (i.e. without external
triggering) is known as Astable or Free Running Multivibrator. The outputted square
pulse is not stable in nature. It switches back and forth from one state to the other. And
the switching time is determined by the external components (i.e. RC constant). These
pulse trains are used to ON/OFF or trigger the connected external circuits. The normal
555 IC Astable Multivibrator can be used readily to drive a relay (operating current must
be less than 150mA).
The circuit diagram shows how the timer IC 555 can be used as an Astable pulse
generator. In this mode the circuit provides very constant output frequency. The
triggering pulse from Energy Meter output is fed to trigger input pin-2 which is grounded
through capacitor C1. When the circuit is first put ON, the capacitor C1 is uncharged and
the trigger input is low and that switching transistor TR1 (at pin-7) is in the non-
conducting state. Thus the output (at pin-3) is high. The capacitor C1 will begin to charge
toward +Vcc with current supplied by means of the series resistors R1, P1 and R2.
When the voltage at the threshold input (at pin-6) exceeds of Vcc, the output
of the upper comparator will change state and the Bistable will be reset, making the
output go HIGH and turning TR1 ON in the process. Due to the inverting action of the
buffer, the final output (at pin-3) will then go LOW.
The capacitor C1 will now discharge, with current flowing through R2 & P1 into
the collector of switching transistor TR1 (at pin-7). At a certain point, the voltage
appearing at the trigger input (pin-2) will have fallen back to one third of the supply
voltage at which point the lower comparator will change state and return the Bistable to
its original set condition. The Q output of the Bistable then goes low, TR1 switches
off, and the final output (pin-3) goes high. Thereafter the entire cycle is repeated
indefinitely.
Dept of E.E.E. |R.Y.M.E.C Bellary. 25
8/3/2019 Automatic Power Saving Energy Meter
26/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
This signal going low-to-high and high-to-low makes one clock pulse and thus
increases the decade counter by one unit.
The essential characteristics of this waveform are:
Time for which output is high: Ton=0.693(R1+R2+P1) CTime for which output is low: Toff=0.693(R2+P1) C
Period of output: T=Ton+Toff=0.693(R1+P1+2R2) C
Pulse Repetitive Frequency of output: p.r.f. = 1.44 / (R1+P1+2R2) C
Pulse Period: T = 1/ p.r.f
Where T is in seconds, C is in farads, and R1 & R2 are in Ohms.
CONSUMED UNIT MONITOR & DRIVER
Dept of E.E.E. |R.Y.M.E.C Bellary. 26
8/3/2019 Automatic Power Saving Energy Meter
27/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
This section counts the number of pulses coming out of Schmitt Trigger; if it
equals any one designation of the Power Card, then it switches the corresponding relay.
The Driver is used to enhance the Consumed Unit Monitor output signals to sufficient
level to drive the low impedance relay.
MICRO-CONTROLLER PIC:
The heart of this module is 14-pin DIL Micro-controller IC PIC, which monitors
the units consumed by Consumers Energy Meter. In this project there are only three
different value Power Cards are used viz., 100 units, 150 units, & 200 units. Hence this
section is programmed to monitor only three specific units with their 90% detection.
Depends upon the number of pulses, this Micro-controller IC makes any one output line
High. This High signal acts as one out-of-two reference signals to Logic stage. As the
received signals are not strong enough to drive the Logic stage, driver section is included.
The switching module contains relays which in turn activates respective Cards output
line High.
HEX BUFFER / CONVERTER [NON-INVERTER] IC 4050:
Buffers does not affect the logical state of a digital signal (i.e. logic 1 input results
into logic 1 output where as logic 0 input results into logic 0 output). Buffers are normally
used to provide extra current drive at the output, but can also be used to regularise the
logic present at an interface. And Inverters are used to complement the logical state (i.e.
logic 1 input results into logic 0 output and vice versa). Also Inverters are used to provide
extra current drive and, like buffers, are used in interfacing applications. This 16-pin DIL
packaged IC 4050 acts as Buffer as-well-as a Converter. The input signals may be of 2.5
to 5V digital TTL compatible or DC analogue the IC gives 5V constant signal output. The
IC acts as buffer and provides isolation to the main circuit from varying input signals. The
working voltage of IC is 4 to 16 Volts and propagation delay is 30 nanoseconds. It
consumes 0.01 mill Watt power with noise immunity of 3.7 V and toggle speed of 3
Megahertz.
Dept of E.E.E. |R.Y.M.E.C Bellary. 27
8/3/2019 Automatic Power Saving Energy Meter
28/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
PIN DIAGRAM OF IC-4040
Dept of E.E.E. |R.Y.M.E.C Bellary. 28
1
2
6
3
16
5
15
4
14
10
11
12
13
7
Vcc
Vss8 9
IC4050
8/3/2019 Automatic Power Saving Energy Meter
29/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Circuit Description:
This Consumed Unit Monitor Circuit is inherited with many sections: Consumed
Unit Monitor, Buffer Section, & Driver Section. Let us see all these sections in detail, in
sequential order.
Micro-Controller IC: This IC is pre-programmed to count the Consumed Units, The
working voltage +Vcc is connected to pin-1 and pin-14 is made ground. The number of
units consumed is fed as clock pulses from Schmitt Trigger section at pin-4 of Micro-
controller chip. Depends upon the number of units consumed, one out-of-six signal output
is made HIGH.
Buffer: The function of this Buffer section is to provide unit gain amplification to Micro-
controller outputted HIGH signal. And also isolates Energy Meter section from Driver
section. The Buffer IC2 has six buffers, which are carrying six outputs of Micro-
controller chip to next stage.
Working of Circuit:
For 100 Units Power Card: Whenever total units consumed reaches 90% of this
card, pin-6 goes High and is carried away as D1 to Logic Stage through Buffer IC [IC2s
input pin-3 & output pin-2]. After 100% unit consumption, pin-7 goes High and drives
the relay through Buffer IC [IC2s input pin-5 & output pin-4]. Resistors R1 & R2
provides path to the output signal.
For 150 Units Power Card: Whenever total units consumed reaches 90% of this
card, pin-8 goes High and is carried away as D2 to Logic Stage through Buffer IC [IC2sinput pin-7 & output pin-6]. After 100% unit consumption, pin-9 goes High and drives
the relay through Buffer IC [IC2s input pin-9 & output pin-10]. Resistors R3 & R4
provides path to the output signal.
For 200 Units Power Card: Whenever total units consumed reaches 90% of this
card, pin-10 goes High and is carried away as D3 to Logic Stage through Buffer IC [IC2s
input pin-10 & output pin-12]. After 100% unit consumption, pin-11 goes High and
Dept. of E.E.E. |R.Y.M.E.C Bellary. 29
8/3/2019 Automatic Power Saving Energy Meter
30/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
drives the relay through Buffer IC [IC2s input pin-14 & output pin-15]. Resistors R5 &
R6 provides path to the output signal.
This explanation is summarized in table form, as shown below:
Output is
High
at Pin
Number
Output
Notation
Power Cards
DenominationRemarks
6 D1 100 Units Indicates completion of 90%
7100u
O/P
100 Units Indicates closing of Power
Card
8 D2 150 Units Indicates completion of 90%
9150u
O/P
150 Units Indicates closing of Power
Card
10 D3 200 Units Indicates completion of 90%
11200u
O/P
200 Units Indicates closing of Power
Card
DRIVER STAGE:
Now the Energy Meter section is totally isolated from this load driver circuit. But
this signal level is not strong enough to drive the low impedance relay. So, Darlington
driver is created using two NPN transistors [T1 & T2 transistor pairs] and boost the signal
level. The output signal from the Darlington driver stage is strong enough to actuate
relays [RL I 100 Units, RL II 150 Units & RL III 200 Units]. The red LED D1 with series
resistor R7 indicate whether the relay is energized or not. The resistor R9 is current
limiting resistor and R9 resistor provides path to HIGH signal towards this driver stage.
The outputs are taken across each driver stage, viz., 100 Units High signal at RL I
as 100u O/P, 150 Units High signal at RL II as 150u O/P, and 200 Units High signal at
RL III as 200u O/P.
5. MICRO-CONTROLLER SECTION
Dept. of E.E.E. |R.Y.M.E.C Bellary. 30
8/3/2019 Automatic Power Saving Energy Meter
31/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
INTRODUCTION OF Micro-controller
The general definition of a microcontroller is a single chip computer, which
refers to the fact that they contain all of the functional sections (CPU, RAM, ROM, I/O,
ports and timers) of a traditionally defined computer on a single integrated circuit. Some
experts even describe them as special purpose computers with several qualifying
distinctions that separate them from other computers.
Microcontrollers are "embedded" inside some other device (often a consumer
product) so that they can control the features or actions of the product. Another name for
a microcontroller, therefore, is "embedded controller."
Microcontrollers are dedicated to one task and run one specific program. The
program is stored in ROM (read-only memory) and generally does not change.
Microcontrollers are often low-power devices. A desktop computer is almost
always plugged into a wall socket and might consume 50 watts of electricity. A battery-
operated microcontroller might consume 50 mill watts.
A microcontroller has a dedicated input device and often (but not always) has a
small LED or LCD display for output. A microcontroller also takes input from the device
it is controlling and controls the device by sending signals to different components in the
device.
A microcontroller is often small and low cost. The components are chosen to
minimize size and to be as inexpensive as possible.
A microcontroller is often, but not always, ruggedized in some way. The
microcontroller controlling a car's engine, for example, has to work in temperature
extremes that a normal computer generally cannot handle. A car's microcontroller in
Kashmir regions has to work fine in -30 degree F (-34 C) weather, while the same
microcontroller in Gujarat region might be operating at 120 degrees F (49 C). When you
add the heat naturally generated by the engine, the temperature can go as high as 150 or
180 degrees F (65-80 C) in the engine compartment. On the other hand, a microcontroller
embedded inside a VCR hasn't been ruggedized at all.
Dept. of E.E.E. |R.Y.M.E.C Bellary. 31
8/3/2019 Automatic Power Saving Energy Meter
32/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Clearly, the distinction between a computer and a microcontroller is sometimes
blurred. Applying these guidelines will, in most cases, clarify the role of a particular
device.
The programmability of modern desktop PCs makes them extraordinarily
versatile. The functionality of the entire machine can be altered by merely changing its
programming. Microcontrollers share this attribute with their desktop relatives. The chips
are manufactured with powerful capabilities and the end user determines exactly how the
device will function. Often, this makes a dramatic difference in the cost and complexity
of a particular design. The true impact of this statement is best illustrated by example.
For every clock pulse, the circuit produces one of the three bit numbers in the
sequence 000, 100, 111, 010, 011. This design has been implemented with three flip-flops
and seven discrete gates as well as a significant amount of wiring.
The design of this system can be quite laborious. One must begin with a state
graph followed by a state table. Then, the flip-flop T input equations must be derived
from a set of Karnaugh maps. Next, the t input equations must be transformed into the
actual T input network. All of this circuitry must then be wired together; a task that's time
consuming and sometimes error prone. On the other hand, this can be accomplished with
a simpler, less costly microcontroller design. Notice the dramatic difference in the amount
of hardware and wiring. This simple circuit, along with about a dozen lines of code, will
perform the same task as the first circuit. There are other benefits as well. The
microcontroller implementation does not have to contend with the undetermined states
that sometimes occur with discrete designs. Also consider for a moment what would be
required to change the sequence of numbers in the first circuit. What if the output needsto be changed to eight bits instead of three? These are trivial modifications for the
microcontroller while the discrete circuit would require a complete redesign.
The example above is not an obscure case. The effects of this device are being felt
in almost every facet of digital design. A sure method of determining the popularity of an
electronic device is to note when they attain widespread use by hobbyists. It therefore
becomes essential that the electronics engineer or hobbyist learn to program these
microcontrollers to maintain a level of competence and to gain the advantages
microcontrollers provide in his or her own circuit designs.
Dept. of E.E.E. |R.Y.M.E.C Bellary. 32
8/3/2019 Automatic Power Saving Energy Meter
33/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Introducing the Intels Microcontroller 89C51
Features
Compatible with MCS-51 Products
8K Bytes of In-System Reprogrammable Flash Memory
Endurance: 1,000 Write/Erase Cycles
Fully Static Operation: 0 Hz to 24 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters Eight Interrupt Sources
Programmable Serial Channel
Low-power Idle and Power-down Modes
Description
The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer
with 8K 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 80C51 and 80C52 instruction set and pin out.
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 Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which
provides a highly-flexible and cost-effective solution to many embedded control
applications.
The AT89C52 provides the following standard features: 8K bytes of Flash, 256
bytes of RAM, 32 I/O lines, 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 AT89C52 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes. The Idle Mode
Dept. of E.E.E. |R.Y.M.E.C Bellary. 33
8/3/2019 Automatic Power Saving Energy Meter
34/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
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.
Dept. of E.E.E. |R.Y.M.E.C Bellary. 34
8/3/2019 Automatic Power Saving Energy Meter
35/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Pin Description
Port 0
Port 0 is an 8-bit open drain bi-directional 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 ashigh impedance inputs.
Port 0 can also be configured to be the multiplexed low order address/data bus
during accesses to external program and data memory. In this mode, P0 has internal pull
ups.
Port 0 also receives the code bytes during Flash programming and outputs the
code by test during program verification. External pull ups are required during program
verification.
Port 1
Port 1 is an 8-bit bi-directional I/O port with internal pull ups. 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 pull ups 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 pull ups.
In 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.
Port 1 also receives the low-order address bytes during Flash programming and
verification. Port Pin Alternate Functions P1.0 T2 (external count input to Timer/Counter
2), clock-out P1.1 T2 EX (Timer/Counter 2 capture/reload trigger and direction control)
AT89C52
Port 2
Port 2 is an 8-bit bi-directional I/O port with internal pull ups. 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 pull ups 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 pull ups.
Dept. of E.E.E. |R.Y.M.E.C Bellary. 35
8/3/2019 Automatic Power Saving Energy Meter
36/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Port 2 emits the high-order address byte during fetches from external program memory
and during accesses to external data memory that uses 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 uses 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.
Port 3
Port 3 is an 8-bit bi-directional I/O port with internal pull ups. 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 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 receives some control signals for Flash programming and verification.
Port Pin Alternate Functions
P3.0 RXD (serial input port)
P3.1 TXD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
P3.6 WR (external data memory write strobe)
P3.7 RD (external data memory read strobe)
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.
ALE/PROG
Address Latch Enable 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
Dept. of E.E.E. |R.Y.M.E.C Bellary. 36
8/3/2019 Automatic Power Saving Energy Meter
37/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
the oscillator frequency and may be used for external timing or clocking purposes. Note,
however, that one ALE pulse is skipped during 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 is weakly pulled high. Setting the ALE-disable bit has no effect if the
microcontroller is in external execution mode.
PSEN
Program Store Enable is the read strobe to external program memory. When the
AT89C52 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 when 12-volt programming is selected.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
Special Function Registers
A map of the on-chip memory area called the Special Function Register (SFR)
space. 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.
Dept. of E.E.E. |R.Y.M.E.C Bellary. 37
8/3/2019 Automatic Power Saving Energy Meter
38/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
User software should not write 1s to these unlisted locations, since they may be
used in future products to invoke AT89C52 new 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 and
T2MOD for Timer2. The register pair (RCAP2H, RCAP2L) is the Capture/Reload
registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.
Interrupt Register
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.
Symbol FunctionTF2 Timer 2 overflow flag set by a Timer 2 overflow and must be cleared by software.
TF2 will not be set when either RCLK = 1 or TCLK = 1.
EXF2 Timer 2 external flag set when either a capture or reload is caused by a negative
transition on T2EX and EXEN2 = 1. When Timer 2 interrupt is enabled,
EXF2 = 1 will cause the CPU to vector to the Timer 2 interrupt routine.
EXF2 must be cleared by software. EXF2 does not cause an interrupt in
up/down counter mode (DCEN = 1).
RCLK Receive clock enable. When set, causes the serial port to use Timer 2 overflow
pulses for its receive clock in serial port Modes 1 and 3. RCLK = 0 causes
Timer 1 overflow to be used for the receive clock.
TCLK Transmit clock enable. When set, causes the serial port to use Timer 2 overflow
pulses for its transmit clock in serial port Modes 1 and 3. TCLK = 0 causes
Timer 1 overflows to be used for the transmit clock.
EXEN2 Timer 2 external enable. When set, allows a capture or reload to occur as a
result of a negative transition on T2EX if Timer 2 is not being used to
clock the serial port. EXEN2 = 0 causes Timer 2 to ignore events at T2EX.
TR2 Start/Stop control for Timer 2. TR2 = 1 starts the timer.
C/T2 Timer or counter select for Timer 2. C/T2 = 0 for timer function. C/T2 = 1 for
external event counter (falling edge triggered).
Dept. of E.E.E. |R.Y.M.E.C Bellary. 38
8/3/2019 Automatic Power Saving Energy Meter
39/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
CP/RL2
Capture/Reload select. CP/RL2 = 1 causes captures to occur on negative
transitions at T2EX if EXEN2 = 1. CP/RL2 = 0 causes automatic reloads to occur when
Timer 2 overflows or negative transitions occur at T2EX when EXEN2 = 1. When either
RCLK or TCLK = 1, this bit is ignored and the timer is forced to auto-reload on Timer 2
overflow.
Data Memory
The AT89C52 implements 256 bytes of on-chip RAM. The upper 128 bytes
occupy a parallel address space to the Special Function Registers. That means the upper
128 bytes have the same addresses as the SFR space but are physically separate from SFR
space.
When an instruction accesses an internal location above address 7FH, the address
mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of
RAM or the SFR space. Instructions that use direct addressing access SFR space. For
example, the following direct addressing instruction accesses the SFR at location 0A0H
(which is P2).
MOV 0A0H, #data
Instructions that use indirect addressing access the upper 128 bytes of RAM. For
example, the following indirect addressing instruction, where R0 contains 0A0H,
accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H).
MOV @R0, #data
Note that stack operations are examples of indirect addressing, so the upper 128
bytes of data RAM are available as stack space.
Timer 0 and 1
Timer 0 and Timer 1 in the AT89C52 operate the same way as Timer 0 and Timer
1 in the AT89C51.
Timer 2
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event
counter. The type of operation is selected by bit C/T2 in the SFR T2CON. Timer 2 has
three operating modes: capture, auto-reload (up or down counting), and baud rate
generator. The modes are selected by bits in T2CON. Timer 2 consists of two 8-bit
Dept. of E.E.E. |R.Y.M.E.C Bellary. 39
8/3/2019 Automatic Power Saving Energy Meter
40/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every
machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is
1/12 of the oscillator frequency.
In the Counter function, the register is incremented in response to a 1-to-0
transition at its corresponding external input pin, T2. In this function, the external input is
sampled during S5P2 of every machine cycle. When the samples show a high in one cycle
and a low in the next cycle, the count is incremented. The new count value appears in the
register during S3P1 of the cycle following the one in which the transition was detected.
Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0
transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a
given level is sampled at least once before it changes, the level should be held for at least
one full machine cycle.
Capture Mode
In the capture mode, two options are selected by bit EXEN2 in T2CON. If
EXEN2 = 0, Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in
T2CON.
This bit can then be used to generate an interrupt. If EXEN2 = 1, Timer 2
performs the same operation, but a 1-to-0 transition at external input T2EX also causes
the current value in TH2 and TL2 to be captured into RCAP2H and RCAP2L,
respectively. In addition, the transition at T2EX causes bit EXF2 in T2CON to be set. The
EXF2 bit, like TF2, can generate an interrupt.
Auto-reload (Up or Down Counter)
Timer 2 can be programmed to count up or down when configured in its 16-bit
auto-reload mode. This feature is invoked by the DCEN (Down Counter Enable) bit
located in the SFR T2MOD. Upon reset, the DCEN bit is set to 0 so that timer 2 will
default to count up. When DCEN is set, Timer 2 can count up or down, depending on the
value of the T2EX pin.
Baud Rate Generator
Dept. of E.E.E. |R.Y.M.E.C Bellary. 40
8/3/2019 Automatic Power Saving Energy Meter
41/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in
T2CON (Table 2). Note that the baud rates for transmit and receive can be different if
Timer 2 is used for the receiver or transmitter and Timer 1 is used for the other function.
Setting RCLK and/or TCLK puts Timer 2 into its baud rate generator mode.
The baud rate generator mode is similar to the auto-reload mode, in that a rollover
in TH2 causes the Timer 2 registers to be reloaded with the 16-bit value in registers
RCAP2H and RCAP2L, which are preset by software. The baud rates in Modes 1 and 3
are determined by Timer 2s overflow rate according to the following equation.
The Timer can be configured for either timer or counter operation. In most
applications, it is configured for timer operation (CP/T2 = 0). The timer operation is
different for Timer 2 when it is used as a baud rate generator. Normally, as a timer, it
increments every machine cycle (at 1/12 the oscillator frequency).
Note that when Timer 2 is running (TR2 = 1) as a timer in the baud rate generator mode,
TH2 or TL2 should not be read from or written to. Under these conditions, the Timer is
incremented every state time, and the results of a read or write may not be accurate. The
RCAP2 registers may be read but should not be written to, because a write might overlap
a reload and cause write and/or reload errors. The timer should be turned off (clear TR2)
before accessing the Timer 2 or RCAP2 registers.
Programmable Clock Out
A 50% duty cycle clock can be programmed to come out on P1.0. This pin,
besides being a regular I/O pin, has two alternate functions. It can be programmed to
input the external clock for Timer/Counter 2 or to output a 50% duty cycle clock ranging
from 61 Hz to 4 MHz at a 16 MHz operating frequency.
To configure the Timer/Counter 2 as a clock generator, bit C/T2 (T2CON.1) must
be cleared and bit T2OE (T2MOD.1) must be set. Bit TR2 (T2CON.2) starts and stops the
timer.
UART : The UART in the AT89C52 operates the same way as the UART in the
AT89C51.
Dept. of E.E.E. |R.Y.M.E.C Bellary. 41
8/3/2019 Automatic Power Saving Energy Meter
42/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Interrupts
The AT89C52 has a total of six interrupt vectors: two external interrupts (INT0
and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. Each
of these interrupt sources can be individually enabled or disabled by setting or clearing a
bit in Special Function Register IE. IE also contains a global disable bit, EA, which
disables all interrupts at once.
Note that Table shows that bit position IE.6 is unimplemented. In the A T89 C5 1,
bit position IE.5 is also unimplemented. User software should not write 1s to these bit
positions, since they may be used in future AT89 products.
Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register
T2CON. Neither of these flags is cleared by hardware when the service routine is
vectored to. In fact, the service routine may have to determine whether it was TF2 or
EXF2 that generated the interrupt, and that bit will have to be cleared in software.
Oscillator Characteristics
XTAL1 and XTAL2 are the input and output, respectively, of an inverting
amplifier that can be configured for use as an on-chip oscillator, as shown in Figure 7.
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.
There are no requirements 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.
Idle Mode
In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain
active. The mode is invoked by software. The content of the on-chip RAM and all the
special functions registers remain unchanged during this mode. The idle mode can be
terminated by any enabled interrupt or by a hardware reset.
Note that when idle mode is terminated by a hardware reset, the device normally
resumes program execution from where it left off, up to two machine cycles before theinternal reset algorithm takes control. On-chip hardware inhibits access to internal RAM
Dept. of E.E.E. |R.Y.M.E.C Bellary. 42
8/3/2019 Automatic Power Saving Energy Meter
43/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
in this event, but access to the port pins is not inhibited. To eliminate the possibility of an
unexpected write to a port pin when idle mode is terminated
By a reset, the instruction following the one that invokes idle mode should not write to a
port pin or to external memory.
Power-down Mode
In the power-down mode, the oscillator is stopped, and the instruction that invokes
power-down is the last instruction executed. The on-chip RAM and Special Function
Registers retain their values until the power-down mode is terminated. The only exit from
power-down is a hardware reset. Reset redefines the SFRs but does not change the on-
chip RAM. The reset should not be activated before VCC is restored to its normal
operating level and must be held active long enough to allow the oscillator to restart and
stabilize.
Programming the Flash
The AT89C52 is normally shipped with the on-chip Flash memory array in the
erased state (that is, contents = FFH) and ready to be programmed. The programming
interface accepts either a high-voltage (12-volt) or a low-voltage (VCC) program enable
signal. The Low-voltage programming mode provides a convenient way to program theAT89C52 inside the users system, while the high-voltage programming mode is
compatible with conventional third party Flash or EPROM programmers.
The AT89C52 is shipped with either the high-voltage or low-voltage
programming mode enabled. The AT89C52 code memory array is programmed byte-by-
byte in either programming mode. To program any nonblank byte in the on-chip Flash
Memory, the entire memory must be erased using the
Chip Erase Mode.
Programming Algorithm Before programming the AT89C52, the address, data
and control signals should be set up according to the Flash programming mode table and
Figure 9 and Figure 10. To program the AT89C52, take the following steps.
1. Input the desired memory location on the address lines.
2. Input the appropriate data byte on the data lines.
3. Activate the correct combination of control signals.4. Raise EA/VPP to 12V for the high-voltage programming mode.
Dept. of E.E.E. |R.Y.M.E.C Bellary. 43
8/3/2019 Automatic Power Saving Energy Meter
44/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-
write cycle is
self-timed and typically takes no more than 1.5 ms.
Repeat steps 1 through 5, changing the address and data for the entire array or
until the end of the object file is reached.
Data Polling
The AT89C52 features Data Polling to indicate the end of a write cycle. During a
write cycle, an attempted read of the last byte written will result in the complement of the
written data on PO.7. Once the write cycle has been completed, true data is valid on all
outputs, and the next cycle may begin. Data Polling may begin any time after a write
cycle has been initiated. Ready/Busy The progress of byte programming can also be
monitored by the RDY/BSY output signal. P3.4 is pulled low after ALE goes high during
programming to indicate
BUSY.
P3.4 is pulled high again when programming is done to indicate READY.
Program Verify If lock bits LB1 and LB2 have not been programmed, the programmed
code data can be read back via the address and data lines for verification. The lock bits
cannot be verified directly. Verification of the lock bits is achieved by observing that their
features are enabled.
Chip Erase
The entire Flash array is erased electrically by using the proper combination of
control signals and by holding ALE/PROG low for 10 ms. The code array is written with
all 1s. The chip erase operation must be executed before the code memory can bereprogrammed.
Reading the Signature Bytes
The signature bytes are read by the same procedure as a normal verification of
locations 030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low.
The values returned are as follows.
(030H) = 1EH indicates manufactured by Atmel
(031H) = 52H indicates 89C52
Dept. of E.E.E. |R.Y.M.E.C Bellary. 44
8/3/2019 Automatic Power Saving Energy Meter
45/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
(032H) = FFH indicates 12V programming
(032H) = 05H indicates 5V programming
Flash Programming Modes
Programming Interface
Every code byte in the Flash array can be written, and the entire array can be
erased, by using the appropriate combination of control signals. The write operation cycle
is self timed and once initiated, will automatically time itself to completion.
DC Characteristics
Absolute Maximum Ratings*
Operating Temperature.................................. -55C to +125C
Storage Temperature ..................................... -65C to +150C
Voltage on Any Pin with Respect to Ground .....................................-1.0V to +7.0V
Maximum Operating Voltage............................................ 6.6V
DC Output Current...................................................... 15.0 mA
Dept. of E.E.E. |R.Y.M.E.C Bellary. 45
8/3/2019 Automatic Power Saving Energy Meter
46/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Dept. of E.E.E. |R.Y.M.E.C Bellary. 46
Parts List of Power SupplyX1 12-0-12V Transformer 1
IC1 7805 Regulator IC 1
D1 & D2 1N4007 Rectifier Diode 2
D3 Red Indicator LED 1
R1 100 K Carbon Resistor 1
C1 1000MFD/25V
Electrolytic Capacitor 1
C2 & C3 0.1F Ceramic Capacitor 2
COMPLETE CIRCUIT DIAGRAM [MOTHER BOARD] OF 89C51
PORT 2PORT 3
8 x 2.2 Kport 0
port 1
89c51
ad7
ad6
ad5
ad4
ad3
ad2
ad1
ad0
a15
a14
a13
a12
a11
a10
a9
a8
230 AC
X1D1 & D2 IC1
+VCC
R1
D3
C1 C2 C3
+Vcc
P0.6
33
P0.5
34
P0.4
35
P0.3
36
P0.2
37
P0.1
38P0.0
39
P2.7
28
P2.6
27
P2.5
26
P2.4
25P2.3
24
P2.2
23
P2.1
22
P2.0
21 1
P1.7
8
P1.6
7
P1.5
6
P1.4
5
P1.3
4
P1.2
3
P1.1
2
P1.0
1 1
19 XTAL1
18 XTAL2
30 pF
12 MHz
30 pF
vss
20
40
vcc
rd
wr
t1
t0
int1
int0
txd
rxd
17
P3.7
16
P3.6
15
P3.5
14
P3.4
13
P3.3
12
P3.2
11
P3.1
10
P3.0
29
PSEN
30 ALE
31 EA
9 RST
+VCC
10 MFD/63V
20KRESET
SWITCH
8/3/2019 Automatic Power Saving Energy Meter
47/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
CIRCUIT DESCRIPTION
The mother board of 89C51 has following sections: Power Supply, 89C51 IC,
Oscillator, Reset Switch & I/O ports. Let us see these sections in detail.
POWER SUPPLY:
This section provides the clean and harmonic free power to IC to function
properly. The output of the full wave rectifier section, which is built using two rectifier
diodes, is given to filter capacitor. The electrolytic capacitor C1 filters the pulsating dc
into pure dc and given to Vin pin-1 of regulator IC 7805.This three terminal IC regulates
the rectified pulsating dc to constant +5 volts. C2 & C3 provides ground path to harmonic
signals present in the inputted voltage. The Vout pin-3 gives constant, regulated and
spikes free +5 volts to the mother board.
The allocation of the pins of the 89C51 follows a U-shape distribution. The top
left hand corner is Pin 1 and down to bottom left hand corner is Pin 20. And the bottom
right hand corner is Pin 21 and up to the top right hand corner is Pin 40. The Supply
Voltage pin Vcc is 40 and ground pin Vss is 20.
OSCILLATOR:
If the CPU is the brain of the system then the oscillator, or clock, is the heartbeat.
It provides the critical timing functions for the rest of the chip. The greatest timing
accuracy is achieved with a crystal or ceramic resonator. For crystals of 2.0 to 12.0 MHz,
the recommended capacitor values should be in the range of 15 to 33pf2.
Across the oscillator input pins 18 & 19 a crystal x1 of 4.7 MHz to 20 MHz value
can be connected. The two ceramic disc type capacitors of value 30pF are connected
across crystal and ground, stabilizes the oscillation frequency generated by crystal.
I/O PORTS:
There are a total of 32 i/o pins available on this chip. The amazing part about
these ports is that they can be programmed to be either input or output ports, even "on the
fly" during operation! Each pin can source 20 mA (max) so it can directly drive an LED.
They can also sink a maximum of 25 Ma current.
Dept. of E.E.E. |R.Y.M.E.C Bellary. 47
8/3/2019 Automatic Power Saving Energy Meter
48/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
Some pins for these I/O ports are multiplexed with an alternate function for the
peripheral features on the device. In general, when a peripheral is enabled, that pin may
not be used as a general purpose I/O pin. The alternate function of each pin is not
discussed here, as port accessing circuit takes care of that.
This 89C51 IC has four I/O ports and is discussed in detail:
P0.0 TO P0.7
PORT0 is an 8-bit [pins 32 to 39] open drain bi-directional I/O port. As an output
port, each pin can sink eight TTL inputs and configured to be multiplexed low order
address/data bus then has internal pull ups. External pull ups are required during program
verification.
P1.0 TO P1.7
PORT1 is an 8-bit wide [pins 1 to 8], bi-directional port with internal pull ups.
P1.0 and P1.1 can be configured to be the timer/counter 2 external count input and the
timer/counter 2 trigger input respectively.
P2.0 TO P2.7
PORT2 is an 8-bit wide [pins 21 to 28], bi-directional port with internal pull ups.
The PORT2 output buffers can sink/source four TTL inputs. It receives the high-order
address bits and some control signals during Flash programming and verification.
P3.0 TO P3.7
PORT3 is an 8-bit wide [pins 10 to 17], bi-directional port with internal pull ups.
The Port3 output buffers can sink/source four TTL inputs. It also receives some control
signals for Flash programming and verification.
PSEN
Program Store Enable [Pin 29] is the read strobe to external program memory.
ALE
Address Latch Enable [Pin 30] is an output pulse for latching the low byte of the
address during accesses to external memory.
EA
Dept. of E.E.E. |R.Y.M.E.C Bellary. 48
8/3/2019 Automatic Power Saving Energy Meter
49/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
External Access Enable [Pin 31] must be strapped to GND in order to enable the
device to fetch code from external program memory locations starting at 0000H upto
FFFFH.
RST
Reset input [Pin 9] must be made high for two machine cycles to resets the
devices oscillator. The potential difference is created using 10MFD/63V electrolytic
capacitor and 20KOhm resistor with a reset switch.
LOGIC STAGE WITH DRIVER
This is the decision making stage and plays vital role in taking the right decision
after comparing the two reference signals. This decision making is done with the help of
Logic gates, which are known as building blocks of Digital Electronics. This stage not
only takes the decision, also switches ON the Beeper or Tone Generator to alert the
consumer when the total power consumption cross 90% of the designation of Power Card,
he has inserted.
Before going in details of this stage, let us see the basics of the Digital
Electronics.
LOGIC GATES
The British Standard (BS) and American Standard (MIL / ANSI) symbols for
some basic logic gates are shown in fig 1. It is fair to say that, in the UK, the MIL / ANSI
standard has overwhelming support and a very few manufacturers adhere to the
recommended BS symbols. We shall now briefly consider the action of each of the basic
logic gates depicted in fig 1.
BUFFERS: Buffers do not affect the logical state of a digital signal (i.e. a logic 1 input
results in a logic 1 output whereas logic 0 input results in a logic 0 output). Buffers are
normally used to provide extra current drive at the output but can also be used to
regularize the logic present at an interface.
Dept. of E.E.E. |R.Y.M.E.C Bellary. 49
8/3/2019 Automatic Power Saving Energy Meter
50/74
June 15, 2011 [AUTOMATIC POWER SAVING ENERGYMETER]
INVERTERS: Inverters are used to complement the logical state (i.e. logic 1 input results
in a logic 0 output and vice versa). Inverters also provide