Sie sind auf Seite 1von 57

CHAPTER-1 INTRODUCTION

Every month we can see a person standing in front of our house from Electricity board or water Board whose duty is to read the energy meter/water meter and handover the bills (electric or water) to the owner of that house . This is nothing but meter reading. According to that reading we have to pay the bills. The main drawback of this system is that person has to go area by area and he has to read the meter of every house and handover the bills. The Electricity board and Water authority has to give privileges for these people to do their duty monthly. The thing is Government will not appoint any particular persons for this duty. The people working in these boards will go on a particular day and do their duty leaving all their pending works. Due to this, their work will be delayed and this is great loss for government. To overcome this drawback we have come up with an idea and thisidea will help the government and it will save the time of the employees working in these boards. The present system of energy billing is error prone and also time and labor consuming. Errors get introduced at every stage of energy billing like errors with electro-mechanical meters, human errors while noting down the meter reading, and errors while processing the paid bills and the due bills. There are many cases where the bill is paid and then is shownas a due amount in the next bill. There is no proper way to know the consumers maximum demand, usage details, losses in the lines, and power theft. The major drawback of a post paid system is that there is no control of usage from the consumers side. There is a lot of wastage of power due to the consumers lack of planning of electrical consumption in an efficient way. Since the supply of power is limited, as a responsible citizen, there is a need to utilize electricity in a better and efficient way. The distribution company has to receive huge amounts in the form of pending bills, which results in substantial revenue losses and also hurdles to modernization because of lack of funds. There are many cases where the bill is paid and then is shownas a due amount in the next bill. There is no proper way to know the consumers maximum demand, usage details, losses in the lines, and power theft. Since the supply of power is limited, as a responsible citizen, there is a need to utilize electricity in a better and efficient way.

JOGINPALLY B.R. ENGINEERING COLLEGE

The distribution company has to receive huge amounts in the form of pending bills, which results in substantial revenue losses and also hurdles to modernization because of lack of funds. Electricity board or water Board whose duty is to read the energy meter/water meter and handover the bills (electric or water) to the owner of that house.The Electricity board and Water authority has to give privileges for these people to do their duty monthly. 1.1What is meant by energy meter? An electricity meter or energy meter is a device that measures the amount of electric energy consumed by aresidence, business, or an electrically powered device.Electricity meters are typically calibrated in billing units, the most common one being the kilowatt hour [kWh]. Periodic readings of electric meters establish billing cycles and energy used during a cycle. 1.2 What is meant by prepaid energy meter? An electricity meter provides an interface between the utility and the customer. Successfully implemented, our product will benefit the end customer as well as the electric utility to the electricity board. It is compatibility with Measure electricity consumption accurately, Display real time account balance, Communicate with the utility of the customer and electricity board, Warn the user of low account balance by flashing an LED, Cut power off when there is zero credit on the account. Financial dealing through cash and cheques are now slowly paving way for transactions using smart cards and ATM (Automatic Teller Machine, also expanded as Any Time Money) machines. Smart card, of the size of a credit card, has a small micro-controller and memory; and it interacts with the smart card reader! ATM machine and acts as an electronic wallet. Smart card technology has the capability of ushering in a cashless society. From a technological point of view, the prepayment system consists of three welldifferentiated components. The first is a service meter installed at the unit where energywill be consumed, such as a household dwelling or a store. In general, these meters are of the twogang type, and consist of a users interface unit and a current measuring set.The interface unit is a device installed inside the building, which allows the user tointeract with the meter. This mechanism essentially requires the users to pay for the electricity before itsconsumption. In this way, consumers hold credit and then use the electricity until thecredit is exhausted.If the available credit is exhausted then the supply of electricity is cutoff by a relay.

JOGINPALLY B.R. ENGINEERING COLLEGE

CHAPTER-2 GENERAL THEORY

2.1 Introduction to Embedded System: An embedded system can be defined as a computing device that does a specific focused job. Appliances such as the air-conditioner, VCD player, DVD player, printer, fax machine, mobile phone etc. are examples of embedded systems. Each of these appliances will have a processor and special hardware to meet the specific requirement of the application along with the embedded software that is executed by the processor for meeting that specific requirement.

2.2 Micro-Controller: A microcontroller (sometimes abbreviated Cor MCU) is a small computer on a single integrated circuit containing a processor core, memory, and programmable

input/outputperipherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications. Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, remote controls, office machines, appliances, power tools, toys and other embedded systems. By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems. The AT89S52 is a low-power, high-performance CMOS 8-bit

microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels high -density nonvolatile memory technology and is compatible with the industry- standard 8051 instruction set and pin out.

JOGINPALLY B.R. ENGINEERING COLLEGE

2.2.1Architecture of Micro Controller:

Fig2.1: Architecture of Microcontroller AT89S52 2.2.2Basic Registers:

2.2.2.1The Accumulator: The Accumulator, as its name suggests, is used as a general register to accumulate the results of a large number of instructions. It can hold an 8-bit (1-byte) value and is the most versatile register the 89c51 has due to the sheer number of instructions that make use of the accumulator. More than half of the 89c51s 255 instructions manipulate or use the accumulator in some way.

JOGINPALLY B.R. ENGINEERING COLLEGE

2.2.2.2The "R" registers: The "R" registers are a set of eight registers that are named R0, R1, etc. up to and including R7.These registers are used as auxillary registers in many operations. To continue with the above example, perhaps you are adding 10 and 20. The original number 10 may be stored in the Accumulator whereas the value 20 may be stored in, say, register R4. To process the addition you would execute the command.

2.2.2.3 The "B" Register: The "B" register is very similar to the Accumulator in the sense that it may hold an 8-bit (1-byte) value. The "B" register is only used by two 89c51 instructions: MUL AB and DIV AB. Thus, if you want to quickly and easily multiply or divide A by another number, you may store the other number in "B" and make use of these two instructions.Aside from the MUL and DIV instructions, the "B" register is often used as yet another temporary storage register much like a ninth "R" register.

2.2.2.4 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. User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0.

2.2.3 Structure of microcontroller: A microcontroller (sometimes abbreviated C, or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. The microcontroller is consisting of four ports, timers, counters, interrupts, serial ports, RAM, EPROM(flash), processor and external input/output ports. And the enable, ALE, program status enable pins are also part of microcontroller.

JOGINPALLY B.R. ENGINEERING COLLEGE

Fig 2.2: Structure of Microcontroller AT89S52

2.2.4 Timers: The 8052 has two timers: Timer 0, Timer 1and Timer 2. They can be used either as timers to generate a time delay or as counters to count events happening outside the microcontroller.Three timers are 16-bit wide. Since the 8052 has an 8-bit architecture, each 16bit timer is accessed as two separate registers of low byte and high byte. The timers 1 and 2 functions are same as in 8051.Lower byte register of Timer 0 is TL0 and higher byte is TH0. Similarly lower byte register of Timer1 is TL1 and higher byte register is TH1.

2.2.4.1 TMOD (timer mode) register: Both timers 0 and 1 use the same register TMOD to set the various operation modes.TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper 4 bits for Timer 1. In each case, the lower 2 bits are used to set the timer mode and the upper 2 bits to specify the operation.

JOGINPALLY B.R. ENGINEERING COLLEGE

(MSB) GATE C/T M1 M0 GATE C/T M1

(LSB) M0

TIMER 1 GATE:

TIMER 0 Table 2.3: TMOD register

Every timer has a means of starting and stopping. Some timers do this by software, some by hardware and some have both software and hardware controls. The timers in the 8051 have both. The start and stop of the timer are controlled by the way of software by the TR (timer start) bits TR0 and TR1. These instructions start and stop the timers as long as GATE=0 in the TMOD register. The hardware way of starting and stopping the timer by an external source is achieved by making GATE=1 in the TMOD register.

C/T: Timer or counter selected. Cleared for timer operation and set for counter operation. M1-Mode bit 1 M0-Mode bit 0 M1 M0 Mode Operating Mode

13-bit timer mode.8-bit timer/counter THx with TLx as 5-bit prescaler

16-bit timer mode.16-bit timer/counters THx and TLx are cascaded

8-bit auto reload timer/counter. THxholds a value that is to be reloaded into TLx each time it overflows

Split timer mode Table 2.4 : TMOD register mode

JOGINPALLY B.R. ENGINEERING COLLEGE

The mode used here to generate a time delay is MODE 2.This mode 2 is an 8-bit timer and therefore it allows only values of 00H to FFH to be loaded into the timers register TH. After TH is loaded with the 8-bit value, the 8051 give a copy of it to TL. When the timer starts, it starts to count up by incrementing the TL register. It counts up until it reaches its limit of FFH. When it rolls over from FFH to 00H, it sets high the TF (timer flag). If Timer 0 is used, TF0 goes high and if Timer 1 is used, TF1 goes high. When the TL register rolls from FFH to 0 and TF is set to 1, TL is reloaded automatically with the original value kept by the TH register.

2.2.4.2Timer 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 (shown in Table 2.7). 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, as shown in Table 2.8. Timer 2 consists of two 8-bit 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.

Table 2.5: Timer 2 mode operation 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. JOGINPALLY B.R. ENGINEERING COLLEGE 8

Timer 2 Registers Control and status bits are contained in registers T2CON (shown in Table 2.7) and T2MOD (shown in Table 2.8) for Timer 2. The register pair (RCAP2H, RCAP2L) are the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit autoreload mode.

2.2.4.3Timer 2 overflow flag: 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.

2.2.4.4Timer 2 external flag: 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).

2.2.4.5 Receive clock enable: 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.

2.2.4.6Transmit clock enable: Transmit clock enablewhen 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.

