Develop, implement and characterize an electric energy … · Develop, implement and characterize...

82
Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the Master of Science Degree in Electronics Engineering Supervisor: Prof. Pedro Miguel Pinto Ramos Examination Committee Chairperson: Prof. Pedro Manuel Brito da Silva Gir˜ ao Supervisor: Prof. Pedro Miguel Pinto Ramos Member of the Committee: Prof. Jos´ e Fernando Alves da Silva October 2018

Transcript of Develop, implement and characterize an electric energy … · Develop, implement and characterize...

Page 1: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Develop, implement and characterize an electric energymonitoring device

Bernardo Ribeiro de Matos

Thesis to obtain the Master of Science Degree in

Electronics Engineering

Supervisor: Prof. Pedro Miguel Pinto Ramos

Examination Committee

Chairperson: Prof. Pedro Manuel Brito da Silva GiraoSupervisor: Prof. Pedro Miguel Pinto Ramos

Member of the Committee: Prof. Jose Fernando Alves da Silva

October 2018

Page 2: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the
Page 3: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Acknowledgments

Firstly, I would like to thank my family and friends for their support during the five years at Instituto

Superior Tecnico. I would also want to thank the Instituto de Telecomunicacoes for the conditions and

materials provided for the completion of dissertation.

Page 4: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the
Page 5: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Abstract

This project consists in developing, implementing and characterizing a small size energy monitoring

device to be used in the long-term monitoring of the energy consumption of a single mains connected

device.

Nowadays, the number of electronic devices are increasing, as well as the need for smaller, more

accurate and low consumption energy metering systems. The electromechanical meters are still widely

used to measure the overall consumption of a power utilities client. Currently, they are being replaced

due to their limitations and their replacements are electronic meters that, in addition to performing the

same functionalities of electromechanical, are capable of distinguishing between hourly rates, store data

and remotely transfer it to the electricity provider. The objective of the prototype to be developed in this

work is not to replace the electromechanical meters or to provide a new device to measure the overall

power consumption of a client. The developed device objective is to monitor the power consumption of

one single mains connected device (for example, a TV, a refrigerator or a washing machine).

The proposed energy metering solution includes: i) voltage and current sensors to interface with the

mains; ii) an energy metering specific integrated circuit and a microcontroller. A resistive voltage divider

is used as a voltage sensor and a Shunt Resistor is used to sense the current. To process the data from

the metering Integrated Circuit (IC), a Peripheral Interface Controller (PIC) is used. This microcontroller

controlls the flow of data from the energy metering IC to the user, storing data in a flash memory,

implements a remote communication protocol. The system is powered by an AC/DC capacitive power

supply and in case of a power failure, a battery is used to acquire the last values of power consumed

before the failure.

The acquired information is stored in a microSD memory card, using the File Allocation Table (FAT)

filesystem. Using this interface the data saved in memory card can be read in a computer.

Alternatively, to analyze the power consumption, an Android Application is used. This app communi-

cates via Bluetooth and displays the information the user wants to analyze.

iii

Page 6: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Keywords

Energy metering, Power, Energy, Power Supply, Signal Conditioning, Microcontroller.

iv

Page 7: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Resumo

Este projecto consiste no desenvolvimento, implementacao e caracterizacao de um dispositivo de

pequeno tamanho capaz de realizar monitorizacao a longo prazo do consumo de energia de um unico

equipamento electrico monofasico.

Nos dias de hoje, o numero de dispositivos eletronicos tem vindo a aumentar, assim como a ne-

cessidade de sistemas de medicao de energia mais pequenos, mais exactos e com menor consumo

de energia. Os contadores electromecanicos sao ainda muito utilizados para a medicao da energia

total consumida pelos equipamentos do cliente. Devido as suas limitacoes, tem vindo a ser substitu-

idos por contadores eletronicos que para alem das mesmas funcionalidades, sao ainda capazes de

distinguir precos por hora, guardar e transmitir a informacao para o consumidor ou fornecedor de ener-

gia remotamente. O objectivo do prototipo a desenvolver neste trabalho nao e substituir os medidores

electromagneticos ou fornecer um novo servico de medicao de energia total consumida pelo cliente. O

objectivo e monitorizar o consumo the um unico dispositivo, como por exemplo uma televisao, frigorifico

ou maquina de lavar.

A solucao de medicao proposta inclui: i) sensores de tensao e corrente que interagem com o dis-

positivo; ii) circuito integrado de medicao de energia especıfico e um microcontrolador. Um divisor

resistivo e utilizado como sensor de tensao e uma resistencia Shunt e utilizada para medir a corrente.

Para processar a informacao proveniente do circuito integrado, e utilizado um microcontrolador. Este

microcontrolador controla o fluxo de informacao desde o circuito integrado de medicao de energia ate

ao utilizador, guarda a informacao numa memoria Flash, implementa um protocolo de comunicacao re-

mota. O sistema e alimentado por uma fonte de alimentacao capacitiva e, em caso de falha de energia,

por uma bateria de modo a que nao seja perdida informacao.

A informacao adquirida e guardada num cartao de memoria microSD, usando o sistema de ficheiros

FAT. Usando esta interface os dados guardados no cartao de memoria podem ser lidos em qualquer

computador.

Em alternativa, para analisar o consumo de potencia, uma applicacao Android pode ser usada.

Esta applicacao comunica com o dispositivo via Bluetooth e e mostrada a informacao desejada pelo

utilizador.

v

Page 8: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Palavras Chave

Contador de energia, Potencia, Energia, Fonte de Alimentacao, Condicionamento de Sinal, Microcon-

trolador.

vi

Page 9: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Contents

1 Introduction 1

1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.2 Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.3 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.4 Document Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.5 Electric Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 State of the Art 9

2.1 Electromechanical Meters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.2 Electronic Meters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.3 Voltage Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.4 Current Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2.5 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.6 Wireless Communication - Bluetooth Low Energy . . . . . . . . . . . . . . . . . . . . . . . 20

2.7 Previous Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.7.1 Electric Energy meter for low voltage usage . . . . . . . . . . . . . . . . . . . . . . 24

2.7.2 Three-phase energy metering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.7.3 DSP-based three-phase power quality measurement system . . . . . . . . . . . . 24

2.8 Electronic Metering Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3 System Architecture 27

3.1 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

3.2 Energy Metering Integrated Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

3.3 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

3.4 Signal Conditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

3.4.1 Current Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

3.4.2 Voltage Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

3.5 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

3.5.1 FAT file system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

vii

Page 10: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

3.5.2 microSD Card Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

3.6 Battery Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

3.7 Bluetooth Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4 Results 43

4.1 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.2 Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.3 Smartphone Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

4.4 Energy Metering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

5 Conclusions 53

Bibliography 57

A Appendix - Hardware Circuit 61

viii

Page 11: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

List of Figures

1.1 Power vectors triangle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2.1 Representation of an Electromechanical Meter. Extracted from [4] . . . . . . . . . . . . . 12

2.2 Voltage sensor circuit based on a transformer. . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.3 Voltage sensor circuit based on a resistive divisor. . . . . . . . . . . . . . . . . . . . . . . 13

2.4 Current sensor using a Shunt Resistor circuit. . . . . . . . . . . . . . . . . . . . . . . . . . 14

2.5 Current transformer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.6 Basic transformer-based power supply circuit. . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.7 Resistive transformerless power supply circuit. . . . . . . . . . . . . . . . . . . . . . . . . 17

2.8 Zener diode in conduction zone represented as shaded. . . . . . . . . . . . . . . . . . . . 18

2.9 Capacitive transformerless power supply circuit. . . . . . . . . . . . . . . . . . . . . . . . 19

2.10 Capacitive transformerless power supply with full wave bridge rectifier. . . . . . . . . . . . 19

2.11 Capacitive transformerless power supply with full wave bridge rectifier and safety concerns. 20

2.12 Bluetooth Low Energy (BLE) protocol stack architecture. Extracted from [20]. . . . . . . . 21

2.13 BLE data protocol stack schematic. Extracted from [20]. . . . . . . . . . . . . . . . . . . . 22

2.14 BLE packets format. Extracted from [20]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3.1 System Block diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.2 PIC24FJ128GA010 from Microchip Technology. . . . . . . . . . . . . . . . . . . . . . . . . 30

3.3 Functional Block Diagram of ADE7753. Extracted from [29]. . . . . . . . . . . . . . . . . . 31

3.4 Energy Counter IC RMS value measurement block diagram. Extracted from [29]. . . . . . 32

3.5 Active Power Measurement Block Diagram. Extracted from [29]. . . . . . . . . . . . . . . 33

3.6 Reactive Power Measurement Block Diagram. Extracted from [29]. . . . . . . . . . . . . . 33

3.7 Apparent Power Measurement Block Diagram. Extracted from [29]. . . . . . . . . . . . . . 34

3.8 Interface between the PIC and the microSD Card. . . . . . . . . . . . . . . . . . . . . . . 36

3.9 FAT file system table. Extracted from [32]. . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

3.10 Power path management block diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

ix

Page 12: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

3.11 RN4871 Bluetooth Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

3.12 Timing characteristics of RN4871 Bluetooth Module after Reset. . . . . . . . . . . . . . . 41

3.13 Timing characteristics of RN4871 Bluetooth Module when powered on. . . . . . . . . . . 42

4.1 Average Output Voltage with different loads. . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.2 Comparison between voltage calibrated values and real values. . . . . . . . . . . . . . . . 47

