Open access peer-reviewed chapter - ONLINE FIRST

# Matlab Program Library for Modeling and Simulating Control Systems for Electric Drives Based on Fuzzy Logic

By Constantin Volosencu

Submitted: March 1st 2021Reviewed: November 3rd 2021Published: November 30th 2021

DOI: 10.5772/intechopen.101488

## Abstract

Fuzzy control of the speed of electric drives is an alternative in the field of the control system. Modeling and simulation of electric drive control systems based on fuzzy logic is an important step in design and development. This chapter provides a complete means of modeling and simulation of fuzzy control systems for DC motors, induction motors, and permanent magnet synchronous motors, made in the Matlab/Simulink program environment, useful for performing complex analyzes. The functioning of the programs is demonstrated by an example of characteristics obtained practically, with a functioning regime often encountered in practice.

### Keywords

• simulation
• modeling
• control of electric drives
• DC motors
• induction motors
• permanent magnet synchronous motors
• fuzzy PI controllers

## 1. Introduction

Electric drives play an important role in the development of machine tools, production systems, means of transport, and many other practical applications. The purpose of using electric drive control systems is to ensure good performance indicators. The use of fuzzy logic in the control of electric drives ensures the realization of high-performance systems. Modeling and simulation of electric drive control systems based on fuzzy logic are an important means in their design. This chapter presents a library of Matlab/Simulink programs designed to model and simulate electrical drive control systems based on fuzzy speed PI controllers.

In the literature, the control of electric drives based on fuzzy logic is studied in many works. Several Matlab programs for modeling and simulating electric drive systems based on fuzzy logic are presented on the Matlab website as well. Programs for modeling and simulating fuzzy DC drive systems are presented in [1, 2, 3]. Programs for modeling and simulating fuzzy driving systems of induction motors are presented in [4, 5]. The Matlab software has the facilities for modeling and simulating fuzzy systems [6] and electric drive systems [7, 8]. The problem of intelligent control of electric drives has been addressed in numerous papers over the years, including application of expert systems, fuzzy logic and neural networks in electric drives [9], fuzzy control of switched reluctance motor drives [10], or fuzzy adaptive vector control of induction motor drives [11]. The basic management systems of electric actuators have been treated in numerous works in the literature as well. The problem of using electric machines in variable speed control systems is treated in [12], principles of motion control with induction motors are presented in [13] and with permanent magnet, AC machines in [14], the issues of pulse-width modulation for electronic power conversion are presented in [15], principles of modeling and simulation of electric drive control systems are presented in [16]. The basic design of fuzzy PID controllers is shown in [17].

The author of this chapter published the results of his research in the field of fuzzy control of electric drives in specialized literature, addressing the following issues: speed control based on fuzzy PI controllers of DC machines [18], of synchronous machines with permanent magnets [19], of AC machines in general [20], demonstration of the robustness of fuzzy control systems of electric machines [21], analysis of the basic properties of fuzzy control systems [22, 23], tuning of fuzzy PID regulators [24, 25] and analysis of the stability of fuzzy control systems [26].

The chapter presents program libraries dedicated to fuzzy speed regulation of the main electric motors used in practice: direct current motors, induction motors, and permanent magnet synchronous motors, respectively in subsections 2, 3, and 4. For each element of the control systems are presented the equations used in modeling and the related subprograms. For each control system, the transient regime characteristics obtained by simulation are presented. Based on the transient regime characteristics, the values ​​obtained for the performance indicators of the control systems are highlighted, such as overshoot, rise time, error, and others.

## 2. Library programs

### 2.1 DC motor

The developed programs solve the problem of speed control of the DC machine with the control system from Figure 1.

The speed control structure from Figure 1 has the following components: MCC - DC motor, ML - load machine, CONV - power converter, RG-i - current controller, RF-Ω - fuzzy speed controller, Ti - current sensor, TΩ - speed sensor, CAN, CNA - analog to digital and digital to analog converters, MM-ISI - DC motor with state-space equations, Lim - anti-wind-up circuit. The control system variables are: Ω* - speed reference, Ω - motor speed, Ωm - measured speed, M - motor torque, Ms - load torque, eΩ - speed error, i* - current reference, iam - measured current, ei - current error, ui - command voltage, ua - motor armature voltage, ia - current motor, ue - excitation voltage.

