Download as pdf or txt
Download as pdf or txt
You are on page 1of 152

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/259563184

Master of Science dissertation, Digital control techniques for grid-connected


inverters, Ain Shams University, 2013. By: Ahmed Abdalrahman Ahmed,

Thesis · January 2013

CITATIONS READS

0 1,161

1 author:

Ahmed Abdalrahman
University of Waterloo
9 PUBLICATIONS 55 CITATIONS

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Smart Grid View project

All content following this page was uploaded by Ahmed Abdalrahman on 28 December 2017.

The user has requested enhancement of the downloaded file.


AIN SHAMS UNIVERSITY
FACULTY OF ENGINEERING
Electronics and Communications Engineering Department

Digital Control Techniques for Grid-Connected


Inverters
A Thesis
Submitted in partial fulfillment of the requirements of the degree of
Master of Science in Electrical Engineering

Submitted by
Ahmed Abd Al-Rahman Ahmed
B.Sc. of Electrical Engineering
(Electronics and Communications Engineering)
Thebes High Institute of Engineering, 2008

Supervisors:
Prof. Dr. Abdel Haleem Zekry
Dr. Ahmed Ali Al-Shazly
Cairo, 2013
Judgment Committee

Name: Ahmed Abd Alrahman Ahmed Abd Alrazek


Thesis: Digital control techniques for grid-connected inverters
Degree: Master of Science in Electrical Engineering

Title, Name and Affiliation Signature

Prof. Dr. Mohamed Abd El-Monem Abou El-Ela


(Professor in Faculty of Engineering, Future University) .........................................

Prof. Dr. Wagdy Refaat Anis


(Professor in Faculty of Engineering, Ain-shams University) .........................................

Prof. Dr. Abdelhalim Abdelnaby Zekry


(Professor in Faculty of Engineering, Ain-shams University) .........................................

Date: / /
STATEMENT

This dissertation is submitted to Ain Shams University for the degree of Master
of Science in Electrical Engineering (Electronics and Communications
Engineering).

The work included in this thesis was carried out by the author at the Electronics
and Communications Engineering Department, Faculty of Engineering, Ain
Shams University, Cairo, Egypt.

No part of this thesis was submitted for a degree or a qualification at any other
university or institution.

Name: Ahmed Abd Alrahman Ahmed


Signature:
Date:
Curriculum Vitae
Name of Researcher Ahmed Abd Alrahman Ahmed Abd Alrazek
Date of Birth 18/4/1986
Place of Birth Egypt
First University Degree B.Sc. in Electrical Engineering
Name of University Thebes High Institute of Engineering
Date of Degree June 2008
ABSTRACT
Ahmed Abd Alrahman Ahmed, Digital control techniques for grid-connected inverters,
Master of Science dissertation, Ain Shams University, 2013.

This thesis demonstrates the design of a control algorithm for the grid-connected inverter,
which is considered an important section in renewable-energy conversion systems. The thesis
is arranged into four main parts:

Firstly, the main hardware topologies of the renewable-energy conversion systems are
presented. Then the block diagram of the grid-connected inverter and its control objectives
are discussed.

Secondly, this thesis introduces a comprehensive study of the three-phase grid-connected


inverter with grid side controller. Initially, the stand-alone three-phase inverter is discussed.
This is followed by a presentation of the mathematical model of the grid-connected inverter.
After that, the possible current control strategies for the grid-connected inverter are studied.
Then the PWM techniques of the three-phase inverter are addressed. After that, the
synchronization algorithms for the grid-connected inverter are introduced. Finally, a
discussion of grid filters topologies for interfacing the distributed generation with national
electricity grid is provided.

Thirdly, the stand-alone and the grid-connected inverter systems are modeled based on the
theoretical basics presented in the previously. These systems are then simulated to verify the
effectiveness of its control structure and to determine its performance parameters using PSIM
simulation package.

Finally, complete experimental versions for both the stand-alone and the grid-connected
inverter are presented. The major differences between the simulation model and the
experimental version are clarified.

Keywords: grid-connected inverter, synchronous PI controller, SVM, PLL.


SUMMARY
Ahmed Abd Alrahman Ahmed, Digital control techniques for grid-connected inverters,
Master of Science dissertation, Ain Shams University, 2013.

This thesis demonstrates the different issues of implementing a control algorithm for the
grid-connected inverter. The thesis is divided into four chapters organized as follows:

Chapter One: is an introduction to renewable-energy and its applications. A brief review on


the state of the contribution of renewable-energy sources like solar energy, wind energy, and
biomass in the Egypt strategy of energy are presented. In addition, it discusses the structure
of distributed generation systems. Moreover, the hardware topologies of PV systems and
wind turbines systems for grid connection are presented. Finally, the block diagram of the
grid-connected inverter, which is the goal of the thesis, is provided and its parts are showed.

Chapter Two: presents a comprehensive study of the three-phase grid-connected inverters.


Firstly, the basic construction of the three-phase inverter is introduced. Secondly, the
mathematical model of the grid-connected inverter is presented. The closed loop current
control techniques are studied, namely: hysteresis current controller, predictive controller,
and linear PI controller. Then their performances are compared. It is found that the linear PI
controller is more suitable for the grid-connected inverter application, since it offers an
excellent steady-state response with zero steady-state error, low current ripple, and highly
sinusoidal waveform to the grid-connected inverter. In addition, the controller is insensitive
to system parameters since the algorithm does not need system models.

Thirdly, the most common PWM techniques are addressed, and then the SPWM and SVM
along with a comparison between them are discussed. The SVM is chosen for the grid-
connected inverter application because SVM has many advantages such as constant
switching frequency, well-defined output harmonic spectrum, optimum switching patterns,
and excellent dc-link voltage utilization.

Fourthly, the importance of the synchronization, for control purposes, of a grid-connected


power generation system is presented. In addition, it is reported that several synchronization
algorithms are capable of detecting the phase angle of the grid voltage, namely: zero crossing
detection, filtering of grid voltages, and PLL technique. It is concluded that the PLL is the
best choice for the grid-connected inverter application. This is because the PLL can
successfully detect the phase angle of the grid voltage even when noise or higher-order
harmonics exist in the grid voltage. Finally, the grid filter that is used in the connection of an
inverter to the utility grid is discussed. Three types of grid filter are addressed, namely: L-
filter, LC-filter, and LCL-filter. The LCL-filter is chosen for the grid-connected inverter
application, since it is effective in the reduction of switching frequency harmonics of the
power inverter. In addition, it reduces the dependence of the filter on the grid parameters.

Chapter Three: in this chapter, the stand-alone and the grid-connected inverter systems are
modeled based on the theoretical basics presented in the previous chapter. These systems are
then simulated to verify the effectiveness of its control structure and to determine its
performance parameters using PSIM simulation package. In the first part, a model for the
stand-alone three-phase inverter is developed. The gating signals for 180º conduction are
simulated, and the simulated output waveforms of the three-phase inverter are shown. In the
second part, the SVM algorithm for three-phase inverter is simulated. The four steps that are
used to implement the SVM algorithm are analyzed, and its results are given. In addition, the
simulated output waveforms of the three-phase inverter with SVM are shown. In the final
part, a model for the grid-connected three-phase inverter is constructed, and the parasitic
elements of the constituting power components are taken into consideration. This simulation
model includes the current controller, SVM, grid-filter, and PLL. All simulation results
validate the theoretical studies performed in chapter 2.

Chapter Four: presents complete experimental versions for both the stand-alone and the
grid-connected inverter. The major differences between the simulation model and the
experimental version are clarified. In the first place, the stand-alone inverter is implemented
and tested. Then the experimental results are presented. All experimental results validate the
theoretical and simulation studies that are done in chapter 2 and chapter 3, respectively. In
the second place, a comprehensive implementation of the three-phase grid-connected inverter
is introduced. The experimental results are shown after testing every part of this circuit.
Additionally, the differences between the simulation and the experimental results are
analyzed. Agreements are found between the simulation and experimental results when the
parasitic resistances of the power components of the inverter circuit are taken into
consideration.

Finally, the thesis ends by extracting conclusions and stating future work that might be done
based on this work.
ACKNOWLEDGEMENT
‫ﺍﻟﺤﻤﺪ ﻟ ﺭﺏ ﺍﻟﻌﺎﻟﻤﻴﻦ‬
I would like to take the opportunity to acknowledge the direct and indirect help of many
people who made this thesis possible.

I would like to express my sincere appreciation to Prof. Dr. Abdel Haleem Zekry and Dr.
Ahmed Al-shazly for their continuous support and valuable guidance. Prof. Dr. Abdel
Haleem Zekry was always giving me valuable advices that help me not only in my thesis, but
also in my life.

I would like to thank my parents, Eng. Abd Al-Rahman and Eman, without their help, this
degree would not have been possible. Moreover, I would like to thank my brothers, Eng.
Mahmoud, Eng. Mohannad, and my little sister Mena Allah.

I would like also to thank Dr. Ahmed Eldessouky for his support and encouragement.
Additionally, I especially want to thank Dr. Noha Ghuneimi. Her assistance and advice was a
tremendous help. Many thanks go to my colleagues and friends for their support and help
during my thesis. Special thanks for Eng. Omar Abdal rehim, Eng. Ahmed Asmat, Eng.
Mohamed Hawary, Eng. Allam Shehata, Eng. Mahmoud Alaa, and Eng. Amin Alsaied.

Ahmed Abd Alrahman


November 2012
List of Contents
LIST OF FIGURES.................................................................................................................................. IV
LIST OF TABLES .................................................................................................................................. VII
LIST OF SYMBOLS .............................................................................................................................. VIII
LIST OF ABBREVIATIONS ..................................................................................................................... IX

CHAPTER 1 RENEWABLE ENERGY AND ITS APPLICATIONS ................................................................. 1


1.1 INTRODUCTION ............................................................................................................................... 1
1.2 RENEWABLE ENERGY APPLICATIONS IN EGYPT ....................................................................................... 1
1.2.1 WIND ENERGY...................................................................................................................................... 2
1.2.2 SOLAR ENERGY ..................................................................................................................................... 2
1.2.2.1 Solar Thermal Technologies .......................................................................................................... 2
1.2.2.2 Photovoltaic (PV) Technology ....................................................................................................... 2
1.2.3 BIOMASS TECHNOLOGIES ....................................................................................................................... 3
1.3 RENEWABLE ENERGY GENERATION SYSTEMS ......................................................................................... 3
1.3.1 HARDWARE STRUCTURE FOR GRID-CONNECTED PV SYSTEMS ....................................................................... 4
1.3.2 HARDWARE STRUCTURE FOR GRID-CONNECTED WT SYSTEMS...................................................................... 6
1.4 GRID-CONNECTED INVERTER BLOCK DIAGRAM ..................................................................................... 10
1.5 SUMMARY ................................................................................................................................... 11

CHAPTER 2 THE THEORY OF THE GRID-CONNECTED THREE-PHASE INVERTER .................................. 13


2.1 INTRODUCTION ............................................................................................................................. 13
2.2 THE THREE-PHASE INVERTER............................................................................................................ 13
2.3 MATHEMATICAL MODEL OF THE GRID-CONNECTED INVERTER ................................................................. 17
2.4 THE CONTROL THEORY OF THE GRID-SIDE INVERTER ............................................................................. 19
2.4.1 HYSTERESIS CURRENT CONTROLLER ....................................................................................................... 22
2.4.2 PREDICTIVE CURRENT CONTROLLER ....................................................................................................... 23
2.4.3 LINEAR PI CURRENT CONTROLLER .......................................................................................................... 23
2.4.4 COMPARISON BETWEEN THE THREE CURRENT CONTROLLERS ..................................................................... 26
2.5 PULSE WIDTH MODULATION TECHNIQUES .......................................................................................... 28

I
2.5.1 SINUSOIDAL PWM .............................................................................................................................. 28
2.5.2 SPACE VECTOR MODULATION ............................................................................................................... 30
2.5.3 COMPARISON BETWEEN SPWM AND SVM............................................................................................. 33
2.6 GRID SYNCHRONIZATION ................................................................................................................. 34
2.6.1 ZERO CROSSING DETECTION .................................................................................................................. 35
2.6.2 FILTERING OF GRID VOLTAGES ............................................................................................................... 35
2.6.3 PHASE-LOCKED LOOP (PLL) .................................................................................................................. 36
2.7 GRID FILTER ................................................................................................................................. 37
2.7.1 L‐FILTER ............................................................................................................................................ 37
2.7.2 LC-FILTER .......................................................................................................................................... 38
2.7.3 LCL-FILTER ......................................................................................................................................... 38
2.8 SUMMARY ................................................................................................................................... 39

CHAPTER 3 SYSTEM SIMULATION .................................................................................................... 41


3.1 INTRODUCTION ............................................................................................................................. 41
3.2 SIMULATION OF THE STAND-ALONE THREE-PHASE INVERTER .................................................................. 41
3.3 SIMULATION OF SVM..................................................................................................................... 44
3.3.1 STEP 1, COMPUTATION OF UΑ, UΒ, UREF, AND ANGLE (Θ) ............................................................................ 45
3.3.2 STEP 2. SECTOR DETERMINATION .......................................................................................................... 47
3.3.3 STEP 3. CALCULATION OF TIME DURATION T1, T2, T0, AND T7..................................................................... 48
3.3.4 STEP 4. SWITCHING TIME DETERMINATION OF EACH TRANSISTOR (SW1 TO SW6). ......................................... 48
3.4 SIMULATION OF GRID-CONNECTED THREE-PHASE INVERTER ................................................................... 53
3.4.1 SIMULATION OF PLL SYNCHRONIZATION CIRCUIT ...................................................................................... 54
3.4.2 SIMULATION OF CURRENT CONTROL STRUCTURE FOR THE GRID-CONNECTED INVERTER .................................. 56
3.5 SUMMARY ................................................................................................................................... 61

CHAPTER 4 SYSTEM IMPLEMENTATION ........................................................................................... 63


4.1 INTRODUCTION ............................................................................................................................. 63
4.2 IMPLEMENTATION OF THE STAND-ALONE THREE-PHASE INVERTER ........................................................... 63
4.2.1 THREE-PHASE POWER INVERTER CIRCUIT ................................................................................................ 64
4.2.2 THE CONTROL CIRCUIT ......................................................................................................................... 68
4.2.3 EXPERIMENTAL DATA FOR THE STAND-ALONE THREE-PHASE INVERTER ........................................................ 71

II
4.3 IMPLEMENTATION OF THE GRID-CONNECTED THREE-PHASE INVERTER ...................................................... 75
4.3.1 THE POWER INVERTER CIRCUIT ............................................................................................................. 76
4.3.2 AUXILIARY POWER SUPPLIES ................................................................................................................. 76
4.3.3 EXTERNAL SENSORS BOARD .................................................................................................................. 76
4.3.3.1 Current Measurement Circuit ..................................................................................................... 77
4.3.3.2 Voltage Measurement Circuit ..................................................................................................... 78
4.3.4 THE INVERTER CONTROL DESIGN ........................................................................................................... 81
4.3.4.1 Hardware of Inverter Control Board ........................................................................................... 81
4.3.4.2 Firmware of dsPIC Microcontroller ............................................................................................. 83
4.3.4.3 PC Based Control Software.......................................................................................................... 89
4.3.5 EXPERIMENTAL DATA FOR THE GRID-CONNECTED THREE-PHASE INVERTER .................................................. 90
4.4 SUMMARY ................................................................................................................................... 96

CONCLUSIONS & FUTURE WORK ........................................................................................................ 98


BIBLIOGRAPHY................................................................................................................................. 101
EXTRACTED PAPER ........................................................................................................................... 106

APPENDIX A COORDINATE TRANSFORMATION ............................................................................ 107


I. CLARK TRANSFORMATION ................................................................................................................ 107
II. PARK TRANSFORMATION ................................................................................................................ 108

APPENDIX B SOFTWARE SOURCE CODE ........................................................................................ 110


I. FIRMWARE FOR THE THREE-PHASE INVERTER ....................................................................................... 110
II. FIRMWARE FOR THE GRID-CONNECTED INVERTER................................................................................. 116
III. PC BASED CONTROL SOFTWARE SOURCE CODE .................................................................................. 128

III
List of Figures
Fig. 1.1, Hardware structure for a PV system using a dc–dc stage to boost the input voltage. ...... 4
Fig. 1.2, Hardware structure for a PV system using step-up transformer. ...................................... 5
Fig. 1.3, Main components of the wind generation system ............................................................ 6
Fig. 1.4, WT systems using power electronic ................................................................................. 8
Fig. 1.5, Generalized power electronics converter for wind systems ............................................. 9
Fig. 1.6, Block diagram of grid-connected inverter ...................................................................... 10
Fig. 2.1, Three phase inverter circuit ............................................................................................ 14
Fig. 2.2, Gating signals and output line-to-line voltages of three-phase VSI ............................... 16
Fig. 2.3, output line-to-neutral voltages of three-phase VSI......................................................... 16
Fig. 2.4, Model of grid-connected inverter ................................................................................... 17
Fig. 2.5, Basic block diagram of current controlled PWM converter. .......................................... 20
Fig. 2.6, (a) Controller with open-loop PWM block. (b) On-off controller. ................................ 21
Fig. 2.7, Block diagram of HCC strategy for a three-phase grid-connected PWM VSI. ............. 22
Fig. 2.8, General structure for synchronous reference frame control structure [9]. ..................... 26
Fig. 2.9, Block scheme of carrier based sinusoidal PWM ............................................................ 29
Fig. 2.10, Basic waveforms of carrier based sinusoidal PWM ..................................................... 29
Fig. 2.11, Six active vectors and two null vectors in SVM. ......................................................... 30
Fig. 2.12, Block scheme of the space vector modulator ............................................................... 31
Fig. 2.13, Output pulses based on Symmetrical Sequence algorithm in sector ............................ 31
Fig. 2.14, Synchronization method using filtering on the synchronous frame. ............................ 35
Fig. 2.15, Synchronization method using filtering on the stationary frame. ................................ 36
Fig. 2.16, Basic structure of a PLL system for grid synchronization. .......................................... 36
Fig. 2.17, Filter configuration circuits .......................................................................................... 37
Fig. 3.1, Simulation circuit of stand-alone three phase inverter ................................................... 42
Fig. 3.2, Simulation of the gating signals of the stand-alone three-phase inverter ....................... 42
Fig. 3.3, Simulation waveforms of line-to-neutral voltage of the stand-alone three-phase
inverter .......................................................................................................................................... 43
Fig. 3.4, Simulation waveforms of line-to-line voltage of the stand-alone three-phase inverter . 43
Fig. 3.5, Simulation circuit of the three-phase inverter with SVM............................................... 44

IV
Fig. 3.6, Simulation circuit for Determination Vα, Vβ, Vref, and angle (ϑ) ................................... 45
Fig. 3.7, (a) Simulation waveforms of input reference signals. (b) Simulation waveforms of
the Uα and Uβ. .............................................................................................................................. 46
Fig. 3.8, Simulation waveform of angle (θ) .................................................................................. 46
Fig. 3.9, Simulation circuit of sector determination ..................................................................... 47
Fig. 3.10, Simulation waveform of sector allocation .................................................................... 47
Fig. 3.11, Simulation circuit of time interval calculation ............................................................. 48
Fig. 3.12, Simulation circuit for transistors switching time calculation ....................................... 49
Fig. 3.13, SVM switching patterns at each sector......................................................................... 50
Fig. 3.14, The overall simulation circuit of SVM algorithm ........................................................ 51
Fig. 3.15, The gating signals for sector 1...................................................................................... 52
Fig. 3.16, The simulation output phase-to-neutral voltage of three-phase inverter with SVM .... 52
Fig. 3.17, The simulation output of phase-to-phase voltages of three-phase inverter with
SVM .............................................................................................................................................. 53
Fig. 3.18, Simulation model of the grid-connected inverter ......................................................... 54
Fig. 3.19, The grid phase angle and the output voltage on 50Hz grid .......................................... 55
Fig. 3.20, The grid phase angle and the output voltage on 40Hz grid .......................................... 55
Fig. 3.21, The grid phase angle and the output voltage on 60Hz grid .......................................... 56
Fig. 3.22, PI controller tuning with setting Ki to 0 and Kp=Kcr . .................................................. 57
Fig. 3.23, Id current reference and measured................................................................................ 58
Fig. 3.24, Iq current reference and measured................................................................................ 58
Fig. 3.25, Simulation result of phase grid current Ia. ................................................................... 59
Fig. 3.26, Simulation result of three-phase grid currents (ia, ib, ic). ............................................ 59
Fig. 3.27, Inverter phase voltage at the input of the filter............................................................. 60
Fig. 3.28, Inverter phase voltage considering ideal transistors. .................................................... 60
Fig. 3.29, Inverter phase voltage considering non-ideal transistors after step-up transformer ..... 61
Fig. 4.1, Circuit diagram of power circuit of the inverter ............................................................. 65
Fig. 4.2, IR2110 typical connection .............................................................................................. 66
Fig. 4.3, The PCB of the three-phase inverter power circuit ........................................................ 67
Fig. 4.4, The control circuit of three phase inverter...................................................................... 69
Fig. 4.5, Software flowchart of stand-alone three-phase inverter part-1 ...................................... 70