2.2.4.7Timer 2 external enable: 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.

JOGINPALLY B.R. ENGINEERING COLLEGE

2.2.4.8 Start/Stop control: Start/Stop control for Timer 2. TR2 = 1 starts the timer.

2.2.4.9 Counter/Timer: Timer or counter select for Timer 2. C/T2 = 0 for timer function. C/T2 = 1 for external event counter (falling edge triggered).

2.2.4.10 Capture/Reload: 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.

2.2.5 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.

2.2.6 The Data Pointer (DPTR): The Data Pointer (DPTR) is the 89C51s only user-accessable 16-bit (2-byte) register. The Accumulator, "R" registers, and "B" register are all 1-byte values.DPTR, as the name suggests, is used to point to data. It is used by a number of commands which allow the 89C51 to access external memory. When the 89c51 accesses external memory it will access external memory at the address indicated by DPTR.While DPTR is most often used to point to data in external memory, many programmers often take advantage of the fact that its the only true 16-register available. It is often used to store 2-byte values which have nothing to do with memory locations.

2.2.7The Program Counter (PC): The Program Counter (PC) is a 2-byte address which tells the 89c51 where the next instruction to execute is found in memory. When the 89c51 is initialized PC always starts at 0000h and is incremented each time an instruction is executed. It is important to note that PC JOGINPALLY B.R. ENGINEERING COLLEGE 10

isnt always incremented by one. Since some instructions require 2 or 3 bytes the PC will be incremented by 2 or 3 in these cases.

2.2.8 The Stack Pointer (SP): The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit (1-byte) value. The Stack Pointer is used to indicate where the next value to be removed from the stack should be taken from. When you push a value onto the stack, the 89c51 first increments the value of SP and then stores the value at the resulting memory location. When you pop a value off the stack, the 89c51 returns the value from the memory location indicated by SP, and then decrements the value of SP. 2.2.9 Input/output (I/O) port: All 8051 microcontrollers have 4 I/O ports, each consisting of 8 bits which can be configured as inputs or outputs. This means that the user has on disposal in total of 32 input/output lines connecting the microcontroller to peripheral devices.A logic state on a pin determines whether it is configured as input or output: 0=output, 1=input. If a pin on the microcontroller needs to be configured as output, then a logic zero (0) should be applied to the appropriate bit on I/O port. In this way, a voltage level on the appropriate pin will be 0.

2.3 Pin Diagram of Microcontroller AT89S52:

Fig 2.6: Pin Diagram of Microcontroller AT89S52 JOGINPALLY B.R. ENGINEERING COLLEGE 11

2.4Pin description: Pins 1-8: Each of these pins can be configured as input or output. These pins are subset of Port1. 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. Port 1 also receives the low-order address bytes during Flash programming and verification. Pin 9 RST: Logical one on this pin stops microcontrollers operating and erases the contents of most registers. By applying logical zero to this pin, the program starts execution from the beginning. In other words, a positive voltage pulse on this pin resets the microcontroller.

Pins 10-17: Similar to port 1, each of these pins can serve as universal input or output. These pins come under port 3. Besides, all of them have alternative functions.

Port 3: Even though all pins on this port can be used as universal I/O port, Since each of these functions use inputs, then the appropriate pins have to be configured like that. In other words, a logical one (1) must be written to the appropriate bit in the P3 register. From hardwares perspective, this port is also similar to P0, with the difference that its outputs have a pull-up resistor embedded. 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.

Pin 10: RXD Serial asynchronous communication input or Serial synchronous communication output. JOGINPALLY B.R. ENGINEERING COLLEGE 12

Pin 11: TXD Serial asynchronous communication output or Serial synchronous communication clock output.

Pin 12: INT0 Interrupt 0 inputs.

Pin 13: INT1 Interrupt 1 input.

Pin 14: T0 Counter 0 clock input.

Pin 15: T1 Counter 1 clock input.

Pin 16: WR Signal for writing to external (additional) RAM.

Pin 17: RD Signal for reading from external RAM.

Pin 18, 19:X2, X1: Internal oscillator input and output. A quartz crystal which determines operating frequency is usually connected to these pins. Instead of quartz crystal, the miniature ceramics resonators can be also used for frequency stabilization. Later versions of the microcontrollers operate at a frequency of 0 Hz up to over 50 Hz. XTAL1: Input to the inverting oscillator amplifier and input to the internal clock operating circuit. JOGINPALLY B.R. ENGINEERING COLLEGE 13

XTAL2: Output from the inverting oscillator amplifier. Oscillator Characteristics: XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator. 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 2. There are no requirements on the duty cycle of the external clock signal,but minimum and maximum voltage high and low time specifications must be observed.

Pin 20: GND Signal Ground.

