+ All Categories
Home > Documents > THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

Date post: 05-Jan-2017
Category:
Upload: hoangthuy
View: 217 times
Download: 0 times
Share this document with a friend
102
iii THE SIMULATION OF THE DIRECT TORQUE CONTROL OF PERMANENT MAGNET SYNCHRONOUS MOTOR. SARIATI BINTI DALIB A project report submitted in partial fulfillment of the requirements of the award of the degree of Master of Engineering (Electrical Power) Faculty of Electrical Engineering Universiti Teknologi Malaysia MAY, 2007
Transcript
Page 1: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

iii

THE SIMULATION OF THE DIRECT TORQUE CONTROL OF PERMANENT MAGNET SYNCHRONOUS MOTOR.

SARIATI BINTI DALIB

A project report submitted in partial fulfillment of the

requirements of the award of the degree of

Master of Engineering (Electrical Power)

Faculty of Electrical Engineering

Universiti Teknologi Malaysia

MAY, 2007

Page 2: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...
Page 3: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

ii

Page 4: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

iv

I declare that this thesis “The Simulation Of The Direct Torque Control Of Permanent

Magnet Synchronous Motor” is the result of my own research except for the works that have been cited in the reference. The thesis has

not been accepted any degree and not concurrently submitted in candidature of any other degree.

Signature :____ ____ ___________

Name of Author : SARIATI BINTI DALIB

Date : 11 MAY 2007

Page 5: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

v

To my beloved husband, mother and family,

for their encouragement, blessing and inspiration……..

Page 6: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

vi

ACKNOWLEDGEMENTS

Alhamdulillah, I am grateful to Allah SWT on HIS blessing and mercy for

making this project successful.

I would like to extend my deepest gratitude to my supervisor, PM Dr Nik Rumzi

bin Nik Idris for his invaluable, committed and continuous supervision, guidance and

patience throughout this project.

I would like to thank all the people involved in the preparation of this thesis

especially to all the lecturers who have taught me, thank you for the lessons that has

been delivered. A special thank to my husband for his endless support and

encouragement.

Page 7: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

vii

ABSTRACT

The direct torque control theory has achieved great success in the control of

induction motor. Many attempts have been made to implement the idea of DTC of

induction motor to PMSM since 1990’s. The DTC is implemented by selecting the

proper voltage vector according to the switching status of inverter which was

determined by the error signals of reference flux linkage and torque with their measured

real value acquired by calculating in the stationary reference frame by means of simply

detecting the motor voltage or currents. Aiming at the DTC in PMSM Drives, this

project explained the theoretical basis of the direct torque control (DTC) for PMSM

firstly. Then explained the difference between the application of DTC to PMSM and to

IM. Finally the Matlab/Simulink models were developed to examine the DTC for

PMSM and IM. The simulation results is presented and explained in detail.

Page 8: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

viii

ABSTRAK

‘Direct Torque Control’ berjaya digunakan bagi mengawal Motor Aruhan . Oleh

yang demikian berbagai usaha dilakukan oleh para penyelidik bagi menggunakan DTC

mengawal Motor Segerak Magnet Kekal (PMSM) sejak tahun 1990. DTC mempunyai

banyak kelebihan berbanding cara kawalan yang lain terutamanya FOC. Cara DTC

ialah pada mulanya tork and fluks motor dianggarkan melalui voltan dan arus motor

yang diukur. Tork dan fluks ini dibandingkan dengan tork dan fluks rujukan. Hasil

perbezaannya dibandingkan dalam pembanding hysteresis dan seterusnya vektor voltan

yang sesuai dipilih untuk dibekalkan kepada motor berdasarkan jadual penyuisan bagi

penyongsang. Projek ini menggunakan cara kawalan DTC dalam mengawal PMSM.

Pada mulanya teori PMSM dan DTC dibincang dan diterangkan dengan jelas. Kemudian

model-model simulink dibina bagi tujuan simulasi. Simulasi dilakukan dengan

menggunakan applikasi Matlab Simulink. Simulasi dilaksanakan dan hasil simulasi

dibentang dan dibincangjan.

Page 9: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

ix

TABLE OF CONTENTS CHAPTER TITLE PAGE

DECLARATION ii

DEDICATION iii

ACKNOWLEDGEMENTS iv

ABSTRACT v

ABSTRAK vi

TABLE OF CONTENTS vii

LIST OF TABLES x

LIST OF FIGURES xi

LIST OF SYMBOLS xiv

LIST OF ABBREVIATIONS xv

1 INTRODUCTION

1.1 Introduction 1

1.2 Objectives 2

1.3 Scope of project 2

1.4 Research Methodology 2

1.5 Literature Review 3

1.6 Structure and Layout of Thesis 5

2 PERMANENT MAGNET SYNCHRONOUS MOTOR

2.1 Introduction 5

Page 10: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

x

2.2 Model of the Permanent Magnet Synchronous Motor. 6

2.2.1 Motor Equation 9

2.2.2 Parks Transformation 12

2.3 The Torque Equation In xy Reference Frame 14

2.4 The Flux Linkage Equations In The xy Reference Frame 10

2.5 PMSM’s With Pole Saliency 11

2.6 Summary 12

3 CONTROL SCHEMES FOR PERMANENT MAGNET

SYNCHRONOUS MOTOR

3.1 Introduction 15

3.2 Scalar Control (Volts/Hertz Control) 16

3.3 Vector Control 17

3.3.1 Field Oriented Control 17

3.3.2 Direct Torque Control 18

3.4 Summary 19

4 DIRECT TORQUE CONTROL

4.1 Introduction 20

4.2 Torque Control principle of DTC for PMSM 21

4.3 Amplitude Control Of Stator Flux Linkage 21

4.4 The control of the rotation of stator flux linkage (ψs ). 23

4.5 The implementation 0f the Direct Torque Control

System

25

4.5.1 Flux and Torque Estimator 26

4.5.2 Torque and Flux Hysteresis Comparator 28

4.5.3 Switching Table 29

4.5.4 Voltage Source Inverter 30

4.6 Summary 32

5 SIMULATION AND RESULT ANALYSIS

Page 11: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

xi

5.1 Introduction 33

5.2 Simulink Block of DTC for PMSM 37

5.2.1 Torque and Flux Hysteresis Block 36

5.2.2 Subsystem Block 37

5.2.3 PMSM Model 38

5.2.4 Stator Flux – Voltage Model 39

5.3 Simulink Block of the DTC for IM 40

5.4 Results 43

5.4.1 The DTC performance of PMSM. 44

5.4.2 The DTC performance of IM 49

5.4.3 Comparison of DTC performance in PMSM and

IM

53

5.5 Summary 60

6 CONCLUSION & FUTURE WORKS

6.1 Conclusion 61

6.2 Suggestion for future work. 62

REFERENCES 63

APPENDIX A 65

APPENDIX B 69

APPENDIX C 73

Page 12: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

xii

LIST OF TABLES

TABLE NO TITLE PAGE

4.1 The switching table for Inverter 25

4.2 The switching table for Inverter 33

5.1 Parameter Values of PMSM used in Simulation 34

5.2 Parameter Values of PMSM used in Simulation 41

Page 13: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

xiii

LIST OF FIGURES

FIGURE NO. TITLE PAGE

2.1 The stator and rotor flux linkages in different frames 9

2.2 Equivalent Circuit of PMSM 13

3.1 Some Common Control Techniques Used For PMSM

19

4.1 The movement of the end of stator flux linkage. 26

4.2 The control of the stator flux linkage 26

4.3 Block Diagram Of the basic DTC For PMSM 28

4.4 2-level torque hysteresis comparator 32

4.5 2-level flux hysteresis comparator 32

4.6 VSI and connection to PMSM 34

5.1 Simulink Block of DTC for PMSM 35

5.2 Model of the torque and Flux hysteresis comparator 35

5.3 The actual torque, reference torque and the output of the hysteresis

36

5.4 The actual flux linkage, reference flux and the output of the hysteresis comparator

37

5.5 Simulik model of Subsytem block. 38

5.6 Simulink Block of PMSM 39

5.7 Stator flux – voltage model 40

Page 14: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

xiv

5.8 The Simulink Block of DTC for IM 42

5.9 Simulink Block of IM 42

5.10 The Torque hysteresis comparator block for IM 43

5.11 The waveform of the stator flux linkage, the developed torque and speed of the PMSM

44

5.12 The actual and reference torque 45

5.13 The torque response 45

5.14 The stator flux linkage and reference flux 46

5.15 Flux and Torque ripple of PMSM 47

5.16 Actual Torque, torque error and hysteresis comparator

47

5.17 The actual and error of the stator Linkage flux and the hysteresis comparator

48

5.18 The waveform of the stator flux linkage, the developed torque and speed

49

5.19 The actual and reference torque of IM 50

5.20 The waveform of the actual stator flux linkage and the reference.

51

5.21 The actual flux linkage , the error and the flux hysteresis comparator output.

53

5.22 The actual torque , the torque error and the torque hysteresis comparator output.

54

5.23 The flux and torque ripple of IM 55

5.24 The waveforms of flux, torque and speed (a) PMSM (b) IM

56

5.25 Torque response of PMSM and IM 57

5.26 Torque ripples of PMSM and IM 58

5.27 Actual and reference flux linkage of PMSM and IM 59

Page 15: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

xv

LIST OF SYMBOLS

Ld - d-axis self inductance

Lq - q- axis self inductance

id - d-axis current