V
Fig. 4.6, Software flowchart of stand-alone three-phase inverter part-2 ...................................... 71
Fig. 4.7, The gating signal for sw1on CH1and the shifted by 60º signal for sw6 on CH2 ........... 72
Fig. 4.8, The gating signal for sw1on CH1and the shifted by 120º signal for sw2 on CH2 ........ 72
Fig. 4.9, The gating signal for sw1on CH1and the shifted by 180º signal for sw4 on CH2 ......... 73
Fig. 4.10, The gating signal for sw1on CH1and the shifted by 240º for sw3 on CH2 ................. 73
Fig. 4.11, The gating signal for sw1on CH1and the shifted by 300º signal for sw5 on CH2 ....... 74
Fig. 4.12, Snapshot of phase-to-neutral output voltage three-phase inverter ............................... 74
Fig. 4.13, Snapshot of phase-to-phase output voltage three-phase inverter. ................................ 75
Fig. 4.14, Schematic diagram of grid-connected inverter ............................................................. 75
Fig. 4.15, current sensors circuit ................................................................................................... 77
Fig. 4.16, oscilloscope screenshot of current measurement circuit output for two phases. .......... 78
Fig. 4.17, Voltage measurement circuit ........................................................................................ 79
Fig. 4.18, Oscilloscope screenshot of voltage measurement circuit output for two phases. ........ 80
Fig. 4.19, Output of voltage sensor on CH1 and grid voltage on CH2......................................... 80
Fig. 4.20, Circuit diagram of grid connected inverter control board ............................................ 82
Fig. 4.21, dsPIC software flow chart (The main routine) ............................................................. 86
Fig. 4.22, dsPIC software flow chart (The SVM routine) ............................................................ 87
Fig. 4.23, dsPIC software flow chart ( PWM interrupt service routine) ....................................... 88
Fig. 4.24, dsPIC software flow chart ( ADC interrupt service routine) ........................................ 89
Fig. 4.25, Screenshot of PC software for inverter control ............................................................ 90
Fig. 4.26, The output pulses for two transistors S1 and S3 .......................................................... 92
Fig. 4.27, The measured voltage signal on CH1 and the generated pulses on CH2. .................... 92
Fig. 4.28, The generated pulses from microcontroller on CH1 and pulses after driver IC on
CH2 ............................................................................................................................................... 93
Fig. 4.29, The output pulses for two complementary transistors S1 and S4................................. 93
Fig. 4.30, The dead time that inserted between two complementary transistors S1 and S4 ......... 94
Fig. 4.31, Experiment waveform of the phase-to-neutral voltage of grid-connected inverter...... 94
Fig. 4.32, Experiment waveform of the phase-to-phase voltage of grid-connected inverter........ 95
Fig. 4.33, Experimental waveform of the output phase voltage and the grid voltage .................. 95
Fig. A.1, Clark Transform for current......................................................................................... 107
Fig. A.2, Park transform for current ........................................................................................... 109

VI
List of Tables
Table 2.1, switches states of three-phase VSI............................................................................... 15
Table 2.3, Comparison between the three current controllers ...................................................... 27
Table 2.2, Comparison between SPWM and SVM ...................................................................... 34
Table 3.1, Switching Time Calculation at Each Sector ................................................................ 49
Table 4.1, dsPIC30F peripheral usage .......................................................................................... 84
Table 4.2, Source code files .......................................................................................................... 85

VII
List of Symbols
E The peak value of the grid voltage
ea,b,c Phase Voltages of the grid
Ɛa,b,c The three-phase error signals in current controller
ed,q Phase Voltages of the grid in synchronous dq reference frame
eα,β Phase Voltages of the grid in stationary αβ reference frame
f Grid frequency
Fs The sampling frequency
Fsn The number of samples
ia,b,c The output phase currents of the inverter
L The inductance between the inverter and grid
R The resistance between the inverter and grid
SA,B,C The switching signals for the three-phase inverter
T0,1,2,7 Time-shares of voltage vectors in SVM
Ts Sampling time
U0→7 Voltage Space Vectors
ua,b,c The output phase voltages of the inverter
ud,q The output phase voltage of the inverter in synchronous dq reference frame
Udc Input DC voltage to the inverter
Uref Reference Space vectors
Ut Triangular Carrier Signal
uα,β The output phase voltage of the inverter in stationary αβ reference frame
θ The grid angle
ω The angular frequency of the grid
ωff The utility nominal frequency

VIII
List of Abbreviations
AC Alternate Current
ADC Analog-to-Digital Converter
CC Current Controlled
CPU Center Processing Unit
DC Direct Current
DPGS Distributed Power Generation System
DSC Digital Signal Controller
DSP Digital Signal Processor
HCC Hysteresis Current Control
I2C Inter-Integrated Circuit
LED Light Emitted Diode
MIPS Mega Instruction Per Second
MOSFET Metal Oxide Semiconductor Field Effect Transistor
MPPT Maximum Power Point Tracking
MW Mega watt
PC Personal Computer
PCB Printed Circuit Board
PI Proportional Integral
PLL Phase Locked Loop
PV Photovoltaic
PWM Pulse Width Modulation
SCIG Squirrel-Cage Induction Generator
SPI Serial Peripheral Interface
SPWM Sinusoidal Pulse Width Modulation
SVM Space Vector Modulation
THD Total Harmonic Distortion
TWh Terawatt Hour
UART Universal Asynchronous Receiver/Transmitter
VCO Voltage Controlled Oscillator

IX
VSI Voltage Source Inverters
WT Wind Turbines

X
Chapter 1 Renewable Energy and its Applications

Chapter 1
Renewable Energy and its Applications
1.1 Introduction

Fossil fuels and hydropower along with non-commercial fuels such as firewood are
considered the main energy resources in Egypt. Nowadays, oil and natural gas are the most
significant Fossil fuel energy sources in Egypt and will be for several years in the future. The
Nile's hydropower is considered the third major supplier of energy, but most of its
hydropower potential has already been used to generate about 13 TWh of electricity per
annum [1].

Because of the growing demand in fossil fuel resources and the resulting
environmental effects, Egypt’s energy strategy aims to increase the reliance on renewable
energy sources, particularly wind and solar power. Consequently, the national energy plan
aims to achieve 20% of total generated electricity from renewable energy sources by the year
2020 including 12% from wind energy. This expected to be achieved through establishing
grid-connected wind farms and solar photovoltaic (PV) systems.

This chapter begins with a brief review of the commercially exploited renewable-
energy applications in Egypt. Then, the renewable-energy generation systems for both PV
systems and wind turbines (WT) systems are presented. Finally, the block diagram of the grid
side converter and its control is introduced.

1.2 Renewable Energy Applications in Egypt

Egypt is endowed with different renewable-energy resources, especially wind and


solar energies. This section presents the renewable-energy resources potential in Egypt, their
status, and government policies to developing renewable-energy technology [1].

1
Chapter 1 Renewable Energy and its Applications

1.2.1 Wind Energy

Wind turbines convert kinetic energy in the wind into mechanical power that can be
converted into electrical energy using a generator. Wind Atlas of Egypt concluded that there
are many promising areas with high wind speeds in the Gulf of Suez, some areas located on
both sides of the Nile River, and some areas in Sinai. These areas are qualified for the
establishment of large-scale wind energy projects.

At the end of 2010, some of wind energy projects have been established like Zafarana
545 MW Wind Farm, and 5 MW Wind Farms in Hurghada. Moreover, it is planned to
implement wind energy projects with total capacities of 2370 MW as part of the national
strategy to promote wind energy.

1.2.2 Solar Energy

Solar technologies use the energy of the sun directly, and then it produces heat, light,
and power. Egypt is considered one of the countries that located in “sunbelt” area and most
suitable for solar-energy applications. The solar Atlas of Egypt shows that the average direct
normal solar radiation is 2000 – 3200 kWh/m2/year. In addition, the sunshine duration
ranges between 9 – 11 h/day, which means that Egypt is suitable for solar-energy
applications.

1.2.2.1 Solar Thermal Technologies

Solar Thermal technologies are identified to be among the main renewable-energy


technology options that can make an impact in achieving the strategy targets. Intensive
efforts are directed mainly at three options:
• Solar thermal water heating that is used for domestic and commercial sectors.
• Solar thermal systems that is used in industrial process heat.
• Solar thermal systems that is used for electricity generation.

1.2.2.2 Photovoltaic (PV) Technology

Photovoltaic (PV) technology involves converting solar energy directly into electrical
energy by a solar cell. A solar cell is typically made of semiconductor materials such as

2
Chapter 1 Renewable Energy and its Applications

crystalline silicon that absorbs sunlight and produces electricity through a process called the
photovoltaic effect.

In spite of being an expensive technology, Photovoltaic systems are considered the


most appropriate energy application for rural and remote areas of small-scattered loads,
which are far away from the national grid. The cost of PV systems maintenance is limited
while the PV life span is about 25 years. At the end of 2010, the total capacity of PV systems
in Egypt is around 10 MW, for lighting, water pumping, wireless communications, cooling
and commercial advertisements on highways.

Solar projects are considered one of the main aspects to increase the contribution of
the renewable-energy the national energy plan. Consequently, the five-year plan (2012 -
2017) includes:
• Solar thermal plants of electricity generation provide total capacity of 100 MW.
• Photovoltaic plants provide total capacity of 20 MW.

1.2.3 Biomass Technologies

Biomass, as a renewable-energy source, is a biological material from living or


recently living organisms such as dead trees and agricultural wastes. As an energy source,
biomass can either be used directly or converted into other energy products such as bio-fuel.
In Egypt, the total biomass resources potential reach 40 million Ton / year. Therefore, many
small-scale research projects are implemented to use this technology.

1.3 Renewable Energy Generation Systems

The power-generation systems that based on renewable-energy sources like


photovoltaic, and wind turbines can be either in centralized systems or in distributed power
generation systems (DPGSs). In the centralized power plants, the electricity is generated at a
remotely located, large-scale power plant, and then it transmitted to the consumer through the
power lines. On the other hand, the DPGSs are small-scale power generation technologies
(typically in the range of 3 kW to 10,000 kW), which is used to provide an alternative or an
enhancement to the traditional centralized power generation system. The DPGS provides

3
Chapter 1 Renewable Energy and its Applications

electric power at a site closer to the customer, eliminating the unnecessary transmission and
distribution costs. In addition, it is quieter and less polluting than large power plants.

The DPGS can be designed either as standalone systems or as grid-connected systems. The
stand-alone systems are used in off-grid applications that meet the local demands from
electricity in the remote locations [2], [3]. On the other hand, the grid-connected systems are
the systems that integrated with the mains power grid, and it can feed the surplus power
generated at the utility grid. In this case, the system output voltage and frequency should be
the same as that of grid voltage and frequency [4]. Consequently, the control of the grid-
connected systems should be improved to meet the requirements for grid interconnection.

In [5], it is stated that the control tasks of the grid-connected systems can be divided
into two parts: input-side controller and grid-side controller. The control objective on the
input-side controller is to capture maximum power from the input source. However, the
control objectives on the grid-side controller are to control the power delivered to the grid,
ensure high quality of the injected power and grid synchronization.

The integration of the renewable-energy sources to the utility grid can be done with
the aid of the power electronics converters. These power conversion units have different
hardware structures, which are closely related to the input power nature. The following
subsections presents an overview on the technologies mostly used today in PV systems and
wind turbines systems.

1.3.1 Hardware Structure for Grid-connected PV Systems

Fig. 1.1, Hardware structure for a PV system using a dc–dc stage to boost the input voltage.

4
Chapter 1 Renewable Energy and its Applications

In PV system, the output voltage is a constant DC whose magnitude depends on the


configuration in which the solar cells/modules are connected. On the other hand, the current
output from the PV system primarily depends on the available solar irradiance. Although PV
systems have a low-voltage input provided by the PV panels, more such units can be
connected together to obtain the required voltage and power level. In this case, it called PV
arrays.

The main requirements of power electronic interface units for the PV systems are to
convert the generated DC voltage into a suitable AC for utility connection. As shown in Fig.
1.1, the DC voltage magnitude of the PV array is required to be boosted to a higher value by
using DC-DC converters before converting them to the utility compatible AC. The DC-AC
inverters are then utilized to convert the output voltage from the DC-DC converter into AC
voltage. To meet the requirements for grid interconnection, the inverter output voltage and
frequency should be the same as that of grid voltage and frequency. The process of
controlling the voltage and current output of the array must be optimized based on the
weather conditions. Specialized control algorithm has been developed called maximum
power point tracking (MPPT) used to extract the maximum amount of power from the array
under varying conditions. The control objective in the DC-DC converter is to perform the
MPPT algorithm and the voltage boosting. However, the control objective in the DC-AC
inverter is to control the injected power into the grid and grid synchronization. Nevertheless,
this configuration does not have a galvanic isolation between input and output [6], [7].

Fig. 1.2, Hardware structure for a PV system using step-up transformer.

5
Chapter 1 Renewable Energy and its Applications

Another configuration is used is shown in Fig 1.2. In this configuration DC-AC


inverter and a transformer operated at grid-frequency are used. The transformer is used to
boost the voltage magnitude to a higher level, and provide isolation. Moreover, the DC-AC
inverter controls the injected power into the grid and performs grid synchronization. The
presence of a transformer also leads to a reduction of leakage currents. However, this design
has its disadvantages in the form of losses and increased weight and size of the inverter [8].

1.3.2 Hardware Structure for Grid-connected WT Systems

Fig. 1.3, Main components of the wind generation system

Wind turbines (WT) convert kinetic energy in the wind into mechanical power that
can be converted into electrical energy using a generator. As illustrated in Fig 1.3, the main
components of the wind-turbine system are the turbine blades, gearbox, generator,
transformer, and potential power electronics [6]. In this section, a classification of WT
systems in those using and those not using power electronics as an interface to the utility grid
is given. Hardware structures in each case will be illustrated to distinguish the systems [5].

[1] WT Systems without Power Electronics: Most of these topologies are based on
squirrel-cage induction generator (SCIG), which is directly connected to the grid. A
soft starter is usually used to reduce the inrush currents during start up. Moreover, a
capacitor bank is necessary to compensate for the reactive power of the machine, as
shown in Fig. 1.4(a).
[2] WT Systems with Power Electronics: By adding power electronics units into the WT
systems, the complexity of the system is increased. In addition, the solution
becomes more expensive. Nevertheless, better control of the input power and grid

6
Chapter 1 Renewable Energy and its Applications

interaction is obtained. For example, maximum power for a large interval of wind
speeds can be extracted while control of both active and reactive powers into the
grid is achieved by power electronics.

The usage of power electronics into WT systems can be further divided into two
categories, namely: 1) system using partial-scale power electronics units and 2) systems
using full-scale power electronics units. A particular structure is to use an induction generator
with a wounded rotor. An extra resistance controlled by power electronics is added in the
rotor, which gives a variable-speed range of 2% to 4%. The power converter for the rotor
resistance control is for low voltage but high currents. In any case, this solution also needs a
soft starter and a reactive power compensator.

Additionally, another solution is to use a medium-scale power converter with a


wounded rotor induction generator, as shown in Fig. 1.4(b). In this case, a power converter
connected to the rotor through slip rings controls the rotor currents. If the generator is
running super-synchronously, the electric power is delivered through both the rotor and
stator. If the generator is running sub-synchronously, the electric power is only delivered into
the rotor from the grid. A speed variation of 60% around synchronous speed may be obtained
using a power converter of 30% of nominal power.

By implementing a full-scale power converter between the generator and the utility
grid, additional technical performances of the WT system can be achieved, with the payback
in losses in the power conversion stage. Normally, as shown in Fig.1.4(c), SCIG is used in
this configuration, but an advantage to eliminate the gearbox can be obtained by using multi-
pole wound-rotor synchronous generator or permanent-magnet synchronous generator, as
depicted in Fig. 1.4(d).

7
Chapter 1 Renewable Energy and its Applications

Fig. 1.4, WT systems using power electronic

(a) Minimum electronics unit. (b) Partial power converter. (c) Full-scale power converter structure with
gearbox. (d) Full-scale power converter structure without gearbox and using Multi-pole synchronous generator.

8
Chapter 1 Renewable Energy and its Applications

The most generalized form of power electronics topology for the wind-energy
application is the back-to-back rectifier/inverter connection, which provides the improved
power flow control as well as increased efficiency. The voltage-fed converter scheme used in
such systems is shown in Fig 1.5. A PWM-based bridge rectifies the variable-frequency
variable-voltage power from the wind generator. The rectifier also supplies the excitation
needs for the induction generator. The inverter topology is identical to that of the rectifier,
and it supplies the generated power at 50 Hz to the utility grid.

Fig. 1.5, Generalized power electronics converter for wind systems

It could be noticed that for interacting with the utility grid, all the structures presented
above use two-level pulse-width-modulation (PWM) voltage-source inverters (VSI). This
technology is the state-of-the-art that used today by all manufacturers of WT systems and PV
systems. The possibility of high switching frequencies combined with a proper control makes
these converters suitable for grid interface in the case of distributed generation, which has a
large contribution to the improvement of generated power quality. Therefore, the next section
presents a discussion on the block diagram of the control structures applied to two-level VSI
PWM driven converters, focusing in this thesis on the grid-side inverter control.

9
Chapter 1 Renewable Energy and its Applications

1.4 Grid-connected Inverter Block Diagram

Fig. 1.6, Block diagram of grid-connected inverter

As mentioned previously, this thesis demonstrates the different issues of


implementing a control algorithm for the grid-connected inverter. The block diagram of the
grid-connected inverter system is shown in Fig. 1.6. The main components of this system are:
• Three-phase PWM inverter, which is used to convert the DC–to-AC.
• Grid Filter, which is used to attenuate the harmonic in the output voltage of inverter.
• The three phase transformer, which is used to boost the voltage magnitude to a higher
level, provide isolation, and prevent DC-current from entering the connected grid.
• Grid side controller, which is used to control the power delivered to the grid, ensure
high quality of the injected power and grid synchronization.

A number of papers, such as [9], [10], [11], are dealing with control of the grid side
inverter, which use a current control loop to regulate the grid current. In other works, the
control of the grid-connected inverter is based on two cascaded loops: an internal current
loop, which regulates the grid current, and an external voltage loop, which is designed for
balancing the power flow in the system [5]. Moreover, control strategies employing an outer
power controller and an inner current control loop are also reported [12]. The next chapter
presents a comprehensive study of the three-phase grid-connected inverter with grid side
controller.

10
Chapter 1 Renewable Energy and its Applications

1.5 Summary

The national energy plan aims to reach 20% of total generated electricity through
renewable energy by the year 2020 including 12% from wind energy, in addition to other
renewable-energy applications such as solar energy and hydro power. In this chapter, a brief
review on the state of the contribution of renewable-energy sources like solar energy, wind
energy, and biomass in the Egypt strategy of energy is presented. In addition, the hardware
topologies of PV systems and wind turbines systems for grid connection are presented.
Finally, the block diagram of the grid-connected inverter, which is the goal of the thesis, is
discussed.

11
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

Chapter 2
The Theory of the Grid-Connected Three-
Phase Inverter
2.1 Introduction

As explained in the last chapter, most of renewable-energy technology produces a DC


power output. An inverter is needed to convert the generated DC power from the renewable-
energy source into useful power that can be directly interconnected with the utility grid, and
can be used for consumer applications. The control of this inverter should be improved in
order to increase the power quality and meet the requirements of grid integration.

This chapter presents a comprehensive study of the three-phase grid-connected


inverter with grid side controller. Initially, the three-phase inverter is discussed. This is
followed by a presentation of the mathematical model for the grid-connected inverter. After
that, the possible current control strategies for the grid-connected inverter are introduced.
Then the PWM techniques for the three-phase inverter are presented. Additionally, the
synchronization algorithms for the grid-connected inverters are addressed. Finally, a
discussion of grid filters topologies for interfacing the inverter with national electricity grid is
provided.

2.2 The Three-Phase Inverter

The inverter is a power electronic-based device that converts the DC input voltage
into a symmetric AC output voltage of desired magnitude and frequency [13]. Inverters can
be broadly classified into two types: single-phase inverters, and three-phase inverters. Single-
phase voltage source inverters (VSIs) cover low-range power applications. This inverter is
out of scope in this thesis. On the other hand, the three-phase VSIs cover medium- to high-
power applications. The main purpose of three-phase inverter is to provide a three-phase
balanced (fundamental) voltage source. As shown in Fig. 2.1, the standard three-phase VSI
topology is a configuration of six transistors and six freewheeling diodes [7].

13
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

Fig. 2.1, Three phase inverter circuit

The switches of any leg of the inverter (S1 and S4, S3 and S6, or S5 and S2) cannot
be switched ON simultaneously because this will cause a short circuit across the DC link
voltage supply. Similarly, in order to avoid undefined states in the VSI, and thus undefined
AC output line voltages, the switches of any leg of the inverter cannot be switched OFF
simultaneously. Two types of control signals can be applied to the transistors: 180º
conduction or 120º conduction. The 180º conduction is preferred method, since it offers
better utilization to the transistors. On the other hand, the 120º conduction is out of scope in
this thesis, since the transistors are less utilized as compared with those of 180º conduction
for the same load condition. In 180 º conduction, each transistor is conduct for 180º. Three
transistors remain ON at any instant of time. The gating signals are shifted from each other
by 60º to obtain three-phase balanced (fundamental) voltages, as shown in Fig. 2.2.

The standard three-phase VSI topology has eight valid switch states are given in
Table 2.1. Of the eight valid states, two of them (states 7 and 8 in Table 2.1) produce zero
AC line voltages. In this case, the AC line currents freewheel through either the upper or the
lower freewheeling diodes. The remaining states (states 1 to 6 in Table 2.1) are producing the
non-zero AC output voltages. In order to generate a given voltage waveform, the inverter
moves from one state to another. Thus, the resulting AC output line voltages consist of
discrete values of voltages those are Udc, 0, and − Udc for the topology shown in Fig. 2.1. The
selection of the states in order to generate the given waveform is done by the modulating
technique that should ensure the use of only the valid states. The gating signals and the

14
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

instantaneous line-to-line voltages are shown in Fig.2.2. Moreover, the line-to-neutral


voltages are shown in Fig 2.3.

State State# uab ubc uca Space vector


