Sunteți pe pagina 1din 55

TRIBHUVAN UNIVERSITY

INSTITUTE OF ENGINEERING
PULCHOWK CAMPUS

A
Final Year Project Report
on
Constant V/Hz Inverter based on
Sinusoidal PWM technique
(As a partial fulfillment of the requirement for the Bachelor’s degree in Electrical Engineering)
(EG777EE)

Project Supervisor
Prof. Dr. Indraman Tamrakar

Project Members
Ayush Shakya (065/BEL/302)
Deepa K.C. (065/BEL/305)
Labi Bajracharya (065/BEL/310)
Sadam Bala (065/BEL/332)
Sandesh Kunwar (065/BEL/333)

October 2012
TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
PULCHOWK CAMPUS

The undersigned certify that they have read and recommended to the Institute of
Engineering for acceptance of a final year project report entitled, ‘Constant V/Hz
inverter based on Sinusoidal PWM technique’ submitted by Ayush Shakya, Deepa
K.C., Labi Bajracharya, Sadam Bala and Sandesh Kunwar in partial fulfillment of the
requirements for the Bachelor’s Degree of Electrical Engineering.

________________________________________________ ________________________________________________
Project Supervisor Head of Department
Prof. Dr. Indraman Tamrakar Assoc. Prof. Kumudini Koirala
Department of Electrical Engineering Department of Electrical Engineering

________________________________________________ ________________________________________________
External Examiner External Examiner
Dr. Laxmi Bhakta Shilpakar Er. Ramesh Shrestha
Member, Public Enterprises Board Principal, Sagarmatha Engineering College

ii
COPYRIGHT

The author has agreed that the Library, Department of Electrical Engineering,
Pulchowk Campus, Institute of Engineering (IOE) may make this report freely available
for inspection. Moreover, the author has agreed that permission for extensive copying
of this project report for scholarly purpose may be granted by the supervisors who
supervised the project work recorded herein or, in their absence, by the Head of the
Department wherein the project report was done. It is understood that the recognition
will be given to the author of this report and to the Department of Electrical
Engineering, Pulchowk Campus, Institute of Engineering in any use of the material of
this project report. Copying or publication or the other use of this report for financial
gain without approval of to the Department of Electrical Engineering, Pulchowk
Campus, Institute of Engineering and author’s written permission is prohibited.
Request for permission to copy or to make any other use of the material in this report
in whole or in part should be addressed to:

Head of Department
Department of Electrical Engineering
Pulchowk Campus, Institute of Engineering (IOE)
Lalitpur, Nepal

iii
ACKNOWLEDGEMENT

We are greatly indebted to all those who have helped us in our project entitled, ‘Constant
Volt-Hertz Inverter using Sinusoidal PWM technique’. We would like to express our
sincere gratitude to our Supervisor Prof. Dr. Indraman Tamrakar for guiding us for our
project. His valuable advice, suggestions, instructive guidance and co-operative supervision
has been one of the very motivating factors for the completion of our project.

We would also like to express our deep thank to Head of Department, Mrs. Kumudini
Koirala and Deputy Head of Department, Er. Dipesh Lamsal for providing us with the well
equipped laboratory and sophisticated equipments. Without their help and support, our
project would face many hurdles.

We are also thankful to Mr. Deepak Shrestha, Chief Instructor of Instrumentation and
Control laboratory, for his generous help in providing us with the necessary equipment. We
are also indebted to Mr. Madhusudan Shrestha for supporting us in completion of our
project.

Our special thanks go to the Department of Electrical Engineering and all its staffs for
providing us good environment and lots of cooperation to conduct this project.

Last but not the least, we would also like to express our deep gratitude to our families and
friends in creating an environment to accomplish this project. Without their love and
affection, we would not be in a state to submit this report.

Ayush Shakya (065/BEL/302)


Deepa K.C. (065/BEL/305)
Labi Bajracharya (065/BEL/310)
Sadam Bala (065/BEL/332)
Sandesh Kunwar (065/BEL/333)

iv
ABSTRACT

Modern sophisticated power appliances and machine system demand adjustable sources at
many instances. This is not possible with in hand available constant AC supply system. So,
inverter technology has been extensively developed for adjustable voltage source. One of the
various adjustable AC source requires constant ratio of volt to hertz at output. Constant
volt/hertz inverter is able to supply adjustable AC source while maintaining constant
volt/hertz ratio at output. Sinusoidal PWM generated using digital technology has been
employed as control strategy in constant V/Hz inverter. The final ‘Constant V/Hz inverter’
hardware system was designed and fabricated after successful software simulations in
Proteus and MATLAB. The simulated results and the actual hardware results were compared
and they were found to be similar. This system finds its application in electrical appliances
and machine employing variable induction motor drive.

v
TABLE OF CONTENTS

Title Page
No.
CHAPTER 1: INTRODUCTION
1.1 Background 1
1.2 Objectives 1
1.3 Scope of the project 2
1.4 Methodology 2

CHAPTER 2: INVERTER SYSTEM


2.1 Voltage Source Inverter (VSI) 3
2.2 Pulse Width Modulation (PWM) 3
2.3 Generation of SPWM using Analog System 4
2.4 Generation of three phase VSI SPWM using Digital System 5
2.4.1 Using look-up table to generate sine wave 6
2.4.2 Changing the frequency of the sine wave 9
2.5 Mathematical Analysis for constant V/Hz inverter 10

CHAPTER 3: SIMULATION STUDIES


3.1 MATLAB Simulation 12
3.2 Software realization 15
3.3 Proteus Simulation 16

CHAPTER 4: HARDWARE DESIGN AND DESCRIPTION


4.1 Description of the proposed scheme 19
4.2 Components used in inverter
4.2.1 Adjustable Voltage regulator 21
4.2.2 Optocoupler 21
4.2.3 MOSFET as a switch 22
4.2.4 MOSFET driver 24
4.3 Hardware results 26
4.3.1 Experiment results 28

CHAPTER 5: CONCLUSION AND RECOMMENDATION


5.1 Conclusion 30
5.2 Recommendation 30

BIBLIOGRAPHY 31