4.3 Comparison between current calibrated values and real values. . . . . . . . . . . . . . . . 48

4.4 Application Screens. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

4.5 RMS Current for a 300 Ω Resistor Load. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

4.6 RMS Voltage for a 300 Ω Resistor Load. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

4.7 Active Power for a 300 Ω Resistor Load. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

4.8 Root Mean Square (RMS) Voltage for a refrigerator. . . . . . . . . . . . . . . . . . . . . . 51

4.9 RMS Current for a refrigerator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

4.10 Power consumed by a refrigerator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

A.1 Bottom Layer (a) and Top Layer (b) of the circuit printed circuit board. . . . . . . . . . . . 63

A.2 Power Supply Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

A.3 Voltage and Current Conditioning Circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

A.4 ADE7753 energy measuring circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

x

Page 13: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

List of Tables

1.1 Main specifications for the device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.1 Comparison between current sensor types. . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.2 Wireless technologies comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

2.3 Comparison between classic and low energy Bluetooth . . . . . . . . . . . . . . . . . . . 23

3.1 Maximum Input Signal Levels for Channel 1. . . . . . . . . . . . . . . . . . . . . . . . . . . 32

3.2 Absolute Maximum Ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

3.3 General Description of RN4871 Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

3.4 Electric Characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

3.5 Current Cunsumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

3.6 Bluetooth BaudRate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

4.1 Comparison between read voltage values and true values . . . . . . . . . . . . . . . . . . 46

4.2 Comparison between read current values and true values . . . . . . . . . . . . . . . . . . 47

A.1 Circuit sizing values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

xi

Page 14: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

xii

Page 15: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Acronyms

AC Alternate Current

ADC Analog-to-Digital Converter

ATT Attribute Protocol

BLE Bluetooth Low Energy

DC Direct Current

CRC Cyclic Redundancy Check

dsPIC Digital Signal Peripheral Interface Controller

FAT File Allocation Table

FRC Fast Internal Clock

GAP Generic Access Profile

GATT Generic Attributes

GFSK Gaussian Frequency-Shift Keying

I/O Input/Output

IC Integrated Circuit

IST Instituto Superior Tecnico

L2CAP Logical Link Control and Adaptation Layer

LCD Liquid Crystal Display

PDU Protocol Data Unit

PGA Programmable-Gain Amplifier

xiii

Page 16: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

PIC Peripheral Interface Controller

RMS Root Mean Square

SAR Successive Approximation Register

SD Secure Digital

SM Security Manager

SMD Surface-Mount Device

SPI Serial Peripheral Interface

UART Universal Asynchronous Receiver-Transmitter

xiv

Page 17: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

1Introduction

Contents

1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.2 Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.3 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.4 Document Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.5 Electric Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1

Page 18: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

2

Page 19: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

1. Introduction

Electromechanical energy metering devices present on houses are obsolete, with measurement

limitations, this type of meters only measures active or reactive energy. To measure energy consumption

the voltage and current must be measured [1].

In this project the development of a small sized energy meter is described. The energy metering

device developed will perform an intensive consumption monitoring of a single electronic equipment

connected to a Schuko connector. It can be used with devices with currents up to 16 A. To communicate

with the user, a wireless communication protocol is used to exchange data between the device and

user. This communication allows to obtain data about voltage, current, instant and accumulated power

consumption.

1.1 Motivation

The increase of electronic devices and consequent increase in energy consumption leads to a greater

need in service and measurement quality [2]. Electronic meters fulfill many needs, as they add some

features such as automatic counting, ease in implementing new features, power failure detection and

power factor measurement [3].

To monitor the consumption of a single device, the electromechanical meter isn’t practical since its

big dimensions and high cost difficult its implementation. In addition to the difficulty in reading the value

of the active power consumed by a low power consumption device.

With electronic meters, the measurement is presented in a numerical form, so the power consumed

by a low power consumption device is noticeable, thus allowing users to have a better idea of the energy

spent and to acquire energy-saving habits [4, 5]. As the information is obtained in a digital form it is

possible to send to a smart phone the measured values, facilitating the interface between the meter

device and user. With these meters is also possible to acquire more information about the voltage and

current signals and consumed power.

3

Page 20: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

1.2 Goals

The objective of this project is to develop a small sized device capable of monitoring the electric

energy consumption of a single equipment. The system must register the consumption during a month

and prepare reports for the user. To save the reports, the device must have a non-volatile memory. The

processing unit is based on a PIC that controls the integrated circuit for energy metering. To measure

energy voltage and current sensors are needed. The connection to the grid is made using a Schuko CEE

7/4 connection and a Schuko CEE 7/3 connection between the device and the electronic equipment to

monitor. This plug supports a maximum current of 16 A. The device should also have a wireless interface

to transfer the measured data.

1.3 Specifications

In Table 1.1 is shown the main specifications on the device. As the device acquire the required data

every 10 second, the sample frequency is 0.1 Hz. The device is connected to the electric grid, so the

input voltage is 230 V. The Schuko connectors limit the current to 16 A. To store the desired information

a 2 GB microSD is used. To transmit the information to the smart phone, the BLE protocol is used.

Table 1.1: Main specifications for the device

Specifications

Connector Schuko CEE 7/4 and Schuko CEE 7/3

Sample Frequency 0.1 Hz

Input Voltage 230 V

Maximum Peak Input Current 16 A

Battery Voltage 3.7 V

Battery Capacity 600 mAh

Wireless Communication Bluetooth Low Energy

Memory 2 GB

Measured Parameters Voltage, Current, Active and Apparent Power,Relative Power Consumption, Cost

4

Page 21: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

1.4 Document Organization

This document is organized as follows:

• Chapter 1 is an introduction about electric energy metering and on the project outline. Some

definitions concerning electric power are presented here.

• Chapter 2 is the state of the art where the basic topologies of current and voltage sensors are

presented, as well as the power supply topologies and some previous works and projects.

• In Chapter 3 the architecture of the proposed system is shown where the characteristics of the

components chosen are presented.

• In Chapter 4 the results of the device are presented.

• Chapter 5 presents the document conclusions.

1.5 Electric Power

Measurement of electric power consumption requires the measurement of the current and voltage

supplied to a load.

The power is divided into three components. The active power (P) that represents the actual work

done by a circuit in form of heat, light and motion, which is expressed in kilowatts (kW). The reactive

power (Q) represents the stored energy and doesn’t produce work and is expressed in kilovolt ampere

reactive (kVAR). The apparent power (S) is the total power required including active and reactive power

and is represented in kilovolt ampere (kVA) [6].

Because of its mechanical construction, the electromechanical meters only measure the consump-

tion of the active or reactive energy so it is possible to consume reactive energy without the meter

measuring it [4].

Depending on the load, the apparent power can be a complex number, where the real component is

the active power and the imaginary component is the reactive power [7]. So, the apparent power is

S = P + jQ. (1.1)

For a given sinusoidal voltage and current, active, reactive and apparent powers remain constant and

the representation can be performed using vectors, these vectors form a triangle as shown in Figure 1.1.

Mathematically, apparent power is defined by

S2 = P 2 +Q2. (1.2)

5

Page 22: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 1.1: Power vectors triangle.

Apparent power is greater or equal to active power. In order to be equal, the power factor must have

a unitary value. A power factor different from the unitary value means that exists a phase shift between

the voltage and current signals. To have a maximum energy transfer and hence the work is performed

with a lower current value, the power factor must be as closest to unitary as possible. With the increase

of phase shift the power factor decreases [8].

Power factor is defined by the ratio between active power and apparent power, where the appar-

ent power is the product of RMS value of voltage with RMS value of current in sinusoidal regime. In

sinusoidal regime

S = VRMS × IRMS , (1.3)

and the power factor is

PF =P

S= cos(φ), (1.4)

where φ is the angle between active power and apparent power vectors in absence of harmonics. To

compensate a low power factor and consequently higher losses in the transmission lines, it is possible

to use capacitors or coils banks, contradicting the reactance of the load [7].

Active power is

P =1

T

∫ T

0

v(t)i(t)dt. (1.5)

It is possible to measure the reactive power by shifting either the voltage or current signal by 90. So,

the reactive power is

Q =1

T

∫ T

0

v(t)i90(t)dt. (1.6)

6

Page 23: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Voltage and current signals aren’t purely sinusoidal since they suffer distortion. So, in addition to the

fundamental, there are harmonics at integer multiple frequencies of the fundamental [9].

The current is then defined by the Fourier Series

i(t) = I0 +

∞∑n=1

In cos(nωt− φn) (1.7)

and the voltage is

v(t) = V0 +

∞∑n=1

Vn cos(nωt− θn). (1.8)

Replacing (1.7) and (1.8) in (1.5)

P =1

T

∫ T

0

(V0 +

∞∑n=1

Vn cos(nωt− θn))(I0 +

∞∑n=1

In cos(nωt−φn)) = V0I0 +

∞∑n=1

VnIn2

cos(φn− θn). (1.9)

According to (1.9) there is only active power consumption when there are terms of the Fourier Series

of voltage and current at the same frequency.

The RMS current and voltage are

IRMS =

√1

T

∫ T

0

i2(t)dt, (1.10)

VRMS =

√1

T

∫ T

0

v2(t)dt. (1.11)

And the average values of the current and voltage signals are

IAverage =1

T

∫ T

0