Pins 21-28 port 2: If there is no intention to use external memory then these port pins are configured as universal inputs/outputs.These pins are Port 2. In case external memory is used then the higher address byte, i.e. addresses A8-A15 will appear on this port. It is important to know that even memory with capacity of 64Kb is not used ( i.e. note all bits on port are used for memory addressing) the rest of bits are not available as inputs or outputs.

Pin 29: PSEN Program Store Enable is the read strobe to external program memory. When the AT89C51 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. If external ROM is used for storing program then it has a logic-0 value every time the microcontroller reads a byte from memory.

Pin 30: ALE Prior to each reading from external memory, the microcontroller will set the lower address byte (A0-A7) on P0 and immediately after that activates the output ALE. Upon receiving JOGINPALLY B.R. ENGINEERING COLLEGE 14

signal from the ALE pin, the external register (74HCT373 or 74HCT375 circuit is usually embedded) memorizes the state of P0 and uses it as an address for memory chip. In the second part of the microcontrollers machine cycle, a signal on this pin stops being emitted and P0 is used now for data transmission (Data Bus). Address Latch Enable 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 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 ALEdisable bit has no effect if the microcontroller is in external execution mode.

Pin 31: EA/VPP External Access Enable 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. By applying logic zero to this pin, P2 and P3 are used for data and address transmission with no regard to whether there is internal memory or not. That means that even there is a program written to the microcontroller, it will not be executed. The program written to external ROM will be used instead. Otherwise, by applying logic one to the EA pin, the microcontroller will use both memories, first internal and afterwards external (if it exists), up to end of address space.

Pins 32-39 PORT 0: Similar to port 2, if external memory is not used, these pins can be used as universal inputs or outputs.These pins are of Port 0 configuration. Otherwise, P0 is configured as address output (A0-A7) when the ALE pin is at high level (1) and as data output (Data Bus), when logic zero (0) is applied to the ALE pin.

JOGINPALLY B.R. ENGINEERING COLLEGE

15

Pin 40: VCC: Power supply of +5V(volts) is given to the circuit through this pin.

2.5Regulated Power supply: The microcontroller and other devices get power supply from AC to Dc adapter through voltage regulator. The adapter output voltage will be 12V DC none regulated. The 7805 voltage regulators are used to convert 12 V to 5VDC. 230V AC50Hz D.C Output

Step down transformer

Bridge Rectifier

Filter

Regulator

Fig 2.7: Power supply block diagram

Fig 2.8: Circuit diagram of power supply

2.5.1 Transformer: Usually, DC voltages are required to operate various electronic equipment and these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus, the ac input available at the mains supply i.e., 230V is to be brought down to the required voltage level. This JOGINPALLY B.R. ENGINEERING COLLEGE 16

is done by a transformer. Thus, a step down transformer is employed to decrease the voltage to a required level.

2.5.2 Rectifier: The output from the transformer is fed to the rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full wave rectification. We use bridge rectifier to get high efficiency of nearly 80% to 85%.

2.5.3 Filter: Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage.

2.5.4 Voltage regulator& its features: As the name itself implies, it regulates the input applied to it. A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. In this project, power supply of 5V and 12V are required. In order to obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first number 78 represents positive supply and the numbers 05, 12 represent the required output voltage levels.

2.5.4.1 Features: Output Current up to 1A. Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V. Thermal Overload Protection. Short Circuit Protection. Output Transistor Safe Operating Area Protection.

JOGINPALLY B.R. ENGINEERING COLLEGE

17

CHAPTER-3 HARDWARE DESCRIPTION

3.1 Block diagram of Energy embedded meter:


ThisBlock diagram mainly Consistof Powersupply,MicrocontrollerAT89S52,IR Transmitter, IR Receiver,Liquid crystal display(LCD), Indicator LED(Light Emitting Diode), Relay, driver circuit and bulb. This gives the idea about the inter connection of the system.The block diagram shown below

POWER SUPPLY

LCD

IR TX

A T 8 9 S 5 2 U L N

INDICATOR LED

IR RX

RELAY

BULB

Fig 3.1:Block diagram of Energy embedded meter

JOGINPALLY B.R. ENGINEERING COLLEGE

18

