Вы находитесь на странице: 1из 86

BACHELOR OF ENGINEERING (Hons) in ELECTRICAL & ELECTRONICS ENGINEERING 3+0 in collaboration with UNIVERSITY OF BRADFORD UK INTELLIGENT POWER METER

PENG FEI

Project Supervisor: Ms. Zuraidah bt. Harith

INTI INTERNATIONAL UNIVERSITY Stage 3 BEng Project

JUNE 2011

Abstract
Nowadays, people consume electricity everyday. But electricity mostly is produced from coal which is limited on earth. The huge amount of producing coal causes deep damage on environment. Some people still does not have the awareness of saving electricity. Besides this, the common power meter is not able to display the amount of electric bill. Therefore, this project is designed to help electricity consumer directly understand how much the electricity cost them. The waste in residence is not only electricity but also the consumers money. This project consists of two parts: 60% hardware implementation and 40% software programming. The main focus of this project is to measure the power consumption from devices. The measurement system is designed to measure voltage and current from AC line. Then the value of them will be stepped down or amplified as the input of PIC microcontroller. PIC16F877A is used as the control system of this project. With the aid of this microcontroller, the program can be performed to calculate the real power consumption simply multiplying two inputs (voltage and current) together from measurement system. And according to the local tariff, the amount of electric bill will be carried out based on power consumption during certain time period. The result from the calculation will be displayed on LCD display module in order to notice the users how much power they consume and how much it will cost them. After one month, the power consumption and amount of electric bill will be reset. This Intelligent Power Meter is successfully built to meet the specifications and aims. This project provides a great opportunity to improve designers practical skills on hardware and software.

Page i

Acknowledgement
I really appreciate University of Bradford to give this precious opportunity to us so that we have the exposure to practical world. First of all, I would like to thank Ms. Zuraidah bt. Harith being the greatest supervisor to provide ideas, give guidance to solve problems on this project and keep monitoring my progress. Without her assistance, this project would not be working successfully. Next, I would like take this opportunity to thank INTI International University laboratory assistances. They tried to give all their helps to us making us feel so comfortable in the laboratory. I want to thank my friends especially Vincent Chan, Kim Siong and Chen Zijian for their kindness and helpfulness. They gave me really constructive suggestions and lend their tools to me. Finally, I like to thank my parents are always being supportive and understanding on my oversea study. I really appreciate what I am doing and being the one of this greatest family members.

Page ii

Declaration
I, Peng Fei, declare that the project is entirely my own work where due references are made. The project was completed under the supervision of Ms. Zuraidah bt.Harith. Yours faithfully,

. Peng Fei UoB No:08028913 14th June 2011

Page iii

Table of Contents
Chapter 1 Introduction ................................................................................................................... 1 1.1 Project title ........................................................................................................................... 1 1.2 Background .......................................................................................................................... 1 1.3 Project aims and objectives ...................................................................................................2 1.4 Report outline ....................................................................................................................... 2 1.5 Scenarios of project ..............................................................................................................4 1.6 Phase of project .................................................................................................................... 4 Chapter 2 Literature Review...........................................................................................................5 2.1 Introduction .......................................................................................................................... 5 2.2 Power supply system ............................................................................................................5 2.2.1 Transformer ................................................................................................................... 5 2.2.2 Regulator and rectifier ...................................................................................................6 2.2.2.1 Regulator .................................................................................................................6 2.2.2.2 Rectifier ................................................................................................................... 7 2.3 Measurement system.............................................................................................................8 2.3.1 Transformer ................................................................................................................... 8 2.3.2Shunt resistor ..................................................................................................................8 2.3.3 Operational amplifier ................................................................................................... 10 2.3.4 Rectifier ....................................................................................................................... 10 2.4 PIC control system .............................................................................................................. 11 2.4.1 PIC16F877A................................................................................................................ 11 2.4.2 LCD display module .................................................................................................... 12 2.5 Software ............................................................................................................................. 12 2.5.1 Multisim ...................................................................................................................... 12 2.5.2 MikroC pro .................................................................................................................. 12 2.5.3 Eagle ........................................................................................................................... 12 2.6 Comparison with current power meter project ..................................................................... 13 Chapter 3 Methodology ................................................................................................................ 14 3.1 Hardware overview ............................................................................................................. 14
Page iv

3.2 Power supply system .......................................................................................................... 15 3.3 Measurement system........................................................................................................... 16 3.3.1 Current measurement ................................................................................................... 17 3.3.1.1 Shunt resistor ......................................................................................................... 17 3.3.1.2 Voltage follower .................................................................................................... 18 3.3.1.3 Rectifier ................................................................................................................. 19 3.3.2 Voltage measurement .................................................................................................. 19 3.3.2.1 Transformer ........................................................................................................... 19 3.3.2.2 Voltage divider ...................................................................................................... 19 3.3.2.3 Voltage follower .................................................................................................... 20 3.3.2.4 Rectifier ................................................................................................................. 20 3.4 PIC control system .............................................................................................................. 20 3.4.1 Hardware ..................................................................................................................... 21 3.4.1.1 PIC microcontroller ............................................................................................... 21 3.4.1.2 LCD display module .............................................................................................. 22 3.4.2 Software ...................................................................................................................... 23 3.4.2.1 Initialization ........................................................................................................... 25 3.4.2.2 ADC conversion .................................................................................................... 26 3.4.2.3 Calculation of power consumption and electric bill ................................................ 27 3.4.2.4LCD display............................................................................................................ 29 Chapter 4 Results ......................................................................................................................... 31 4.1 Simulation approach ........................................................................................................... 31 4.1.1 Power system............................................................................................................... 31 4.1.2 Current measurement ................................................................................................... 33 4.1.2.1 Shunt resistor ......................................................................................................... 34 4.1.2.2 Voltage follower .................................................................................................... 34 4.1.2.2 Rectifier ................................................................................................................. 36 4.1.3 The current measurement of two lamps ........................................................................ 37 4.1.4 Voltage measurement .................................................................................................. 39 4.1.4.1 Workability of measuring voltage in Multisim ....................................................... 39 4.1.4.2 Transformer ........................................................................................................... 40
Page v

4.1.4.3 Voltage divider ...................................................................................................... 41 4.1.4.3 Voltage follower .................................................................................................... 42 4.1.4.4 Rectifier ................................................................................................................. 42 4.2 Practical approach ............................................................................................................... 43 4.2.1 Current measurement ................................................................................................... 43 4.2.2 Voltage measurement .................................................................................................. 47 4.2.3 Power supply system ................................................................................................... 50 4.3 LCD analog inputs measurement ........................................................................................ 50 4.4 Hardware constructions....................................................................................................... 52 Chapter 5 Discussion.................................................................................................................... 53 5.1 Result discussion ................................................................................................................ 53 5.2 Problems encountered and solutions.................................................................................... 55 5.3 Validity of the project ......................................................................................................... 58 5.4 Limitation of Intelligent Power Meter ................................................................................. 58 Chapter 6 Conclusion ................................................................................................................... 59 6.1 Technical specifications ...................................................................................................... 60 6.2 Future Enhancement ........................................................................................................... 61 References ................................................................................................................................... 62 Appendix A: Gantt chart .............................................................................................................. 66 Appendix B: Schematic diagram .................................................................................................. 67 Appendix C: PCB layout .............................................................................................................. 68 Appendix D: Software.................................................................................................................. 69 Appendix E: List of Components ................................................................................................. 75

Page vi

List of figures
Figure 1.1 Table of energy loss due to power meter ....1 Figure 2.1 Transformer5 Figure 2.2 LM7805 regulator.......6 Figure 2.3 MICW04M bridge rectifier.....7 Figure 2.4 the operation of bridge rectifier 7 Figure 2.5 Connection shunt resistor...8 Figure 2.6 5W 10 shunt resistor....9 Figure 2.7 High current rating and low resistance shunt resistor .....9 Figure 2.8 MCP6004 OP-AMP...........10 Figure 2.9 PIC16F877A..11 Figure 2.10 416 characters LCD Module...12 Figure 2.11 Electromechanical meter ...13 Figure3.1 Block diagram of Intelligent Power Meter ..14 Figure 3.2 The circuit of power supply system15 Figure3.3 The circuit of measurement system.....16 Figure 3.4 Voltage follower (unity gain differential amplifier) ...18 Figure 3.5 Voltage divider...19 Figure 3.6 Schematic diagram of PIC control system.....21 Figure 3.7 Schematic of PIC16F877A.22 Figure 3.8 Schematic of LCD display module.....23 Figure 3.9 Flow chart of power meter.....24 Figure 3.10 Configuration of LCD display module .25 Figure 3.11 Initialization of parameters...25 Figure 3.12 Configuration of input and output ports...25
Page vii