S1, S2, and S6 are on and
1 Udc 0 - Udc U1 = 1+j0.577
S4, S5, and S3 are off
S2, S3, and S1 are on and -
2 0 Udc U2 = j1.155
S5, S6, and S4 are off Udc
S3, S4, and S2 are on and -
3 Udc 0 U3 = -1+j0.577
S6, S1, and S5 are off Udc
S4, S5, and S3 are on and -
4 0 Udc U4 = -1-j0.577
S1, S2, and S6 are off Udc
S5, S6, and S4 are on and -
5 0 Udc U5 = -j1.155
S2, S3, and S1 are off Udc
S6, S1, and S5 are on and -
6 Udc 0 U6 = 1-j0.577
S3, S4, and S2 are off Udc
S1, S3, and S5 are on and
7 0 0 0 U7 =0
S4, S6, and S2 are off
S4, S6, and S2 are on and
8 0 0 0 U8 =0
S1, S3, and S5 are off

Table 2.1, switches states of three-phase VSI

15
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

Fig. 2.2, Gating signals and output line-to-line voltages of three-phase VSI

Fig. 2.3, output line-to-neutral voltages of three-phase VSI

16
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

2.3 Mathematical Model of the Grid-Connected Inverter

Fig. 2.4, Model of grid-connected inverter

In this section, the mathematical model for the grid-connected inverter is presented
[11]. As shown in Fig. 2.4, the three-phase grid voltages are represented as follows:
𝑒𝐴 = 𝐸 cos 𝜔𝑡
2𝜋
𝑒𝐵 = 𝐸 cos �𝜔𝑡 − � Equation 2.1
3

2𝜋
𝑒𝐶 = 𝐸 cos �𝜔𝑡 + �
3
where E and ω are the maximum phase voltage and angular frequency of the power source
respectively. The system equation in the stationary (ABC) frame can be represented as
follows:
𝑑𝑖𝐴
⎡ 𝑑𝑡 ⎤ 1 0 0 𝑖𝐴 𝑢𝐴 − 𝑒𝐴
⎢𝑑𝑖𝐵⎥ −R 1 Equation 2.2
⎢ 𝑑𝑡 ⎥ =
L
� 0 1 0� �𝑖𝐵 � + 𝐿 � 𝐵 − 𝑒𝐵 �
𝑢
⎢𝑑𝑖𝐶 ⎥ 0 0 1 𝑖𝐶 𝑢𝐶 − 𝑒𝐶
⎣ 𝑑𝑡 ⎦

where iA, iB and iC are the output currents and uA, uB and uC are the output voltages of the
grid-connected inverter, L is the inductance between the grid-connected inverter and the
grid, R is the resistance between the grid-connected inverter and the grid. As discussed in
Appendix A, Clark transformation can be used to convert the three phase stationary (ABC)
frame into two-phase stationary (αβ) frame as given in Equation 2.3.

17
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

1 1� −1�
𝑒𝛼 2 2 𝑒𝐴 Equation 2.3
�𝑒 � = �
𝛽 0 √3� −√3� � �𝑒𝐵 �
2 2 𝑒𝐶

According to Equation 2.2 and 2.3, the following equation is obtained:

𝑑𝑖𝐴
⎡ 𝑢𝐴 − 𝐿 − 𝑅𝑖𝐴 ⎤
1 1�2 −1� ⎢
2
𝑑𝑡 ⎥
𝑒𝛼 𝑑𝑖𝐵
�𝑒 � = � ⎢
−√3� � 𝑢𝐵 − 𝐿 − 𝑅𝑖𝐵 ⎥
𝛽 0 √3�2 2 ⎢ 𝑑𝑡 ⎥
⎢ 𝑑𝑖𝐶 ⎥
⎣ 𝑢 𝐶 − 𝐿 − 𝑅𝑖𝐶 ⎦
𝑑𝑡

𝑑𝑖𝛼
𝑢𝛼 − 𝐿 − 𝑅𝑖𝛼
𝑑𝑡
=� 𝑑𝑖𝛽 � Equation 2.4
𝑢𝛽 − 𝐿 − 𝑅𝑖𝛽
𝑑𝑡

Moreover, as discussed in Appendix A, Park transformation can be used to transform the


stationary (αβ) into the synchronous (dq) frame as given in Equation 2.5.

𝑒𝑑 cos 𝜔𝑡 sin 𝜔𝑡 𝑒𝛼
�𝑒 � = � �� � Equation 2.5
𝑞 − sin 𝜔𝑡 cos 𝜔𝑡 𝑒𝛽

Using Equation 2.4 and 2.5, the following equation is obtained:

𝑑𝑖𝛼
𝐿
𝑒𝑑 cos 𝜔𝑡 sin 𝜔𝑡 𝑢𝛼 cos 𝜔𝑡 sin 𝜔𝑡 cos 𝜔𝑡 sin 𝜔𝑡 𝑅𝑖𝛼
�𝑒 � = � � �𝑢 � − � � � 𝑑𝑡 � − � �� �
𝑞 − sin 𝜔𝑡 cos 𝜔𝑡 𝛽 − sin 𝜔𝑡 cos 𝜔𝑡 𝑑𝑖𝛽 − sin 𝜔𝑡 cos 𝜔𝑡 𝑅𝑖𝛽
𝐿
𝑑𝑡

𝑢𝑑 cos 𝜔𝑡 sin 𝜔𝑡 𝑑 cos 𝜔𝑡 sin 𝜔𝑡 −1 𝑖𝑑 𝑖𝑑


= �𝑢 � − � � . 𝐿 �� � �𝑖 �� − 𝑅 �𝑖 �
𝑞 − sin 𝜔𝑡 cos 𝜔𝑡 𝑑𝑡 − sin 𝜔𝑡 cos 𝜔𝑡 𝑞 𝑞

𝑢𝑑 𝑑 𝑖𝑑 𝑖𝑑 𝑖𝑞
= �𝑢 � − 𝐿 �𝑖 � − 𝑅 �𝑖 � + 𝜔𝐿 � � Equation 2.6
𝑞 𝑑𝑡 𝑞 𝑞 −𝑖𝑑

where ed and eq are park transformation of the grid voltage. ud and uq are the park
transformation of the inverter output. From Equation 2.6, it can be concluded that Equation
2.7 gives the output voltages of the grid-connected inverter in the synchronous (dq) frame.

18
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

𝑢𝑑 𝑑 𝑖𝑑 𝑖𝑑 −𝑖𝑞 𝑒𝑑
�𝑢 � = 𝐿 �𝑖 � + 𝑅 �𝑖 � + 𝜔𝐿 � � + �𝑒 � Equation 2.7
𝑞 𝑑𝑡 𝑞 𝑞 𝑖𝑑 𝑞

2.4 The Control Theory of the Grid-Side Inverter

In order to control three-phase VSI, there are two control strategies: current control
and voltage control. The voltage-controlled VSI use the phase angle between the inverter
output voltage and the grid voltage to control the power flow. In the current controlled VSI,
the active and reactive components of the current injected into the grid are controlled using
pulse width modulation (PWM) techniques. A current controller is less sensitive to voltage
phase shifts and to distortion in the grid voltage. Moreover, it is faster in response. On the
other hand, the voltage control is sensitive to small phase errors, and large harmonic currents
may occur if the grid voltage is distorted. Consequently, the current control is recommended
in the control of the grid-connected inverter [14].

The current controller of three-phase VSI is an essential part in controlling the grid-
connected inverters. Consequently, the quality of the applied current controller largely
influences the performance of the inverter system. The current controlled PWM (CC-PWM)
converters have the following advantages [15]:

• Control of instantaneous current waveform, high accuracy


• Peak current protection
• Overload rejection
• Extremely good dynamics
• Compensation of effects due to load parameter changes (resistance and reactance)
• Compensation of the semiconductor voltage drop and dead times of the converter
• Compensation of the DC link and AC side voltage changes

The main task of the control scheme in a CC-PWM converter as shown in Fig. 2.5 is
to force the currents in a three-phase AC load to follow the reference signals. By comparing
the command iAc (iBc, iCc) and measured iA (iB, iC) instantaneous values of the phase currents,
the CC generates the switching states SA (SB, SC) for the converter power devices which
decrease the current errors ƐA (ƐB, ƐC). Hence, the current controller implements two tasks:

19
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

error compensation (decreasing ƐA, Ɛ B, ƐC). Moreover, pulse width modulation


(determination of switching states SA, SB, SC).

Fig. 2.5, Basic block diagram of current controlled PWM converter.

The basic requirements and performance criteria of the current controller are [16]:

• No phase and amplitude errors (ideal tracking) over a wide output frequency range
• High dynamic response of the system
• Limited or constant switching frequency to guarantee safe operation of converter
semiconductor power devices
• Low harmonic content
• Good DC-link voltage utilization

Many control mechanisms have been proposed to regulate the inverter output current
that injected into the utility grid. The current control techniques are divided into two main
groups: Controllers with open loop PWM block as shown in Fig. 2.6a and On-off controllers
as shown in Fig. 2.6b [15].
In contrast to the on-off controllers (Fig. 2.6b), schemes with open-loop PWM block
(Fig. 2.6a) have clearly separated current error compensation and voltage modulation parts.
This concept allows us to exploit the advantages of open-loop modulators (sinusoidal PWM,
space vector modulator) such as constant switching frequency, well-defined harmonic
spectrum, optimum switch pattern, and good DC link utilization. In addition, full independent
design of the overall control structure as well as open loop testing of the converter and load
can be easily performed.
20
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

Fig. 2.6, (a) Controller with open-loop PWM block. (b) On-off controller.

As an example of the On-off controllers, the hysteresis current control (HCC) is


widely employed for three-phase PWM VSIs [10]. With HCC, current errors are directly
used to determine the next PWM state of the VSI. The current error compensation and PWM
generation are carried out in the same control unit at the same time, rendering the controller a
good dynamic response, and an inherent current protection. However, HCC has some
disadvantages such as high-current ripples and variable switching frequency, which usually
cause a reduction in current quality and introduces difficulties in output filter design.

Among the previously developed controllers with open loop PWM block,
proportional-integral (PI) regulation and predictive control are two dominant algorithms for
current error compensation. Current control strategies based on PWM are widely employed.
A PWM-based current controller separates current error compensation and PWM functions,
making it possible to exploit the advantages of PWM as well as design the overall control
structure independently. The PWM algorithms are discussed in details in section 2.5.

However, with the development of faster and more powerful microprocessors, the
implementation of new and more complex control schemes is possible. Some of these new
control schemes for power inverters include fuzzy logic and sliding mode control [15]. Fuzzy
logic is suitable for applications where the controlled system or some of its parameters are
unknown. Sliding mode present robustness and takes into account the switching nature of the
power converters. Other control schemes found in the literature include neural networks,

21
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

neuro–fuzzy and other advanced control techniques. However, these control algorithms is out
of scope in these thesis.
In following sections, three current control strategies, namely: hysteresis current
controller, predictive current controller, and linear proportional-integral (PI) controller are
studied for the application of the three-phase grid-connected PWM VSI.

2.4.1 Hysteresis Current Controller

A basic hysteresis current control is developed and implemented for the application of
the grid-connected inverter, as shown in Fig. 2.7. Three-phase output currents of the inverter
are detected and compared with the corresponding phase current references individually. The
resulting three current errors are used directly to generate the PWM signals for the power
switches through hysteresis comparators. HCC generates the desired PWM signals for the
next control cycle to maintain the current trajectories within the hysteresis bands [10], [16].

Fig. 2.7, Block diagram of HCC strategy for a three-phase grid-connected PWM VSI.

Clearly, HCC is simple for implementation and insensitive to system parameters.


Moreover, its dynamic response is extremely fast; actually, it is the fastest possible for any
VSI with given dc link voltage and output inductance. The basic reason for this is that the
hysteresis controller does not require any modulator. The state of the converter switches is
determined directly by comparing the instantaneous converter current with its reference.

22
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

However, the HCC has some drawbacks such as variable switching frequency and
high current ripples. This causes a poor current quality and introduces difficulties in the
output filter design. Moreover, in the VSI applications like grid connection, the injection of a
variable frequency noise into the utility grid is not recommended, because unpredictable
resonances with other connected loads could be triggered [17].

2.4.2 Predictive Current Controller

The main characteristic of predictive control is the use of the model of the system for
the prediction of the future behavior of the controlled variables. The controller uses this
information in order to obtain the optimal actuation, according to a predefined optimization
criterion [18]. A well-known type of predictive controller is the deadbeat controller. This
approach uses the model of the system to calculate, once every sampling period, the required
reference voltage in order to reach the reference value in the next sampling instant. That
means the optimal actuation is the one that makes the error equal to zero in the next sampling
instant. Then, this voltage is applied using a modulator.

The predictive controller is capable of achieving a very fast dynamic response, the
best among digital current controllers and clearly superior to that achievable by any other
linear controller. However, the stability and robustness of the predictive current control are
mainly affected by parameter variation. The current delivered by grid-connected inverters
passes through a filter inductor and possibly a coupling transformer. Interfacing parameters,
such as the equivalent inductance and resistance of the coupling transformer, filter inductors,
and connection cables, are frequency dependent. Moreover, these parameters vary with
temperature, core saturation, cables overload, and other environmental conditions. This leads
to parameter sensitivity problems.

2.4.3 Linear PI Current Controller

Proportional-integral (PI) controller is the most common control algorithm used for
current error compensation. A PI controller calculates an error value as the difference
between a measured inverter output current and a desired injected current to the grid, then the
controller attempts to minimize the error between them. The PI controller calculation

23
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

algorithm involves two separate constant parameters, the proportional, the integral values,
denoted Kp and Ki.

The proportional term Kp (sometimes called gain) of the controller is formed by


multiplying the error signal by a Kp gain. This will cause the PI controller to produce a
control response that is a function of the error magnitude. As the error signal becomes larger,
the Kp term of the controller becomes larger to provide more correction.

The effect of the Kp term will tend to reduce the overall error with time. However,
the effect of the Kp term will reduce as the error approaches zero. In most systems, the error
of the controlled parameter will get very close to zero, but will not converge. The result is a
small remaining steady-state error. The Integral term of the controller is used to fix small
steady-state errors. The Integral term integrates the error. Therefore, a small steady-state
error will accumulate into a large error value over time. This accumulated error signal
(integrating the error) is multiplied by a Ki gain factor and becomes the integral output term
of the PI controller. The integral term (when added to the proportional term) accelerates the
movement of the process towards set point and eliminates the residual steady-state error that
occurs with a proportional only controller.

The PI current control offers an excellent steady-state response, low current ripple,
constant switching frequency, and well-defined harmonic content. Moreover, the controller is
insensitive to system parameters since the algorithm does not need system models [10]. PI
controllers can be applied either in the stationary (αβ) or in the synchronous (dq) reference
frame. When the synchronous PI controller is used, the control variables become DC, and the
PI compensators are able to reduce the stationary error of the fundamental component to
zero. This is not the case with PI controllers working in the stationary system, where there is
an inherent tracking error of phase and amplitude. Therefore, current control in a
synchronous (rotating) reference frame, using PI controllers is the typical solution in the
three‐phase grid connected inverters [16].

According to the mathematical model of the grid-connected inverter section 2.3, the
output voltages of the inverter in the synchronous (dq) frame are given by Equation 2.7.

24
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

𝑢𝑑 𝑑 𝑖𝑑 𝑖𝑑 −𝑖𝑞 𝑒𝑑
�𝑢 � = 𝐿 �𝑖 � + 𝑅 �𝑖 � + 𝜔𝐿 � � + �𝑒 �
𝑞 𝑑𝑡 𝑞 𝑞 𝑖𝑑 𝑞

Where ed and eq is park transformation of the grid voltage. ud and uq is the park
transformation of the inverter output. ω is the angular frequency of the grid. L is the
inductance between the grid-connected inverter and the grid. R is the resistance between the
grid-connected inverter and the grid. By rearrange the equation, it can be found that:

𝑑𝑖𝑑
𝐿 + 𝑅𝑖𝑑 = 𝑢𝑑 − 𝑒𝑑 + 𝜔𝐿𝑖𝑞
𝑑𝑡
� 𝑑𝑖𝑞
Equation 2.8
𝐿 + 𝑅𝑖𝑞 = 𝑢𝑞 − 𝑒𝑞 − 𝜔𝐿𝑖𝑑
𝑑𝑡

Assuming

𝑢�𝑑 = 𝑢𝑑 − 𝑒𝑑 + 𝜔𝐿𝑖𝑞
� Equation 2.9
𝑢�𝑞 = 𝑢𝑞 − 𝑒𝑞 − 𝜔𝐿𝑖𝑑

Using Equation 2.8 and 2.9, we obtain

𝑑𝑖𝑑
𝑢�𝑑 = 𝐿 + 𝑅𝑖𝑑
𝑑𝑡
� 𝑑𝑖𝑞 Equation 2.10
𝑢�𝑞 = 𝐿 + 𝑅𝑖𝑞
𝑑𝑡

In order to make the output currents track the reference current, the PI-type current
controllers can be utilized. In this case, the output voltages of the current controllers are as
follows:

𝑢�𝑑 = 𝑘𝑝 (𝑖𝑑∗ − 𝑖𝑑 ) + 𝑘𝑖 ∫(𝑖𝑑∗ − 𝑖𝑑 ) 𝑑𝑡 Equation 2.11



𝑢�𝑞 = 𝑘𝑝 �𝑖𝑞∗ − 𝑖𝑞 � + 𝑘𝑖 ∫�𝑖𝑞∗ − 𝑖𝑞 � 𝑑𝑡

The d-axis reference voltage and q-axis reference voltage are expressed as follows:

𝑢𝑑∗ = 𝑒𝑑 − 𝜔𝐿𝑖𝑞 + 𝑢�𝑑 Equation 2.12



𝑢𝑞∗ = 𝑒𝑞 + 𝜔𝐿𝑖𝑑 + 𝑢�𝑞

25
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

Fig. 2.8, General structure for synchronous reference frame control structure [9].

According to Equation 2.12, the block diagram of the synchronous controller for the
grid-connected inverter can be represented as shown in Fig.2.8. The figure shows that the
inverter has two PI controllers to compensate the current vector components that defined in
the synchronous reference frame (dq). Because of coordinate transformations, iq and id are
DC components and therefore, PI compensators reduce the error(s) between the desired
current I*d (I*q) and the actual current Id (Iq) to zero. The output energy and power factor can
be controlled via changing d-axis current and q-axis current. For improving the performance
of PI controller in such a structure, cross-coupling terms and voltage feed forward are usually
used [11], [9].

2.4.4 Comparison Between the Three Current Controllers

The explanation of the three most common current control strategies namely:
hysteresis current controller, predictive controller, and linear PI controller have been
presented in the last subsections. In this subsection, the advantages and disadvantages of each

26
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

current control strategy are presented in the application of grid-connected inverters.


Moreover, a comparison between the three current controllers has been provided.
The hysteresis current controller is attractive for its highly simplicity, robustness,
extremely fast dynamic response, and inherent over-current protection. However, high-
current ripple and variable switching frequency are the drawbacks of the hysteresis current
controller, which limit its applications in grid-connected VSIs. The predictive current
controller has a very good steady-state performance, and it provides a good dynamic
performance. However, its performance is sensitive to system parameters, especially to the
output filter inductance L that may vary due to its nonlinearity. The linear PI current control
offers an excellent steady-state response with zero steady-state error, low current ripple, and
highly sinusoidal waveform. Moreover, the controller is insensitive to system parameters
since the algorithm does not need system models. Its dynamic response is inferior to those of
the hysteresis current controller.

As shown in Table 2.3, the advantages and disadvantages of the three current
controllers are summarized. Consequently, according to the advantages of the linear PI
control algorithm, it concluded that this control algorithm is the best choice to implement the
grid-connected inverter.

Hysteresis current Predictive current Linear PI current


Parameter
controller controller controller
High THD
Very low THD
Steady State high current ripple and
Low THD Even with high
response variable switching
distorted grid
frequency
Sensitivity to
Sensitive to system
system None None
parameters
parameters
Dynamic Slightly inferior than
Very fast Very fast
response others

Table 2.2, Comparison between the three current controllers

27
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

2.5 Pulse Width Modulation Techniques

After calculating the reference voltages U*a, U*b and U*c by the current regulation
algorithm, the gating pulses for individual inverter switches is generated using the PWM
algorithm. Then the desired inverter voltage is generated.
PWM techniques have been the subject of intensive research during the last few
decades. A large variety of methods, different in concept and performance, have been newly
developed and described. Their implementation is depended on the machine type, the power
level, and the semiconductor devices used in the power converter. It is lastly performance
and the cost, which determine the choice of a PWM method in a specific application.
Historically, the best-known PWM technique is triangular carrier-based sinusoidal PWM.
However, with microprocessor development, the space vector modulation (SVM) becomes a
basic power processing technique in three-phase PWM converters [13]. In the following two
subsections, the sinusoidal PWM and SVM are discussed in details. Then, a comparison
between them is presented.

2.5.1 Sinusoidal PWM

The sinusoidal pulse width modulation (SPWM) is the most widely used method of
pulse width modulation. As shown in Fig. 2.9, the SPWM algorithm is consisted of three
sinusoidal reference signals UAc, UBc, UCc each shifted by 120◦ from each other. The three
reference signals are compared with high frequency triangular carrier signal Ut, which is
common to all three phases. In this way, the logical signals SA, SB, and SC are generated,
which define the switching instants of the power transistors [7], [13]. The generation of
gating signals, line-to-line output voltages, and line-to-neutral output voltages are shown in
Fig. 2.10.
The control parameter that used to control the amplitude of the output voltage is the
modulation index (m). The modulation index is defined as the ratio between the peak
magnitudes of the modulating waveform and the carrier waveform. The modulation index m
can be varied between 0 and 1 to give a linear relation between the reference and output
√3𝑈𝐷𝐶
wave. The maximum amplitude of the fundamental ac output line voltage is . Therefore,
2

one can write

28
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

√3
𝑢
� 𝑎𝑏1 = 𝑚𝑈𝑑𝑐 ; 0 < 𝑚 ≤ 1
2
Equation 2.13

Fig. 2.9, Block scheme of carrier based sinusoidal PWM

Fig. 2.10, Basic waveforms of carrier based sinusoidal PWM

29
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

2.5.2 Space Vector Modulation

