*4.2.2. Electromagnetic torque error fuzzification*

Three trapezoidal membership functions are selected to fuzzify the torque error as shown in figure 14, so the following three fuzzy sets are used, N signify Negative, EZ for Zero and P for Positive.

Improved DTC Algorithms for Reducing Torque and Flux Ripples of PMSM Based on Fuzzy Logic and PWM Techniques 179

**Figure 14.** Membership functions for electromagnetic torque error

## *4.2.3. Stator flux angle fuzzification*

178 MATLAB – A Fundamental Tool for Scientific Computing and Engineering Applications – Volume 1

**Figure 12.** Matlab/Simulink design of the fuzzy logic switching table used in FDTC

**4.2. Inputs fuzzification and outputs defuzzification** 

*4.2.1. Stator flux error fuzzification* 

these two functions are indicated in figure 13.

**Figure 13.** Membership functions for stator flux error

*4.2.2. Electromagnetic torque error fuzzification* 

for Positive.

configuration of its inputs and outputs as membership functions.

Figure 12 shows the design of this fuzzy logic system in Matlab/Simulink and also the

In order to examine the fuzzy logic contribution to DTC, the choice of the membership functions number for the fuzzification of flux and torque errors has been repected in this part, i.e two membership functions for ΔФs, because a two level hysteresis controller was utilized to control the stator flux in basic DTC. Whereas three membership functions for the fuzzification of ∆Г because a three level hysteris controller was used to adjust the torque.

Two trapezoidal membership functions are selected to fuzzify the stator flux error, so the following two fuzzy sets are used, N signify Negative and P for Positive. The parameters of

Three trapezoidal membership functions are selected to fuzzify the torque error as shown in figure 14, so the following three fuzzy sets are used, N signify Negative, EZ for Zero and P The flux angle has a universe of discours equal 2π radians, as shown in figure 15. It is divided into six zones or sectors in order to be equivalent to that of the basic DTC. "thetai" means sector i, i.e "theta1" means sector 1 (θ1) and so on.

**Figure 15.** Membership functions for stator flux position

#### *4.2.4. State switches defuzzification*

The sole output control variable of fuzzy logic system is the inverter switching states S1, S3 and S5 or the selected voltage vector. Figure 16, illustrates the suggested output fuzzy set as singletons. Indeed, the choice of the stator volt dge vector is based on the rules indicated in table 3. Each control rule can be described using the state variables ΔФ, ΔΓ and θs and the control variables. The ith rule Ri can be written as:

Ri : if ΔФ, is Ai, ΔΓ is Bi and θs is Ci then S1 is a, S3 is b and S5 is c

Where a, b and c are a boolean variable. Ai, Bi and Ci denote the fuzzy set of the variables ΔФ, ΔΓ and θs, respectively.whereas Ri is the control rule number i.

**Figure 16.** Membership functions for state switches as singletons

### **4.3. Fuzzy logic switcher rules**

The most important part of designing the fuzzy controller (fuzzy logic system) is to design the rule base, because it gouverns the behiviour of fuzzy controller and stores the expert knowledge on how to control the plant. The fuzzy associative memory of Mamdani rule base model to develop DTFC is as shown in Table 3.


**Table 3.** Fuzzy logic switcher rules

#### **4.4. PI-Fuzzy speed controller synthesis**

The speed closed loop with the PI-Fuzzy controller structure is shown in Figure 17. The inputs of this FLC are the normalized values of the speed error denoted "e" and its rate of change denoted "de" that should remain between ±1. Wherefore, two scaling factors (Kne and KΔne) are used to normalize the actual speed error and its rate of change. The output of the controller is the normalized change of the motor torque command which generates the actual value of the motor torque demand when it's multiplied by a third scaling factor (Knc).

Improved DTC Algorithms for Reducing Torque and Flux Ripples of PMSM Based on Fuzzy Logic and PWM Techniques 181

**Figure 17.** Closed loop PI-Fuzzy speed controller

180 MATLAB – A Fundamental Tool for Scientific Computing and Engineering Applications – Volume 1

The most important part of designing the fuzzy controller (fuzzy logic system) is to design the rule base, because it gouverns the behiviour of fuzzy controller and stores the expert knowledge on how to control the plant. The fuzzy associative memory of Mamdani rule

θ2

θ3

**∆Г\∆Φ P N** 

 **P** V1 V2

 **Z** V0 V7

θ6

**∆Г\∆Φ P N** 

 **P** V4 V5

 **Z** V7 V0

**∆Г\∆Φ P N** 

 **P** V6 V1

 **Z** V7 V0

θ5

**∆Г\∆Φ P N** 

 **P** V3 V4

 **Z** V0 V7

The speed closed loop with the PI-Fuzzy controller structure is shown in Figure 17. The inputs of this FLC are the normalized values of the speed error denoted "e" and its rate of change denoted "de" that should remain between ±1. Wherefore, two scaling factors (Kne and KΔne) are used to normalize the actual speed error and its rate of change. The output of the controller is the normalized change of the motor torque command which generates the actual value of the motor torque demand when it's multiplied by a third scaling factor (Knc).

**Figure 16.** Membership functions for state switches as singletons

base model to develop DTFC is as shown in Table 3.

**4.3. Fuzzy logic switcher rules** 

θ1**,** θ<sup>7</sup>

**∆Г\∆Φ P N** 

 **P** V5 V6

 **Z** V0 V7

θ4

**∆Г\∆Φ P N** 

 **P** V2 V3

 **Z** V7 V0

**Table 3.** Fuzzy logic switcher rules

**4.4. PI-Fuzzy speed controller synthesis** 

**Figure 18.** Membership functions for speed error

The membership functions used, in this chapter, for the inputs and the output are the same, as shown in figure 18. Where, the following fuzzy sets used in these membership functions: NG is negative big, NM is negative medium, NP is negative small, EZ is equal zero, PP is positive small, PM is positive medium and PG is positive big.

From the speed behavior analysis, the table 4 has been developed to obtain a good performance in the speed closed loop. Whereas, from the membership functions of inputs and the output, and the rules presented in this table, the FLC elaborates the electromagnetic torque reference to be developed by the PMSM.


**Table 4.** PI-Fuzzy speed controller rules

### **4.5. Simulation results**

The sampling period has been chosen equal to 100 µs (10 KHz) for FDTC; in order to compare this strategy with basic DTC; despite the fact that the sampling time used to simulate DTC is less than that used in case of FDTC.

**Figure 19.** Mechanical speed (on the left) and electromagnetic torque (on the right) tracking performance under load variations in case of FDTC

**Figure 20.** Stator current waveform at 800 rpm with nominal load under FDTC

**Figure 21.** Stator current spectrum at 800 rpm with nominal load (on the left) and Stator flux in (α,β) axes under load variations (on the right) in case of FDTC