3.2 Overview of block diagram: We plan to make accurate power measurements, interface an LCD display as well as a keypad with the central microcontroller unit and implement a transceiver module in our system. An electricity meter provides an interface between the utility and the customer. The device will show the remaining balance so that the user knows how much he has consumed and can plan ahead to not overuse the budget and know when he needs to refill the account. The display will also show the current electricity rate. Since electricity rates vary throughout the day, the user can cut down on consumption when the rate is high. The utility companies will have a better idea of electricity demand. This will help them to plan ahead.The utility companies would be able to collect the expenses from customers in advance,so they will no longer have to deal with late payments or non-paying customers. Since the meter will send daily/hourly consumption data to the utility company, it will help reduce electricity theft. We would like our meter to be able to do the following things: 1. Measure electricity consumption accurately. 2. Display real time account balance. 3. Communicate with the utility company. 4. Warn the user of low account balance by flashing an LED 5. Cut power off when there is zero credit on the account. The microcontroller which is used to operate over all the circuit gets to know that how much amount of power consumption is used. The driver circuit acting as a relay acts as a switch between the power supply and the energy meter. And the bulb which is connected to the energy meter gets to knew that how much power is consumed in units through the LCD. And the display shows that in how many units the power is used. And the Led indicator gives the warn that the power is used to be reducing and indicates that should be recharged.And the coin box is interfaced with the energy meter and the bulb.Therefore, the whole project is designed on the PCB boards. This can be used in the industries, factories and homes etc. An electric meter or Energy meter is a device that measures theamount of electrical energy supplied to or produced by a residence, business ormachine.The most common type is a kilowatt hour meter. When used in electricityretailing, the utilities record the values measured by these meters to generate a voice for the electricity. JOGINPALLY B.R. ENGINEERING COLLEGE 19

3.3 Block diagram Description:

3.3.1 Power supply: The overall power supply from the alternating current(AC) is of 230V(volts). The transformer which is a part of power supply used to convert into 12V(volts) Direct current(DC). And the regulator will convert to 5V DC, the power will pass to the whole circuit.

3.3.2 Microcontroller AT89S52 The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels high -density nonvolatile memory technology and is compatible with the industry- standard 80C51 instruction set and pin out.

3.3.3 IR Transmitter (TX):

Fig 3.4: IR Transmitter TSAL6200 is a high efficiency infrared emitting diode in GaAlAs on GaAs technology, molded in clear, bluegrey tinted plastic packages. In comparison with the standard GaAs on GaAs technology these emitters achieve more than 100 % radiant power improvement at a similar wavelength. The forward voltages at low current and at high pulse current roughly correspond to the low values of the standard technology. Therefore these emitters are ideally suitable as high performance replacements of standard emitters. 3.3.4 IR Receiver (RX): The TSOP17.. Series are miniaturized receivers for infrared remote control systems. PIN diode and preamplifier are assembled on lead frame, the epoxy package is designed as IR filter.

JOGINPALLY B.R. ENGINEERING COLLEGE

20

Fig 3.5: IR Receiver The demodulated output signal can directly be decoded by a microprocessor. TSOP17XX is the standard IR remote control receiver series, supporting all major transmission codes.

3.3.5 Liquid Crystal Display (LCD): The primary function of the display will be to show the real time account balance along with the present rate of electricity. It will also be used for recharging the account.The LCD along with the keypad will provide an interface between the meter and the user or in other words, the utility and the user.

3.3.6 Indicator led: A light-emitting diode (LED) is a semiconductor light source.LEDs are used as indicator lamps in many devices and are increasingly used for other lighting.LEDs emitted low-intensity red light, but modern versions are available across the visible, ultraviolet, and infrared wavelengths, with very high brightness.When a light-emitting diode is switched on, electrons are able to recombine with holes within the device, releasing energy in the form of photons. This effect is calledelectroluminescence and the color of the light.LEDs powerful enough for room lighting are relatively expensive and require more precise current and heat management than compact fluorescent lampsources of comparable output.

3.3.7 Relay: A relay is an electrically operated switch. Many relays use anelectromagnet to operate a switching mechanism mechanically, but other operating principles are also used. Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits, repeating the signal coming

JOGINPALLY B.R. ENGINEERING COLLEGE

21

in from one circuit and re-transmitting it to another. Relays were used extensively in telephone exchanges and early computers to perform logical operations.

3.3.8 ULN:

Fig 3.6 ULN Pin overview diagram The ULN is a monolithic high voltage and high current darlington transistor arrays. It consists of seven NPN Darlington pairs that feature high-voltage outputs with common-cathode clamp diode for switching inductive loads. It acts as a current amplifier circuit used to run a high voltage/current peripheral circuits.When input terminal is high it offers low impedance path other wide it offers a high impedance. Any two inputs and output are used for our purpose. This ULN is used as relay.

3.3.9 Bulb: A 0W (Watt) bulb is used for this system. The bulb glows through the energy meter when the coin is dropped in box to get the power.

3.4 Requirements: The meter should be sturdy and resistant to normal wear and tear. Power measurements have to be accurate. It goes without saying that accurate power measurement is at the core of any electricity meter.The time lag between power measurement and display should be of the order of a few seconds. The keypad should have a lifetime as long as the meter itself. The LCD should have a lifetime of at least 10 years. The transceiver should be able to able to provide glitch-free communication. This will help prevent any discrepancies in the event of a transaction. JOGINPALLY B.R. ENGINEERING COLLEGE 22

The process of recharging ones account should be seamless. There shouldnt be a disruption in service during the process of recharging.

3.5 Circuit diagram of energy embedded meter:

Fig 3.7: Circuit diagram of energy embedded meter