As mentioned in last subsection, conventional sinusoidal PWM essentially compares


low-frequency three sinusoidal reference signals with high frequency triangular or saw-tooth
carrier to generate firing pulses for turning controlled switches ON and OFF. However, with
microprocessor development, the space vector modulation (SVM) becomes popular and
possibly the best PWM technique in three-phase PWM inverter. SVM has many advantages
such as constant switching frequency, well-defined output harmonic spectrum, optimum
switching patterns, and excellent dc-link voltage utilization [11], [19], [20].

SVM treats the three-phase inverter as a single unit. Specifically, in case of the two-
level inverter as shown in Fig.2.1, there are eight possible unique states, each of which
determines a voltage space vector. As shown in Fig.2.11, six voltage space vectors shape the
axis of hexagonal and divide the whole space into six sectors from 1 to 6. Moreover, there
are two zero vectors, U0 and U7 lies at the origin. The angle between any two adjacent non-
zero vectors is 60°. Space vectors and voltages corresponding to each state are shown in
Table 2.1. Therefore, SVM is a digital modulating technique where the objective is to find an
appropriate combination of active and zero vectors to approximate a given reference voltage.

Fig. 2.11, Six active vectors and two null vectors in SVM.

30
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

In SVM, the three phase reference frame voltages U*a, U*b, and U*c are mapped to the
complex two-phase orthogonal α-β plane. This is known as the Clark’s transformation and
explained in details in Appendix A.

1 − 1�2 − 1�2 Ua∗


𝑈𝛼
�𝑈 � = � √3� � �Ub∗ � Equation 2.14
𝛽 0 2 − √3�2
Uc∗

The signal flow in space vector modulator is shown in Fig. 2.12.

Fig. 2.12, Block scheme of the space vector modulator

Fig. 2.13, Output pulses based on Symmetrical Sequence algorithm in sector

The construction of any space vector Uref lie in the hexagon can be done by time
averaging the adjacent two active space vectors and any zero vectors, as follows.

31
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

𝑢𝑛 ∗𝑇1 +𝑢𝑛+1 ∗𝑇2 +𝑢0 ∗𝑇0 +𝑢7 ∗𝑇7


𝑈𝑟𝑒𝑓 = Equation 2.15
𝑇𝑠

Where Un and Un+1 are the non-zero adjacent active vectors. U0 and U7 are the zero vectors.
T1, T2, T0, and T7 are time-shares of respective voltage vectors. Ts is the sampling period.
SVM can be implemented through the following steps [21]:

1. The computation of reference voltage and angle (𝛉)

Uref = �Uα2 + Uβ2 Equation 2.16

𝑈𝛽
θ = tan−1 Equation 2.17
𝑈𝛼

2. Identification of the sector number that is done by taking the angle computed from the
last step, and then comparing it with angles range of each sector
3. Calculate the modulation index (𝑚) and the time duration T1, T2, T0, T7

𝑈𝑟𝑒𝑓
𝑚= 𝑈𝐷𝐶� Equation 2.18
2

𝑇𝑠 𝑚 sin(𝜋�3 − θ) ;
√3
𝑇1 = Equation 2.19
2

√3
𝑇2 = 𝑇𝑠 𝑚 sin(θ) ; Equation 2.21
2

Equation 2.20
𝑇0 + 𝑇7 = 𝑇𝑠 − 𝑇1 − 𝑇2

4. After T1, T2, T7, and T0 are calculated; the SVM pulses can be generated. The
arrangement of switching sequence must ensure minimum transition between one
vector and the next. This method reduces the switching frequency and has fewer
harmonic. For the first sector, one can use 01277210 for symmetry reasons as shown
in Fig.2.13

To maintain three-phase and half-wave symmetry output voltage, the samples


should be evenly distributed in each sector. Furthermore, the sequences used for each
sample should be identical with corresponding positions within each sector. The number
of samples used in each sector should be an integer number. Defining Fsn as

32
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

𝐹𝑠
𝐹𝑠𝑛 = Equation 2.23
𝑓

𝐹𝑠 = 6𝑁 Equation 2.22

Fs is the sampling frequency and f is fundamental frequency of the waveform to be


reconstructed (or equivalently Uref), it should be an integer multiple of six. N is the number of
samples in a sector [20]. In SVM, the maximum fundamental line-voltage amplitude is unity
as 0 ≤ θ ≤ π/3. This is an advantage over the SPWM technique, which achieves a √3/2
maximum fundamental line-voltage amplitude in the linear operating region [7].

2.5.3 Comparison Between SPWM and SVM

As mentioned previously, in the SPWM method, three reference signals are compared
with triangular carrier signal, then gate signals are generated. In the SVM, time duration of
active (T1, T2) and zero (T0, T7) vectors are calculated, and from these times switching
signals are obtained.

The SPWM can be implemented by hardware or software methods [22]. In the


hardware method, a simple comparator between reference signals and triangular carrier
signal is used. Then gate pulses are generated. In the software method, a programmable
device like microprocessor/controller is usually used to perform SPWM algorithm. The
SPWM implementation is considered easy for either hardware or software implementation
methods. Nevertheless, this algorithm has the following drawbacks:

• The Sine PWM algorithm is unable to utilize the available DC bus supply voltage
(UDC) to the VSI. The generated line-to-line voltage is less than 90% of UDC in the
linear operating region
• This algorithm gives more Total Harmonic Distortion (THD)
• Often, to reduce run-time processing load for slow controllers, three 120° phase-
shifted sine tables are created in the controller memory. This is an inefficient usage of
the controller memory
• There is no degree of freedom in implementation

33
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

On the other hand, SVM is more sophisticated, and it offers more voltage output
(approximately 15% more) if compared to SPWM, and thus DC voltage utilization is
increased by using SVM. In terms of THD, losses such as switching, and commutation
losses, SVM has an advantage over SPWM as SVM minimizes both aspects that tend to
haunt the SPWM technique. Advantages and strength of SVM over SPWM are paving the
way towards wider usage of SVM in AC motor control and AC power generation [20]. Table
2.2 compares both SVM and SPWM techniques in a simple manner.

SPWM SVM
Comparing high frequency triangular The duration of each switch state is
carrier signal with three sinusoidal explicitly calculated (as can be seen in
reference signals (treated as separate computations involved for determination
identity). of ON times of space vectors).
SPWM is unable to utilize the available Increase utilization of DC supply voltage,
DC supply voltage. 15% more than SPWM.
SPWM causes more Total Harmonic SVM causes less Total Harmonic
Distortion. Distortion.
SPWM does not facilitate more advanced SVM enable more advanced vector
vector control implementation. control implementation.

Table 2.3, Comparison between SPWM and SVM

2.6 Grid Synchronization

The inverter output current that injected into the utility network must be synchronized
with the grid voltage. The synchronization algorithm objective is to extract the phase angle of
the grid voltage. The feedback variables can be converted into a suitable reference frame
using the extracted grid angle. Hence, the detection of the grid angle has an essential role in
control of the grid-connected inverter [5], [9]. The synchronization algorithms should
respond quickly to changes in the utility grid. Moreover, it should have the ability to reject
noise and the higher-order harmonics.

34
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

Many synchronization algorithms have been proposed to extract the phase angle of
the grid voltage such as the zero crossing detection, the Filtering of grid voltages, and phase-
locked loop (PLL) technique [23].

2.6.1 Zero Crossing Detection

The simplest synchronization algorithm is the zero crossing detection. Owing to the
fact that grid voltage is sinusoidal, the maximum number of zero crossings in a period is
three. By detecting the zero crossing points, the phase and frequency information of the grid
voltage can be obtained. However, this method has many disadvantages such as low
dynamics, since the phase tracking action is impossible between the detecting points. In
addition, it is affected by noise and higher-order harmonics in the utility grid. Therefore, this
method is unsuitable for applications that required continuous accurate phase angle detection.

2.6.2 Filtering of Grid Voltages

Filtering of grid voltages is another solution for detecting the phase angle of grid
voltage. In this method, the grid voltage is transformed into a Cartesian coordinate system
such as stationary αβ or synchronous rotating dq system as shown in Fig. 2.14 and Fig. 2.15
respectively. Then the arctangent function is used to obtain the phase angle of the utility
voltage.
This method has been used in drive applications, for transforming feedback variables
to a reference frame suitable for control purposes. However, when used in conjunction with
grid-connected power converters, additional filtering is necessary in order to obtain a clean
synchronization signal in situation when distortions are present in the voltage waveform.

Fig. 2.14, Synchronization method using filtering on the synchronous frame.

35
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

Fig. 2.15, Synchronization method using filtering on the stationary frame.

However, this method has the drawback that requires additional filtering in order to
obtain an accurate detection of the phase angle and frequency in the case of a distorted grid
voltage. Nevertheless, the usage of filters introduces a delay in the phase angle calculation.
Therefore, this technique is not suitable for grid-connected inverter applications.

2.6.3 Phase-Locked Loop (PLL)

Phase-locked loop (PLL) is a phase tracking algorithm widely applied in


communication technology, being able to provide an output signal synchronized with its
reference input in both frequency and phase. Nowadays, the most common synchronization
algorithm for extracting the phase angle of the grid voltages is the PLL. The PLL can
successfully detect the phase angle of the grid voltage even when the noise or higher-order
harmonics in the grid voltage exist. PLL schematic is illustrated in Fig. 2.16.

Fig. 2.16, Basic structure of a PLL system for grid synchronization.

36
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

As shown in Fig.2.16, the PLL is implemented in synchronous (dq) reference frame.


eabc is the sensed grid voltage which is then transformed into DC components using park
transformation abc-dq. The PLL is locked by setting e*d to zero, which acts as a phase
detector. A controller, usually PI, is used to control this variable, which brings the phase
error to zero and acts as a loop filter. The ωff represents the utility nominal frequency that is
added to the output of the regulator then outputted as the grid frequency. After the loop filter,
whose output is the grid frequency, a voltage-controlled oscillator (VCO) is applied. This is
usually an integrator, which gives the phase locked angle of the grid θ as output. This
algorithm has a better rejection of grid harmonics, notches, and any other kind of
disturbances [24].

2.7 Grid Filter

The connection of an inverter to the utility grid is typically done using a filter [25].
Harmonics in the output voltage of the inverter are usually attenuated by connecting a filter
between the VSI and the grid in order to cope with the power quality requirements of the
utility. The most common filters used for this purpose are reviewed in this section. Three
types of grid filter are addressed namely L-filter, LC-filter and LCL-filter [26].

Fig. 2.17, Filter configuration circuits

2.7.1 L‐Filter

The degree of which the harmonic content is attenuated depends on the filter used. A
first-order filter consisting of one inductor in series with the mains is the most commonly

37
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

used filter as shown in fig. 2.17(a). This is because the filter is easy to make, and it has no
resonance problems as higher-order filters may have. Attenuation of the basic inductor filter
is –20 dB/decade over the whole frequency range. Using this filter, the inverter switching
frequency has to be high in order to attenuate the inverter harmonics sufficiently.

The major drawback of this filter is the size of the inductor needed to achieve a
reasonable attenuation of the current harmonics. Consequently, in order to obtain a good
damping, a large filter (that can be bulky and expensive) is needed.

2.7.2 LC-Filter

Higher order filters consisting of combinations of inductors and capacitors, can give a
better attenuation of the harmonics, but they also make the design more complex. The LC-
filter in Fig 2.17 (b) is a second-order filter giving –40 dB/decade attenuation. Since the
previous L-filter achieves low attenuation of the inverter switching components, a shunt
element is needed to further attenuate the switching frequency components. In grid-
connected systems, the LC filter is seldom used, since the resonance frequency of the filter
will vary with the inductance value of the grid.

2.7.3 LCL-Filter

The third filter common in the literature is the LCL filter configuration shown in Fig.
2.17 (c). It produces better attenuation of inverter switching harmonics than the L and LC
filters. The key advantages of the LCL-filters are [27]:

• Low grid current distortion and reactive power production


• Attenuation of -60 dB/decade for frequencies in excess of the resonance frequency
• Possibility of using a relatively low switching frequency for a given harmonic
attenuation
• The resonance frequency is mostly depending on the filter components

The LCL filter provides good performances with a lower costs. This is the main
reason why this filter is chosen for this application.

38
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter

2.8 Summary

This chapter presents a comprehensive study of the three-phase grid-connected


inverters. Initially, the basic construction of the three-phase inverter is introduced in section
2.2. After that, the mathematical model of the grid-connected inverter is presented in Section
2.3. The closed loop current control techniques are studied in section 2.4, namely: hysteresis
current controller, predictive controller, and linear PI controller. Then their performances are
compared. It is found that the linear PI controller is more suitable for the grid-connected
inverter application, since it offers an excellent steady-state response with zero steady-state
error, low current ripple, and highly sinusoidal waveform to the grid-connected inverter. In
addition, the controller is insensitive to system parameters since the algorithm does not need
system models.

After that, the most common PWM techniques have been addressed, and then the
SPWM and SVM along with a comparison between them are discussed in section 2.5. The
SVM is chosen for the grid-connected inverter application because SVM has many
advantages such as constant switching frequency, well-defined output harmonic spectrum,
optimum switching patterns, and excellent dc-link voltage utilization.

In section 2.6, the importance of the synchronization, for control purposes, for the
grid-connected inverter is presented. In addition, it is reported that several synchronization
algorithms are capable of detecting the phase angle of the grid voltage, namely: zero crossing
detection, filtering of grid voltages, and PLL technique. It is concluded that the PLL is the
best choice for the grid-connected inverter application. This is because the PLL can
successfully detect the phase angle of the grid voltage even when noise or higher-order
harmonics exist in the grid voltage.

Finally, the grid filter that used in the connection of an inverter to the utility grid is
introduced in section 2.7. Three types of grid filter are addressed, namely: L-filter, LC-filter,
and LCL-filter. The LCL-filter is chosen for the grid-connected inverter application, since it
is effective in the reduction of switching frequency harmonics of the power inverter. In
addition, it reduces the dependence of the filter on the grid parameters.

39
Chapter 3 System Simulation

Chapter 3
System Simulation
3.1 Introduction

In this chapter, the stand-alone and the grid-connected inverter system are modeled
based on the theoretical basics presented in the previous chapter. The system is then
simulated to verify the effectiveness of its control structure and to determine its performance
parameters using PSIM 1 simulation package. PSIM is simulation software specifically
designed for power electronics and motor drives. With fast simulation and friendly user
interface, PSIM provides a powerful simulation environment for power electronics, analog
and digital control, magnetic, renewable-energy, and motor drive system studies [28].

This chapter is divided into three major parts: Firstly, the stand-alone three-phase
inverter is modeled and simulated. Secondly, the SVM algorithm for three-phase inverter is
developed. Finally, a model for the grid-connected three-phase inverter is constructed, and
the parasitic elements of the constituting power components are taken into consideration.
This simulation model includes the current controller, SVM, grid-filter, and PLL.

3.2 Simulation of the Stand-Alone Three-Phase Inverter

The simulation model of the stand-alone three-phase inverter is shown in Fig. 3.1.
This simulation model consists of six MOSFET transistors and six freewheeling diodes.
Additionally, three 1KΩ load resistors are connected in the star form, and the inverter input
is 12V DC source that represents the output power from the renewable-energy source.

In case of 180º conduction, each transistor conducts for 180º. Three transistors remain
ON at any instant of time as described previously in chapter 2. In order to obtain three-phase
balanced (fundamental) voltages, six gating pulses that are shifted from each other by 60º
must be used, as shown in Fig. 3.2. The gating signals are generated by three- square wave

1
PSIM is a registered trademark of, and is copyrighted by, Powersim Inc., 2001-2010

41
Chapter 3 System Simulation

voltage sources with Vpeak-peak=1V and frequency= 50HZ. A 60º phase delay is inserted
between them to provide the required phase shift.

Fig. 3.1, Simulation circuit of stand-alone three phase inverter

Fig. 3.2, Simulation of the gating signals of the stand-alone three-phase inverter

42
Chapter 3 System Simulation

The line-to-neutral voltages are shown in Fig 3.3. Moreover, the line-to-line voltages
are shown in Fig.3.3. Consequently, the simulation results validate the theoretical studies that
have been done in chapter 2.

Fig. 3.3, Simulation waveforms of line-to-neutral voltage of the stand-alone three-phase inverter

Fig. 3.4, Simulation waveforms of line-to-line voltage of the stand-alone three-phase inverter

43
Chapter 3 System Simulation

3.3 Simulation of SVM

As described in chapter 2, the space vector PWM (SVM) is an alternative method


used to control three-phase inverters. In this method, the PWM duty cycles are computed
rather than derived through hardware comparison like SPWM. The SVM has many
advantages such as constant switching frequency, well-defined output harmonic spectrum,
optimum switching patterns, and excellent dc-link voltage utilization.

Fig. 3.5, Simulation circuit of the three-phase inverter with SVM.

As shown in Fig. 3.5, the model contains a three-phase sinusoidal voltages source
work as reference signal and SVM sub-circuit which contain the SVM algorithm. Moreover,
it consists of three-phase inverter with six MOSFET transistors and six freewheeling diodes.
In addition to three 1KΩ load resistors are connected in the star form, and the inverter input
is 12V DC source that represents the output power from the renewable-energy source. The
SVM sub-circuit can be implemented through the following steps:

 Step 1, Computation of Uα, Uβ, Uref, and angle (θ)


 Step 2, Determine the sector of reference signal
 Step 3, Determine time duration T1, T2, T0, and T7
 Step 4, Determine the switching time of each transistor (sw1 to sw6)

44
Chapter 3 System Simulation

Each one of these steps is explained and its corresponding output waveforms are showed in
the following subsections.

3.3.1 Step 1, Computation of Uα, Uβ, Uref, and angle (θ)

The first step in SVM algorithm is to compute Uα and Uβ. That done with simple
Clark's transformation as explained in appendix A. Then the Uref is calculated by a square
root of the sum of (Uα)2 and (Uβ)2. The angle (θ) is computed by use of arctangent function.
The simulation circuit that doing this calculation is shown in Fig 3.6. Moreover, the
waveforms of the input reference signals are shown in Fig. 3.7(a). In addition, the simulation
waveforms of the Uα and Uβ are shown in Fig 3.7(b). Additionally, the waveform of the angle
(θ) is shown in Fig 3.8.

Fig. 3.6, Simulation circuit for Determination Vα, Vβ, Vref, and angle (ϑ)

45
Chapter 3 System Simulation

Fig. 3.7, (a) Simulation waveforms of input reference signals. (b) Simulation waveforms of the Uα and Uβ.

Fig. 3.8, Simulation waveform of angle (θ)

46
Chapter 3 System Simulation

3.3.2 Step 2. Sector Determination

The second step in SVM algorithm is to determine the sector of reference signal. That
is done by take the angles computed from last step, and then compare it with angles range of
each sector by using six comparators. The output of each comparator is high (value= 1) when
the non-inverting input is higher than the inverting input. When the positive input is lower,
the output is zero. The circuit of simulation is shown in Fig. 3.9. Moreover, the output of this
circuit is shown in Fig 3.10.

Fig. 3.9, Simulation circuit of sector determination

Fig. 3.10, Simulation waveform of sector allocation

47
Chapter 3 System Simulation

3.3.3 Step 3. Calculation of Time Duration T1, T2, T0, and T7

The third step in SVM algorithm is to calculate the time duration T1, T2, T0, and T7.
As explained in chapter 2 the time duration is calculated by a set of equations that are a
function of sampling Time (Ts), modulation index (𝑚) and angle (θ). The simulation circuit
of time interval calculation is shown in Fig.3.11.

Fig. 3.11, Simulation circuit of time interval calculation

3.3.4 Step 4. Switching Time Determination of Each Transistor (sw1 to sw6).

The fourth and final step is to determine the switching time for each transistor (sw1 to
sw6). The switching state of each transistor is shown in table 3.1. The simulation circuit that
performs this function is shown in Fig. 3.12. The circuit contains six monostable
multivibrator with adjustable width allows the pulse width to be specified externally. Each
pulse with specified width that calculated from previous step is marked by unique amplitude.
Then six two-dimensional lookup tables used to output the switching pulse for each
transistor. The SVM switching patterns at each sector is shown in Fig. 3.13.

48
Chapter 3 System Simulation

Sector Upper switches Lower switches


(Sw1, Sw3, Sw5) (Sw4, Sw6, Sw2)
1 Sw1=T1+T2+T0/2 Sw4 =T0/2
Sw3=T2+T0/2 Sw6=T1+T0/2
Sw5=T0/2 Sw2=T1+T2+T0/2
2 Sw1=T1+T0/2 Sw4 =T2+T0/2
Sw3=T1+T2+T0/2 Sw6=T0/2
Sw5=T0/2 Sw2=T1+T2+T0/2
3 Sw1=T0/2 Sw4 =T1+T2+T0/2
Sw3=T1+T2+T0/2 Sw6=T0/2
Sw5=T2+T0/2 Sw2=T1+T0/2
4 Sw1 =T0/2 Sw4 =T1+T2+T0/2
Sw3=T1+T0/2 Sw6=T2+T0/2
Sw5=T1+T2+T0/2 Sw2=T0/2
5 Sw1=T2+T0/2 Sw4 =T1+T0/2
Sw3=T0/2 Sw6=T1+T2+T0/2
Sw5=T1+T2+T0/2 Sw2=T0/2
6 Sw1=T1+T2+T0/2 Sw4 =T0/2
Sw3=T0/2 Sw6=T1+T2+T0/2
Sw5=T1+T0/2 Sw2=T2+T0/2

Table 3.1, Switching Time Calculation at Each Sector

Fig. 3.12, Simulation circuit for transistors switching time calculation

49
Chapter 3 System Simulation

Fig. 3.13, SVM switching patterns at each sector.

50
Chapter 3

51
System Simulation

Fig. 3.14, The overall simulation circuit of SVM algorithm


Chapter 3 System Simulation