vi
LIST OF FIGURES
Page
No.
1. Figure 2.1: Duty cycle and frequency of PWM 3
2. Figure 2.2: Single phase half-bridge topology 4
3. Figure 2.3: SPWM Generation principle 5
4. Figure 2.4: Three phase VSI topology 5
5. Figure 2.5: Complementary PWM signals(10kHz) generated by microcontroller 6
6. Figure 2.6: Diagram showing the scaling operation to generate the required duty cycle
from the sine table 7
7. Figure 2.7 Gate signal pattern for upper switch and corresponding complementary gate
signal for lower switch 8
8. Figure 2.8 Changing Vmod through PWM pattern where, M.I (a) > M.I (b) > M.I(c) 9
9. Figure 3.1: Constant V/f PWM generator block 13
10. Figure 3.2: Inverter bridge 13
11. Figure 3.3: Output waveforms of MATLAB simulation 14
12. Figure 3.4: Layout for Proteus Simulation 16
13. Figure 3.5: PWM signal generation from microcontroller with PWM frequency of 10 kHz 16
14. Figure 3.6: Line-to-line voltage waveform (Proteus Simulation) 17
15. Figure 3.7: Line-to-neutral voltage waveform (Proteus Simulation) 18
16. Figure 4.1: Block diagram of the proposed scheme 19
17. Figure 4.2: MOSFET Inverter Bridge 20
18. Figure 4.3: LM317 Typical Connection 21
19. Figure 4.4: Optocoupler Schematic 21
20. Figure 4.5: Optocoupler IC package 21
21. Figure 4.6: I-V characteristics of MOSFET 23
22. Figure 4.7: Power MOSFET Schematic 23
23. Figure 4.8: Fabrication of Hardware (Microcontroller Part) 25
24. Figure 4.9: Fabrication of Hardware (Three Phase Inverter Part) 26
25. Figure 4.10: Complementary PWM outputs (from Digital Oscilloscope) 26
26. Figure 4.11: Complete train of pulses for a complete cycle with complementary outputs 27
27. Figure 4.12: Line-to-neutral voltage waveform (Hardware result) 27
28. Figure 4.13: Line-to-Line voltage waveform (Hardware result) 28

vii
CHAPTER 1
INTRODUCTION

1.1 Background
After long debates in the past, it is proven that AC transmission and distribution is more
economical and reliable than DC. Hence, AC transmission and distribution is used widely
which has resulted in growing popularity of AC based appliances. AC can also be divided as
single phase or three phases. Three phase AC is more popular in high power application
while single phase is used in home appliances and low power systems.

Even though constant AC sources are readily available, in many cases we need to control the
frequency and magnitude of output voltage of the available AC source. Speed Control of
induction motors, used in various appliances and machines like conveyer belt, air
conditioner, pumps, electric traction, etc is one of the examples where it is necessary to
control the frequency for controlling the speed of the motor to match the variable torque,
power and speed requirement. Due to robust and rugged structure, induction motors are more
popular than DC motors. But speed control of AC motor is not as simple as that of DC
motors due to complex torque-speed characteristics of AC induction motor. So, it requires
special control system like constant Volt/Hz Inverter.

Constant Volt/Hertz Inverter is the inverter which maintains the ratio of magnitude of output
AC voltage to frequency constant. This inverter finds its application for control of AC motor
drive which implements constant V/f speed control method. One of the most popular control
strategies used for variable AC output from inverter is Pulse Width Modulation (PWM)
technique which controls the duty cycle of the controller switches at high switching
frequency to achieve controlled AC output from inverter. In this project, sinusoidal PWM
technique is used to control the magnitude of output AC voltage from the inverter
maintaining constant V/f ratio.

1.2 Objective
 To design and fabricate constant volt/hertz inverter
The major objective of this project is to develop a control strategy to change voltage when
frequency is varied externally so as to maintain a constant volt/hertz inverter.
1
1.3 Scope of the project
In this project, there is provision of changing voltage by varying frequency externally so as
to maintain a constant voltage to frequency ratio. This project is microcontroller based and is
easily controllable. It has wide range of applications when employed for controlling speed of
a three phase induction motor in industrial sectors.

1.4 Methodology
In order to carry out the mentioned objectives, the following methodology will be adopted:
1. Preliminary study of inverter, particularly constant Volt/Hertz Inverter
2. Simulations of constant Volt/Hertz Inverter on MATLAB/Simulink
3. Programming in MPLAB software for dsPIC microcontroller
4. Simulation of constant Volt/Hertz Inverter in Proteus software to determine required
parameters of the hardware using the microcontroller
5. Design and fabrication of hardware of the proposed scheme
6. Testing and debugging of fabricated hardware
7. Final report of the project illustrating activities and results obtained

2
CHAPTER 2

INVERTER SYSTEM

2.1 Voltage Source Inverter (VSI)


Inverter is an electrical converter system which is able to convert DC supply to AC output at
desired magnitude and frequency level. Voltage source inverter is the inverter topology
where independently controlled AC output is voltage signal. The AC output voltage from
inverter may be either fixed or variable. The input DC source may be fixed DC source or it
may be rectified from fixed AC source. This DC voltage is converted to AC by using
network of switches to alternate between positive and negative DC buses. The output
magnitude and frequency is varied by controlling the switching sequence which is done by
various modulating techniques. In this project, sinusoidal PWM generated using
microcontroller is used as modulating signal to control the switching sequence.

2.2 Pulse Width Modulation (PWM)

Pulse Width Modulation (PWM) refers to a form of signal modulation where data is
represented by the duty cycle (ratio of the ON time to the total time).PWM has the property
where the instantaneous DC component is directly proportional to the duty cycle. By using
PWM techniques, the frequency spectra of input waveforms can be changed such that the
major non-fundamental components are at relatively high frequency and also to reduce the
switching stress imposed upon the power switching devices. The high frequency components
can be filtered by using low pass filters so as to reduce the harmonic distortion at output.

Figure 2.1 shows the duty cycle and frequency of PWM.


The relationship between the time average voltage, Vavg,
the high and low voltage of the square wave (Vhi and Vlo)
and the duty cycle (D) in percent is as follows:
Vavg = (Vhi – Vlo) * D + Voffset
Figure 2.1: Duty Cycle and Frequency of
PWM

3
Where,
tON
D=
tW
1
And fPWM=
tw

2.3 Generation of SPWM using Analog System


Basically there are two types of PWM techniques- Analog System and Digital PWM
technique. Figure 2.2 shows the single phase half bridge topology of inverter. In Analog
PWM technique, which is also a conventional system, a carrier signal and modulating signal
are compared using a comparator and output of the comparator is desired PWM signal. For
sinusoidal PWM technique, the reference waveform is a sinusoidal wave and the carrier
waveform is triangular and hence the width of output PWM signal varies sinusoidally as
shown in figure 2.3. Sine wave and triangular waves are generated using analog techniques
and compared using a comparator. Output voltage amplitude can be controlled by controlling
the Modulation Index of the system. The frequency of the system can be varied by changing
the frequency modulation index.

Figure 2.2: Single phase half bridge topology

4
Figure 2.3: SPWM Generation principle

2.4 Generation of three phase VSI SPWM using Digital System


The proposed alternative approach is to replace the conventional method of generation of
SPWM by the use of microcontroller. Digital PWM techniques are applied using
quantization method. Most of the digital techniques employ counter and comparator based
system. Digital systems are more flexible, less sensitive to environmental noise and simpler
in construction in comparison to the analog techniques. Digital PWM technique can be
easily applied by using digital technologies like microcontroller.

Vdc
2

