power meter design

Upload: ryan-peng-fei

Post on 04-Jun-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Power Meter design

    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

  • 8/13/2019 Power Meter design

    2/86

    Pa

    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 designerspractical skills on hardware

    and software.

  • 8/13/2019 Power Meter design

    3/86

    Pag

    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.

  • 8/13/2019 Power Meter design

    4/86

    Pag

    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

    14thJune 2011

  • 8/13/2019 Power Meter design

    5/86

    Pag

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

  • 8/13/2019 Power Meter design

    6/86

    Pag

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

  • 8/13/2019 Power Meter design

    7/86

    Pag

    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 .............................................................................................................. 66Appendix B: Schematic diagram .................................................................................................. 67

    Appendix C: PCB layout .............................................................................................................. 68

    Appendix D: Software .................................................................................................................. 69

    Appendix E: List of Components ................................................................................................. 75

  • 8/13/2019 Power Meter design

    8/86

    Page

    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 rectifier7

    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

  • 8/13/2019 Power Meter design

    9/86

    Page

    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 current33

    Figure 4.6 Waveform of output voltage from shunt resistor...34

    Figure 4.7 Waveform of output voltage from voltage follower in current measurement35

    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

  • 8/13/2019 Power Meter design

    10/86

    Pag

    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 lamps46

    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 LCD55

    Figure 5.2 Program of AAA loop56

    Figure 5.3 Readings in current measurement with oscilloscope.57

  • 8/13/2019 Power Meter design

    11/86

  • 8/13/2019 Power Meter design

    12/86

    Page 1

    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 ofwire 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]

  • 8/13/2019 Power Meter design

    13/86

    Page 2

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

  • 8/13/2019 Power Meter design

    14/86

    Page 3

    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.

  • 8/13/2019 Power Meter design

    15/86

    Page 4

    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

  • 8/13/2019 Power Meter design

    16/86

    Page 5

    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

    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

    produced. The secondary voltage is proportional to the primary voltage with the ratio of

    Figure 2.1: Transformer [6]

  • 8/13/2019 Power Meter design

    17/86

    Page 6

    the number of turns in secondary coil to the number of turns in the primary coil. Theformula of this fact is shown as below:

    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]

  • 8/13/2019 Power Meter design

    18/86

    Page 7

    2.2.2.2 Rectifier

    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 inthe same direction through the load.

    Figure 2.3 MICW04M bridge rectifier [8]

    Figure 2.4 The operation of bridge rectifier [9]

  • 8/13/2019 Power Meter design

    19/86

    Page 8

    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.

    5W10Neutral

    Line

    Current I

    Voltage V

    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.

    Figure 2.5 Connection shunt resistor

  • 8/13/2019 Power Meter design

    20/86

  • 8/13/2019 Power Meter design

    21/86

  • 8/13/2019 Power Meter design

    22/86

    Page 11

    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.

    Comparing to others PIC microcontroller with PIC16F877A, PIC16F877A meets the

    requirements of ADC converter, I/O port, EEPRO M and oscillator.

    Fi ure 2.9 PIC16F877A 13

  • 8/13/2019 Power Meter design

    23/86

    Page 12

    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.

    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.

    Figure 2.10 416 characters LCD Module [14]

  • 8/13/2019 Power Meter design

    24/86

    Page 13

    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.

    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.

    Figure 2.11 Electromechanical meter [16]

  • 8/13/2019 Power Meter design

    25/86

  • 8/13/2019 Power Meter design

    26/86

    Page 15

    3.2 Power supply system

    The circuit design of power supply system from 10VAC to 5VDC is drawn in EAGLE

    software as shown below:

    GND

    10VAC

    RectifierRegulator

    5VDC

    GND

    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 . Therefore, the output of LM7805 or the output of

    power supply system is

    Figure 3.2 The circuit of power supply system

  • 8/13/2019 Power Meter design

    27/86

    Page 16

    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

    Current measurement

    Voltage divider Voltage

    follower

    Voltage

    follower

    Rectifier

    Rectifier

    Output of

    transformer

    Output of shunt

    resistor

    PIC ADC chann

    PIC ADC chann

    V3

    V4

    V1

    V2

    Figure3.3 The circuit of measurement system

  • 8/13/2019 Power Meter design

    28/86

    Page 17

    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.

  • 8/13/2019 Power Meter design

    29/86

    Page 18

    3.3.1.2 Voltage follower

    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 voltageThe 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.7Kas protecting resistors.

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

  • 8/13/2019 Power Meter design

    30/86

    Page 19

    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 rectifiertakes 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

    The ratio of two resistors and is determined the output voltage. After thetransformer, 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:

    Figure 3.5 Voltage divider [18]

  • 8/13/2019 Power Meter design

    31/86

    Page 20

    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

  • 8/13/2019 Power Meter design

    32/86

    Page 21

    calculation to gain the actual current and voltage. These actual values will be showed on the

    LCD display module.

    5V

    GND

    Output of voltage

    measurement

    Output of current

    measurement

    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.

    Figure 3.6 Schematic diagram of PIC control system

  • 8/13/2019 Power Meter design

    33/86

    Page 22

    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 PIC port B pins

    Pin1 Ground

    Pin2 5V

    Pin3 Ground with 1K resistor

    Pin4 Pin 37 RB4

    Pin5 Ground

    Pin6 Pin 38 RB5

    Pin7 Null

    Pin8 Null

    Pin9 Null

    Pin10 Null

    Pin11 Pin 33 RB0

    Pin12 Pin 34 RB1

    Pin13 Pin 35 RB2

    Pin14 Pin 36 RB3

    Pin15 5V

    Pin16 Ground

    Figure 3.7 Schematic of PIC16F877A

  • 8/13/2019 Power Meter design

    34/86

    Page 23

    5V

    Ground

    PIC16F877F

    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 reading2. Current reading3. Power consumption and electric bill calculation

    Figure 3.8 Schematic of LCD display module

  • 8/13/2019 Power Meter design

    35/86

    Page 24

    Start

    Initialization

    Is curret reading

    larger than last

    reading?

    Case:AAA

    No

    Yes

    Calculate and

    display actual

    voltage

    Read from analog

    input channel 1

    No

    Yes

    Calculate and

    display actual

    current

    Read from analog

    input channel 0

    Calculate and

    display power

    consumption P=VI

    Calculate electric

    bill

    Is curret reading

    larger than last

    reading?

    After 1 hour,

    electric bill

    increment

    After 1 month,

    power meter reset.

    Voltage

    reading

    Current

    reading

    Power

    consumption

    and electric bill

    Figure 3.9 Flow chart of power meter

  • 8/13/2019 Power Meter design

    36/86

    Page 25

    3.4.2.1 Initialization

    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 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.10 Configuration of LCD display module

    Figure 3.11 Initialization of parameters

    Figure 3.12 Confi uration of in ut and out ut orts

  • 8/13/2019 Power Meter design

    37/86

    Page 26

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

    Figure 3.13 Calculation of voltage

  • 8/13/2019 Power Meter design

    38/86

    Page 27

    Because the operation in MikroC pro does not accept decimal, 429.57 is represented by

    42957/100.

    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 isthe output from voltage and current calculation.

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

    Figure 3.14 Calculation of current

    Figure 3.15 Calculation of power consumption

  • 8/13/2019 Power Meter design

    39/86

    Page 28

    C1< 9

    a=power0.218RM/kwh

    Display amount ofelectric bill

    m=a+b

    Voltage, current,power consumption

    calculation

    Initializationb=0

    Case:AAA

    C1=C1+1

    b=m

    Reset

    Delay 1 second

    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

    Figure 3.16 Calculation of electric bill

  • 8/13/2019 Power Meter design

    40/86

    Page 29

    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

  • 8/13/2019 Power Meter design

    41/86

    Page 30

    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, thedesigner 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.

  • 8/13/2019 Power Meter design

    42/86

    Page 31

    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.

    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.

    `

    Figure 4.1 Simulation of power supply system

  • 8/13/2019 Power Meter design

    43/86

    Page 32

    Figure 4.2 is showing that of the transformer output is 11.173V.And .

    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.

    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,

    Figure 4.2 Waveform of the output from transformer

    Figure 4.3 Waveform of the output from bridge rectifier

  • 8/13/2019 Power Meter design

    44/86

    Page 33

    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.4 Waveform of the output from LM7805 voltage regulator

    Figure 4.5Simulation of measuring current

  • 8/13/2019 Power Meter design

    45/86

  • 8/13/2019 Power Meter design

    46/86

    Page 35

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

    0.09VAC shown in Figure 4.5 XMM3. The ratio between voltage followerand 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 butonly 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

  • 8/13/2019 Power Meter design

    47/86

    Page 36

    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

  • 8/13/2019 Power Meter design

    48/86

    Page 37

    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, , , andoutput 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.

    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 0.234V from section 4.1.2.1Shunt resistor is

    Figure 4.9 Simulation of measuring current on two lamps

  • 8/13/2019 Power Meter design

    49/86

    Page 38

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

    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.10 Waveform of voltage across shunt resistor in the simulation with two lamps

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

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

  • 8/13/2019 Power Meter design

    50/86

  • 8/13/2019 Power Meter design

    51/86

    Page 40

    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.

    4.1.4.2 Transformer

    Figure 4.14 Workability of measuring voltage in Multisim

    Figure 4.15 Workability of measuring voltage in Multisim

  • 8/13/2019 Power Meter design

    52/86

    Page 41

    The output from transformer is obtained as above in Figure 4.15. is 0.904V.Then, . is 1.818V. This output will be the input forvoltage 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 getthe output across line 10 and line 11

    Figure 4.16 Voltage across line 8 and line10

  • 8/13/2019 Power Meter design

    53/86

    Page 42

    4.1.4.3 Voltage follower

    The output 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.17 Output voltage of voltage follower on voltage

    Figure 4.18 Output voltage of rectifier on voltage measurement

  • 8/13/2019 Power Meter design

    54/86

    Page 43

    The output of this rectifier in Figure 4.18 is 391.615nV. Then, without proper inputfrom 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

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

    actual current one lamp draws.

    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.

    Figure 4.19 Output of shunt resistor with one lamp

    Figure 4.20 Output of shunt resistor with two lamps

  • 8/13/2019 Power Meter design

    55/86

    Page 44

    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.21 Output of voltage follower with one lamp

    Figure 4.23Output of voltage follower with two lamps

    Figure 4.22 Waveform of voltage follower with one lamp

  • 8/13/2019 Power Meter design

    56/86

    Page 45

    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

    .

    Comparing Figure 4.21 and Figure 4.23, the Vamp ( ) of waveform in voltagefollower with two lamps is about double of the Vamp ( ) of waveform in voltagefollower 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.

    Figure 4.25 Output of rectifier with one lamp

    Figure 4.24 Waveform of voltage follower with two lamps

  • 8/13/2019 Power Meter design

    57/86

    Page 46

    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. . In the waveformof rectifier with two lamps in Figure 4.28, its amplitude is 3.24VDC.

    Figure 4.27 Output of rectifier with two lamp

    Figure 4.26 Waveform of rectifier with one lamp

    Figure 4.28 Waveform of rectifier with two lamps

  • 8/13/2019 Power Meter design

    58/86

  • 8/13/2019 Power Meter design

    59/86

    Page 48

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

    ratio between voltage divider and transformer is

    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 .

    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

    Figure 4.32 AC output of voltage follower

    Figure 4.33 DC output of voltage follower

  • 8/13/2019 Power Meter design

    60/86

    Page 49

    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 inFigure 4.36 has the amplitude 0.560mV with ripple voltage.

    Figure 4.35 Output of rectifier

    Figure 4.34 Waveform of voltage follower

    Figure 4.36 Waveform of rectifier

  • 8/13/2019 Power Meter design

    61/86

    Page 50

    4.2.3 Power supply system

    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

    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 powerconsumption with increment with 1 second time.

    Figure 4.38 LCD display with one lamp

    Figure 4.37 Output of power supply syestem

  • 8/13/2019 Power Meter design

    62/86

    Page 51

    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

    . It shows that with more

    devices adding the voltage stays at 244.14V.

    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.

    VThe 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

    Figure 4.39 LCD display with two lamps

    Figure 4.40 ADC module readings

  • 8/13/2019 Power Meter design

    63/86

    Page 52

    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 Power plug

    from wall outlet

    TransformerShunt

    resistor

    Power supply

    system

    Voltage

    follower

    Rectifier

    Voltage divider

    PIC control

    system with

    LCD

    Measurement

    system

    As shown in Figure 4.42, the hardware of power supply system, measurement system and

    PIC control system are constructed on PCB board.

    Figure 4.41 The display of electric bill

    Figure 4.42 Hardware construction

  • 8/13/2019 Power Meter design

    64/86

    Page 53

    Chapter 5

    Discussion

    5.1 Result discussion

    Systems Parts Theory

    (output)

    Simulation

    approach(output)

    Practical approach(output)

    Power supply

    system

    Regulator 4.9VDC 5.001VDC 4.98VDC

    Current

    measurement

    Shunt resistor 1.69VAC 1.65VACRatio

    0.545

    1.696VAC

    Ratio

    0.579

    Voltage follower 0.9VAC(M)1.65VAC(O)

    0.983VAC(M)

    1.27VAC(O)Rectifier 0.175uVDC 1.788VDC

    Voltage

    measurement

    Transformer 9.8VAC 0.639VAC Ratio to

    58mV is

    0.09

    10.3VAC Ratio to

    0.87V is

    0.0834

    Voltage divider 0.882VC 58mVAC Ratio

    0.001

    0.87VAC Ratio

    0.534Voltage follower

    63.6uVAC 0.456VAC(M)

    0.47VAC(O)

    Rectifier 91.615nVDC 0.568VDC(M)0.560VDC(o)

    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.

    Table 1 Results

  • 8/13/2019 Power Meter design

    65/86

    Page 54

    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 is0.09. And the ratio between them in practical approach is 0.0824. It proves that transformer

    and voltage divider are operating.

  • 8/13/2019 Power Meter design

    66/86

    Page 55

    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

    1stand third row.

    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.

    Figure 5.1 Fault in LCD

  • 8/13/2019 Power Meter design

    67/86

    Page 56

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

    Problem 4: there is short circuit caused during the wave measurement in oscilloscope. Theoscilloscope 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.

    Figure 5.2 Program of AAA loop

  • 8/13/2019 Power Meter design

    68/86

    Page 57

    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.

    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.

    Figure 5.3 Readings in current measurement with oscilloscope

  • 8/13/2019 Power Meter design

    69/86

    Page 58

    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. The Intelligent Power Meter cannot work with high current above 0.7A in theory.2. The time counting for one hour and one month is not accurate on PIC16F877A3. The operational amplifier MCP6004 in voltage follower is easily damaged.

  • 8/13/2019 Power Meter design

    70/86

    Page 59

    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.

  • 8/13/2019 Power Meter design

    71/86

    Page 60

    6.1 Technical specifications

    No. Technical specification Status and Explanation

    1 To construct a circuit which is able to

    measure voltage and current

    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.

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

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

  • 8/13/2019 Power Meter design

    72/86

    Page 61

    6.2 Future Enhancement

    The table as shown below is providing the future enhancement for others designer refers to.

    No. Future enhancement Explanation

    1 Design wireless transmission and

    database.

    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.

  • 8/13/2019 Power Meter design

    73/86

    Page 62

    References

    Web address

    1. Basic electronic conceptAvailable from: http://sci301.uvi.edu/Electrical/ElectricalConcepts.htmlLast accessed: 20th October 2010

    2. HVAC solution from Texas InstrumentsAvailable from: http://focus.ti.com/docs/solution/folders/print/399.html

    Last accessed: 20th October 2010

    3. Washing machine: highend solutions from Texas InstrumentsAvailable from: http://focus.ti.com/docs/solution/folders/print/397.html

    Last accessed: 20th October 2010

    4. MCP6004 datasheetAvailable 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 meterAvailable from:

    http://powerelectronics.com/power_management/motor_power_management/705PET23.

    pdf

    Last accessed: 7th January 2011

    6. Figure 2.1: TransformerAvailable from: http://best-b2b.com/userimg/545/570-1/power-transformer-628.jpg

    Last accessed: 7th January 2011

    7. Figure 2.2 LM7805 regulatorAvailable from: http://www.fairchildsemi.com/ds/LM/LM7805.pdf

    Last accessed: 7th January 2011

    8. Figure 2.3 MICW04M bridge rectifierAvailable from:http://www.binbin.net/photos/dc-components/wo2/wo2-1.5a-200v-

    bridge-rectifier-rc.jpg

    Last accessed: 7th January 2011

    http://www.binbin.net/photos/dc-components/wo2/wo2-1.5a-200v-bridge-rectifier-rc.jpghttp://www.binbin.net/photos/dc-components/wo2/wo2-1.5a-200v-bridge-rectifier-rc.jpghttp://www.binbin.net/photos/dc-components/wo2/wo2-1.5a-200v-bridge-rectifier-rc.jpghttp://www.binbin.net/photos/dc-components/wo2/wo2-1.5a-200v-bridge-rectifier-rc.jpg
  • 8/13/2019 Power Meter design

    74/86

    Page 63

    9. Figure 2.4 the operation of bridge rectifierAvailable 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 resistorAvailable from:

    http://www.quickerbuy.com/assets/photo/avatar/51486/big__brtyucwbmk___kgrhqmh-

    ceeunsbq1q_blzi6srnn____35.jpg

    Last accessed: 7th January 2011

    11.Figure 2.7 High current rating and low resistance shunt resistorAvailable from: http://www.rc-electronics-usa.com/current-shunt.html

    Last accessed: 7th January 2011

    12.Figure 2.8 MCP6004 OP-AMPAvailable from:http://ww1.microchip.com/downloads/en/DeviceDoc/21733j.pdf

    Last accessed: 7th January 2011

    13.Figure 2.9 PIC16F877AAvailable from:http://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf

    Last accessed: 7th January 2011

    14.Figure 2.10 416 characters LCD ModuleAvailable from:

    http://www.egochina.net.cn/eshop/ebay/Character/JHD762/P1090306.jpg)

    Last accessed: 7th January 2011

    15.MikroC PRO for PICAvailable from: http://www.mikroe.com/eng/products/view/7/mikroc-pro-for-pic/

    Last accessed: 23rd January 2011

    16.Figure 2.11 Electromechanical meterAvailable from:

    http://img.diytrade.com/cdimg/214476/1494287/0/1218724437/Single_Phase_Long_Life

    _Round_Power_Meter.jpg)

    Last accessed: 23rd January 2011

    http://www.osha.gov/SLTC/etools/electric_power/illustrated_glossary/substation_equipment/rectifiers.htmlhttp://www.osha.gov/SLTC/etools/electric_power/illustrated_glossary/substation_equipment/rectifiers.htmlhttp://www.quickerbuy.com/assets/photo/avatar/51486/big__brtyucwbmk___kgrhqmh-ceeunsbq1q_blzi6srnn____35.jpghttp://www.quickerbuy.com/assets/photo/avatar/51486/big__brtyucwbmk___kgrhqmh-ceeunsbq1q_blzi6srnn____35.jpghttp://ww1.microchip.com/downloads/en/DeviceDoc/21733j.pdfhttp://ww1.microchip.com/downloads/en/devicedoc/39582b.pdfhttp://www.egochina.net.cn/eshop/ebay/Character/JHD762/P1090306.jpghttp://img.diytrade.com/cdimg/214476/1494287/0/1218724437/Single_Phase_Long_Life_Round_Power_Meter.jpghttp://img.diytrade.com/cdimg/214476/1494287/0/1218724437/Single_Phase_Long_Life_Round_Power_Meter.jpghttp://img.diytrade.com/cdimg/214476/1494287/0/1218724437/Single_Phase_Long_Life_Round_Power_Meter.jpghttp://img.diytrade.com/cdimg/214476/1494287/0/1218724437/Single_Phase_Long_Life_Round_Power_Meter.jpghttp://www.egochina.net.cn/eshop/ebay/Character/JHD762/P1090306.jpghttp://ww1.microchip.com/downloads/en/devicedoc/39582b.pdfhttp://ww1.microchip.com/downloads/en/DeviceDoc/21733j.pdfhttp://www.quickerbuy.com/assets/photo/avatar/51486/big__brtyucwbmk___kgrhqmh-ceeunsbq1q_blzi6srnn____35.jpghttp://www.quickerbuy.com/assets/photo/avatar/51486/big__brtyucwbmk___kgrhqmh-ceeunsbq1q_blzi6srnn____35.jpghttp://www.osha.gov/SLTC/etools/electric_power/illustrated_glossary/substation_equipment/rectifiers.htmlhttp://www.osha.gov/SLTC/etools/electric_power/illustrated_glossary/substation_equipment/rectifiers.html
  • 8/13/2019 Power Meter design

    75/86

    Page 64

    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 dividerAvailable fromhttp://www.ehobbycorner.com/pages/tut_resistors.html

    Last accessed: 23rd January 2011

    19.Tariff RatesAvailable from: http://www.tnb.com.my/tnb/residential/pricing-and-tariff/tariff-rates.html

    Last Accessed: 2nd February

    http://www.ehobbycorner.com/pages/tut_resistors.htmlhttp://www.ehobbycorner.com/pages/tut_resistors.html
  • 8/13/2019 Power Meter design

    76/86

    Page 65

    APPENDICES

  • 8/13/2019 Power Meter design

    77/86

    Page 66

    Appendix A: Gantt chart

    The Gantt chart shows as below Table 2

    Table 2. Gantt chart

    Projected

    Actual

    Task3 4 5 6 7 8 9 1

    011

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    Brainstorming

    and planning

    Research and

    information

    collection

    First meeting

    withsupervisor

    Marketsearching forcomponents

    Circuit Design

    Developingsubsystemcircuit

    Programming

    Testing and

    troubleshooting

    Integratingsubsystems

    Calibration

    Project ReportWriting

    Week

  • 8/13/2019 Power Meter design

    78/86

    Page 67

    Appendix B: Schematic diagram

    1. Measurement system and power supply system

    2. PIC control system

  • 8/13/2019 Power Meter design

    79/86

    Page 68

    Appendix C: PCB layout

    1. Measurement system and power supply system

    2. PIC control system

  • 8/13/2019 Power Meter design

    80/86

    Page 69

    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 RA0 RA1 RA2 are inputs

    PORTA=0x00;

    PORTB=0x00; //portB is ouput

    TRISB=0x00;

    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:

  • 8/13/2019 Power Meter design

    81/86

    Page 70

    // 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 pointLCD_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'); // write 'V' at cursor point

    LCD_Chr_CP(32);

    LCD_Chr_CP(32);

    LCD_Chr_CP(32);

    LCD_Chr_CP('P');

    LCD_Chr_CP('D');

    LCD_Chr_CP('o');

  • 8/13/2019 Power Meter design

    82/86

    Page 71

    LCD_Chr_CP('g');

    }

    else if (vol=t2){

    t2=cur;

    i=(long)t2*5/1023; //covert adc resolution to voltage

    i=i*100/107 ; //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

  • 8/13/2019 Power Meter design

    83/86

    Page 72

    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

  • 8/13/2019 Power Meter design

    84/86

    Page 73

    LCD_Chr_CP('W'); // write 'W' at cursor point

    //MONEY

    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; // extract 10.00 RM

    LCD_Chr_CP(48+ch); // write ASCii + CH at 4st row, 2nd column

    ch=(m/10000) %10; // extract 01.00 RM

    LCD_Chr_CP(48+ch); // write ASCii + CH at cursor point

    ch=(m/1000) %10; // extract 00.10 RMLCD_Chr_CP(48+ch); // write ASCii + CH at cursor point

    LCD_Chr_CP('.'); // write '.' at cursor point

    ch=(m/100) %10; // extract 01.00 RM

    LCD_Chr_CP(48+ch); // 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'); // write 'R' at cursor point

    LCD_Chr_CP('m'); // write 'M' at cursor point

  • 8/13/2019 Power Meter design

    85/86

    Page 74

    c1 = c1 + 1;

    b=m;

    delay_ms(1000);}

    else if( c1 >= 9){ // if it reaches 10 second reset all parameters

    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;

    }

    }

  • 8/13/2019 Power Meter design

    86/86

    Appendix E: List of Components

    The components list is shown as below table 3:

    Components Price per unit (RM) Units(s) Price (RM)

    Terminal block 1.00 10 10.00

    Voltage Regulator 1.00 1 1.00

    Tact switch 0.40 1 0.40

    Diode 0.10 4 0.40

    Capacitors 0.50 3 1.50

    Rectifier 1.00 2 2.00

    Transformer 6.00 2 12.00

    16x4 LCD display 36.00 1 19.00

    PIC16F877A 17.50 1 17.50

    8M Crystal oscillator 1.50 1 1.50

    Op amp MCP6004 6.00 2 12.00

    IC Socket 0.5 2 1.00

    PCB Optic Fibre boards 33.00 1 33.00

    Connectors (jumper wire) 0.1 100 10.00

    Lamps 2.00 5 10,00

    Single phase wire 2.00 5 10.00

    Plug 1.00 2 2.00

    Power plug extension 10.00 1 10.00

    Grand total RM153.3