3.5.1 Circuit diagram explanation: A scheme of Electricity billing system called prepaid energy meter with coin box 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 have a coin box stored inside it using a MC program. The coin box is available at various ranges (i.e. Re 1, Rs 2, Rs 5 etc).In our project we have given the name for coin box as prepaid card. When the consumer insert a coin into the box which is connected in prepaid energy meter with coin boxkit.Suppose if a consumer insert a coin of Re 1/- amount through the coin box so that prepaid energy meter kit will be activated. According to the power consumption the amount will be reduced. When the amount is over, the relay (i.e.ULN) will automatically shutdown the whole system. JOGINPALLY B.R. ENGINEERING COLLEGE 23

CHAPTER-4 SOFTWARE DESCRIPTION

4.1 Introduction to the embedded c: Embedded C for programming the application software to the microcontroller.The embedded C is an extension of the conventional C.Embedded C is Controller or target specific. Embedded C allows direct communication with memory.

4.2Keil compiler setup: Procedure Steps: Step-1: Install Keil MicroVision-2 in your PC, Then after Click on that Keil UVision-2 icon. After opening the window go to toolbar and select Project Tab then close previous project.

JOGINPALLY B.R. ENGINEERING COLLEGE

24

Step-2: Next select New Project from Project Tab.

JOGINPALLY B.R. ENGINEERING COLLEGE

25

Step-3: Then it will open Create New Project window. Select the path where you want to save project and edit project name.

JOGINPALLY B.R. ENGINEERING COLLEGE

26

Step-4: Next it opens Select Device for Target window, It shows list of companies and here you can select the device manufacturer company.

JOGINPALLY B.R. ENGINEERING COLLEGE

27

Step-5: For an example, for your project purpose you can select the chip as 89C51/52 from Atmel Group. Next Click OK Button, it appears empty window here you can observe left side a small window i.e, Project Window. Next create a new file.

JOGINPALLY B.R. ENGINEERING COLLEGE

28

Step-6: From the Main tool bar Menu select File Tab and go to New, then it will open a window, there you can edit the program.

JOGINPALLY B.R. ENGINEERING COLLEGE

29

Step-7: Here you can edit the program as which language will you prefer either Assembly or C.

JOGINPALLY B.R. ENGINEERING COLLEGE

30

Step-8: After editing the program save the file with extension as .c or .asm, if you write a program in Assembly Language save as .asm or if you write a pro gram in C Language save as .c in the selected path. Take an example and save the file as test.c.

JOGINPALLY B.R. ENGINEERING COLLEGE

31

Step-9: Then after saving the file, compile the program. For compilation go to project window select source group and right click on that and go to Add files to Group.

JOGINPALLY B.R. ENGINEERING COLLEGE

32

Step-9: Here it will ask which file has to add. For an example here you can add test.c as you saved before.

JOGINPALLY B.R. ENGINEERING COLLEGE

33

Step-9: After adding the file, again go to Project Window and right click on your c file then select Build target for compilation. If there is any Errors or Warnings in your program you can check in Output Window that is shown bottom of the Keil window.

JOGINPALLY B.R. ENGINEERING COLLEGE

34

Step-10: Here in this step you can observe the output window for errors and warnings.

JOGINPALLY B.R. ENGINEERING COLLEGE

35

Step-11: If you make any mistake in your program you can check in this slide for which error and where the error is by clicking on that error.

JOGINPALLY B.R. ENGINEERING COLLEGE

36

Step-12: After compilation then next go to Debug Session. In Tool Bar menu go to Debug tab and select Start/Stop Debug Session.

JOGINPALLY B.R. ENGINEERING COLLEGE

37

Step-13: Here a simple program for Leds Blinking. LEDS are connected to PORT -1. You can observe the output in that port.

JOGINPALLY B.R. ENGINEERING COLLEGE

38

Step-14: To see the Ports and other Peripheral Features go to main toolbar menu and select peripherals.

JOGINPALLY B.R. ENGINEERING COLLEGE

39

Step-15: In this slide see the selected port i.e. PORT-1.

JOGINPALLY B.R. ENGINEERING COLLEGE

40

Step-16: Start to trace the program in sequence manner i.e, step by step execution and observe the output in port window.

JOGINPALLY B.R. ENGINEERING COLLEGE

41

Step-17: After completion of Debug Session Create an Hex file for Burning the Processor. Here to create a Hex file, go to project window and right click on Target next select Option for Target.

JOGINPALLY B.R. ENGINEERING COLLEGE

42

Step-18: It appears one window; here in target tab modify the crystal frequency as you connected to your microcontroller.

JOGINPALLY B.R. ENGINEERING COLLEGE

43

Step-19: Next go to Output tab. In that Output tab click on Create HEX File and then click OK.

JOGINPALLY B.R. ENGINEERING COLLEGE

44

Step-20: Finally Once again compile your program. The Created Hex File will appear in your path folder.