i(t)dt, (1.12)

VAverage =1

T

∫ T

0

V (t)dt. (1.13)

As the cross-multiplication of terms has zero mean, replacing (1.7) in (1.10)

IRMS =

√√√√I20 +

∞∑n=1

I2n2

(1.14)

and (1.8) in (1.11)

7

Page 24: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

VRMS =

√√√√V 20 +

∞∑n=1

V 2n

2. (1.15)

Using (1.14) and (1.15) in (1.4), the power factor is

PF =V0I0 +

∑∞n=1

VnIn2 cos(φn − θn)√

I20 +∑∞n=1

I2n2 ×

√V 20 +

∑∞n=1

V 2n

2

. (1.16)

The presence of harmonic content increases the RMS value of current and voltage. However, the

mean value of the power may not increase.

8

Page 25: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

2State of the Art

Contents

2.1 Electromechanical Meters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.2 Electronic Meters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.3 Voltage Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.4 Current Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2.5 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.6 Wireless Communication - Bluetooth Low Energy . . . . . . . . . . . . . . . . . . . . 20

2.7 Previous Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.8 Electronic Metering Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

9

Page 26: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

10

Page 27: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

2. State of the Art

2.1 Electromechanical Meters

Most energy meters that are found in homes are still electromechanical. These meters are based

on the inductive principle working as an inductive motor, where the rotor moves with parasite currents,

called eddy currents. The stator is the current coil and connected in series with the load and inducts

parasite currents at the aluminum disk. A coil in parallel with the load (voltage coil) generates a magnetic

field, this field interacts with the magnetic field generated by the current coil creating a binary that

produces a rotatory movement on the disk [10]. The rotation is proportional to the active power since the

binary is a result of an interaction between the magnetics fields created by the voltage coil and current

coil. To avoid an accelerated rotation that can cause an over accelerated disk and an higher value of

power consumption measurement, permanent magnets are placed to cause a binary contrary to the

disk rotation, making the resulting rotation proportional to active power. These meters are susceptible

to measurement errors, resulting from various factors such as voltage and current distortion, direction of

energy flow among others. However, considerable measurements errors only occur for large distortions

(over 20%) which is rare [11]. A simple structure of an electromechanical Meter is shown in Figure 2.1.

11

Page 28: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 2.1: Representation of an Electromechanical Meter. Extracted from [4]

2.2 Electronic Meters

Over the years, the electromechanical meters became obsolete and the need to develop new types

of meters that allowed communication with the costumers and less susceptible to the unauthorized alter-

ation of the recorded power consumption increased. These meters have advantages over the electrome-

chanical, such as a small size, high accuracy over a large current range, greater capacity to handle high

currents, low power consumption, greater reliability and robustness and the absence of gears avoids

mechanical wear and possible failures in counting the number of rotations [1].

The first electronic meters processed the signals in the analog domain, and the power information

was obtained through the multiplication and filtering of the acquired signals.

The latest meters use digital signal processing, converting the acquired voltage and current sig-

nals from analog to digital using Analog-to-Digital Converter (ADC)’s, usually Successive Approximation

Register (SAR) or Sigma Delta type [4]. After conversion, the signals can be multiplied, filtered and

integrated by microprocessors or integrated circuits to obtain power information.

Electronic meters can be reconfigured using software updates, their calibration is simpler and without

the need to adjust the device hardware.

2.3 Voltage Sensor

Since the load is connected to the electric grid, the voltage will only have small changes, so the

dynamic range of the ADC can be low. However, the voltage must be reduced so ADC can read its

value correctly. For the voltage sensor there are two main alternatives: voltage transformer and resistive

12

Page 29: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

divider. The voltage transformer reduces the voltage to a range suitable for measurement. When using a

transformer, galvanic isolation is guaranteed and the circuit is protected from grid peaks. The primary of

the transformer is connected to the electric grid between the phase and the neutral and the measurement

is made in the secondary. Although the circuit is protected from the electric grid, this topology has an

high cost and considerable volume.

The voltage in the secondary is

VS =npnsVP , (2.1)

where VP is the voltage in the primary, VS is the voltage in the secondary, np is the number of turns in

the primary and ns is the number of turns in the secondary.

The connection of the transformer to the load is represented in Figure 2.2.

Figure 2.2: Voltage sensor circuit based on a transformer.

The resistive divider consists on dividing the grid voltage into a smaller voltage using resistors. The

sensor is placed in parallel with the load to have the same voltage. The measurement is performed as

shown in Figure 2.3.

Figure 2.3: Voltage sensor circuit based on a resistive divisor.

The measured voltage is

13

Page 30: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

VO =R2

R1 +R2VAC , (2.2)

The resistor values are chosen to have an adequate voltage in the input of the circuit that will process

the signal. The resistors must also have a high value so that the power consumption is low.

Resistor R1 is replaced by a set of resistors of equal value connected in series so that the set of

resistors has the same value of R1. In this way, it is guaranteed a protection of the system since in

case of a malfunction of one resistor the system isn’t compromised. Also, the power is distributed

by all resistors, each consuming less than the total power consumption. If only one Surface-Mount

Device (SMD) resistor is used, there is a voltage drop of 230 V in 2 or 3 mm, which is dangerous.

This type of sensor has the advantages of a reduced size and low cost of components. On the other

hand, it has the disadvantage of not isolating the system from the grid.

For the voltage sensor because of its dimensions and price the resistive divider is used.

2.4 Current Sensors

Unlike voltage, the current has a wide dynamic range and because of the harmonic content of the

current signal, the sensor has to handle a higher frequency range. Thus, there are several topologies

of current sensors, among them Shunt Resistor, Current Transformer, Hall Effect Sensor and Rogowski

Coil Sensor [12].

The Shunt Resistor consists of a highly stable low value resistor, placed in series with the load as

shown in Figure 2.4. The voltage across the shunt resistor is proportional to current, so since the value

of the resistor is known, it is possible to calculate the current according to Ohm’s law [13].

Figure 2.4: Current sensor using a Shunt Resistor circuit.

14

Page 31: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

This type of sensor has some advantages such as good accuracy, low cost and the measurement

process is simple. However, it has the disadvantage of parasite induction and dissipated power. As this

sensor is resistive, the power will be dissipated by heat and this heating is proportional to the square of

the current that flows through the resistor so it has to have a small value to minimize the heat. Thus, for

high currents values another type of sensor is usually implemented [12].

The current transformer converts the current in the primary, connected in series with the load, into

a lower current in the secondary. This is the topology mostly used in high currents. The magnetic

properties of this type of sensor are highly linear over a wide range of primary current and temperature.

This type of sensor has the advantages of measuring high currents and having low power consumption.

Its disadvantage is the possibility of saturation due to the material typically used in the core (ferrite) and

a nonlinear phase response at low currents and large power factors. After being magnetized, the core

will undergo hysteresis and accuracy will worsen unless it is demagnetized again. Saturation can occur

when the current is higher than that allowed by the sensor or when there is an high Direct Current (DC)

component. To prevent saturation from occurring a material with high permeability is used [14]. In Figure

2.5 an example of a current transformer sensor is shown.

Figure 2.5: Current transformer.

There are two main types of Hall Effect sensors implementations, open-loop and closed-loop. Usually

the Hall Effect sensors used for energy metering have an open-loop implementation, so the cost of the

system is lower. These sensors have the advantage of a good frequency response and good high

current measurement capability. Their disadvantages are the high variation with temperature and a

stable external current source is required [12].

The Rogowski Coil sensor consists of a coil that has a mutual inductance with the conductor con-

ducting the current. The Rogowski Coil is typically made with a core of air so that there is no hysteresis,

saturation or non-linearities. This sensor being based on the measurement of a magnetic field is sus-

ceptible to external magnetic fields. The output signal is derived from the voltage and an integrator is

required to process the signal [12].

A comparison between these current sensor types is presented in Table 2.1.

15

Page 32: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Table 2.1: Comparison between current sensor types.

CurrentSensor Shunt Resistor Current

Transformer Rogowski Coil Hall Effect

Cost Very Low Medium Low High

Linearity Good Medium Good Bad

High CurrentsMeasurement Bad Good Good Good

Consumption High Low Low Medium

CurrentSaturation No Yes No Yes

TemperatureVariation Medium Low Very Low High

DC Offset Yes No No Yes

Saturation andhysteresis No Yes No Yes

Isolation No Yes Yes Yes

ExtraComponents No No Yes Yes

After analyzing the characteristics of the current sensors the Shunt Resistor was chosen for the

energy metering device. Its small dimensions, low cost, good linearity and the fact that it doesn’t suffer

saturation or hysteresis problems were the factors that led to this option.

2.5 Power Supply

There are several ways to convert an Alternate Current (AC) voltage into a DC voltage needed to

supply the microcontroller and other devices. Typically, a transformer is used along with a rectifier

circuit. However, in small sized applications that involve only a microcontroller and a few low-current

devices, this topology isn’t appropriate. This is due to the high price of the transformer as well as the

space occupied. A typical power supply with a transformer circuit is shown in Figure 2.6. Despite the

cost and size, a transformer based power supply has the advantage of isolating the electrical grid from

the output of the power supply.

Transformerless power supplies provide a low-cost and small alternative to a transformer-based

power supply. There are two basic transformerless power supplies topologies, resistive and capaci-

tive. The simplest circuit of a transformerless power supply is the resistive with half wave rectification,