Figure 3.13 Calculation of voltage......26 Figure 3.14 Calculation of current ...27 Figure 3.15 Calculation of power consumption...27 Figure 3.16 Calculation of electric bill28 Figure 3.17 Calculation of electric bill29 Figure 4.1 Simulation of power supply system...31 Figure 4.2 Waveform of the output from transformer .32 Figure 4.3 Waveform of the output from bridge rectifier32 Figure 4.4 Waveform of the output from LM7805 voltage regulator ..33 Figure 4.5 Simulation of measuring current 33 Figure 4.6 Waveform of output voltage from shunt resistor ...34 Figure 4.7 Waveform of output voltage from voltage follower in current measurement 35 Figure 4.8 Waveform of output voltage from rectifier in current measurement .36 Figure 4.9 Simulation of measuring current on two lamps..37 Figure 4.10 Waveform of voltage across shunt resistor in the simulation with two lamps .38 Figure 4.11 Waveform of output of voltage follower in the simulation with two lamps .38 Figure 4.12 Waveform of output of rectifier in the simulation with two lamps..38 Figure 4.13 Simulation of measuring voltage..39 Figure 4.14 Workability of measuring voltage in Multisim40 Figure 4.15 Output of transformer...40 Figure 4.16 Voltage across line 10 and line11.41 Figure 4.17 Output voltage of voltage follower on voltage measurement ..42 Figure 4.18 output voltage of rectifier on voltage measurement .42 Figure 4.19 Output of shunt resistor with one lamp43 Figure 4.20 Output of shunt resistor with two lamps..43
Page viii

Figure 4.21 Output of voltage follower with one lamp44 Figure 4.22 Waveform of voltage follower with one lamp.44 Figure 4.23 Output of voltage follower with two lamps44 Figure 4.24 Waveform of voltage follower with two lamps45 Figure 4.25 Output of rectifier with one lam45 Figure 4.26 Waveform of rectifier with one lamp46 Figure 4.27 Output of rectifier with two lamps 46 Figure 4.28 Waveform of rectifier with two lamps .46 Figure 4.29 Input of transformer..47 Figure 4.30 Input of transformer..47 Figure 4.31 Output of voltage divider..47 Figure 4.32 AC output of voltage follower..48 Figure 4.33 DC output of voltage follower..48 Figure 4.34 Waveform of voltage follower.49 Figure 4.35 Output of rectifier.49 Figure 4.36 Waveform of rectifier...49 Figure 4.37 Output of power supply system50 Figure 4.38 LCD display with one lamp..50 Figure 4.39 LCD display with two lamps51 Figure 4.40 ADC module readings..51 Figure 4.41 The display of electric bill52 Figure 4.42 Hardware construction..52 Figure 5.1 Fault in LCD 55 Figure 5.2 Program of AAA loop56 Figure 5.3 Readings in current measurement with oscilloscope.57
Page ix

List of abbreviations
1. PIC 2. LCD 3. PCB 4. OP AMP 5. AC 6. DC Peripheral Interface controller Light Crystal Display Printed Circuit Board Operational Amplifier Alternative current Direct current Analog to digital conversion Ground Electrostatic discharge

7. ADC 8. GND 9. ESD

Page x

Chapter 1 Introduction
1.1 Project title
The final year project is given as Intelligent Power Meter. To achieve this project successfully, the essential knowledge is required such as display devices, digital electronics, microcontrollers and programming.

1.2 Background
The targets to measure in this project are light bulbs and a fan. The light bulb is a resistive device [1]. And the fan is an inductive device. Any inductive device with a coil of wire like motor will cause the current and voltage are out of phase. It contributes power factor is less than one. Hence, there will be energy loss in the inductive devices. However, the consideration of power meter is not necessary in Intelligent Power Meter project. Because the modern devices such as washing machine and air-conditioner are designed with power factor correction and power management system to reduce the energy loss due to power factor. This information can be referred to High-End Solution from Texas Instrument [2] [3]. Besides it, there is a proof that the power factor from inductive home appliances does not give significant effect on the electricity bill. The further calculation and explanation involved in this proof is stated in Powerelectronics.com [4].

Figure1.1 Table of energy loss due to power meter [5] Page 1

As Figure1.1 shown above, the energy losses due to power factor for refrigerator, washing machine, clothes dyer and air conditioner cost less than 20 cent/month. Such low cost from power factor is negligible. As the result of two reasons stated above, Intelligent Power Meter will not be considered to measure and calculate with power factor even though it measures the apparent power.

1.3 Project aims and objectives


The aim of this project is to design and implement an Intelligent Power Meter by developing the objectives and specifications. The objectives of this project: 1. Meter should read the power consumed from one or two devices. 2. Meter should consist of total power and monthly power consumed. 3. Based on monthly power consumed. Student must be come up with the amount that needs to be paid shown on LCD 4. Monthly power reader part can be reset.

1.4 Report outline


Chapter 1 Introduction In this chapter, the background, specifications, aim of this project are introduced to readers. This provides the understanding of Intelligent Power Meter that why the project initiated and how it is going to achieve. With the aid of chapter 1, the reader is easy to understand the deeper analysis in the following chapters.

Chapter 2: Literature review and theory Chapter 2 will discuss about the difference of current existed power meter and this Intelligent Power Meter. Besides this, the components are introduced to provide the justification of the most suitable one. Hence, the selection of components can be done according to components introduction.

Page 2

Chapter 3: Methodology With the decision of selecting components and the design of power meter, the method to achieve power meter is explained in detail. It has two major parts: hardware and software. It focuses on how the circuit functions and the software programming.

Chapter 4: Results The chapter consists of two approaches to obtain the results which are either from Multisim simulation approach or practical approach. The results are showing with diagram and description. The understanding of power meter from users is enhanced with how the measurement system and PIC control system works.

Chapter 5: Discussion Discussion will investigate the major problems encountered and the results between Multisim simulation approach and practical approach. This provides effective explanation to readers so that they can fully comprehend the operation of power meter.

Chapter 6: Conclusion The designer will conclude the achievement of this project and comment on the results. Despite of these, the future enhancement will be discussed.

Page 3

1.5 Scenarios of project


The devices will be placed on the 240VAC line. The voltage will be stepped down by the transformer. The current will be converted into voltage using shunt resistor connected in series with Neutral line. Both voltage transformer and current shunt resistor have two outputs.

PIC16F877A only understands one ADC input from transformer and shunt resistor. Therefore, the voltage follower is used to convert two inputs into one output. The voltage across two inputs is equal to the voltage between the output and ground. The output of voltage follower is still AC voltage which will not keep constant in PIC16F877A so the calculation cannot be done.

Next, the rectifier will cap the peak voltage of AC voltage. PIC16F877A will take these values to calculate the actual voltage and current. The power consumption will be obtained from the multiplication between voltage and current. Hence, the electric bill will be carried out. There are four values showing on LCD display: voltage, current, power consumption and electric bill. The reason to display current is because there is electric breakdown happened in residences due overload. The residences can refer to current to adjust how many loads should work simultaneously.

1.6 Phase of project


Intelligent Power Meter project are categorized into six phases as shown below: Phase 1: Comprehend the project aim and objectives. Research the theory of power meter. Phase 2: Circuit design Algorithm of measurement system and PIC control system Phase 3: Circuit test and development of software Phase 4: Troubleshooting on circuit and software Phase 5: Design and implementation of PCB board Phase 6: Test and troubleshooting on PCB board
Page 4

Chapter 2 Literature Review