Vdc
2

Figure 1.4: Three phase VSI topology

Figure 2.4 shows the three phase topology of full bridge inverter. SPWM can be generated
using digital logic equipments like microcontroller by using sine table. Complementary
PWM outputs are generated from a microcontroller using its PWM module. Altogether,
there are six PWM channels with three PWM pairs configured in complementary mode for
the three arms of the inverter. In complementary mode, if one of the PWM is high, the other
is low and vice-versa as shown in figure below. A certain programmable dead time is
inserted so that upper and lower switches of the H-bridge are not simultaneously ‘ON’ to
prevent short circuiting of the DC bus. This PWM technique is applied by using PWM
5
module of dsPIC microcontroller for generating required PWM control signals for this
project. Complementary PWM signals (10 kHz) generated by dsPIC microcontroller with
2µs dead time between the two signals is shown in figure 2.5.
PWM High Side

PWM Low Side


Figure 2.5: Complementary PWM signals (10 kHz) generated by microcontroller

Consider a single phase half bridge as shown with load connected at point ‘a’ as shown in
figure 2.2. If the complementary outputs have a 50 % duty cycle, then for half of the time,
the upper switch is ON and the voltage across the load is +VDC/2 with respect to point ‘N’
and for the next half of the period, the lower switch is ON (with upper switch now in OFF
state) and so the voltage across the load is –VDC/2. Therefore, 50 % duty cycle corresponds
to average voltage of zero volts averaged over a PWM period in complementary mode.

2.4.1 Using look-up table to generate sine wave

Sinusoidal waveform can be generated by using a look-up table. A look-up table contains,
sine values for a complete electrical cycle (0 to 360 degrees), normalized in the range -1 to 1.
The number of data points to be used depends upon the PWM frequency and the modulation
frequency i.e. frequency of sine wave to be generated. Also, too little points will cause a
‘staircase’ effect in the motor current waveform. The staircase effect will cause excessive
motor current distortion, which causes higher heat dissipation. Too many points will use
more memory of the microcontroller. A good rule of thumb is to divide maximum desired
modulation frequency by the PWM frequency.

In this project, 256 points have been used in sine table for a 10 kHz PWM frequency and
maximum modulating frequency of 77.97 Hz.

The sine values for the 256 different points can be evaluated by the expression;
6

y[i] = sin ×i
256
where, i = 0 to 255

The sine values are read from the table at periodic interval, scaled to match the allowable
ranges of duty cycle, and then written to the duty cycle register. If any numerical value is put
in the duty cycle register then the microcontroller produces output PWM waveform of that
particular duty cycle.

At first, the data from table is first multiplied by 50 percent duty cycle value. The resulting
value is then multiplied by the value of modulation index (M.I) to change the average
voltage of through the variation of pulse widths. Finally, 50 percent duty cycle value is then
added to ensure that resulting duty cycle value is positive.

Sine table[i] = y[i] * 50 percent duty cycle * M.I + 50 percent duty cycle

Figure 2.6: Diagram showing the scaling operation to generate the required duty cycle from
the sine table

Figure 2.6 shows the scaling process carried so that duty cycle values are obtained
sinusoidally. Figure 2.7 shows the PWM signals for the upper and lower switch and shows
the variation of duty cycle over a completer electrical cycle for modulation index value of
one. It can be seen that at zero electrical degree of sine wave, the duty cycle of the high side
PWM is 50%, therefore the average voltage is zero for a PWM period as the lower switch is
also ‘ON’ for remaining 50% of the PWM period. At around 90 electrical degree, the upper
switch is ‘ON’ for all PWM period (i.e 100% duty cycle), so the output is high during this
period and voltage across the load is +VDC/2 with respect to point ’N’. But, at around 270
electrical degrees, the upper switch is ‘OFF’ for whole PWM period (i.e. 0% duty cycle)
7
while the lower switch is ‘ON’ for full PWM period. So, the output voltage is negative and
voltage across the load is –VDC/2. Similarly, at other electrical degrees, the duty cycle varies
sinusoidally so as to encode the sinusoidal signal in the PWM waveform.

50% duty 0% duty 50% duty 100% duty 50% duty

Figure 2.7: Gate signal pattern for upper switch and corresponding complementary gate
signal for lower switch

8
Figure 2.8 given shows the effect of changing the modulation index on the variation of pulse
width, thereby changing the amplitude of the fundamental voltage component.

Figure 2.8: Changing Vmod through PWM pattern where, M.I (a) > M.I (b) > M.I(c)

2.4.2 Changing the frequency of the sine wave

A variable called ‘Phase’ is used as a 16-bit pointer to the sine table with 0x0000
representing 0° and 0xFFFF representing 360°. Let us assume the sine table pointer is
adjusted every PWM period. In other words, at each PWM interrupt, ‘Frequency’ variable is
added to the ‘Phase’. The value of ‘Delta_Phase’ determines how fast the code moves
through the sinusoidal data table, and, as a result, sets the modulation frequency.

The Frequency variable is calculated as follows:


Desired modulation frequency (in Hz)
Delta_phase = 2 ×
F

For example, to get a 76 Hz modulation frequency using 10 KHz PWM frequency

9
76
Delta_phase = 216 × =498.07=498
10000

After the Phase variable has been adjusted by Delta_Phase, two additional table pointers are
calculated for the 2nd and 3rd motor phases by adding a constant offset to Phase. For a 16-bit
pointer, a value of 0x5555 provides 120° offset and a value of 0xAAAA gives a 240° offset.

2.5 Mathematical Analysis of Constant Volt/Hertz Inverter

The Sine PWM is implemented using a VSI (Voltage Source Inverter) as shown in figure
2.4. At any instant, either the top or the bottom switch of a half bridge is on. Hence, the
resultant fundamental component of phase-to-neutral point ‘O’ voltage (VAO, VBO and VCO)
can be represented as:
Vdc
Vio= ×Vif
2
Where i = A,B,C
Vif represents the 3-phase waveforms shifted at an angle of 120° with one another. Each
phase waveform can be represented as shown below:
VAf = m × sinθ
VBf = m × sin (θ+120°)
VCf = m × sin (θ+240°)
Vdc
∴VAO= ×m× sin θ
2
Vdc
VBO= × m× sin (θ+120°)
2
Vdc
VCO= × m × (θ+240°)
2
The resultant line-to-line output voltage is given by:
√(3)Vdc
VAB = VAO-VBO = ×m× sin (θ+30°)
2
√(3)Vdc
VBC = VBO-VCO = ×m× sin (θ+150°)
2
√(3)Vdc
VCA = VCO-VAO = ×m× sin (θ+270°)
2
From the above equations, it is clear that the maximum line-to line voltage is achieved when
m=1
10
√3 Vdc
. . Maximum line-to-line voltage =
2
Vdc
√2×VLL(rms)= √3
2
∴VLL(rms)= 0.612 Vdc
VLL(rms) 0.612
Vph(rms) = = × Vdc = 0.354Vdc
√3 √3
These equations are valid for modulation index, M.I. = m = 1. For any value of m, the
following equations will be valid.
∴VLL(rms)= 0.612 m Vdc
VLL(rms) m 0.612
Vph(rms)= = × Vdc = 0.354 m Vdc
√3 √3
Vreq
Let us assume that =k (a)
freq
Where k = constant
Dividing both sides of equation (a) by Vph(rms) with m=1, we get
Vreq k
=
Vph(rms)×f Vph(rms)
Vreq k
or, m= = ×f
Vph(rms) Vph(rms)