16

Page 33: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 2.6: Basic transformer-based power supply circuit.

as shown in Figure 2.7 [15].

Figure 2.7: Resistive transformerless power supply circuit.

Resistor R1 is used as a current limiter and the output voltage is constant when the output current is

less than or equal to the input current. All the current that flows through R1 can become output current.

While the grid voltage is smaller than the zener diode voltage drop, the output voltage is defined by the

grid voltage. Since the zener isn’t conducting, the output capacitor stores charge, allowing the load to

draw current from it as needed. When the grid voltage exceeds the zener voltage, the output voltage

is defined by the zener diode, being constant and equal to the difference of the zener (D1) and diode

(D2) voltage drop. So, the voltage across R1 is the subtraction of the grid voltage with zener voltage

drop [16]. Since the circuit has a half wave rectifier, the average current through R1 represents the

maximum average output current that the power supply can generate.

The region where the zener diode conducts is represented as shaded in Figure 2.8. The average

voltage across R1 is

vR1,average =1

π − 0

∫ π−sin−1(

VD1Vpeak

)sin−1

(VD1

Vpeak

) (Vpeaksinθ − VD1)dθ, (2.3)

where VD1 is the voltage drop in D1 and Vpeak is the maximum grid voltage (√

2× 230 V).

As the value of sin−1(VD1

Vpeak

)is very low (2.3) can be simplified into

vR1,average =1

π − 0

∫ π

0

(Vpeaksinθ − VD1)dθ, (2.4)

since the circuit performs half wave rectification, the maximum average output current is approximately

17

Page 34: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 2.8: Zener diode in conduction zone represented as shaded.

iout,max =

(1

π−0∫ π0

(Vpeaksinθ − VD1)dθ

)2R1

(2.5)

and results in

iout,max =2Vpeak − πVD1

2πR1(2.6)

since the source doesn’t have a transformer to reduce the grid voltage, the voltage drop in the resistor

is high and an high power will be dissipated as heat.

This topology has the advantages of reduced size and cost compared to transformer-based power

supply and capacitive transformerless power supply. However, it has the disadvantage of not isolating

the voltage which can introduce safety problems. This topology is also less efficient than the capacitive

due to dissipation of energy as heat in the resistor [16].

The other basic topology is the capacitive power supply, where a capacitor is added in series with

the resistor, so the current is limited by the reactance of the capacitor. The resistor is kept to limit the

inrush current, so its value can be smaller. The inrush current happens when a capacitor is connected

directly to the grid and at the instant the AC voltage is at a peak value, the capacitor will behave as a

short circuit, producing an high current [15]. The capacitive transformerless power supply topology is

shown in Figure 2.9.

The method to calculate the maximum output current is similar to the resistive power supply but

replacing the resistor R1 by the combined impedance of the resistor in series with the capacitor.

18

Page 35: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 2.9: Capacitive transformerless power supply circuit.

iout,max =2Vpeak − πVD1

2πZ=

2Vpeak − VD1

2π√

(R1)2 + ( 12πfC1

)2, (2.7)

Like the resistive power supply, the capacitive version has the advantage of a reduced size and price

when compared to the transformer-based power supply, in addition of a higher efficiency comparing to

the resistive version. On the other hand, it is also not isolated from the grid and the cost is slightly higher

than the resistive [15]. To improve the efficiency, a rectifying bridge can be used to rectify both cycles of

the input signal. This topology is represented in Figure 2.10.

Figure 2.10: Capacitive transformerless power supply with full wave bridge rectifier.

The maximum output current is

iout,max =2Vpeak − πVD1

π√

(R1)2 + ( 12πfC1

)2, (2.8)

This topology has the advantage of being more efficient, the output voltage is more stable and the

output current is higher. As a disadvantage the cost is slightly higher [16].

Figure 2.11 shows the capacitive full-wave rectifier power supply. A relay controlled by the PIC is

added to protect the circuit from high current values and the resistor R2 in parallel with the capacitor

creates a filter to attenuate the electromagnetic interference back to the line, discharging the capacitor

avoiding shocks due to the capacitor charge [15].

19

Page 36: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 2.11: Capacitive transformerless power supply with full wave bridge rectifier and safety concerns.

2.6 Wireless Communication - Bluetooth Low Energy

There are several wireless technologies that can be used to connect devices remotely. The ZigBee

standard, is a simple technology that uses a protocol of data packets with specific characteristics. The

main characteristic of this technology is the number of nodes that reach more than 64000 nodes in

the same network [17]. Wi-Fi standard is a technology that allows networks to connect with computers

and other compatible devices, like smart-phones or tablets. The Wi-Fi standard has a typical maximum

range of 100 m and a higher data rate than ZigBee and Bluetooth being that the main advantage in

using this technology [18]. Bluetooth is a technology developed for short-range devices, this technology

has the advantage of being compatible with most modern devices as a smart-phone, tablet or personal

computer [19]. Table 2.2 presents the main characteristics of these wireless technologies.

Table 2.2: Wireless technologies comparison

Standard Wi-Fi ClassicBluetooth

BluetoothLow Energy ZigBee

RF Band (MHz) 2400/5000 2400 2400 868/915/2400

NetworkTopology Star Star Star Star/Mesh

Network Size 32 8 ApplicationDependent 65536

Data Rate (Mb/s) 11/54/600 3 1 0.25

Range (m) 100 100 30 100

Number ofChannels 11-14 79 40 27

Packet Size(Bytes) 2346 358 47 127

In this project the Bluetooth wireless technology is chosen since it doesn’t need additional compo-

20

Page 37: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

nents and doesn’t depend on the Wi-Fi network, also the number of nodes required is low.

Bluetooth is a wireless technology that allows data exchange between devices over short distances.

In 2002 was ratified as the IEEE 802.15.1 standard that specifies its Media Access Control and Physical

layers. Nowadays there are two technologies for Bluetooth, the basic rate and the low energy. BLE is

the most recent Bluetooth protocol standard and was created with the propose of establishing low-data

rate connections between mobile devices in a power-efficient way.

Data protocol stack is divided in host and controller. The controller is responsible for the link layer

and physical layer and to filter data packets. The host consists in the Logical Link Control and Adapta-

tion Layer (L2CAP) that is the protocol that allows the communication between host and controller, its

main function is to group and ungroup data packets. The Generic Access Profile (GAP) that defines

generic procedures used to pair and link the device. The Security Manager (SM) that authenticates

and encrypts the data. The Attribute Protocol (ATT) to transmit small packets in an optimized way. The

Generic Attributes (GATT) are responsible to describe the service frameworks and communicate with the

application layer, it defines a hierarchical data structure that is exposed to connected BLE devices [20].

Figure 2.12 represents the architecture of the BLE protocol.

Figure 2.12: BLE protocol stack architecture. Extracted from [20].

The Bluetooth Low Energy physical layer consists in the analog communications circuitry responsible

for translation of digital symbols. The radio divides the 2.4 GHz band in 40 physical channels with a 2

MHz bandwidth. These channels can be one of two types, as shown in Figure 2.13: 3 advertising chan-

nels that are used for the transmission of advertising packets prior to a connection and discover other

devices and 37 data channels used for transmission of data during a connection. BLE has a data rate

that theoretically can reach 1 Mb/s, however this value can be reduced by some factors like bidirectional

traffic, protocol overhead, CPU and radio limitations and software restrictions. The radio uses Gaussian

Frequency-Shift Keying (GFSK), whereby the data pulses are filtered with a Gaussian filter before being

applied to alter the carrier frequency, in order to make the frequency transitions smoother. [20].

21

Page 38: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 2.13: BLE data protocol stack schematic. Extracted from [20].

The Link Layer interfaces with the physical layer and is responsible for advertising, scanning and

creating connections. A frequency hopping scheme is implemented in this layer to remap a packet from

a bad channel to a good channel where the interference from other devices is reduced.

BLE devices can operate in Master or Slave mode, advertising mode and scanning mode. Master

and Slave modes are used by the device to read and write data, while connected. Scanning mode

is used to capture advertise packets. Advertising mode is used to advertise information of possible

connections and responding to queries from other devices. After establishing connection, the device

that is on advertising mode assumes the slave mode and the device on scanning mode assumes master

mode.

There are two types of packets, the data packets and the advertising packets. These packets have

only one format as shown in Figure 2.14. These packets have a 1 Byte preamble to synchronize trans-

mission timing between systems, 4 bytes for an access code generated randomly by the RF channel, 2

to 257 bytes for the Protocol Data Unit (PDU) and 3 bytes for Cyclic Redundancy Check (CRC) to check

for accidental changes to raw data.

Figure 2.14: BLE packets format. Extracted from [20].

The difference between the advertising and data packets is in the Protocol Data Unit, where the

advertise packets only have a 2 Bytes header and a payload up to 37 Bytes, whereas the data packets

have a payload that can has up to 255 Bytes plus a 2 Bytes header.

The advertising channels protocol data unit have two purposes: broadcast data for applications that

do not require a full connection, discover slaves and connect to them. While connected the devices

can send data to one another. This is performed by exchanging data channel protocol data units during

regularly scheduled connection events. The data channel Protocol Data Unit is divided in five parts: 2

Bytes PDU Header, 4 Bytes Message Integrity Check, 4 Byte L2CAP Header, 1 Byte ATT Operation

22

Page 39: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Code and the remaining 246 bytes are reserved for data.

