• Nenhum resultado encontrado

Design and implementation of a plug-in power metering device

N/A
N/A
Protected

Academic year: 2022

Share "Design and implementation of a plug-in power metering device"

Copied!
90
0
0

Texto

(1)

Design and implementation of a plug-in power metering device

Carlos de Almeida Santos de Castro e Abreu

Thesis to obtain the Master of Science Degree in

Electronics Engineering

Supervisors: Prof. Pedro Miguel Pinto Ramos

Examination Committee

Chairperson: Prof. Paulo Ferreira Godinho Flores Supervisor: Prof. Pedro Miguel Pinto Ramos

Members of the Committee: Prof. S ´onia Maria Nunes dos Santos Paulo Ferreira Pinto

September 2020

(2)
(3)

Declaration

I declare that this document is an original work of my own authorship and that it fulfills all the require- ments of the Code of Conduct and Good Practices of the Universidade de Lisboa.

(4)
(5)

Declarac¸ ˜ao

Declaro que o presente documento ´e um trabalho original da minha autoria e que cumpre todos os requisitos do C ´odigo de Conduta e Boas Pr ´aticas da Universidade de Lisboa.

(6)
(7)

Acknowledgments

Gostaria de expressar toda a minha gratid ˜ao e aprec¸o a todos aqueles que, directa ou indirecta- mente, contribu´ıram para que este trabalho se torn ´asse uma realidade.

Ao Prof. Pedro Ramos e Sr. Pina por toda a orientac¸ ˜ao, apoio e disponibilidade ao longo deste processo.

Aos meus amigos, Sebas, Afonso, Pedro e Hugo, por todas as discuss ˜oes t ´ecnicas e menos t ´ecnicas.

Aos meus amigos, Pico, Joana, Rita e Bruno por todo o companheirismo e palavras de incentivo.

Ao grupo de sempre (TG) por nunca me deixarem esquecer que existe sempre um lado bom da vida.

Ao Rodrigo, pelas distrac¸ ˜oes e incentivo ao desenvolvimento de um novo hobby.

As minhas irm ˜as, Mariana e Sofia, por sempre acreditarem em mim mesmo quando eu n ˜ao o fiz.` Aos meus pais, Paula e Carlos, por sempre primarem pela minha educac¸ ˜ao e por toda a forc¸a e carinho que me t ˆem transmitido ao longo da vida.

A Lara, uma companheira eterna para a vida que nos espera, pela paci ˆencia angelical.` A todos voc ˆes, os meus sinceros agradecimentos.

(8)
(9)

Abstract

This project focuses in developing and implementing a device capable of monitoring the electric power consumption of an appliance connected to the 230 V, 50 Hz power grid.

The device presents a Schuko CEE 7/4 to connect to the grid and on the other end a Schuko CEE 7/3. The appliance maximum current is 16 A. A specific energy metering Integrated Circuit (IC) is used and sensing circuitry is included for voltage and current, to attenuate the grid’s voltage to the Analog- to-Digital Converter (ADC)’s input range of theICand convert current drawn into a differential potential, once again taking into consideration the input range.

The system includes a non-volatile memory where measured values are stored. The files format will be readable by any modern device, for example a smartphone or a computer. The system also comprises a wireless communication module, to offer system management (e.g. period between saved values) and data analysis options (e.g. graphs) to the user without interrupting the data acquisition.

Avoiding the necessity to take the Secure Digital Card (SD Card) out of the metering device to view the results, which requires the system to be halted.

The device is based on a Peripheral Interface Controller (PIC) microcontroller from Microchip, which manages data processing and communication with the energy metering IC, SD Card and bluetooth module.

Keywords

Energy metering, Single Phase, Embedded System.

(10)
(11)

Resumo

Este projeto tem como foco o desenvolvimento e implementac¸ ˜ao de um dispositivo capaz de moni- torizar o consumo el ´etrico de um eletrodom ´estico ligado a rede el ´etrica de 230 V, 50 Hz.

O dispositivo apresenta-se ligado `a rede el ´etrica atrav ´es de um conector Schuko 7/4 e na outra extremidade a um Schuko 7/3. A corrente m ´axima do eletrodom ´estico ´e de 16 A. UmICespec´ıfico para a medic¸ ˜ao de energia ´e usado bem como circuitos de condicionamento de tens ˜ao e corrente, com o intuito de atenuar a tens ˜ao da rede para a gama de tens ˜oes de entrada dosADCs do ICe converter a corrente consumida numa diferenc¸a de potencial, mais uma vez tendo em considerac¸ ˜ao a gama de tens ˜oes de entrada.

O sistema inclui uma mem ´oria n ˜ao-vol ´atil onde os valores medidos s ˜ao armazenados. O formato dos ficheiros ser ´a leg´ıvel por qualquer dispositivo moderno, por exemplo, um smartphone ou computador. O sistema tamb ´em inclui um m ´odulo de comunicac¸ ˜ao sem fios, para disponibilizar ao utilizador a gest ˜ao do sistema (ex. intervalo entre valores guardados) e opc¸ ˜oes de an ´alise de dados (ex. gr ´aficos) sem interromper a aquisic¸ ˜ao de dados. Caso contr ´ario, seria sempre necess ´ario retirar o cart ˜ao de mem ´oria do dispositivo de medic¸ ˜ao para visualizar os resultados, o que requer que o sistema seja interrompido.

O dispositivo ´e baseado num microcontrolador PIC da Microchip, que gere o processamento de dados e a comunicac¸ ˜ao com oICmedidor de energia, cart ˜ao de mem ´oria e m ´odulo bluetooth.

Palavras Chave

Contador de Energia, Monof ´asico, Sistema Embebido.

(12)
(13)

Contents

1 Introduction 1

1.1 Purpose and motivation . . . 3

1.2 Goals and challenges . . . 4

1.3 Electric Power . . . 5

1.4 Signal Acquisition . . . 7

1.5 Document organization . . . 9

2 State of the Art 11 2.1 Voltage Sensor . . . 13

2.1.1 Hall effect Voltage Transducer. . . 13

2.1.2 Voltage Transformer . . . 14

2.1.3 Resistive divider . . . 15

2.2 Current Sensor . . . 15

2.2.1 Shunt resistor. . . 16

2.2.2 Current Transformer . . . 16

2.2.3 Hall Effect Sensor . . . 17

2.2.4 Rogowski Coil . . . 17

2.3 Wireless Communication . . . 18

2.4 Non-volatile memory - SD Card . . . 18

2.5 Previous Work . . . 19

2.5.1 Intelligent Electric Energy Counter . . . 19

2.5.2 Develop, implement and characterize an electric energy monitoring device . . . . 20

2.5.3 Electric energy meter for low voltage usage . . . 21

2.5.4 A Low-cost Wi-Fi Smart Plug with On-off and Energy Metering Functions . . . 21

2.5.5 Data acquisition and control using Arduino-Android Platform : Smart plug . . . 22

2.5.6 Development of Embedded System for Making Plugs Smart. . . 23

2.5.7 Power-Efficient Smart Metering Plug for Intelligent Households . . . 24

(14)

3 System Architecture 25

3.1 Microcontroller - Microchip PIC24F . . . 28

3.2 Energy meter IC - ADE7753 . . . 32

3.3 Signal conditioning . . . 36

3.3.1 Voltage sensor - Resistive divider. . . 37

3.3.2 Current sensor - Shunt resistor . . . 37

3.4 Bluetooth module - Itead HC-05. . . 38

3.5 Memory - SD Card . . . 40

3.6 Power Supply . . . 42

3.7 Mobile Application (APP) . . . 45

3.8 Software - PIC . . . 47

4 Results 51 4.1 Energy meter IC - ADE7753 . . . 53

4.2 SD Card and Real Time Calendar-Clock (RTCC) . . . 54

4.3 Bluetooth module - Itead HC-05. . . 54

4.4 Calibration . . . 55

4.4.1 Voltage Root Mean Square (RMS) and Current RMS. . . 56

4.4.2 Active and Apparent Power . . . 56

4.4.3 Reactive Power. . . 57

4.5 Final Results . . . 57

5 Conclusions 61

xii

(15)

List of Figures

1.1 Power vectors triangle from [7]. . . 6

1.2 Three examples of waveform sampling (6 samples) adapted from [11]. . . 7

1.3 Replication of the signal spectrum to be acquired due to the signal sampling process [11]. 9 2.1 Operating principle of closed loop voltage transducer adapted from [15]. . . 14

2.2 Voltage sensor with resistive divider [7]. . . 15

2.3 Implementation of a shunt resistor [7]. . . 16

2.4 Implementing an integrator using an Operational Amplifier (OPAMP) [17]. . . 17

2.5 System diagram adapted from [9]. . . 19

2.6 Application Screens [7]. . . 20

2.7 Network design [27]. . . 21

2.8 System block diagram [27]. . . 22

2.9 Voltage sensor circuit [18].. . . 23

2.10 Block diagram of the efficient smart plug [37]. . . 24

3.1 Energy meter architecture. . . 27

3.2 PIC24FJXXXGA010 pin diagram [23]. . . 28

3.3 PIC24FJXXXGA010 clock diagram [23]. . . 29

3.4 ADE7753 functional block diagram [2]. . . 32

3.5 ADE7753 channel 1 offset range with gain set to 1 [2]. . . 34

3.6 ADE7753 Active Power calculation [2]. . . 35

3.7 ADE7753 Active Power calculation block diagram [2].. . . 35

3.8 ADE7753 Reactive Power calculation block diagram [2]. . . 36

3.9 ADE7753 Apparent Power calculation block diagram [2]. . . 36

3.10 HC-05 pin diagram [4]. . . 39

3.11 HC-05 module [4]. . . 40

3.12 SD Card Serial Peripheral Interface (SPI) interface [7]. . . 40

(16)

3.13 SD Card folder structure (red: folder path, yellow: file name). . . 41

3.14 Power Supply Unit (PSU) diagram. . . 42

3.15 IRM-15-12 block diagram [46]. . . 42

3.16 LM2575 block diagram [47]. . . 43

3.17 MCP1825 block diagram [48]. . . 44

3.18 Application screen. . . 45

3.19 Data review feature. . . 46

3.20 Live data feature. . . 47

3.21 Main loop flowchart. . . 48

3.22 Data buffers management functions. . . 49

3.23 ADE7753 interrupt function. . . 49

4.1 Software reset request. . . 53

4.2 Successful software reset.. . . 53

4.3 Printed Circuit Board (PCB)’s front view. . . 55

4.4 PCB’s back view. . . 55

4.5 Alcor HS100. [50]. . . 56

4.6 Measured RMS voltage and RMS current from a resistive load. . . 58

4.7 Measured apparent, active and reactive power from a resistive load. . . 58

4.8 Measured RMS voltage and RMS current from a rated 65 W laptop charger. . . 59

4.9 Measured apparent, active and reactive power from a rated 65 W laptop charger. . . 60

xiv

(17)

List of Tables

1.1 System specifications. . . 5

2.1 Main characteristics of wireless technologies. . . 18

3.1 Oscillator configuration. . . 29

3.2 PIC Universal Asynchronous Receiver-Transmitter (UART) error rate for various baud rates for high-speed and standard mode [23]. . . 31

3.3 ADE7753 maximum input signal levels for channel 1 [2]. . . 33

3.4 ADE7753 offset correction range for channel 1 and 2 [2].. . . 33

3.5 HC-05 current consumption [43]. . . 39

(18)

xvi

(19)
(20)

Acronyms

AC Alternate Current

ADC Analog-to-Digital Converter

AP Access Point

APP Application

ARM Advanced RISC Machine

ASCII American Standard Code for Information Interchange BLE Bluetooth Low Energy

CPU Central Processing Unit CRLF Carriage Return Line Feed CSV Comma-Separated Values CT Current Transformer CTS Clear to Send DC Direct Current

dsPIC Digital Signal Peripheral Interface Controller EDR Enhanced Data Rate

FAT File Allocation Table FRC Fast Internal Oscillator

GSM Global System for Mobile Communications I2C Inter-Integrated Circuit

xviii

(21)

IC Integrated Circuit

IDE Integrated Development Environment I/O Input/Output

IDE Integrated Development Environment IEC International Electrotechnical Commission IoT Internet of Things

LAN Local Area Network LCD Liquid Crystal Display LSB Least Significant Bit LPF Low-Pass Filter MCUs Microcontroller Units OPAMP Operational Amplifier

PIC Peripheral Interface Controller PCB Printed Circuit Board

PF Power Factor

PGA Programmable Gain Amplifier PLC Power-line Communication PLL Phase-Locked Loop PSU Power Supply Unit

RMS Root Mean Square

RS-232 Recommended Standard 232 RTCC Real Time Calendar-Clock RTS Request to Send

SD Card Secure Digital Card SoC System-on-a-chip

(22)

SPI Serial Peripheral Interface SMD Surface Mounted Device

UART Universal Asynchronous Receiver-Transmitter USB Universal Serial Bus

VT Voltage Transformer WAN Wide Area Network

xx

(23)

1

Introduction

Contents

1.1 Purpose and motivation . . . . 3 1.2 Goals and challenges . . . . 4 1.3 Electric Power . . . . 5 1.4 Signal Acquisition . . . . 7 1.5 Document organization . . . . 9

(24)

2

(25)

Introduction

1.1 Purpose and motivation

The XIX century was marked by the spread of electric energy starting with street lighting and later on in households, to power telegraphs, telephones, radios and televisions succeeded by modern appli- ances, such as fridges and washing machines. The demand for electric energy will only tend to increase as the world moves to a more interconnected society with data centers working around the clock [1].

This consumption of the modern era comes as a service and with it came the need to meter it for billing purposes. Two centuries passed by and nowadays the need to monitor the electric energy consumption goes beyond billing. This includes balancing the power grid based on demand in real time and patterns from previously logged information. Furthermore, the need of better knowing the load patterns of an equipment; where it can be a steady load or its consumption may be arranged in short bursts, lead to the development of more advanced plug-in power meters.

The objective of the prototype to be designed is a compact and remotely accessed energy metering device, where the measured power consumption is limited to one single mains appliance. This project describes the design, development and implementation of a plug-in power meter. Aside from the basic role expected from an energy meter, other functionalities characterise this device, meaning real time monitoring, long term logging, control of relevant parameters, wireless connectivity for an improved user experience.

The energy metering device will work as a man-in-the-middle; where the device is connected to the mains, and the load to a Schuko connector present on the developed device. Data about voltage, current, instant and accumulated power consumption will be acquired. A non-volatile memory; aSD Card, is present for long term logging up to a month. Moreover, the user will resort to an application on a smartphone to review data and adjust parameters.

(26)

1.2 Goals and challenges

The primary objective of this work is to develop a compact device able to monitor the electrical power consumption of an Alternate Current (AC) equipment. The project must acquire data for a long period of time and register on non-volatile memory, connect to the mains through a Schuko CEE 7/4 connection and pass-through to the metered equipment with a Schuko CEE 7/3 connection. A metering IC[2], current and voltage sensing circuitry is required for the measurement. As for processing unit, the embedded system must be based on aPIC[3]. A wireless interface [4] in conjunction with a smartphone application shall be integrated for live monitoring and download of the acquired data, improving the user experience. As such, the goals for this project are to develop:

• An embedded measurement system;

• Firmware capable of performing processing and routing of data;

• MeteringICconditioning circuit;

• Power supply;

• Integration of non-volatile memory;

• Wireless interface;

• SmartphoneAPP.

The system specifications goal is presented in Table1.1.

4

(27)

Table 1.1:System specifications.

Connector Schuko CEE 7/3 and 7/4

Input Voltage 230 V

Maximum Current 16 A

Wireless Communication Bluetooth or Bluetooth Low Energy (BLE) module

Non-volatile Memory MicroSD Card

Sampling Rate of Voltage and Current

Sensors 27.9 kSPS

Acquired Data active, reactive, and apparent power; current and voltageRMS

Microcontroller Microchip 16-bit Microcontroller, PIC24FJ128GA010

Energy MeterIC Analog Devices single meteringIC, ADE7753

1.3 Electric Power

In the XIX century a battle between two electric energy standards for mass distribution took place, between Thomas Edison (Direct Current (DC)) and Nikola Tesla (AC). The high distribution cost ofDC, mainly linked to power losses in the line that forced the presence of a power plant no further than 1 mile away from the end user, as well as the high cost and at the time lack of step-up and step-down voltage technology forDC[5] encouraged three-phaseACto be implemented. [6]

A load with an impedance purely resistive is when all power consumed by the user is transformed into transformed energy, light, mechanical, sound, etc. However, not all loads are resistive, and thus may hold a reactive component, either capacitive and/or in most cases inductive (motors, transformers).

A reactive component generates a phase shift on the sine wave of current that feeds the load.

The power dissipated in terms of resisitive component is called Active Power (P) expressed typically in kilowatts (kW), and the reactive component, Reactive Power (Q) expressed in kilovolt ampere reactive (kVAr). The later, is considered a loss, since it is not converted into other form of useful energy to the load. Apparent power (S) expressed in kilovolt ampere (kVA) is the amount of electric energy required to distribute a given (P); thus S could be equal or higher thanP. For a given sinusoidal voltage and current, apparent power, described by active and reactive power (1.1and1.2) as represented in Figure 1.1, remains constant [7].

(28)

Figure 1.1:Power vectors triangle from [7].

S~ =P+jQ. (1.1)

And

S2=P2+Q2. (1.2)

For a P equal to S, the Power Factor (PF) is unitary; meaning there is no phase shift between voltage and current. With aPFof one, all the work (P) can be done with less current. Further is the gap between voltage and current sine waves (lowerPF), the lesserP is transferred in favor ofQ. For a givenP, the lower the power factor, higherS is required to compensateQ, leading to a higher current consumption [8].

Power factor is the ratio (1.3) betweenP andS,

P F = P

S. (1.3)

Where for sinusoidal waveforms,PFhas a direct relationship with the phase shift (φ) between voltage and current, given by

P F = cos(φ). (1.4)

S (1.5) is given by theRMSvalue of voltage and theRMSvalue of current,

S =VRM S×IRM S. (1.5)

6

(29)

From (1.4), a null power factor is characterized by 90 degrees phase shift either from a capacitive load (-90) or an inductive load (90).

The energy meter should measureP andQ. The later is important specially for customers where inductive loads are more common (ACmotors and transformers) since these loads consume not onlyP but also a considerable amount ofQ. Since, in a case where the electrical energy distribution company bills only forP instead ofS, it would seem but deceitfully that the customer in question was drawing far less energy. [9]

1.4 Signal Acquisition

Acquiring a signal is an analog to digital conversion of a time-varying signal, with a fixed sampling rate. The acquisition of the power outlet will be done with uniform sampling, as the sole purpose is to acquire a known signal, for example a test was conducted in Enschede (Netherlands) [10] where its frequency rarely deviates more than 0.2 % from 50 Hz. This process will convert the continuous signal into a discrete signal; result of the sampling with a small period (discrete time) defined by the sampling rate and limited by the conversion time of the system.

An ADCdeals with the discretization of the signal amplitude into binary code based on the analog value at the input and resolution; the number of bits of the converter. This data is then processed and turned into meaningful information through a Central Processing Unit (CPU).

On the other hand, the process of acquiring a waveform trough sampling loses any information be- tween samples; the same discrete signal may characterize numerous continuous signal as demonstrated in Figure1.2.

Figure 1.2:Three examples of waveform sampling (6 samples) adapted from [11].

(30)

This phenomena can be explained by the Sampling Theory [11] also known as Nyquist Theorem, Shannon Theorem or Nyquist-Shannon Theorem that was demonstrated in the first half of the XX cen- tury [12] [13]. The baseline of this theory shows that for a signal with a limited bandwidth, if acquired with a sampling rate of at least two times higher than its bandwidth, it is possible to rebuild the original signal. This approach mitigates the event of sudden variations between samples [11].

The process of sampling corresponds to multiplying the signal desired to be acquired (x(t)) by a sum of Dirac delta functions analogous to the sampling moments. This sum is also known as unit impulse symbol is described by

d(t) =

X

n=−∞

δ(t−n∆t), (1.6)

where∆tis the time interval between samples and corresponds to the inverse of the sampling rate

fs= 1

∆t. (1.7)

Sampling a signal corresponds to multiply (1.6) by the signalx(t), where the signal value is only kept at the sampling instants and between them all information is lost,

x(t)×d(t) =x(t)×

X

n=−∞

δ(t−n∆t) =

X

n=−∞

x(n∆t)×δ(t−n∆t). (1.8) In the frequency domain, (1.8) corresponds to applying a convolution function to the signal spectra X(f)and the Dirac sumD(f),

T F[x(t)×d(t)] = X(f)∗D(f) 2π =fs×

X

k=−∞

X(f−kfs), (1.9)

withD(f)defined by

D(f) =T F[d(t)] = 2πfs

X

k=−∞

δ(2πf −k2πfs) = 2πfs

X

k=−∞

δ(f−kfs), (1.10) Equation 1.9 describes that the sampled signal spectrum will correspond to the sum of spectral replicas of the signal to be sampled,X(f). These replicas are centered at the on multiple frequencies of the sampling frequency, as depicted in Figure1.3.

In Figure1.3there is no overlap of the multiple spectral replicas of the signal to be acquired, since there is enough margin between the end of the spectrum to be acquired and the start of of the first spectral replica, present atfs−fmax. To ensure no superposition,fmax< fs−fmaxthus leading to the relation, defined by the Sampling Theory

8

(31)

Figure 1.3:Replication of the signal spectrum to be acquired due to the signal sampling process [11].

fs>2×fmax, (1.11)

or the Nyquist frequency defined by

fN = fs

2 > fmax. (1.12)

1.5 Document organization

This document is organized as follows:

• Chapter1is a introduction about the project development, choices taken to tackle the the problem and some considerations about electric power and signal sampling.

• Chapter2 is the state of the art, in this chapter it is presented some of the work already done in plug-in power meters with non-mechanical solutions.

• In Chapter3the architecture of the proposed system is shown and the selection of components is detailed.

• Chapter4presents the project results.

• Chapter5presents the project conclusions and suggestions for future work.

(32)

10

(33)

2

State of the Art

Contents

2.1 Voltage Sensor. . . 13 2.2 Current Sensor. . . 15 2.3 Wireless Communication. . . 18 2.4 Non-volatile memory - SD Card . . . 18 2.5 Previous Work . . . 19

(34)

12

(35)

State of the Art

2.1 Voltage Sensor

The national residential electric grid has an RMSvoltage value of 230 V, and ADCs require lower input voltage; thus there is a need to create a conditioning circuit. There are three methods that could be implemented:

• Hall effect voltage transducer;

• Voltage Transformer (VT);

• Resistive divider.

2.1.1 Hall effect Voltage Transducer

On an Hall effect based voltage transducer, a primary winding is fed by a current proportional to the voltage to be measured, generating a magnetic flux. Separated by a small air gap there is a Hall effect sensor which senses this flux, causing a potential difference at the output. The output can be connected in a open loop or closed loop [14]:

• in open loop the output of the Hall Effect sensor is the system output; the core can be easily saturated and is characterized with greater nonlinearity in terms of error with respect to the closed loop;

• in closed loop the Hall Effect sensor output feds current to a secondary winding, amplified by a high-gainOPAMPand translated into voltage by a resistor with exactly the same waveform of the primary current (Figure2.1);

(36)

Figure 2.1:Operating principle of closed loop voltage transducer adapted from [15].

This setup offers galvanic isolation between the high voltage line and the data acquisition system, providing remarkable linearity and bandwidth compared to transformers [14]. Although, its working principle makes it susceptible to false readings due to external magnetic fields [16].

2.1.2 Voltage Transformer

A voltage transformer offers a simple solution to step-down the voltage to a suitable range; based on induction between a primary and a secondary winding. Galvanic isolation can be guaranteed but considerable volume and high cost must be taken into account. The voltage at the secondary is

VS= nP

nS

VP, (2.1)

whereVP is the voltage in the primary (RMS230 V),VS the output voltage in the secondary winding.nP

andnS the number of turns in the primary and secondary winding, respectively [7].

14

(37)

2.1.3 Resistive divider

A resistive divider is a series of resistors to create an attenuation network placed in parallel with the source. Resistors should be high valued to pull the least current possible; diminishing its effect on the source. This setup is described by the source voltage, the series of resistors and the desired output voltage; as shown in Figure2.2and defined by

Vout = R2 R1+R2

×VAC. (2.2)

Figure 2.2:Voltage sensor with resistive divider [7].

This configuration is the cheapest of them; although it requiresR1to be a series of multiple resistors to share the dissipated power across them. The occupied area is small, especially if Surface Mounted Device (SMD) resistors are used but lacks the advantage of isolating the output from the mains.

2.2 Current Sensor

The load voltage does not vary much contrary to current; thus it is required a wider measurement dynamic range and frequency range due to rich harmonic contents in the current waveform. There are several current sensor topologies, such as [17]:

• Low resistance current shunt;

• Current Transformer (CT);

• Hall effect sensor;

• Rogowski coil.

(38)

2.2.1 Shunt resistor

A shunt resistor is the cheapest solution for current sensing; with highly stable low values available in the range ofµΩto mΩ. This resistor should be placed in series with the load, as shown in Figure2.3.

The voltage across the resistor is proportional to the current flowing through it

I= U

R. (2.3)

Figure 2.3:Implementation of a shunt resistor [7].

Two disadvantages to take into consideration is parasitic inductance and dissipated power. When performing high precision current measurements even at line frequency, the inductance is generally in the order of nH but its effect in the phase can be significant enough to cause an error in case of a low power factor. The heat dissipated by the resistor is proportional to the square of the current flowing and the smaller its value lesser the heat generated [7] [17].

2.2.2 Current Transformer

A current transformer translates the current flowing through the primary winding, which is connected in series with the load, into a lower current in the secondary. Among high currents measurements, this topology is the most common. It’s a low power sensor, having little impact on the measured current and deals great with high currents. It presents a low phase-shift if calibrated although in extreme cases of current or substantial presence ofDCcomponent it may saturate due to the core characteristics. After the ferrite core is magnetized, it will show hysteresis with negative repercussions on its accuracy, until demagnetized [17].

16

(39)

2.2.3 Hall Effect Sensor

As in Hall effect voltage transducers there are open-loop and closed-loop implementations. The first being the option with lower cost. The system withstands measuring very large current and has a good frequency response. On the other hand, the output of the Hall effect sensor is sensitive to temperature and usually requires a stable external current source [17].

2.2.4 Rogowski Coil

A Rogowski coil is an inductor which has mutual inductance with the conductor carrying the current to be measured. This phenomena makes that a change in the current passing through the wire causes an induced electromagnetic force in the coil, due to the magnetic field generated. Rogowski coil typically has a core of air, so in theory there is no hysteresis, saturation or non-linearity. Its low inductance allows for fast response to current changes and the lack of an iron core makes it respond linearly even at high currents. These characteristic as well as its smaller size and cost compared to aCT make it a better option for high current applications, such as, in electrical power transmission. Its output is proportional to the time derivative of the current

Vout(t) =− 1 RC

Z

vin(t)dt, (2.4)

therefore requires an integrator with anOPAMPas shown in Figure2.4[17].

Figure 2.4:Implementing an integrator using anOPAMP[17].

(40)

2.3 Wireless Communication

Wireless communication offers further flexibility to the system by removing the need of a cable and by making it more versatile in terms of to what it can connect to. Smartphones lack ethernet ports and even some laptops nowadays. For the device in development, a short range wireless connection is ideal for system management since all data is saved locally there is no need to constantly upload it elsewhere. Embedded systems in general implement short range wireless communication such as Bluetooth, Bluetooth Low Energy (BLE), WiFi or ZigBee [18]. Table2.1presents the main characteristics of these wireless technologies [19] [20].

Table 2.1:Main characteristics of wireless technologies.

Standard WiFi ZigBee Bluetooth Bluetooth Low

Energy Network

Topology Star Star/Mesh Star Star

Data Rate (Mb/s) 54 0.25 3 1

Maximum Power

Consumption 700 mW 75 mW 100 mW 50 mW

Range 100 m 30 m 100 m 30 m

WiFi would be useful for an Internet of Things (IoT) approach since it would be the only standard implementation that would easily connect to an existing Access Point (AP) connected to the internet.

Although it is the fastest option and with high range, there is no benefit to include the system in a Local Area Network (LAN) if there is no desire to implement a server to make it accessible outside (Wide Area Network (WAN)). The current implementation of this project looks to include a wireless interface but not to make it remote accessible since it would increase the total system cost and complexity.

ZigBee is a low power, highly resilient wireless network type, with range that could match WiFi and can be further expanded through a mesh topology. But it isn’t commonly offered on smartphones and laptops, external modules would need to be acquired [21].

Bluetooth orBLE offers enough range for the purpose of the developed system, it is low cost, low power and is available in virtually any device making it ideal in terms of versatility.

2.4 Non-volatile memory - SD Card

A non-volatile memory allows the metering system to be independent in terms of data logging.

SD Cardoffers a good price per GB ratio, enough capacity for long term logging, basic and fast com- munication throughSPIinterface. Furthermore, its popularity made available a number of abstraction li-

18

(41)

braries to simplify the programming necessary for the interaction between the embedded system and the SD Card. These abstraction layers also implement a filesystem such as File Allocation Table (FAT); mak- ing theSD Cardcompatible with a broad range of devices (computers, smartphones, tablets, etc.) [22].

2.5 Previous Work

This section presents some related projects developed in the last decade.

2.5.1 Intelligent Electric Energy Counter

This project [9] consist of an energy metering system capable of measuring the power consumption in real-time. Based on aPIC24 microcontroller [23], it resorts to the built-inADCs for sampling the voltage and current sensing circuits (Voltage transformer TZ111V and Current transformer TC174V [24]), then the live information is presented on a Liquid Crystal Display (LCD) display, as depicted in Figure2.5.

This device accounts with the following major characteristics: possibility to miniaturize it, low power consumption and the main advantage for the final user, the possibility to visualize the results through the display.

Figure 2.5:System diagram adapted from [9].

(42)

2.5.2 Develop, implement and characterize an electric energy monitoring de- vice

The objective of this thesis [7] was to develop an energy metering device. Based on aPIC24 micro- controller [23] and a specificICfrom Analog Devices (ADE7753 [2]) for sampling the voltage and current sensing circuits, voltage divider and shunt resistor, respectively. Live information is presented on aLCD display and in the developped androidAPPeither live measurements or the previously logged data, as depicted in Figure 2.6. There is also the possibility to transfer the raw data from theSD Card to any electronic device runing any modern operating system (e.g. Microsoft Windows, Linux, Apple MacOS, Android).

Figure 2.6:Application Screens [7].

20

(43)

2.5.3 Electric energy meter for low voltage usage

The work presented in [25] consists on the development, implementation and design of a single phase energy meter for low voltage use. This device can be used in installations up to 30 A and has as aCPUa Digital Signal Peripheral Interface Controller (dsPIC) from Microchip, which communicates with a a specificICfor energy metering, capable of reportingRMScurrent,RMSvoltage, and instantaneous as well as accumulated power consumption. The voltage sensor is a resistive divider and the current sensor a shunt resistor. The information is displayed on a LCD and can be sent through Universal Serial Bus (USB) and/or Recommended Standard 232 (RS-232) interface. A transformerless power supply was used to power-up the device which draws less than 2 W, meeting the requirements for IEC62053 standard [26].

2.5.4 A Low-cost Wi-Fi Smart Plug with On-off and Energy Metering Functions

The paper presented in [27] consist of a device based on a ESP-WROOM2 [28], a microcontroller with a built-in WiFi module, another part consists of a relay driver with a voltage quadrupler (from 3.3 V to 12 V) and a relay to latch the supply from the load. It operates with devices on the same network; such as a homeAP; making it easy to interact with virtually any modern mobile device through a WebApp as shown in Figure2.7.

Figure 2.7:Network design [27].

The system communicates internally throughSPIbetween the microcontroller and the energy meter (STPM01 chip [29]) and a couple IO pins to flag the relay driver and voltage quadrupler, as shown in Figure2.8.

(44)

Figure 2.8:System block diagram [27].

The STMP01 energy meter is capable of calculating RMS voltage, RMS current, apparent power, frequency, power and power factor from the sampled data. The device was tested with a single-phase ACpower supply, CAL-SOURCE 200 [30], set at 220 VAC at 50 Hz and a phase angle fixed at 0 degree;

varying the current from 1 A up to 10 A the system accuracy of measurement resulted in magnitude error less than 0.5 % [27].

2.5.5 Data acquisition and control using Arduino-Android Platform : Smart plug

In [31], a paper describes the development of a smart plug for remote monitoring. Implemented on an open source microcontroller, the Arduino Duemilanove (ATmega168 or ATmega328 [32]) which communicates viaSPIinterface with an ethernet module (enc28j60 [33]) to connect to the internet. The system resorts to an non-invasive technique for current sensing with a current transformer (SCT-013- 030 [34]). It is capable of sensing up to 30 A and outputs a maximum of 1 V, acquired by the included ADCwhich makes part of the Arduino peripherals. Furthermore, a server was required to be setup and connected to theAP, as well as an AndroidAPP[31].

22

(45)

2.5.6 Development of Embedded System for Making Plugs Smart

The project presented in [18] tackles the multiple attempts to create a smart plugs, points out the multiples approaches to the wireless and non-wireless communication techniques for remote manage- ment: Global System for Mobile Communications (GSM), Bluetooth, Power-line Communication (PLC), ZigBee [35] and Ethernet. The embedded system is described as a microcontroller, Arduino mega 2560 [32], linked to the internet via an ethernet cable connected to theAPthrough an external Arduino module, Ethernet shield [36]. Current sensing is done with the SCT-013-030 [34], a split core current transformer. Arduino does not have anyACcapable inputs, neither accepts inputs above 5 V, thus anAC toDCand step down circuit was developed to create the voltage sensor based on a full-bridge rectifier shown in Figure2.9. An Android APPwas developed to display information such as Apparent power, ACvoltage,ACcurrent and control up to 8 devices in the network (turn on or off) [18].

Figure 2.9:Voltage sensor circuit [18].

(46)

2.5.7 Power-Efficient Smart Metering Plug for Intelligent Households

In [37] a power-efficient solution for smart metering plugs is described; it gives emphasis on the fact that most smart plugs that are wireless use WiFi, a fairly inefficient solution [38] compared toBLE[39].

The proposed solution resorts toBLEdue to its compatibility with a wide range of devices while keeping the power consumption low. The project was focused on the following requirements:

• compactness - built-in type of smart plug.

• low power - power efficient solution.

• easy integration - compatible with other devices.

• increased security - a secure element integrated.

• low price - reasonable price for large scale deployment.

The system is built around a System-on-a-chip (SoC), a power efficient Advanced RISC Machine (ARM) Cortex M0 core extended by a BLE transmitter and peripherals for SPI, Inter-Integrated Cir- cuit (I2C) andUARTcommunication. The metering front-end of the smart plug is based on Infineon’s dual channel on-chip isolatedADCchip that provides serial data from two sigmadeltaADCs via aSPI interface. On the high voltage side of the ADC, both channels are connected as voltage and current monitors using a voltage divider and a current shunt, respectively. The whole smart plug is powered from the mains using an AC to DC converter in step down configuration with 3.3 V as the nominal output voltage. The system only requires a 3.3 V supply and is characterised by a peak power consumption of 170 mW. The full system diagram is depicted in Figure2.10[37].

Figure 2.10:Block diagram of the efficient smart plug [37].

24

(47)

3

System Architecture

Contents

3.1 Microcontroller - Microchip PIC24F . . . 28 3.2 Energy meter IC - ADE7753 . . . 32 3.3 Signal conditioning . . . 36 3.4 Bluetooth module - Itead HC-05 . . . 38 3.5 Memory - SD Card . . . 40 3.6 Power Supply . . . 42 3.7 Mobile APP . . . 45 3.8 Software - PIC . . . 47

(48)

26

(49)

System Architecture

The developed system is comprised by current and voltage sensors, an energy meter IC, a non- volatile memory unit, a wireless communication interface and aPICmicrocontroller.

The energy meteringICcontinuously acquires samples from both current and voltage sensors, and thePICgathers information from theICwhen requested either via an interrupt or a bluetooth request. All data received on the microcontroller regarding voltage, current and power are stored on anSD Card.SPI is used to communicate between thePICand theSD Card. TheUARTmodule is enabled to interface with the bluetooth module. Communication with the energy meter is achieved throughSPI. An overview of the system architecture is represented in Figure3.1.

Figure 3.1:Energy meter architecture.

(50)

3.1 Microcontroller - Microchip PIC24F

Microchip’s PIC24 family of Microcontroller Units (MCUs) features a 16 MIPS core and enhanced on-chip peripherals [23]. It communicates through SPI1 module with theSD Card, SPI2 module with the energy meter ICandUARTwith the Bluetooth module. There is also anotherUARTand two I2C modules available. This number of communications modules allow for various interface configurations with minimum compromises. Another feature worth mentioning is the availability of aRTCC, five timers and interrupts based on external inputs, timers or peripherals. Lastly, the program language used is C and the program is uploaded to the unit via a PICkit3 programmer [40]. A pin diagram of the usedPIC24 is depicted in Figure3.2.

Figure 3.2:PIC24FJXXXGA010 pin diagram [23].

An Fast Internal Oscillator (FRC) feeds a clock source of 8 MHz and with the integrated Phase- Locked Loop (PLL), it reaches 32 MHz, maximizing the peripherals clock at 16 MHz by following

FC Y = FO S C

2 . (3.1)

28

(51)

All clock sources and derivatives used in this project are described in Table3.1.

Table 3.1:Oscillator configuration.

FOSC RT C PLL Multiplier F RCP LL FCY

8 MHz 32.768 kHz 4× 32 MHz 16 MHz

A simplified diagram of the oscillator system present in thePIC24FJXXXGA010 family is depicted in 3.3.

Figure 3.3:PIC24FJXXXGA010 clock diagram [23].

(52)

The system was designed so that by tweaking three properties, namely theUARTclock, enable/dis- able predefinedCT SandRT S pins and customize the termination character, anyUARTcapable blue- tooth module can be used.PIC’sUARTmodule has a register controlled baud rate generator (U BRGX), which values can be calculated depending on the selected mode set byBRGH. [3]

ForBRGH= 1, high-speed mode is enabled (4 clocks per bit period),BRGHis given by

U BRGX=IN T

FC Y 4×baudratedesired

−1

. (3.2)

Resulting in a actual baud rate of,

baudratecalculated= FC Y

4×(U BRGX+ 1). (3.3)

And forBRGH= 0, standard mode enabled (16 clocks per bit period), by

U BRGX =IN T

FC Y

16×baudratedesired

−1

. (3.4)

Giving an actual baud rate of,

baudratecalculated= FC Y

16×(U BRGX+ 1). (3.5)

Lastly, the error is given by,

Error=baudratecalculated−baudratedesired

baudratedesired . (3.6)

The results are displayed in Table3.2. The baudrate was set at 115.2 kHz delivering an error free and more stable communication with the bluetooth module.

30

(53)

Table 3.2:PIC UARTerror rate for various baud rates for high-speed and standard mode [23].

Set Baud Rate 921600 460800 307200 230400 115200 57600 38400 19200 9600

Calculated Baud Rate

(BRGH= 1) Error

1000000 0.085%

500000 0.085%

307692 0.001%

235294 0.021%

117647 0.021%

57971 0.006%

38461 0.001%

19230 0.001%

9615 0.001%

Calculated Baud Rate

(BRGH= 0) Error

1000000 0.085 %

500000 0.085 %

333333 0.085%

250000 0.085%

125000 0.085%

58823 0.021%

38461 0.001%

19230 0.001%

9615 0.001%

In addition to the three serial peripherals used to access the SD Card, transmit/receive data over Bluetooth and communicate with the energy meterIC, the integratedRTCCis set to append timestamps to the acquired samples.

Furthermore, three interrupts are active, two of which are triggered by external inputs and the third one by the UART module. These external inputs are configured as such to detect the insertion of the SD Card leading to its initialization and to sense the zero-crossing output (ZX) from the energy meter IC thus synchronizing the reading of the registers [2]. UART interrupts allows the system to fetch the streamed data from the Bluetooth module to a software buffer as soon as it’s available without polling; received strings can be later processed when the system is free of other more critical tasks (e.g.

retrieving samples from theIC, free buffer space by flushing samples to theSD Card).

(54)

3.2 Energy meter IC - ADE7753

The Analog Devices’s ADE7753 is an energy meterICwith a high accuracy, compliant with the fol- lowing International Electrotechnical Commission (IEC) standards: IEC 60687/61036/61268 and IEC 62053-21/62053-22/62053-23.TheIC is intended for single phase applications with all the signal pro- cessing required to perform active, reactive and apparent power calculation. It can also measureRMS voltage andRMScurrent. This energy meter resorts to two second-orderΣ−∆ADCs to acquire the analog inputs. TheICpower consumption tops at 25 mW with a 5 V supply. [2]

The ADE7753 is compatible withSPIto read data and allows calibration for power, phase and input offset with on-chip registers. Furthermore, it contains a Programmable Gain Amplifier (PGA) (up to 16×) to adapt for a smaller input range in case of a shunt or current transformer, along with an internal integrator in channel 1 for use with Rogowski coil sensors [17]. The chip also provides a pulse output frequency (CF) proportional to the active power and a zero-crossing output signal. It is characterized by less than 0.1% error in active power measurements over a dynamic range of 1000:1 at an ambient temperature of 25C. The functional block diagram is presented in Figure3.4. [2]

Figure 3.4:ADE7753 functional block diagram [2].

The ADE7753’s sensing inputs are comprised of two fully differential voltage input channels with a maximum voltage range of±0.5 V. Both channels have aPGAwith user defined gains of 1, 2, 4, 8 and 16. Furthermore, channel 1 also has a full-scale input range selection for itsADC. Table3.3summarizes all possible setup combinations for thePGAand channel input range.

32

(55)

Table 3.3:ADE7753 maximum input signal levels for channel 1 [2].

Max Signal Channel 1

0.5 V 0.25 V 0.125 V 0.0625 V 0.0313 V 0.0156 V 0.00781 V

ADC Input Range Selection 0.5 V 0.25 V 0.125 V

Gain = 1 - -

Gain = 2 Gain = 1 -

Gain = 4 Gain = 2 Gain = 1 Gain = 8 Gain = 4 Gain = 2 Gain = 16 Gain = 8 Gain = 4

- Gain = 16 Gain = 8

- - Gain = 16

At theADClevel, it is also possible to adjust offset errors in the range of 20 mV to 50 mV based on the gain set and the Least Significant Bit (LSB) weight, as described in Table3.4and depicted in Figure 3.5.

Table 3.4:ADE7753 offset correction range for channel 1 and 2 [2].

Gain Correctable Span LSBsize

1 ±50 mV ±1.61 mV/LSB

2 ±37 mV ±1.19 mV/LSB

4 ±30 mV ±0.97 mV/LSB

8 ±26 mV ±0.84 mV/LSB

16 ±24 mV ±0.77 mV/LSB

(56)

Figure 3.5:ADE7753 channel 1 offset range with gain set to 1 [2].

The zero-crossing detection circuit generates its output in regards to the channel 2 input;ZXsignal is logic high when a rising flank crosses zero and logic low on a falling edge crossing zero. This output is used to generate interrupts and synchronize readings, as well as for calibration purposes.

The ADE7753’s channel 1 and 2 sample voltage inputs at a user selected rate depending on the M ODE register configuration, the offered options are 3.5 kSPS, 7 kSPS, 14 kSPS or the default and used in this project, 27.9 kSPS. TheRMSvalues are then simultaneously calculated for both channels by

VRM S = v u u t 1 N ×

N

X

i=1

V(i)2 (3.7)

and saved in their corresponding registers (V RM S, IRM S). All conversions from the registers values to Volts (channel 2) and to Amps (channel 1) must be done in the microcontroller; taking into account the selected input range and gains for theADCs, as well as the designed voltage and current sensor circuits.

The average power over a defined integral number of periodsnis given by,

P = 1 nT

Z nT

0

p(t)dt=V I, (3.8)

whereT is the line cycle period,V is theRMSvoltage andItheRMScurrent.

Active power3.8, is equal to theDCcomponent of the instantaneous power signal,V I. Extracted from the multiplication of voltage and current signals by a Low-Pass Filter (LPF), specified in Figure 3.4and3.7asLP F2; this process can be visualized in Figure3.6and corresponding block diagram is depicted in Figure3.7.

34

(57)

Figure 3.6:ADE7753 Active Power calculation [2].

Figure 3.7:ADE7753 Active Power calculation block diagram [2].

The average reactive power over a selected integral number of lines cycles (n) is given by,

RP = 1 nT

Z nT

0

Rp(t)dt=V Isin(φ), (3.9)

whereφis the phase difference between the voltage and current channel.

Reactive power3.9, is the product of voltage and current drifted apart by 90, meaning the channel 1 input is shifted 90 from channel 2 and then theDCcomponent of the instantaneous reactive power signal is extracted by theLPF, as depicted in the block diagram of Figure3.8.

(58)

Figure 3.8:ADE7753 Reactive Power calculation block diagram [2].

Apparent power, as defined in1.5, is the maximum power that can be feed to a load; whereVRM S

andIRM S are the effective voltage and current delivered. And is independent from the phase shiftφ, the drift between the current and voltage. Figure3.9shows the process of calculation of the apparent power.

Figure 3.9:ADE7753 Apparent Power calculation block diagram [2].

3.3 Signal conditioning

The energy meter ICcontains twoADCwith a variety of user defined input gains, as it includes a PGAin each channel; nonetheless it has a maximum differential input range of±0.5 V. A conditioning circuit is present at the input to meet the ICinput range, and if necessary it’s possible to amplify the resulting signal to an ideal range avoiding loss of information due to the signal amplitude or theADCs resolution.

36

(59)

3.3.1 Voltage sensor - Resistive divider

The choice of voltage sensor was focused on low cost and reduced footprint thus leading to a resistive divider setup. The attenuation network is composed of a single 1 kΩresistor and two 499 kΩresistors, resulting in a ratio of

ratio= R2

(R1+R2) = 1000

499000×2 + 1000= 1×10−3. (3.10) For a voltage peak of 425 V (300 VRM S), the voltage sensor output is

Voutput=Vpeak×ratio= 425×1×10−3= 0.425 V. (3.11) And the maximum current is,

Ioutput= Vpeak

(R1+R2) = 4.254×10−4= 0.425 mA. (3.12) Resulting in a power consumption per resistor of,

Pmax=Ioutput2 ×R, (3.13)

P499k = 4.254×10−42

×499000 = 90.3 mW, (3.14)

P1k= 4.254×10−42

×1000 = 180µW. (3.15)

The resistors of 1 kΩ(ERJP06F1001V) and 499 kΩ(ERJP06F4993V) used for the voltage sensor, have a power dissipation characteristic of 500 mW. This large margin in terms of power dissipation allows for cooler operation and a steadier temperature overall for the resistors, thus mitigating the resistance drift that otherwise could occur with the temperature increase. [41]

3.3.2 Current sensor - Shunt resistor

Once again, the selection for the current sensor relies on the same attributes, low cost and small footprint. A 10 mΩShunt resistor is chosen taking into consideration its power dissipation capabilities and temperature coefficient. As detailed in Table1.1, the system must handle to measure current up to 16 A, which leads to

Pshuntmax=Imax2 ×Rshunt= 2.56 W, (3.16)

(60)

of power generated as heat, that has to be dissipated by the Shunt.

In this case, sensed voltage in theICinput is

Voutmax =Imax×Rshunt= 0.16 V. (3.17)

The voltage output of the selected current sensor is within energy meterICrange.

Lastly, a small temperature coefficient is required so that as current increases, thus also the heat generated (3.16), the shunt resistor preserves its characteristics. Based on availability, the smallest temperature coefficient is ±50 ppm/ C. A 3 W current sense chip resistor of 10 mΩfrom Bourns is used as current sensor [42]. It complies with the requirement and handles a maximum working current of

Ishuntmax= Pshuntmax Rshunt

= 3

0.01= 17.32 A. (3.18)

3.4 Bluetooth module - Itead HC-05

Wireless communication is carried by a Bluetooth module with the task to create an abstraction layer from the wave driven transmission to the available serial communication, most of which the available solutions resort toUART.

The Itead HC-05 [4] supports Bluetooth 2.0 with Enhanced Data Rate (EDR), delivering a maxi- mum bit rate of 3 Mbps. Connects to the PICviaUART, it allows data to be streamed bidirectionally.

Any American Standard Code for Information Interchange (ASCII) string sent to the module, either via Bluetooth from a smartphone or from the microcontroller viaUARTis echoed to the other device. The termination character, declaring the end of transmission, is a Carriage Return Line Feed (CRLF).

Parameters can be user defined viaUART, such as customizing the device name and the pairing pin code, when powered inAT mode also known as command mode [4]. There is a dedicated pin (PIO11) to enter this mode; it is required to pull-high the pin before powering the module. A pin diagram is shown in Figure3.10. The chip operates at 3.3 V and features a low power operation for its Input/Output (I/O) (1.8 to 3.3 V). [4]

38

(61)

Figure 3.10:HC-05 pin diagram [4].

As for peak current consumption, the HC-05 caps out at 40 mA while pairing to a device, after which the current drawn is 8 mA in any case; as described in Table3.5. [43]

Table 3.5:HC-05 current consumption [43].

Parameter Min. Max. Units

Pairing 30 40 mA

TX mode Peak Current - 8 mA

RX mode Peak Current - 8 mA

The available module has sixI/O’s of the thirty-four pins of the chip (Figure3.10);V DD(5 V in this specific version) andGN Dto power the device,T XandRXforUARTcommunication,ST AT E(P IO1) that drives an LED to offer a quick visual indicator of the bluetooth connection state andEN (P IO11) which can also be triggered via an on-board push-button to enter inAT mode, as depicted in Figure 3.11.

(62)

Figure 3.11:HC-05 module [4].

The baud rate of the unit can be configured. An experiment was setup to check the stability of the selected baud rate. A string was sent repeatedly viaUARTto the Bluetooth module and echoed to a smartphone running a serial terminal, if any character was missing or incorrect; it was considered unstable. Clear to Send (CTS) and Request to Send (RTS) pins are physically inaccessible in this version of the module (Figure3.11), all tests were conducted without flow control, from which the maximum baud rate achieved for viable operation was 115.2 kHz.

3.5 Memory - SD Card

Non-volatile memory allows the system to store and keep the previously measured data even when powered down. TheSPIinterface connection between the PICand theSD Cardis depicted in Figure 3.12[7].

Figure 3.12:SD Card SPIinterface [7].

40

(63)

All the acquired samples will be saved on this type of memory, following a specific file tree organiza- tion. CDpin doesn’t take part of theSPIinterface, it’s a switch present on theSD Cardholder that gets closed when a card is inserted. The microcontroller should have a pin set as input to sense the closed circuit and initialize theSD Cardwhen inserted.

To interface with the SD Card memory blocks a file system (FAT) and library module, FatFS, was implemented. Offering an abstraction layer on the programming side to create/read/edit folders and files tailored to small embedded systems, while keeping theSD Cardinterpretable by any device. [44]

TheFATfile system was originally designed for small volumes and simple folder structures. InFAT, memory sectors are combined into clusters, there is an allocation table keeping track of the starting cluster of each folder/file and each cluster then points to the next one that comprises the file or a end- of-file indicator. [7]

The chosen file structure is comprised of a main folder (year), a sub-folder (month), another sub- folder (day of the month) and lastly a text file (hour) in Comma-Separated Values (CSV) format where data is saved (e.g. /YEAR/MONTH/DAY/hour.csv). This setup minimizes the number of files per folder which helps prevent hangups or even disk failure, while offering the user ease of navigation through the acquired data. As an example, the system was initialized on the 8 of September 2020 at 17h, the SD Cardfolder structure and file naming scheme is depicted in Figure3.13.

Figure 3.13:SD Cardfolder structure (red: folder path, yellow: file name).

Each sample is a new line written into the appropriate file based on its timestamp and offers informa- tion in the following order: number of sample,RMSvoltage,RMScurrent, apparent power, active power, reactive power and timestamp.

(64)

All files and folders, for a complete thirty-one day run, are created at startup to reduce write time when flushing the acquired data into memory. But a dynamic function was also implemented, in such way that if left more than thirty-one days running, there is no major data loss since files and folder will continue to be created as needed; making theSD Cardvolume size the real limiting factor. Although, due to the time required for these actions to complete (file: two seconds, folder: five seconds) some data may be lost during the process of file/folder creation, depending on the selected acquisition rate.

Lastly, if the user requests to stop the run prematurely, all empty files and folder are deleted.

3.6 Power Supply

The system requires two different voltage rails to work, 3.3 V and 5 V. For the implemented microcon- troller family (PIC24F) andSD Card, 3.3 V is needed and 5 V for the energy meterIC(ADE7753). The bluetooth module (HC-05) can be powered with 5 V through the module or 3.3 V if connected directly to the chip. The power source of the system is the mainsACoutlet.

The total system power consumption is 235 mA on the 3.3 V rail and 84 mA for the 5 V rail. The microcontroller running at the maximum frequency (Table3.1) draws 35 mA, theSD Card can peak to 200 mA, the energy meterIC4 mA and the bluetooth module up to 80 mA. [3] [2] [43] [45]

Figure3.14presents a diagram of the designed power supply setup.

Figure 3.14:PSUdiagram.

A universalACinput (85 to 264 VAC [46]) switching power supply rectifies and attenuates the mains ACvoltage toDC12 V. Other characteristic such as short circuit, overload and over voltage protection, make the IRM-15-12 a compact, reliable and affordable solution to generate 12 V. This switching power supply can deliver up to 1.25 A. The block diagram is represented in Figure3.15. [46]

Figure 3.15:IRM-15-12 block diagram [46].

42

(65)

It is required to further step-down the voltage to the required levels. From 12 V to 5 V, there is a 7 V drop, power dissipation is a concern, but can be circumvented with a step-down voltage switching regulator. The LM2575-5, when powered with 12 V, can deliver up to 1 A with a voltage output between 4.75 V and 5.25 V with 77 % efficiency. The power dissipated is low thus no heatsink is required. This switching regulator shuts down when internal temperature reaches 150C and has a thermal resistance characteristic of 65C/W. For the device to shut down, it would require an ambient temperature over 100C, since generated power is low and can be calculated by [47]

Pmax= (Vinmax×IQmax) + Vout

Vinmin

×Ioutmax×Vsatmax

= ((12×1.05)×0.011) +

5 12×0.975

×1×1.3 = 0.694 W.

(3.19)

Leading to an internal temperature rise over ambient of

Trise=Pmax×Rφ= 0.694×65 = 45.12C. (3.20) The switching voltage regulatorICis presented in Figure3.16. [47]

Figure 3.16:LM2575 block diagram [47].

(66)

Lastly, a linear voltage regulator is used to achieve the final step-down to 3.3 V, from the 5 V supplied by the LM2575-5 output. The chosen MCP1825S variant is a SOT-223-3 package with a fixed 3.3 V output, accepts inputs in the range of 2.1 V to 6 V, has a current limit of 500 mA and has integrated over temperature and short circuit protection. This linear regulator shuts down when internal temperature reaches 150C and has a thermal resistance characteristic of 62C/W. For the device to shut down, it would require an ambient temperature over 80C, since generated power is low and can be calculated by

Pmax= (Vinmax−Voutmin)×Ioutmax

= ((5×1.05)−(3.3×0.975))×0.5 = 1.016 W.

(3.21)

Leading to an internal temperature rise over ambient of

Trise=Pmax×Rφ= 1.016×62 = 63C. (3.22)

The MCP1825S’s functional block diagram is depicted in Figure3.17. [48]

Figure 3.17:MCP1825 block diagram [48].

44

(67)

3.7 Mobile APP

A smartphone mobileAPPwas developed to complement the designed system. It offers the possibil- ity to review previously acquired data (voltageRMS, currentRMS, apparent, active and reactive power) in form of graphs, as well as live samples. The user can start, pause or reset the system and instantly change the acquisition rate from a list of predefined intervals. Moreover, theAPPhas the task to sync the system, on connect theAPPautomatically updates the time and date of thePIC RTCCbased on the smartphone clock and calendar. The application screen is depicted in Figure3.18.

Figure 3.18:Application screen.

PressingStarttriggers a chain of processes. ThePICwill start scanning theSD Cardfor the files and folders; if non-existent, the missing ones are created for a thirty-one day run. Furthermore, it requests the user to select from a list an acquisition rate for the energy meterIC.

TheStopbutton holds the current state of the system, halts all sampling and cleans the log structure by deleting the empty files and folders from theSD Card. The user can then remove theSD Card, view or copy the data to another device. To proceed with the same run, the user inserts theSD Cardback into the slot and pressesStart; sinceStopholds the system state, the execution will continue then from the previous state. Holding down theStopbutton will start a complete reset of the system, all variables are set back to their initial value and and all data present in theSD Cardis deleted.

(68)

With theAPPconnected via bluetooth,Get Databutton requests the user to chose a date and time- frame, after which the corresponding data is downloaded and processed. Due to performance reasons, fifty samples are retrieved at a time, taking up to ten seconds to receive and process each request;

the user is prompted to download more samples or halt the process to plot the downloaded data. This feature is presented in Figure3.19.

Figure 3.19:Data review feature.

46

(69)

Turning on the LiveM onitor switch will start a looping one second timer. Every second, the app retrieves the last sampled data by the energy meter IC and displays the values at the bottom of the screen. When live monitoring is disabled, a graph will be automatically plotted as a summary, as depicted in Figure3.20.

Figure 3.20:Live data feature.

3.8 Software - PIC

Microchip offers an Integrated Development Environment (IDE) to configure, develop and debug embedded designs based on theirMCUs, MPLAB X. A plugin can be installed to further assist the user, MPLAB Code configurator, a graphical programming environment to generate libraries for the desired peripherals. Both tools were used to create the C program that runs on thePIC. The setup is divided in modules, each manages a functionality of the developed system: main loop,SD Card, energy meterIC, bluetooth module, logging buffers and processing of bluetooth commands.

In Figure 3.21 a flowchart presents the main workflow of the system. At boot, the system initial- izes and configures theI/O,RTCC, communication peripherals (SPIandUART), energy meterICand interrupts.

Referências

Documentos relacionados

(Mestrado em Ciências) – Faculdade de Agronomia Eliseu Maciel, Universidade Federal de Pelotas, Pelotas. A mineração de carvão representa uma grande importância para

O fato da demanda ser inelástica à renda no curto prazo, mas elástica no longo prazo, pode ser explicado uma vez que as indústrias têm, no longo prazo, condições para

Para criar valor estratégico, organizadores de eventos e executivos precisam contar com mais de especialista por disciplina para trabalhar o design do evento.. Idealmente, um

A &#34;questão social&#34; contemporânea, chamada erroneamente de &#34;nova questão social&#34;, advém dessas profundas modificações nos padrões de produção, de

Sexual como Tema Transversal nos currículos escolares é uma proposta da Lei de Diretrizes e Bases da Educação Brasileira - LDB n&#34; 9.394t96' que da mesrna

Neste capítulo, pretende-se estabelecer se existe uma relação entre os dados climatológicos analisados e o registo de notícias de tempo severo em Portugal,

LEI DO AUDIOVISUAL (Lei Federal 8685) - Esta lei federal modificada pela MP 1515 permite desconto fiscal para quem comprar cotas de filmes em produção. O limite de desconto é de 3%

As campanhas se alimentam e têm o potencial de alimentar o que Maingueneau (2010) chama de regime de atualidade e regime memorial, ou seja, têm a capacidade de serem sustentadas