Vd - d-axis voltage

iq - q- axis current

Vq - q- axis voltage

J - inertia

B - friction

L - Self inductance

ψs - Stator flux linkage

ψf - Field flux linkage

τ - output Torque hysteresis

φ - output flux hysteresis

δ - load angle

Va,Vb,Vc - Three Phase Voltage

Rs - rotor resistance

P - pairs of pole

Te - develop torque

ωr - rotor electrical speed ωm - rotor mechanical speed. νdc - DC Voltage Sa,Sb,Sc - switching states

Page 16: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

xvi

LIST OF ABBREVIATIONS

DTC Direct Torque Control

PMSM Permanent magnet Synchronous Motor

IM Induction Motor

VSI Voltage Source Inverter

FOC Field Oriented Control

VSV Voltage Space Vector

Page 17: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

CHAPTER 1

INTRODUCTION

1.1 Introduction

Permanent magnet synchronous motors (PMSM) are widely used in low and mid

power applications such as computer peripheral equipments, robotics, adjustable speed

drives and electric vehicles.

The growth in the market of PMSM motor drives has demanded the need of

simulation tool capable of handling motor drive simulations. Simulations have helped

the process of developing new systems including motor drives, by reducing cost and

time. Simulation tools have the capabilities of performing dynamic simulations of motor

drives in a visual environment so as to facilitate the development of new systems.

In this work, the simulation of a direct torque control of PMSM is developed

using Simulink. The Direct Torque Control is one of the high performance control

strategies for AC machine. The DTC scheme has been realized successfully in the

Induction Motor drives. The aim of the project is to study the implementation of the

Direct Torque Control (DTC) in Permanent Magnet Synchronous Motor (PMSM).

Page 18: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

2

1.2 Objectives

The objectives of the project are:

i) To stimulate the Direct Torque Control (DTC) of Permanent Magnet

Synchronous Motor (PMSM) and Induction Motor (IM).

ii) To compare the performance of the DTC of Permanent Magnet

Synchronous Motor (PMSM) and Induction Motor.

1.3 Scope of project

The scope of work for this project:

i) PMSM with saliency is considered.

ii) Simulation is performed using MATLAB Simulink.

iii) The performance of DTC in PMSM and IM are discussed based on the

simulation results.

1.4 Research Methodology

The research work is undertaken in the following stages:

i) Studied the application of MATLAB simulink.

ii) Studied the theoretical basis of the direct torque control (DTC) for

Permanent Magnet Synchronous Motor (PMSM) drives and Induction

Motors.

Page 19: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

3

iii) Simulation of DTC of PMSM and IM is performed using Simulink.

iv) Analyzed the simulation results.

1.5 Literature Review

The original concept of DTC was proposed by Takahashi and Noguchi in 1986

for application in Induction Motors. Their idea was to control the stator flux linkage and

the torque directly , not via controlling the stator current. This was accomplished by

controlling the power switches directly using the outputs of hysteresis comparators for

the torque and the modulus of the stator flux linkage and selecting an appropriate

voltage vector from a predefined switching table. The table was called the ‘optimum

switching table”. The measurement of the rotor angle was not used.

A same kind of control was proposed by Depenbrock (1987). At first,

Takahashi and Noguchi did not give any name to their new control principle. In a later

paper by Takahasi and Ohmori (1987) the control system was named the direct torque

control, DTC. Depenbrock called his control method Direct Self Control, DSC.

Tiitenen et al discussed the first industrial application of the DTC. After that , the

number of papers on the DTC has grown tremendously on different aspects of the DTC

for asynchronous motors. In recent years there has been interest to apply the DTC to

permanent magnet synchronous motors.

Page 20: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

4

L.Zhong et al discussed the implementation of DTC in PMSM Drives. In 1998,

Rahman et al proposed a DTC scheme for a wide speed range operation of an interior

PMSM drive. The proposed scheme possess some attractive features compared to the

conventional current-controlled drives like field oriented control (FOC). Later on, Tang

et al proposed a DTC control schemes for the IPM featuring almost fixed switching

frequency.

In 2002, Rahman et al, proposed a completely sensorless DTC control for an IPM

drive, which uses a new speed estimator from the stator flux linkage vector and the

torque angle. To reduce the torque ripples, Sun et al proposed a fuzzy logic algorithm to

refine the selection of the voltage vectors. Today, the DTC has become an accepted

control method beside the field oriented control.

1.6 Structure and Layout of Thesis

The purpose of this thesis is to present a simulation of a direct torque controlled

of permanent magnet synchronous motor and compared the performance with IM. The

simulation is carried out by using Matlab Simulink. The thesis is organized into six

chapter:

Chapter 1 gives the introduction to project, stating its objectives, scope of

work, research methodology and overview.

Page 21: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

5

Chapter 2 introduces to permanent magnet synchronous motor and the equation

related to PMSM such as the voltage, stator flux linkage and torque.

Chapter 3 presents some common control techniques used for control of

Permanent Magnet Synchronous Motors (PMSM).

Chapter 4 present and analyzed the implementation of the Direct Torque

Control in PMSM drives.

Chapter 5 explain the simulink block of DTC of PMSM and Induction motor

and also discuss the results obtained from the simulation

Chapter 6 gives the summary of this project and present the recommendation for

future work to improve the performance of the DTC of PMSM.

Page 22: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

6

CHAPTER 2

PERMANENT MAGNET SYNCHRONOUS MOTOR

2.1 Introduction

Page 23: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

7

Two types of permanent magnet ac motor drives are available in the drive

industry. There are Permanent Magnet Synchronous Motor (PMSM) drive with a

sinusoidal flux distribution and the brushless dc motor drive with a trapezoidal flux

distribution.

The Permanent Magnet Synchronous Motor (PMSM) has numerous advantages

over other machines that are conventionally used for ac servo drives. The stator current

of the induction motor (IM) contains magnetizing as well as torque-producing

components. The use of the permanent magnet in the rotor of the PMSM makes it

unnecessary to supply magnetizing current through the stator for constant air-gap flux;

the stator current need only be torque producing. Hence for the same output, the PMSM

will operate at a higher power factor (because of the absent of magnetizing current).and

will be more efficient than Induction Motor. The development of the PMSM was to

remove the foregoing disadvantages of the Synchronous Motor by replacing its field

coil, DC power supply and slip rings with a permanent magnet [7]

2.2 Model of the Permanent Magnet Synchronous Motor.

The two axes PMSM stator windings can be considered to have equal turn per

phase. The rotor flux can be assumed to be concentrated along the d axis while there is

zero flux along the q axis, an assumption similarly made in the derivation of indirect

vector controlled induction motor drives. Also, rotor flux is assumed to be constant at a

given operating point.

Page 24: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

8

There is no need to include the rotor voltage equation as in the induction motor

since there is no external source connected to the rotor magnet and variation in the rotor

flux with respect to time is negligible.

The stator equations of the induction machine in the rotor reference frames using

flux linkages are taken to derive the model of the PMSM. The rotor reference frame is

chosen because the position of the rotor magnets determine independently of the stator

voltages and currents, the instantaneous induced emfs and subsequently the stator

currents and torque of the machine. In Induction motor , the rotor fluxes are not

independent variables, they are influenced by the stator voltage and currents and that is

why any frame of reference is suitable for the dynamic modeling of the induction

machine.

2.2.1 Motor Equation

The stator flux linkage vector ψs and rotor flux linkage ψf of PMSM can be

drawn in the rotor flux (dq), stator flux (xy), and stationary (DQ) frames as shown in

figure 1.

Page 25: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

9

q

d

D

x ψs

ψf

y

isVs

id

ixδ

θr

Q

Figure 2.1 The stator and rotor flux linkages in different frames.

When rotor references frame are considered, it means the equivalent q and d axis

stator windings are transformed to the reference frames that are revolving at rotor speed.

The consequences is that there is zero speed differential between the rotor and stator

magnetic fields and the stator q and d axis windings have a fixed phase relationship with

the rotor magnet axis which is the d axis in the modeling.

The angle between the stator and rotor flux linkage δ is the load angle when the

stator resistance is neglected. In the steady state , δ is constant corresponding to a load

torque and both stator and rotor flux rotate at synchronous speed. In transient operation δ

varies and the stator and rotor flux rotate at different speeds. Since the electrical time

constant is normally much smaller than the mechanical time constant , the rotating speed

Page 26: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

10

of the stator flux with respect to the rotor flux can be easily changed. It will be shown in

this chapter that the increase of torque can be controlled by controlling the change of δ

or the rotating speed of the stator flux.

The well-known voltage equations in the rotor reference frame are as follows:

υd = Rd id + d ψd - ωrψq ( 1 ) dt υq= Rq iq + d ψq + ωrψd ( 2 ) dt

where Rd and Rq are the quadrature and direct-axis winding resistances which

are equal and be refered to as Rs is the stator resistance.

To compute the stator flux linkage in the q and d axes, the current in the stator

and rotor are required. The permanent magnet excitation can be modeled as a constant

current source, if. The rotor flux along d axis , so the d axis rotor current is if. The q axis

current in the rotor is zero , because there is no flux along this axis in the rotor, by

assumption.

Then the flux linkage are written as

ψd = Ld id + Lm if ( 3 )

ψq = Lq iq ( 4 )

where Lm is the mutual inductance between the stator winding and rotor magnets.

Substituting these flux linkages into the stator voltage equations gives the stator

equations:

Page 27: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

11

υq = Rs iq + ωr(Ld id + ψf) + ρLqiq ( 5 ) υd = Rs id - ωrLq iq + ρ( Ldid + ψf) Rd + Ldid ( 6 )

Arranging the above equations in matrix form :

υq Rq + ρLq ωrLd iq ωrLm if ( 7 )

υd -ωrLq Rd + ρLd id ρψf = +

The developed torque motor is being given by

Te = 3 P ( ψd iq - ψq id ) ( 8 ) 2

which upon substitution of the flux linkages in terms of the inductances and

current yields

Te = 3 P ( ψf iq + (Ld - Ld ) iq id ) ( 9 ) 2

ψf is the flux through the stator windings due to the permanent magnet.

ψf = Lm if ( 10 )

The mechanical Torque equation is

Te = TL + Bωm +J dωm ( 11 ) dt Solving for the rotor mechanical speed from the above equation :

ωm = ∫(Te + TL + Bω)dt ( 12 )

Page 28: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

12

J And

ωm = ωr (2/P) ( 13 )

In the above equation ωr is the rotor electrical speed where as ωm is the rotor

mechanical speed.

2.2.2 Parks Transformation

Converting the phase voltages variables Vabc to Vdqo variables in rotor

reference frame the following equations are obtained:

Vq cos θr cos (θr -120) cos ( θr +120) Va

Vd = 2/3 sin θr sin (θr -120) sin ( θr +120) Vb

V0 ½ ½ ½ Vc

Va cos θr sin θr Vq

Vb = 2/3 cos (θr -120) sin (θr -120) Vd

Vc cos ( θr +120) sin ( θr +120) V0

( 14 )

( 15 )

2.2.3 Equivalent Circuit of Permanent Magnet Synchronous Motor.

From the d-q modeling of the motor using the stator voltage equations the

equivalent circuit of the motor can be derived. Assuming rotor d axis flux from the

Page 29: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

13

permanent magnet is represented by a constant current source as described in the

following equation ψf = Lm if, figure below is obtained.

Lls = Ld -Lm Lls = Lq -Lm

Rs ωrψq Rs ωrψd

+ + - + - +

id iq

Vd Lm If Vq Lm

- -

Figure 2.2 : Equivalent Circuit of PMSM

2.3 The Torque Equation In xy Reference Frame

With the transformation below, equation (6) can be transformed to stator flux

reference frame.

Fx cosδ sinδ Fd

Fy -sinδ cosδ Fq = (16)

The inverse transformation is

Page 30: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

14

Fd cosδ -sinδ Fx

Fq sinδ cosδ Fy = (17)

where F represent the voltage, current and the flux linkage.

From figure 1, it can be found that

sin δ = ψq

|ψs| (18)

cos δ = ψd

|ψs|

where | ψs| represents the amplitude of the stator flux linkage. Substituting (16)

and (17) for current into (8) gives :

T = 3 P [ ψd (ix sin δ + iy cos δ) - ψq (ix cos δ + iy sin δ) ]

2

= 3 P [ ix ψdψq + iy ψd 2 - ix ψdψq + iy ψd

2 (19) 2 | ψs| | ψs| | ψs| | ψs|

Equation (19) means that the torque is directly proportional to the y –axis

component of the stator current if the amplitude of the stator flux linkage is constant.

Page 31: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

15

2.4 The Flux Linkage Equations In The xy Reference Frame

Equation (3) can be rewritten into matrix form as follows:

ψd = Ld 0 id + ψf (20) ψq 0 Lq iq 0

substituting (3) into (7) gives

cosδ -sinδ ψx Ld 0 cosδ -sinδ + ψf

sinδ cosδ ψy 0 Lq sinδ cosδ 0 =(21)

2.5 PMSM’s With Pole Saliency

Page 32: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

16

For a PMSM’s with pole saliency, Ld ≠Lq, the torque equation in terms of stator

flux linkage and angle δ can be obtained by solving ix with ψy= 0:

ix = 2 ψf sinδ - [(Ld +Lq) +(Ld-Lq)cos 2δ]iy (22)

(Lq –Ld)sin2δ

Then the torque equation is as follows:

(23)

T = 3P | ψs| [2ψf Lqsinδ – | ψs|(Lq – Ld)sin 2δ] 4 LqLd

Equation (23) consists of two terms, the first is the excitation torque, which is

produced by the permanent magnet flux. The second term is the reluctance torque. For

PMSM with pole saliency, the amplitude of the stator flux should be changed with the

change of actual torque even for constant torque operation.

Under the condition of constant amplitude of ψs , by differentiating (23) with

respect to time, the rate of increasing of torque at t = 0 can be obtained in (24).

dT = 3P ψs [2ψf Lqcosδ – 2 ψs (Lq – Ld)cos 2δ]dδ (24) dt 4 LqLd dt

From (23) and (24) can be seen that electromagnetic torque in PMSM is

determined by the δ angle; quick dynamic response can be achieved by changing δ as

quickly as possible. And according to (25) , fast dynamic response can be achieved if

the amplitude of the stator flux linkage is chosen as ( 25) [5 ]

ψs < Lq ψ f (25)

Page 33: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

17

Lq – Ld

2.6 Summary

In this chapter the motor model was derived. The equations expressed in the rotor

reference frame is used in simulations. The electromagnetic torque for PMSM with pole

saliency was derived. From the toque equation can be seen that that electromagnetic

torque in PMSM is determined by the δ angle; quick dynamic response can be achieved

by changing δ as quickly as possible and fast dynamic response can be achieved if the

amplitude of the stator flux linkage is chosen according to equation (25).

CHAPTER 3

CONTROL SCHEMES FOR

PERMANENT MAGNET SYNCHRONOUS MOTOR

Page 34: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

18

3.1 Introduction

PMSM control techniques can be divided into scalar and vector control.

Scalar control is based on relationships valid in steady-state. Amplitude and

frequency of the controlled variables are considered. In vector control amplitude and

position of a controlled space vector is considered. These relationships are valid

even during transients which is essential for precise torque and speed control.

Variable frequency

Control

Scalar Based Vector Based

Voltz/Hertz Field Oriented Direct torque

Control(FOC) Control (DTC)

Figure 3.1 : Some Common Control Techniques Used For PMSM.

Page 35: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

19

3.2 Scalar Control

Scalar control is based on relationships valid in steady state. Only

magnitude and frequency of voltage, current, etc. are controlled. Scalar control is used

e.g. where several motors are driven in parallel by the same inverter.

Volts/Hertz control is among the simplest control schemes for motor control. The

control is an open-loop scheme and does not use any feedback loops. The idea is to keep

stator flux constant at rated value so that the motor develops rated torque/ampere ratio

over its entire speed range.

3.3 Vector Control

The problem with scalar control is that motor flux and torque in general are

coupled. This inherent coupling affects the response and makes the system prone to

instability if it is not considered. In vector control, not only the magnitude of the

stator and rotor flux is considered but also their mutual angle.

3.3.1 Field Oriented Control

Field Oriented Control was invented in the beginning of 1970’s and it

demonstrates that an induction motor or synchronous motor could be controlled like a

separately excited dc motor by the orientation of the stator mmf or current vector in

relation to the rotor flux to achieve a desired objective.

Page 36: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

20

The vector control of currents and voltages in control of the spatial orientation

of the electromagnetic fields in the machine and has led to the name field orientation.

Field Oriented Control usually refer to controllers which maintain a 90° electrical angle

between rotor and stator field components. System which depart from the 90° orientation

are referred to as field angle control or angle control.

The performance of FOC is comparable to DC Machine. It produce less ripples

but the system is more complex and less robust compare to DTC.

3.3.2 Direct Torque Control

The Direct Torque Control was introduced in the 1980’s for Induction Machine

for torque and flux control. It was developed for PMSM in 1990’s. The DTC is gaining

popularity due to its simple control structure and easy implementation .

The principle of Direct Torque Control (DTC) is to directly select

voltage vectors according to the difference between reference and actual value of torque

and flux linkage. Torque and flux errors are compared in hysteresis

comparators. Depending on the comparators a voltage vector is selected from a table.

Advantages of the DTC are low complexity and that it only need to use of one motor

parameter, the stator resistance. No pulse width modulation is needed; instead one of

the six VSI voltage vectors is applied during the whole sample period. All calculations

are done in a stationary reference frame which does not involve the explicit knowledge

of rotor position. Still, for a synchronous motor, rotor position must be known at start-

up.

Page 37: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

21

The DTC hence require low computational power when implemented digitally.

The system possess good dynamic performance but shows quite poor performance

in steady-state since the crude voltage selection criteria give rise to high ripple levels in

stator current, flux linkage and torque. Its simplicity makes it possible to execute

every computational cycle in a short time period and use a high sample frequency.

For every doubling in sample frequency, the ripple will approximately halve. The

problem is that the power switches used in the inverter impose a limit for the

maximum sample frequency.

3.4 Summary

This chapter presents some of the control techniques used for permanent magnet

motor control. A scalar control technique called Volts/hertz control being among the

simplest control methods. It is used where exact torque and flux control is not essential

but where speed control is desirable, like when several motors are driven in parallel by a

single inverter.

Vector control is used where high performance torque and flux control is needed.

Vector control can be implement by using FOC or DTC technique. DTC technique is

simple, robust and offer good dynamic performance. FOC technique gives the best

performance in terms of ripples level but requires more processor power and are more

complicated to implement.

Page 38: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

22

CHAPTER 4

DIRECT TORQUE CONTROL

4.1 Introduction

Page 39: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

23

This chapter discussed the three signal which affect the control action in a DTC

system and also presents the block diagram of the basic DTC system. Each block is

described in detail and the functions of all system blocks are explained.

There are 3 signals which affect the control action in a DTC system;

1. Torque - Te

2. The amplitude of the Stator Flux linkage - |ψs|

3. The angle of the resultant flux linkage vector - δ

4.2 Torque Control principle of DTC for PMSM.

In the chapter 2, it has been proven that the change of torque can be

controlled by keeping the amplitude of the stator flux linkage constant and increasing

the rotating speed of the stator flux linkage as fast as possible. The amplitude and

rotating speed of the stator flux linkage can be controlled by selecting the proper stator

voltage vectors.

4.3 Amplitude Control Of Stator Flux Linkage.

The stator flux linkage of a PMSM expressed in the stationary reference frame is

ψs = ∫ (υs - Ris ) dt (26)

Page 40: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

24

Each voltage vector is constant during the switching interval and (26) is then

rewritten as in (27).

ψs = υst - R ∫ is dt + ψs|t =0 (27)

Neglecting the stator resistance , the stator flux linkage can be directly defined

by the integration of the voltage vector.

ψs = υst + ψs|t =0 (28)

Equation (28) explains that the movement of the end of the stator flux linkage

has the same direction with the given voltage vector, as shown in Figure 4.1. Therefore,

it is possible to control the amplitude, moving direction and moving speed of the stator

flux linkage by selecting proper voltage vector. ψs|t =0 is the initial stator flux linkage

at the instant switching.

Page 41: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

25

θ1

V2

V3V4

V5

V6 V1

θ2

θ6

θ5

θ4

θ3

Figure 4.1 : The movement of the end of stator flux linkage.

For the convenience of selecting voltage vector, it is desired to divide the space

vector plane into six-region as shown in figure 4.1 In each region , two adjacent voltage

vectors, which give the minimum switching frequency , are selected to increase or

decrease the amplitude of stator flux linkage. ,respectively. For example, in figure 4.1,

vectors V2 and V3 are selected to increase and decrease the amplitude of stator flux

linkage when ψs in region one and rotating in counter –clockwise. In this way , ψs can

be controlled at the required value by selecting the proper voltage vectors. Figure 4.2

V2 V3

V5

V4

ψs|t=0

V0 & V8

ψs V1

V6

V3 is applied

Hysteresis band

θ= section V = voltage vector ψs= stator flux linkage ψs|t=0 = initial linkage stator flux

Page 42: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

26

shows how the voltage vectors are selected for keeping ψs within a hysteresis band when

ψs is rotating in the counter clockwise direction.

V1

V2V3

V4

V5 V6

V3

V2

V3

V3

V4

V4

V5V4

V5

V6

V5

V6 V1

V6V1

V2V1

V2

θ4

θ3θ2

θ1

Figure 4.2: The control of the stator flux linkage

4.4 The control of the rotation of stator flux linkage (ψs ).

It is seen from (28) that ψs will stay at its original position when zero voltage

vectors are applied. This is true for an induction motor. In an Induction Motor, the stator

flux linkage is uniquely determined by the stator voltage, and when the zero voltage

Page 43: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

27

vectors are selected the stator flux linkage vector will be standstill in the position where

it was and the electromagnetic torque will decrease rapidly. In a PMSM, however , the

stator flux linkage is jointly determined by both the stator voltage and the rotor magnet

flux. Since the permanent magnets rotate all the time, the stator flux linkage still exists

even if the zero voltage vectors are used, and as a result, the zero voltage vectors will

only cause the torque decrease slightly. An inverse voltage vector is normally selected to

reduce the torque rapidly. The zero voltage vectors are not used for controlling the stator

flux linkage. Thus ψs should always be in motion with respect to rotor flux linkage.

In the previous chapter, it is seen that , the electromagnetic torque can be

controlled effectively by controlling the amplitude and rotational speed of the stator flux

linkage. For counter-clockwise operation, if the actual torque is smaller than the

reference, the voltage vectors that keeps ψs rotating in the same direction are selected.

The angle δ increases as fast as it can, and the actual torque increases as well. Once the

actual torque is greater than the reference, the voltage vectors that keep ψs rotating in

the reverse direction are selected instead of the zero voltage vectors. The angle δ

decreases, and the torque decreases also.

By selecting the voltage vectors in this way, the stator flux linkage (ψs) is

rotated all the time and its rotational direction is determined by the output of the

hysteresis controller for the torque.

Page 44: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

28

The switching table for controlling the amplitude and rotating direction of ψs is

as below and is used for both direction of operations. In Table 4.1, φ and τ are the

outputs of the hysteresis controllers for the flux linkage and torque, θ1 - θ6 denote the

section of the space vector plane where the present flux linkage vector is located, V1 -

V6 are the voltage vectors to be selected. This table formed the control strategy for

DTC of PMSM. If the φ = 1, then the actual flux linkage is smaller than the reference

value. The same is true for the torque.

Table 4.1: The switching table for Inverter

θ -Section

(stator flux linkage position)

Flux φ

Torque τ θ1 θ2 θ3 θ4 θ5 θ6

τ = 1

V2(110) V3(010) V4(011) V5(001) V6(101) V1(100) φ= 1

τ = 0 V6(101) V1(100) V2(110) V3(010) V4(011) V5(001)

τ = 1 V3(010) V4(011) V5(001) V6(101) V1(100) V2(110) φ= 0 τ= 0 V5(001) V6(101) V1(100) V2(110) V3(010) V4(011)

4.5 The implementation of the Direct Torque Control System

The basic DTC scheme is indicated in figure 4.3, torque and flux signals are

obtained from the estimator. These are regulated by using two hysteresis controllers. The

Page 45: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

29

hysteresis controllers outputs in turn switch the three inverter legs, applying a set of

voltage vectors across the motor.

Figure 4.3: Block Diagram Of the basic DTC For PMSM

Hysteresis Controller

Hysteresiscontroller

Switching table

Flux and Torque estimator

PMSM

VSI/PWM Inverter

ψref

Te

ψs

τ Terr

ψerr

Vdc

Va

Vb

Vc

φ

Sa

Sb Sc

θ

Tref

In the DTC there are no extra sensors needed compared to FOC except the dc-

bus voltage sensors. The continuous rotor position which is essential for torque control

in the FOC is not required if the initial rotor position is known.

4.5.1 Flux and Torque Estimator.

Page 46: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

30

Flux and torque estimator are used to determine the actual value of the torque

and flux linkage. Into this block enters the VSI voltage vector transformed to the qd-

stationary reference frame.

The three-phase variables are transformed into dq axes variables with the

following transformation:

ƒ d 2 -1 -1 ƒ a = 3 3 3 ƒ b

ƒ q 0 -1 1 ƒ c

√3 √3

(29)

where ƒ represents the stator currents, voltages and flux linkages.

The stator flux linkage is estimated by taking the integral of diffrerence between the

input voltage and the voltage drop across the stator resistance as,

ψd = ∫ (υd - Rsid ) dt

ψq = ∫ (υq - Rsiq ) dt (30)

The flux linkage phasor is given by

ψs = √(ψd 2 + ψq

2 ) (31)

In this block , the location of stator flux linkage (θ) is determined by the load

angle (δ) i.e the angle between the stator and rotor flux linkage. The load angle must be

Page 47: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

31

known so that the DTC can choose an appropriate set of vectors depending on the flux

location. The load angle can be determined by :

δ = tan-1 ψd (32)

ψq

The electromagnetic torque can be estimated with;

Te = 3 P ( ψd iq - ψq id )

2 4.5.2 Torque and Flux Hysteresis Comparator

The estimated torque and stator flux linkage are compared with the reference

torque and stator flux linkage . The difference between reference and estimated value is

compared in this block. If the actual torque is smaller than the reference value, the

comparator output at state 1 or otherwise.

state

1

Page 48: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

32

e

-1

Figure 4.4 : 2-level torque hysteresis comparator

state

1

e

0

Figure 4.5 : 2-level flux hysteresis comparator

4.5.3 Switching Table

Page 49: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

33

The hysteresis comparator states, φ and τ, together with the section number θ,

are now used by the switching table block to chose an appropriate volatge vector. The

switching table used in this project is shown in Table 4.2. A high hysteresis state

increases the corresponding quantity and vice versa. The selected voltage vector is sent

to the Voltage Source Inverter then synthesized.

Table 4.2: The switching table for Inverter

θ -Section (stator flux linkage position)

Flux φ

Torque τ θ1 θ2 θ3 θ4 θ5 θ6

τ = 1

V2 11-1

V3-11-1

V4 -111

V5 -1-11

V6 1-11

V1 1-1-1

τ = 0 V7 111

V0 -1-1-1

V7 111

V0 -1-1-1

V7 111

V0 -1-1-1

φ= 1

τ = -1 V4 -111

V5 -1-11

V6 1-11

V1 1-1-1

V2 11-1

V3-11-1

τ = 1 V1 1-1-1

V2 11-1

V3-11-1

V4 -111

V5 -1-11

V6 1-11

τ = 0 V0 -1-1-1

V7 111

V0 -1-1-1

V7 111

V0 -1-1-1

V7 111

φ= 0

τ = -1 V5 -1-11

V6 1-11

V1 1-1-1

V2 11-1

V3-11-1

V4 -111

4.5.4 Voltage Source Inverter

Page 50: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

34

The VSI synthesizes the voltage vectors commanded by the switching table. In

DTC, this task is quite simple since no pulse width modulation is used, the output

devices stay in the same state during the entire sample period.

Vdc 1 1 1

Sa Va Sb Vb Sc Vc 0 0 0

Figure 4.6: VSI and connection to PMSM

The connection of power switchers in a VSI with three-phase windings of a

PMSM is shown in Figure 4.6 , where the power switches of this voltage source inverter

are 180° conducting mode [ SD] , which means only three switching signal Sa, Sb and

Sc are needed to uniquely determined the status of six switchers. If the switcher in

upper leg of certain phase is on, the switching signal for this phase is defined as S = 1,

otherwise S=0 represents the switcher in lower leg of this phase is on. In this way there

Page 51: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

35

are six effective VSVs and two zero VSVs existing in the ordinary operation for a

inverter. Assuming that the VSV is located in the a-axis of the a, b, c reference frame

with phase a voltage Va applied alone, then the inverter output VSVs under different

switching states can be expressed as

νs = 2 νdc (Sa + Sb e j2/3π + Sc e j4/3π ) (33) 3

= 2 νdc (Sa + aSb + a2Sc) , a = e j2/3 π 3

where νs is the primary voltage vector, Sa, Sb , Sc represent three-phase switching states

and 2/3 is a transformation coefficient. According to above equation, the inverter

output VSV represent in terms of switching statue where six effective VSVs V1 – V6 are

apart from each other in space by 60° electric degrees and the two zero VSVs , V0, V7

are located in the centre of the space-vector plane.

The inverter keeps the same state until the output of the hysteresis controllers

changes their outputs at the sampling period. Therefore, the switching frequency is

usually is not fixed; it is changes with the rotor speed, load and bandwidth of the flux

and torque controllers.

4.6 Summary

Page 52: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

36

This chapter discussed the three signal which affect the control action in a DTC

system and also presents the block diagram of the hysteresis based DTC system. Each

block is described in detail and the functions of the blocks are explained.

In DTC technique , the actual flux and torque values are firstly calculated by the

estimator. The calculated torque/flux are compared with the torque/flux reference in the

hysteresis comparator. The output of the hysteresis comparators and the section number

(θ) are used to select the proper stator voltage vector based on the optimal voltage

vector switching logic so as to minimize the errors between the actual and reference

value of torque/flux. The selected voltage vector is sent to VSI. The VSI synthesizes the

voltage vectors commanded by the switching table. The inverter keeps the same state

until the output of the hysteresis controllers changes their outputs at the sampling period.

Therefore, the switching frequency is usually is not fixed; it is changes with the rotor

speed, load and bandwidth of the flux and torque controllers.

Page 53: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

37

CHAPTER 5

SIMULATION AND RESULT ANALYSIS

5.1 Introduction

In Chapter 3 and 4, the PMSM and DTC systems were explained in detail. In this

chapter the simulation models of DTC of PMSM and IM are programmed in Matlab

Simulink. The simulation models are presented and the results are discussed. The

PMSM parameter used in this project are given in Table 5.1. These parameters were

taken from reference [13 ]

Table 5.1: Parameter Values of PMSM used in Simulation

Page 54: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

38

Resistance R (ohm) 0.57Ω

Inductance [Ld,]H 8.72 x10-3 H

Inductance [Lq,]H 22.8 x10-3H

Flux Induced by magnets [wb] 0.108

Inertia[Jkgm^2] 3.8 x10-3

Friction factor 0.1 x 10-4

Pairs of pole 2

5.2 Simulink Block of the DTC for PMSM

Page 55: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

39

The simulink models of DTC of PMSM is shown Figure 5.1.

Figure 5.1 : Simulink Block of DTC for PMSM

5.2.1 Torque and Flux Hysteresis Block

Page 56: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

40

Torque and Stator Flux Hysteresis is shown in Figure 5.2 . The torque

reference value of -2 Nm to 2Nm at 0.067sec was produced by the signal generator. The

flux linkage reference was produced by step response with 0.808Wb.

Figure 5.2 : Model of the torque and flux hysteresis comparator

Page 57: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

41

Figure 5.3 : The actual torque, reference torque and the output of the hysteresis

comparator.

Figure 5.4 : The actual flux linkage, reference flux and the output of the hysteresis

comparator

5.2.2 Subsystem Block

Page 58: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

42

The subsystem is used to provide three-phase voltage, Va, Vb and Vc to the

PMSM . The hysteresis comparator states, φ and τ, together with the load angle, are

now used by the switching table block (select 2) to choose an appropriate voltage

vector. The switching table used in this project is shown in Table 4.2.

Figure 5.5 : Simulik model of Subsystem block.

5.2.3 PMSM Block

Page 59: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

43

In this block, the three-phase voltage and current ( Vabc and iabc) are transformed

to dq voltage and current by using park transformation. Vabc is 100V. The developed

torque is sent to the comparator.

Figure 5.6 : Simulink Block of PMSM

5.2.4 Stator flux – voltage model

Page 60: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

44

The stator flux-voltage model was developed based on the equations below,

υd = Rd id + d ψd - ωrψq

dt υq= Rq iq + d ψq + ωrψd

dt

The stator flux-voltage model is used to determine the amplitude of stator flux

linkage and the load angle in order to select the proper voltage vector for VSI.

Figure 5.7 : Stator flux – voltage model

5.3 Simulink Block of the DTC for IM

Page 61: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

45

The difference between the simulink block of the DTC for IM and PMSM are the

torque hysteresis block and motor properties. The torque reference is 15Nm at 15 Hz.

The Induction motor parameter is given in Table 5.2 . The simulink block of DTC in IM

is given in figure 5.8 and 5.9.

Table 5.2 : Parameter Values of IM used in Simulation

Stator Resistance R (ohm) 5.5Ω

Rotor Resistance R (ohm) 4.51 Ω

Inductance [Ls,]H 306.5 x 10-3

Inductance [Lr,]H 306.5 x 10-3

Inductance [Lm,]H 291.9 x 10-3

Inertia[Jkgm^2] 0.03

Load torque 1Nm

No of pole 4

Page 62: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

46

Figure 5.8 : The Simulink Block of DTC for IM

Page 63: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

47

Figure 5.9 : Simulink Block of IM

5.3.1 Torque Hysteresis

The torque hysteresis of the IM is a three –level hysteresis comparator. The zero

voltage vectors are used in IM because when the zero voltage vectors are selected the

stator flux linkage vector will be standstill in the position where it was and the

electromagnetic torque will decrease rapidly.

Page 64: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

48

Figure 5.10 : The Torque hysteresis comparator block for IM

5.4 Results

Matlab/Simulink models were developed to examine the basic Direct Torque

Control for Permanent Magnet Synchronous Motor and Induction Motor. The simulation

results is divided into three section. Section 5.4.1 presents the steady-state

performance of DTC systems in PMSM. The waveforms are flux linkage, torque and

speed respectively. The reference torque given is 2Nm to -2Nm and the reference stator

flux linkage is set at the rated value 0.808Wb

Section 5.4.2 discuss the performance of the IM at nominal torque reference, -

15Nm to 15Nm. Section 5.4.3 presents the comparison of PMSM and IM performance

at the same reference torque and flux.

Page 65: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

49

5.4.1 The DTC performance of PMSM.

The PMSM parameter used for this simulation is given in table 5.1. The torque

and flux linkage reference is set at -2Nm to 2 Nm and 0.808Wb respectively. The

waveforms of torque, speed, flux, hysteresis comparator are presented to show the

performance of DTC in PMSM.

Flux Torque Speed

rpm

N

m

Wb

Time (s)

Figure 5.11 : The waveform of the stator flux linkage, the developed torque and

speed of the PMSM. Tref at -2Nm to 2 Nm and 0.808Wb flux reference.

Page 66: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

50

Figure 5.11 shows that the motor speed is 1500rpm, the actual flux and torque is

about the reference values. There are ripples exist in both waveforms. Figure 5.12 and

5.13 show the torque response of DTC in PMSM. The actual torque response of the

Permanent Magnet Synchronous Motor is delayed by 0.6ms compared to the reference

torque.

Nm

N

m

Time (s)

Figure 5.12: The actual and reference torque ( Tref =-2Nm to 2 Nm)

Page 67: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

51

Time (s)

Figure 5.13 : The torque response

Figure 5.14 shows that the actual stator flux linkage ripples is varied from

0.797Wb to 0.817Wb at t = 0.01s. The reference flux is set at 0.808Wb. While Figure

5.15 present the flux linkage and torque ripples. The flux linkage ripples of PMSM is

about 0.02Wb and torque ripples is about 0.4 Nm

Page 68: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

52

Wb

Wb

Figure 5.14 : The stator flux linkage and reference flux (Flux ref at 0.808Wb)

Time (s)

Time (s)

Flux ripples Torque ripples

Wb

Nm

Figure 5.15 : Flux and Torque ripple of PMSM

Page 69: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

53

T

Terr τ

Nm

N

m

Time (s)

Figure 5.16 : Actual Torque, torque error and Hysteresis comparator.

The torque hysteresis band for PMSM is set at 0.2Wb. Figure 5.16 shows that the status

of the hysteresis comparator (τ):

1 when τerr = 0.2 Wb

-1 when τerr = -0.2Wb

Page 70: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

54

ψs

ψerr φ

Wb

Wb

Time (s)

Figure 5.17 : The actual and error of the stator Linkage flux and the hysteresis

comparator.

Figure 5.17 shows that the status of the hysteresis comparator (φ):

1 when ψerr = 0.01Nm

0 when ψerr = -0.01Nm

The flux hysteresis band is set at ± 0.01Nm

Page 71: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

55

5.4.2 The performance of DTC in IM .

Flux Torque Speed

Nm

W

b pu

Time (s)

Figure 5.18: The waveform of the stator flux linkage, the developed torque and speed

of the IM , torque reference is 15Nm to -15Nm, flux linkage is 1.2 Wb

Page 72: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

56

Actual Torque Reference Torque

Nm

N

m

Time (s)

Figure 5.19: The actual and reference torque of IM (Tref = -15Nm to15Nm)

Figure 5.19 shows that the actual torque response of the Induction Motor is

delayed by 0.8ms compared to the reference torque

Page 73: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

57

Actual Flux Reference Flux

Wb

Wb

Time (s)

Figure 5.20 : The waveform of the actual stator flux linkage and the reference .

The reference flux linkage is 1.2 Wb but the actual stator flux linkage shows in

figure 5.20 is varied from 1.1Wb to 1.22Wb. The flux ripple is about 0.12Wb.

Page 74: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

58

ψs

Wb

Wb

ψerr

φ

Time (s)

Figure 5.21 : The actual flux linkage , the error and the flux hysteresis comparator

output.

From the above figure shows that the status of the hysteresis comparator (φ):

0 when ψerr = -0.1

1 when ψerr = 0.1

Page 75: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

59

T Terr τ

Nm

N

m

Time (s)

Figure 5.22 : The actual torque , the torque error and the torque hysteresis comparator

output.

From the above figure shows that the status of the hysteresis comparator (τ):

1 when τerr > 0

-1 when τerr < 0

Page 76: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

60

Wb

Nm

Time (s)

Figure 5.23 : The flux and torque ripple of IM

Figure 5.23 the flux ripples of IM is about 0.12 Wb while the torque ripples is

about 1Nm.

Page 77: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

61

5.4.3 Comparison of DTC performance in PMSM and IM

The reference torque for both motors are set at -2 Nm to 2 Nm, 15Hz and flux

linkage at 0.808Wb. The motors parameter used as in Table 5.1 and 5.2.

Nm

W

b rp

m

Flux Torque Speed

Time (s)

(a) PMSM

Page 78: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

62

Flux Torque Speed

Wb

Nm

Time (s)

(b) Induction Motor

Figure 5.24 : The waveforms of flux, torque and speed (a) PMSM (b) IM when Tref

is -2Nm to 2Nm and the flux reference is 0.808Wb.

Figure 5.24 shows the performance of DTC in PMSM and IM. PMSM

performance is better than IM because the ripples exist in both waveforms is less than

IM.

Page 79: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

63

ATorque

ctual

Actual Torque Reference Torque

(a) PMSM

Time (s)

Time (s)

Nm

N

m

Nm

N

m

Actual Torque Reference Torque

(b) Induction Motor

Figure 5.25: Torque response of PMSM and IM when Tref is -2Nm to 2Nm

Page 80: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

64

(a) PMSM

Nm

N

m

Time (s)

Time (s)

(b) Induction Motor

Figure 5.26 : Torque ripples of PMSM and IM

Page 81: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

65

Figures 5.25 and 5.26 show the waveforms of electromechanical torque

produced by the PMSM and IM. The torque produced by IM has large ripples compare

to PMSM. The torque ripples of PMSM and IM is about 0.4Nm and 1Nm respectively.

Actual Flux Reference Flux

Wb

Wb

Time (s)

(a) PMSM

Page 82: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

66

Actual Flux Reference Flux

Wb

Wb

Time (s)

(b) Induction Motor

Figure 5.27 : Actual and reference flux linkage of PMSM and IM

Figure 5.27 shows that the flux ripples of IM is larger than PMSM.

The flux ripples of PMSM is 0.02Wb while the flux of IM varies from 0.41Wb to

0.57Wb.

Page 83: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

67

5.5 Summary

In this chapter the simulink models and results of DTC of PMSM and IM are

presented. The above simulation results show the DTC implemented in PMSM having

less torque and flux ripple and good torque response compare to IM.

Page 84: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

68

CHAPTER 6

CONCLUSION & FUTURE WORKS

6.1 Conclusion

DTC was introduced in the 1980’s for the application of Induction motor. In

1990’s , DTC was applied to PMSM . Direct Torque Control has a good dynamic torque

response when compared with other control method. The basic principle of the DTC is

quite the same for the implementation in PMSM and IM.

Since the introduction of DTC a lot of research has been done to improve the

performance of DTC drives while maintaining the good properties such as low

complexity, good dynamic response, high robustness.

Page 85: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

69

This thesis explained the mathematical equations related to the application of

DTC in PMSM. The equations show that the change of torque can be controlled by

keeping the amplitude of the stator flux linkage constant and increasing the rotating

speed of the stator flux linkage as fast as possible. The amplitude and rotating speed of

the stator flux linkage can be controlled by selecting the proper stator voltage vectors.

The differences in the DTC technique for PMSM and IM are presented. The simulink

block of DTC in PMSM and IM are presented. The simulation results examined the

implementation of the direct torque control in permanent magnet synchronous motor and

compared its performance with induction motor. The torque and flux linkage reference

are kept constant at the same level..

A detailed Simulink model for DTC of PMSM and IM has being developed.

Simulink has been chosen from several simulation tools because its flexibility.

Mathematical models can be easily incorporated in the simulation and the present

numerous toolboxes and support guides simplified the simulation of large system

compared to other software. Simulink is capable of showing real time results with

reduced simulation time and debugging.

It is shown in the simulation results of DTC in PMSM and IM that the DTC

implemented in PMSM having less level of torque and flux ripples and at the same time

maintaining good torque response.

6.2 Suggestion for future work.

Page 86: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

70

DTC technique is simple, robust and offer good dynamic performance. The main

drawback of the DTC is its relatively high torque and flux ripples and also variable

switching frequency. Therefore, the performance of the Direct Torque Control of PMSM

can be improved by reduced the high torque and flux ripples and maintaining a constant

switching frequency.

The source to the variable switching frequency problem is the use of hysteresis

comparators, in particular, the torque hysteresis comparator. The variable switching

frequency in a hysteresis-based DTC due to the variation of the time taken for the torque

error to touch the upper and lower hysteresis bands, which is caused by the variation of

the torque slopes with operating conditions. The torque ripples is directly related to the

width of the torque hysteresis comparator. Therefore, a constant switching frequency

torque controller should be designed to replace the conventional hysteresis-based

controller in order to minimize the torque .

REFERENCES

Page 87: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

71

1. I.Takahashi, T. Noguchi (1986). A New quick-response and high efficiency

control strategy of an induction machine,” IEEE Transactions on Industry

Application, Vol 22,

2. Bimal K. Bose(1988), A High-Performance Inverter-Fed Drive System of an

Interior Permanent Magnet Synchronous Machine. IEEE Transactions on

Industry Application, Vol 24, No.6.

3. Pragasen Pillay(1999) Modelling,Simulation and Analysis of Permanent Magnet

Motor Drives. IEEE Transaction On Industry Application, Vol 25.

4. N. R. N. Idris, A.H. M. Yatim.(2004). Direct Torque Control of induction

Machines with constant switching frequency and Reduced Torque Ripple. IEEE

Transaction On Industry Application, Vol 51, No 4.

5. L.Tang, L.Zhong, M.F. Rahman.(2003). A Novel Direct Torque Control for

Interior Permanent-Magnet Synchronous Machine drive with low ripple in

torque and flux – A speed-sensorless Approach. IEEE Transaction On Industry

Application, Vol 39, No. 6.

6. D. Casadie, G.Serra and A.Tani (2000) : Implementation Of A Direct Torque

Control Algorithm for Induction Motors Based On Discrete Space Vector

Modulation. Power Electronics IEEE Transaction On Power Electronics, Vol 15

No 4.

7. Isao Takashi, Toshishiko Noguchi (1997. Take a look back upon the past decade

of direct torque control . IECON 97

8. C.G.Mei, S.K. Panda, J.X.Xu And K.W.Lim.(1999).Direct Torque Control of

induction Motor-Variable switching sectors. Proc.IEEE PEDS.

Page 88: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

72

9. Z.Tan , Y.Li and M.Li. (2001). A direct Torque Control of induction motor

based on three level-inverter in Proc.IEEE PESC, Vol12.

10. C. Martins,X.Roboam, T.A Meynard and A.S. Caryalh.(2002). Switching

Frequency Imposition And Ripple Reduction In Dtc Drives By Multilevel

Converter. IEEE Transaction On Power Electronics, Vol 17

11. G.Escobar.(2003): A Family of switching Control Strategies for the reduction of

Torque Ripple in DTC. IEEE Transaction On Control System, Vol 11, No 6.

12. L.Tang, M.F.Rahman. (2001). A Matlab/Simulink Modul Based on Power

System Blocked – A New Direct Torque Control Strategy for Interior PMSM

Drives System.University of New South Wales, Australia.

13. L.Zhong, M.F.Rahman. (1997). Analysis of Direct Torque Control in Permanent

Magnet Synchronous Drives. IEEE Transaction On Power Electronics, Vol 12,

No 3.

14. Bimal K. Bose. (2002). Modern Power Electronics and AC Drives. Prentice Hall.

15. S.Dan, F.Weizhong,H.Yikang.(2000). Study on the Direct Torque Control of

Permanent Magnet Synchronous motor Drives. Zhejiang university, Hangzhoa,

China.

16. S.Dan, J.G. Zhu,H.Yikang.(2003). Continuous Direct Torque Control of

Permanent Magnet Synchronous motor Based on SVM. Zhejiang university,

Hangzhoa, China

17. Y.Yan, J.Zhu, H.Lu . Direct Torque Control of a Surface-Mounted Permanent

Magnet Synchronous motor Based on Accurate Modelling. University of

Technology, Sydney, Australia.

Page 89: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

73

APPENDIX A :

IMCH.C

Page 90: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

74

* sfuntmpl.c: Template C S-function source file. * * ------------------------------------------------------------------------- * | See matlabroot/simulink/src/sfuntmpl.doc for a more detailed template | * ------------------------------------------------------------------------- * * Copyright (c) 1990-97, by The MathWorks, Inc. * All Rights Reserved * $Revision 1.1 $ * You must specify the S_FUNCTION_NAME as the name of your S-function. */ #define S_FUNCTION_NAME imch /* Input Arguments */ /* * Need to include simstruc.h for the definition of the SimStruct and * its associated macro definitions. */ /* #include "tmwtypes.h" */ #include "tmwtypes.h" #include "simstruc.h" #define Rs ssGetArg(S,0) #define Rr ssGetArg(S,1) #define Ls ssGetArg(S,2) #define Lr ssGetArg(S,3) #define Lm ssGetArg(S,4) #define pole ssGetArg(S,5) /*====================* * S-function methods * *====================*/ /* Function: mdlInitializeSizes =============================================== * Abstract: * The sizes information is used by SIMULINK to determine the S-function * block's characteristics (number of inputs, outputs, states, etc.). */ static void mdlInitializeSizes(SimStruct *S) ssSetNumContStates( S, 4); /* number of continuous states */ ssSetNumDiscStates( S, 0); /* number of discrete states */ ssSetNumInputs( S, 3); /* number of inputs */ ssSetNumOutputs( S, 5); /* number of outputs */ ssSetDirectFeedThrough(S, 0); /* direct feedthrough flag */ ssSetNumSampleTimes( S, 1); /* number of sample times */

Page 91: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

75

ssSetNumInputArgs( S, 6); ssSetNumRWork( S, 0); /* number of real work vector elements */ ssSetNumIWork( S, 0); /* number of integer work vector elements*/ ssSetNumPWork( S, 0); /* number of pointer work vector elements*/ ssSetNumModes( S, 0); /* number of mode work vector elements */ ssSetNumNonsampledZCs( S, 0); /* number of nonsampled zero crossings */ ssSetOptions( S, 0); /* general options (SS_OPTION_xx) */ /* Function: mdlInitializeSampleTimes ========================================= */ static void mdlInitializeSampleTimes(SimStruct *S) ssSetSampleTime(S, 0, CONTINUOUS_SAMPLE_TIME); ssSetOffsetTime(S, 0, 0.0); /* Function: mdlInitializeConditions ========================================== * Abstract: * * In this function, you should initialize the continuous and discrete * states for your S-function block. The initial states are placed * in the x0 variable. You can also perform any other initialization * activities that your S-function may require. */ static void mdlInitializeConditions(real_T *x0, SimStruct *S) int i; for (i=0; i<4; i++) *x0++ = 0.0; /* Function: mdlOutputs ======================================================= * Abstract: * * In this function, you compute the outputs of your S-function * block. The outputs are placed in the y variable. */ static void mdlOutputs(real_T *y, const real_T *x, const real_T *u, SimStruct *S, int_T tid) double lm; double pl; lm = mxGetPr(Lm)[0]; pl = mxGetPr(pole)[0];

Page 92: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

76

y[0]=x[0]; y[1]=x[1]; y[2]=x[2]; y[3]=x[3]; y[4]=1.5*(pl/2)*lm*((x[0]*x[3])-(x[1]*x[2])); static void mdlUpdate(real_T *x, const real_T *u, SimStruct *S, int_T tid) /* Function: mdlDerivatives =================================================== * Abstract: * * In this function, you compute the S-function block's derivatives. * The derivatives are placed in the dx variable. */ static void mdlDerivatives(real_T *dx, const real_T *x, const real_T *u, SimStruct *S, int_T tid) /* x0=iq x1=id x2= iqr x3= idr u0=vq u1=vd u2=w */ double lr,ls,rr,rs,lm,a; lm = mxGetPr(Lm)[0]; lr = mxGetPr(Lr)[0]; ls = mxGetPr(Ls)[0]; rr = mxGetPr(Rr)[0]; rs = mxGetPr(Rs)[0]; a=1/(lm*lm-lr*ls); dx[0]=(u[2]*lm*lm*x[1]+rs*lr*x[0]+u[2]*lr*lm*x[3]-rr*lm*x[2]-lr*u[0])*a; dx[1]=(rs*lr*x[1]-u[2]*lm*lm*x[0]-rr*lm*x[3]-u[2]*lr*lm*x[2]-lr*u[1])*a; dx[2]=-(u[2]*lm*ls*x[1]+rs*lm*x[0]+u[2]*lr*ls*x[3]-rr*ls*x[2]-lm*u[0])*a; dx[3]=-(rs*lm*x[1]-u[2]*lm*ls*x[0]-rr*ls*x[3]-u[2]*lr*ls*x[2]-lm*u[1])*a; /* Function: mdlTerminate ===================================================== * Abstract: * * In this function, you should perform any actions that are necessary

Page 93: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

77

* at the termination of a simulation. For example, if memory was allocated * in mdlInitializeConditions, this is the place to free it. */ static void mdlTerminate(SimStruct *S) /* * YOUR CODE GOES HERE */ /*======================================================* * See sfuntmpl.doc for the optional S-function methods * *======================================================*/ /*=============================* * Required S-function trailer * *=============================*/ #ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */ #include "simulink.c" /* MEX-file interface mechanism */ #else #include "cg_sfun.h" /* Code generation registration function */ #endif

APPENDIX B:

FLXP2.C

Page 94: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

78

/* * sfuntmpl.c: Template C S-function source file. * ------------------------------------------------------------------------- * | See matlabroot/simulink/src/sfuntmpl.doc for a more detailed template | * ------------------------------------------------------------------------- * Copyright (c) 1990-97, by The MathWorks, Inc. * All Rights Reserved * $Revision 1.1 $ */ /* * You must specify the S_FUNCTION_NAME as the name of your S-function. */ #define S_FUNCTION_NAME flxp2 /* Input Arguments */ /* * Need to include simstruc.h for the definition of the SimStruct and * its associated macro definitions. */ /* #include "tmwtypes.h" */ #include "tmwtypes.h" #include "simstruc.h" /*====================* * S-function methods * *====================*/ /* Function: mdlInitializeSizes =============================================== * Abstract: * * The sizes information is used by SIMULINK to determine the S-function * block's characteristics (number of inputs, outputs, states, etc.). * */ static void mdlInitializeSizes(SimStruct *S) ssSetNumContStates( S, 0); /* number of continuous states */ ssSetNumDiscStates( S, 0); /* number of discrete states */ ssSetNumInputs( S, 1); /* number of inputs */ ssSetNumOutputs( S, 1); /* number of outputs */ ssSetDirectFeedThrough(S, 1); /* direct feedthrough flag */ ssSetNumSampleTimes( S, 1); /* number of sample times */ ssSetNumInputArgs( S, 0); ssSetNumRWork( S, 0); /* number of real work vector elements */

Page 95: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

79

ssSetNumIWork( S, 0); /* number of integer work vector elements*/ ssSetNumPWork( S, 0); /* number of pointer work vector elements*/ ssSetNumModes( S, 0); /* number of mode work vector elements */ ssSetNumNonsampledZCs( S, 0); /* number of nonsampled zero crossings */ ssSetOptions( S, 0); /* general options (SS_OPTION_xx) */ /* Function: mdlInitializeSampleTimes ========================================= */ static void mdlInitializeSampleTimes(SimStruct *S) ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME); ssSetOffsetTime(S, 0, 0.0); /* Function: mdlInitializeConditions ========================================== * Abstract: * * In this function, you should initialize the continuous and discrete * states for your S-function block. The initial states are placed * in the x0 variable. You can also perform any other initialization * activities that your S-function may require. */ static void mdlInitializeConditions(real_T *x0, SimStruct *S) /* Function: mdlOutputs ======================================================= * Abstract: * * In this function, you compute the outputs of your S-function * block. The outputs are placed in the y variable. */ static void mdlOutputs(real_T *y, const real_T *x, const real_T *u, SimStruct *S, int_T tid) if(u[0] > -1.5708 & u[0] <= -0.5236) y[0] = 1; else if(u[0] > -0.5236 & u[0]<= 0.5236) y[0] = 2; else if(u[0] >0.5236 & u[0] <=1.5708) y[0] = 3; else if(u[0] > 1.57 & u[0] <=2.618)

Page 96: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

80

y[0] = 4.0; else if(u[0] > 2.61 & u[0] <= 3.1416) y[0] = 5; else if(u[0] > -3.1416 & u[0] <= -2.618) y[0] = 5; else if(u[0]> -2.618 & u[0] <= -1.5708) y[0] = 6; static void mdlUpdate(real_T *x, const real_T *u, SimStruct *S, int_T tid) /* Function: mdlDerivatives =================================================== * Abstract: * * In this function, you compute the S-function block's derivatives. * The derivatives are placed in the dx variable. */ static void mdlDerivatives(real_T *dx, const real_T *x, const real_T *u, SimStruct *S, int_T tid) /* Function: mdlTerminate ===================================================== * Abstract: * * In this function, you should perform any actions that are necessary * at the termination of a simulation. For example, if memory was allocated * in mdlInitializeConditions, this is the place to free it. */ static void mdlTerminate(SimStruct *S) /*======================================================* * See sfuntmpl.doc for the optional S-function methods * *======================================================*/ /*=============================* * Required S-function trailer * *=============================*/ #ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */ #include "simulink.c" /* MEX-file interface mechanism */ #else

Page 97: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

81

#include "cg_sfun.h" /* Code generation registration function */ #endif

APPENDIX C:

SELECT2.C

/* * sfuntmpl.c: Template C S-function source file.

Page 98: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

82

* * ------------------------------------------------------------------------- * | See matlabroot/simulink/src/sfuntmpl.doc for a more detailed template | * ------------------------------------------------------------------------- * * Copyright (c) 1990-97, by The MathWorks, Inc. * All Rights Reserved * $Revision 1.1 $ */ * You must specify the S_FUNCTION_NAME as the name of your S-function. */ #define S_FUNCTION_NAME select2 /* Input Arguments */ * Need to include simstruc.h for the definition of the SimStruct and * its associated macro definitions. */ /* #include "tmwtypes.h" */ #include "tmwtypes.h" #include "simstruc.h" /*====================* * S-function methods * *====================*/ /* Function: mdlInitializeSizes =============================================== * Abstract: * * The sizes information is used by SIMULINK to determine the S-function * block's characteristics (number of inputs, outputs, states, etc.). * */ static void mdlInitializeSizes(SimStruct *S) ssSetNumContStates( S, 0); /* number of continuous states */ ssSetNumDiscStates( S, 0); /* number of discrete states */ ssSetNumInputs( S, 3); /* number of inputs */ ssSetNumOutputs( S, 3); /* number of outputs */ ssSetDirectFeedThrough(S, 1); /* direct feedthrough flag */ ssSetNumSampleTimes( S, 1); /* number of sample times */ ssSetNumInputArgs( S, 0); ssSetNumRWork( S, 0); /* number of real work vector elements */ ssSetNumIWork( S, 0); /* number of integer work vector elements*/ ssSetNumPWork( S, 0); /* number of pointer work vector elements*/ ssSetNumModes( S, 0); /* number of mode work vector elements */ ssSetNumNonsampledZCs( S, 0); /* number of nonsampled zero crossings */ ssSetOptions( S, 0); /* general options (SS_OPTION_xx) */

Page 99: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

83

/* Function: mdlInitializeSampleTimes ========================================= */ static void mdlInitializeSampleTimes(SimStruct *S) ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME); ssSetOffsetTime(S, 0, 0.0); /* Function: mdlInitializeConditions ========================================== * Abstract: * * In this function, you should initialize the continuous and discrete * states for your S-function block. The initial states are placed * in the x0 variable. You can also perform any other initialization * activities that your S-function may require. */ static void mdlInitializeConditions(real_T *x0, SimStruct *S) /* Function: mdlOutputs ======================================================= * Abstract: * * In this function, you compute the outputs of your S-function * block. The outputs are placed in the y variable. */ static void mdlOutputs(real_T *y, const real_T *x, const real_T *u, SimStruct *S, int_T tid) /* inputs: torque u[0], flux u[1] and angle u[2] * For torque =1 */ if(u[0] == 1 & u[2] == 1 & u[1] == 1) y[0] = 1; y[1] = 1; y[2] = -1; else if(u[0] == 1 & u[2] == 1 & u[1] == 0) y[0] = 1; y[1] = -1; y[2] = -1; else if(u[0] == 1 & u[2] == 2 & u[1] == 1) y[0] = -1; y[1] = 1; y[2] = -1; else if(u[0] == 1 & u[2] == 2 & u[1] == 0) y[0] = 1; y[1] = 1; y[2] = -1; else if(u[0] == 1 & u[2] == 3 & u[1] == 1) y[0] = -1; y[1] = 1; y[2] = 1; else if(u[0] == 1 & u[2] == 3 & u[1] == 0)

Page 100: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

84

y[0] = -1; y[1] = 1; y[2] = -1; else if(u[0] == 1 & u[2] == 4 & u[1] == 1) y[0] = -1; y[1] = -1; y[2] = 1; else if(u[0] == 1 & u[2] == 4 & u[1] == 0) y[0] = -1; y[1] = 1; y[2] = 1; else if(u[0] == 1 & u[2] == 5 & u[1] == 1) y[0] = 1; y[1] = -1; y[2] = 1; else if(u[0] == 1 & u[2] == 5 & u[1] == 0) y[0] = -1; y[1] = -1; y[2] = 1; else if(u[0] == 1 & u[2] == 6 & u[1] == 1) y[0] = 1; y[1] = -1; y[2] = -1; else if(u[0] == 1 & u[2] == 6 & u[1] == 0) y[0] = 1; y[1] = -1; y[2] = 1; /* for torque = 0 */ else if(u[0] == 0 & u[2] == 1 & u[1] == 1) y[0] = 1; y[1] = 1; y[2] = 1; else if(u[0] == 0 & u[2] == 1 & u[1] == 0) y[0] = -1; y[1] = -1; y[2] = -1; else if(u[0] == 0 & u[2] == 2 & u[1] == 1) y[0] = -1; y[1] = -1; y[2] = -1; else if(u[0] == 0 & u[2] == 2 & u[1] == 0) y[0] = 1; y[1] = 1; y[2] = 1; else if(u[0] == 0 & u[2] == 3 & u[1] == 1) y[0] = 1; y[1] = 1; y[2] = 1; else if(u[0] == 0 & u[2] == 3 & u[1] == 0) y[0] = -1; y[1] = -1; y[2] = -1; else if(u[0] == 0 & u[2] == 4 & u[1] == 1) y[0] = -1; y[1] = -1; y[2] = -1; else if(u[0] == 0 & u[2] == 4 & u[1] == 0) y[0] = 1; y[1] = 1; y[2] = 1; else if(u[0] == 0 & u[2] == 5 & u[1] == 1) y[0] = 1; y[1] = 1; y[2] = 1; else if(u[0] == 0 & u[2] == 5 & u[1] == 0) y[0] = -1; y[1] = -1; y[2] = -1; else if(u[0] == 0 & u[2] == 6 & u[1] == 1) y[0] = -1; y[1] = -1; y[2] = -1; else if(u[0] == 0 & u[2] == 6 & u[1] == 0) y[0] = 1; y[1] = 1; y[2] = 1; /* for torque = -1 */ else if(u[0] == -1 & u[2] == 1 & u[1] == 1) y[0] = -1; y[1] = 1; y[2] = 1; else if(u[0] == -1 & u[2] == 1 & u[1] == 0) y[0] = -1; y[1] = -1; y[2] = 1;

Page 101: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

85

else if(u[0] == -1 & u[2] == 2 & u[1] == 1) y[0] = -1; y[1] = -1; y[2] = 1; else if(u[0] == -1 & u[2] == 2 & u[1] == 0) y[0] = 1; y[1] = -1; y[2] = 1; else if(u[0] == -1 & u[2] == 3 & u[1] == 1) y[0] = 1; y[1] = -1; y[2] = 1; else if(u[0] == -1 & u[2] == 3 & u[1] == 0) y[0] = 1; y[1] = -1; y[2] = -1; else if(u[0] == -1 & u[2] == 4 & u[1] == 1) y[0] = 1; y[1] = -1; y[2] = -1; else if(u[0] == -1 & u[2] == 4 & u[1] == 0) y[0] = 1; y[1] = 1; y[2] = -1; else if(u[0] == -1 & u[2] == 5 & u[1] == 1) y[0] = 1; y[1] = 1; y[2] = -1; else if(u[0] == -1 & u[2] == 5 & u[1] == 0) y[0] = -1; y[1] = 1; y[2] = -1; else if(u[0] == -1 & u[2] == 6 & u[1] == 1) y[0] = -1; y[1] = 1; y[2] = -1; else if(u[0] == -1 & u[2] == 6 & u[1] == 0) y[0] = -1; y[1] = 1; y[2] = 1; static void mdlUpdate(real_T *x, const real_T *u, SimStruct *S, int_T tid) /* Function: mdlDerivatives =================================================== * Abstract: * * In this function, you compute the S-function block's derivatives. * The derivatives are placed in the dx variable. */ static void mdlDerivatives(real_T *dx, const real_T *x, const real_T *u, SimStruct *S, int_T tid) /* Function: mdlTerminate ===================================================== * Abstract: * * In this function, you should perform any actions that are necessary * at the termination of a simulation. For example, if memory was allocated * in mdlInitializeConditions, this is the place to free it. */ static void mdlTerminate(SimStruct *S)

Page 102: THE SIMULATION OF THE DIRECT TORQUE CONTROL OF ...

86

/*======================================================* * See sfuntmpl.doc for the optional S-function methods * *======================================================*/ /*=============================* * Required S-function trailer * *=============================*/ #ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */ #include "simulink.c" /* MEX-file interface mechanism */ #else #include "cg_sfun.h" /* Code generation registration function */ #endif


Recommended