2.1 Introduction
In real life, power meter runs 24 hours continuously to monitor the power consumption of devices. If it stops working for certain time, this will result in inaccuracy to the electric bill. Therefore, this project must equip with a power supply which can work continuously without any failure. The best solution is to convert 240VAC to 5 VDC for PIC control system. For home appliance AC line, it works with 240VAC and 13A MAX in 50HZ. The aim of measurement system is to convert 240VAC and 13A MAX into a value in such manner where it is compatible with PIC microcontroller. In measurement system, there are voltage measurement and current measurement. The output of measurement system will be processed to PIC controller. In PIC control system, the PIC microcontroller must be able to have ADC module, perform calculation and interface with LCD display module.

2.2 Power supply system


2.2.1 Transformer

Figure 2.1: Transformer [6]

Transformer has two coils, primary coil and secondary coil. It uses magnetic field formed by primary coil to move electrons to secondary coil. Thus, the electricity current is is proportional to the primary voltage with the ratio of
Page 5

produced. The secondary voltage

the number of turns in secondary coil formula of this fact is shown as below:

to the number of turns

in the primary coil. The

The 220VAC to 9VAC transformer is selected based on the availability. This transformer has the largest ratio between primary and secondary in the market. Since 5VDC power supply is needed in this project. Therefore, the 10V AC to 5VDC converter is required.

2.2.2 Regulator and rectifier 2.2.2.1 Regulator Voltage regulator can convert AC voltage into DC voltage. There are various outputs available among the regulator products. The most common one is with starting series number 78 and 79. 78 series are with a positive output and 79 series are with a negative output. LM7805 is applied into this project. It is able to regulate 10 VDC into 5 VDC. LM7805 is picked is to meet the 10VAC output from transformer.

Figure 2.2 LM7805 regulator [7]

Page 6

2.2.2.2 Rectifier

Figure 2.3 MICW04M bridge rectifier [8]

The bridge rectifier MICW04M is applied as shown in Figure 2.3. It has the function to convert AC input voltage to DC ripple output voltage. And it fully utilizes four diodes in bridge to perform the full-wave rectification. Full-wave rectification brings the fact that no matter rectifier circuit is in positive half cycle or negative half cycle, the current will flows in the same direction through the load.

Figure 2.4 The operation of bridge rectifier [9]

Page 7

2.3 Measurement system


2.3.1 Transformer The operation of transformer in measurement system is the same as the one using in power supply system. The reason to use two separated transformers with same characteristics is because of the consideration of safety. If power supply system fails, the independent measurement system is still able to operate.

2.3.2Shunt resistor When the device switches on, the current will flow through the device and shunt resistor. As current appears, voltage will be across shunt resistor. Based on Ohms law, the current can be obtained by

Where R=10.
Current I Neutral Line

5W10

Voltage V
Figure 2.5 Connection shunt resistor

The shunt resistor is very crucial for power meter that must be protected from damage. The fixed cement power resistor is adopted as the shunt resistor.

Page 8

Figure 2.6 5W 10 shunt [10]

The 5W 10 shunt resistor is chose because it has higher power rating than other resistors in the market. In practical, to meet the requirement of measuring high power consumption home appliances, the current sensing shunt resistor with high current rating and low resistance must be applied as shown below. High current rating guarantees the safety and low resistance provides high accuracy to measurement. However, this type of shunt resistor has difficulty to purchase.

Figure 2.7 High current rating and low resistance shunt resistor [11]

Page 9

2.3.3 Operational amplifier MCP6004 is the operation amplifier in this project design. It performs as the voltage follower which changes two inputs to one output. It has one advantage comparing to common used Op Amp LM741. It only requires 5V and Ground. But LM741 needs +5V and -5V which brings the complexity to the power supply system.

Figure 2.8 MCP6004 OP-AMP [12]

In order to prevent the damage on this op amp, the voltage and current must be limited. Inside the op amp, there are ESD diodes to protect the input pins (Vin + and Vin-) from

voltage drop [12]. And there must be resistor to limit the leakage current. The further explanation is in Chapter 3 Methodology section 3.3.1.2 Voltage follower 2.3.4 Rectifier The purpose of this rectifier is to convert AC input voltage from Op-Amp to DC output voltage. It will be compatible with PIC16F877A ADC input pins. Otherwise the readings from input pins are changing along with the sinusoidal wave. It is using the same bridge rectifier MICW04M from the power supply system.

Page 10

2.4 PIC control system


2.4.1 PIC16F877A PIC16F877A plays the roles as a microcontroller which consists of input/output pins, ROM, RAM, CPU, Oscillator and A/D converter. The reason to choose microcontroller but not microprocessor is that the microcontroller has low power consumption, high performance of computation and low economical price but it is only designed to perform a specific task. These characteristics are more suitable for hobbyists project like this Intelligent Power Meter. Microprocessor has powerful CPU which is able to perform multitasking. It is built in most commercial products.

Figure 2.9 PIC16F877A [13]

Comparing to others PIC microcontroller with PIC16F877A, PIC16F877A meets the requirements of ADC converter, I/O port, EEPRO M and oscillator.

Page 11

2.4.2 LCD display module JHD204A LCD Module is involved in this project because it can interface with PIC16F877A. It has 416 characters. This LCD module shown as below will display the current, voltage, power consumption and electric bill.

Figure 2.10 416 characters LCD Module [14]

2.5 Software
2.5.1 Multisim National Instrument MULTISIM is powerful software which provides the platform for users to achieve simulation of design without taking time to implement the circuit in real life. The measurement system circuit testimony will be done in Multisim. 2.5.2 MikroC pro MikroC pro is a C compiler for PIC microcontrollers to design for the development, building and debugging PIC-based embedded application [15]. Therefore, PIC16F877A can be compiled using this software. 2.5.3 Eagle Easily Applicable Graphical Layout Editor is software with the function of schematic capturing and PCB layout. It can automatically generate PCB layout from schematic. It is more convenience than Express PCB.

Page 12

2.6 Comparison with current power meter project


For the common power meters, they are electromechanical meter which applies two coils for voltage and current measurement using the effect of magnetic flux. It only displays power consumption. The residences are confused how much it will cost them. Besides these, the amount of power consumption is increment. If the residences want to know how much the power consumption is, they have to take current power consumption to minus with the power consumption from last month.

Figure 2.11 Electromechanical meter [16]

Intelligent Power Meter will apply microcontroller to measure the power consumption. The results will be in digital form which can be accurate as electromechanical meter. This project can provide more convenience to the residences.

Page 13

Chapter 3 Methodology
In this chapter, the approach of hardware and software will be discussed. In hardware part, there are discussions about circuit design, component characteristic, circuit simulation and theoretical results. Next, software is only involved in PIC control system that will be discussed under section 3.3 PIC control system.

3.1 Hardware overview


E L N PIC control system Measurement system
Measuring voltage Transformer Voltage divider Voltage follower Voltage follower Rectifier PIC16F877A Measuring current Rectifier LCD display

Shunt resistor

Power supply system

Figure3.1 Block diagram of Intelligent Power Meter

There are three systems in this project: 1. Power supply system 2. Measurement system 3. PIC control system Power supply system and measurement system are designed on one PCB board. At first, they are designed in schematic diagram. After this, this will be transferred to PCB diagram. This process is part of Eagle software.

Page 14

3.2 Power supply system


The circuit design of power supply system from 10VAC to 5VDC is drawn in EAGLE software as shown below:
Rectifier 10VAC 5VDC Regulator

GND

GND

Figure 3.2 The circuit of power supply system

In this project, the operational amplifier MCP6004, PIC16F877A and LCD module requires 5V power supply. Power supply system steps down 240 VAC to 10VAC using transformer. Then, it converts 10VAC to 5VDC using rectifier and voltage regulator. And in order to smooth the ripple voltage, the C1, C2 and C3 are used. In this project, the 220V input to 9 V output transformers is applied. Hence, the ratio of number of turns is

The theoretical output from the transformer in this project is

Then, the ratio between transformer and AC power line is The ratio of LM7805 is power supply system is . Therefore, the output of LM7805 or the output of

Page 15

3.3 Measurement system


In measurement system, there are two parts involved: 1. Voltage measurement: it consists of transformer, voltage divider, voltage follower and rectifier. 2. Current measurement: it consists of shunt resistor, voltage follower and rectifier. The following is the circuit of measurement system drawn in EAGLE software. The output of measurement system will be the input of PIC control system.