11
CHAPTER 3
SIMULATION STUDIES

Before carrying out activities in hardware, simulations were carried out in software such as
MATLAB/Simulink and Proteus. This chapter is mainly concerned with the simulations in
these software.

3.1 MATLAB Simulation


MATLAB simulation was performed to test and confirm its implementation in a real
hardware. The major components of the Simulink model as shown in figure 3.1 are given
below:
1. Clock
2. Programming block
3. PWM generator block

1. Clock: This block is used to provide current simulation real time for the program.
2. Programming block: It is a block where program can be written. This block is used
in this model for specifying modulation index and frequency input to the PWM
generator block.
3. PWM generator block: This block generates sinusoidal PWM signals for
MOSFETs used in the three phase H-bridge.

Constant V/f PWM generator block simulates the working of microcontroller, which
generates constant V/f PWM outputs. With the help of programming block, required V/f
ratio and output as per the real time could be obtained and modulation index and frequency
are fed to PWM generator, which generates sine PWM signals to provide it to the gates of
the inverter.

12
Programming block

Figure 3.1: Constant V/f PWM generator block

Figure 3.2: Inverter bridge


Figure 3.2 shows the inverter bridge which comprises of six MOSFETS. The gating signals
generated from the PWM generator are fed to the gates of the MOSFET blocks. The three
phase outputs are fed to the three phase load. Here three phase load is taken as resistive.

13
Figure 3.3: Output waveforms

14
3.2 Software realization
Fmin = minimum frequency to be generated
MImin =minimum modulation index
Fbase = arbitrarily set frequency above which Modulation Index become 1

Flowchart of the process used in constant Volt-hertz inverter

Start

Initialization of constant V/f ratio (K)