JOGINPALLY B.R. ENGINEERING COLLEGE

45

4.3Program:
/********************************/ #include<reg52.h> #include<intrins.h> #include<string.h> #define ldata P0 sbitrs=P2^6; sbit en=P2^7; sbit r=P1^1; //recharge key sbit pulses=P1^2;//decrement pulses key //sbittr=P1^2; //new card issue key

sbit relay=P2^0; unsigned char a[100],msg_report=0,i; void delays(unsigned int); void command(unsigned char); voidlcddata(unsigned char); voidlcd_init(void); void message(unsigned char,unsigned char*); voidstring_display(unsigned char*); voidwelcomemsg(void); void conv1(unsigned char); void main(void) { unsigned char c=0x00,p=0x00; lcd_init(); relay=0; welcomemsg(); command(0x01); message(0x80,"Units:"); message(0xc0,"Pulses:"); while(1) { command(0x88); conv1(c); command(0xc8); conv1(p); if(c>=1) { if(pulses==0) { while(pulses==0); p++; command(0xc8);

JOGINPALLY B.R. ENGINEERING COLLEGE

46

conv1(p); if(p==0x09) { p=0x00; c--; command(0x88); conv1(c); if(c==1) { message(0x80,"Recharge quickly"); delays(10); command(0x01); message(0x80,"Units:"); message(0xc0,"Pulses:"); } else if(c==0) { relay=0; message(0x80," Load Off "); delays(10); command(0x01); message(0x80,"Units:"); message(0xc0,"Pulses:"); } } } } if(r==1) { while(r==1); c=c+0x03; command(0x01); message(0x80,"3U recharge,L ON"); relay=1; delays(10); command(0x01); message(0x80,"Units:"); message(0xc0,"Pulses:"); } } } void delays(unsigned int ms1) { unsignedint x1,y1; for(x1=0;x1<ms1;x1++) { for(y1=0;y1<1275;y1++); } } void command(unsigned char value)

JOGINPALLY B.R. ENGINEERING COLLEGE

47