GND

5V

Voltage measurement

V3 V4
Voltage follower Rectifier
PIC ADC channel 0

Output of transformer

Voltage divider

Output of shunt resistor Current measurement Voltage follower

V1 V2
Rectifier
Figure3.3 The circuit of measurement system

PIC ADC channel 0

Page 16

3.3.1 Current measurement 3.3.1.1 Shunt resistor The wattage rating of shunt resistor is 5w and resistance is 10. According the formula

The maximum current can be obtained as

This current rating is not only for shunt resistor but also for this Intelligent Power Meter project. Approximately, it can support four 40W lamps at the same time. There is 240V 40W lamp on AC line. Hence, the current it draws is

According to this, the current of shunt resistor when one lamp works on AC line is also 0.167A. Then, based on Ohms law, the voltage across it is

Then, when two lamps switch on, the voltage across shunt resistor will be

This voltage will be the input of current measurement and voltage follower.

Page 17

3.3.1.2 Voltage follower

Figure 3.4 Voltage follower (unity gain differential amplifier) [17]

This voltage follower is constructed with differential amplifier. The voltage output of differential amplifier is

Where V1 and V2 are marked in Figure 3.3 When = = , this differential amplifier has the unity gain (gain =1). It is called

voltage follower. Then,

Where

is RMS voltage

The voltage follower is implemented by the operational amplifier MCP6004.Before designing the circuit, the safety must be considered as mention in section 2.3.3. There are two formulas for analog inputs protecting resistors which are squared in Figure 3.3.

In this case, the designer has chosen 17.7K

as protecting resistors.
Page 18

3.3.1.3 Rectifier The rectifier is designed with bridge diode to provide full wave output. The output of voltage follower will be in AC voltage. However, ADC module of PIC only can read constant DC voltage. To meet this, the idea of designing rectifier is created. The rectifier takes the as the output of itself. Then,

3.3.2 Voltage measurement 3.3.2.1 Transformer The transformer is adopted as the same from power supply system. The output of the transformer is 9.8VAC as mentioned in section 3.2. 3.3.2.2 Voltage divider

Vd

Figure 3.5 Voltage divider [18]

The ratio of two resistors

and

is determined the output voltage. After the

transformer, the voltage is too high for the operational amplifier MCP6004. The purpose of voltage divider design is to step down the voltage. Depending on the resistance of voltage divider, the designers can get the suitable output voltage in their design. The formula of voltage divider is shown as below:

Page 19

In this voltage divider, the ratio between input voltage and output voltage is 0.09 as shown below.

Then, the output of the voltage divider will be Where 9.8V is the output of transformer

3.3.2.3 Voltage follower The voltage follower in voltage measurement has the same operation as the voltage follower in current measurement in section 3.3.1.2. The output of voltage follower in voltage measurement is

Where V3 and V4 are marked in Figure 3.3 3.3.2.4 Rectifier The rectifier in voltage measurement has the same operation as the rectifier in current measurement in section 3.3.1.3. The output of rectifier in voltage measurement is

3.4 PIC control system


In Figure 3.6, the PIC control system is presented. It functions to control inputs and outputs according to the programming. With the aid of LCD display and PIC16F877A, PIC control system is able to read analog inputs from measurement system and to perform the

Page 20

calculation to gain the actual current and voltage. These actual values will be showed on the LCD display module.
5V

GND

Output of current measurement

Output of voltage measurement

Figure 3.6 Schematic diagram of PIC control system

3.4.1 Hardware 3.4.1.1 PIC microcontroller There must be 5VDC power supply to pin 1 (VPP) with 1K resistor, pin 11(Vcc) and pin 21(Vdd). The ground must be provided to pin 12 and pin 31 (Vss/Gnd). Pin 13 and pin 14 (Osc1 and OSc2) needs to connect with 8M crystal oscillator with two 22pF capacitors. The output of current measurement is connected with pin 2 ADC module (ADCON0). The output of voltage measurement is connected with pin 3 ADC module (ADCON1). And pin 33 to pin 38 will be connected with LCD display module.

Page 21

Figure 3.7 Schematic of PIC16F877A

3.4.1.2 LCD display module The LCD display module is adopted to display the current, voltage, power consumption and electric bill. As shown below, it is the list of LCD display module connection.
LCD Pins Pin1 Pin2 Pin3 Pin4 Pin5 Pin6 Pin7 Pin8 Pin9 Pin10 Pin11 Pin12 Pin13 Pin14 Pin15 Pin16 PIC port B pins Ground 5V Ground with 1K resistor Pin 37 RB4 Ground Pin 38 RB5 Null Null Null Null Pin 33 RB0 Pin 34 RB1 Pin 35 RB2 Pin 36 RB3 5V Ground Page 22

5V

PIC16F877F

Ground
Figure 3.8 Schematic of LCD display module

3.4.2 Software The flow chart of the whole process to measure power consumption is presented as following Figure 3.9. It is processed in PIC control system using C language. This software programming is written with the configuration hardware input and output pins. There are 3 major parts in this program: 1. Voltage reading 2. Current reading 3. Power consumption and electric bill calculation

Page 23

Start

Initialization

Case:AAA

Read from analog input channel 1

Voltage reading

Is curret reading larger than last reading? Yes

No

Calculate and display actual voltage

Read from analog input channel 0

Current reading

Is curret reading larger than last reading?

Yes No Calculate and display actual current

Calculate and display power consumption P=VI

Power consumption and electric bill

Calculate electric bill

After 1 hour, electric bill increment

After 1 month, power meter reset.

Figure 3.9 Flow chart of power meter

Page 24

3.4.2.1 Initialization

Figure 3.10 Configuration of LCD display module

Figure 3.10 shown above is the configuration of LCD display module. The pins of LCD are connected according to the list of LCD display module connection.

Figure 3.11 Initialization of parameters

Figure 3.11 shown above is the initialization of parameters which are going to be used in the program. Unsigned char has 8 bits size and the range from 0 to 255. Unsigned long has 32 bits and range from 0 to 4294967295 which are sufficient for calculation and readings. Unsigned int has 16 bits and range from 0 to 65535.

Figure 3.12 Configuration of input and output ports

Page 25

Figure 3.12 shown above is the configuration of input and output ports. RA0, RA1 and RA2 in Port A are configured as inputs. All pins in Port B are outputs. Besides these, the LCD display module is initialed. 3.4.2.2 ADC conversion ADC conversion is to convert analogue voltage input into digital form which is understood by microcontroller. The output of measurement system is read by ADC module in PIC16F877A. This ADC module has 10 bits with 1024 sampling levels to represent the ADC inputs. 1024 sampling levels have 0 to 1023 resolutions.

In ADC module, the voltage reference is 5V by default in PIC16F877A. Hence, one resolution represents 0.0048V,

Figure 3.13 Calculation of voltage

Figure 3.13 above shows the actual voltage calculation. The output of voltage measurement will be read by Channel 1 in ADC module of PIC16F877A. The output of voltage measurement is 0.568 (obtained in 4.1 voltage measurement). And the input of voltage measurement is 244V. Then, the ratio between them is

Page 26

Because the operation in MikroC pro does not accept decimal, 429.57 is represented by 42957/100.

Figure 3.14 Calculation of current

Figure 3.14 shows the actual current calculation. The output of current measurement will be read by Channel 0 in ADC module. And it is 1.788 (obtained in 4.2 current measurement). And the input of voltage measurement is 1.67V (mentioned in 3.3.1.1 Shunt resistor). Then, the ratio between them is

1.07 can be represented by 100/107.

3.4.2.3 Calculation of power consumption and electric bill To get power consumption is to simply multiply voltage with current as Figure 3.15. u and i is the output from voltage and current calculation.

Figure 3.15 Calculation of power consumption

The home user in Malaysia is charged by domestic tariff from Tenaga Nasional Berhad. The domestic tariff is RM0.218/KWH which is represented by [19]. To obtain how much

the power consumption costs the home appliances users is to multiply power consumption with RM0.218/KWH in each hour. For the demonstrate purpose, the one hour time is represented by 1 second (1000ms).
Page 27