At the end, the overall simulation circuit of SVM algorithm is shown in Fig 3.14. The
gating signals for sector 1 on the upper switches sw1, sw3, and sw5 are shown in Fig. 3.15.
The simulation output phase-to-neutral voltages of the three-phase inverter are shown in Fig
3.16. In addition, the simulation output of phase-to-phase voltages are shown in Fig 3.17.

Fig. 3.15, The gating signals for sector 1.

Fig. 3.16, The simulation output phase-to-neutral voltage of three-phase inverter with SVM

52
Chapter 3 System Simulation

Fig. 3.17, The simulation output of phase-to-phase voltages of three-phase inverter with SVM

3.4 Simulation of Grid-Connected Three-Phase Inverter

In this section, the grid-connected inverter system is modeled based on the theoretical
basics presented in chapter 2. The system is then simulated to verify the effectiveness of its
control structure and to determine its performance parameters.
As shown in Fig. 3.18, the inverter input is 24V DC source that represents the output
power from renewable-energy source. In addition, there is a Three-phase inverter with six
MOSFET transistors and six freewheeling diodes. Every transistor has an on-resistance of
0.55-Ohm. The connection of an inverter to the utility grid is typically done using a grid
filter. The objective of the grid filter is to attenuate harmonics in the output voltage of the
inverter.
In the simulation model, an LC-filter is utilized as that used in the practical circuit to
be able to compare the simulation results with the experimental ones. So, 5mH inductors with
an internal resistance of 0.172-Ohm resistance and 10uF capacitors are used as an LC-filter
in order to achieve the desired voltage and current ripple characteristics.
A three-phase step-up transformer is used to achieve isolation, DC decoupling and
step-up voltage to 220V phase-to-neutral for grid connection. Moreover, three current
sensors and three voltage sensors are used to sense the injected current to the grid and grid

53
Chapter 3 System Simulation

voltage respectively. Finally, to emulate the utility grid a three-phase 220V, 50Hz AC source
is used.

Fig. 3.18, Simulation model of the grid-connected inverter

3.4.1 Simulation of PLL Synchronization Circuit

As described in chapter 2, the PLL circuit is the best-known synchronization algorithm.


The PLL simulation model is shown in Fig.3.18 as a part of the simulation model of the grid-
connected inverter. The simulation results of PLL as shown in Fig. 3.19 through Fig. 3.21 show
that the PLL can successfully extract, without errors, the phase angle of the grid voltages, which
allows for synchronization with the grid. The extracted phase angle is used to convert the
feedback variables into the (dq) reference. Consequently, synchronization between output of
inverter phase and grid phase angle is achieved by locking PLL for every instant of time between
0 to 2π.

Fig.3.19 represents the grid phase angle and the output voltage on the 50Hz grid.
Furthermore, if grid frequency is shifted into 40Hz or 60Hz, the PLL can successfully track
the variation in grid frequency and extracts the phase angle as shown in Fig. 3.20 and
Fig.3.21 for 40Hz or 60Hz respectively.

54
Chapter 3 System Simulation

Fig. 3.19, The grid phase angle and the output voltage on 50Hz grid

Fig. 3.20, The grid phase angle and the output voltage on 40Hz grid

55
Chapter 3 System Simulation

Fig. 3.21, The grid phase angle and the output voltage on 60Hz grid

3.4.2 Simulation of Current Control Structure for the Grid-Connected Inverter

In the grid-connected inverter, the inverter operates as a current-controlled source to


generate an output current based on a reference current signal. The amount of desired output
power delivered to the utility is controlled through the current regulation algorithm. The
accuracy of the current regulation algorithm is important for effective maximum power
processing. The quality of the current regulation algorithm is also important to meet the total
harmonic distortion restrictions imposed by the applicable standards.

As described before in chapter 2, there are many control algorithms have been
proposed to control inverter output current for utility interactive operations such as hysteresis
controller, predictive controller, and linear proportional-integral (PI) controller. It is found
that the linear PI controller is more suitable for the grid-connected inverter application, since
it offers an excellent steady-state response with zero steady-state error, low current ripple,
and highly sinusoidal waveform to the grid-connected inverter. In addition, the controller is
insensitive to system parameters since the algorithm does not need system models.

56
Chapter 3 System Simulation

In order to obtain a synchronous control, the feedback variables are converted into the
(dq) reference frame, which is obtained by using the Park transformations. The three-phase
currents and voltages from (abc) frame are transformed into (dq) frame currents and voltages.
For a high-performance application with accurate current tracking capability at a dynamic
state, the decoupled controller diagram for the grid-connected three-phase inverter should be
applied, as described previously in chapter 2 in Fig. 2.8. The output signals from PI
controllers after dq/abc transformations are used as input to a space vector modulator (SVM)
block in order to generate gating pulses.

As shown in Fig. 3.18, two identical conventional PI controllers are used. Each of
them contains the basic proportional (Kp) component and the integral (Ki) component. The
process of setting the optimal gains for Kp, and Ki to get an ideal response from a control
system is called tuning. There are different methods used for tuning the PI. In this
application, Ziegler-Nichols tuning rules is used to give an educated guess for the parameter
values and provide a starting point for fine tuning [29].

In this method, the Ki terms are set to zero first. Then, increase Kp from 0 to some
critical value Kp=Kcr at which sustained oscillations occur as shown in Fig. 3.22. Once
oscillation starts, the critical gain Kcr and the period of oscillations Pcr are noted. The Kp is set
to 0.45Kcr, and the Ki is set to 1.2Kp/Pcr. The optimum parameters for PI controller are
chosen to be Kp=0.1 and Ki=0.001.

Fig. 3.22, PI controller tuning with setting Ki to 0 and Kp=Kcr .

57
Chapter 3 System Simulation

To simulate the operation of the current control, a step reference input active current
Id whose amplitude is 5A at time t = 0.05 s is applied. Then followed at t = 0.1 s by a reactive
current reference component step Iq whose amplitude also is 5A. The input current
waveforms are depicted in Fig 3.23 and Fig. 3.24. The simulated output inverter current Ia is
shown in Fig 3.25. Additionally, the simulation result of three-phase grid currents (Ia, Ib, Ic)
are shown in Fig.3.26. Those figures show that after a small transient time, the output
inverter current reaches its steady-state value of 5A, which is exactly equal to the reference
value. On the application of the reactive current step, the output inverter current changed
accordingly. This proves that the current loop controller is effective such that measured
currents track their references. In addition, its dynamic behavior is satisfactory.

Fig. 3.23, Id current reference and measured

Fig. 3.24, Iq current reference and measured

58
Chapter 3 System Simulation

Fig. 3.25, Simulation result of phase grid current Ia.

Fig. 3.26, Simulation result of three-phase grid currents (ia, ib, ic).

Assuming ideal transistor switches with zero on resistance, the simulated output
phase-to-neutral voltage of the grid-connected inverter before LC-filter is shown in Fig. 3.27.
This waveform is typical for such an inverter. To demonstrate the effect of the filter, the
output voltage waveform of the inverter after the LC-filter is shown in Fig. 3.28. This figure
shows that the waveform is a nearly pure sinusoidal waveform with small ripples.

59
Chapter 3 System Simulation

Fig. 3.27, Inverter phase voltage at the input of the filter.

Fig. 3.28, Inverter phase voltage considering ideal transistors.

Then, in order to take into consideration the non-ideal effects of the model
component, especially the on-resistances of the transistors, the simulation is repeated with an
on-resistance of 0.55 Ohm. The simulated waveform of the output phase voltage is shown in
Fig. 3.29. It is clear from the figure that the presence of an appreciable on resistance in the
power switches causes noticeable distortion of the output voltage waveform.

60
Chapter 3 System Simulation

Fig. 3.29, Inverter phase voltage considering non-ideal transistors after step-up transformer

3.5 Summary

In this chapter, the stand-alone and the grid-connected inverter systems are modeled
based on the theoretical basics presented in the previous chapter. The systems are then
simulated to verify the effectiveness of its control structure and to determine its performance
parameters using PSIM simulation package. This chapter is divided into three parts:

In the first part, a model for the stand-alone three-phase inverter is developed. The
gating signals for 180º conduction are simulated, and the simulated output waveforms of the
three-phase inverter are shown.

In the second part, the SVM algorithm for three-phase inverter is simulated. The four
steps that are used to implement the SVM algorithm are analyzed, and its results are given. In
addition, the simulated output waveforms of the three-phase inverter with SVM are shown.

In the final part, a model for the grid-connected three-phase inverter is constructed,
and the parasitic elements of the constituting power components are taken into consideration.
This simulation model includes the current controller, SVM, grid-filter, and PLL. All
simulation results prove that the control structure is effective, and validate the theoretical
studies performed in chapter 2.

61
Chapter 4 System Implementation

Chapter 4
System Implementation
4.1 Introduction

In this chapter, complete experimental versions for both the stand-alone and the grid-
connected inverter are constructed. The major differences between the simulation model and
the experimental version are clarified. Additionally, this chapter explains the theory that must
be considered along with the approach that has allowed for the successful implementation of
the power inverter system. It is worth mentioning that power inverter design requires
knowledge of various areas in electrical and computer engineering, including circuit analysis,
power electronics, signals and systems, microcontrollers, software programming, and
feedback controls. A general knowledge of these areas is critical for understanding the
physical behavior of each circuit component, as well as the interaction with other
components.

This chapter is divided into two major parts: Firstly, the stand-alone inverter is
implemented and tested. Then the experimental results are presented. Additionally, a general
overview of the technology considered in this project for both hardware and software by the
implementation is presented in this section. Secondly, a comprehensive implementation of
the three-phase grid-connected inverter is introduced. The experimental results are shown
after testing every part of this circuit. Additionally, the differences between the simulation
and the experimental results are analyzed.

4.2 Implementation of the Stand-Alone Three-Phase Inverter

The stand-alone inverter is a power electronic-based device that converts DC power


output from the solar arrays or wind turbine into clean AC electricity for AC appliances
without connecting to the grid. According to the theoretical bases that are described in
chapter 2, and the circuit simulation that has been done in chapter 3, the stand-alone three-
phase inverter topology is a configuration of six MOSFET transistors and six freewheeling
diodes. Additionally, three 1KΩ load resistors are connected in the star form, and the inverter

63
Chapter 4 System Implementation

input is 12V DC source that represents the output power from the renewable-energy source.
The gating signals are six pulses shifted from each other by 60º to obtain three-phase
balanced (fundamental) voltages.

In order to implement the three-phase inverter an extensive research has been done to
find the suitable circuit components. Some of the major factors that determined the circuit
components for this project include power capabilities, efficiency, size, and cost. The
hardware design of the three-phase inverter platform will consist of two sections, the power
circuit, and the control circuit. The power circuit consists of the power switches and their
drivers. On the other hand, the control circuit consists of the dsPIC microcontroller with the
software of operation. The following two sections provide a detailed description of each part:

4.2.1 Three-Phase Power Inverter Circuit

The hardware implementation of the three-phase power inverter circuit is shown in


Fig. 4.1. It consists of six IRF740 N-channel power MOSFET 2 transistors with 0.55-Ohm
drain to source on resistance and can handle up to 400V and 10A. When utilizing N-Channel
MOSFETs to switch a DC voltage across a load, the drain terminals of the high side
MOSFETs are often connected to the highest voltage in the system. This creates a difficulty,
as the gate terminal must be approximately 10V higher than the drain terminal for the
MOSFET to conduct. Often, integrated circuit devices known as MOSFET drivers are
utilized to achieve this difference through charge pumps or bootstrapping techniques. These
chips are capable of quickly charging the input capacitance of the MOSFET quickly before
the potential difference is reached, causing the gate to source voltage to be the highest system
voltage plus the capacitor voltage, allowing it to conduct. Consequently, in order to utilize
the MOSFETs transistors, an integrated circuit device known as MOSFET driver is needed.
Additionally, the circuit contains six freewheeling diodes. The freewheeling diodes are used
to protect the switching device from being damaged by the reverse current of an inductive
load.

2
International Rectifier Co.

64
Chapter 4 System Implementation

Fig. 4.1, Circuit diagram of power circuit of the inverter

There are many MOSFET drivers available to power N-Channel MOSFETs through
level translation of low voltage control signals into voltages capable of supplying sufficient
gate voltage. The IR2110 high and low side driver 3 is chosen in this circuit [30], since it
exceeds all requirements for driving the MOSFETs in the three-phase power inverter circuit.

The IR2110 high and low side drivers are used to convert the 5 V logic level signals
from the dsPIC microcontroller to the power MOSFETs level of operation. The operation of
the IR2110 device will be controlled through generated gating signals. The gating signal will
be fed to the HIN and LIN pins simultaneously. The gating signal on HIN pin will control the
high side output (HO) and the gating signal on LIN pin will control the low side output (LO).
The SD pin controls shut down of the device and will be tied to the dsPIC microcontroller.
The VDD that will be tied to 5V, this pin is the supply voltage providing biasing to the input
side circuit of the IC (such as the HIN, LIN, and SD signals). Additional pins are required
external connections such as the Vss pin, which will be tied to the ground, and the Vcc pin,
which will be tied to 15V. Moreover, the device contains some pins requiring connections to
bootstrapping components. With the three-phase configuration, three of these devices are
utilized, as shown in Fig. 4.1. A typical connection of a single IR2110 device is shown in
Fig. 4.2.

3
International Rectifier Co.

65
Chapter 4 System Implementation

Fig. 4.2, IR2110 typical connection

As shown in Fig. 4.2, the bootstrap diode and capacitor are the only external
components strictly required for operation of the IR2110. The bootstrap capacitor provides
gate charge to the high side MOSFET. As the switch begins to conduct, the capacitor
maintains a potential difference, rapidly causing the MOSFET to further conduct, until it is
fully on. The values for these components are calculated from [31]. The formula for
minimum bootstrap capacitor value obtained from this document is shown below.

𝐼𝑞𝑝𝑠(𝑚𝑎𝑥) 𝐼𝑐𝑝𝑠(𝑙𝑒𝑎𝑘)
2 �2𝑄𝑔 + + 𝑄𝑙𝑠 + �
𝑓 𝑓
𝐶≥
𝑉𝑐𝑐 − 𝑉𝑓 − 𝑉𝑙𝑠 − 𝑉Min

The elements of the equation above can be found in datasheets as follows:

 Qg = gate charge of high side MOSFET = 41nC


 Iqbs = Quiescent current for high side driver circuitry = 230uA
 Qls = Level shift charge required per cycle = 5nC (given in application note)
 Icbs(leak) = Bootstrap capacitor leakage current = 250uA
 f = Frequency = 50Hz
 Vcc = Supply Voltage = 15V
 Vf = Forward voltage drop across bootstrap diode = 1V
 Vls = Voltage drop across low side FET = 1.5V

66
Chapter 4 System Implementation

According to the calculation above, the bootstrap capacitor is chosen to be 10µF. The
bootstrap diode should be able to block the full-power rail voltage, which is seen when the
high side MOSFET is switched on. The bootstrap diode should also be a fast recovery diode
to minimize the amount of charge fed back from the bootstrap capacitor into the Vcc supply.
In this design, the bootstrap diode is chosen to be 1N4001.

The printed circuit board (PCB) is designed by using Proteus Design Suite 4 . As
shown in Fig.4.3, a double layer PCB is implemented for the power circuit. It should note
that the tracks had to set and positioned in a certain way to minimize the interferences
between the high tension and digital controller circuits. Moreover, the high-tension track
width is set to 3.8 mm to be able to carry high current. Additionally, a heat sink along with
thermal compound is used for every transistor in order to cool the devices by dissipating heat
into the surrounding air.

Fig. 4.3, The PCB of the three-phase inverter power circuit

4
Labcenter Electronics Ltd.

67
Chapter 4 System Implementation

4.2.2 The Control Circuit

The purpose of the control circuit is to provide six-pulse gating signals that shifted
from each other by 60º. Moreover, it observes the power circuit then shut down the power
circuit when detected an abnormal condition. Additionally, it provides an indication LEDs to
show the status of system operation. The main component in the control circuit is the
microcontroller, which is chosen to be dsPIC30F3010 5. The 16-bit dsPIC30F Digital Signal
Controller (DSC) is the newest and advanced processor family from Microchip [32].

The dsPIC30F is an advanced 16-bit processor, which offers true DSP capability with
the fundamental real-time control capabilities of a microcontroller and speed up to 30 MIPS
(Mega instruction per second). In addition, the chosen microcontroller is from Motor Control
and Power Conversion Family, which is specially designed to support motor control
applications. They are also suited for Uninterruptible Power Supplies, inverters, switched
mode power supplies, and related equipment. This variant family has:

• 10-bit, 500-ksps ADC Converter


• Motor Control PWM
• Timers, Input Capture, Output Compare
• UART, SPI, I2C.

As shown in Fig. 4.4, the control circuit of the three-phase inverter is consisting
of dsPIC30F3010 microcontroller, 5MHZ crystal oscillator and two indication LEDs.
PORTE is used to generate output pulses to the three-phase power circuit. The software is
written to run at a CPU speed of 20 MIPS. This operating speed can be achieved by using
the 16X PLL on the dsPIC device and using the 5 MHz crystal.

5
Microchip Technology Inc.

68
Chapter 4 System Implementation

Fig. 4.4, The control circuit of three phase inverter

The basic idea of software implementation for gating signals generation is to divide
every 50HZ cycle into six-divisions. The duration of each is 0.0033 second. That can be done
by implementing a timer that interrupts every 0.0033 second. After the timer interrupt, a
variable called INDEX.X is incremented, then the pulses is outputted via PORTE. A dead
time of 4µsec is inserted to the pulses. The dead time is the period of time that must be
inserted between the turn-off event of one transistor in a complementary pair and the turn-on
event of the other transistor. This is a precaution to avoid short circuits across the DC source
of the inverter. Moreover, an external interrupt is used to supervise the abnormal condition
detections of the power circuit. In the case of abnormal condition detection, the gating signals
are stopped to prevent the damage of the power circuit.

The software flowchart of three-phase inverter is shown in Fig.4.5 and 4.6. MPLAB®
(v8.63) is used for the development environment and the Microchip C30 optimizing compiler
(v3.01) is used for compilation [33] [34]. The source code is written in C programming
language and included in Appendix B.

69
Chapter 4 System Implementation

Fig. 4.5, Software flowchart of stand-alone three-phase inverter part-1

70
Chapter 4 System Implementation

Fig. 4.6, Software flowchart of stand-alone three-phase inverter part-2

4.2.3 Experimental Data for the Stand-Alone Three-Phase Inverter

The experimental results for the three-phase inverter are shown in the following
figures. Snapshots of the generated pulses from dsPIC microcontroller are shown in Fig 4.7-
4.11. From these figures, it has shown that the generated pulses from dsPIC microcontroller
are shifted from each other by exactly 60º. These figures are the same as the simulation
results shown in Fig. 3.2. Additionally, the phase-to-neutral voltage of the three-phase
inverter is shown in Fig.4.12. This experimental waveform is very similar to the
corresponding simulated waveforms shown in Fig. 3.3. Moreover, the phase-to-phase voltage
is shown in Fig.4.13. This is the same as the simulation result shown in Fig. 3.4.
Consequently, the results validate the theoretical and simulation studies that done in chapter
2 and chapter 3 respectively.

71
Chapter 4 System Implementation

Fig. 4.7, The gating signal for sw1on CH1and the shifted by 60º signal for sw6 on CH2

Fig. 4.8, The gating signal for sw1on CH1and the shifted by 120º signal for sw2 on CH2

72
Chapter 4 System Implementation

Fig. 4.9, The gating signal for sw1on CH1and the shifted by 180º signal for sw4 on CH2

Fig. 4.10, The gating signal for sw1on CH1and the shifted by 240º for sw3 on CH2

73
Chapter 4 System Implementation

Fig. 4.11, The gating signal for sw1on CH1and the shifted by 300º signal for sw5 on CH2

Fig. 4.12, Snapshot of phase-to-neutral output voltage three-phase inverter

74
Chapter 4 System Implementation

Fig. 4.13, Snapshot of phase-to-phase output voltage three-phase inverter.

4.3 Implementation of the Grid-Connected Three-Phase Inverter

Fig. 4.14, Schematic diagram of grid-connected inverter

Now a complete experimental version of the grid-connected inverter is presented. The


major differences between the simulation model and the experimental version are intended to
clarify. Due to the limitation of facilities available in the laboratory, the experimental model
is modified down to a lower level but still achieve the same goal. The hardware design is

75
Chapter 4 System Implementation

verified by testing of different components of the project, which included the power circuit,
the control board, and measurement board. After the individual components are tested for
proper functionality, an experimental data for the grid integration is presented at the end of
this section.

As shown in Fig.4.14, the schematic diagram the grid side converter feed by the DC
voltage source that represent the renewable energy source. The three-phase inverter performs
the DC-to-AC conversion. The connection to the grid is done by means of a passive LC-filter
and transformer. A measurement board is needed to measure the three-phase grid-voltage and
the injected current to the grid to achieve control. A control circuit performs the control
algorithm of the overall system. The reference active and reactive current is changed via
computer. All communications between the computer and the control board is done through
the RS-232 interfaces [35], [36].

4.3.1 The Power Inverter Circuit

The power circuit of the inverter platform is the same of the power circuit of the
three-phase inverter explained previously in section 4.2.1. This circuit consists of six IRF740
MOSFET transistors with 0.55-Ohm drain to source on resistance and can handle up to 400V
and 10A; along with three IR2110 high and low side drivers that convert the 5 V logic level
signals from the dsPIC microcontroller to the power MOSFETs level of operation.
Additionally, it contains six freewheeling diodes as shown in Fig. 4.1.

4.3.2 Auxiliary Power Supplies

Different DC voltage levels are necessary for the operation of different parts of the
hardware. The power circuit requires 15 V DC power supply. The control board requires 5V,
and additional +12V is required for the measurement board.

4.3.3 External Sensors Board

A measurement board is needed to measure the three-phase grid-voltage and the