{ ldata = value; rs = 0; //rw = 0; en = 1; delays(1); en = 0; } ////////////////////////////////////////////////////////////////////////// ////// voidlcddata(unsigned char value) { ldata = value; rs = 1; //rw = 0; en = 1; delays(1); en = 0; } voidlcd_init(void) { command(0x38); command(0x80); command(0x0e); command(0x01); command(0x06); command(0x0c); } void message(unsigned char value,unsigned char *d) { unsigned char i; command(value); for(i=0;d[i]!='\0';i++) { lcddata(d[i]); delays(15); } } voidstring_display(unsigned char *ptr2) { while(*ptr2) { lcddata(*ptr2); ptr2++; } }

JOGINPALLY B.R. ENGINEERING COLLEGE

48

/**************************************/ voidwelcomemsg(void) { command(0x80); string_display(" WELCOME TO "); command(0xc0); string_display(" MICRO WARE "); delays(10); command(0x80); string_display(" Prepaid "); command(0xc0); string_display("Coin Box System "); delays(10); } //////////////////////////////////////////// void conv1(unsigned char x) { unsigned char d1,d2,t; t=x/10; d1=x%10; d2=t%10; d2=d2+0x30; lcddata(d2); d1=d1+0x30; lcddata(d1); //delays(1); } //////////////////////////////////////////

JOGINPALLY B.R. ENGINEERING COLLEGE

49

CHAPTER-5 RESULT ANALYSIS


5.1 Specifications: Components Used Power supply
Transformer Regulator

Specifications 230V AC
Step-down transformer converting 230V to 12V. Convert 12V to 5V.

Oscillator frequency Microcontroller Used IR Sensors

11.052MHz AT89S52 1. Power requirements: 3.3 to 5V DC>3 mA(may vary). 2. Communication: Single bit high/low output. 3. Dimensions: 1.27 x 0.96 x1.0 in.

Bulb AC Wires

A 0W(watt) bulb used to glow. 4 wires are needed.

Table 5.1 Specifications

5.2 Power supply off: This clip shows the entire circuit before switching on the power supply.

Fig.5.2 Power supply off The hardware kit is consisting of total components i.e. power supply, LCD, Microcontroller AT89S52, energy meter, relay, IR transmitter and Receiver. JOGINPALLY B.R. ENGINEERING COLLEGE 50

5.3 Power Supply Unit: The transformer takes 230V ac supply and steps down to the required voltage level which is rectified to dc using rectifier circuitry as shown.

Fig.5.3 Power supply unit The power supply is passed through entire circuit.

5.4 Power Supply On: Clip showing power supply being circulated among all the parts of the kit.

Fig.5.4 Power supply on When the power supply is ON state, the bulb glows and on the LCD display shows the units how much power is consumed. JOGINPALLY B.R. ENGINEERING COLLEGE 51

5.5 LCD display: 5.5.1 LCD display at initial stage:

Fig 5.5.1: LCD display at initial stage The consumer observes his power of consumption at the initial stage. The display shows units and pulses as 0 before recharge. 5.5.2 LCD display after recharge:

Fig 5.5.2: LCD display after recharge When consumer recharges his account with Re 1/- then the number of units is incremented by 3 units. 5.5.3 LCD display for indication to recharge:

Fig 5.5.3: LCD display for indication to recharge The fig 5.5.3 shows that to recharge his account quickly after expiration of his previous account. When there is only one unit left over, then it displays to recharge quickly. That is after 10thpulse the account will expire. JOGINPALLY B.R. ENGINEERING COLLEGE 52

The customer can recharge his account wirelessly from his home.The device will show the remaining balance so that the user knows how much he has consumed and can plan ahead to not overuse the budget and know when he needs to refill the account. The display will also show the current electricity rate. Since electricity rates vary throughout the day, the user can cut down on consumption when the rate is high. Since the meter will send daily/hourly consumption data to the utility company, it will help reduce electricity theft. The following features are: 1. Wireless capabilities to recharge the account from home. 2. Provision of a keypad to recharge the account from a different card every time. 3. LCD to display real time account balance and the current electricity rate. 4. LED to warn the user of low account balance. 5. Automatic shut-down feature once the account balance is zero.

JOGINPALLY B.R. ENGINEERING COLLEGE

53

ADVANTAGES & DISADVANTAGES


Advantages: 1. We can avoid errors that get introduced at every stage of energy billing like errors with electro-mechanical meters. 2. There is no need of any person going to each and every house to note the meterreading.Thus in this way the electricity board can reduce their work. 3. And there is a provision of a keypad to recharge the account from a different card every time. 4. This involves the consumer continuously in managing their electricity usage and conserve energy. 5. Since the supply of power is limited, as a responsible citizen, there is a need to utilize electricity in a better and efficient way.

Disadvantages: 1. The best energy deals on the market aren't available to prepayment meter customers. 2. They can be inconvenient because you have to go out to top up keys and smartcards. 3. Older meters need to have their prices updated manually after price rises or falls, which can take months. 4. This means you could be left paying old rates and owing a lump sum or paying too much. 5. If you aren't able to buy a top-up in time, you could find yourself with your supply switched off.

JOGINPALLY B.R. ENGINEERING COLLEGE

54

APPLICATIONS

1. It is applicable for the GSM type system. 2. It is mainly used for EB distribution system. 3. This is also applicable based on RFID technology. 4. In the technology of smart card this is used. 5. For the air-conditional system it is applicable. 6. In LPG revolution path this can be used.

JOGINPALLY B.R. ENGINEERING COLLEGE

55

CONCLUSIONS & FUTURE SCOPE


Conclusions: An attempt can be made in this work to develop a system, which when interfaced with static electronic energy meter works as a online prepaid energy meter. By this the consumers and suppliers can be benefited by using this prepaid energy meter. This system is of great advantage to the electricity department as this unit can be utilized effectively for preventing power theft, non payment of electricity bills etc. The whole process of billing can be centralized. This project work has been taken up which serves the purposes of energy monitoring and controlling by implementing prepaid system. To save money by adjusting energy use in response to price signals. Advanced electricity meters that generate consumption data enabling customers to see when they are using energy, to manage that use more efficiently. It is hoped that this work helps the electric engineers for better energy management and its utility in the distribution system for economic liability of the electric companies.

Future scope: The system can be made more user friendly by using smart card technology. Further work can be done in reading the consumed energy from energy meter wirelessly using Bluetooth technology. Prepaid energy meter is an advantageous concept for the future. It facilitates the exemption from electricity bills. Prepaid energy meter is used to prepaid the ongoing power supply of electricity to homes, offices etc. The scope of this project work is to introduce advanced technology in converting direct current (DC) voltage to alternating current (AC) voltage and introduction to prepaid energy metering concept. The energy meter used in this produces pulses according to load and this can be converted as prepaid energy meter using smart card. Now a days, energy measurement and electric energy pilferage detection has become prime importance for the state electricity department.

JOGINPALLY B.R. ENGINEERING COLLEGE

56

REFERENCES

[1]. Handbook for Electricity Metering,TenthEditionby the Edison Electric Institute. [2].The 8051 Microcontroller and Embedded Systems Using Assembly and C, Second Edition by Mazidi, MazidiandMcKinlay [3].Yelaran, S and H. Emery, 2010. Programming and Interfacing the8051 Microcontroller in C and Assembly Language, Rigel Press. [4].Shoeb, S.S and S. Sharma, 2011. Design and implementation of wireless automatic meter reading system. IJEST. [5]. www.8051projects.info [6].www.8051projects.net [7]. www.alldatasheets.com [8]. Datasheets of AT89S52, AT24C02,ULN2003

JOGINPALLY B.R. ENGINEERING COLLEGE

57