The Simulink block diagram of the speed control system of DC drives based on the fuzzy PI controller is presented in Figure 2.

The block RF-win Figure 1 represents the Simulink model of the fuzzy speed controller. The other part of the Simulink diagram is a conventional control part of a linear control system.

The block srcmccis the internal current control loop and it has the Simulink block diagram from Figure 3.

The block Mccrepresents the DC motor and it has the equations:

The power converter has the block CONVand the current sensor has the block Ti. Their transfer functions are presented in their blocks. The current controller has a PI linear transfer function. The armature voltage ua is limited. The speed sensor has the block Tw. The current controller has anti-windup protection. The current reference is limited. The simulation diagram allows simulations in four quadrants for speed and torque. The diagram calculates a quadratic performance criterion of speed error with the formula:

E=e2dtE2

A theoretic design for fuzzy speed control systems for DC drives is presented in [27].

### 2.2 Induction motor

The structure of the fuzzy control system of the induction machine is presented in Figure 4.

The meanings of the notations in the Figure 4 are as follows: MAS - induction machine; ML- working machine; CONV- power electronic convertor; RG-i - stator phase current controllers; Ti—current sensor; Tθ—position sensor; TΩ—speed sensor; TCI—inverse Park coordinate transformation; BCC—block for calculating the reference currents in the vector control structure of the asynchronous machine with rotor flux orientation; RF-Ω—speed fuzzy PI controller; Ω—rotor speed; Ω*—speed reference; M*—torque reference; фr*—rotor flux reference; θs*—stator phasor position reference; id*, iq*—d, q stator current references; is*—stator current reference; Ωm—measured speed; θm—measured rotor position; ism—measured stator currents; eΩ—speed error; ei—current error; Si—control signals for power converter switches with pulse width modulation; Vcc—DC converter supply voltage; us—stator voltages; Ms—load torque. The induction motor is vector controlled with rotor flux orientation, with rotor flux reference ϕ*r and torque reference M* and the measured rotor position θm. The reference stator currents are calculated with the block TCI. The current regulators RG-i give the pulse width modulation signals Si for the electronic power converter CONV, fed from a DC voltage source VCC. The power converter CONV gives the stator voltages us.

The speed control system of induction motors based on the fuzzy PI controller is presented in Figure 5.

The model from Figure 5 implements an induction motor control structure with indirect field orientation in rotor coordinates [13, 28]. The block masrepresents the induction motor and it has the Equations [13, 29, 30]:

u¯sf=u¯sejθf,i¯sf=i¯sejθf,Φ¯sf=Φ¯sejθf,u¯rf=u¯rejθf+θ,i¯rf=i¯rejθf+θ,Φ¯rf=Φ¯rejθf+θ,u¯sf=Rsi¯sf+dΦ¯sfdt+jωfΦ¯sf,u¯rf=Rri¯rf+dΦ¯rfdt+jωfωΦ¯rf,M=32npLmReji¯sf.i¯rf,JdΩdt=MkfΩMsE3

The Eqs. (3) are written for the general flux, and in the case of vector control with rotor flux orientation, the flux is the rotor flux: θf = θr. CONV is a power inverter functioning in comutation, TCI is the inverse Park coordinate transformation [30], BCC is for calculating the reference currents in the vector control structure of the asynchronous machine with rotor flux orientation. BCC has the block diagram from Figure 6 [13, 30].

Where np - the pole pair number, Lm,r - magnetic and rotor inductances, s- slip frequency, Rr - rotor resistance, ωs* - stator frequency reference. Two-position current controllers RG-i with hysteresis are used.

### 2.3 Permanent magnet synchronous motor

The structure of the fuzzy control system of the permanent magnet synchronous motor is presented in Figure 7.

The meanings of the notations in Figure 7 are the same as in Figure 4, and MSMP is the permanent magnet synchronous machine. The permanent magnet synchronous motor is vector controlled with rotor flux orientation with rotor q current i*q as a torque reference, the rotor d current i*d at zero as a flux reference ϕ*r, and the measured rotor position θm.

The speed control system of induction motors based on the fuzzy PI controller is presented in Figure 8.

This diagram implements the rotor flux oriented control structure [14]. The block msmp + cscincludes the permanent magnet synchronous motor, with Equations [14, 30]:

u¯sf=u¯sejθ,i¯sf=i¯sejθ,Φ¯sf=Φ¯sejθ,u¯sf=Rsi¯sf+dΦ¯sfdt+Φ¯sf,M=32RejΦ¯sf.i¯sf,JdΩdt=MkfΩMsE4

The current controllers and the Park inverse coordinator transformation, like in the case of the induction motor.

### 2.4 Fuzzy speed controller

The Simulink diagram of fuzzy speed controller RF-w is presented in Figure 9.

It is developed based on the block diagram of the fuzzy controller RG-F from Figure 10.

The fuzzy controller has Mamdani’s structure with the fuzzification of the input variables xi, inference of the fuzzy values xf, with a rule base, and defuzzification of the fuzzy command uf. The fuzzy block gives the command ud. Different membership functions for the input and output variables, different inference methods, and different rule bases may be chosen [17, 19, 21, 22]. Here are some Matlab programs for fuzzy computing, as follows.

A program for defining the function of triangle membership:function [m]=triunghi(x,a,b,c) % parameters: a<b<c / m(a)=m(c)=0, m(b)=1 n=length(x); for i=1:n if x(i)<=a | x(i)>=c m(i)=0; elseif x(i)>a & x(i)<b m(i)=1/(b-a)*x(i)+a/(a-b); elseif x(i)==b m(i)=1; else m(i)=x(i)/(b-c)+c/(c-b); end end

A program for defining the function of decreasing trapezoidal membership:function [m]=trapezd(x,a,b) % parameters: a<b, m(a)=1, m(b)=0 n=length(x); for i=1:n if x(i)<=a m(i)=1; elseif x(i)<b & x(i)>a m(i)=x(i)/(a-b)+b/(b-a); else m(i)=0; end end

A program for defining the function of increasing trapezoidal membership:function [m]=trapezc(x,a,b) % parameters: a<b, m(a)=0, m(b)=0 n=length(x); for i=1:n if x(i)<=a m(i)=0; elseif x(i)>=b m(i)=1; else m(i)=x(i)/(b-a)+a/(a-b); end end end

A program for calculating the rule base 3–3 for DC motors:% Loading control system parameters: load pudmcc % Calculating the margins of discourse universes: diN=IN/Ki/5/Ti; diM=IM/Ki/5/Ti; ewM=KCAN*KTw*2*wb; ewb=ewM/2; deMt=KCAN*KTw/J*(MMt+kf*wb); deMc=KCAN*KTw/J*(MMc+kf*wb); pdi=diM/20; pe=ewM/20; pde=deMt/20; % discourse universes: udi=[-diM:pdi:diM]; ue=[-ewM:pe:ewM]; ude=[-deMt:pde:deMt]; % Definition of fuzzy values: NBdi=trapezd(udi,-diN,0); ZEdi=triunghi(udi,-diN,0,diN); PBdi=trapezc(udi,0,diN); NBe=trapezd(ue,-ewb,0); ZEe=triunghi(ue,-ewb,0,ewb); PBe=trapezc(ue,0,ewb); NBde=trapezd(ude,-deMc,0); ZEde=triunghi(ude,-deMc,0,deMc); PBde=trapezc(ude,0,deMc); % Normalization of discourse universes: ue=ue/ewb; ude=ude/deMc; udi=udi/diN; subplot(3,1,1),plot(ue,NBe,ue,ZEe,ue,PBe); xlabel('ew');ylabel('me');grid subplot(3,1,2),plot(ude,NBde,ude,ZEde,ude,PBde); xlabel('de');ylabel('mde');grid subplot(3,1,3),plot(udi,NBdi,udi,ZEdi,udi,PBdi); xlabel('di');ylabel('mdi');grid % Table of rules A1=[NBe; ZEe; PBe; NBe; ZEe; PBe; NBe; ZEe; PBe]; A2=[NBde; NBde; NBde; ZEde; ZEde; ZEde; PBde; PBde; PBde]; B=[NBdi; NBdi; ZEdi; NBdi; ZEdi; PBdi; ZEdi; PBdi; PBdi]; save daterf3 ue ude udi A1 A2 B ewM deMt