injected current to the grid to achieve control [37]. The following subsections describe the
current sensing circuit and voltage sensing circuit separately.

76
Chapter 4 System Implementation

4.3.3.1 Current Measurement Circuit

This circuit measures the inverter output current flowing into the grid. In this circuit,
the current transformer is connected between the inverter output and the grid. The idea of the
current transformer is that the current carrying conductor threads through a toroidal core,
forming the primary of a transformer. A secondary winding on the same core provides an
output voltage. The current transformer is designed to produce a linear voltage output, which
accurately tracks the AC component of the current in the primary.

In practice, the sum of the three-phase current values is zero in a three-phase system.
This advantage can be used to measure only two components of the three-phase current, and
the third component will be known through calculation. Consequently, the cost of the
hardware will be reduced because only two current sensors are required.

Fig. 4.15, current sensors circuit

As shown in Fig.4.15, the current sensor circuit contains a current transformer


(5A/5mA) is connected to 0.5KΩ resistor and the output of the current sensor is fed to the
inverting pin of the Op-amp (LM158). The voltage of the analog input of dsPIC
microcontroller must be between 0V and 5V. Therefore, an offset of 1.25V is supplied to the
non-inverting input, which amplified to provide an offset of 2.5V. The output of Op-amp,

77
Chapter 4 System Implementation

which is the 2.5V offset voltage in addition to the output of the current transformer, is
provided directly to the ADC pin of dsPIC. By this method, the sensed current delivered to
the dsPIC microcontroller with the right voltage level. The output waveforms of the current
measurement circuit are shown in Fig.4.16. It is noted that output of the circuit is out of
phase with actual output of current transformer due to the inverting amplifier. However, this
problem can be solved in the software, by multiplying the ADC result by negative one.

Fig. 4.16, oscilloscope screenshot of current measurement circuit output for two phases.

4.3.3.2 Voltage Measurement Circuit

The circuit adjective is to measure the three-phase grid voltages. The inverter output
voltage and grid voltage are AC in nature. Therefore, it cannot be sensed through a resistive
divider network, because the voltage of the analog input of dsPIC microcontroller must be
between 0V and 5V. Therefore, the high-voltage AC signals must be stepped down firstly.
Then a 2.5V-offset voltage is added to the output using the LM158 operational amplifier as
shown in Fig. 4.17.

78
Chapter 4 System Implementation

Since, the voltage of the analog input of dsPIC microcontroller must be between 0V
and 5V. Therefore, an offset of 2.5 V is supplied to the non-inverting input. The 2.5V-offset
voltage allows the bidirectional AC sense voltage centered around this DC offset voltage.
The step-down transformer makes sure that the sense signal voltage varies from 0V to 5V
with an offset of 2.5V at the analog pin of the dsPIC DSC, to utilize the available voltage
range of the ADC effectively. As described before, the sum of the three-phase voltage values
is zero in a three-phase system. This advantage can be used to measure only two components
of the three-phase voltage and the third component will known through calculation.
Consequently, the cost of the hardware will be reduced because only two voltage sensors are
required.

The circuit diagram of the voltage measurement circuit is shown in Fig.4.17. The
output waveforms of the voltage measurement circuit are shown in Fig.4.18. It is noted that
the output is out of phase with actual output of the step-down transformer due to the inverting
amplifier. However, this problem can be solved in the software, by multiplying the ADC
result by negative one. As shown in Fig. 4.19, the output of the voltage sensor has the same
frequency and phase as the grid voltage.

Fig. 4.17, Voltage measurement circuit

79
Chapter 4 System Implementation

Fig. 4.18, Oscilloscope screenshot of voltage measurement circuit output for two phases.

Fig. 4.19, Output of voltage sensor on CH1 and grid voltage on CH2

80
Chapter 4 System Implementation

4.3.4 The Inverter Control Design

The purpose of the control circuit is to perform the control loop. The control strategy
that used in developing the grid-connected inverter is described before in chapter 2.
Moreover, a simulation of the overall grid-connected system that included SVM based PI
controller, PLL and grid-filter is presented in chapter 3. The control structure of the grid-
connected inverter is shown in Fig. 2.8. As shown in this figure the grid voltage and the
injected current to the grid are sensed firstly. Then, the grid angle is extracted by PLL
algorithm. After that, the PI controller is executed for the current control loop. Finally, SVM
is executed then the gating signals to the power circuit are generated.

There are two significant parts in the inverter control design: the hardware and the
software. The hardware design revolves around the control board, which includes the dsPIC
microcontroller. In addition, an interface that required for communication between the
control board, and the higher level CPU based controller. In The software part, the software
codes for both the local dsPIC microcontroller and for the PC based controller are
implemented.

4.3.4.1 Hardware of Inverter Control Board

As shown in Fig.4.20, the control circuit contains the dsPIC30F3010 microcontroller


along MAX232 that is RS232 transceiver (transceiver means transmitter and receiver). The
software is written to run at a CPU speed of 20 MIPS. This operating speed can be achieved
by using the 8X PLL on the dsPIC device and using the 10 MHz crystal oscillator.

The output of the measurement board is inserted to the dsPIC 10-bit high-speed
analog-to-digital converter (ADC) directly. That allows conversion of an analog input signal
to a 10-bit digital number. This module is based on successive approximation register
architecture, and provides a maximum sampling rate of 500 Ksps. Four analog input pins
(AN2-to-AN5) are simultaneously sampled to perform the ADC of the grid voltage and the
injected current to the grid respectively. The Simultaneous sampling of multiple signals
ensures that the snapshot of the analog inputs occur at precisely the same time for all inputs.
Therefore, the accuracy of the control loop increases.

81
Chapter 4 System Implementation

Fig. 4.20, Circuit diagram of grid connected inverter control board

The dsPIC motor control PWM module simplifies the task of generating multiple
synchronized pulse width modulated outputs. The module has six PWM output pins,
numbered PWM1H/PWM1L through PWM3H/PWM3L. The six I/O pins are grouped into
high/low numbered pairs, denoted by the suffix H or L, respectively. The complementary
mode is operated. In this mode, the low PWM pins are always the complement of the
corresponding high I/O pin. A hardware dead time generator for complementary mode is
programmed to generate 4µsec dead time between high/low pairs.

There are fault pins, FLTA associated with the PWM module. When the power circuit
sends an alarm-signal, these pin can optionally drive each of the PWM I/O pins to a defined
state that is zeros. This action takes place without software intervention so fault events can be
managed quickly. By this technique, the power circuit is protected against any up normal
condition.

82
Chapter 4 System Implementation

The PWM module has a special event trigger that allows A/D conversions to be
synchronized to the PWM time base. The ADC sampling and conversion time is programmed
to occur at the end of PWM period. The special event trigger allows the user to minimize the
delay between the time when ADC conversion results are acquired and the time when the
duty cycle value is updated.

The main outputs of the control board are the gate drive PWM signals to the power
circuit. Additionally, a D-type RS232 connector is used to interface the circuit to the
computer via RS232-to-USB cable adaptor. Since, the hardware serial ports with their 9-pin
D connectors have disappeared from laptop and desktop computers. The input of the circuit
is output of voltage and current measurement signals from the external sensors and the alarm
signal from the power circuit. LED1 emitted when the alarm signal detected. LED2 emitted
to indicate that the process is functional well.

4.3.4.2 Firmware of dsPIC Microcontroller

MPLAB® (v8.63) is used as the development environment and the Microchip C30
optimizing compiler (v3.01) is used as compilation [33], [34], [38]. The source code is
written in C programming language and included in Appendix B.

Generally, microcontrollers can be programmed in two modes: free-run and


multitasking. In free-run mode, the processor executes the one program loop continuously.
On the other hand, Multitasking takes place when two or more programs on one
microcontroller at precise, calculated moments, to execute the firmware routines. Therefore,
the multitasking goal is to run several tasks together. Multitasking requires the code to be
structured and broken into small fragments [39]. The first mode of operation is appropriate
for applications that implement only few functions, one or two, which require maximum
controller speed. In this application, the free-run mode will be a good choice because it
executes very fast. Moreover, in order to control the program all events need to be interrupt
driven.

Although the source code is thoroughly commented, the major routines specific to
grid-connected inverter control are explained in the flow charts contained in Fig.4.21 through
Fig 4.24. Table 4.1 explains which of the dsPIC30F peripherals are used and for what

83
Chapter 4 System Implementation

purpose. Table 4.2 describes the content and function of the 14 individual source code files.
The source code is written in C programming language and included in Appendix B.

dsPIC30F Peripheral Function and Configuration

PWM Module The PWM module is used in order to drive the


three-phase inverter with 3.6 kHz PWM
modulation. Outputs are configured in
complementary mode, center aligned PWM
signals, 4µsec dead time generated, and the
special event trigger is used to initiate ADC
conversions just before switches turn off. PWM
interrupt is enabled with priority 4. FLTA
interrupt is enabled with priority 7.

High Speed 10-bit ADC The ADC is used in order to take four
simultaneous samples per PWM cycle of injected
current and grid voltage. CH0 to CH3 are
enabled. The samples are synchronized to the
PWM module. Auto sampling selected. ADC
interrupt is enabled with priority 5.

UART The UART is used in order to interface with


computer. Full-duplex 8- data transmission
through the U1TX and U1RX pins enabled. No
Parity, one stop bit and 9600-baud rate selected.
Receive Interrupt is enabled with priority 3.

External Interrupt 1 The external interrupt is used in order to stop the


system operation when needed. INT1 interrupted
on falling edge with priority 6.

Table 4.1, dsPIC30F peripheral usage

84
Chapter 4 System Implementation

Filename Purpose of File

p30f3010.h This file is MPLAB-C30 dsPIC30F3010 processor header.

math.h The header file math.h consists of a macro and various functions that
calculate common mathematical operations.

ports.h Header for I/O ports module library functions.

dsp.h Interface to the DSP Library for the dsPIC30F.

adc10.h Header for 10-bit ADC module library functions.

pwm.h Header for PWM module library functions.

UART.h Header for UART module library functions.

GENRAL.c Store constant names and macros used all over the program.

mainControl.c This file is for Initialization and background code.

DATA.c This file holds Application global data and performs variables
declaration.

initiate Initiate all dsPIC30F peripherals.


peripheral.c

ClarkPark.c This file controls Clark and Park transformation.

SVM.c This file controls PWM calculations.

interrupts.c This file handles Interrupt Service Routines.

Table 4.2, Source code files

85
Chapter 4 System Implementation

Fig. 4.21, dsPIC software flow chart (The main routine)

86
Chapter 4 System Implementation

Fig. 4.22, dsPIC software flow chart (The SVM routine)

87
Chapter 4 System Implementation

Fig. 4.23, dsPIC software flow chart ( PWM interrupt service routine)

88
Chapter 4 System Implementation

Fig. 4.24, dsPIC software flow chart ( ADC interrupt service routine)

4.3.4.3 PC Based Control Software

The PC software is needed in order to provide a mean to change the reference active
and reactive current. Moreover, change the Kp and Ki parameters of the PI controller. Visual
Studio 2010 is used to implement such software. Visual Studio 2010 is an integrated
environment for building, testing, debugging, and deploying a variety of applications:
windows applications, web applications, classes and custom controls, and even console

89
Chapter 4 System Implementation

applications. Visual Basic 2010 is the languages that used to build this application within
Visual Studio 2010.

Fig. 4.25, Screenshot of PC software for inverter control

As shown in Fig.4.25, the PC software of inverter control is used to change the


reference active and reactive current, the Kp and Ki parameters of PI controller in the current
control loop. Moreover, the Kp and Ki parameters of PI controller in PLL loop. In order to
use the software, RS232 cable must connect from PC to inverter control circuit and establish
a connection between them by chose the COM port from radio button and press connect
button. The start button used to switch ON and OFF the inverter. In order to change any
parameter, the value is chosen from the track bar, and then presses the send button. The
source code for PC based control software is included in Appendix B.

4.3.5 Experimental Data for the Grid-Connected Three-Phase Inverter

The experimental results for the grid-connected three-phase inverter are shown in the
following figures. A typical oscilloscope snapshot of the control voltage pulses for the two
transistors S1 and S3 are shown in Fig. 4.26. This is the same as the simulation result shown
in Fig. 3.15. Moreover, a typical oscilloscope snapshot for the measured voltage and the

90
Chapter 4 System Implementation

gating pulses for S1 are shown in Fig. 4.27. This figure shows that the pulse widths of the
generated gating pulses are varied as a function of the control loop as described before in
chapter 2. Additionally, a typical oscilloscope snapshot for the generated pulses from the
dsPIC microcontroller and the generated pulses after the IR2110 driver IC are shown in Fig.
4.28. This figure shows that the generated pulses from the IR2110 driver IC are the same as
the generated pulses from dsPIC microcontroller. However, it is larger in amplitude.

A typical oscilloscope snapshot of the control voltage pulses for the two transistors in
a complementary pair S1 and S4 are shown in Fig. 4.29. A dead time of 4µsec is inserted
between the gating pulses of any two transistors in a complementary pair as shown in Fig.
4.30. As described previously, the dead time is the period of time that must be inserted
between the turn-off event of one transistor in a complementary pair and the turn-on event of
the other transistor. This is a precaution to avoid short circuits across the DC source of the
inverter.

Fig. 4.31 shows a typical oscilloscope snapshot of the phase-to-neutral voltage of our
experimental grid-connected inverter taken directly before the filter. Moreover, a typical
oscilloscope snapshot of the phase-to-phase voltage taken directly before filter is shown in
Fig. 4.32. The experimental waveforms are very similar to the corresponding simulated
waveforms as shown in Fig. 3.16 and Fig. 3.17 respectively.

A typical output voltage of the grid-connected inverter taken after the transformer,
and the grid voltage are shown in Fig.4.33. As it is clear from the figure, the inverter output
voltage and the grid voltage are the same in amplitude, frequency, and phase except that the
waveform shape of the inverter is distorted. This waveform is to be compared with that
simulated in Fig.3.29. It is apparent that the two waveforms are identical to a large extent.
Consequently, it can be concluded that the major waveform distortion of the output inverter
voltage is caused basically by the internal resistances of the power supply and the power
transistors. The presence of these parasitic resistances not only dissipates power but also
distorts the voltage waveform. Therefore, one must design the inverter with the smallest
possible parasitic resistances such that the total voltage drop across them is much smaller
than the power-supply voltage at the peak current of the circuit.

91
Chapter 4 System Implementation

Fig. 4.26, The output pulses for two transistors S1 and S3

Fig. 4.27, The measured voltage signal on CH1 and the generated pulses on CH2.

92
Chapter 4 System Implementation

Fig. 4.28, The generated pulses from microcontroller on CH1 and pulses after driver IC on CH2

Fig. 4.29, The output pulses for two complementary transistors S1 and S4

93
Chapter 4 System Implementation

Fig. 4.30, The dead time that inserted between two complementary transistors S1 and S4

Fig. 4.31, Experiment waveform of the phase-to-neutral voltage of grid-connected inverter

94
Chapter 4 System Implementation

Fig. 4.32, Experiment waveform of the phase-to-phase voltage of grid-connected inverter

Fig. 4.33, Experimental waveform of the output phase voltage and the grid voltage

95
Chapter 4 System Implementation

4.4 Summary

In this chapter, complete experimental versions for both the stand-alone and the grid-
connected inverter are presented. The major differences between the simulation model and
the experimental version are clarified. This chapter is divided into two main sections:

In the first section, the stand-alone three-phase inverter is implemented and tested.
Then the experimental results are presented. All experimental results validate the theoretical
and simulation studies that are done in chapter 2 and chapter 3, respectively.

In the second section, a comprehensive implementation of the grid-connected three-


phase inverter is introduced. The experimental results are shown after testing every part of
this circuit. Additionally, the differences between the simulation and the experimental results
are analyzed. Agreements are found between the simulation and experimental results when
the parasitic resistances of the power components of the inverter circuit are taken into
consideration. An important conclusion is that such parasitic resistance causes not only
power losses but also a distortion in the output voltage waveform.

96
Conclusions & Future Work

Conclusions & Future Work


With the development of the control structures of the grid-connected inverter, the
efficiency and the performance of renewable-energy sources can be increased. This thesis
demonstrates the design of a control algorithm for the grid-connected inverter.

In this thesis, the theory of the three-phase grid-connected inverter is outlined. The
closed loop current control techniques are discussed. Then it is found that the linear PI
control is more suitable for this grid-connected inverter application, since it offers an
excellent steady-state response with zero steady-state error, low current ripple, and highly
sinusoidal waveform to the grid-connected inverter. In addition, the controller is insensitive
to system parameters since the algorithm does not need system models.

The most common PWM techniques are addressed. The SVM is chosen for the grid-
connected inverter application because the SVM has many advantages such as constant
switching frequency, well-defined output harmonic spectrum, optimum switching patterns,
and excellent dc-link voltage utilization.

The importance of the synchronization for control purposes of a grid-connected


power generation system is presented. In addition, it is reported that several synchronization
algorithms are capable of detecting the phase angle of the grid voltage. Then it concludes that
the PLL is the best choice for the grid-connected inverter application. This is because the
PLL can successfully detect the phase angle of the grid voltage even when the noise or
higher-order harmonics exist in the grid voltage.

The stand-alone and the grid-connected inverter systems are modeled based on the
theoretical basics presented in the previously. These systems are then simulated to verify the
effectiveness of its control structure and to determine its performance parameters using PSIM
simulation package.

Finally, complete experimental versions for both the stand-alone and the grid-
connected inverter are presented. The major differences between the simulation model and
the experimental version are clarified. Agreements have been found between the simulation
and experimental results when the parasitic resistances of the power components of the

98
Conclusions & Future Work

inverter circuit are taken into consideration. An important conclusion is that such parasitic
resistance causes not only power losses but also a distortion in the output voltage waveform.

Future research can be done based on this work, as summarized in the following points:

• Design and implementation of other control strategies for the grid-connected inverter
in order to do a comparison between methods of control.
• This work has been focused and implemented only on the grid side converter. A
complete implementation of the control strategy for the generator side together with
the control for the grid side convertor could be built.

99
Bibliography

Bibliography
[1] New and Renewable Energy Authority (NREA). Annual report 2010/2011.

[2] A. Zekry, A. A. Slim. Investigations on Stepped sine wave push-pull inverter.


Mansoura, Egypt : 12th International Mechanical Power Engineering Conference
IMPEC12, 2001.

[3] A. Zekry. Computer-aided analysis of stepped sine wave inverters. s.l. : Solar
Cells 31, 1991.

[4] A.Abobakr, A.Zekry. Three phase grid connected inverter, PhD thesis.
Cairo, Eygpt : Ain-Shams university, 2008.

[5] Frede Blaabjerg, Remus Teodorescu, Marco Liserre, Adrian V. Timbus.


Overview of Control and Grid Synchronization for Distributed Power Generation
Systems. s.l. : IEEE Transactions On Industrial Electronics, October 2006. pp. VOL.
53, NO. 5.

[6] W. Kramer, S. Chakraborty, B. Kroposki, and H. Thomas. Advanced


Power Electronic Interfaces for Distributed Energy Systems Part 1: Systems and
Topologies. s.l. : National Renewable Energy Laboratory, March 2008.

[7] Muhammad H. Rashid. Power Electronics Handbook. Pensacola, Florida :


Acadmic press.

[8] H. Haeberlin. Evolution of Inverters for Grid connected PV-Systems from


1989 to 2000. Munich, Germany, : 17th European Photovoltaic Solar Energy
Conference, Oct. 22 – Oct. 26, 2001.

[9] Yilmaz Sozer, David A. Torrey. Modeling and Control of Utility Interactive
Inverters. s.l. : IEEE Trans On Power Electronics, November 2009. pp. VOL. 24, NO.
11.

101
Bibliography

[10] Qingrong Zeng, Liuchen Chang. Study of Advanced Current Control


Strategies for Three-Phase Grid-Connected PWM Inverters for Distributed
Generation. Toronto, Canada : IEEE Conference on Control Applications, 2005.

[11] YANG Yong , RUAN Yi , SHEN Huan-qing , TANG Yan-yan ,YANG


Ying. Grid-connected inverter for wind power generation system. Shanghai , P. R.
China : J Shanghai Univ (Engl Ed), 2009.

[12] Milan Prodanovic, Timothy C. Green. Control and Filter Design of Three-
Phase Inverters for High Power Quality Grid Connection. s.l. : IEEE Transactions
On Power Electronics, January 2003. pp. VOL. 18, NO. 1.

[13] Muhammad H. Rashid . Power Electronics: Circuits, Devices and


Applications (3rd Edition) . s.l. : Prentice Hall, 2004. ISBN-10: 0131011405.

[14] Sung-Hun Ko, Seong R. Lee, Hooman Dehbonei, Chemmangot V. Nayar.


Application of Voltage- and Current-Controlled Voltage Source Inverters for
Distributed Generation Systems. s.l. : IEEE Transactions On Energy Conversion,
September 2006. pp. VOL. 21, NO. 3.

[15] Marian Kazmierkowski, Ramu Krishnan and Frede Blaabjerg . Control


in Power Electronics Selected Problems. s.l. : Institute of Energy Technology at
Aalborg University, 2002. 978-0-12-402772-5.

[16] Marian Kazmierkowski, Luigi Malesani. Current Control Techniques for


Three-Phase Voltage-Source PWM Converters: A Survey. s.l. : IEEE Transactions On
Industrial Electronics, October 1998. pp. VOL. 45, NO. 5.

[17] Simone Buso and Paolo Mattavelli. Digital Control in Power electronics.
2006.

[18] Patricio Cortés, Marian P. Kazmierkowski, Ralph M. Kennel. Predictive


Control in Power Electronics and Drives. s.l. : IEEE Transactions on Industrial
Electronics, December 2008.

102
Bibliography

[19] Nisha G. K., IAENG, Ushakumari S., Lakaparampil Z. V. Harmonic


Elimination of Space Vector Modulated Three Phase Inverter. Hong Kong :
international multiconference of engineers and computer scientists, 2012.