To pair two devices one must be advertising while the other is scanning. The advertise device

transmit packets on the advertise channels with the address and additional information. When the

connection is established, the scanning device sends information about the connection interval and

slave latency to the advertiser device. Connection interval sets the start of connection events and the

slave latency sets the number of connection intervals the slave can ignore without losing the connection.

Unlike the classic Bluetooth, BLE uses lower power duty cycle that allows the device to spend more

time sleeping and waking up with less frequency to send and receive packets. BLE remains sleeping

unless there is data to send or receive, in opposition of classic Bluetooth that is always connected even

if there isn’t data to transfer [21]. Table 2.3 resumes the principal characteristics between the classic

Bluetooth and BLE.

Table 2.3: Comparison between classic and low energy Bluetooth

Classic Bluetooth Bluetooth Low Energy

Modulation Technique Frequency Hopping Frequency Hopping

Frquency Hopping 2400 to 2483.5 MHz 2400 to 2483.5 MHz

Modulation Scheme GFSK GFSK

# Channels 79 40

Channels Bandwidth 1 MHz 2 MHz

Nominal Data Rate 3 Mbps 1 Mbps

# Nodes 8 8

Range 100 m 30 m

Time to Send Data 10 ms 3 ms

Peak current 30 mA 20 mA

Because of its low power consumption, BLE has some limitations such as a lower Data Transfer

Rate that on classic bluetooth can reach 3 Mbps and on BLE 1 Mbps. For continuous transmission of

large amounts of data the BLE is not the advised device. In this project there is no need to continuously

transfer data, so the BLE option is a better solution.

23

Page 40: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

2.7 Previous Work

In this section some related projects developed in Instituto Superior Tecnico (IST) are described.

This projects had different approaches for the same goal, to measure electric energy.

2.7.1 Electric Energy meter for low voltage usage

A energy metering system based on a energy metering IC, with communications with a user through

USB and RS-232. The device measures the instantaneous and accumulated power consumption. The

information is also shown in a Liquid Crystal Display (LCD). To supply power to the device components a

transformerless power supply was used. To process data a Digital Signal Peripheral Interface Controller

(dsPIC) is used. The voltage sensor is a resistive divider and the current sensor a Shunt resistor. The

device works up to 30 A [22].

2.7.2 Three-phase energy metering

This project consisted in a three-phase watt-hour meter, it was based on a IC to process the voltage

and current and to control a LCD and a flash memory to store the data obtained. The current sensor

is based on a current transformer in each phase and the voltage is conditioned through a resistive

divider and filters into the controller. A remote communication was implemented via optocouplers, serial

port and infrared. The system was capable of detecting attempts of tempering with the system and/or

recorded data. In addiction to a capacitive power supply, the system features a rechargeable battery to

keep the system running in case of power failure [23].

2.7.3 DSP-based three-phase power quality measurement system

In this project the system is able to monitor in real-time the power quality of the grid, detecting every

event described in international standards and register the duration of such events. The retrieved data

is then sent to a computer through an Ethernet connection [24].

2.8 Electronic Metering Projects

Between 2000 and 2005, the Italian energy distributor ”ENEL” installed 30 Million meters with a cost

of 70 e per house. According to ENEL the savings reach 500 Million e per year. Power consumption

from households had fallen 5 % due to the switch to new energy meters. These new meters provided

new features such as the ability to turn power on and off at demand site, remote billing, fraud detection,

among others [4].

24

Page 41: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

In USA, due to high temperatures in summer and consequent use of air-conditioning systems, an

increase in power consumption was observed, so California’s energy regulators approved a program to

install 9 Million meters in 2006. Consumers could monitor their consumption patterns online and make

better decisions on their usage [4].

Other countries like UK, Canada, China and Japan also have big programs to renew energy meters

for electronic ones that involves the replacement of millions of outdated meters for newer with more

features that help the consumer and the distributor [4].

In Portugal, EDP installed about 100 000 electronic meters until 2012 to test the new features and

communication between device and user [25]. An European Union initiative predicts that, by 2020, 80%

of traditional meters are replaced by electronic meters. EDP signed a contract for 800 000 meters with

Siemens and are expecting that 3.6 Million clients have these new meters by 2020.

25

Page 42: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

26

Page 43: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

3System Architecture

Contents

3.1 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

3.2 Energy Metering Integrated Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

3.3 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

3.4 Signal Conditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

3.5 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

3.6 Battery Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

3.7 Bluetooth Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

27

Page 44: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

28

Page 45: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

3. System Architecture

An electronic energy meter is normally composed of voltage and current sensors, power supply unit,

energy measurement unit, microcontroller, memory and communicating system unit [26,27].

The developed system has to acquire the information regarding the power from the energy metering

IC, store this information in a non-volatile memory and send it via Bluetooth protocol when requested.

As the system is connected to the electric grid, the power supply is supplied by the grid. To measure

power, it is needed to measure the voltage and current, these measurements are performed by means

of sensors. The system architecture is represented in Figure 3.1.

This system has a memory unit composed by a Secure Digital (SD) Card and the communication

unit composed by two Serial Peripheral Interface (SPI) modules that are used to communicate with the

energy meter and the memory unit and a Universal Asynchronous Receiver-Transmitter (UART) module

to communicate with the Bluetooth module.

Figure 3.1: System Block diagram.

29

Page 46: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

3.1 Microcontroller

The microcontroller controls the communication with the energy metering IC, process the data re-

ceived, communicate with the memory and the bluetooth module.

To process the data from the energy metering IC, Microchip Technology PIC24FJ128GA010 micro-

controller was chosen. This microcontroller is small and fast enough for the required operations, in

addition to integrate several functionalities such as specific communication protocols and an internal

oscillator. In Figure 3.2 is presented a figure of the PIC24FJ128GA010 microcontroller.

Figure 3.2: PIC24FJ128GA010 from Microchip Technology.

This PIC belongs to a class of programmable microcontrollers with Harvard architecture and a small

set of instructions. The architecture is a 16-bit architecture and is characterized for having two different

memories, one for the instructions and other for data. The PIC is constituted by a RAM memory, non-

volatile EEPROM memory, program memory and Input/Output (I/O) digital and analog terminals. To

program the microcontroller C language is used together with a PICkit3 to transfer the code to PIC.

This microcontroller has various options of oscillators, internal and external. The oscillators are

two crystals, two external clocks with the option of dividing the clock by two at the output, a Fast Internal

Clock (FRC) with an output frequency of 8 MHz that can be software divided until 31 kHz, a phase-locked

loop available for the external oscillator and for the FRC internal oscillator that can reach frequencies

up to 32 MHz and a fixed 31 kHz internal oscillator. In this project the FRC oscillator is chosen at a

frequency of 8 MHz.

The PIC has several modules for communication with peripherals. In this project the most important

are two SPI modules, two UART modules and two I2C modules. These modules are useful since the

communication between the energy metering IC and the microcontroller is done using SPI as well as the

communication with the memory. The UART is used for communication with the bluetooth module [28].

A Timer generates a fixed specific time interval for the device to measure the energy consumption.

30

Page 47: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

3.2 Energy Metering Integrated Circuit

For energy metering the Analog Devices’ ADE7753 was chosen because it has an high accuracy

over large variations in environmental conditions and incorporates all the signal processing required to

perform active, reactive, and apparent energy measurements and RMS calculation on the voltage and

current. Also, the ADE7753 provides a serial interface to read data and to make calibrations such as

channel offset correction, phase calibration and power calibration [29].

This energy counter supports IEC 62053-21/62053-22/62053-23 standards for accuracy, incorpo-

rates a Programmable-Gain Amplifier (PGA) in the current channel to directly interface with shunts or

current transformers, has less than 0.1% error in active energy measurement over a dynamic range

of 1000 to 1 and low power consumption with a typical power consumption of 25 mW. To acquire the

voltage and current it includes two second-order 16-bit Σ−∆ ADC’s [29]. A functional block diagram of

the ADE7753 is shown in Figure 3.3.

Figure 3.3: Functional Block Diagram of ADE7753. Extracted from [29].

To measure the current and voltage, the input signals are firstly converted with the ADCs. The

Channel 1 ADC includes three maximum range options in addition to the gain from the PGA. The

possible alternatives for the maximum input ranges in Channel 1 are presented in Table 3.1. For the

Channel 2, only the PGA introduces a gain that can take the same values as Channel 1 PGA that are 1,

2, 4, 8 or 16.

In the current channel, the digital signal is filtered with an high pass filter as it is shown in Figure 3.4.

31

Page 48: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Table 3.1: Maximum Input Signal Levels for Channel 1.

ADC Input Range SelectionMax Signal

Channel 10.5 V 0.25 V 0.125 V

0.5 V Gain = 1 - -

0.25 V Gain = 2 Gain = 1 -

0.125 V Gain = 4 Gain = 2 Gain = 1

0.0625 V Gain = 8 Gain = 4 Gain = 2

0.0313 V Gain = 16 Gain = 8 Gain = 4

0.0156 V - Gain = 16 Gain = 8

0.00781 V - - Gain = 16

Because the current is sensed into a voltage and sampled, to calculate it’s RMS value is used

VRMS =

√√√√ 1

N∑i=1

V 2i . (3.1)

The result value has a 24-bit length. To measure the RMS value of the voltage, the process is similar.