`

Frequency (f) input from potentiometer knob

Yes
Set Modulation Index = MImin
Is f<fmin ?
and f =fmin
No
Yes
Is f>fbase? Set Modulation Index = 1

No

Calculation of Modulation Index


M.I = K/Vph(max) *f

Computation of duty cycles for the six PWM


waveforms from the Sine lookup table based
on ‘f’ and ‘M.I’

Generation of the required PWM waveforms


based on the calculated duty cycles

15
3.3 Proteus Simulation
After performing simulations on MATLAB, further simulations were carried out on Proteus.
Before this, programming was done in MPLAB and the hex code, thus generated after
compilation of the source code, was loaded in the microcontroller. The layout of Proteus
simulation is shown in figure 3.4. The load used in this simulation is three-phase resistive
load. The PWM waveforms generated from the microcontroller are shown in the figures 3.5.

Figure 3.4: Layout for Proteus Simulation

Figure 3.5: PWM signal generation from microcontroller with PWM frequency of 10 kHz
16
In figure 3.5, PWMH1 and PWML1 are complementary PWM outputs from the
microcontroller for producing gate signals for the first arm of the three-phase H-bridge.
Similarly, PWMH2 and PWML2 are complementary PWM outputs from the microcontroller
for producing gate signals for the second arm of the bridge. Figure 3.6 and 3.7 show the
output waveforms.

Figure 3.6: Line-to-line voltage waveform

17
Figure 3.7: Line-to-neutral voltage waveform

18
CHAPTER 4

HARDWARE DESIGN AND FABRICATION

4.1 Description of the proposed scheme


This scheme is design of the three phase inverter to drive or supply any load which required
constant V/F such as induction motor. This drive generates the output voltage in proportion
to the output frequency to provide a relatively constant ratio of voltage to frequency (V/Hz).

Sinusoidal pulse width modulation (SPWM) is widely used in power electronics to digitize
the power so that a sequence of voltage pulses can be generated by ON and OFF of the
power switches. The pulse width modulation inverter is simple and provides better control
scheme. SPWM techniques are characterized by constant amplitude pulses with different
duty cycle for each period. The width of this pulses are modulated to obtain inverter output
voltage control and to reduce its harmonic content. To generate this signal, triangular wave
is used as a carrier signal and is compared with sinusoidal wave, whose frequency is the
desired frequency. The proposed alternative approach is to replace the conventional method
with the use of microcontroller. The use of microcontroller brings the flexibility to change
the real-time control algorithms without further changes in hardware. It is also low cost and
has a small size of control circuit for the three phase full bridge inverter. The microcontroller
has the built in dead time control circuit and various other features to control pwm signals.

AC
POWER
DC VOLTAGE AC
SUPPLY
LINK SUPPLY VOLTAGE
RECTIFIER MOSFET INVERTER THREE PHASE
BRIDGE LOAD

ISOLATION
MICROCONTROLLER CIRCUIT

Figure 4.1: Block diagram of the proposed scheme

19
a. Rectifier: The first step in this process is to convert the AC supply voltage into DC by the
use of a rectifier. DC power contains voltage ripples which are smoothed using filter
capacitors. This section of the VFD is often referred to as the DC link. In our project,
rectifier is not used. Instead, dc supply is directly taken from the available dc bank.

b. MOSFET Inverter Bridge: This DC voltage is then converted back into AC. This
conversion is typically achieved through the use of power electronic devices such as IGBT
power transistors or MOSFETs using a technique called Pulse width Modulation (PWM).
The output voltage is turned on and off at a high frequency, with the duration of on-time, or
width of the pulse, controlled to approximate a sinusoidal waveform. The MOSFET inverter
bridge has 6 switches that are controlled in order to generate 3-phase AC output from the DC
bus. PWM signals, generated from the microcontroller, control these 6 switches. Switches
H1 through H3 are upper switches. Switches L1 through L3 are lower switches. The
amplitude of phase voltage is determined by the duty cycle of the PWM signals. In this
configuration, three out of six switches will be on at any given time; either one upper and
two lower switches or one lower and two upper switches. The switching produces a
rectangular shaped output waveform that is rich in harmonics. When switches are turned off,
the inductive nature of the load oppose any sudden change in direction of flow of the current
until all of the energy stored in the load is dissipated. To facilitate this, fast recovery diodes
are provided across each switch. These diodes are known as freewheeling diodes.

H1 H2 H3
THREE
PHASE
L1 L2 L3
LOAD

Figure 4.2: MOSFET Inverter Bridge

c. Microcontroller: The microcontroller used is dsPIC33FJ32MC202. It consists of 6 PWM


channels, one channel for each of the semiconductor switches.

20
d. Isolation Circuit: The isolation circuit is used to isolate low voltage signals from high
voltage signals for protection and safety. This can be done by using optoisolator.

4.2 Components used in inverter

4.2.1 Adjustable Voltage Regulator


The LM317 is an adjustable 3-terminal
positive voltage regulator capable of supplying
in excess of 1.5A over an output voltage range
of 1.2 V to 37 V. This voltage regulator is
exceptionally easy to use and requires only
two external resistors to set the output voltage.
Further, it employs internal current limiting;
thermal shutdown and safe area compensation, making it
Figure 4.3: LM317 Typical
essentially blow-out proof. Connection

Here, as shown in the adjacent figure, Cin is required if regulator is located at an appreciable
distance from power supply filter. Co is not needed for stability; however, it does improve
transient response. The datasheet of LM317 can be found in Appendix B.

4.2.2 Optocoupler
Certain isolation system between high voltage level and low
voltage level is required in Constant V/Hz Inverter system.

The microcontroller which is operating at low voltage level Figure 4.4: Optocoupler Schematic
(3.3V) has to control load which is at much higher voltage level. So,
the microcontroller needs to be isolated to protect from overvoltage
damage. Optocoupler can provide such isolation. It is also known as
optoisolators.

Optocouplers are basically small electronics device which


Figure 4.5: Optocoupler IC
facilitates the transmission of electrical signal between two package
parts of a system while keeping them electrically isolated.
They use beam of light to transmit the signal while maintaining excellent isolation.
21
Basically, there are two parts of optocoupler: an optical transmitter (LED) and an opto-
receiver (phototransistor) separated by transparent barrier which allows light to pass through
it but does not allow any electrical transmission. The main purpose of an opto-isolator is to
prevent high voltages or rapidly changing voltages on one side of the circuit from damaging
components or distorting transmissions on the other side. Commercially available opto-
isolators can withstand input-to-output voltages up to 10 kV.

They are best for transmitting PWM signals with frequent switching. In this project, high
speed 6N137 logic gate optocoupler is selected. The datasheet of this optocoupler is given in
Appendix B.

4.2.3 MOSFET as switch


The MOSFET (Metal Oxide Semiconductor Field Effect Transistor) is a transistor used for
amplifying or switching electronic signals. MOSFETs are commonly used as switching
devices in inverter. MOSFET have three terminals namely gate, drain and source. When
used as switching device, MOSFET is voltage controlled switch.

The threshold voltage between gate and drain determines the switching level of the
MOSFET switch. By applying suitable drive voltage to the gate of MOSFET, the resistance
of drain source channel can be varied from very high value (OFF state), effectively an open
circuit, to very low value (ON state), effectively short circuit. MOSFETs can be effectively
turned on and off at very high switching frequency to pass current through it. MOSFETs are
more efficient and faster in comparison to same rating of bipolar transistor switches and
IGBTs. Features like fast switching speed, high peak current, ease of drive, dv/dt capability
has boosted the popularity of MOSFETs as logic switches.

Enhancement mode MOSFET has been used in our project for switching electronic signals.
Enhancement mode MOSFET can be taken as a switch as these transistors require a positive
gate voltage to turn 0N and a zero voltage to turn 0FF making them easily understood as
switches and also easy to interface with logic gates.

The operation of the enhancement mode MOSFET can best be described using its I-V
characteristics curves shown below. When the Input voltage, (Vin) to the gate of the

22
transistor is zero, the MOSFET conducts virtually no current and the output voltage (Vout) is
equal to the supply voltage (VDD). So the MOSFET is fully-OFF and in its cut-off region.

Figure 4.7: Power MOSFET


Schematic

Figure 4.6: I-V characteristics of MOSFET

The minimum ON-state gate voltage required to ensure that the MOSFET remains fully-ON
when carrying the selected drain current can be determined from the V-I transfer curves
above. When VIN is high or equal to VDD the MOSFET Q-point moves to point A along the
load line. The drain current (ID) increases to its maximum value due to reduction in the
channel resistance. ID becomes a constant value independent of VDD, and is dependent only
on gate source voltage(VGS). Therefore, the transistor behaves like a closed switch but the
channel on-resistance does not reduce fully to zero due to its R DS(on) value, but gets very
small.

Likewise, when Vin is low or reduced to zero the MOSFET Q-point moves from point A to
point B along the load line. The channel resistance is very high so the transistor acts like an
open circuit and no current flows through the channel. So if the gate voltage of the MOSFET
toggles between two values, high and low the MOSFET well behave as a single-pole single-
throw (SPST) solid state switch.

Cut off region


Here the operating conditions of the transistor are zero input gate voltage (V IN), zero drain
current ID and output voltage VDS = VDD .Therefore the MOSFET is switched Fully-OFF.

23
Saturation region
In the saturation or linear region, the transistor will be biased so that the maximum amount
of gate voltage is applied to the device which results in the channel resistance R DS (on) being
as small as possible with maximum drain current flowing through the MOSFET switch.
Therefore the MOSFET is switched fully 0N.

Six IRF840 MOSFETs are used in this project as switches. The datasheet of IR840 is
included in Appendix B.

4.2.4 MOSFET Driver


To turn a power MOSFET on, the gate terminal must be set to a voltage at least 10 V greater
than the source terminal. This is comfortably above the VGS (Th) (Gate Threshold Voltage)
parameter which is defined as the minimum voltage required between the gate and source
terminals to turn the MOSFET on. It will need more than this to turn it fully ON.

One feature of power MOSFETs is that they have a large stray capacitance between the gate
and the other terminal. The effect of this is that when the pulse to the gate terminal arrives, it
must first charge this capacitance up before the gate voltage can reach the 10 V required.
The gate terminal then effectively takes current. Therefore the circuit that drives the gate
terminal should be capable of supplying a reasonable current so the stray capacitance can be
charged up as quickly as possible. The best way to do this is to use a dedicated MOSFET
driver chip.

Three IRS2110 high and low side MOSFET driver are used in this project whose datasheet is
included in Appendix B.

24
After successful implementation of the proposed scheme in softwares, design and fabrication
of hardware was carried out. Some of the pictures of the hardware are shown below:
LM317
VOLTAGE
REGULATOR
dsPIC
MICRONCONTROLLER

FREQUENCY VARYING
KNOB
PWM OUTPUTS FROM
MICROCONTROLLER

Figure 4.8: Fabrication of Hardware (Microcontroller Part)

Figure 4.9 shows microcontroller part. The microcontroller part is a low voltage part of the
project. In order to vary frequency, a potentiometer was used as shown in the above figure.
The voltage developed in potentiometer is fed to the microcontroller which by means of its
ADC (analog-to digital converter) converts the analog signal (i.e. voltage) into digital signal
to be used internally for calculating frequency. The PWM signals generated from the
microcontroller is fed to the three phase part as shown in the figure 4.2 via PWM channels of
the microcontroller. LM317 voltage regulator was used so as to convert dc voltage from dc
bank to dc voltage of about 3.3 V as required by the microcontroller.

Figure 4.10 depicts the three phase part of the inverter. Optocoupler 6N137 was used so as to
isolate low voltage level from the high voltage level. The PWM signals are received from
the microcontroller via optocoupler which is applied to MOSFETs. Before applying these
gate signals to MOSFETs, they are firstly fed to MOSFET drivers. There is no problem in
turning ON the lower semiconductor switches but there is problem in turning ON the higher
semiconductor switches. In order to turn ON the higher semiconductor switches, MOSFET
drivers are used which builds up the required gate-to-source voltage by means of bootstrap
capacitor.

25
Snubber circuit

Three Phase
outputs

MOSFET

Optocoupler

MOSFET Driver

Figure 4.9: Fabrication in Hardware (Three Phase Inverter part)

4.3 Hardware results


After proper design and fabrication in hardware, the output waveforms were observed by
means of digital oscilloscope. The following pictures depict waveforms associated with this
project. The output waveforms were similar to those observed in softwares such as
MATLAB and Proteus.

Figure 4.10: Complementary PWM outputs

26
Figure 4.11: Complete train of pulses for a complete cycle with complementary outputs

Figure 4.12: Line to neutral voltage waveform

27
Figure 4.13: Line-to-line voltage waveform

4.3.1 Experiment Results

Power analyzer was used to check if constant volt/hertz ratio was being maintained at output
of the inverter. The ratio of fundamental rms phase voltage to frequency (V/f) was set at
0.106 in the code of the microcontroller. The observations of the experiment are tabulated
below in Table 4.1:

DC bus voltage, (Vdc ) = 15 V


For Modulation Index (M.I.) =1
Maximum fundamental line-to-line voltage (VLL)= 0.612 × Vdc = 9.18 V
Maximum fundamental Phase Voltage (Vph1) =5.3 V

28
Table 4.1
S.No. Frequency Fundamental Fundamental Modulation Index (M. I) Vph
ratio
(Hz) RMS line- RMS Phase Vph f
=
line Voltage Voltage (Vph) Vph1
(volt/Hz)
(VLL)
VLL
Vph=
√3
1 12.38 1.9 1.09 0.205 0.088
2 14.71 2.3 1.33 0.251 0.090
3 31.85 5.0 2.88 0.543 0.090

From the above observations, it can be noticed that constant volt/hertz ratio is maintained
approximately equal to that previously set value (0.106 V/Hz).

Simulations in MATLAB was also carried out with the paramaters set the same as in
experiment. And, the results obtained are tabulated below;

Table 4.2

S.No Frequency Fundamental Fundamental Modulation Index (M. I) Vph


. (Hz) RMS line- RMS Phase Vph ratio
= f
line Voltage Voltage (Vph) Vph1
(VLL) (volt/Hz)
VLL
Vph=
√3
1 14.71 2.724 1.573 0.297 0.111
2 31.75 5.826 3.364 0.635 0.106

By looking at the experimental results and MATLAB simulation results, it is clear that the
ratio of magnitude to frequency of output voltage is maintained near constant in both cases.
So the objective of the project is fulfilled.

29
CHAPTER 5
CONCLUSION AND RECOMMENDATION

5.1 Conclusion
The major objective of this project is to design and fabricate constant volt/hertz inverter
using sinusoidal pulse width modulation (PWM) technique. In order to achieve this
objective, a series of steps were taken. Firstly, the project was designed and evaluated using
softwares such as Proteus and MATLAB. After achieving satisfactory results, the project
was implemented in hardware. This implementation was found to be successful. It was
verified by observing whether the ratio of voltage to frequency ratio was constant or not
when the frequency was varied externally by means of potentiometer knob. The V/f ratio
was noticed to be nearly constant which implied success of the project.

5.2 Recommendation
Constant volt/hertz Inverter system was successfully designed as per the aim of project. But
still we can improve the performance of this system by further study and enhancement. This
system can also be used to drive three phase induction motor with few enhancements and
proper protection system. The following are suggestions for future enhancement for better
performance and reliability of the system:
 By employing extra protection system (a better snubber circuits) for MOSFET
switching circuit, the reliability of the system can be increased.
 This system can be used for speed control mechanism of AC induction drive after
considering the maximum voltage and current level which the system can handle.
 MOSFETs with better static and dynamic characteristics can be used to increase
switching efficiency and hence the overall efficiency of the system.
 Isolation circuit with optocoupler of better rise and fall time can be used to prevent
losses of pulse during PWM signal transfer.
 By adding proper filter circuits, the quality of output can be increased for driving
both resistive and inductive loads.

30
BIBLIOGRAPHY

 Muhammad H. Rashid (2001), Power Electronics Handbook, Academic Press


 Prof. Dr. Indra Man Tamrakar, A Course Manual on Power Electronics
 Application notes of various PIC provided in Official Microchip website
www.microchip.com
 Datasheets of MOSFETs and MOSFET drivers provided in Official International
Rectifier website www.irf.com
 www.alldatasheets.com

31
APPENDIX A
SOURCE CODE
The following source code is program for microcontroller.
// Source code compiled in MPLAB using C30 compiler and simulated in
Proteus software
//programming reference can be taken from microchip site and dspic pdf

#define FCY 40000000


#include <p33fj32MC202.h>
#include<libpic30.h>

// derived using PLL, first FRC at first


_FOSCSEL(FNOSC_PRI)
_FOSC(FCKSM_CSECMD & POSCMD_HS & OSCIOFNC_OFF& IOL1WAY_ON)
_FWDT(FWDTEN_OFF)
_FPOR(FPWRT_PWR128 & HPOL_ON & LPOL_ON & PWMPIN_OFF) // LPOL_ON
// PWM module low side output pins have active-high output polarity
;;
// HPOL_ON: PWM module high side output pins have active-high output
polarity
_FICD(ICS_PGD1 & JTAGEN_OFF) // Communicate on PGC1/EMUC1 and
PGD1/EMUD1

unsigned int FREQ_SCALING=1999; // P1TPER value


volatile unsigned int Modulation_Index=0,Modulation=0;
volatile unsigned int PhaseA=0,PhaseB=0,PhaseC=0,Frequency=0,f=0;
volatile signed int ASinevalue,BSinevalue,CSinevalue;

void __attribute__((__interrupt__,no_auto_psv)) _MPWM1Interrupt(void);


void __attribute__((interrupt, no_auto_psv)) _ADC1Interrupt(void);
void init_PWM(void);
void initInterrupts(void);
void initAdc1(void);

const signed int Sinetable[ ]={0,


3212,6393,9512,12540,15446,18205,20787,23170,25330,27245,28898,30273,31357
,32138,32610
,32768,32610,32138,31357,30273,28898,27245,25330,23170,20787,18205,15446,1
2540,9512,6393,
3212,0,-3212,-6393,-9512,-12540,-15446,-18205,-20787,-23170,-25330,-
27245,-28898,-30273,
-31357,-32138,-32610,-32768,-32610,-32138,-31357,-30273,-28898,-27245,-
25330,-23170,
-20787,-18205,-15446,-12540,-9512,-6393,-3212,};

void initInterrupts(void)
{ INTCON1bits.NSTDIS = 0; // Interrupt nesting enabled here
IPC14bits.PWM1IP = 6; // Set PWM interrupt priority to 6 (level 7
is highest)
_PWM1IF=0; // reset
_PWM1IE=1; // enable interrupt
T3CONbits.TON = 0; // Disable Timer
T3CONbits.TCS = 0; // Select external clock
T3CONbits.TGATE=0; //disable gated timer mode
T3CONbits.TCKPS = 0b00; // Select 1:1 Prescaler
TMR3 = 0x00; // Clear timer register
PR3 = 20000; // Load the period value= 20000*1/(40)=500us
IPC2bits.T3IP = 3; // Set Timer3 Interrupt Priority Level
i
IFS0bits.T3IF = 0; // Clear Timer3 Interrupt Flag
IEC0bits.T3IE = 0; // Enable Timer3 interrupt
T3CONbits.TON = 1; // Start Timer3
}

/*========================================================================
=====
ADC INITIALIZATION FOR CHANNEL SCAN
==========================================================================
===*/
void initAdc1(void)
{

AD1CON1bits.FORM = 0b00; // Data Output Format: integer


AD1CON1bits.SSRC = 0b010; // Sample Clock Source: GP Timer
starts conversion
AD1CON1bits.ASAM = 1; // ADC Sample Control: Sampling begins
immediately after conversion
AD1CON1bits.AD12B = 0; // 10-bit ADC operation
AD1CON2bits.VCFG = 0b000; //AVDD,AVSS
AD1CON2bits.CSCNA = 1; // Scan Input Selections for CH0+
during Sample A bit
AD1CON2bits.CHPS = 0; // Converts CH0
AD1CON2bits.ALTS = 0; //always use channel i/p select
for sample A
AD1CON3bits.ADRC = 0; // ADC Clock is derived from Systems Clock
AD1CON3bits.ADCS = 15; // ADC Conversion Clock
Tad=Tcy*(ADCS+1)= (1/10M)*16 = 1.6us (625Khz)
// ADC Conversion Time for 10-bit Tc=12*Tab = 19.2us
AD1CON2bits.SMPI = (NUM_CHS2SCAN-1);// 1 ADC Channel is scanned..
for input scanning SMPI is one less the //channels
being scanned
//AD1CSSH/AD1CSSL: A/D Input Scan Selection Register
AD1CSSLbits.CSS0=1; // Enable AN0 for
channel scan
AD1CSSLbits.CSS1=1; // Enable AN1 for channel scan
//AD1PCFGH/AD1PCFGL: Port Configuration Register
AD1PCFGL=0xFFFF;
AD1PCFGLbits.PCFG0 = 0; // AN4 as Analog Input
AD1PCFGLbits.PCFG1 = 0; // AN5 as Analog Input
IPC3bits.AD1IP=2; //2nd last priority
IFS0bits.AD1IF = 0; // Clear the A/D interrupt flag
bit
IEC0bits.AD1IE = 1; // Enable A/D interrupt
AD1CON1bits.ADON = 1; // Turn on the A/D converter
}

/*========================================================================
=====
ADC INTERRUPT SERVICE ROUTINE
==========================================================================
===*/
// this will be called after timer3 register matches the period after
200us (special trigger event)
void __attribute__((interrupt, no_auto_psv)) _ADC1Interrupt(void)
{
float freq;
asm("mov _ADC1BUF0,W3"); //Read the ADC results into W3 ::suppose the pot
is set at 100%, then ADC1BUF0 reads //1023d decimal

ii
asm("asr W3,#1,W4");// Right shift by 1 bits to get the frequency(named
in placed of PhaseReq) :: this statement //divides it by 2..ie1023/2=
511 decimal and this number is the frequency (511*10000)/65536= 77.972 Hz
so the //highesh freq by this method is 77.972 Hz.. So, if we use 10Khz
freq, we can achieve 77.97 Hz maximum freq using this //algorithm
asm("mov W4,_Frequency");

/* this register w4(adc pin) can be used externally to control the


modulation by slight //modification
asm("mov _ADC1BUF1,W4");// Read the ADC results into W4
::suppose the pot is set at 100%, then ADC1BUF1 reads
//1023 decimal
asm("sl W4,#5,W4");// Left shift By 5 to get Q15 value in
the range ::multiply by 2^5 or by 32 to transform the
//frequency to the range 0 to 32767 (in fractional format to be used
below for MPY instruction)
asm("mov W4,_Modulation");
*/
if(Frequency<66)
Frequency=66;
freq=Frequency;
f=(freq*10000)/65535;
Modulation_Index=f*655; //if vdc=15v,vprms=5.3V and f=50hz
then and MI=655*freq;
if(Modulation_Index > 32500)
Modulation_Index = 32500;
IFS0bits.AD1IF= 0; // Clear the ADC1
Interrupt Flag
}

void init_PWM()
{
P1TCONbits.PTMOD = 0b10;// PWM time base input clock period is
TCY (1:1 prescale)
P1TCONbits.PTCKPS = 0b00; // PWM time base output post
scale is 1:1
P1TCONbits.PTOPS = 0b00;
// Choose PWM time period based on input clock selected
// Refer to Equation 14-1
// PWM switching frequency is 20 kHz
// FCY is 40 MHz
// P1TPER = (FCY/(Fpwm*1*2))-1 =1000=999
P1TPER = 1999;
// PWM I/O pairs 1 to 3 are in complementary mode
// PWM pins are enabled for PWM output
PWM1CON1bits.PMOD1 = 0;
PWM1CON1bits.PMOD2 = 0;
PWM1CON1bits.PMOD3 = 0;
PWM1CON1bits.PEN1H = 1;
PWM1CON1bits.PEN2H = 1;
PWM1CON1bits.PEN3H = 1;
PWM1CON1bits.PEN1L = 1;
PWM1CON1bits.PEN2L = 1;
PWM1CON1bits.PEN3L = 1;
PWM2CON1bits.PEN1H = 0; //PWM module 2 used as general i/o
PWM2CON1bits.PEN1L = 0;
// synchronized update of PWM enabled
PWM1CON2bits.IUE = 0; //1 means immediate update
// Clock period for Dead Time Unit B is TcY
P1DTCON1bits.DTAPS = 0b01;
iii
P1DTCON1bits.DTBPS = 0b01;
// Dead time value for Dead Time Unit B and Unit A
P1DTCON1bits.DTA = 45;
P1DTCON1bits.DTB = 45;// Tcy * 2 * 45= 2.25 usec
// Dead Time Unit selection for PWM signals
// Dead Time Unit A selected for PWM active transitions
// Dead Time Unit B selected for PWM inactive transitions
P1DTCON2bits.DTS3A = 0;
P1DTCON2bits.DTS2A = 0;
P1DTCON2bits.DTS1A = 0;
P1DTCON2bits.DTS3I = 1;
P1DTCON2bits.DTS2I = 1;
P1DTCON2bits.DTS1I = 1;
// PWM I/O pin controlled by PWM Generator
P1OVDCONbits.POVD3H = 1;
P1OVDCONbits.POVD2H = 1;
P1OVDCONbits.POVD1H = 1;
P1OVDCONbits.POVD3L = 1;
P1OVDCONbits.POVD2L = 1;
P1OVDCONbits.POVD1L = 1;
// Initialize duty cycle values for PWM1, PWM2 and PWM3
signals
P1DC1 =1999; // 50% duty cycle
P1DC2 =1999; // 50% duty cycle
P1DC3 =1999; // 50%
PhaseA=0; // pointers for 3 sine waves generation
PhaseB=0;
PhaseC=0;
//Enabling PWM Pulse Generation
P1TCONbits.PTEN = 1;
return;
}
void delay10ms(int n){
int i;
for(i=0;i<n;i++){
__delay_ms(10);
}
}

// MAIN function
int main(void)
{
_TRISB6=0;
_LATB6=1;
/* Configure PLL prescaler, PLL postscaler, PLL divisor */
PLLFBD=30; /* M = PLLFBD + 2=32 */
CLKDIVbits.PLLPOST=0b00; /* N2 = 2 */
CLKDIVbits.PLLPRE=0b10; /* N1 = 4 */
// Fosc=20 * 32 /(2*4)=79.2275 Mhz ; Fcy=39.61375Mhz used in this
case

// coding in assembly language(asm) to switch the clock from 20MHz


to 80MHz using PLL mode and //Fcy=Fosc/2
//Place the New Oscillator Selection (NOSC=0b11) in W0
asm("MOV #0x03,w0");
//OSCCONH (high byte) Unlock Sequence
asm("MOV #OSCCONH, w1");
asm("MOV #0x78, w2");
asm("MOV #0x9A, w3");
asm("MOV.B w2, [w1]"); // Write 0x78");
asm("MOV.B w3, [w1]"); // Write 0x9A");
//;Set New Oscillator Selection
iv
asm("MOV.B w0, [w1]");
//; Place 0x01 in W0 for setting clock switch enabled bit
asm("MOV #0x01, w0");
//;OSCCONL (low byte) Unlock Sequence
asm("MOV #OSCCONL, w1");
asm("MOV #0x46, w2");
asm("MOV #0x57, w3");
asm("MOV.B w2, [w1]"); //; Write 0x46
asm("MOV.B w3, [w1]"); //; Write 0x57
//; Enable Clock Switch
asm("MOV.B w0, [w1]");// ; Request Clock Switching by Setting OSWEN
bit
while(OSCCONbits.COSC != 0b011); // Wait for new Oscillator to
become POSC w/ PLL
while(OSCCONbits.LOCK != 1); // Wait for Pll to Lock
while (OSCCONbits.OSWEN == 1) { } // wait till finish: if OSWEN
=0 then oscillator switch is complete;
PMD3bits.PWM2MD=1;
//there is simulation problem in proteus during Pll,ie in lock and oswen
but works in hardware
//which means proteus can't simulate PLL mode using external oscillator ,
but it simulates if clock is set in FRCPLL
init_PWM();
initAdc1();
initInterrupts();
while(1)
{
delay10ms(5);
_LATB6=~_LATB6; // to check if PIC is in working
}
}

void _ISR _MPWM1Interrupt(void)


{ PhaseA+=Frequency; // Accumulate Delta_Phase
in Phase variable
PhaseB =PhaseA + OFFSET_120; // Add proper value to phase
offset
PhaseC =PhaseA + OFFSET_240;
ASinevalue = Sinetable[PhaseA>>8]; // Take sine info
BSinevalue = Sinetable[PhaseB>>8];
CSinevalue = Sinetable[PhaseC>>8];
//Save off working registers ;might be used by other interrupts in nested
form
//multiplication is done in asm code and decimal has been converted into
integer (Q15 format) ie 32767
//beacause normal method of multiplying a floating point number takes a
lot of pic memory and takes long time for //calculation
asm("push.d W4");
asm("push.d W6");
asm("push.d W8");
asm("mov _FREQ_SCALING,W7");
asm("mov _Modulation_Index,W6");
asm("mov _ASinevalue,W5");
asm("mpy W5*W6,A"); //Multiply by the
amplitude scaling
asm("sac A,W5"); //Store the scaled result
asm("mpy W5*W7,A"); //Multiply by the
PWM scaling factor
asm("sac A,W8"); //Store the scaled result
v
asm("add W7,W8,W8"); //Add the PWM scaling
factor to produce 50% offset
asm("mov W8,_P1DC1"); //Write the PWM duty cycle
asm("mov _BSinevalue,W5");
asm("mpy W5*W6,A"); //Multiply by the
amplitude scaling
asm("sac A,W5"); //Store the scaled result
asm("mpy W5*W7,A"); //Multiply by the
PWM scaling factor
asm("sac A,W8"); //Store the scaled result
asm("add W7,W8,W8"); //Add the PWM scaling
factor to produce 50% offset
asm("mov W8,_P1DC2"); //Write the PWM duty cycle
asm("mov _CSinevalue,W5");
asm("mpy W5*W6,A"); //Multiply by the
amplitude scaling
asm("sac A,W5"); //Store the scaled result
asm("mpy W5*W7,A"); //Multiply by the
PWM scaling factor
asm("sac A,W8"); //Store the scaled result
asm("add W7,W8,W8"); //Add the PWM scaling
factor to produce 50% offset
asm("mov W8,_P1DC3"); //Write the PWM duty cycle
asm("pop.d W8"); //Save off working registers
;might be used by other interrupts in nested form
asm("pop.d W6");
asm("pop.d W4");
_PWM1IF=0;
}

vi
APPENDIX B
DATASHEETS OF SOME OF THE COMPONENTS USED

vii
dsPIC33FJ32MC202/204

viii
ix
x
xi
xii
Optocoupler/ Optoisolators (6N137)

xiii
xiv
Power MOSFET (IRF840A)

xv
MOSFET driver (IRS2110)

xvi
Figure: Pin Configuration of MOSFET driver

xvii

S-ar putea să vă placă și