[20] A. Mehrizi-Sani, S. Filizadeh. Digital Implementation and Transient


Simulation of Space-Vector Modulated Converters. Montreal, QC : Power
Engineering Society General Meeting IEEE (PESGM 06), Jun.2006.

[21] D. Rathnakumar, J. Lakshmana Perumal, T. Srinivasan. A New software


implementation of space vector PWM. s.l. : Proceedings of IEEE Southeast
conference, 2005. pp. 131-136.

[22] Microchip Technology Inc. VF Control of 3-Phase Induction Motor Using


Space Vector Modulation. 2005. AN955.

[23] Florin Iov, Mihai Ciobotaru, Nicolaos A. Cutululis and Frede Blaabjerg.
Power Electronics: Key-Enabling Technology for Grid Integration of Wind Power.
Galati, Romania : The Second International Symposium on Electrical and Electronics
Engineering – ISEEE, 2008.

[24] Adrian Timbus. Grid Monitoring and Advanced Control of Distributed


Power Generation Systems,( Ph.D. Thesis). Denmark : Aalborg University-Institute
of Energy Technology, 2007.

[25] Svein Erik Evju. Fundamentals of Grid Connected Photo-Voltaic Power


Electronic Converter Design M.Sc thesis. s.l. : Norwegian University of Science and
Technology, June 2007.

[26] Khaled H. Ahmed, Stephen J. Finney and Barry W. Williams. Passive


Filter Design for Three-Phase Inverter Interfacing in Distributed Generation.
Strathclyde University, UK : Electrical Power Quality and Utilisation, Journal Vol.
XIII, No. 2., 2007.

103
Bibliography

[27] Marco Liserre, Frede Blaabjerg, Steffan Hansen. Design and Control of an
LCL-Filter-Based Three-Phase Active Rectifier. s.l. : IEEE Transactions on Industry
Applications, September/October 2005. pp. VOL. 41, NO. 5.

[28] Powersim Inc. PSIM® Version 9.0 User’s Guide . January 2010.

[29] Katsuhiko Ogata. Modern control engineering- Fourth Edition. 2002.

[30] Omar M F Muhialdin, Ahmad Nahas and Takyin Chan. The Design and
Implementation of a Three Phase Power Converter in the Power Electronics and
Drives Subject. Australia : School of Electrical Engineering,Victoria University.

[31] International Rectifier. HV Floating MOS-Gate Driver ICs, Application


Note AN-978.

[32] Microchip Technology Inc. dsPIC30F Family Reference Manual. 2005.

[33] Microchip Technology Inc. MPLAB® IDE user’s guide. 2005.

[34] Microchip Technology Inc. MPLAB® C30 C compiler user’s guide. 2007.

[35] S. Chakraborty, C. Pink, J. Price and B. Kroposki. Development of


Standardized Power Electronic Components, Sub-systems and Systems for Increased
Modularity and Scalability. s.l. : National Renewable Energy Laboratory, 2007.
NREL/TP-581-42482.

[36] S. Chakraborty, B. Kroposki, and W. Kramer. Advanced Power Electronic


Interfaces for Distributed Energy Systems ( Part 2). Colorado : National Renewable
Energy Laboratory, November 2008. NREL/TP-550-44313.

[37] Ali Tahri , Azeddine Draou. Design of A Simple Measuring Technique Of


The Instantaneous Power In Three-Phase System. s.l. : Journal of Electrical
Engineering, 2005.

[38] Microchip Technology Inc. dsPIC™ Language Tools Libraries. 2004.

104
Bibliography

[39] O G POPA. Learn Hardware, Firmware and Software Design. 2005. ISBN
0-9735678-7-2.

[40] Microchip Technology Inc. Using the dsPIC30F for Vector Control of an
ACIM. 2004. AN908.

105
Extracted Paper

Extracted Paper
Ahmed Abdalrahman, Abdalhalim Zekry and Ahmed Alshazly. Article: Simulation and
Implementation of Grid-connected Inverters. International Journal of Computer Applications
60(4):41-49, December 2012. Published by Foundation of Computer Science, New York,
USA.

106
Appendix A Coordinate Transformation

Appendix A
Coordinate Transformation
The objective of this section is to give the basic knowledge needed to describe the
control principles for three-phase grid-connected inverter. Two fundamental tools are
required to design an efficient three-phase current controller: Clark transformation and Park
transformation.

I. Clark Transformation

Clark transformation (αβ transformation) represents a very useful tool for the analysis
and modeling of three-phase electrical systems. Clark transforms maps three-phase a, b, c
components which are equally shifted by 120° into a two-phase system. The new rotating
vector is represented by two orthogonal components α and β. The space vector consists of a
real (α) and imaginary (β) part, which represents two sinusoids shifted by 90° in time [17],
[37].

Fig. A.1, Clark Transform for current

As illustrated in Fig. A.1, the αβ transformation can be defined as follows:

1 − 1�2 − 1�2 X𝑎
𝑋𝛼 2
�X � = � � √3� � �𝑋𝑏 � Equation A.1
𝛽 3 0
2 − √3�2 𝑋
𝑐

107
Appendix A Coordinate Transformation

In the balanced three-phase system, the instantaneous sum of the three-phase current
values will be zero. This advantage can be used to measure only two components of the
three-phase currents. Then the third component can be known through calculation. In this
case, the cost of the hardware is reduced because only two current sensors are required [40].
Moreover, this technique can be applied for the three-phase voltage system.

𝑋𝛼 = 𝑋𝑎
� 1 2 Equation A.2
𝑋𝛽 = 𝑋𝑎 + 𝑋𝑏
√3 √3

II. Park Transformation

Park Transformation converts the stationary system into a rotating system, which is
called synchronous coordinate, or dq coordinates. Space vector which rotates in one direction
converted by Park transformation will be visible as a (not rotating, similar to the standard)
complex phases. The instantaneous angle of the space vector will be referenced to the θ
angle. This transform make the rotating vectors look like DC quantities, thus simplifying
analysis and control [17], [37].

The reference angle θ for synchronous frame is usually synchronized with some other
rotating quantity, e.g. voltage. It is important that the reference angle θ rotates smoothly;
therefore, a PLL is often used. The idea behind Park’s transformation is quite simple. Instead
of mapping the three-phase inverter and its load onto a fixed two-axis reference frame, this
transformation maps it onto a two-axis synchronous rotating reference frame. This practically
means moving from a static coordinate transformation to a dynamic one, i.e., to a linear
transformation whose matrix has time varying coefficients.

108
Appendix A Coordinate Transformation

Fig. A.2, Park transform for current

Park transformation defines a new set of reference axes, called d and q, which rotate
around the static αβ reference frame at a constant angular frequency ω. This means that θ =
ωt. The new system quantities are d (direct) and q (quadrate). The conversion from stationary
system (α, β) to the synchronous (rotating) system is defined as:

𝑋𝑑 cos 𝜃 sin 𝜃 𝑋𝛼
� �=� �� � Equation A.3
𝑋𝑞 − sin 𝜃 cos 𝜃 𝑋𝛽

In case of direct transformation from the three-phase system (abc) to the synchronous
system (dq) the equations are given by:

2𝜋 2𝜋
𝑋𝑎
𝑋𝑑 2 𝑐𝑜𝑠(𝜃) cos �𝜃 + �
3
cos �𝜃 −
3
� Equation A.4
� �= � � �𝑋𝑏 �
𝑋𝑞 3 2𝜋
−𝑠𝑖𝑛(𝜃) −sin (𝜃 + )
2𝜋
−sin (𝜃 − ) 𝑋𝑐
3 3

In the digital signal processing theory, Park transformation is known as a shift in the
frequency domain. Park transformation causes all frequency components to be shifted by a
specified frequency. This is why 50 Hz signal shifted with -50Hz become a DC signal;
analogously, the 250 Hz signal becomes a 200 Hz.

109
Appendix B Software Source Code

Appendix B
Software Source Code
The objective of this section is to list the source code of programs that is created for
both the stand-alone and the grid-connected inverter. Firstly, the microcontroller firmware
for the stand-alone three-phase inverter is presented. Secondly, the microcontroller firmware
for the grid-connected inverter is introduced. All dsPIC microcontroller programs in this
thesis have been written in C programming language, and uses the MPLAB® (v8.63) as a
development environment and the Microchip C30 optimizing compiler (v3.01) is used as
compilation [33], [34]. Finally, the source code of PC control software is provided. This
program uses the Visual Basic 2010 as a programming language, and uses Visual Studio
2010 to build this application.

I. Firmware for the Three-Phase Inverter


/*
=============================================================
Project/File: digital
control/general.c
Processor: 30F3010
Frequency: XT w/PLL*8; 80MHz;
20MIPS
Copyrights: Eng. Ahmed
Date 1-st built: 22/6/2011
==============================================================
==
Description: This file contains useful macros
=========================================================== */
// general constants
#define FCY 20000000 // xtal = 10Mhz; PLLx8
#define MILLISEC FCY/1000 //20000*50nsec= 1 mSec delay
#define FPWM 3600
// PWM freq. Fsn= Fs/f &Fsn=6N where N is odd in SVM
#define TPWM 0.0033
#define VDC 40 // dc voltage

#define Outmax 346


#define Outmin 0
#define kp 1
#define Ki 0.1

110
Appendix B Software Source Code

//generic constants definitions


#define ON 1 //generic ON value
#define OFF 0 //generic OFF value
#define TRUE 1 //generic TRUE value
#define FALSE 0 //generic FALSE value
#define LOW 0 //generic logic low
#define HIGH 1 //generic logic high
#define RISINGEDGE 0 //pulse rising edge value
#define FALLINGEDGE 1 //pulse falling edge value
#define OK 1 //OK value
#define NOTOK 0 //Not OK value
#define ACTIVE 1 //active state of UART/SPI
#define PASSIVE 0 //passive state of UART/SPI
#define INTMAX 65535 //maximum unsigned integer limit
#define CHARMAX 255 //maximum unsigned char limit

// MASK difination
#define MASK0 0X0001 // BIT 0000000000000001 IS SET
#define MASK1 0X0002 // BIT 0000000000000010 IS SET
#define MASK2 0X0004 // BIT 0000000000000100 IS SET
#define MASK3 0X0008 // BIT 0000000000001000 IS SET
#define MASK4 0X0010 // BIT 0000000000010000 IS SET
#define MASK5 0X0020 // BIT 0000000000100000 IS SET
#define MASK6 0X0040 // BIT 0000000001000000 IS SET
#define MASK7 0X0080 // BIT 0000000010000000 IS SET
#define MASK8 0X0100 // BIT 0000000100000000 IS SET
#define MASK9 0X0200 // BIT 0000001000000000 IS SET
#define MASK10 0X0400 // BIT 0000010000000000 IS SET
#define MASK11 0X0800 // BIT 0000100000000000 IS SET
#define MASK12 0X1000 // BIT 0001000000000000 IS SET
#define MASK13 0X2000 // BIT 0010000000000000 IS SET
#define MASK14 0X4000 // BIT 0100000000000000 IS SET
#define MASK15 0X8000 // BIT 1000000000000000 IS SET

// general MACRO definition


#define nop() {Nop();} //Nop() defined in
p30f4011.h
#define nop2() {nop();nop();} //2 "no operation"
instructions
#define nop3() {nop2();nop();} //3 "no operation"
instructions
#define nop4() {nop2();nop2();} //4 "no operation"
instructions

111
Appendix B Software Source Code

#define nop5() {nop2();nop3();} //5 "no operation"


instructions
#define nop10() {nop5();nop5();} //10 "no operation"
instructions
#define nop20() {nop10();nop10();} //20 "no operation"
instructions
#define nop40() {nop20();nop20();} //40 "no operation"
instructions
#define toggle(a) {a=a^1;}
//toggle bit a ON and OFF; a must be one bit XOR
//glue macros
#define glue2(a,b) a##b //the arguments a and b are read
as ab
#define glue3(a,b,c) a##b##c //the arguments a, b, c are read
as abc
#define xglue2(a,b) (glue2(a,b)) //used to force the
glue2()
#define xglue3(a,b,c) (glue3(a,b,c))//used to force glue3()

//bit macros
//general bit macros
#define setbit(bit,a) {a=a|(xglue2(MASK,bit));} //sets bit in
variable a
#define clearbit(bit,a) {a=a&(~(xglue2(MASK,bit)));}
//clears bit from variable a
#define isbit(bit,a)
((a&(xglue2(MASK,bit)))==(xglue2(MASK,bit)))
//true if bit is set in a

//bit shift macros


#define lshift1(a) {a=a<<1;} //a is shifted left 1 bit (*2)
#define lshift2(a) {a=a<<2;} //a is shifted left 2 bits (*4)
#define lshift3(a) {a=a<<3;} //a is shifted left 3 bits (*8)
#define lshift4(a) {a=a<<4;} //a is shifted left 4 bits (*16)

#define rshift1(a) {a=a>>1;} //a is shifted right 1 bit (/2)


#define rshift2(a) {a=a>>2;} //a is shifted right 2 bits (/4)
#define rshift3(a) {a=a>>3;} //a is shifted right 3 bits (/8)
#define rshift4(a) {a=a>>4;} //a is shifted right 4 bits (/16)

//delay macros
unsigned int x; //local variable
#define delay10() {for(x=0;x<INTMAX;x++) nop10();}//first
delay macro
#define delay20() {delay10(); delay10();}//second delay macro

112
Appendix B Software Source Code

//byte access macros


#define Lbyteptr(var16) ((unsigned char*)(&var16)) //returns
address of L byte
#define Hbyteptr(var16) ((unsigned char*)(&var16)+1) //returns
address of H byte
//set the low byte of a 16 bits variable
#define setLbyte(var16,var8) {(unsigned
char)(*Lbyteptr(var16)=var8);} //
//set the high byte of a 16 bits variable
#define setHbyte(var16, var8) {(unsigned
char)(*Hbyteptr(var16)=var8);} //
//get the low byte of a 16 bits variable
#define getLbyte(var16) ((unsigned char)(*Lbyteptr(var16))) //
//get the high byte of a 16 bits variable
#define getHbyte(var16) ((unsigned char)(*Hbyteptr(var16))) //

//turn any port On/OFF


#define turnport(a,b) {xglue2(_LAT,a)=b;} //

#define TESTLED _LATD1 //TESTLED is on port RD1


#define TESTLED2 _LATD0 //TESTLED is on port RD0

void DelayNmSec(unsigned int N)


{
unsigned int j;
while(N--)
for(j=0;j < MILLISEC;j++);
}
/* =========================================================
Project/File: 3ph simple/main.c
Processor: 30F3010
Frequency: XT w/PLL*8; 80 MHz; 20 MIPS
Copyrights: Eng. Ahmed
Date 1-st built: 17/7/2011
============================================================
Description: simple 6 pulse for inverter
========================================================= */
#include "p30f3010.h" //30F3010 SFR definitions
#include <timer.h>
#include <ports.h>
#include "GENRAL.c" //utilities file

//allows for bit fields declaration, and group tmr1 data