Figure 3.4: Energy Counter IC RMS value measurement block diagram. Extracted from [29].

As the Active Power is the DC component of the instantaneous power signal, to calculate it’s value

the current and voltage signals are multiplied to obtain the instantaneous power signal and then a low

pass filter (LPF2 in Figure 3.3) is used to extract the DC component corresponding to active power. The

relationship between the power and the energy is

E =

∫Pdt = lim

t=0

∞∑n=1

p(nT )× T, (3.2)

A block diagram of the process is shown in Figure 3.5. The energy meter IC also registers the accu-

32

Page 49: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

mulated active power. This register has a length of 48 bits, however only the upper 24 bits are accessible,

the lower 24 bits are used to delay the influence of the acquired active power values rounding.

Figure 3.5: Active Power Measurement Block Diagram. Extracted from [29].

Reactive power is defined as the product of the voltage and current when one of the signals is phase-

shifted by 90 [29]. The resulting multiplication is called instantaneous reactive power, so as in active

power case, to obtain the average reactive power a low pass filter is used, as observed in Figure 3.6.

Figure 3.6: Reactive Power Measurement Block Diagram. Extracted from [29].

The apparent power is calculated as in (1.3) by multiplying the RMS values of the current and voltage

as it is seen in Figure 3.7.

3.3 Power Supply

To implement the power supply, the topology from Figure 2.11 was used because of its small size,

high efficiency and low power consumption due to the diodes bridge.

The component that requires more current is the microcontroller that has a maximum current of

33

Page 50: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 3.7: Apparent Power Measurement Block Diagram. Extracted from [29].

32 mA at maximum frequency [28]. The other components have small currents comparing to microcon-

troller, with the energy meter having a current of 4 mA. So, the power supply was developed to supply

up to 75 mA.

The resistor R2 has an high value, so the resulting impedance of R2 in parallel with C1 is approxi-

mately the impedance of C1.

With this topology, R1 can have a small value but different from zero to avoid inrush current when the

circuit is turned on, because the current is limited by the C1 reactance, so a value of 100 Ω is chosen.

From (2.8) it is possible to calculate the value of C1,

C1 =1

2πf

1√( 2Vpeak−πVD1

π Iout,max

)2 −R21

= 1.003 µF, (3.3)

To connect a capacitor directly to the grid it is necessary a capacitor with special features. This type

of capacitor is called X2, also referred as ”across the line capacitor”. If a X capacitor fails, one of two

options can happen. Either the capacitor turns into a open circuit or a short circuit, in the last option an

high current is generated and the fuse will open. After calculating the theoretical value of the capacitor,

the closest value of a capacitor with these characteristics available in market is 1 µF. With the new value

of the capacitor, replacing in (2.8), the maximum output current is 75 mA.

With this current the maximum power dissipation in resistor R1 is

PR1 = R1× I2out,max = 100× 0.0752 = 0.5625 W. (3.4)

So, a 1 W resistor is used. In the worst case the Zener diode should be able to dissipate a power of

PZ = VZ × Iout,max = 5× 0.075 = 0.375 W. (3.5)

34

Page 51: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

As the Zener diode as to dissipate a power of 0.375 W, a 1 W Zener diode is chosen. Each rectifier

diode only conducts half of a cycle, meaning that there is only current in each diode half of the time. So,

in average, the power dissipation in each diode is

PD = VD ×Iout,max

2= 26.25 mW. (3.6)

To increase the stability of the output voltage a voltage regulator was placed after the circuit of Figure

2.11.

3.4 Signal Conditioning

The energy metering integrated circuit has an Analog Input maximum range of +−0.5 V, so the voltage

and current signals must be reduced to fit in the IC range. The IC also includes one PGA in the current

channel and other in the voltage channel so it is possible to amplify the signal before it is converted

to digital, avoiding the loss of information if the signal is too small and the resolution of the ADC isn’t

enough to detect the values [29].

3.4.1 Current Sensor

For the current sensor, a small value Shunt Resistor is chosen taking into account the power and

temperature coefficient. As the system has to be capable of measuring currents up to 16 A and according

to Joule’s Law, the power of heating generated in an electrical conductor is proportional to the square

of current, a small value of 0.001 Ω is chosen for the Shunt Resistor. This way, the maximum power

dissipation is

PShunt = I2max ×RShunt = 0.256 W. (3.7)

From Ohm’s Law

VShunt,max = Imax ×RShunt = 0.016 V, (3.8)

so, this voltage is in the energy metering IC range. As a resistor dissipates power through heat it is

required that the Shunt doesn’t change it’s properties with an increase of temperature. With a small

temperature coefficient, a linear approximation of the resistor is used.

For this project a 0.001 Ω SMD Shunt Resistor was chosen with a power rating of 1 W and with the

minimum available temperature coefficient of 50 ppm/°C. With this power rating the maximum current

that the sensor supports is 31 A.

35

Page 52: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

3.4.2 Voltage Sensor

The voltage sensor is a resistive voltage divider and is composed by a series of ten 47 kΩ resistors

and one 220 Ω resistor. Considering a maximum value of voltage of 470 V for the circuit to be capable

of handle a voltage peak, the maximum input value in the energy metering is,

VInput,max = Vmax ×220Ω

10× 47kΩ + 220Ω= 0.22 V, (3.9)

This value is in energy metering IC range. According to Ohm’s Law, the maximum current consumed

by the voltage sensor is

IV oltageDivider,max =470V

10× 47kΩ + 220Ω= 1 mA, (3.10)

Each resistor has a maximum power consumption of

PConsumption,max = I2V oltageDivider,max ×R. (3.11)

In case of 47 kΩ resistors is 47 mW and for the 220 Ω resistor is 0.22 mW. The chosen resistors have

a power rating of 250 mW.

3.5 Memory

To store the read data a non-volatile memory is used. This type of memory can keep the stored

information even when the system isn’t powered. Compared to volatile memory, non-volatile memory

usually has a higher cost but a poorer performance. Although the device works with a battery in case of a

power failure, this battery will run out of energy and the information stored must be kept. To implement a

non-volatile memory, a microSD Card was used. In Figure 3.8 is presented the connection scheme [30].

Figure 3.8: Interface between the PIC and the microSD Card.

The CD pin isn’t part of the microSD Card SPI data communication protocol, it only shows if the card

is detected or not, assuming a value of 3.3 V when the card is inserted and a value of 0 V otherwise.

36

Page 53: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

To interact with the memory card, the data cannot be stored as individual blocks of bytes, since a lot of

devices don’t read individual blocks of memory space. So, an abstraction layer above the memory space

is needed to make sure all devices can read the data stored in the memory card. The abstraction layers,

also known as filesystem, divides the memory in clusters and sectors that most devices can understand.

Since the information in memory card must be read in computers a filesystem needs to be implemented.

The SD card has a FAT file system implemented to be compatible with a broad range of modern and old

devices.

3.5.1 FAT file system

The FAT file system was originally designed for small disk with simple folder structures. The method

of organization is based on an allocation table that resides at the beginning of the volume. The volume

includes two copies of the table to protect the volume in case one gets damaged, as shown in Figure

3.9 [31].

Figure 3.9: FAT file system table. Extracted from [32].

A volume with FAT file system is allocated in clusters that is divided in sectors, being its size de-

termined by the size of the volume. For a 2 GB memory card, FAT16 uses 32 kB clusters. In case of

the FAT file system, the cluster number must fit in 16 bits and be a power of two. These clusters are

the smallest memory allocation unit for a file. That means that a 4 kB file is stored in a single 32 kB

cluster and the remaining 28 kB can’t be used to store another file. So, with a smaller sized cluster, a

more efficient system is obtained. The files and directories starting clusters are stored in a root directory

cluster. To access a file in the root directory, it is needed to access the root directory cluster to get the

number of the starting cluster of the file. The first cluster holds the data and a pointer to the next cluster

where data continues or to an end-of-file indicator [31,32].

3.5.2 microSD Card Organization

The memory card saves the energy consumption reports. The data is saved in text files for each

quantity to measure. So the files in microSD Card are:

• VRMS.txt, to save the voltage RMS measured values.

• IRMS.txt, to save the current RMS measured values.

• AENERGY.txt, to save the active energy measured values.

37

Page 54: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

• VAENERGY.txt, to save the apparent energy measured values.

• DATE.txt, to save the date and hours of the measuring

The data about the cost is processed in the smart phone application because this value can be

changed any time by the user. The stored data is available for a month and then erased to be replaced

by the new values.

3.6 Battery Management

An energy meter where the power depends on the grid voltage must present a protection in case of

an energy fault. To prevent a system shut down a battery was used with an integrated circuit to monitor

the voltage level and to perform the power path management [33].

In Figure 3.10 a block diagram of the battery charger is represented.

Figure 3.10: Power path management block diagram.

The power path management is accomplished used a BQ24070 IC from Texas Instruments, which is

placed between the power supply and the system. This circuit performs the management of energy and

charges the battery if needed. If the battery is fully charged and the power supply is working properly,

the system is supplied from the power supply, with the battery in a stand by mode. When there is an

energy outage, the power management IC swaps the supply of the system from the power supply to the

battery, when the energy from the grid is restored the battery is charged.

The maximum input voltage level from the AC adapter allowed from BQ24070 is 18 V with a maximum

input current of 3.5 A, as shown in Table 3.2.

Table 3.2: Absolute Maximum Ratings

Parameter Min Max Units