Initialization b=0

Case:AAA

Voltage, current, power consumption calculation

C1< 9

Reset

a=power0.218RM/kwh

m=a+b

Display amount of electric bill

C1=C1+1

b=m

Delay 1 second

Figure 3.16 Calculation of electric bill

As to the calculation of electric bill, in the initialization, b=0. The program goes through the voltage, current, power consumption calculation. At the beginning of electric bill

Page 28

program, the 10 loops are set with parameter C1. C1 increments from 0 to 9. Since there is 1 second delay, the 10 loops will be defined as 10 second. The 10 loops command checks whether the current loop is bigger or equal to 9. If it is, it will proceed to reset all the parameters and goes back to case: AAA. If it is less than 9 times, the program will perform calculation and following command lines. When the loop is less than 9 times, the calculated amount of money is put in a. Then, the total amount m equals to a + b. The sum of a + b is displayed on LCD. C1 increments by the step of 1. Next, the m will be stored in b. After 1second, the program will go back to case: AAA. Therefore, by following this method, the amount of money can increment with 1 second and all parameters can be reset when 10 loops reached. For the demonstration purpose, one hour is represented by 1 second. And 720 hours (30days24hours=1 month in hours) are represented by 10 seconds. 3.4.2.4LCD display For display of voltage, current and power consumption, they are 5 digits. The decimal point is between the third digit and the fourth digit. For electric money, it needs 6 digits.

Figure 3.17 Calculation of electric bill Page 29

Figure 3.17 shown above is the 5 digits display program. To obtain the individual digit is to make the parameter (i or v) divide by . X is the number of digits. For example, the

designer wants to extract 5 digits with decimal between the third digit and the fourth digit. Then, it will

Extracting 4 digits, 3 digits and 2 digits etc. follows the above algorithm as shown in Figure 3.17.

Page 30

Chapter 4 Results
This chapter provides the practical evidence of each system in this project. There are two approaches to verify the operation of power meter. The first is simulation approach on Multisim and another is practical approach from constructed circuits.

4.1 Simulation approach


4.1.1 Power system The following is the simulation of power supply system.

Figure 4.1 Simulation of power supply system