A program for fuzzy block implementation in Simulink scheme:function [dip]=bdf(e,de,A1,ue,A2,ude,B,udi) % Input variables: error e, error deivative: de % Output variable: dip % Inference with Larsen max-min method: dif=infermm(A1,e,ue,A2,de,ude,B); % Defuzzification with centre of gravity method: dip=defzfir(dif,udi,1); end

The fuzzy block RG-F has algebraic properties and the sector property presented in [22, 23, 24]. The fuzzy controller RF-w may be designed using a pseudo-equivalence with a linear PI controller with a grapho-analytical method [25, 26, 27], based on its input–output transfer characteristics [22, 23, 24].

## 3. Speed characteristics

With the help of the programs presented above, transient characteristics can be obtained for various operating regimes, which can be chosen by the signals applied to the speed prescription inputs and to the disturbing inputs of the load torques. Thus, transient regime characteristics can be obtained for speeds, currents, voltages, fluxes, mechanical torques, regulation errors, and others. These programs allow complex analyzes of the behavior of speed control systems based on fuzzy PI controllers. The fuzzy PI controller can be replaced with a conventional, linear PI controller. In order to demonstrate the good functioning of the programs, the following is an example of an operating regime often encountered in practice for the three-speed regulation structures. The simulated operating regime consists of: starting the machine idle up to the nominal speed, loading it with a nominal mechanical torque, and reversing the load. It was also chosen to exemplify the case when a conventional linear PI speed regulator is used. The characteristics in the two cases - fuzzy and linear - are presented in the same graph, and the same coordinate axes, for example. Figure 11ac show the speed characteristics for the DC machine, induction machines, and the permanent magnet synchronous machine, respectively.

It is observed that in the case of fuzzy control better quality control indicators are obtained: zero overshoot, shorter rise time, shorter time for elimination of load torque effect, etc. [18, 19, 20]. The fuzzy control structures are global absolute internal stable and external BIBO stable [28]. The fuzzy control structures are robust at parameter identification errors and at the perturbation from the load torque [21].

## 4. Conclusion

The chapter presents a library of Matlab/Simulink programs for the control of electric drives. Thus, Simulink schemes are presented for modeling and simulating the fuzzy speed control systems of direct current machines, induction machines with vector control with rotor flux orientation, and synchronous machines with permanent magnets. Matlab/Simulink programs are presented for modeling and simulating fuzzy PI controllers based on the Mamdani structure. To demonstrate the operation of the programs, the characteristics of the speed obtained in the case of the three adjustment structures are presented. Fuzzy system modeling programs can be developed for various types of membership functions, inference methods, and rule bases.

## Conflict of interest

The author has no conflict of interest.

The parameters of the three motors taken as examples are presented below.

The DC motor: Pn = 1 kW, Un = 220 V, nn = 3000 rot./min., η = 0,75, p = 2, J = 0,006 kgm2, Mn = 3,2 Nm, Ωn = 314 rad/s, In = 6A, IM = 10,8 A, Ra = 2,01 Ω, La = 0,034 H, Ta = 0,017 ms, ke = 0,664 Vs, km = 0,533 Nm/A, kf = 8.10−4 Nms, KCNA = KCAN = 1, Ilim = IM, UaM = 240 V.

The induction motor: Rs = 12,4 Ω; Rr = 12,4 Ω; Lm = 0,8 H; L = 0,06 H; L = 0,06 H; p = 4; kf = 0,008 Nms; J = 0,01 kgm2; MMc = 7 Nm; MMt = 24 Nm; nb = 750 rot/min; PN(Mc) = 550 W; IsN = 1,77 A; IsM = 8 A; UsN = 220 V.

The permanent magnet synchronous motor: PN = 400 W; IN = 3 A; IM = 8 A; nm = 4000 rot/min; nb = 3000 rot/min; MMc = 1,3 Nm; MMt = 3,4 Nm; J = 0,001 kgm2; kf = 0,0001 Nms; Rs = 0,6 Ω; Ld = 4 mH; Lq = 5 mH; p = 4; Φe0 = 0,072 Wb; Vcc = 200 V.

chapter PDF

## More

© 2021 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution 3.0 License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

## How to cite and reference

### Cite this chapter Copy to clipboard

Constantin Volosencu (November 30th 2021). Matlab Program Library for Modeling and Simulating Control Systems for Electric Drives Based on Fuzzy Logic [Online First], IntechOpen, DOI: 10.5772/intechopen.101488. Available from: