You are on page 1of 68

THAINGUYEN UNIVERSITY OF TECHNOLOGY

Faculty of International Training

BACHELOR THESIS

Design of a Power Measurement


System for Single Phase Grids

Author: Supervisor:
Tran Thanh Bang Dr. Nguyen Tien Hung
Nguyen Van Phuong
Student’s ID: K135520216004
K135520207119

A thesis submitted in fulfillment of the requirements


for the degree of Bachelor of Engineering
in the
Division of English-taught Electrical Engineering
and Computer Science

August 12, 2018


This thesis has been approved by the

Head of the Division: Dr. Vu Quoc Dong


Signed:

Date:

Faculty Dean: Dr. Nguyen Tien Hung

Signed:

Date:

Composition of the committee (optional):

Dr. Nguyen Tien Hung Thainguyen University of Technology


Dr. Vu Quoc Dong Thainguyen University of Technology
Dr. Nguyen Tuan Minh Thainguyen University of Technology
Dr. Nguyen Minh Y Thainguyen University of Technology
M.S. Tran Que Son Thainguyen University of Technology

Copyright © 2018 by Tran Thanh Bang. All rights reserved.


Published by the Faculty of International Training (FIT). Thainguyen University of Technology. No part of
this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning without the prior written permission of the
authorization.
Declaration of Authorship

We declare that this thesis titled, “Implementation of a one-phase electronics meter” and
the work presented in it are my own. I confirm that:

 This work was done wholly or mainly while in candidature for a research degree at
this University.
 Where any part of this thesis has previously been submitted for a degree or any other
qualification at this University or any other institution, this has been clearly stated.
 Where I have consulted the published work of others, this is always clearly attributed.
 Where I have quoted from the work of others, the source is always given. With the
exception of such quotations, this thesis is entirely my own work.
 I have acknowledged all main sources of help.
 Where the thesis is based on work done by myself jointly with others, I have made
clear exactly what was done by others and what I have contributed myself.

Signed:

Date:

i
ACKNOWLEDGEMENTS

First of all, we would like to express my gratitude for our supervisor in this thesis work, Dr.
Nguyen Tien Hung for giving us the opportunity to explore an interesting field of electronics
meter. His guidance helped us in all the time of research and writing of this thesis. We could
not have imagined having a better advisor and mentor for our project.

We would like to thank my friends for creating a friendly and productive working
environment.

We also want to thank all the members of my reference group for very interesting meetings,
helpful discussions and meaningful comments during the research.

Finally, we would like to thank Mr. Linh for his support.

Tran Thanh Bang

Nguyen Van Phuong

K49APE

ii
Contents
ACKNOWLEDGEMENTS .............................................................................................................. ii
ABSTRACT.......................................................................................................................................vi
CHAPTER 1 ....................................................................................................................................... 1
OVERVIEW ........................................................................................................................................ 1
CHAPTER 2 ....................................................................................................................................... 3
INTRODUCTION TO ELECTRICAL SYSTEM AND POWER MEASUREMENT .................. 3
2.1 ALTERNATING CURRENT SYSTEM ........................................................................... 3
2.1.1 INTRODUCTION ABOUT AC.................................................................................. 3
2.1.2 AC WAVEFORM ........................................................................................................ 4
2.1.3 THE QUANTITIES OF SINUSOIDAL CURRENT ................................................ 5
2.2 HARMONIC DISTORTION ............................................................................................. 7
2.2.1 CURRENT HARMONICS ......................................................................................... 7
2.2.2 VOLTAGE HARMONICS ......................................................................................... 8
2.2.3 TOTAL HARMONIC DISTORTION ....................................................................... 8
2.2.4 FOURIER ANALYSIS .............................................................................................. 10
2.3 POWER TYPES ................................................................................................................ 10
2.4 METHODS TO MEASURE POWER ............................................................................ 11
2.4.1 USING IC ADE7953 TO MEASURE POWER ...................................................... 11
2.4.2 USING POWER METER ......................................................................................... 11
2.5 ALGORITHM IN THE CIRCUIT .................................................................................. 12
BASIC HARDWARE STRUCTURE ............................................................................................ 13
3.1 POTIENTIAL TRANSFORMER ................................................................................... 13
3.1.1 GENERAL STRUCTURE ........................................................................................ 13
3.1.2 WORKING PRINCIPLES ........................................................................................ 14
3.2 CURRENT TRANSFORMER ......................................................................................... 15
3.2.1 GENERAL STRUCTURE ........................................................................................ 15
3.2.2 WORKING PRINCIPLES ........................................................................................ 16
3.3 INTRODUCTION TO 20x4 LCD.................................................................................... 17
3.3.1 DESCRIPTIONS........................................................................................................ 17
3.4 INTRODUCTION TO ARM CORTEX-M3 STM32F103ZET6 .................................. 19
3.4.1 OVEVIEW .................................................................................................................. 19
3.4.2 SOPHISTICATION................................................................................................... 22
3.4.3 SAFETY ...................................................................................................................... 23
3.4.4 CONFIDENTIALITY ............................................................................................... 23
3.4.5 SOFTWARE DEVELOPMENT .............................................................................. 23
3.4.6 PERFORMANCE AND ACCESS LINE OF STM32............................................. 24

iii
3.4.7 ARM CORTEX-M3 PROCESSOR ......................................................................... 24
3.4.8 WHY USE CORTEX-M3 IN RESEARCH ............................................................. 25
3.4.9 PIN CONFIGURATION ........................................................................................... 26
3.5 SYSTEM STRUCTURE OF ARM CORTEX-M3 ........................................................ 26
3.5.1 BASIC MEMORY STRUCTURE ........................................................................... 27
3.5.2 PHASE LOCK LOOP ............................................................................................... 29
CHAPTER 4 ..................................................................................................................................... 34
HARDWARE SYSTEM MODEL AND ALGORITHM................................................................ 34
4.1 HARDWARE STRUCTURE ........................................................................................... 34
4.1.1 BLOCK DIAGRAM OF ELECTRONICS METER .............................................. 34
4.2 REAL CIRCUIT ............................................................................................................... 37
4.3 ALGORITHM ..................................................................................................................... 39
4.3.1 VOLTAGE MESUREMENT ......................................................................................... 39
4.3.2 CURRENT MESUREMENT ........................................................................................ 43
CHAPTER 5 ..................................................................................................................................... 45
SOFTWARE BASIS AND PROGRAMMING ............................................................................. 45
5.1 INTRODUCTION TO KEIL C ....................................................................................... 45
5.2 MAIN DIAGRAM UTILIZED IN THE PROGRAM ................................................... 47
5.3 PROGRAMMING .............................................................................................................. 47
CHAPTER 6 ..................................................................................................................................... 55
RESULTS ......................................................................................................................................... 55
CHAPTER 7 ..................................................................................................................................... 59
CONCLUSION AND FUTURE WORK ........................................................................................ 59
BIBLIOGRAPHY ............................................................................................................................. 60

iv
List of figures
Figure 1. Two Sinusoidal Waveforms ................................................................................................. 5
Figure 2. Phase Difference of a Sinusoidal Waveform........................................................................ 6
Figure 3. Relationship between S and Q ............................................................................................ 11
Figure 4. Power Meter ....................................................................................................................... 11
Figure 5. General structure of a voltage transformer ......................................................................... 13
Figure 6. Single-phase transformer .................................................................................................... 15
Figure 7. Current Transformer. .......................................................................................................... 15
Figure 8. Working principles of current transformer. ........................................................................ 17
Figure 9. 20x4 LCD ........................................................................................................................... 18
Figure 10. LED Pin Configuration..................................................................................................... 19
Figure 11. The Cortex-M3 processor ................................................................................................. 20
Figure 12. The memory map .............................................................................................................. 22
Figure 13. USB Access and Connectivity.......................................................................................... 24
Figure 14. STM32F103ZET106 Pins ................................................................................................ 26
Figure 15. System Structure of ARM Cortex-M3 ............................................................................. 27
Figure 16. Memory Map .................................................................................................................... 27
Figure 17. Phase Lock Loop-PLL ...................................................................................................... 28
Figure 18. SMD 8MHZ Crystal ......................................................................................................... 30
Figure 19. J-Link ................................................................................................................................ 30
Figure 20. SMD Resistor ................................................................................................................... 31
Figure 21. Sizes of SMD Resistors .................................................................................................... 32
Figure 22. SMD Capacitor ................................................................................................................. 33
Figure 23. Block diagram of electronics meter. ................................................................................. 34
Figure 24. Schematics of the circuit .................................................................................................. 35
Figure 25. 2D electronics meter circuit in PCB. ................................................................................ 36
Figure 26. 3D electronics meter circuit in PCB ................................................................................. 37
Figure 27. Real circuit........................................................................................................................ 38
Figure 28. Complete Circuit of Electronics Meter............................................................................. 39
Figure 29. Electronic dc analog voltmeter schematics. ..................................................................... 40
Figure 30. Electronic, rectifier-based ac analog voltmeter schematics .............................................. 40
Figure 31. Signal waveforms in a rectifier-based ac analog voltmeter when the input voltage is
sinusoidal ........................................................................................................................................... 41
Figure 32. Electronic, full-wave rectifier-based ac analog voltmeter schematics ............................. 42
Figure 33. Algorithm Amplifier ......................................................................................................... 47
Figure 34. U, I and Phase Delay Measure Circuit ............................................................................. 47
Figure 35. Lamp Measurement ........................................................................................................ 56
Figure 36. Charger ............................................................................................................................. 57
Figure 37. Bulb light .......................................................................................................................... 58

v
ABSTRACT
This paper is representing a method of measuring power consumption, voltage and current.
With the large-scale application of electronics meter, for the needs of electric energy meter
status evaluation and present situation of the large number of low-voltage electric energy
meter and long-time interval for the operational information collection, this paper present a
method of electric energy meter status evaluation fused security region. Though analyzing
the common factors that affect power metering accuracy and status, designed of the security
domain model and evaluation system based on the status assessment algorithm in the virtual
load network, got the key factors affecting the reliability of energy metering, and given the
status evaluation, improve the accuracy of status evaluation, according to the result can
dynamically guidance of the site inspection and adjust the cycle of rotation of the meter.

vi
CHAPTER 1
OVERVIEW
Before I start, I want to tell you about a story since I was a kid. Then at the beginning of each
month, employees would collect electricity fee, I was curious how people charged electricity
fee. It was a pretty palatable question for a kid like me. I started finding out the answer for
that question then I know they charged fee based on the total power consumption in the
family. And, another question that came to my mind is how to know the total power
consumption in the home. So I continued to learn to satisfy my curiosity, I went to see the
power consumption of each household appliances, calculated how much time spent they
worked a day. Unfortunately, some electrical appliances did not have the power on the labels
so I could not calculate the cost. Time went by, this year I got a list of graduation projects, I
found a project related to measuring power consumption, I decided to choose it, a choice
because of a curious childhood.
Besides, currently in Vietnam, the electricity sector is still using popular electronic energy
meters. However, in the face of the modernization requirements of the power sector, these
devices have clearly demonstrated the major disadvantages of precision, automation in the
data collection and management.
Therefore, it is required to replace these devices with more advanced equipment to overcome
the disadvantages. Digital measuring devices are designed to meet the above requirements.
Thanks to the advances in technology in the electronics field, component manufacturers have
developed a variety of integrated ICs that simplify the design and manufacture of precision
instrumentation. The ADE7xxx IC from Analog Devices. But when using the ADE7xxx IC,
it does all the work, the work we need to do is read the signal from Analog to Digital and
then display the screen. We want to understand more about how to measure power, so we
decided to design a power circuit using only the ARM Cortex-M3 ZET6. In the future, after
the project is completed, we will develop it based on the available circuit platform. Circuit
design and programming are quite interesting. Another task comes, you may want to ask us
how I can measure the power consumption without using any ADE IC. And you might have
the answer for your question that we measure current, voltage and calculate cos  (the phase
difference between current and voltage). For our circuit, we don’t use a full
1
STM32F103ZET6 board, we only use ARM Cortex-M3. The reason we do that because we’d
like to understand deeply about working principles of STM32F103ZET6. Morover, I design
a circuit in Altium Designer and use almost all SMD components to avoid noises happening
in the circuit. One of the most difficult tasks in our project is to design PCB. Thanks to Dr.
Hung’s support, we have the schematics so it’s easier for us when design PCB. Besides,
coding for chip STM32F103ZET6 is so tough because that chip is hard for us to code. It
differs from all other chips in STM32 family. Luckily, our tries are deserved, we successfully
code for chip STM32F103ZET6. After finishing soldering all components and coding, we try
to run the circuit. It’s working as our desires and gives good results. To have the success, we
highly appreciate of Dr. Nguyen Tien Hung’s supports. Now, let’s go to the details of our
project and see how it is.

2
CHAPTER 2
INTRODUCTION TO ELECTRICAL SYSTEM AND
POWER MEASUREMENT
2.1 ALTERNATING CURRENT SYSTEM
2.1.1 INTRODUCTION ABOUT AC
Alternating current (AC) is an electric current which periodically reverses direction, in
contrast to direct current (DC) which flows only in one direction. Alternating current is the
form in which electric power is delivered to businesses and residences, and it is the form
of electrical energy that consumers typically use when they plug kitchen appliances,
televisions, fans and electric lamps into a wall socket. A common source of DC power is
a battery cell in a flashlight. The abbreviations AC and DC are often used to mean
simply alternating and direct, as when they modify current or voltage.
The usual waveform of alternating current in most electric power circuits is a sine wave. In
certain applications, different waveforms are used, such as triangular or square
waves. Audio and radio signals carried on electrical wires are also examples of alternating
current. These types of alternating current carry information such as sound (audio) or images
(video) sometimes carried by modulation of an AC carrier signal. These currents typically
alternate at higher frequencies than those used in power transmission.
Electrical energy is distributed as alternating current because AC voltage may be increased
or decreased with a transformer. This allows the power to be transmitted through power
lines efficiently at high voltage, which reduces the energy lost as heat due to resistance of the
wire, and transformed to a lower, safer, voltage for use. Use of a higher voltage leads to
significantly more efficient transmission of power. The power losses in the wire are a product
of the square of the current (I) and the resistance (R) of the wire, described by the formula

Pw  I 2 R
This means that when transmitting a fixed power on a given wire, if the current is halved (i.e.
the voltage is doubled), the power loss will be four times less.

3
The power transmitted is equal to the product of the current and the voltage (assuming no
phase difference); that is,

Pt  IV
2.1.2 AC WAVEFORM
An alternating function or AC Waveform on the other hand is defined as one that varies in
both magnitude and direction in more or less an even manner with respect to time making it
a “Bi-directional” waveform. An AC function can represent either a power source or a signal
source with the shape of an AC waveform generally following that of a mathematical sinusoid
being defined as:
A(t) = Amax*sin(2πƒt)
The term AC or to give it its full description of Alternating Current, generally refers to a time-
varying waveform with the most common of all being called a Sinusoid better known as a
Sinusoidal Waveform. Sinusoidal waveforms are more generally called by their short
description as Sine Waves. Sine waves are by far one of the most important types of AC
waveform used in electrical engineering.
The shape obtained by plotting the instantaneous ordinate values of either voltage or current
against time is called an AC Waveform. An AC waveform is constantly changing its polarity
every half cycle alternating between a positive maximum value and a negative maximum
value respectively with regards to time with a common example of this being the domestic
mains voltage supply we use in our homes.
This means then that the AC Waveform is a “time-dependent signal” with the most common
type of time-dependant signal being that of the Periodic Waveform. The periodic or AC
waveform is the resulting product of a rotating electrical generator. Generally, the shape of
any periodic waveform can be generated using a fundamental frequency and superimposing
it with harmonic signals of varying frequencies and amplitudes but that’s for another tutorial.
Alternating voltages and currents can not be stored in batteries or cells like direct current
(DC) can, it is much easier and cheaper to generate these quantities using alternators or
waveform generators when they are needed. The type and shape of an AC waveform depends
upon the generator or device producing them, but all AC waveforms consist of a zero voltage
line that divides the waveform into two symmetrical halves. . The main characteristics of an
AC Waveform are defined as:
4
AC Waveform Characteristics
The Period, (T) is the length of time in seconds that the waveform takes to repeat itself from
start to finish. This can also be called the Periodic Time of the waveform for sine waves, or
the Pulse Width for square waves.
The Frequency, (ƒ) is the number of times the waveform repeats itself within a one second
time period. Frequency is the reciprocal of the time period, ( ƒ = 1/T ) with the unit of
frequency being the Hertz, (Hz).
The Amplitude (A) is the magnitude or intensity of the signal waveform measured in volts or
amps.
2.1.3 THE QUANTITIES OF SINUSOIDAL CURRENT
Firstly, lets consider that two alternating quantities such as a voltage, v and a current, i have
the same frequency ƒ in Hertz. As the frequency of the two quantities is the same the angular
velocity, ω must also be the same. So at any instant in time we can say that the phase of
voltage, v will be the same as the phase of the current, i.
Then the angle of rotation within a particular time period will always be the same and the
phase difference between the two quantities of v and i will therefore be zero and Φ = 0. As
the frequency of the voltage, v and the current, i are the same they must both reach their
maximum positive, negative and zero values during one complete cycle at the same time
(although their amplitudes may be different). Then the two alternating quantities, v and i are
said to be “in-phase”.

Figure 1. Two Sinusoidal Waveforms

Now lets consider that the voltage, v and the current, i have a phase difference between
themselves of 30 degrees, so (Φ = 30 degrees or π/6 radians). As both alternating quantities
5
rotate at the same speed, i.e. they have the same frequency, this phase difference will remain
constant for all instants in time, then the phase difference of 30 degrees between the two
quantities is represented by phi, Φ as shown below.

Figure 2. Phase Difference of a Sinusoidal Waveform

The voltage waveform above starts at zero along the horizontal reference axis, but at that
same instant of time the current waveform is still negative in value and does not cross this
reference axis until 30o later. Then there exists a Phase difference between the two
waveforms as the current cross the horizontal reference axis reaching its maximum peak and
zero values after the voltage waveform.
As the two waveforms are no longer “in-phase”, they must therefore be “out-of-phase” by an
amount determined by phi, Φ and in our example this is 30o. So we can say that the two
waveforms are now 30o out-of phase. The current waveform can also be said to be “lagging”
behind the voltage waveform by the phase angle, Φ. Then in our example above the two
waveforms have a Lagging Phase Difference so the expression for both the voltage and
current above will be given as.

vt  Vm sin t
it  I m sin t   

where, i lags v by angle Φ


Likewise, if the current, i has a positive value and crosses the reference axis reaching its
maximum peak and zero values at some time before the voltage, v then the current waveform

6
will be “leading” the voltage by some phase angle. Then the two waveforms are said to have
a Leading Phase Difference and the expression for both the voltage and the current will be.
vt  Vm sin t
it  I m sin t   

where, i leads v by angle Φ


The phase angle of a sine wave can be used to describe the relationship of one sine wave to
another by using the terms “Leading” and “Lagging” to indicate the relationship between two
sinusoidal waveforms of the same frequency, plotted onto the same reference axis. In our
example above the two waveforms are out-of-phase by 30o. So we can correctly say that i
lags v or we can say that v leads i by 30o depending upon which one we choose as our
reference.
The relationship between the two waveforms and the resulting phase angle can be measured
anywhere along the horizontal zero axis through which each waveform passes with the “same
slope” direction either positive or negative.
In AC power circuits this ability to describe the relationship between a voltage and a current
sine wave within the same circuit is very important and forms the bases of AC circuit analysis.
2.2 HARMONIC DISTORTION
Harmonic is multiple of the fundamental frequency and it can be voltage and current in an
electric power system are a result of non-linear electric loads. Harmonic frequencies in the
power grid are a frequent cause of power quality problems. Harmonics in power systems
result in increased heating in the equipment and conductors, misfiring in variable speed
drives, and torque pulsations in motors. Reduction of harmonics is considered desirable.
2.2.1 CURRENT HARMONICS
In a normal alternating current power system, the current varies sinusoidally at a specific
frequency, usually 50 or 60 hertz. When a linear electrical load is connected to the system, it
draws a sinusoidal current at the same frequency as the voltage (though usually not in phase
with the voltage).
Current harmonics are caused by non-linear loads. When a non-linear load, such as a rectifier
is connected to the system, it draws a current that is not necessarily sinusoidal. The current
waveform can become quite complex, depending on the type of load and its interaction with
other components of the system. Regardless of how complex the current waveform becomes,
as described through Fourier series analysis, it is possible to deconstruct it into a series of
7
simple sinusoids, which start at the power system fundamental frequency and occur at integer
multiples of the fundamental frequency.
Further examples of non-linear loads include common office equipment such as computers
and printers, Fluorescent lighting, battery chargers and also variable-speed drives.
In power systems, harmonics are defined as positive integer multiples of the fundamental
frequency. Thus, the third order harmonic is the third multiple of the fundamental frequency.
This type of harmonics is generated in non-linear loads. Examples of nonlinear loads include
transistors, electrical motors, and the non-ideal transformer. Non-linear loads create
disturbances in the fundamental harmonic, which produce all types of harmonics. However,
in this section we focus on the 3rd order harmonic due to its certain special characteristics in
the context of powers systems.
2.2.2 VOLTAGE HARMONICS
Voltage harmonics are mostly caused by current harmonics. The voltage provided by the
voltage source will be distorted by current harmonics due to source impedance. If the source
impedance of the voltage source is small, current harmonics will cause only small voltage
harmonics. It is typically the case that voltage harmonics are indeed small compared to
current harmonics. For that reason, the voltage waveform can usually be approximated by the
fundamental frequency of voltage. If this approximation is used, current harmonics produce
no effect on the real power transferred to the load. An intuitive way to see this comes from
sketching the voltage wave at fundamental frequency and overlaying a current harmonic with
no phase shift (in order to more easily observe the following phenomenon). What can be
observed is that for every period of voltage, there is equal area above the horizontal axis and
below the current harmonic wave as there is below the axis and above the current harmonic
wave. This means that the average real power contributed by current harmonics is equal to
zero. However, if higher harmonics of voltage are considered, then current harmonics do
make a contribution to the real power transferred to the load.
2.2.3 TOTAL HARMONIC DISTORTION
Total harmonic distortion, or THD is a common measurement of the level of harmonic
distortion present in power systems. THD can be related to either current harmonics or
voltage harmonics, and it is defined as the ratio of total harmonics to the value at fundamental
frequency times 100%

8

n
V2 2  V32  V4 2  ...  VN 2 k 2
Vk 2
THDV   100%   100%
V1 V1


n
I 2 2  I 32  I 4 2  ...  I N 2 k 2
Vk 2
THDI  100%   100%
I1 I1

where Vn is the RMS voltage of nth harmonic, In is the RMS current of the nth harmonic,
and n = 1 is the fundamental frequency.
It is usually the case that we neglect higher voltage harmonics; however, if we do not neglect
them, real power transferred to the load is affected by harmonics. Average real power can be
found by adding the product of voltage and current (and power factor, denoted by pf here) at
each higher frequency to the product of voltage and current at the fundamental frequency, or

Pavg  Vk  I k  pf  Pavg ,1  Pavg ,2  ...
k 1

where Vk and Ik are the RMS voltage and current magnitudes at harmonic k (k =1 denotes the
fundamental frequency)

It must be noted that the power factor mentioned above is the displacement power factor.
There is another power factor that depends on THD. True power factor can be taken to mean
the ratio between average real power and the magnitude of RMS voltage and current

2
 THDV 
Vrms  V1.rms 1   
 100 
2
 THDI 
I rms  I1.rms 1  
 100 

Substituting this in for the equation for true power factor, it becomes clear that the quantity
can be taken to have two components, one of which is the traditional power factor (neglecting
the influence of harmonics) and one of which is the harmonics’ contribution to power factor:
Pavg 1
pftrue  
V1.rms I I ,rms  THDv 
2
 THDI 
2

1    1  
 100   100 
Names are assigned to the two distinct factors as follows:
pftrue  pf disp  pft

9
2.2.4 FOURIER ANALYSIS
The analysis of harmonics is the process of calculating the magnitudes and phases of the
fun‐ damental and high order harmonics of the periodic waveforms. The resulting series
is known as Fourier series. It establishes a relation between a function in the domain of
time and a func‐ tion in the domain of frequency.
The Fourier’s theorem states that every nonsinusoidal periodic wave can be decomposed
as the sum of sine waves through the application of the Fourier series, given the following
conditions:
• The integral over one period of the function is a finite value.
• The function possesses a finite number of discontinuities in a period.
• The function possesses a finite number of maxima and minima in a period.
Coefficients and Fourier series. The Fourier series of a periodic function x(t) is
expressed as:

  2 t   2 t  
x  t   a0    an cos    bn sin  
n 1   T   T 
This constitutes a representation of periodic function in the domain of the frequency.
In this expression, a0 is the average value of the function x(t), where an and bn are the
coefficients of the series besides being the rectangular components of the n harmonic. For the
correspond‐ ing n harmonic its vector is:
Ann  an  jbm

With a magnitude and an angle of phase:

An   a n  b n, 
2 2
n  tan 1 bn

2.3 POWER TYPES


AC power has three types of power:
Effective power (actual power) P = U.I.Cos Ø
Reactive power (useless power) Q = U.I. Sin Ø: is the term used to refer to the portion of
electrical power that is shifted back to the power supply in each cycle due to the accumulation
of energy in the resistive components and the capacitance of resistance, created by the
difference between Voltage and Voltage
Visible power (total power) S = U.I: is the real sum of the effective power (P) and the reactive
power (Q)

10
What is the relationship between these capacities? We will learn the following:

Figure 3. Relationship between S and Q


We can see S = P + iQ or : S  P 2  Q 2

2.4 METHODS TO MEASURE POWER


2.4.1 USING IC ADE7953 TO MEASURE POWER
ADI's ADE7953 is a high-accuracy, electrical energy measurement IC intended for single-
phase applications. It measures line voltage and current and calculates active, reactive,
apparent energy, and instantaneous VRMS and current.
The device incorporates three sigma delta ADCs with a high-accuracy energy measurement
core. The third input channel simultaneously measures neutral current and enables tamper
detection and neutral-current billing. The additional channel incorporates a complete signal
path that allows a full range of measurements. Each input channel supports independent and
flexible gain stages, making the device suitable for use with a variety of current sensors such
as current transformers (CT’s) and low-value shunt resistors. Two on-chip integrators
facilitate the use of Rogowski coil sensors.
2.4.2 USING POWER METER

Figure 4. Power Meter


11
The 100A AC Voltage, Current, Power, AC Power Meter is used to measure and monitor
virtually all AC power circuits such as Operating Voltage, Current Consumption, Power and
energy consumption.
Voltage, Current, Power, AC Power 100A small, easy to install, high strength, professional
LCD display, can be turned on or off as desired.
2.5 ALGORITHM IN THE CIRCUIT
In order to measure power consumption, we need to know the value of U, I, and cos  .
We can easily obtain the value of U and I, but to cos  , we have to calculate phase delays
between current and voltage using reading ADC from chip STM32F103ZET6. The formula
is as below:

P  U  I  cos 

But the thing is that how to calculate cos  , we considered really careful then we get to the
answer for this task. We let the sine wave of U pass through 0 will trigger the timer counter
until it goes through 0, stop counting the timer, count the timer as much as cos  as the small,
the more the timer goes to zero, to 1, in terms of how many coefficients k are inferred from
the timer
After we have the value of all those things, chip STM32F103ZET6 will process and
transmit the result to LCD. Then, we can see the result on the screen.

12
CHAPTER 3
BASIC HARDWARE STRUCTURE
3.1 POTIENTIAL TRANSFORMER
3.1.1 GENERAL STRUCTURE
A transformer is a static electrical device that transfers electrical energy between two or more
circuits through electromagnetic induction. A varying current in one coil of the transformer
produces a varying magnetic field, which in turn induces a varying electromotive force or
"voltage" in a second coil. Power can be transferred between the two coils, without a metallic
connection between the two circuits. Faraday's law of induction discovered in 1831 described
this effect. Transformers are used to increase or decrease the alternating voltages in electric
power applications.
Since the invention of the first constant-potential transformer in 1885, transformers have
become essential for the transmission, distribution, and utilization of alternating current
electrical energy. A wide range of transformer designs is encountered in electronic and
electric power applications. Transformers range in size from RF transformers less than a
cubic centimeter in volume to units interconnecting the power grid weighing hundreds of
tons.

Figure 5. General structure of a voltage transformer


13
3.1.2 WORKING PRINCIPLES
The working principle of transformer is very simple. It depends upon Faraday's law of
electromagnetic induction. Mutual induction between two or more winding is responsible for
transformation action in an electrical transformer. According to these Faraday's laws, "rate of
change of flux linkage with respect to time is directly proportional to the induced EMF in a
conductor or coil". Say you have one winding which is supplied by an alternating electrical
source. The alternating current through the winding produces a continually changing flux or
alternating flux that surrounds the winding. If any other winding is brought nearer to the
previous one, obviously some portion of this flux will link with the second. As this flux is
continually changing in its amplitude and direction, there must be a change in flux linkage in
the second winding or coil. According to Faraday's law of electromagnetic induction, there
must be an EMF induced in the second. If the circuit of the later winding is closed, there must
be a current flowing through it. This is the simplest form of an electrical power transformer,
and this is the most basic of working principle of transformer.
Figure below shows a schematic diagram of a single-phase transformer. There are two types
of windings in a single-phase transformer. These are called primary and secondary windings
or coils. The primary winding is connected to the alternating voltage source and the secondary
winding is connected to the load. The primary and secondary winding parameters are
represented by the suffix p or 1 and s or 2, respectively. A sinusoidal current flows in the
primary winding when it is connected to an alternating voltage source. This current establish
a flux u which moves from the primary winding to the secondary winding through low
reluctance magnetic core.
About 95 % of this flux moves from the primary to the secondary through the low reluctance
path of the magnetic core and this flux is linked by the both windings and a small percent of
this flux links to the primary winding. According to the Faradays laws of electromagnetic
induction, a voltage will be induced across the secondary winding as well as in the primary
winding. Due to this voltage, a current will flow through the load if it is connected with the
secondary winding. Hence, the primary voltage is transferred to the secondary winding
without a change in frequency.

14
Figure 6. Single-phase transformer
The current in the primary winding establishes a flux. The flux that moves from primary to
secondary and links both the windings is called the mutual flux
Flux which links only the primary winding and completes the magnetic path through the
surrounding air is known primary leakage flux. Similarly, secondary leakage flux is that
flux which links only the secondary winding and completes the magnetic path through the
surrounding air.
3.2 CURRENT TRANSFORMER
3.2.1 GENERAL STRUCTURE
A current transformer is an instrument transformer, used along with measuring or protective
devices, in which the secondary current is proportional to the primary current (under normal
conditions of operation) and differs from it by an angle that is approximately zero.

Figure 7. Current Transformer.

15
3.2.2 WORKING PRINCIPLES
The Current Transformer (CT), is a type of “instrument transformer” that is designed to
produce an alternating current in its secondary winding which is proportional to the current
being measured in its primary. Current transformers reduce high voltage currents to a much
lower value and provide a convenient way of safely monitoring the actual electrical current
flowing in an AC transmission line using a standard ammeter. The principal of operation of
a basic current transformer is slightly different from that of an ordinary voltage transformer.
Unlike the voltage or power transformer looked at previously, the current transformer consists
of only one or very few turns as its primary winding. This primary winding can be of either
a single flat turn, a coil of heavy duty wire wrapped around the core or just a conductor or
bus bar placed through a central hole as shown.
Due to this type of arrangement, the current transformer is often referred too as a “series
transformer” as the primary winding, which never has more than a very few turns, is in series
with the current carrying conductor supplying a load.
The secondary winding however, may have a large number of coil turns wound on a
laminated core of low-loss magnetic material. This core has a large cross-sectional area so
that the magnetic flux density created is low using much smaller cross-sectional area wire,
depending upon how much the current must be stepped down as it tries to output a constant
current, independent of the connected load.
The secondary winding will supply a current into either a short circuit, in the form of an
ammeter, or into a resistive load until the voltage induced in the secondary is big enough to
saturate the core or cause failure from excessive voltage breakdown.
Unlike a voltage transformer, the primary current of a current transformer is not dependent
of the secondary load current but instead is controlled by an external load. The secondary
current is usually rated at a standard 1 Ampere or 5 Amperes for larger primary current
ratings.

16
Figure 8. Working principles of current transformer.
3.3 INTRODUCTION TO 20x4 LCD
3.3.1 DESCRIPTIONS
It is a DataVision part and uses the Samsung KS0066 LCD controller. It's a clone of the
Hitachi HD44780. We're not aware of any incompatabilities between the two - at least we
have never seen any in all the code and custom applications we have done.
This 20x4 LCD is electrically and mechanically interchangeable with 20x4 LCDs from
several other vendors. The only differences we've seen among different 20x4 LCDs are:
 LED backlight brightness, voltage and current vary widely, as does the quality of the
display
 There is a resistor “Rf” which sets the speed of the LCD interface by controlling the
internal oscillator frequency. Several displays we have evaluated have a low resistor
value. This makes the display too slow. Looking at the Hitachi data sheet page 56,
it appears that perhaps the “incorrect” resistor is really intended for 3V use of the
displays.
 At 5V the resistor Rf should be 91 Kohms. At 3V it should be 75 Kohms. Using a 3V
display at 5V is acceptable from a voltage standpoint (the display can operate on 3-
5V) but the oscillator will then be running too slowly. One fix is to always check the
busy flag and not use a fixed time delay in your code, then it will work regardless of
the LCD speed. The other option is to always allow enough delay for the slower
display.

17
All Systronix 20x4 LCDs have the 91 Kohm resistor and are intended for 5V operation.

Figure 9. 20x4 LCD


Vcc, Vss and Vee pins
5V Vcc pin, Vss pin is ground, Vee pin is used to control the contrast of the LCD.
RS (Register select)
At low level, the instruction is transmitted to LCD such as erase screen, cursor position. At
high level, the character is transmitted to the LCD
R / W (Read / Write)
Used to determine the direction of data transfer between the LCD and the microcontroller.
When it is low data is recorded to the LCD and when high, the data is read from the LCD. If
we just write data to the LCD then we can connect this pin to GND to save the leg
E (Enable)
Allows us to access / output to LCD via RS and R / W pins. When the E pin is high (1), the
LCD will check the status of both the RS and R / W pins and respond accordingly. When the
data is allocated to the data pin, a low-level pulse must be applied to the pin so that the LCD
latches data on the data pins. This pulse must be at least 450 nm wide. When the E pin is low
(0), the LCD will disable or bypass the signal of both RS and R / W pins.
Pins D0 - D7
Here are eight 8-bit data pins, which are used to send information to the LCD or read the
contents of the LCD registers. Characters are passed in the corresponding code in the ascii
18
encoding. There are also codes that can be sent to the LCD to clear the screen or to move the
cursor to the cursor or to blink the cursor.
LCD has 2 modes of communication, 4 bit mode (only use 4 pins D4 to D7 for data transfer)
and 8 bit mode (use 8 data pins from D0 to D7), in 4 bit mode, when 1 byte transmission, we
will pass the high half of the first byte, then the new low half of the byte transmission.
Before transmitting the characters to the LCD, we need to set up the LCD as either 4 bit or 8
bit mode, 1 line or 2 lines, turn on / off the pointer

Figure 10. LED Pin Configuration


3.4 INTRODUCTION TO ARM CORTEX-M3 STM32F103ZET6
3.4.1 OVEVIEW
The ARM Cortex line consists of three different configurations of the ARMv7 architecture.
· Configuring A for sophisticated, high-demand applications that run on open
and complex operating systems such as Linux, Android, etc.
· R configuration for real-time systems.
· M configuration is optimized for microcontroller applications, requiring cost
savings.
The Cortex-M3 processor is the first ARM processor based on the ARMv7-M architecture
and is specifically designed to deliver high performance in embedded applications that
19
require energy and cost savings. Speeding up a higher operating frequency can increase
performance but also come with more power consumption and more complex design. In other
words, doing the same thing but by improving the computational efficiency while still
operating at lower frequencies will lead to simpler design and less power consumption.
The core of the Cortex-M3 processor is a three-tiered, tubular core, based on the Harvard
architecture.
Core Cortex-M3:
 The Cortex-M3 core is based on the Harvard architecture, which is characterized by
the separation of data and program memory so that individual buses are accessible.
Because of the ability to simultaneously read commands and data from memory, the
Cortex-M3 processor can perform many parallel operations, accelerating application
performance.

o
Figure 11. The Cortex-M3 processor
 Cortex core is structured in three layers: Instruction Fetch, Instruction Decode and
Instruction Execute. When encountered with a branch command, the decode stage
contains a speculative command directive that can lead to faster execution. The
20
command processor expects to branch in the decoding stage. Then, during the
execution phase, branching is resolved and the processor analyzes the next execution
order. If the fork is not selected then the next command is ready. If the branch is
selected, the branch command is ready immediately, limiting idle time to one cycle.
 The Cortex-M3 processor is a 32-bit microprocessor, with a 32-bit data path width,
strip ranges, and memory interface. There are 13 multiprocessor registers, two stack
pointer, one link register, one program counter, and several special registers, including
a program state register.
 The Cortex-M3 processor supports two operating modes (Thread and Handler) and
two access levels of processor cores (privileged and non-privileged), facilitating the
installation of systems. Open and complex but still secure. Unclaimed lines of code
are restricted or do not allow access to some important resources (some special
commands and certain areas of memory).
 Thread mode is a typical operation mode that supports both privileged and non
privileged code. The processor enters Handler mode when an exception occurs and all
code is privileged in this mode.
 Ability to address 2 ^ 32 = 4gb address: predefined addresses, dedicated to code (code
area), SRAM (memory area), external memory / device, peripheral devices. inside and
outside. There is also a special storage area reserved for vendors.

21
Figure 12. The memory map
• Nested Vectored Interrupt Controller (NVIC) is an integrated component of the Cortex-M3
processor that is capable of handling very fast and flexible interrupts. In standard installation,
it provides an NMI (Non-Maskable Interrupt) and 32 multi-use physical interruptions with 8
pre-emption priorities. It can be configured from 1 to 240 physical interrupts with up to 256
priority levels.
3.4.2 SOPHISTICATION
The peripherals of STM32 are the same as other microcontrollers, such as two ADC, timer,
12C, SPI, CAN, USB and RTC converters. However, each of the periphery has many
interesting features. For example, the 12-bit ADC has a built-in temperature sensor that
automatically calibrates when temperature changes and supports multiple conversion modes.
Each timer has four capture compare blocks (used to capture the input capture and output
waveforms), each block can be associated with other timers to create an array. more
sophisticated timepieces.
STM32 supports up to 12 channels of DMA (Direct Memory Access). Each channel can be
used to transmit data to peripheral registers or from peripheral registers to the word (s). Data

22
transfer can be either 8/16 or 32-bit. Each peripheral may have a built-in DMA controller
(DMA Controller) for sending or requesting data as required.
STM32 is a microcontroller that consumes low power and high performance. It can operate
at 2 volts, running at 72 MHz and 36 mA at the same time with all the blocks inside the
microcontroller running.
3.4.3 SAFETY
Today's modern applications must operate in a rigorous, high-security environment, as well
as require more processing power and more sophisticated equipment. To meet these stringent
requirements, STM32 offers a number of hardware features that best support applications.
These include a low voltage detector, a clock protection system and two sets of watchdogs.
The first set is a windowed watchdog. This watch must be refreshed within a specified time
frame. If you hit it too soon, or too late, the Watchdog will trigger. The second is an
independent watchdog, which has an external oscillator that is separate from the external
main system clock (usually quartz) and automatically switches to an internal 8Mhz RC
oscillator.
3.4.4 CONFIDENTIALITY
One of the more stringent requirements of modern design is the need to secure program code
to prevent software piracy. Flash memory of STM32 can be locked to prevent access to read
Flash via Debug port. When Read Protection is enabled, Flash memory is also write-protected
to prevent unreliable code from being inserted into the interrupt vector table. Further write
protection may be allowed in the rest of Flash memory. The STM32 also has a real-time clock
and a small area of data on the SRAM fed by the battery. This area has an anti-tamper input,
which can trigger an interrupt event when there is a status change at this input. Also an anti-
forgery event will automatically erase the data stored on the battery-powered SRAM.
3.4.5 SOFTWARE DEVELOPMENT
If you have used an ARM-based microcontroller, existing ARM development tools have
supported Thumb-2 and Cortex. The ST also offers a number of peripheral control libraries,
a USB library as an ANSI C library, and source code that is compatible with previously
released libraries for microcontrollers. STR7 and STR9. The Cortex-M3 also comes with a
completely new debugging system called CoreSight. Access to the CoreSight system via the
Debug Access Port, which supports either the JTAG standard interface or the 2 wire serial

23
interface, as well as providing debugging, The CoreSight system on STM32 provides a data
watchpoint system and an instrumentation trace.
3.4.6 PERFORMANCE AND ACCESS LINE OF STM32
The STM32 family has two distinct branches: Performance and Access. The Performance
Series is full of peripherals and runs at up to 72MHz. The Access series has fewer peripherals
and runs at up to 36Mhz. More important is that the pins layout and package types are the
same between the Access and Performance lines. This allows different versions of STM32 to
be permuted without having to modify the footprint of the PCB on the printed circuit board.
In addition to the first two Performance and Access lines, the ST has now introduced two
additional USB Access and Connectivity lines, as shown below:

Figure 13. USB Access and Connectivity


3.4.7 ARM CORTEX-M3 PROCESSOR
The System-on-Chip (ARM) -based ARM processor is used in a variety of markets, including
enterprise applications, automotive systems, home networks, and wireless technologies.
ARM Cortex-based processors are based on a standardized architecture that is sufficient to
meet most of the performance requirements in all of these areas. The ARM Cortex line
consists of three different configurations of ARM7 architecture: A configuration for
sophisticated applications, high requirements running on open and complex operating
systems such as Linux, Adroid, etc .; The R configurations for real-time systems and M-
configurations are optimized for control applications that require cost savings. The Cortex-
24
M3 processor is the first ARM processor based on the ARMv7-M architecture and is
specifically designed to achieve high performance in embedded applications that require
energy and cost savings, such as microcontrollers, automotive control systems, industrial
control systems, and wireless systems
To achieve higher performance, processors can work better or work smarter. Pushing higher
operating frequencies can increase performance but also come with more power consumption
and design is also more complex. In other words, doing the same thing, but by improving the
computational efficiency while still operating at lower frequencies will result in simpler
design and less power consumption. The heart of the Cortex-M3 processor is a three-storey
advanced pipeline core structure, based on the Harward architecture, incorporating powerful
features such as branch speculation, Cycle and division are done by hardware to create a
remarkable performance (Dhrystone point is 1.25 DMIPS / Mhz).
Cost is always the biggest barrier to choosing a high-performance processor. Microprocessors
designed on a small footprint will reduce costs considerably. The Cortex-M3 processor
performs this by installing the smallest ARM cores ever, with only 33,000 ports (ports may
be NAND or NOR depending on manufacturing technology) in the core (0.18 um G) and by
combining the most efficient, rigorous components in the microprocessor system. Thumb-2
instruction set saves 25% more memory than ARM instruction set. In order to meet the
growing demand for energy-efficient wireless network applications, the Cortex-M3 processor
extends the clock frequency to the ports. ports for power saving) and built-in sleep mode.
Embedded systems often do not have a graphical user interface (GUI), which makes
debugging a real challenge for programmers. Initially, the ICE (In-circuit Emulator) was used
to create a system monitor window via a familiar interface on a PC. However, as the system
becomes smaller and more complex, this method is no longer feasible. The Cortex-M3
processor debugging technology is installed in its own hardware (in combination with several
other components) for faster debugging with trace & profiling, breakpoints, watchpoints and
patches. errors help shorten application development time
3.4.8 WHY USE CORTEX-M3 IN RESEARCH
For almost a decade, ARM7 processors have been used extensively. The Cortex-M3
processor is based on this platform, so upgrading from the ARM7 to the Cortex-M3 is just as
easy. The central core is more efficient, the simpler programming model, the deterministic

25
interrupt behavior, the integration of peripherals that improve productivity while keeping
costs down. .
3.4.9 PIN CONFIGURATION

Figure 14. STM32F103ZET106 Pins


3.5 SYSTEM STRUCTURE OF ARM CORTEX-M3
The ARM Cortex STM32 includes the Cortex core connected to the FLASH memory via a
special command bus. Cortex Data busses and Cortex System busses are connected to high
speed busses (ARM Advanced High Speed Busses). Internal SRAM is connected to AHB
and acts as DMA. Peripheral devices are connected by two high-speed peripheral bus systems
(APB -ARM Advanced Peripheral Busses). APBs through the AHB-APBs bridge connect to
the AHB system. The AHB bus matrix uses a clock frequency equal to that of the Cortex
core. However, the AHB frequency divider can operate at lower frequencies to save energy.

26
Figure 15. System Structure of ARM Cortex-M3
The internal bus architecture provides a dedicated transmission path for the executable
instruction and the data bus matrix for the Cortex core and the DMA controller to access the
processor resources.
3.5.1 BASIC MEMORY STRUCTURE
In addition to the STM32 variety of internal bus systems, it also offers 4Gbyte of continuous
memory space for programming. Memory is started at address 0x00000000. On-chip SRAMs
start at 0x20000000 addresses and all internal SRAMs are arranged at the same bit band start
point. The peripheral memory is mapped from the address 0x40000000 and in the bit band.
The control registers of the Cortex kernel are mapped from address 0xE0000000.

Figure 16. Memory Map


27
The flash memory is divided into three areas. The first area called User Flash starts at address
0x00000000. Next is System Memory, also known as large memory. This area is typically
4Gbytes in size and will be installed by the manufacturer of the bootloader. Finally, the
memory area starts at address 0x1FFFFF80 containing the configuration information for
STM32. Bootloaders are usually used to load programs via USART1 and are stored in the
User Flash area.

Figure 17. Phase Lock Loop-PLL


In addition to supporting two external clock generators STM32 provides two additional
internal clock generators. After resetting the clock to create a pulse of the Cortex core, the
High Speed Internal Oscillator operates at a low 8MHz. The remaining internal oscillator is
Low Speed Internal Oscillator) operating at low 8Mhz. The remaining internal pulse
generator is Slow Speed Internal Oscillator operating at 32768Khz. This low-speed clock is
often used for real-time clocks and watchdogs.
The Cortex cores can be clocked from internal and external oscillators simultaneously from
the internal PLL. As shown in Figure 1.36, the PLL can be obtained from a high-speed
internal oscillator oscillator that does not operate correctly at 8Mhz so that when using
peripheral devices such as serial communication or timing In real time, the external oscillator
should be used. However, no matter which oscillator to use, the Cortex core must always use
the clock generated by the PLL. All PLL controllers and bus configurations are located in the
RCC (Reset and Clock Control) group.

28
3.5.2 PHASE LOCK LOOP
After the STM32 reset system receives the clock from the HIS oscillator. At that point the
external oscillators will be turned off. The first step for STM32 to operate at the highest clock
rate is to turn on the HSE oscillator and wait until it goes into stable operation.
External oscillators can be activated via the RCC_Control control registers. There will be a
bit of the state turned on when they go into stable operation. Once the external oscillator is
stable, it can be selected as input to the PLL. The output pulse generated by the PLL is
determined by multiplying the integer multiples in the RCC_PLL configuration register. In
case the input pulse of the PLL is 8Mhz then it is necessary to configure the multiplier for
PLL of 9 to generate the 72Mhz clock at the output. When the external oscillator and PLL
are stable, the state control bit will turn on, then the external oscillator and the PLL will
operate stably, the state control bit will turn on, then the oscillation generated by PLL will be
provided for the STM32 Cortex CPU core.
3.6 8MHZ CRYSTAL
A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a regularly
ordered, repeating pattern extending in all three spatial dimensions.
Almost any object made of an elastic material could be used like a crystal, with appropriate
transducers, since all objects have natural resonant frequencies of vibration. For example,
steel is very elastic and has a high speed of sound. It was often used in mechanical filters
before quartz. The resonant frequency depends on size, shape, elasticity, and the speed of
sound in the material. High-frequency crystals are typically cut in the shape of a simple
rectangle or circular disk. Low-frequency crystals, such as those used in digital watches, are
typically cut in the shape of a tuning fork. For applications not needing very precise timing,
a low-cost ceramic resonator is often used in place of a quartz crystal.
When a crystal of quartz is properly cut and mounted, it can be made to distort in an electric
field by applying a voltage to an electrode near or on the crystal. This property is known as
electrostriction or inverse piezoelectricity. When the field is removed, the quartz generates
an electric field as it returns to its previous shape, and this can generate a voltage. The result
is that a quartz crystal behaves like an RLC circuit, composed of an inductor, capacitor and
resistor, with a precise resonant frequency.
Quartz has the further advantage that its elastic constants and its size change in such a way
that the frequency dependence on temperature can be very low. The specific characteristics
29
depend on the mode of vibration and the angle at which the quartz is cut (relative to its
crystallographic axes).[11] Therefore, the resonant frequency of the plate, which depends on
its size, does not change much. This means that a quartz clock, filter or oscillator remains
accurate. For critical applications the quartz oscillator is mounted in a temperature-controlled
container, called a crystal oven, and can also be mounted on shock absorbers to prevent
perturbation by external mechanical vibrations.

Figure 18. SMD 8MHZ Crystal


3.7 J-LINK
With up to 3 MBytes/s download speed to RAM and record-breaking flashloaders, as well as
the ability to set an unlimited number of breakpoints in flash memory of MCUs, the J-Link
debug probes are undoubtedly the best choice to optimize your debugging and flash
programming experience.
J-Link debug probes support ARM 7/9/11, Cortex-M/R/A, Microchip PIC32, Renesas RX
CPUs as well as SPI flash devices. Here is the complete list of microcontrollers and SPI flash
devices that are supported by J-Link.
The J-Link debug probes are supported by all major IDEs including Eclipse, GDB-based
IDEs and SEGGER Embedded Studio. For a complete list, please refer to Supported IDEs.

Figure 19. J-Link


30
3.8 SMD RESISTOR
Resistors are available in a large amount of different packages. Nowadays the most used are
the rectangular surface mount resistors, but also the good old axial resistor is still used
extensively in through hole designs. This page will inform you about the dimensions of SMD,
axial and MELF packages and about the required land patterns for SMD components.
The shape and size of surface mount resistors are standardized, most manufacturers use the
JEDEC standards. The size of SMD resistors is indicated by a numerical code, such as 0603.
This code contains the width and height of the package. So in the example of 0603 Imperial
code, this indicates a length of 0.060″ and a width of 0.030″. This code can be given in
Imperial or Metric units, in general the Imperial code is used more often to indicate the
package size. On the contrary in modern PCB design metric units (mm) are more often used,
this can be confusing. In general you can assume the code is in imperial units, but the
dimensions used are in mm. The SMD resistor size depends mainly on the required power
rating.

Figure 20. SMD Resistor

31
Figure 21. Sizes of SMD Resistors
3.9 SMD CAPACITOR
SMD capacitors are used in vast quantities within the manufacture of all forms of electronic
equipment. After SMD resistors they are the most widely used type of component. There are
many different types of SMD capacitor ranging from ceramic types, through tantalum
varieties to electrolytics and more. Of these, the ceramic SMD capacitors are the most widely
used. Surface mount capacitors are basically the same as their leaded predecessors. However
instead of having leads they have metallised connections at either end.

This has a number of advantages:


Size: SMD capacitors can be made very much smaller than their leaded relations. The fact
that no wired leads are required means that different construction techniques can be sued and
this allows for much smaller components to be made. Ease of use in manufacturing: For all
other surface mount components, SMD capacitors are very much easier to place using
automated assembly equipment.

32
Figure 22. SMD Capacitor

33
CHAPTER 4
HARDWARE SYSTEM MODEL AND ALGORITHM
4.1 HARDWARE STRUCTURE
4.1.1 BLOCK DIAGRAM OF ELECTRONICS METER

Figure 23. Block diagram of electronics meter.


The above block diagram explains for the working principles of our circuit. We obtain the
voltage signals and current signals from transformers. After we know U and I, we will
calculate the phase difference between U and I, it’s called cos  . U and I we can easily, but
cos  is more difficult to measure. We use the ADC to read the cosine by letting the sine wave
of u pass through zero triggers the timer counter until i passes 0,it stops counting the timer,
the more counted the timer, the smaller the cos  , the timer as far as 0, the angle of deviation
approach to 1, with the coefficient k, we can get cos  .
4.1.2 SCHEMATICS AND PCB

34
In order to get PCB, the first step is that we have to design a schematics for the circuit. We
are absolutely careful in design the schematics since if error occurs when converted to PCB,
it’s hard to fix the issues.

In the schematics, we can see exactly all of the components. Furthermore, we know positions
and names of all components.

Figure 24. Schematics of the circuit


All names and postion are set carefully, it gives us the ease to wire in PCB.

35
Figure 25. 2D electronics meter circuit in PCB.
For our circuit, we don’t use wires because using wires can cause various noises when the
circuit have transferred signals. This guides me to a solution that we create the circuit by
using PCB then we print the board. Although it takes time and money but a good quality of
the circuit.
We carefully design PCB since if any error happens after the circuit is printed, we have no
chances to fix it so we must design it again and again. This process will lengthen our time
working. The above is our product after two weeks working hard on it.

36
Figure 26. 3D electronics meter circuit in PCB
In 3D PCB, we easily obtain the shape of the circuit, it serves for work of soldering components.
However, for the first times to design PCB, we don’t have many experiences in arranging components
so the circuit may not look properly
4.2 REAL CIRCUIT
To make sure that the circuit working properly, we send PCB to a company specializing in
producing PCB. It took us eight days to finish and receive the circuit. The circuit is below

37
Figure 27. Real circuit
In this circuit, we use almost SMD components to make it not look old and primitive. The
circuit includes many small components so it requires proficient skills in soldering. Morover,
designing PCB and soldering the circuit bring me some useful practical engineering
experiences which are crucial to all engineers. We want to have the circuit perfect so we order
real circuit in China. It may be expensive but the quality is much better than ordering in
Vietnam.
The picture in the next page is the circuit that are equip full components. We try to design the
circuit as small as possible so that it has a professional overview. Also, for the future work,
when we want to insert more components, the circuit is still small.

38
Figure 28. Complete Circuit of Electronics Meter
4.3 ALGORITHM
4.3.1 VOLTAGE MESUREMENT
Assuming that the operational amplifier exhibits ideal behavior, current Im flowing in the
milliammeter A is given by:

Uo Uo R R  Ro U  R 
Im  Io  I2    U i 2 2   1 1  2 
Ro Ro R1 R2 Ro R1  Ro 

39
If R1 = R2, and the same resistances are far greater than Ro, Equation can be simplified to:

U1
Im  
Ro

Equation now shows that the milliammeter reading is directly proportional to the input
voltage through resistance Ro only. This means that, once the milliammeter full-scale value
is set, the voltmeter full-scale value can be changed, within the dynamic range of the
amplifier, by changing the Ro value. This way, the meter full-scale value can be changed
without changing its input impedance.

Figure 29. Electronic dc analog voltmeter schematics.


Voltage Measurement

Figure 30. Electronic, rectifier-based ac analog voltmeter schematics

40
Figure 31. Signal waveforms in a rectifier-based ac analog voltmeter when the input voltage is
sinusoidal
Analog meters for ac voltages can be obtained starting from the dc analog voltmeters, with a
rectifying input stage. [2] Figure shows how the structure can be modified in order to realize
an ac voltmeter. Because of the high input impedance of the electronic amplifier, i2(t) = 0,
and the current im(t) flowing in the milliammeter A is the same as current io(t) flowing in the
load resistance. Since the amplifier is connected in a voltage-follower configuration, the
output voltage is given by:

uo  t   ui  t 

Due to the presence of the input diode, current im(t) is given by:

ui  t 
m t  
Ro

when ui(t) > 0, and:

im  t   0

when ui(t) £ 0. If ui(t) is supposed to be a sine wave, the waveform of im(t) is shown in
Figure. The dc moving-coil milliammeter measures the average value – Im of im(t), which,
under the assumption of sinusoidal signals, is related to the rms value Ui of ui(t) by:

41
Figure 32. Electronic, full-wave rectifier-based ac analog voltmeter schematics

2 2
Im  U
 Ro 1

The performance of the structure in Figure can be substantially improved by considering the
structure, which realizes a full-wave rectifier. Because of the presence of diodes D1 and D2.

where ui(t) is the circuit input voltage. If capacitor C is supposed to be not connected,
amplifier A2 output voltage is:

uo  t    ui  t   2u1  t  

thus proving that the circuit in Figure realizes a full-wave rectifier. If ui(t) is a sine wave, the
waveforms of ui(t), u1(t), and uo(t) are shown in Figure 1.13. Connecting capacitor C in the
feedback loop of amplifier A2 turns it into a first-order low-pass filter, so that the circuit
output voltage equals the average value of uo (t):

U o  ui  t 

In the case of sinusoidal input voltage with rms value Ui, the output voltage is related to this
rms value by:

2 2
Uo  Ui

Uo can be measured by a dc voltmeter.

42
4.3.2 CURRENT MESUREMENT
An isolated current sensor is free of any metallic connection to the circuit being measured.
It is also essentially free of capacitive coupling so that it is safe to use with grounded
amplifiers and other equipment. The quality of the isolation is measured in volts and is
usually the breakdown potential of an insulator. 5 kV is typical for personal safety around
light industrial power. By far, the simplest current-to-voltage converter is the resistor. In
current measuring service, it is called a shunt although it is typically placed in series with
the load. That is because shunts are sometimes used to increase the range of another current-
measuring device using a connection that bypasses part of the current around a meter.
Frequency response of a shunt is good and includes dc. Shunts produce a voltage output
that can be presented by a variety of secondary meters, including analog meters, digital
meters, oscilloscopes, and 4 to 20 mA converters. Shunts provide no isolation and have a
potentially unacceptable effect on the circuit being measured. Shunts used for dc are as
accurate as the resistance and the associated voltmeter. The common moving-coil meter,
the D’Arsonval movement [1, 2], probably with an internal shunt and/or rectifier, is an
easily used device and still available. Its isolation is by means of the human eye since that
is the only way to read out the result. It is useful for power panels where an operator needs
quick data. Accuracy is no better than 2%. For power frequency, 25 to 400 Hz service, the
current transformer, called a “donut” transformer, or CT in the trade, is commonly
employed. The current-carrying conductor is passed through the hole in a toroid of magnetic
material. A shorted secondary winding of n turns carries current, which is 1/n times the
measured current, and is typically passed to another ammeter or used as the current input to
a power measuring device. Isolation is as good as the insulation on the primary conductor;
frequency response is fair but does not include dc; there is minimal effect on the measured
circuit, and the cost is low. Operational safety is an issue; see the note below. A variety of
noncontact sensors is available for dc sensing. Most depend on the Hall effect and all require
a source of operating power. Frequency response from dc to 200 kHz is advertised. Because
operating power is available, output to later processing can be voltage, current, or digital.
Accuracy is whatever one wants to pay for. Long-term stability depends on dc-coupled
operational amplifiers and can exhibit zero drift. Externally, these look much like CTs. CTs,
Hall devices, and other similar noncontact schemes are available in wrap-around form so
they can be installed without disconnecting power. The wrapping process always involves
43
breaking a magnetic path, and consistency of reassembly becomes a limit on precision.
Everything from current-sensing probes for oscilloscopes to CTs for 10000 A circuits can
be found as wrap-arounds.

44
CHAPTER 5
SOFTWARE BASIS AND PROGRAMMING
5.1 INTRODUCTION TO KEIL C

The µVision IDE is a window-based software development platform combining a robust


editor, Project Manager, and Make Utility tool. µVision supports all the Keil tools including
C/C++ Compiler, Macro Assembler, Linker, Library Manager, and Object-HEX Converter.

Device Database for selecting a device and configuring the development tools for that
particular microcontroller.

 Project Manager to create and maintain projects.


 Make Utility for assembling, compiling, and linking your embedded applications
 Full-featured source code editor.
 Template Editor that is used to insert common text sequences or header blocks.
 Source Browser for rapidly exploring code objects, locating and analyzing data in your
application.
 Function Browser for quickly navigating between functions in your program.
 Function Outlining for controlling the visual scope within a source file.
 Built-in utilities, such as Find in Files and functions for commenting and
uncommenting source code.
 µVision Simulator and Target Debugger are fully integrated.
 Configuration Wizard providing graphical editing for microcontroller startup code and
configuration files.
 Interface to configure Software Version Control Systems and third-party utilities.
 Flash Programming Utilities, such as the family of Keil ULINK USB-JTAG Adapters.
 Dialogs for all development tool settings On-line Help and links to microcontroller
data sheets and user guides.

45
µVision Device Database
The µVision Device Database offers a convenient way to select and configure your device
and project parameters. It includes preconfigured settings, so that you can fully concentrate
on your application requirements. In addition, you can add your own devices, or change
existing settings. Use the features of the Device Database to:
 Initialize the start up code and device settings.
 Load the configuration options for the assembler, compiler, and linker.
 You can add and change microcontroller configuration settings.
 The µVision Debugger is completely integrated into the µVision IDE. It provides the
following features:.
 Disassembly of the code on C/C++ source- or assembly-level with program execution
in various stepping modes and various view modes, like assembler, text, or mixed
mode.
 Multiple breakpoint options including access and complex breakpoints.
 Bookmarks to quickly find and define your critical spots.
 Review and modify memory, variable, and register values.
 List the program call tree including stack variables.
 Review the status of on-chip microcontroller peripherals.
 Debugging commands or C-like scripting functions.
 Execution Profiling to record and display the time consumed, as well as the cycles
needed for each instruction.
 Code Coverage statistics for safety-critical application testing.
 Various analyzing tools to view statistics, record values of variables and peripheral
I/O signals, and to display them on a time axis.
 Instruction Trace capabilities to view the history of executed instructions Define
personalized screen and window layouts.

46
5.2 MAIN DIAGRAM UTILIZED IN THE PROGRAM
5.3 PROGRAMMING
Coding ARM Cortex-M3 is one of the most difficult parts in our project. It’s quite different
from other cores. In order to code it, we need to have knowledge about C++ so we choose
to program in Keil C. Here is the code in Keil C
#include "stm32f1xx_hal.h"
#define GPIO_PIN_SET 1
#define GPIO_PIN_RESET 0
#define RS_Port GPIOD
#define EN_Port GPIOD
#define D4_Port GPIOD
#define D5_Port GPIOD
#define D6_Port GPIOD
#define D7_Port GPIOD
uint16_t ADC_Value[16],p=0;
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
TIM_HandleTypeDef htim3;
unsigned char DATA0[30];
unsigned char DATA1[30];
unsigned char tcadc0[30];
uint32_t adc0=0;
float i=0,fp=0;
uint8_t di=0,ti=0,v=0,dv=0;
float hi=0;
char sdi[10];
char sti[10];
char sp[10];
char cadc0;
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
47
static void MX_ADC1_Init(void);
static void MX_TIM3_Init(void);
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim->Instance == TIM3)
{
HAL_GPIO_TogglePin(GPIOB,GPIO_PIN_12); // Thuc hien chop tat led PB12
}
}
void LCD_Enable()
{
HAL_GPIO_WritePin(EN_Port,EN_Pin,1);
HAL_Delay(1);
HAL_GPIO_WritePin(EN_Port,EN_Pin,0);
HAL_Delay(1);
}
void LCD_Send4Bit(unsigned char Data)
{
HAL_GPIO_WritePin(D4_Port,D4_Pin,Data&0x01);
HAL_GPIO_WritePin(D5_Port,D5_Pin,(Data>>1)&0x01);
HAL_GPIO_WritePin(D6_Port,D6_Pin,(Data>>2)&0x01);
HAL_GPIO_WritePin(D7_Port,D7_Pin,(Data>>3)&0x01);
}
void LCD_SendCommand(unsigned char command)
{
LCD_Send4Bit(command >>4);
LCD_Enable();
LCD_Send4Bit(command);
LCD_Enable();
}
void LCD_Clear()
{
48
LCD_SendCommand(0x01);
HAL_Delay(1);
}
void LCD_Init()
{
LCD_Send4Bit(0x00);
HAL_GPIO_WritePin(RS_Port,RS_Pin,0);
LCD_Send4Bit(0x03);
LCD_Enable();
LCD_Enable();
LCD_Enable();
LCD_Send4Bit(0x02);
LCD_Enable();
LCD_SendCommand(0x28);
LCD_SendCommand(0x0C);
LCD_SendCommand(0x06);
LCD_SendCommand(0x01);
}
void LCD_Gotoxy(unsigned char x, unsigned char y)
{
unsigned char address;
if(y==0)
address=0x80;
else if(y==1)
{
address=0xc0;
}
else if(y==2)
{
address=0x94;
}
else
49
address=0xd4;
address+=x;
LCD_SendCommand(address);
}
void LCD_PutChar(unsigned char Data)
{
HAL_GPIO_WritePin(RS_Port,RS_Pin,1);
LCD_SendCommand(Data);
HAL_GPIO_WritePin(RS_Port,RS_Pin,0);
}
void LCD_Puts(char *s)
{
while (*s){
LCD_PutChar(*s);
s++;
}
}
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
LCD_Init();
MX_GPIO_Init();
MX_TIM3_Init();
while (1)
{
HAL_ADC_Start_DMA(&hadc1,(uint32_t*)&ADC_Value,12);
HAL_Delay(1);
HAL_ADC_Stop_DMA(&hadc1);
50
//LCD_Gotoxy(0,4); sprintf(DATA0,"%d %d %d %d
",ADC_Value[0],ADC_Value[1],ADC_Value[2],ADC_Value[3]); LCD_Puts(DATA0);
LCD_Puts(" ")
if(ADC_Value[1]>1000){
dv++;
if(dv<3){adc0=ADC_Value[1];adc0=adc0/18.9;}
if(dv==3){adc0=adc0+1;}
if(dv==5){adc0=adc0+2;}
if(dv==9){adc0=adc0-1;}
if(dv>=14){dv=0;adc0=adc0+1;}
} else{adc0=0;}
sprintf(tcadc0, "%i", adc0);
sprintf(sdi, "%i", di);
sprintf(sti, "%i", ti);
LCD_Gotoxy(0,0);
LCD_Puts("VOLTAGE =");LCD_Puts(tcadc0);LCD_Puts("V ");
i=ADC_Value[3]/5886;
di=(int)i;
if(ADC_Value[3]>=400){ti=ADC_Value[3]/5.886;
if(ti==2){ti=200;}
if(ti==1){ti=100;}
} else{ti=0;}
ti=(int)ti;
LCD_Gotoxy(0,1);
LCD_Puts("CURRENT = ");LCD_Puts(sdi);LCD_Puts(".");LCD_Puts(sti);LCD_Puts("A
");
hi=ti;
fp=adc0*cosphi*hi;
p=(int)fp;
p=p/1000;
sprintf(sp, "%i", p);
LCD_Gotoxy(0,2);
51
LCD_Puts("P = "); LCD_Puts(sp); LCD_Puts("W ");
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0); //Thuc hien chop tat led tai 2 chan la PB12
va PB13 noi voi LED
HAL_Delay(1000); // Delay
}
}
void MX_TIM3_Init(void)
{
TIM_ClockConfigTypeDef sClockSourceConfig;
TIM_MasterConfigTypeDef sMasterConfig;
htim3.Instance = TIM3;
htim3.Init.Prescaler = 4800;
htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
htim3.Init.Period = 499;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
HAL_TIM_Base_Init(&htim3);
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig);
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig);
}
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInit;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
52
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType =
RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
void MX_ADC1_Init(void)
{
ADC_ChannelConfTypeDef sConfig;
hadc1.Instance = ADC1;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.NbrOfConversion = 4;
HAL_ADC_Init(&hadc1);
sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
53
sConfig.Channel = ADC_CHANNEL_1;
sConfig.Rank = 2;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
sConfig.Channel = ADC_CHANNEL_2;
sConfig.Rank = 3;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
sConfig.Channel = ADC_CHANNEL_3;
sConfig.Rank = 4;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
}
void MX_DMA_Init(void)
{
__HAL_RCC_DMA1_CLK_ENABLE();
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
}
void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOD, D6_Pin|D7_Pin|RS_Pin|EN_Pin
|D4_Pin|D5_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin : PB0 */
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
54
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : D6_Pin D7_Pin RS_Pin EN_Pin
D4_Pin D5_Pin */
GPIO_InitStruct.Pin = D6_Pin|D7_Pin|RS_Pin|EN_Pin
|D4_Pin|D5_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
}
#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
}
#endif

CHAPTER 6
RESULTS
After we finish coding and adjusting all component, we try with some common equipment.
First, we try with a lamp, power consumption 30W on the label, the result is shown below :

55
Figure 35. Lamp Measurement

To make sure the circuit is working well, we try with other equipment.
I know exactly the power consumption of a charger is 24W, then we try to measure and it
gives an accurate result as shown below

56
Figure 36. Charger
We also test the durability of the circuit, let it run in two hour, then see whether the result is still
correct or it gives a wrong result. It’s clear to know that, the circuit works well in any cases.

57
Another experiment we use to test the circuit. It’s still working well and no heat happens during
whole running time. The same as previous one, we let it run in two hours, then no error occurs.

Figure 37. Bulb light

58
CHAPTER 7
CONCLUSION AND FUTURE WORK
In this research report, the electronics meter implemented by utilizing potential transformer,
current transformer, LCD through the microcontroller STM32F103ZET6 is well achieved.
The design is found to be working properly with quite high accuracy. It has small size, light
weight and low power consumption that may clearly display essential parameters on the
screen. Through what we have researched, we accumulated a lot of knowledge about working
principles of potential and current transformer, STM32 programming, and designing
schematics, PCB on Altium Designer.

In the future, we will try to make the design more precise, may analyze and identify different
kinds of signals that approach to the system, then resolve them. What we tend to reach for far
future is that we can design an electronics meter with small size and it can be sold in market.
In order to make it come true, we must develop every part in the circuit. Besides, to be on top
in the market, the price is priority, hence, reducing cost of designing is a tough question to
us.

Moreover, we are reaching to industrial technology 4.0 period, having communication in the
circuit is a such important task. When using communication in electronics meters, we can
easily obtain information from them with a smart phone.

59
BIBLIOGRAPHY
[1] M. Barnes. Practical Variable Speed Drives and Power Electronics. Newnes, 2003.
[2] Simone Buso. Digital Control in Power Electronics. Morgan Publishers, 2007.
[3].Electronics-tutorials.ws/transformer/transformer-construction.html.
[4] Predictabledesigns.com/introduction-to-programming-stm32-arm-cortex-m-32-bit-
microcontrollers.

60

You might also like