As the result shown in Figure 4.1, the output from the power supply system in simulation is 4.99V. In order to observe the whole process of AC to DC conversion, at first, the operation of transformer is investigated. `

Page 31

Figure 4.2 is showing that And .

of the transformer output is 11.173V.

Figure 4.2 Waveform of the output from transformer

The bridge rectifier is the next process after transformer. It rectifies the 11.173VAC into 9.57VDC as shown in Figure 4.3 so that voltage regulator is able to accept this as an input.

Figure 4.3 Waveform of the output from bridge rectifier

LM7805 voltage regulator has the ability to step down 10VDC input to 5VDC output. As shown in Figure 4.4, the output of LM7805 voltage regulator is 5.001VDC. This will supply to all the systems. Then,

Page 32

Figure 4.4 Waveform of the output from LM7805 voltage regulator

4.1.2 Current measurement The simulation of measuring current in Multisim is done as shown below in Figure 4.5. The result is obtained as the following. In this simulation, since Multisim does not support the AC power line with Life, Neutral and Earth, the single line AC power source is applied instead. Based on the theory of AC power line, the negative part of this AC power source can be seen as Neutral line and the positive part of it can be seen as Life line.

Figure 4.5Simulation of measuring current

Page 33

4.1.2.1 Shunt resistor In Multisim, the 1 shunt resistor is used but not 10 resistor. This is because this simulation is not imitating the real power line situation. If 10 resistor is applied as shunt resistor, the lamp in Multisim could not function properly that is only on for a short time period. However, this will not affect the objective of this simulation. The result still could be obtained by multiplying 10 times. The simulation shows the voltage of shunt resistor in XMM2 in Figure 4.5 is 0.166V. By observing in oscilloscope in Figure 4.6, And measurement. Then, of the shunt resistor output is 0.234V.

. This also is the input of voltage follower in current

Figure 4.6 Waveform of output voltage from shunt resistor

4.1.2.2 Voltage follower In the simulation, 4.5 and = = , is measured by XMM5 shown in Figure and .

is measured by XMM4. They shows that

In theory, the output voltage of voltage follower in current measurement is

Page 34

In the simulation, the output voltage of voltage follower in current measurement is 0.09VAC and shunt resistor is There is difference between simulation and theory on the output voltage of voltage follower in current measurement is because the output of voltage follower also connects to the bridge rectifier where is the voltage cancelling certain voltage from 0.165VAC to obtain 0.09VAC. The waveform of output voltage from voltage follower in current measurement is investigated in oscilloscope as shown in the following. It has the same but shown in Figure 4.5 XMM3. The ratio between voltage follower

only with half cycle because the operational amplifier MCP6004 is not able to accept negative input. The output of voltage follower proves that it successfully change two inputs into an output with same value. Therefore,

The ratio of Vpeak between voltage follower and shunt resistor with one lamp is

Figure 4.7 Waveform of output voltage from voltage follower in current measurement Page 35

4.1.2.2 Rectifier The minimum output of rectifier is 175.614nV and the maximum output of rectifier is 176.716nV. There is still a small ripple voltage existing in output after smoothing capacitor 220uF C4. But, this output becomes DC voltage in the PIC analog input manner.

Figure 4.8 Waveform of output voltage from rectifier in current measurement

Page 36

4.1.3 The current measurement of two lamps This is the testimony for more than one device on the AC power line to observe the difference with the simulation with one device. The two exactly same lamps are added in this simulation.

From the readings shown in Figure 4.9, the voltage across shunt resistor,

, and

output of voltage follower all are doubled comparing the readings in the simulation with one lamp shown in Figure 4.5. This shows that the voltage across the shunt resistor is proportion to the drawing current from devices. More devices operates at the same time, more current will be drawn. Then, higher voltage across shunt resistor presents.

Figure 4.9 Simulation of measuring current on two lamps

The voltage across shunt resistor in the simulation with two lamps is measured as the following Figure 4.10. The ratio between this voltage and Shunt resistor is 0.234V from section 4.1.2.1

Page 37

Figure 4.10 Waveform of voltage across shunt resistor in the simulation with two lamps

The output of voltage follower is obtained from Figure 4.10 as following with the same from Figure 4.11. And it becomes half cycle due to the negative input limitation of MCP6004.

Figure 4.11 Waveform of output of voltage follower in the simulation with two lamps

The output of rectifier in Figure 4.12 is obtained with slight increase from 175.614nV to 179.77nV comparing to Figure 4.8.

Figure 4.12 Waveform of output of rectifier in the simulation with two lamps Page 38

4.1.4 Voltage measurement The simulation of measuring voltage is done as following. The result shows the faults and inaccuracy due to Multisim United States standard.

Figure 4.13 Simulation of measuring voltage

4.1.4.1 Workability of measuring voltage in Multisim Multisim is designed and programmed in the way of United States Electrical and Electronic system. Therefore, the simulation is following United States Standard. The lamp standard by default is 120V 100W and 120V 150W which are able to find in database. But for country like Malaysia, the standard is 240V with different wattage. The lamp with 240V lamp is not available in Multisim.

Page 39

As shown below Figure 4.14, the outputs from the same circuit with different sources and lamps are different. The circuit with 240V lamp has much lower voltage output. But the circuit with 120V 100W lamp can get the expected output 5V. This states Multisim does not have the ability to simulation with 240V Lamp. However, it is still able to simulation with output. The results from the simulation 240V lamp have the value to make the comparison with practical results. This method is workable.

Figure 4.14 Workability of measuring voltage in Multisim

4.1.4.2 Transformer

Figure 4.15 Workability of measuring voltage in Multisim

Page 40

The output from transformer is obtained as above in Figure 4.15. Then, .

is 0.904V.

is 1.818V. This output will be the input for

voltage divider. It is supposed to be the same as the transformer in power supply system. Due to the workability mentioned in section 4.1.4.1, the transformer is failed in Multisim. The ratio between transformer and AC power line is

4.1.4.3 Voltage divider In the waveform Figure 4.16, it is obtained by oscilloscope across line 10 and line 11. The is 82.265mV. Then,

And the output

from transformer in Figure 4.15 is 904.853mV.

The ratio between voltage divider and transformer is

The output voltage across transformer will undergo the operation of voltage divider to get the output across line 10 and line 11

Figure 4.16 Voltage across line 8 and line10 Page 41

4.1.4.3 Voltage follower

The output

Figure 4.17 Output voltage of voltage follower on voltage measurement

of this voltage follower is 90.031uV. Then,

Because of Multisim standard as discussed in 3.3.2.1 Workability of measuring voltage in Multisim, 240V lamp does not work properly in this voltage measurement. it brings the fault that 5VDC power supply is not generated. Hence, the Op Amp MCP6004 does not turn on. The functionality of voltage follower is not performing in this case. The ratio between voltage follower and voltage divider is 4.1.4.4 Rectifier

Figure 4.18 Output voltage of rectifier on voltage measurement Page 42

The output

of this rectifier in Figure 4.18 is 391.615nV. Then, without proper input

from voltage follower, the result has fault also. But the waveform is still rectified into DC voltage.

4.2 Practical approach


4.2.1 Current measurement

Figure 4.19 Output of shunt resistor with one lamp

The output of shunt resistor with one lamp shown in Figure 4.19 is 1.696VAC. This is the actual current one lamp draws.

Figure 4.20 Output of shunt resistor with two lamps

The output of shunt resistor with two lamps shown in Figure 4.20 is 3.355VAC. This is the actual current the lamp draws. It is the double of the current with one lamp in shunt resistor.

Page 43

Figure 4.21 Output of voltage follower with one lamp

The output of voltage follower with one lamp shown in Figure 4.21 is 0.983VAC. The ratio between voltage follower and shunt resistor is . The waveform of voltage

follower with one lamp is shown in Figure 4.22 which has Vrms 1.27VAC

Figure 4.22 Waveform of voltage follower with one lamp

Figure 4.23Output of voltage follower with two lamps Page 44

The output of voltage follower with two lamps in Figure 4.23 is 1.717VAC. It is the double of the current with one lamp in voltage follower. The ratio between voltage follower and shunt resistor is .

Figure 4.24 Waveform of voltage follower with two lamps

Comparing Figure 4.21 and Figure 4.23, the Vamp ( follower with two lamps is about double of the Vamp ( follower with one lamp.

) of waveform in voltage ) of waveform in voltage

Figure 4.25 Output of rectifier with one lamp

The output of rectifier with one lamp in Figure 4.25 is 1.788VDC. The ratio between rectifier and voltage follower is .

Page 45

Figure 4.26 Waveform of rectifier with one lamp

Figure 4.27 Output of rectifier with two lamp

The output of voltage follower with two lamps as shown in Figure 4.27 is 3.175VDC. It is the double of the current with one lamp in voltage follower. of rectifier with two lamps in Figure 4.28, its amplitude is 3.24VDC. . In the waveform

Figure 4.28 Waveform of rectifier with two lamps Page 46

4.2.2 Voltage measurement

Figure 4.29 Input of transformer

The Figure shown above Figure 4.29 is not only AC voltage in AC power line but also input of transformer which 244VAC.

Figure 4.30 Input of transformer

The output of transformer is 10.30VAC as shown above in Figure 4.30. This AC voltage will be divided in voltage divider. The ratio between transformer and AC power line is

Figure 4.31 Output of voltage divider

Page 47

The output of voltage divider is 0.870VAC as shown above in Figure 4.31. Then, the ratio between voltage divider and transformer is

Figure 4.32 AC output of voltage follower

The AC output of voltage follower is 0.456VAC as shown above in Figure 4.32. Then, the ratio between voltage follower and voltage divider is .

Figure 4.33 DC output of voltage follower

The DC output voltage is 0.563V in Figure 4.33 and the waveform showing the Vrms output of voltage follower is 0.472V in Figure 4.34. It has the 0.02V difference with Vrms measured in multimeter in Figure 4.33

Page 48

Figure 4.34 Waveform of voltage follower

Figure 4.35 Output of rectifier

The DC output of rectifier is 0.568V as shown above in Figure 4.35. Then, the ratio between rectifier and voltage follower is . The waveform of rectifier shown in

Figure 4.36 has the amplitude 0.560mV with ripple voltage.

Figure 4.36 Waveform of rectifier Page 49

4.2.3 Power supply system

Figure 4.37 Output of power supply syestem

The Figure shown above in Figure 4.37 is the output of power supply system from voltage regulator. The output voltage is 0.496VDC

4.3 LCD analog inputs measurement

Figure 4.38 LCD display with one lamp

The result of LCD display is obtained as above in Figure 4.38. With one lamp working, the current showing is 0.16V and the voltage is 244.14. The power consumption is 39.06W . The electric bill is below power consumption with increment with 1 second time.

Page 50

Figure 4.39 LCD display with two lamps

With two lamps working, the current showing in Figure 4.39 is 0.31V and the voltage is 244.14. The power consumption is 75.68W devices adding the voltage stays at 244.14V. . It shows that with more

Figure 4.40 ADC module readings

The resolution read from channel 0 for current measurement is 360. To convert it to voltage is shown in Figure 3.13 Calculation of voltage. The result of this conversion is the output of voltage measurement from rectifier shown in Figure 4.40. V The resolution read from channel 1 for current measurement is 111. To convert it to voltage is shown in Figure 3.14 Calculation of current. The result of this conversion is the output of current measurement from rectifier shown in Figure 4.40. V
Page 51

Figure 4.41 The display of electric bill

At this moment in Figure 4.41, the power consumption is 37.26W. According to the tariff 0.218RM/KWH, 37.26W will cost the user As shown in Figure 4.41, the amount of electric bill is exactly displayed on LCD .

4.4 Hardware constructions

Power plug to devices Transformer Shunt resistor

Power plug from wall outlet

Power supply system PIC control system with LCD

Voltage divider

Voltage follower Rectifier

Measurement system

Figure 4.42 Hardware construction

As shown in Figure 4.42, the hardware of power supply system, measurement system and PIC control system are constructed on PCB board.
Page 52

Chapter 5 Discussion
5.1 Result discussion
Systems Parts Theory (output) Power supply system Current measurement Shunt resistor Voltage follower 1.69VAC 1.65VAC 0.9VAC(M) 1.65VAC(O) Rectifier Voltage measurement Transformer 9.8VAC Ratio 0.545 1.696VAC 0.983VAC(M) 1.27VAC(O) 1.788VDC 10.3VAC Ratio to 0.87V is 0.0834 Ratio 0.579 Regulator 4.9VDC Simulation approach(output) 5.001VDC 4.98VDC Practical approach(output)

0.175uVDC 0.639VAC Ratio to 58mV is 0.09

Voltage divider Voltage follower

0.882VC

58mVAC 63.6uVAC

Ratio 0.001

0.87VAC 0.456VAC(M) 0.47VAC(O)

Ratio 0.534

Rectifier

91.615nVDC

0.568VDC(M) 0.560VDC(o)

Table 1 Results

The results obtained from three approaches: theory in Chapter 3 Methodology, simulation approach and practical approach in Chapter 4 Results. The capital O beside the values states that the value taken from waveform in oscilloscope. The capital M beside the values states that the value taken from multimeter. In power supply system, the output 4.9VDC in theory is proven with 5.001VDC in simulation approach and 4.98VDC in practical approach.

Page 53

In current measurement, the outputs of shunt resistor and voltage follower are obtained with only 2.7% errors. . But for rectifier, there are very large errors. It is because in the database of Multisim it is lack of bridge rectifier. The only type of bridge rectifier is applied in Multisim which is not the one in practical approach. Therefore, with different components, the result definitely will be different. In voltage measurement, due to the workability of measuring voltage in Multisim, the results are not reliable. But the operating evidence still can be found in the ratio between two components. The ratio between voltage divider and transformer in simulation approach is 0.09. And the ratio between them in practical approach is 0.0824. It proves that transformer and voltage divider are operating.

Page 54

5.2 Problems encountered and solutions


Problem 1: the value from measurement system keeps jumping when it shows in LCD display module. Reason: The first design of this power meter is without the consideration of rectifier. The output of measurement system is AC voltage. The ADC module in PIC 16F877F is to converting DC voltage into a resolution by the method of sampling. Solution: The rectifier is added in order to convert AC voltage into DC voltage. With the aid of rectifier, the output of itself is still not the perfect DC voltage but is the ripple voltage as mention in section 4.1.2.2 and section 4.1.4.5.

Problem 2: the LCD display module does not show the characters but showing the blocks on the 1st and third row.

Figure 5.1 Fault in LCD

Reason: the program compiled inside LCD display module is tested in other project which is workable. And the hardware is synchronized with LCD pins. The only reason will be PIC hardware connection with faults. Solution: the fault is found in PIC hardware connection where the MCLR pin1 is connected to GND with 1k resistor. the correct way is to connect MCLR pin1 to 5 V with 1k resistor.

Page 55

Problem 3: even though the ripple DC voltage is obtained in measurement system, the LCD display output according to the ripple DC voltage is not stable still having different values in short period. Reason: if ripple DC voltage is zoomed in, it is AC voltage with very low peak to peak voltage. Hence, PIC ADC module will read the voltage along with sinusoidal of ripple DC voltage. Solution: there is correction in program. The correction is to put the case AAA in front of the program and check the new reading (vol) whether is larger than last reading (t1). If new reading (vol) is larger than the last reading (t1), the program proceeds to calculation and display actual values. If
new reading (vol) is smaller than the last reading (t1), the program goes back case: AAA.

Figure 5.2 Program of AAA loop

Problem 4: there is short circuit caused during the wave measurement in oscilloscope. The oscilloscope is not able to measure the waveform across transformer and input of voltage follower. Reason: in order to implement the wave measurement, there is current generated from oscilloscope. Therefore, any floating point without ground is not the target of oscilloscope. One of the two probes must connect to GND being reference point. Solution: the floating point can be monitor in Multisim using oscilloscope. In practical, the output waveform with common reference point GND can be measured in oscilloscope.

Page 56

Problem 5: During measuring output of voltage follower in the current measurement, the results change when the oscilloscope is attached. As shown below Figure 5.2, the current is not zero when no lamps are on. It shows 1.22A from the current measurement which is not expected.

Figure 5.3 Readings in current measurement with oscilloscope

Reason: as mention in problem 4, the oscilloscope generates current to measure waveform. Solution: there is no solution for this problem since the reason is from the characteristic of oscilloscope.

Problem 6: The output voltage from current measurement is not accurate. With one lamp working, the voltage is 2.1V and with two lamps working the voltage is 2.7 V. they are in the relation of double values. Reason: the capacitor adopted at first is 220uF which is small for discharging and charging. Solution: the designer replaced 220uF with 470uF. The output voltage with two lamps is double of the output voltage with one lamp.

Page 57

5.3 Validity of the project


The components of this project are common in the market. The important component in Intelligent Power Meter is shunt resistor. If the design acquires large current measurement, the shunt resistor must equip with the high power consumption rating and low resistance. With low rating shunt resistor, the maximum current of Intelligent Power Meter is only 0.7A. The power meter is able to measure current and voltage, perform calculation of power consumption and electric bill. The amount of money is able to increment in each one hour. Finally, after one month, PIC16F877A can reset.

5.4 Limitation of Intelligent Power Meter


The project is successfully achieved. But there are few limitations due to the hardware and software. 1. 2. 3. The Intelligent Power Meter cannot work with high current above 0.7A in theory. The time counting for one hour and one month is not accurate on PIC16F877A The operational amplifier MCP6004 in voltage follower is easily damaged.

Page 58

Chapter 6 Conclusion
The process of introduction, designing, implement and constructing is obtained in the previous chapter to achieve the project of Intelligent Power Meter. The innovation of Intelligent Power Meter is the convenience of user. The intelligent part of this project is able to calculate power consumption and electric bill so that the users will not lost the track of how much the power consumption cost to them. The current is represented by voltage using a shunt resistor. The voltage follower is to change the output of shunt resistor with floating point to the voltage output of voltage follower with reference point GND. Because PIC inputs can only be with reference point but not floating point. The rectifier is to convert AC voltage into DC ripple voltage. Then, PIC 16F877A can be stable to calculate. The output of current measurement shows that it is proportional to the current in the AC power line. The voltage is stepped down by transformer and voltage divider in order to compatible with op-amp MCP6004. The function of voltage follower and rectifier has the same functionality with current measurement. As chapter 4 results shown, the voltage output is not affected by adding more devices in AC power line. In conclusion, this project, Intelligent Power Meter is successfully completed based on the results. The aims and objectives are fully achieved.

Page 59

6.1 Technical specifications


No. 1 Technical specification To construct a circuit which is able to measure voltage and current Status and Explanation The shunt resistor, voltage follower and rectifier are constructed in the current measurement design. Status: achieved.

The transformer, voltage divider, voltage follower and rectifier are constructed in voltage measurement design. Status: achieved. 2 The Intelligent Power Meter is able to calculate power consumption and electric bills According to the output from voltage and current measurement system, the PIC16F877 reads the outputs of them and calculate with the outputs. The electric bill increments with Malaysia tariff in every one hour. Status: achieved.

The Intelligent Power Meter is able to display power consumption and electric bills

The PIC control system consists of PIC16F877A and LCD display module. They are interface to display the power consumption and electric bill according to the output from measurement system. Status: achieved.

Intelligent Power Meter can monthly reset

This specification is achieved in programming by adding a loop to check the time is meeting one month. Status: achieved.

Page 60

6.2 Future Enhancement


The table as shown below is providing the future enhancement for others designer refers to. No. 1 Future enhancement Design wireless transmission and database. Explanation In each month, the power meter is able to transmit the data (power consumption and electric bills ) to the database so that it cuts down the cost of workforce so that the whole system does not need workers to go every users home to check the power consumption. 2 Built more robust power meter Short circuit in home appliances is common. If the robust power meter is designed, it prevents any damage from short circuit. Also in order to suit with high load home appliances users, the shunt resistor must with high rating. 3 Improve the accuracy of power meter To meet the accuracy requirement, the designer can apply current precise sensing amplifier instead of voltage follower and rectifier. And shunt resistor with low resistance must be considered in this case.

Page 61

References
Web address 1. Basic electronic concept Available from: http://sci301.uvi.edu/Electrical/ElectricalConcepts.html Last accessed: 20th October 2010 2. HVAC solution from Texas Instruments Available from: http://focus.ti.com/docs/solution/folders/print/399.html Last accessed: 20th October 2010

3. Washing machine: high end solutions from Texas Instruments Available from: http://focus.ti.com/docs/solution/folders/print/397.html Last accessed: 20th October 2010 4. MCP6004 datasheet Available from: http://ww1.microchip.com/downloads/en/DeviceDoc/21733j.pdf Last accessed: 7th January 2011 5. Figure1.1 Table of energy loss due to power meter Available from: http://powerelectronics.com/power_management/motor_power_management/705PET23. pdf Last accessed: 7th January 2011 6. Figure 2.1: Transformer Available from: http://best-b2b.com/userimg/545/570-1/power-transformer-628.jpg Last accessed: 7th January 2011 7. Figure 2.2 LM7805 regulator Available from: http://www.fairchildsemi.com/ds/LM/LM7805.pdf Last accessed: 7th January 2011 8. Figure 2.3 MICW04M bridge rectifier Available from: http://www.binbin.net/photos/dc-components/wo2/wo2-1.5a-200vbridge-rectifier-rc.jpg Last accessed: 7th January 2011

Page 62

9. Figure 2.4 the operation of bridge rectifier Available from: http://www.osha.gov/SLTC/etools/electric_power/illustrated_glossary/substation_equipm ent/rectifiers.html Last accessed: 7th January 2011 10. Figure 2.6 5W 10 shunt resistor Available from: http://www.quickerbuy.com/assets/photo/avatar/51486/big__brtyucwbmk___kgrhqmhceeunsbq1q_blzi6srnn____35.jpg Last accessed: 7th January 2011 11. Figure 2.7 High current rating and low resistance shunt resistor Available from: http://www.rc-electronics-usa.com/current-shunt.html Last accessed: 7th January 2011 12. Figure 2.8 MCP6004 OP-AMP Available from: http://ww1.microchip.com/downloads/en/DeviceDoc/21733j.pdf Last accessed: 7th January 2011 13. Figure 2.9 PIC16F877A Available from: http://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf Last accessed: 7th January 2011 14. Figure 2.10 416 characters LCD Module Available from: http://www.egochina.net.cn/eshop/ebay/Character/JHD762/P1090306.jpg) Last accessed: 7th January 2011 15. MikroC PRO for PIC Available from: http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/ Last accessed: 23rd January 2011 16. Figure 2.11 Electromechanical meter Available from: http://img.diytrade.com/cdimg/214476/1494287/0/1218724437/Single_Phase_Long_Life _Round_Power_Meter.jpg) Last accessed: 23rd January 2011

Page 63

17. Figure 3.4 Voltage follower (unity gain differential amplifier) Available from: http://www.electronics-tutorials.ws/opamp/opamp_5.html Last accessed: 23rd January 2011 18. Figure 3.5 Voltage divider Available from http://www.ehobbycorner.com/pages/tut_resistors.html Last accessed: 23rd January 2011 19. Tariff Rates Available from: http://www.tnb.com.my/tnb/residential/pricing-and-tariff/tariff-rates.html Last Accessed: 2nd February

Page 64

APPENDICES

Page 65

Appendix A: Gantt chart


The Gantt chart shows as below Table 2
Week 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0

Task

Brainstorming and planning Research and information collection First meeting with supervisor Market searching for components Circuit Design Developing subsystem circuit Programming Testing and trouble shooting Integrating subsystems Calibration Project Report Writing

Table 2. Gantt chart Projected

Actual

Page 66

Appendix B: Schematic diagram


1. Measurement system and power supply system

2.

PIC control system

Page 67

Appendix C: PCB layout


1. Measurement system and power supply system

2. PIC control system

Page 68

Appendix D: Software
sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; unsigned char ch; unsigned long u,i,power,m; unsigned int vol,t1=0,cur,t2,a,b=0,c1 = 0; void main() { TRISA=0x03; PORTA=0x00; PORTB=0x00; TRISB=0x00;

//portA RA0 RA1 RA2 are inputs //portB is ouput

INTCON = 0; Lcd_Init(); //initial LCD connected to PORTB LCD_Cmd(_LCD_CLEAR); //clear display LCD_Cmd(_LCD_CURSOR_OFF); //turn cursor off while(1) { AAA:

Page 69

// VOLTAGE vol=ADC_read(1); // get voltage output of voltage measurement system from ADC channel 1 if(vol>=t1){ t1=vol; u=(long)t1*5/1023; // covert adc resolution to voltage u=u*(42957)/100; //calculate actual voltage ch=u/10000 ; // extract 100.00V digit if (ch==0) { LCD_Chr(2,2, 32); // write empty space if digit is 0 } else { LCD_Chr(2,2,48+ch); // write ASCii + CH at 2nd row, 2nd column } ch=(u/1000)%10; // extract 10.00 V LCD_Chr_CP(48+ch); ch=(u/100) %10; // extract 01.00 V LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point LCD_Chr_CP('.'); // write '.' at cursor point ch=(u/10) %10; // extract 00.10 V digit LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point ch=u %10; // extract 00.01 U digit LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point LCD_Chr_CP('V'); LCD_Chr_CP(32); LCD_Chr_CP(32); LCD_Chr_CP(32); LCD_Chr_CP('P'); LCD_Chr_CP('D'); LCD_Chr_CP('o'); // write 'V' at cursor point

Page 70

LCD_Chr_CP('g'); } else if (vol<=t1){ goto AAA; } //CURRENT cur=ADC_read(0); channel 0 t2=0; if(cur>=t2){ t2=cur; i=(long)t2*5/1023; i=i*100/107 ; //get voltage output of current measurement system from ADC

//covert adc resolution to voltage //calclate actual current

ch=i/10000 ; // extract 100.00A digit if (ch==0) { LCD_Chr(1,2, 32); // write empty space if digit is 0 } else { LCD_Chr(1,2,48+ch); // write ASCii + CH at 1st row, 2nd column } ch=(i/1000)%10; // extract 10.00 A digit LCD_Chr_CP(48+ch); // write ASCii + CH at 1st row, 2nd column ch=(i/100) %10; // extract 01.00 A digit LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point LCD_Chr_CP('.'); // write '.' at cursor point ch=(i/10) %10; // extract 00.10 A digit LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point ch=i %10; // extract 00.01 A digit LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point LCD_Chr_CP('A'); // write 'A' at cursor point
Page 71

LCD_Chr_CP(32); LCD_Chr_CP(32); LCD_Chr_CP('W'); LCD_Chr_CP('a'); LCD_Chr_CP('t'); LCD_Chr_CP('t'); LCD_Chr_CP('s'); LCD_Chr_CP('U'); LCD_Chr_CP('P'); } else if (Cur<=t2){ goto AAA; } //POWER power=u*i; ch=power/10000 ; // extract 100.00 W digit if (ch==0) { LCD_Chr(3,2, 32); // write empty space if digit is 0 } else { LCD_Chr(3,2,48+ch); // write ASCii + CH at 3st row, 2nd column } ch=(power/1000)%10; LCD_Chr_CP(48+ch); ch=(power/100) %10; LCD_Chr_CP(48+ch); LCD_Chr_CP('.'); ch=(power/10) %10; LCD_Chr_CP(48+ch); // extract 10.00 W // write ASCii + CH at 1st row, 2nd column // extract 01.00 W // write ASCii + CH at cursor point // write '.' at cursor point // extract 00.10 W // write ASCii + CH at cursor point

ch=power %10; // extract 00.01 W LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point


Page 72

LCD_Chr_CP('W'); //MONEY

// write 'W' at cursor point

if( c1 < 9){ //check whether it reaches 10 second a=power*218/(1000*1000); m=a+b; ch=m/1000000 ; if (ch==0) { LCD_Chr(4,2, 32); // write empty space if digit is 0 } else { LCD_Chr(4,2,48+ch); // write ASCii + CH at 4st row, 2nd column } ch=(m/100000)%10; LCD_Chr_CP(48+ch); ch=(m/10000) %10; LCD_Chr_CP(48+ch); // extract 10.00 RM // write ASCii + CH at 4st row, 2nd column // extract 01.00 RM // write ASCii + CH at cursor point

ch=(m/1000) %10; LCD_Chr_CP(48+ch); LCD_Chr_CP('.'); ch=(m/100) %10; LCD_Chr_CP(48+ch);

// extract 00.10 RM // write ASCii + CH at cursor point // write '.' at cursor point // extract 01.00 RM // write ASCii + CH at cursor point

ch=(m/10) %10; // extract 00.10 RM LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point ch=m %10; // extract 00.01 RM LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point LCD_Chr_CP('R'); LCD_Chr_CP('m'); // write 'R' at cursor point // write 'M' at cursor point

Page 73

c1 = c1 + 1; b=m; delay_ms(1000);} else if( c1 >= 9){ u = 0; i =0; power=0; m=0; b=0; a=0; vol=0; ch=0; c1=0; t1=0; cur=0; t2=0; } goto AAA; } } // if it reaches 10 second reset all parameters

Page 74

Appendix E: List of Components

The components list is shown as below table 3: Components Terminal block Voltage Regulator Tact switch Diode Capacitors Rectifier Transformer 16x4 LCD display PIC16F877A 8M Crystal oscillator Op amp MCP6004 IC Socket PCB Optic Fibre boards Connectors (jumper wire) Lamps Single phase wire Plug Power plug extension Grand total Price per unit (RM) 1.00 1.00 0.40 0.10 0.50 1.00 6.00 36.00 17.50 1.50 6.00 0.5 33.00 0.1 2.00 2.00 1.00 10.00 Units(s) 10 1 1 4 3 2 2 1 1 1 2 2 1 100 5 5 2 1 Price (RM) 10.00 1.00 0.40 0.40 1.50 2.00 12.00 19.00 17.50 1.50 12.00 1.00 33.00 10.00 10,00 10.00 2.00 10.00 RM153.3

Page 75

Вам также может понравиться