Input Voltage (IN) -0.3 18 V

Input Voltage (BAT) -0.3 7 V

Input Current - 3.5 A

Output Current - 4 A

38

Page 55: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

3.7 Bluetooth Module

For this project the RN4871 Microchip Technology Bluetooth Module is chosen because of its small

dimensions of 9 mm x 11.5 mm and its functionalities. This module is used to communicate between

the device and the user. It has an integrated ceramic antenna and an ASCII Command Interface API

over UART [34]. Through the ASCII Commands it is possible to configure the module since establishing

connection to creating a script and enter in Low-Power Mode. The module has GPIO pins that can be

configured to give some information, such as if the Bluetooth is connected. In Figure 3.11 the RN4871

module is shown.

Figure 3.11: RN4871 Bluetooth Module.

The RN4871 module supports four built-in GATT services:

• Device information public service;

• Airpatch private service, which handles Over The Air (OTA) updates;

• BeaconThings, which handles beacon services control;

• UART Transparent private service, which handles data streaming function.

In this project the UART Transparent private service is used since it is the best option for data stream-

ing.

The module can work on two modes, a Test Mode to make firmware updates and Application Mode

to run the pretended script for the application.

Table 3.3 shows general specifications for the module. This module has a frequency band of 2.402

to 2.480 GHz, a maximum data rate of 10 kbps when using Transparent UART mode and an integrated

ceramic antenna. It has an UART interface and is the supply voltage is 3.3 V.

In Table 3.4 the main electric characteristics are shown.

39

Page 56: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Table 3.3: General Description of RN4871 Module.

Specification Description

Standard Bluetooth 4.2

Frequency Band 2.402 to 2.480GHz

Modulation Method GFSK

Maximum Data Rate 10 kbps

Antenna Ceramic

Interface UART, AIO, PIO

Table 3.4: Electric Characteristics.

Parameter Min Max Units

Supply Voltage (VDD) 1.9 3.6 V

I/O Voltage Levels

VIL Input Logic Levels Low 0 0.3 VDD V

VIH Input Logic Levels High 0.7 VDD VDD V

VOL Output Logic Levels Low 0 0.2 VDD V

VOH Output Logic Levels High 0.8 VDD VDD V

Reset

Reset Low Duration 63 - ns

40

Page 57: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

The module has a typical consumption of 10 mA while transmitting or receiving data and 60 µA in

Low-Power Mode. Table 3.5 shows current consumption for each state.

Table 3.5: Current Cunsumption

Parameter Min Typical Max Units

Supply Current

Tx Mode Peak Current - 10 at +25ºC 13 at +75ºC mA

Rx Mode Peak Current - 10 at +25ºC 13 at +75ºC mA

Low-Power Mode Current - 60 at +25ºC - uA

Shutdown Low-Power Mode 1 - 2.9 uA

Depending on the mode (Application or Test) the timing characteristics are different. In Figure 3.12

the timing diagram of RN4871 after Reset is shown and in Figure 3.13 the timing diagram when powered

on is shown.

Figure 3.12: Timing characteristics of RN4871 Bluetooth Module after Reset.

41

Page 58: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 3.13: Timing characteristics of RN4871 Bluetooth Module when powered on.

Table 3.6 shows the differences between the set baud rates and the measured baud rate as well as

the error. The highest error is when the baud rate is set to its maximum of 921600, the baud rate of

307200 is the rate with the least error between the set and obtained Baud Rate.

Table 3.6: Bluetooth BaudRate

Set Baud Rate Measured Baud Rate Error

921600 941176 -2.12%

460800 457143 0.79%

307200 307692 -0.16%

230400 231884 -0.64%

115200 115942 -0.64%

57600 57971 -0.64%

38400 38095 0.79%

19200 19048 0.79%

9600 9524 0.79%

42

Page 59: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

4Results

Contents

4.1 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.2 Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.3 Smartphone Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

4.4 Energy Metering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

43

Page 60: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

44

Page 61: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Results

4.1 Power Supply

The voltage measured in the Zener diode is dependent on the current and consequently on the load.

So, a study on the behavior of the power supply when the load is varying is performed. The measured

results of the voltage in Zener diode terminals are illustrated in Figure 4.1. As expected the implemented

power supply provides 5 V with a minimum load of about 70 Ω, corresponding to a maximum current of

72 mA.

0 200 400 600 800 1,0000

1

2

3

4

5

Load [Ω]

Ave

rage

Out

putV

olta

ge[V

]

Figure 4.1: Average Output Voltage with different loads.

4.2 Calibration

After obtaining the values from the energy metering chip it is required to calibrate the device. The

calibration was performed by taking several measurements and compare with the values measured with

a multimeter. Then, a linear regression model (y = mx + b) is used to minimize the error between the

45

Page 62: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

energy chip measurements and the multimeter measurements. As the energy chip has a linear behavior

between FS/20 and FS (Full Scale) the linear regression model is used.

Voltage

In Table 4.1 the data collected by the ADE7753 energy metering chip compared to the values obtain

from the multimeter is shown.

Table 4.1: Comparison between read voltage values and true values .

Before Calibration True Value (V)

4289 54.81

5634 72.88

6709 89.89

8203 109.99

9726 130.99

11273 153.15

12489 172.67

14078 195.45

15748 218.4

17884 242.1

After linearizing, the resultant calibration equation that minimizes the error is

V RMS = 0.0140599945× x− 5.0493397926, (4.1)

And the coefficient of determination, R2, is

R2 = 0.999, (4.2)

From the equation it is possible to compare the calibrated values with the values obtained from the

multimeter, as it is shown in Figure 4.2. The maximum relative error obtained was 1.77%.

46

Page 63: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 4.2: Comparison between voltage calibrated values and real values.

Current

To calibrate the current values, the same process is executed. So, in Table 4.2 is presented the data

collected by the ADE7753 energy metering chip and the values measured with a multimeter.

Table 4.2: Comparison between read current values and true values .

Before Calibration True Value (A)

2045 0.295

2188 0.320

2390 0.374

2641 0.432

2854 0.469

3211 0.548

3702 0.635

4169 0.742

The outcome calibration equation that minimizes the error is

IRMS = 0.0002085269× x− 0.1278090220, (4.3)

And the coefficient of determination, R2, is

R2 = 0.998, (4.4)

47

Page 64: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Comparing the calibrated values with the true values (Figure 4.3) a maximum of 2.46% relative error

was obtained.

Figure 4.3: Comparison between current calibrated values and real values.

4.3 Smartphone Application

To display the acquired values, an Android Application is used. This app shows the desired values

such as the active power or the voltage. This values can be displayed in two forms, live value and a

chart. The chart shows the values from the last 30 days.

Figure 4.4(a) shows the home screen. In this screen it is required to connect with the Bluetooth

device. In the settings screen it is possible to select which quantities to display. In Figure 4.4(b) the

settings screen and the options to select is shown.

There are two more screens: live values screen (Figure 4.4(c)) and chart screen (Figure 4.4(d)). In

the live values screen the instant values of the quantities selected in settings screen are presented and

in the chart screen it is required to select the chart to display. The chart is refreshed when the refresh

button is pressed.

4.4 Energy Metering

To test the performance of the device, several linear and non linear loads where connected to the

device during a period of time.

The information is saved every 10 seconds and saved in the microSD Card. To view the power

consumption of a device it is required to have the Smartphone Application or remove the memory card

48

Page 65: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

(a) (b)

(c) (d)

Figure 4.4: Application Screens.

49

Page 66: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

from the device and read the values in a computer. If the Bluetooth is connected it is possible to observe

the instant values and accumulated values as well as chart from the previous 30 days.

In first example, a linear load of 300 Ω was connected for 30 minutes to the circuit and its consumption

measured. As expected the current (Figure 4.5), voltage (Figure 4.6) and active power (Figure 4.7)

remain constant.

Figure 4.5: RMS Current for a 300 Ω Resistor Load.

Figure 4.6: RMS Voltage for a 300 Ω Resistor Load.

50

Page 67: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 4.7: Active Power for a 300 Ω Resistor Load.

A second measurement was performed by connecting a refrigerator to the system for 3 hours. Ac-

cording to its characteristics, the refrigerator works with a current of 0.6 A and is connected to the mains.

Figure 4.8 shows that the RMS value of the voltage in refrigerator. After connecting the refrigerator it

took about 10 min to power up and then remained on until it was turned off as it is shown in Figure 4.9.

The consumed power is shown in Figure 4.10.

Figure 4.8: RMS Voltage for a refrigerator.

51

Page 68: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure 4.9: RMS Current for a refrigerator.

Figure 4.10: Power consumed by a refrigerator.

52

Page 69: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

5Conclusions

53

Page 70: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

54

Page 71: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

5. Conclusions

An energy monitoring device to be used in the long-term monitoring of the energy consumption of a

single mains connected device was developed and tested.

The system is composed by a microcontroller, a memory module composed by a SD memory card,

a power supply, a Bluetooth module and an energy meter IC.

To power the circuit, a capacitive transformerless power supply is used instead of a traditional power

supply with a transformer, since the proposed solution is smaller and cheaper. This power supply allows

the system to work without a battery as long as it is connected to the grid and an energy fault doesn’t

occur. In case of an energy failure the system is prepared to work on a battery to prevent from losing

information and keep a record of the measurements. An analysis of this circuit was performed by varying