struct tmrdata
{
unsigned x :3; //counter values 0,1,2,3,4,5,6,7
unsigned i :1; // interrupt flag

113
Appendix B Software Source Code

} index;
unsigned int a;
void inittimer1() //this initialize timers
{
index.x=0; //counter
index.i=0;
/*configures the 16-bit timer interrupt.*/
ConfigIntTimer1(T1_INT_PRIOR_3 & T1_INT_ON);

/*configures the 16-bit Timer Control register*/


OpenTimer1(T1_ON & T1_GATE_OFF & T1_PS_1_8& T1_IDLE_CON &
T1_SYNC_EXT_OFF & T1_SOURCE_INT,8250);
/* 50 ns*8250*8=0.0033*6= 0.02 sec= 1/50HZ /
}
/*----------------------------------------------------------*/
void initint1()
{
ConfigINT1(FALLING_EDGE_INT & EXT_INT_PRI_5 &EXT_INT_ENABLE);
}
/*------------------------------------------------------*/
int main(void) //beginning of the main routine
{
ADPCFG=0xFFFF; //disable the A/D conversion
_ADON=0; //turn A/D OFF to conserve power
DelayNmSec(1);//delay 1msec to allow controller's voltages
to set
_TRISD0=1;
_TRISD1=0;
TRISB=0; //sets PORTD to all outputs
TRISE=0;
TRISF=0;
inittimer1(); //init timer1
initint1();
while(OK) //executes forever
{
if (index.i==0)
{
if (index.x==0 && index.i==0 )
{
if (a<=80){ // 80*50 nsec= 4usec dead time
LATE=0x30;
a++;}
else if (a>80){
LATE=0x31;
LATB=0x31;}
}
else if (index.x==1&& index.i==0 )

114
Appendix B Software Source Code

{
//toggle(TESTLED); //test: toggle port RD1 ON/OFF
if (a<=80)
{LATE=0x21;
a++;}
else if (a>80){
LATE=0x23;
LATB=0x23;}
}
else if (index.x==2 && index.i==0)
{
if (a<=80)
{LATE=0x03;
a++;}
else if (a>80){
LATE=0x07;
LATB=0x07;}
}
else if (index.x==3&& index.i==0 )
{
//toggle(TESTLED); //test: toggle port RD1 ON/OFF

if (a<=80)
{LATE=0x06;
a++;}
else if (a>80){
LATE=0x0E;
LATB=0x0E; }
}
else if (index.x==4&& index.i==0 )
{
//toggle(TESTLED); //test: toggle port RD1 ON/OFF
if (a<=80)
{LATE=0x0C;
a++;}
else if (a>80){
LATE=0x1C;
LATB=0x1C;}
}
else if (index.x==5&& index.i==0 )
{
//toggle(TESTLED); //test: toggle port RD1 ON/OFF
if (a<=80)
{ LATE=0x18;
a++;}
else if (a>80){
LATE=0x38;

115
Appendix B Software Source Code

LATB=0x38;}
}
else{LATE=0x00; }
}
else if (index.i==1)
{
LATE=0x00;
TESTLED=1;
}
}
nop();
return 0; //return of main
}
//ISR timer1 --------------------------------------------
void __attribute__((interrupt, auto_psv)) _T1Interrupt()
{//will comes here whenever timer1 interrupts
toggle(_LATF2);
if (index.x<5)
{index.x++;
a=0;}
else if (index.x>=5)
{index.x=0;
a=0;}
IFS0bits.T1IF=0; //clear timer1 interrupt flag
}
//ISR int1 ------------------------------------------
void __attribute__((interrupt, auto_psv)) _INT1Interrupt()
{//will comes here whenever INT1 interrupts
LATE=0x00;
index.i=1;
CloseTimer1();
IFS1bits.INT1IF=0; //clear timer1 interrupt flag
}
/*---------------------------------------------------*/

II. Firmware for the Grid-Connected Inverter


/* =========================================================
Project/File: Digital Control/main.c
Processor: 30F3010
Frequency: XT w/PLL*8; 80 MHz; 20 MIPS
Copyrights: Eng. Ahmed
Date 1-st built: 3/8/2011
=============================================================
Description: This Project contains the Digital control
Software
============================================================
*/

116
Appendix B Software Source Code

/* Header Files*/
#include "p30f3010.h" //30F3010 SFR definitions
#include <math.h>
#include <ports.h>
#include <dsp.h>
#include <adc10.h>
#include <pwm.h>
#include <UART.h>
#include <timer.h>

/* Function Files*/
#include "GENRAL.c" //utilities file
#include "DATA.c" //data file
#include "initiate peripheral.c"
#include "PI.c"
#include "ClarkPark.c"
#include "SVM.c"
#include "interrupts.c"//ISR file; ATTENTION! ALWAYS KEEP
LAST!

/* configure the PID LIBRARY FUNCTIONS AND DATA STUCTURES*/


/*tPID fooPID; // PI controller for PLL
fractional abcCoefficient[3] __attribute__ ((section (".xbss,
bss, xmemory")));
fractional controlHistory[3] __attribute__ ((section (".ybss,
bss, ymemory")));
fractional PLLCoeffs[] = {0,0,0};*/

tPID fooPID2;// PI controller for Iq


fractional abcCoefficient2[3] __attribute__ ((section (".xbss,
bss, xmemory")));
fractional controlHistory2[3] __attribute__ ((section (".ybss,
bss, ymemory")));
fractional kCoeffs[] = {0,0,0};

tPID fooPID3;// PI controller for Id


fractional abcCoefficient3[3] __attribute__ ((section (".xbss,
bss, xmemory")));
fractional controlHistory3[3] __attribute__ ((section (".ybss,
bss, ymemory")));

int main(void) //beginning of the main


routine
{
ADPCFG=0xFFFF; //disable the A/D conversion
_ADON=0; //turn A/D OFF to conserve
power

117
Appendix B Software Source Code

DelayNmSec(1); //delay 1msec to allow controller's voltages


to set

_TRISD0=1;
_TRISE8=1;
_TRISD1=0;
TRISF=0; //sets PORTD to all outputs

initUART(); //init UART2


iniADC();
initPWM();
initint1();
inittimer1(); //init timer1

while(OK) //executes forever


{
if (obs.i==0)
{
/*--------- Clark-Park transformation--------------------*/
Clarkv();
angle = atan2f (T.Vbeta,T.Valpha);
Parkv();//for power ref cal.
Clarki();
Parki();
//------------------current control----------------------
T.Iqf= T.Iq/1024;
T.Idf= T.Id/1024;
desIdf= desId/1024;//
desIqf= desIq/1024;//

// Iq control/
fooPID2.abcCoefficients = &abcCoefficient2[0];
//Set up pointer to derived coefficients
fooPID2.controlHistory = &controlHistory2[0];
//Set up pointer to controller history samples
PIDInit(&fooPID2);
//Clear the controller history and the controller output
kCoeffs[0] = Q15(1);
kCoeffs[1] = Q15(0.001);
kCoeffs[2] = Q15(0);
PIDCoeffCalc(&kCoeffs[0], &fooPID2);
fooPID2.controlReference = Q15(desIqf) ;
//Set the Reference Input for your controller
fooPID2.measuredOutput = Q15(T.Iqf) ;

// Id control
fooPID3.abcCoefficients = &abcCoefficient3[0];

118
Appendix B Software Source Code

//Set up pointer to derived coefficients


fooPID3.controlHistory = &controlHistory3[0];
//Set up pointer to controller history samples
PIDInit(&fooPID3);
//Clear the controler history and the controller output
PIDCoeffCalc(&kCoeffs[0], &fooPID3);
fooPID3.controlReference = Q15(desIdf) ;
//Set the Reference Input for your controller
fooPID3.measuredOutput = Q15(T.Idf) ;

PID(&fooPID2); ;
outputIq = Fract2Float(fooPID2.controlOutput);
PID(&fooPID3); ;
outputId = Fract2Float(fooPID3.controlOutput);

outId= T.Vd +desId + outputId*1024;//T.Vd +T.Iq*-1.570


outIq= desIq + outputIq*1024;//T.Iq*1.570
//------------------------SVM--------------------------------
InvParki();
SVM();
}
else if (obs.i==1)
{
TRISE=0;
LATE=0x00;
TESTLED=1;
}
}
nop();
return 0; } //return of main
/*============================================================
Project/File: digital control/ClarkPark.c
Processor: 30F2010
Frequency: XT w/PLL*8; 80MHz; 20MIPS
Copyrights: ENG. Ahmed
Date 1-st built: 6/8/2011
==============================================================
Description: This file controls Clark and Park transformation
==============================================================
*/
double angle;
struct
{
signed int Va; //this will hold converted data

119
Appendix B Software Source Code

signed int Vb;


signed int Vc;
signed int Ia;
signed int Ib;
signed int Ic;
} sample;

struct
{
signed int Ialpha; //this will hold converted
data
signed int Ibeta;
signed int Valpha;
signed int Vbeta;
signed int Id;
// input and output of Clark and park transformation
signed int Iq;
float Idf;
float Iqf;
signed int Vd;
signed int Vq;
} T;

struct // output of inverse Clark and park transformation


{
signed int Ialpha;
signed int Ibeta;
} Inv;

void Clarki() //convert ia, ib, ic =>> ialpha, ibeta


{
sample.Ic = -(sample.Ia + sample.Ib);
T.Ialpha= 0.6667*sample.Ia- 0.3333*(sample.Ic+ sample.Ib);
T.Ibeta= 0.577*(sample.Ib-sample.Ic);
}

void Parki() //convert ialpha, ibeta =>> id, iq


{
T.Id= T.Ialpha*cosf(angle)+T.Ibeta*sinf(angle);
T.Iq= -T.Ialpha*sinf(angle)+T.Ibeta*cosf(angle);
}

void InvParki() //convert id,iq => ialpha,ibeta


{
Inv.Ialpha=(outId*cosf(angle) - outIq*sinf(angle));
Inv.Ibeta= (outId*sinf(angle) + outIq*cosf(angle));

120
Appendix B Software Source Code

void Clarkv() //convert va, vb, vc =>> valpha, vbeta


{
sample.Vc = -(sample.Va + sample.Vb);
T.Valpha= 0.6667*sample.Va- 0.3333*(sample.Vc+ sample.Vb);
T.Vbeta= 0.577*(sample.Vb - sample.Vc);
}

void Parkv() //convert Valpha, Vbeta =>> Vd, Vq


{
T.Vd= T.Valpha*cosf(angle)+T.Vbeta*sinf(angle);
T.Vq= -T.Valpha*sinf(angle)+T.Vbeta*cosf(angle);
}
/*============================================================
Project/File: TEST/data.c
Processor: 30F3010
Frequency: XT w/PLL*8; 80MHz; 20MIPS
Copyrights: Eng. Ahmed
Date 1-st built: 17/8/2011
==============================================================
Description: This file holds App. global data
==============================================================
*/
#include "math.h"

// This sine-wave lookup table


const int sinetable[] ={
0,3425,6812,10125,13327,16384,19260,21926,24351,26509,28377};
/* variables declaration*/
struct //allows for bit-fields declaration
{
unsigned i :1; // interrupt flag
unsigned ref :2;
} obs;

float desIdf,desIqf,outputId,outputIq;
unsigned int outId, outIq, desId, desIq;

//makes variables static and global


struct
{
float Id; // The reference parameter
float Iq;
unsigned int P;
unsigned int Q;
float outputIq;

121
Appendix B Software Source Code

float outputId;
unsigned int k;
} ref;

struct{
float PIout;
float sum;
float intg;
float angle;
float freq;
}PLL;

/*============================================================
Project/File: digital control/initiate peripheral .c
Processor: 30F2010
Frequency: XT w/PLL*8; 80MHz; 20MIPS
Copyrights: ENG. Ahmed
Date 1-st built: 16/8/2011
==============================================================
Description: This file initiates the peripherals
============================================================
*/
void iniADC()
{
unsigned int PinConfig ,Scanselect, Adcon3_reg , Adcon2_reg
,Adcon1_reg ;
ADCON1bits.ADON = 0; /* turn off ADC */
/*configures the ADC interrupt*/
ConfigIntADC10(ADC_INT_ENABLE & ADC_INT_PRI_6 );
/*configures the ADCHS register*/
// Connect AN3,AN4,AN5=>CH0, AN0=>CH1, AN1=>CH2, AN2=>CH3,
ADCHS=0x0004;
/*configures the ADC*/
//configure AN0>>AN5 to analog input
PinConfig = ENABLE_ALL_ANA; //
//skip input scan
Scanselect = SKIP_SCAN_AN0 & SKIP_SCAN_AN1 & SKIP_SCAN_AN2
;
//configure the ADCON3 register
Adcon3_reg = ADC_SAMPLE_TIME_1 & ADC_CONV_CLK_SYSTEM &
ADC_CONV_CLK_6Tcy;
//Tconv=12*((1+6)/2)*50nsec=3usec
//configure the ADCON2 register
Adcon2_reg = ADC_VREF_AVDD_AVSS & ADC_SCAN_ON &
ADC_ALT_BUF_OFF & ADC_ALT_INPUT_OFF & ADC_CONVERT_CH_0ABC &
ADC_SAMPLES_PER_INT_4;
//configure the ADCON1 register

122
Appendix B Software Source Code

Adcon1_reg = ADC_MODULE_ON & ADC_IDLE_CONTINUE &


ADC_FORMAT_SIGN_INT& ADC_CLK_MPWM & ADC_SAMPLE_SIMULTANEOUS &
ADC_AUTO_SAMPLING_ON;
OpenADC10(Adcon1_reg,Adcon2_reg,Adcon3_reg,PinConfig,Scanselec
t);
}
/*------------------------------------------------------------
*/
void initPWM()
{
unsigned int config;
/* Holds the PWM interrupt configuration value*/
unsigned int period;
/* Holds the value to be loaded into dutycycle register */
unsigned int sptime;
/* Holds the value to be loaded into special event compare
register */
unsigned int config1; /* Holds PWM configuration value */
unsigned int config2;
/* Holds the value be loaded into PWMCON1 register */
unsigned int config3;
/* Holds the value to configure the special event trigger
post-scale and duty-cycle */
/* Configure PWM interrupt enable/disable and set interrupt
priorities */

config = (PWM_INT_EN & PWM_INT_PR4 & PWM_FLTA_EN_INT &


PWM_FLTA_INT_PR7);
ConfigIntMCPWM( config );

/*configures dead time values and clock prescalers */


SetMCPWMDeadTimeGeneration(PWM_DTAPS2 & PWM_DTA35);
// Tcy =50nsec dead time = 2*40*Tcy =4 usec

/*configures Fault A Override bits*/


SetMCPWMFaultA(PWM_OVA3H_INACTIVE & PWM_OVA2H_INACTIVE &
PWM_OVA1H_INACTIVE & PWM_OVA3L_INACTIVE & PWM_OVA2L_INACTIVE &
PWM_OVA1L_INACTIVE & PWM_FLTA_MODE_LATCH & PWM_FLTA3_EN &
PWM_FLTA2_EN & PWM_FLTA1_EN);

/* configure the motor control PWM module */


//PWM Time Base Period= 10KHZs
period = (FCY/FPWM - 1)>>3;
//contains the special event compare value to be stored in
SEVTCMP register.
sptime =2 ;
// Cannot be 0 -> turns off trigger (Missing from doc)

123
Appendix B Software Source Code

//A special event trigger will occur when the PWM time
base is counting downwards.
SEVTCMPbits.SEVTDIR=0;
//configure the PTCON register
config1 = (PWM_EN & PWM_IDLE_CON & PWM_OP_SCALE1 &
PWM_IPCLK_SCALE4 &PWM_MOD_UPDN);
//configure the PWMCON1 register
config2 = (PWM_MOD3_COMP &PWM_MOD2_COMP &PWM_MOD1_COMP &
PWM_PEN3H & PWM_PEN2H & PWM_PEN1H & PWM_PEN3L & PWM_PEN2L &
PWM_PEN1L);//configure the PWMCON2 register
config3 = (PWM_SEVOPS1 & PWM_OSYNC_PWM & PWM_UEN);
OpenMCPWM(period,sptime,config1,config2,config3);
}
/*------------------------------------------------------------
*/
void initint1()
{
ConfigINT1(FALLING_EDGE_INT & EXT_INT_PRI_5 &EXT_INT_ENABLE);
}
/*
============================================================
Project/File: FD2/interrupts.c
Processor: 30F3010
Frequency: XT w/PLL*8; 80 MHz; 20 MIPS
Copyrights: ENG. Ahmed
Date 1-st built: 20/8/2011
==============================================================
Description: This file handles Interrupt Service Routines
=============================================================*
/
//ISR ADC ----------------------------------------------------
--
void __attribute__((interrupt, auto_psv)) _ADCInterrupt()
{
if (obs.ref == 0)
{
sample.Ia=ADCBUF0; //read converted data
sample.Va=ADCBUF1;
sample.Vb=ADCBUF2;
desId =ADCBUF3+512;
obs.ref++;
toggle(_LATF2);
IFS0bits.ADIF=0; //clear ADC interrupt flag
}
else if (obs.ref == 1)
{
sample.Ib=ADCBUF0; //read converted data

124
Appendix B Software Source Code

sample.Va=ADCBUF1;
sample.Vb=ADCBUF2;
desId =ADCBUF3+512;
obs.ref++;
toggle(_LATF2);
IFS0bits.ADIF=0; //clear ADC interrupt flag
}
else if (obs.ref == 2)
{
desIq =ADCBUF0+512; //read converted data
sample.Va=ADCBUF1;
sample.Vb=ADCBUF2;
desId =ADCBUF3+512;
obs.ref=0;
toggle(_LATF2);
IFS0bits.ADIF=0; //clear ADC interrupt flag
}
}
//ISR PWM ----------------------------------------------------
--
void __attribute__((interrupt, auto_psv))_PWMInterrupt()
// PWM interrupt
{
if (SV.sector==1)
{
PDC1 =(SV.T1+SV.T2+SV.T0); // PWM 1, 2 and 3 duty cycles
PDC2 =(SV.T2+SV.T0);
PDC3 =(SV.T0);
}
else if (SV.sector==2)
{
PDC1 =(SV.T1+SV.T0);
PDC2 =(SV.T1+SV.T2+SV.T0);
PDC3 =(SV.T0);
}
else if (SV.sector==3)
{
PDC1 =(SV.T0);
PDC2 =(SV.T1+SV.T2+SV.T0);
PDC3 =(SV.T2+SV.T0);
}
else if (SV.sector==4)
{
PDC1 =(SV.T0);
PDC2 =(SV.T1+SV.T0);
PDC3 =(SV.T1+SV.T2+SV.T0);
}

125
Appendix B Software Source Code

else if (SV.sector==5)
{
PDC1 =(SV.T2+SV.T0);
PDC2 =(SV.T0);
PDC3 =(SV.T1+SV.T2+SV.T0);
}
else if (SV.sector==6)
{
PDC1 =(SV.T1+SV.T2+SV.T0);
PDC2 =(SV.T0);
PDC3 =(SV.T1+SV.T0);
}
IFS2bits.PWMIF=0; //clear RX Interrupt flag
}
//ISR int1 ---------------------------------------------------
void __attribute__((interrupt, auto_psv)) _INT1Interrupt()
//will come here whenever INT1 interrupts
{
LATE=0x00;
obs.i=1;
CloseMCPWM();
IFS1bits.INT1IF=0; //clear timer1 interrupt
flag
}
//ISR FlTA ---------------------------------------------------
void __attribute__((interrupt, auto_psv)) _FLTAInterrupt()
//will come here whenever FLTA interrupts
{
LATE=0x00;
obs.i=1;
CloseMCPWM();
IFS2bits.FLTAIF=0; //clear timer1 interrupt
flag
}
/*============================================================
Project/File: digital control/SVM.c
Processor: 30F3010
Frequency: XT w/PLL*8; 80MHz; 20MIPS
Copyrights: ENG. Ahmed
Date 1-st built: 20/8/2011
==============================================================
Description: This file controls PWM
============================================================
*/
//variables declaration
struct
{

126
Appendix B Software Source Code

long x;
unsigned int vref;
unsigned int m;
unsigned int sector;
double a2;
float th;
float th2;
float th3;
unsigned int thno;
unsigned int thno2;
unsigned int T0;
unsigned int T1;
unsigned int T2;
} SV;
unsigned int tpwm;
void SVM()
{
/*************** angle cal.****************************/
SV.a2=57.2958*angle; //*180/pi
if (SV.a2>=0) SV.th=SV.a2;
else if (SV.a2<0) SV.th= SV.a2+360;
if (SV.th<=60)SV.sector=1; // find the sector
else if (SV.th>60 && SV.th<=120) SV.sector=2;
else if (SV.th>120 && SV.th<=180) SV.sector=3;
else if (SV.th>180 && SV.th<=240) SV.sector=4;
else if (SV.th>240 && SV.th<=300) SV.sector=5;
else if (SV.th>300 && SV.th<=360) SV.sector=6;
SV.th2= SV.th -(SV.sector -1)*60; // 0< SV.th <60 in deg
SV.th3= 60-SV.th2;
SV.thno=(SV.th2*10)/60;
SV.thno2=(SV.th3*10)/60;
/**************modulation index************************/
SV.x=((long)Inv.Ialpha*(long) Inv.Ialpha+(long)
Inv.Ibeta*(long) Inv.Ibeta);
SV.vref=sqrtf(SV.x);
SV.m =(SV.vref)<<5;
Vmax=1024(2^15-2^10)
if(SV.m > 28300) {
// This is the maximum value that may be passed to the SVM
SV.m = 28300;} // function without over-modulation.
// This limit is equivalent to 0.866, which is sqrt(3)/2
*2^15.
/*************** Time intervals cal. *******************/
// calculate the total PWM count period, which is twice the
value
// in the PTPER register.
tpwm = PTPER<<1 ;

127
Appendix B Software Source Code

SV.T1 = sinetable[(unsigned char)SV.thno2];


// Look up values from table
SV.T2 = sinetable[(unsigned char)SV.thno];
// Scale t1 to by the volts variable.
SV.T1 = ((long)SV.T1*(long)SV.m) >> 15;
// Scale t1 for the duty cycle range.
SV.T1 = ((long)SV.T1*(long)tpwm) >> 15;
// Scale t2 time
SV.T2 = ((long)SV.T2*(long)SV.m) >> 15;
SV.T2 = ((long)SV.T2*(long)tpwm) >> 15;
SV.T0 = (tpwm - SV.T1 - SV.T2) >> 1;
}

III. PC Based Control Software Source Code


Public Class Form1
Dim P As String
Dim Kp1 As String
Dim x As String
Private Sub connbtn_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles connbtn.Click
If connbtn.Text = "Connect" Then
ToolStripStatusLabel2.Text = "connecting to inverter"
'SerialPort1.PortName = ComboBox1.SelectedItem
If RadioButton1.Checked Then
SerialPort1.PortName = "COM1"
ElseIf RadioButton2.Checked Then
SerialPort1.PortName = "COM2"
ElseIf RadioButton3.Checked Then
SerialPort1.PortName = "COM3"
End If
Try
SerialPort1.Open()
Catch ex As Exception
MsgBox(Err.Description)
Finally
If SerialPort1.IsOpen = True Then
ToolStripStatusLabel2.Text = "Connected to inverter"
connbtn.Text = "Disconnect"
Else
ToolStripStatusLabel2.Text = "Can not connect to Inverter"
End If
End Try
ElseIf connbtn.Text = "Disconnect" Then
ToolStripStatusLabel2.Text = "Disconnecting from inverter"
Try
SerialPort1.Close()
Catch ex As Exception
MsgBox(Err.Description)
Finally
If SerialPort1.IsOpen = False Then

128
Appendix B Software Source Code

ToolStripStatusLabel2.Text = "Disconnected from inverter"


connbtn.Text = "Connect"
Else
ToolStripStatusLabel2.Text = "Can not disconnect from Inverter"
End If
End Try
End If
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TrackBar1.Scroll
TextBox1.Text = TrackBar1.Value * 10
End Sub
Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TrackBar2.Scroll
TextBox2.Text = TrackBar2.Value * 10
End Sub
Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TrackBar3.Scroll
TextBox3.Text = TrackBar3.Value / 10
'string => hex
'TextBox4.Text = Hex(TrackBar3.Value)
' TextBox2.Text = CStr(TextBox4.Text)
End Sub
Private Sub TrackBar4_Scroll(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TrackBar4.Scroll
TextBox4.Text = TrackBar4.Value / 1000
End Sub
Private Sub TrackBar5_Scroll(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TrackBar5.Scroll
TextBox5.Text = TrackBar5.Value / 10
End Sub
Private Sub TrackBar6_Scroll(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles TrackBar6.Scroll
TextBox6.Text = TrackBar6.Value / 1000
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
If Button2.Text = "Start" Then
If SerialPort1.IsOpen = True Then
SerialPort1.Write("o")
ToolStripStatusLabel1.Text = "Inverter ON"
Button2.Text = "Stop"
ElseIf SerialPort1.IsOpen = False Then
MsgBox(" Connect to the inverter first")
End If
ElseIf Button2.Text = "Stop" Then
If SerialPort1.IsOpen = True Then
SerialPort1.Write("f")
ToolStripStatusLabel1.Text = "Inverter OFF"
Button2.Text = "Start"
ElseIf SerialPort1.IsOpen = False Then
MsgBox(" Connect to the inverter first")

129
Appendix B Software Source Code

End If
End If
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
If SerialPort1.IsOpen = True Then
SerialPort1.Write("00A")
If TrackBar1.Value < 10 Then
SerialPort1.Write(0)
SerialPort1.Write(0)
SerialPort1.Write(TrackBar1.Value)
ElseIf TrackBar1.Value >= 10 And TrackBar1.Value < 100
Then
SerialPort1.Write(0)
SerialPort1.Write(TrackBar1.Value)
ElseIf TrackBar1.Value >= 100 Then
SerialPort1.Write(TrackBar1.Value)
End If
SerialPort1.Write("A")
If TrackBar2.Value < 10 Then
SerialPort1.Write(0)
SerialPort1.Write(0)
SerialPort1.Write(TrackBar2.Value)
ElseIf TrackBar2.Value >= 10 And TrackBar2.Value < 100
Then
SerialPort1.Write(0)
SerialPort1.Write(TrackBar2.Value)
ElseIf TrackBar2.Value >= 100 Then
SerialPort1.Write(TrackBar2.Value)
End If
ElseIf SerialPort1.IsOpen = False Then
MsgBox(" Connect to the inverter first")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
If SerialPort1.IsOpen = True Then
SerialPort1.Write("00B")
If TrackBar3.Value < 10 Then
SerialPort1.Write(0)
SerialPort1.Write(0)
SerialPort1.Write(TrackBar3.Value)
ElseIf TrackBar3.Value >= 10 And TrackBar3.Value < 100
Then
SerialPort1.Write(0)
SerialPort1.Write(TrackBar3.Value)
ElseIf TrackBar3.Value >= 100 Then
SerialPort1.Write(TrackBar3.Value)
End If
SerialPort1.Write("B")
If TrackBar4.Value < 10 Then
SerialPort1.Write(0)

130
Appendix B Software Source Code

SerialPort1.Write(0)
SerialPort1.Write(TrackBar4.Value)
ElseIf TrackBar4.Value >= 10 And TrackBar4.Value < 100
Then
SerialPort1.Write(0)
SerialPort1.Write(TrackBar4.Value)
ElseIf TrackBar4.Value >= 100 Then
SerialPort1.Write(TrackBar4.Value)
End If
ElseIf SerialPort1.IsOpen = False Then
MsgBox(" Connect to the inverter first")
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button4.Click
If SerialPort1.IsOpen = True Then
SerialPort1.Write("00C")
If TrackBar5.Value < 10 Then
SerialPort1.Write(0)
SerialPort1.Write(0)
SerialPort1.Write(TrackBar5.Value)
ElseIf TrackBar5.Value >= 10 And TrackBar5.Value < 100
Then
SerialPort1.Write(0)
SerialPort1.Write(TrackBar5.Value)
ElseIf TrackBar5.Value >= 100 Then
SerialPort1.Write(TrackBar5.Value)
End If
SerialPort1.Write("C")
If TrackBar6.Value < 10 Then
SerialPort1.Write(0)
SerialPort1.Write(0)
SerialPort1.Write(TrackBar6.Value)
ElseIf TrackBar6.Value >= 10 And TrackBar6.Value < 100
Then
SerialPort1.Write(0)
SerialPort1.Write(TrackBar6.Value)
ElseIf TrackBar6.Value >= 100 Then
SerialPort1.Write(TrackBar6.Value)
End If
ElseIf SerialPort1.IsOpen = False Then
MsgBox(" Connect to the inverter first")
End If
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button10.Click
Me.Close()
End Sub
End Class

131

View publication stats

You might also like