Professional Documents
Culture Documents
Master of Science Dissertation, Digital Control Techniques For Grid-Connected Inverters, Ain Shams University, 2013. by Ahmed Abdalrahman Ahmed
Master of Science Dissertation, Digital Control Techniques For Grid-Connected Inverters, Ain Shams University, 2013. by Ahmed Abdalrahman Ahmed
net/publication/259563184
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:
All content following this page was uploaded by Ahmed Abdalrahman on 28 December 2017.
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
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.
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.
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.
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:
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.
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.
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
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
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
Chapter 1 Renewable Energy and its Applications
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.
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.
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.
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.
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.
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
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].
5
Chapter 1 Renewable Energy and its Applications
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.
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
(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.
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
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
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
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
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
16
Chapter 2 The Theory of the Grid-Connected Three-Phase 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 𝑒𝐶
𝑑𝑖𝐴
⎡ 𝑢𝐴 − 𝐿 − 𝑅𝑖𝐴 ⎤
1 1�2 −1� ⎢
2
𝑑𝑡 ⎥
𝑒𝛼 𝑑𝑖𝐵
�𝑒 � = � ⎢
−√3� � 𝑢𝐵 − 𝐿 − 𝑅𝑖𝐵 ⎥
𝛽 0 √3�2 2 ⎢ 𝑑𝑡 ⎥
⎢ 𝑑𝑖𝐶 ⎥
⎣ 𝑢 𝐶 − 𝐿 − 𝑅𝑖𝐶 ⎦
𝑑𝑡
𝑑𝑖𝛼
𝑢𝛼 − 𝐿 − 𝑅𝑖𝛼
𝑑𝑡
=� 𝑑𝑖𝛽 � Equation 2.4
𝑢𝛽 − 𝐿 − 𝑅𝑖𝛽
𝑑𝑡
𝑒𝑑 cos 𝜔𝑡 sin 𝜔𝑡 𝑒𝛼
�𝑒 � = � �� � Equation 2.5
𝑞 − sin 𝜔𝑡 cos 𝜔𝑡 𝑒𝛽
𝑑𝑖𝛼
𝐿
𝑒𝑑 cos 𝜔𝑡 sin 𝜔𝑡 𝑢𝛼 cos 𝜔𝑡 sin 𝜔𝑡 cos 𝜔𝑡 sin 𝜔𝑡 𝑅𝑖𝛼
�𝑒 � = � � �𝑢 � − � � � 𝑑𝑡 � − � �� �
𝑞 − sin 𝜔𝑡 cos 𝜔𝑡 𝛽 − 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
𝑞 𝑑𝑡 𝑞 𝑞 𝑖𝑑 𝑞
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]:
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
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.
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.
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.
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].
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.
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 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
𝑢�𝑞 = 𝑢𝑞 − 𝑒𝑞 − 𝜔𝐿𝑖𝑑
𝑑𝑖𝑑
𝑢�𝑑 = 𝐿 + 𝑅𝑖𝑑
𝑑𝑡
� 𝑑𝑖𝑞 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:
The d-axis reference voltage and q-axis reference voltage are expressed as follows:
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].
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
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.
27
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter
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.
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
28
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter
√3
𝑢
� 𝑎𝑏1 = 𝑚𝑈𝑑𝑐 ; 0 < 𝑚 ≤ 1
2
Equation 2.13
29
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter
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.
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
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]:
𝑈𝛽
θ = 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
32
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter
𝐹𝑠
𝐹𝑠𝑛 = Equation 2.23
𝑓
𝐹𝑠 = 6𝑁 Equation 2.22
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 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.
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].
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.
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.
35
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter
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.
36
Chapter 2 The Theory of the Grid-Connected Three-Phase Inverter
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].
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]:
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
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.
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.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
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:
44
Chapter 3 System Simulation
Each one of these steps is explained and its corresponding output waveforms are showed in
the following subsections.
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β.
46
Chapter 3 System Simulation
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.
47
Chapter 3 System Simulation
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.
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
49
Chapter 3 System Simulation
50
Chapter 3
51
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.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
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.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
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.
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.
58
Chapter 3 System Simulation
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
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.
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:
2
International Rectifier Co.
64
Chapter 4 System Implementation
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
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
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.
4
Labcenter Electronics Ltd.
67
Chapter 4 System Implementation
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:
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
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
70
Chapter 4 System Implementation
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
74
Chapter 4 System Implementation
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].
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.
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.
76
Chapter 4 System Implementation
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.
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.
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.
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
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.
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
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.
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.
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.
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.
84
Chapter 4 System Implementation
math.h The header file math.h consists of a macro and various functions that
calculate common mathematical operations.
GENRAL.c Store constant names and macros used all over the program.
DATA.c This file holds Application global data and performs variables
declaration.
85
Chapter 4 System Implementation
86
Chapter 4 System Implementation
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)
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.
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.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
94
Chapter 4 System Implementation
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.
96
Conclusions & Future Work
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 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.
[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.
[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
[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.
[17] Simone Buso and Paolo Mattavelli. Digital Control in Power electronics.
2006.
102
Bibliography
[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.
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.
[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.
[34] Microchip Technology Inc. MPLAB® C30 C compiler user’s guide. 2007.
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].
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
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
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.
110
Appendix B Software Source Code
// 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
111
Appendix B Software Source Code
//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
//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
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);
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
}
/*---------------------------------------------------*/
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!
117
Appendix B Software Source Code
_TRISD0=1;
_TRISE8=1;
_TRISD1=0;
TRISF=0; //sets PORTD to all outputs
// 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
PID(&fooPID2); ;
outputIq = Fract2Float(fooPID2.controlOutput);
PID(&fooPID3); ;
outputId = Fract2Float(fooPID3.controlOutput);
119
Appendix B Software Source Code
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;
120
Appendix B Software Source Code
float desIdf,desIqf,outputId,outputIq;
unsigned int outId, outIq, desId, desIq;
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
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
128
Appendix B Software Source Code
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