a load in its terminals. The power supply was capable of supplying the necessary current to the system.

To measure the power consumption of a single mains connected device it is required to measure and

process information about the load voltage and current. The system has a resistive voltage divider as

voltage sensor and a shunt resistor to measure the current. These sensors are connected to a specific

energy metering IC that processes the data performing every calculation needed to obtain the RMS

values of voltage and current, as well as active, apparent and reactive power. To save the measured

information a SD memory card is used to avoid the loss of data in case of both the power supply and

battery won’t work. The system was connected to several loads and the information about the power

was stored in the memory card. In a PC was possible to verify that all the measurements were stored.

To test these circuits a load was connected to system for some time and the measured values stored in

the SD card, then theses values were read in a PC confirming that no information has been lost.

To communicate with the client, a Bluetooth module is used to send the collected information from

the SD Card to an Android smartphone. To test this module, a load was connected to the system and

the values measured were stored on the memory card, then a request from the application was sent to

the device and the stored data displayed on the phone being verified that all the values from the SD card

were transferred to the application.

For future work some optimization could be made to improve the system operation, such as:

• Optimization of the user interface on the Android Application;

55

Page 72: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

• Optimization of the PIC code and communication with Bluetooth and microSD card;

• Replace the energy meter IC with a 3.3 V, to avoid generating 5 V and 3.3 V;

• Implementation of the Power-Path management circuit for the device to work even when there is

an energy fault;

• Replace Bluetooth module, the chosen is very unstable.

56

Page 73: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Bibliography

[1] E.E.Institute, ”Handbook For Electricity Metering”, 11th edition, 2014.

[2] Natasha Wan; Kevin Manning, ”Exceeding 60-Year Life Expectancy from an Electronic Energy

Meter”, Metering Asia Pacific Conference, February 2001.

[3] Rachel Kaplan, ”Frequently Asked Questions (FAQs) Analog Devices Energy (ADE) Products”.

[Online]. Available: http://www.analog.com/static/imported-files/application notes/AN639.pdf

[4] K. S. K. Weranga; Sisil Kumarawadu; D. P. Chandima, ”Smart Metering Design and Applications”,

Springer, 2014, DOI:10.1007/978-981-4451-82-6.

[5] Kara S., Bogdanski G., Li W., ”Electricity Metering and Monitoring in Manufacturing Systems”,

Glocalized Solutions for Sustainability in Manufacturing, Springer, Berlin, 2011.

[6] Vinaya Skanda, ”Power Factor Correction in Power Conversion Using the dsPIC® DSC”. [Online].

Available: http://ww1.microchip.com/downloads/en/AppNotes/01106A.pdf

[7] Gil Marques, Maria Jose Resende, ”Circuitos Electricos”, Sistemas Electricos e Electromecanicos,

2013. [Online]. Available: http://e-lee.ist.utl.pt

[8] W. Mack Grady, Robert J. Gilleskie, ”Harmonics and how they relate to power factor”, EPRI Power

Quality Issues and Opportunities Conference, November 1993.

[9] Jack Blitz, ”Fundamentals of Power Electronics”, Chapter 15: Power and Harmonics on

Nonsinusoidal Systems. [Online]. Available: http://encon.fke.utm.my/nikd/SEM4413/power-factor1.

pdf

[10] ”Handbook on Electricity Meters”, APEC/APLMF Training Courses in Legal Metrology.

[11] A. Baggini, ”Power Quality Handbook”, Ed. John Wiley and Sons Ltd, 2008.

[12] William Koon, ”Current Sensing for energy metering”, Analog Devices Inc. [On-

line]. Available: http://www.analog.com/media/en/technical-documentation/technical-articles/

16174506155607IIC Paper.pdf

57

Page 74: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

[13] ”Direct Measurement of AC Current by Measuring the Voltage Drop on the Coaxial Current Shunt”,

IEEE Transctions on Intrumentation and Measurement, Vol. 58, No. 4, April 2009.

[14] Craig L. King, ”IEC Compliant Active-Energy Meter Design Using The MCP3905A/06A”, Microchip

Technology. [Online]. Available: http://ww1.microchip.com/downloads/en/AppNotes/00994b.pdf

[15] Reston Condit, ”Transformerless Power Supplies: Resistive and Capacitive”, Microchip Technology.

[Online]. Available: http://ww1.microchip.com/downloads/en/AppNotes/00954A.pdf

[16] ”Transformerless Power Supply Design”, Designer Circuits, LLC. [Online]. Available: http:

//www.designercircuits.com/DesignNote1b.pdf

[17] ZigBee Alliance, ”Understanding ZigBee Gateway”, 2010. [Online]. Available: https://www.zigbee.

org/zigbee-for-developers/zigbee-gateway

[18] Wi-Fi Alliance, ”Generational Wi-Fi User Guide”, 2018. [Online]. Available: https://www.wi-fi.org/

discover-wi-fi

[19] Bluetooth SIG, ”Radio Versions”, 2018. [Online]. Available: https://www.bluetooth.com/

bluetooth-technology/radio-versions

[20] Microchip, ”Introduction to Bluetooth® Low Energy”. [Online]. Available: http://microchipdeveloper.

com/wireless:ble-introduction

[21] Bluetooth SIG, ”Topology Options”, 2018. [Online]. Available: https://www.bluetooth.com/

bluetooth-technology/topology-options

[22] Pedro Agulha, “Contador de Energia Electrica para uso em baixa tensao,” Master’s thesis, Instituto

Superior Tecnico, November 2010.

[23] Andre Gomes, “Contador de Energia Electrica Trifasico,” Master’s thesis, Instituto Superior Tecnico,

November 2012.

[24] Luıs Magalhaes, “Development and implementation of a DSP-based three-phase power quality

measurement system,” Master’s thesis, Instituto Superior Tecnico, October 2014.

[25] ”Estudo sobre contadores inteligentes de electricidade e de gas natural”, Relatorio 1E/G: Situacao

actual e experiencia com projectos-piloto em Portugal, KEMA, February 2012. [Online]. Available:

http://www.designercircuits.com/DesignNote1b.pdf

[26] Stephen T. English, ”A Low Cost Watt-Hour Energy Meter Based on the ADE7757”,

Analog Devices. [Online]. Available: http://www.analog.com/media/en/technical-documentation/

application-notes/AN-679.pdf

58

Page 75: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

[27] Stephen T. English and Dave Smith, ”A Power Meter Reference Design Based on the ADE7756”,

Analog Devices. [Online]. Available: http://www.analog.com/media/en/technical-documentation/

application-notes/an564.pdf

[28] Microchip. 64/80/100-Pin, General Purpose, 16-Bit Flash Microcontrollers. [Online]. Available:

http://ww1.microchip.com/downloads/en/DeviceDoc/39747F.pdf

[29] Analog Devices. Single-Phase Multifunction Metering IC with di/dt Sensor Interface. [Online].

Available: http://www.analog.com/media/en/technical-documentation/data-sheets/ADE7753.pdf

[30] SD Card Association, SD Specifications - Part 1 - Physical Layer - Simplified Specification, 2018.

[Online]. Available: http://www.analog.com/media/en/technical-documentation/application-notes/

an564.pdf

[31] Microchip, Implementing File I/O Functions Using Microchip’s Memory Disk Drive File System

Library. [Online]. Available: http://ww1.microchip.com/downloads/en/AppNotes/01045b.pdf

[32] LSoft Technologies Inc., ”FAT File Systems. FAT32, FAT16, FAT12”, 2018. [Online]. Available:

http://www.ntfs.com/fat-systems.htm

[33] Texas Instruments. bq2407x Single-Chip Li-Ion Charge and System Power-Path Management IC.

[Online]. Available: http://www.ti.com/lit/ds/symlink/bq24070.pdf

[34] Microchip. Bluetooth® 4.2 Low Energy Module. [Online]. Available: http://ww1.microchip.com/

downloads/en/DeviceDoc/50002489C.pdf

59

Page 76: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

60

Page 77: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

AAppendix - Hardware Circuit

61

Page 78: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

62

Page 79: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

The hardware circuit is shown in Figure A.1. This is the current version of the circuit. The circuit is

divided in six parts:

1. Voltage and Current conditioning circuit;

2. microSD card and socket;

3. PIC microcontroller;

4. ADE7753 energy measuring circuit;

5. Bluetooth Module;

6. Power Supply circuit.

(a)

(b)

Figure A.1: Bottom Layer (a) and Top Layer (b) of the circuit printed circuit board.

63

Page 80: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure A.2: Power Supply Circuit.

Figure A.3: Voltage and Current Conditioning Circuit.

64

Page 81: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Figure A.4: ADE7753 energy measuring circuit.

65

Page 82: Develop, implement and characterize an electric energy … · Develop, implement and characterize an electric energy monitoring device Bernardo Ribeiro de Matos Thesis to obtain the

Table A.1: Circuit sizing values.

Component Value

Resistors

R1 470 kΩ

R2 100 Ω

R3 1, R3 2, R3 3, R3 4, R3 5, R3 6, R3 7, R3 8, R3 9 47 kΩ

R4 220 Ω

R5, R6, R7, R8 1 kΩ

Capacitors

C1 1 µF

C2 470 µF

C3, C4, C5, C6 33 nF

C7, C9 0.1 µF

C8, C10 10 µF

C11, C12 22 pF

Crystal

Y1 3.579545 MHz

66