Sie sind auf Seite 1von 46

LAKEHEAD UNIVERSITY

DEPARTMENT OF ELECTRICAL ENGINEERING 0573 FUZZY LOGIC CONTROLLER

FUZZY LOGIC CONTROLLER DESIGN FIELD-CONTROLLED DC MOTOR SPEED CONTROL

BRUNO SERGIO ADAMCZYK CLEITON FERREIRA DOS SANTOS LARISSA RODRIGUES CUSTDIO

APRIL 8th, 2014

CONTENTS

LIST OF FIGURES...................................................................................................... 4 LIST OF TABLES ....................................................................................................... 4

ABSTRACT................................................................................................................. 5 1. 2. INTRODUCTION .................................................................................................. 6 MODELING .......................................................................................................... 7 2.1. Parameters values........................................................................................ 9 2.2. Frequency domain representation by Laplace transform ........................ 9 2.3. Relation between Laplace transform and Ztransform, and frequency domain representation by Ztransform ............................................................. 10 2.4. DC motor block diagram with disturbance ........................................... 12 2.5. Comparison between continuous-time and discrete-time ...................... 12 2.6. Disturbances .............................................................................................. 13 2.7. Control objective ........................................................................................ 14 3. FUZZY LOGIC CONTROLLER ......................................................................... 15 3.1. Proportional-Integral (PI) fuzzy controller architecture .......................... 15 3.2. Normalisation ............................................................................................. 16 3.3. Partition....................................................................................................... 17 3.4. Membership function ................................................................................. 18 3.5. Fuzzy rule base .......................................................................................... 19 3.6. Fuzzification process ................................................................................. 20 3.7. Fuzzy inference engine .............................................................................. 20 3.8. Defuzzification process ............................................................................. 21 3.9. Fuzzy implication ....................................................................................... 23 4. SIMULATION RESULTS ................................................................................... 24 4.1. Discrete PI Controller................................................................................. 24 4.2. Proportional-Integral Fuzzy Logic Controller (PI-FLC) ........................... 25 4.3. Comparison between discrete PI and PI-FLC .......................................... 27 5. 6. RESULT ANALYSIS .......................................................................................... 29 CONCLUSION ................................................................................................... 30

REFERENCES .......................................................................................................... 31 ATTACHMENT I ....................................................................................................... 32

ATTACHMENT II ...................................................................................................... 35 ATTACHMENT III ..................................................................................................... 40 ATTACHMENT IV ..................................................................................................... 42

LIST OF FIGURES Figure 1 Electric equivalent circuit of the motor. ....................................................... 7 Figure 2 System model (open-loop). ...................................................................... 12 Figure 3 Open-loop response: discrete-time vs. continuous-time........................... 13 Figure 4 Motor model (closed-loop) for a fuzzy controller. .................................. 14 Figure 5 Block diagram: PI fuzzy controller. ........................................................... 16 Figure 6 Partitioning the error, , and change in error, . ..................................... 17 Figure 7 Partitioning the change in control, . ...................................................... 18 Figure 8 Crisp and centroid found for = 0.5 and = 0.25 by Singleton fuzzifier, Mamdani Minimun implication, and centroid defuzzification method. .......... 22 Figure 9 Control surface (graphical form), *. ....................................................... 23 Figure 10 System response, with discrete PI controller and disturbance applied at = 0.3. .................................................................................................................... 24 Figure 11 Error signal, with discrete PI controller. .................................................. 25 Figure 12 PI fuzzy logic controller response. .......................................................... 26 Figure 13 PI fuzzy logic controller response, with disturbance applied at = 0.3.26 Figure 14 Error and change in error signals (fuzzy logic controller inputs). ............ 27 Figure 15 Discrete PI controller vs. PI fuzzy logic controller. .................................. 28

LIST OF TABLES Table 1 Project variables and conventions. .............................................................. 8 Table 2 Normalised data ranges. ........................................................................... 16 Table 3 Fuzzy rule base. ........................................................................................ 19 Table 4 Control surface (table form), *. ............................................................... 22

ABSTRACT

The present work consists in develop a controller for a DC motor in order to control and regulate its speed. The motor was modeled in frequency domain from differential equations, which represents the system behavior mathematically. Since the Fuzzy Logic Controller (FLC) uses discrete values, it was necessary to convert the transfer function obtained in Laplace domain to Z-domain, which was made by Zero-OrderHold (ZOH) method. In order to prove the relation between both domains, a comparison was made applying a step signal and measuring the open loop response. However, the goal is to design a closed loop system where a controller will control the motor speed from an input voltage. Therefore, a FLC was implemented in a Proportional-Integral (PI) architecture, since the main goal is minimizing the error signal as much as possible, getting a value that tends to zero, consequently, reaching the set point. Moreover, a discrete PI controller was designed, with the aid of an optimized and heuristic algorithm. This implementation was necessary because a comparison between the controllers response must be done to show that the PI-FLC is as good as the discrete PI depending on its rules, gains and architecture were created. Several parameters and configurations were performed in order to tune the fuzzy controller (normalisation, partition, membership function, fuzzy rule base, fuzzy inference engine, fuzzifier, defuzzifier, and fuzzy implication), and all of them will shown in this document. Finally, the simulations are executed and the results are recorded and analyzed.

Key words: Fuzzy design; Proportional-Integral fuzzy logic controller; Fuzzy controller; Discrete PI controller; System modeling.

1. INTRODUCTION

Nowadays, with the technology advance, it is essential to project controllers that are able to regulate and control systems. These controllers can be analog or digital, and can assume several architectures being the most common the Proportional (P), Proportional-Integral (PI), and Proportional-Integral-Derivative (PID) structures. However, developing these controllers, sometimes, it is not trivial, since the gains vary from system to system and the tuning is a hard task, being often necessary to use Heuristic Methods to find them. Therefore, to simplify this process and improve functionality, other controllers were created. For instance, Fuzzy Logic Controllers (FLC), Neural Networks, Genetic Algorithms, Artificial Intelligence, and so on, are included in this huge group of new controllers. Based in this assumption, the main purpose of this project is to design and implement a fuzzy controller in order to control and regulate the DC motor speed with a field controlled, which means the current at the armature is constant. Fuzzy controllers are usually non-linear, in other words, they operate by bands. In general, this operations adaptability could be useful, but, sometimes, it could bring some problems to control the system. Everything depends on the goal and applicability of the project. Then, this project will try to cover some points regarding the FLC, as the PID controller. The document is divided in five main sections, and follows this order: modeling, design, simulations, analysis and conclusion.

2. MODELING

The project development began to set up the input and output desired, and then for modeling the system. The case considered for this project assumes that the current in the armature is constant equal to , therefore, the field-current is controlled. In Figure 1, it is shown the general model representation for the considered system, a DC motor, and its parameters.

Figure 1 Electric equivalent circuit of the motor.

The input of the system is given in voltage denoted by (), and the output desired is the motor speed, (), in rad/sec. Therefore, the equations, in time domain, for a DC motor are given by: () = () + ()
Equation 1

() 1 = () ()() + ()
Equation 2

() 1 = () () () ()
Equation 3

where: = () () () ( )

Since the motor field-current is controlled, () is constant, then, from Eq. 2: () = = 0 Therefore, using Kirchoff's voltage law, Equation 1 and Equation 3 could be rewritten as: () + () = ()
Equation 4

() + () = () () ()
Equation 5

For convenience, let define: () = () () = () = () = . = 1


Table 1 Project variables and conventions. Variable () () () () () () () () Name Motor torque constant Electromotive force constant Electric resistance Electric inductance Motor viscous friction constant Moment of inertia of the rotor Current in the armature Angular speed (time domain) Current in the field (time domain) Set point (time domain) Disturbance (time domain) Angular speed (frequency domain) Current in the field (frequency domain) Set point (frequency domain) Disturbance (frequency domain) Value 2.58 0.0182 0.83 0.63 x 10-3 0.0638 5.9 x 10-4 1 Unit N.m/A V.sec/rad Ohm H N.m.sec kg.m2 A rad/sec A V N.m

2.1. Parameters values

All parameters and variables used over this project are described in Table 1. In the table, the variables, their significance, their values and units of measure of are provided.

2.2. Frequency domain representation by Laplace transform

The transfer function (TF) for this system could be found applying the Laplace transform to Equation 4 and Equation 5 (Equation 6 and Equation 7, respectively), and combining both of them (Equation 8). Then, the following results are obtained: ()[ + ] = ()
Equation 6

()[ + ] = () ()
Equation 7

() =

(1) ( + )

[()

( + )

()]

Equation 8

It can be noted, from Equation 8, that this system is MISO (Multiple Input, Single Output), which means there are two inputs, but only one output. In this case, there is no way to obtain only one TF, since it is SISO (Single Input, Single Output). Therefore, two transfer functions will be provided, one relating the output and the input, the other relating the output and the disturbance,
() . () () ()

, and

The first one, called the system transfer function, is defined as follows: () () = = () ( )

( + ) ( + )

Equation 9

Then the TF relating the output and the disturbance is given by: () ( ) () = = () ( + )
Equation 10

The complete calculations for these transfer functions could be seen in ATTACHMENT I. Even though the Equation 8 is the Laplace domain representation for the continuous-time system, the fuzzy logic controller uses discrete variables, which means that this TF must be in the complex variable z (Z-domain). The next section shows the relation between s and z arguments, using the Zero-Order-Hold (ZOH) method.

2.3. Relation between Laplace transform and Ztransform, and frequency domain representation by Ztransform An easy method to convert the complex variable s in z is using the following relation: () = (1 1 ) {1 {
Equation 11

() }}

where: (1 1 ) { } 1 { }

Therefore, using the method shown in Equation 11, the Equation 8 is rewritten in two terms. One considers the motor TF, [() = disturbance TF, [() =
() ]. () () ()

], and the other considers the

10

() =

(( + ) + ( + ) + ( + )) + ( + + ) ( + ) + ()
Equation 12

where , , and are the partial fraction coefficients and, and are the z-poles, whose values are given by: = ( ) ( )
)

( )

where is the sampling period. Following the same principle, the transfer function relating the output and the disturbance could be seen in Equation 13.
( ) ( )

() =

Equation 13

Equation 12 and Equation 13 are the system representation in Z-domain, which means that the project works from now on with discrete values, based on the sampling period. The complete calculations are shown in ATTACHMENT II.

11

2.4. DC motor block diagram with disturbance

Every model could be represented in block diagram, which facilitates understanding the general system concept. Therefore, Figure 2 shows the system representation, where () is the input in voltage, () is the output in rad/sec, () is the input disturbance in N.m, () is the motor TF and, () is the disturbance transfer function.

Figure 2 System model (open-loop).

2.5. Comparison between continuous-time and discrete-time

For the values given in Table 1, it is possible to find the open-loop transfer function in Laplace domain (related with continuous-time) and Z-domain (related with discrete-time), and them are shown in Equation 14 and Equation 15 (for = 1), respectively. () . () = = () + . + .
Equation 14

() =

() . + . = () . + .
Equation 15

Note that the disturbance was not listed on this point, since the goal is doing the open-loop comparison between continuous-time and discrete-time. In Figure 3, the comparison is shown in a graphical way.

12

It can be concluded, from the figure, that the relationship between both transform is valid and proves that the selected sampling time for this system is consistent. Moreover, the functionality of the zero-order-hold method cited previously is maintain the present value until the next sampling period running.

Figure 3 Open-loop response: discrete-time vs. continuous-time.

2.6. Disturbances

The only disturbance within the system is a load on the motor during operation. This load disturbance affects the response of the system's change in error, and it could be either negative or positive, at any period. Physically, this disturbance could be understood as a load placed on the motor shaft, and this load generates a counterforce on the motor trying to stop the movement, therefore, the disturbance demands a bigger or lower response from the controller. From the values shown in Table 1, the transfer function relating the output and the disturbance could be seen in Equation 16.
13

() =

() . = () .
Equation 16

2.7. Control objective

The main object of this project is controlling the speed of the motor providing an input voltage the speed will be measure in rad/sec. Furthermore, the operation range for this motor could vary from 12 to +12 , which means that in speed the motor varies from 660/ to 660/ . For control purposes, the maximum torque varies based on the input voltage, and follows the Equation 17, where is the input. () = 3.516 + 46.424
Equation 17

The controller will be fed with the error signal, [], and the change in error signal, [], given by: [] = [] [] [] = [] [ 1] where [] is the desired speed, [] is the current response, [] is the current error, and [ 1] is the previous error. The closed-loop diagram model, for a fuzzy controller, is shown in Figure 4.

Figure 4 Motor model (closed-loop) for a fuzzy controller. 14

3. FUZZY LOGIC CONTROLLER

According to [PIEGAT, 2001], fuzzy set theory has opened new exploratory possibilities, among them: The possibility of creating artificial intelligence similar to human intelligence and providing automatons and robots with it; The creation of computers programmed with words; The application of information of any membership function for modeling, control, optimization and diagnostics of system and objects; The possibility of adapting the membership function according to the required accuracy of modeling, control, optimization, diagnostics, and so forth.

Therefore, a fuzzy control system (or fuzzy logic controller) is a control based on a mathematical system that analyses input values in terms of logic variables, converting them in any value between [0,1]. According to [CRESPO and others, 2010], a typical fuzzy logic controller includes three main parts: Input signal fuzzicated: converts discrete values into fuzzy sets using fuzzification; Fuzzy inference engine with rule base: this step decides what to do based on the rule base pre-defined by the user; Output signal defuzzicated: uses the fuzzy set provided by the inference engine to produce an output real values , also known as defuzzification.

3.1. Proportional-Integral (PI) fuzzy controller architecture

The PI fuzzy controller architecture is shown in Figure 5. The PI architecture characterizes by having a sum before the motor input. Since this project works as a proportional-integral controller, the controller output is defined as: [] = [] + [] + [ 1] where and are the integral and proportional gain, respectively.
15

Figure 5 Block diagram: PI fuzzy controller.

3.2. Normalisation The normalisation process consists in amplify/attenuate a value , which varies in the interval [ , ], in order to do it belongs to the interval [-1, 1] using an appropriate scaling factor. As previously stated, the operation range varies from 12 to +12 , consequently, for the input the scaling factor chosen was 112, and for the input was 12, since the maximum values will occur in = 0 and will be equal to the input. Following the same procedure, the chosen output scaling factor value, for the , was (112)
1

= 12. In Table 2, it could be seen the compilation of these values.

Table 2 Normalised data ranges. Variable Min Value -1 -1 -1 Max Value 1 1 1 Scaling factor (Attenuation/Amplification) 1 12 1 2 12

In short, the universe of discourse for the error, change in error, and change in control input could be understood as: [1, 1] [1, 1] [1, 1]

16

3.3. Partition

Partitioning consists in bands apportioning in order to get different actions due to the error and changing in error variations. Even though more bands can provide softly responses, they increase the controller complexity as well; however, at least three bands are necessary to get smoothly transitions. Based on this statement and previous experiments, the actual project uses three partitions (N, Z and P). It is possible to see in Figure 6 the selected partition to the error and change in error, and Figure 7 to the change in control.

Figure 6 Partitioning the error, , and change in error, .

17

Figure 7 Partitioning the change in control, .

3.4. Membership function

The membership function consists of the three linguistic terms defined by: Negative (N); Zero (Z); Positive (P).

Figure 6 and Figure 7 showed, in a graphical way, the membership function considered for the project. However, the graphs could be represented in sets, as follows: 1 1 1 0.5 1 0.75 0.5 0.25 0 0 1/3 2/3 () = () = { 1 0.75 0.5 0.25 0 0 0 0 () = () = { 1 0.75 0.5 0.25 () = () = { 0 0 1 0 0 0 0 0.25 2/3 0.25 0.5 0.25 0 0 0 } 0.5 0.75 1 1/3 0 0 } 0.5 0.75 1 1 1 1 } 0.5 0.75 1
18

() = {

1 1 1 1 0.75 0.5 0 0 0 () = { 1 0.75 0.5 0 0 0 () = { 1 0.75 0.5

0.5 0.25 0.5 0.25 0 0.25

0 0 0 0 0 } 0 0.25 0.5 0.75 1 0 0 0 1 0.5 } 0 0.25 0.5 0.75 1 1 1 1 0 0.5 } 0 0.25 0.5 0.75 1

Note that the membership function for the zero shape differs from input and output. In the considered case, the change in control has a shaper form.

3.5. Fuzzy rule base

According to [PIEGAT, 2001], the rule fuzzy base consists of logical rules determining causal relationships existing in the system between fuzzy sets of its inputs and output. For instance, a rule base can be as follow:

Rule 1: IF e is N and ce is N THEN cu is N Rule 2: IF e is N and ce is Z THEN cu is N Rule 3: IF e is N and ce is P THEN cu is Z Rule 4: IF e is Z and ce is N THEN cu is N Rule 5: IF e is Z and ce is Z THEN cu is Z Rule 6: IF e is Z and ce is P THEN cu is P Rule 7: IF e is P and ce is N THEN cu is Z Rule 8: IF e is P and ce is Z THEN cu is P Rule 9: IF e is P and ce is P THEN cu is P

Since three rules were selected to the error and change in error, the final number of rules reach a total value of nine rules. The rules can be represented in a matrix form, such as in Table 3.
Table 3 Fuzzy rule base.

e\ce N P Z

N N N Z

P N Z P

Z Z P P
19

3.6. Fuzzification process

Into fuzzification process, the membership grades of the numeric values of the model inputs in fuzzy sets of the inputs are calculated. The most common fuzzifiers used in this process are: Singleton fuzzifier; Gaussian fuzzifier; Triangular fuzzifier.

Therefore, due to its applicability the Singleton fuzzifier was chosen for this project. Thus, it is defined as follows: () = { 1, 0, = =

() = {

1, 0,

3.7. Fuzzy inference engine

The inference engine is an algorithm, which calculates the controller response by computing the rule bases into a subset. The Mamdani Minimum Inference (MMI) was select as the fuzzy inference engine of this project. The formula used to do the fuzzy inference engine, by Singleton fuzzifier, could be seen in Equation 19, where is shown the simplified version. () = { { { (, ), (), (), ()}}}
Equation 18

This equation could be simplified as shown in Equation 19: () = {{ ( ), ( ), ()}}


Equation 19

20

3.8. Defuzzification process

The defuzzification process calculates from the resulting membership function a crisp, numeric output value, , being an effect of the numeric inputs values and . There are some methods to do this process, among which the most well-known are: Middle of maxima method; Least of maxima method; Max of maxima method; Center of maxima method; Centroid method.

For this project, the centroid method was chosen because it assumes that the crisp representative is the coordinate of the center of gravity (centroid) of the surface under the curve determined by this function. This value could be calculated by Equation 20, as follows: = = (). . d (). d

Equation 20

For instance, let define the follow assumption: = 0.5 = 0.25

Using the fuzzy inference engine defined previously, the follow crisp is found: 2 2 2 1 1 1 1 1 1 () = { ()} = { , , , , , , , , } 3 3 3 2 2 2 3 3 3 Then, by the centroid method, the final result, which means the output signal from the controller is equal to: = 0.1667

21

The complete calculations, for this and , could be seen in ATTACHMENT III. In Figure 8, the crisp and the centroid could be seen in a graphical way.

Figure 8 Crisp and centroid found for = 0.5 and = 0.25 by Singleton fuzzifier, Mamdani Minimun implication, and centroid defuzzification method.

Table 4 Control surface (table form), *. e\ce -1 -0.75 -0.5 -0.25 0 0.25 0.5 0.75 1 -1 -0.6786 -0.6786 -0.6786 -0.65 -0.6786 -0.4286 -0.25 0 0 -0.75 -0.6786 -0.6786 -0.6786 -0.65 -0.6786 -0.4286 -0.25 0 0 -0.5 -0.6786 -0.6786 -0.55 -0.4868 -0.55 -0.1667 0 0.25 0.25 -0.25 -0.65 -0.65 -0.4868 -0.3553 -0.3553 0 0.1667 0.4286 0.4286 0 -0.6786 -0.6786 -0.55 -0.3553 0 0.3553 0.55 0.6786 0.6786 0.25 -0.4286 -0.4286 -0.1667 0 0.3553 0.3553 0.4868 0.65 0.65 0.5 -0.25 -0.25 0 0.1667 0.55 0.4868 0.55 0.6786 0.6786 0.75 0 0 0.25 0.4286 0.6786 0.65 0.6786 0.6786 0.6786 1 0 0 0.25 0.4286 0.6786 0.65 0.6786 0.6786 0.6786

22

Therefore, for the partition defined previously, the control surface is shown in Table 4, by Singleton fuzzifier, Mamdani Minimun implication, and centroid defuzzification method. This table could be visualized in a graphical form as well. Then, in Figure 9 shows the compiled results.

Figure 9 Control surface (graphical form), *.

3.9. Fuzzy implication

The fuzzy implication used forms the basis of the inference engine, which was explained by the Equation 19. Therefore, the implication takes the form of Equation 21, which is the Mamdani Minimum implication operator. (, , ) = (, , ) = { (, ), ()}
Equation 21

23

4. SIMULATION RESULTS

The simulation results are divided into three parts: discrete PI controller, PI fuzzy logic controller, and the comparison between both controllers. The algorithm used for the simulation could be seen in ATTACHMENT IV.

4.1. Discrete PI Controller

In order to compare the fuzzy logic controller results, a discrete PI controller was constructed using an optimized and heuristic method. The response for this controller could be seen in Figure 10.

Figure 10 System response, with discrete PI controller and disturbance applied at = 0.3 .

Note that the response is smoothly and there is no overshoot in the motor. Moreover, the disturbance was applied in the system in order to analyse whether the system attenuates or amplifies it. Other important point is that the response is being
24

measured in voltage, to be easier to compare the set point (input) with the output. In Figure 11, it is shown the error signal for this controller discrete PI controller.

Figure 11 Error signal, with discrete PI controller.

4.2. Proportional-Integral Fuzzy Logic Controller (PI-FLC)

The Proportional-Integral Fuzzy Logic Controller was developed to control the DC motor speed such as the discrete PI controller. The result will be compiled and compared with the discrete PI controller in order to contrast the differences between these controllers. The parameterization for the FLC was based on previous experiences that showed good results for nine rules. All the parameters/configuration for the PI-FLC could be seen in the previous section 3.0. In Figure 12, it is shown the PI-FLC response for different levels of set point, where a set point of six volts represents a speed, approximately, of 330rad/sec, and a set point of minus three volts represents a speed, approximately, of -175rad/sec (opposite direction, or |175|rad/sec in absolute value). It is possible to notice that the system stabilize in steady state for any input.
25

Figure 12 PI fuzzy logic controller response.

Figure 13 PI fuzzy logic controller response, with disturbance applied at = 0.3 . 26

The PI-FLC was tested with disturbance conditions as well, and the results are shown in Figure 13, which shows the set point and response in voltage. The same set point was chosen, and the disturbance consisted of a load applied in the motor shaft after the stabilization at = 0.3. It is possible to see that the PI-FLC rejected the disturbance restabilising the system. In Figure 14, it is shown the error and change in error signals for this controller, PI-FLC, with the disturbance.

Figure 14 Error and change in error signals (fuzzy logic controller inputs).

4.3. Comparison between discrete PI and PI-FLC

The comparison between the two controllers showed that the PI-FLC proportioned good results, even better than the conventional discrete PI controller, due to nonappearance of an overshoot and a smaller settling time, being on steady state in less than 0.04 seconds.

27

It is possible to compare both of the responses in Figure 15, with a disturbance applied at = 0.3. The following points of the proportional-integral fuzzy logic controller could be evidenced because they presents better results compared to the discrete PI controller: No overshoot (both responses present it); Less settling time, which means that stabilizes faster; Better disturbance rejection.

Figure 15 Discrete PI controller vs. PI fuzzy logic controller.

28

5. RESULT ANALYSIS

Analysing the results obtained from the comparison of the two controllers was possible to verify that the discrete PI controller proportioned good results with a first order response without overshoot; however, the PI-FLC presented a much better response, stabilizing in less than 0.04 seconds. One reason that explain why the discrete PI-FLC showed better results is the fact that this kind of controller can deal with non-linearity. Fuzzy controllers generate the response based on the change in error tendency, for this reason it can take control actions in advance in order to minimize the error, providing good responses such as the presented on this paper. The gains for the discrete PI controller were obtained with an optimized and heuristic algorithm, which tested many values of gains and compared all the responses to come up with the best response based on settling time and overshoot. Even though the discrete PI controller showed good results, the proportionalintegral fuzzy logic controller overcome its results by using just nine rules. In fact, better results for the PI-FLC could be given by increasing the number of the rule bases, but it also would increase the complexity of the project. The designer expertise plays an important role when it is necessary tuning a PIFLC, which depends on the designer acquaintance about the plant behavior and previous experiences tuning this kind of controller.

29

6. CONCLUSION

The main purpose of the project was achieved, which was design a fuzzy logic controller in order to control and regulate a DC motor speed. However, in addition to design the FLC, several other processes were needed, among them how to obtain a transfer function from differential equations, the relation between Laplace domain and Z-domain, how to tune a discrete PI controller, and other related with process control. Therefore, a discrete PI controller was designed in order to compare its results with the PI fuzzy logic controller. Thus, an optimized and heuristic algorithm was developed to find the best gains to the controller. The FLC was designed in order to obtain the best response as a discrete PI controller. Using only nine rules, the PI-FLC was able to control the system without overshoot and in an acceptable time (half of the discrete PI controller). Initially, 49 rules (7x7) were created for the fuzzy controller, but there was no big difference from the nine rules shown in this project. Since that, the response is similar and the system is robust (accepts some variations), opted not to use the biggest rule base due to the calculation complexity will increase proportionally. The experiment validates the choices made for the proportional-integral fuzzy logic controller, including its inference engine, fuzzifier, defuzzifier, and membership functions. The simulation results showed that any overshoot occurred, and the settling time for the PI-FLC was less than half of the discrete PI controller. Furthermore, the error tends to zero, which means that the controller is able to achieve the set point the main goal for every controller. It is known that some improvements should be implemented according to the system. However, the FLC showed that it is possible to change the way of controllers are designed, bringing human knowledge for the system control. It could be affirmed that this project was successful in designing a fuzzy logic controller for a DC motor speed control. These practical applications of Fuzzy Logic are very useful in the process control fields due to its implementation and simulation availability.

30

REFERENCES

CHATTERJI, S., MATHEW, L., and NISA S. A., (2013) Comparative analysis of speed control of DC motor using A.I. technique. International Journal of Engineering Research and Applications.

CRESPO, B., TROLLEY, Z., ZAPORZAN, B. (2010) Fuzzy logic control of motor position. Lakehead University.

PACHTER, M. (1981) Speed control of a field controlled D.C. traction motor. International Federation of Automatic Control.

PIEGAT, A. (2001) Fuzzy modeling and control. Physica-Verlag, Heidelberg, New York.

PIVONKA, P. (2002) Comparative analysis of fuzzy PI/PD/PID controller based on classical PID controller approach. IEEE.

PLACENCIA, A. C., RAMIREZ, E. G. (2004) How to tune fuzzy controllers. IEEE.

RAHMANI, R., and others (2012) Fuzzy logic controller optimized by particle swarm optimization for dc motor speed control. IEEE.

SHAW, I. S. (1998) Fuzzy control of industrial systems: theory and applications. Kluwer Academic Publishers, Boston, Massachusetts.

31

ATTACHMENT I The model with input () and output () is: () = () + ()


Equation 22

() = () ()() + ()
Equation 23

() = () () () ()
Equation 24

() + () = () () ()

where: = () () () For convenience: () = () () = ()

Field-controlled, then: () . () = = 0

Appling Laplace Transform in Equation 22: () + () = ()

32

() + () = ()

()[ + ] = () () 1 = () ( + ) 1 ( )

() = ()

[ + ( )]

() = ()

( )

[ + ( )]

Equation 25

Appling Laplace Transform in Equation 24:


() 1 + () = () () ()

() = = 1 () + 1 () = () ()

() [ + ] = () ()
Equation 26

From Equation 25 and Equation 26: 1 ( ) 1 () [ + ] = () () [ + ( )]

33

() = ()

( )

( + ) ( + ) ( )

()

1 ( + )

() = ()

( + ) ( + )

()

1 ( + )

or () = () ( + ) [() ( + ) ()]

Let: () = ( + ) ( + )

() =

() = ()[()() ()]

34

ATTACHMENT II Relation between () and () is: () = (1 1 ) {1 { () }}

Part 1: Motor transfer function: ( () = () )

( + ) ( + )

() () = = ()

( )

( + ) ( + )

Therefore: () = ( )

( + ) ( + )

+ + ( + ) ( + )

( ) ( ) = | = = ( )( ) = ( + ) ( + ) ( ) = 0

( ) = ( + ) | | ( + ) ( + ) = ( ) = = ( ) ( + ) ( ) ( + )
35

( ) | = ( + ) | ( + ) ( + ) =

= (

( )

) ( + )

( ) ( + )

Continuous time: () = +
( )

( )

Discrete time: [] = +
( )

( )

where is the sampling time.

() = (1

1 )

{ +

( )

() = (

1 ) [ + 1


( )

] ( )

() = +

( 1)
( )

( 1)
( )

Let: =
( )

36

( )

() = +

( 1) ( 1) +

() =

( )( ) + ( 1)( ) + ( 1)( ) ( )( )

() =

[ 2 ( + ) + ()] + [ 2 (1 + ) + ] + [ 2 (1 + ) + ] 2 ( + ) + ()

() =

(( + ) + ( + ) + ( + )) + ( + + ) ( + ) + ()

Part 2: Disturbance transfer function: () = () ( + )

1 ( ) () () = = () ( + )

1 ( ) () = = + ( + ) ( + )

1 ( ) ( + )

| = 0

1 ( ) ( )

=(

1 1 ) ( ) =

37

1 ( ) | 1 1 = ( + ) | = = ( ) ( ) = ( + ) ( ) =

1 ( )

1 1 () = + ( + )

Continuous time: () = 1 1 () +

Discrete time: 1 1 () [] = + 1 1 () + }

() = (1 1 ) {

1 1 ( ) () = ( )[ + 1

1 ( )
(

] )

() = ( 1) [

1 ( ) 1

1 ()
(

] )

1 () ( 1) 1 () = ( ) + ( )
( ) 1 1 ( ) ( ) + () ( 1)

() =

38

() =

1 1 1 () 1 ( ) + ( )
( )

() =

) ( ) (

39

ATTACHMENT III Let define and , then find by Singleton fuzzifier, Mamdani Minimum implication and centroid method. = 0.5 () = { 1, 0, = =

= 0.25

() = {

1, 0,

() = {{ ( ), ( ), ()}} ( ) = 1 ( ) = 0 1 2 ( ) = 3 3 ( ) = 0 ( ) = 0.5 ( ) = 1 : 1 () = { ( ), ( ), ()} = {1,0, {1,1,1,0.5,0,0,0,0,0}}

1 : 1 () = {0,0,0,0,0,0,0,0,0}

2 2 : 2 () = { ( ), ( ), ()} = {1, , {1,1,1,0.5,0,0,0,0,0}} 3 2 2 2 1 2 : 2 () = { , , , , 0,0,0,0,0} 3 3 3 2 1 3 : 3 () = { ( ), ( ), ()} = {1, , {0,0,0,0.5,1,0.5,0,0,0}} 2 1 1 1 3 : 3 () = {0,0,0, , , , 0,0,0} 2 2 2 1 4 : 4 () = { ( ), ( ), ()} = { , 0, {1,1,1,0.5,0,0,0,0,0}} 3 4 : 4 () = {0,0,0,0,0,0,0,0,0}

40

1 2 5 : 5 () = { ( ), ( ), ()} = { , , {0,0,0,0.5,1,0.5,0,0,0}} 3 3 1 1 1 5 : 5 () = {0,0,0, , , , 0,0,0} 3 3 3 1 1 6 : 6 () = { ( ), ( ), ()} = { , , {0,0,0,0,0,0.5,1,1,1}} 3 2 1 1 1 1 6 : 6 () = {0,0,0,0,0, , , , } 3 3 3 3 7 : 7 () = { ( ), ( ), ()} = {0,0, {0,0,0,0.5,1,0.5,0,0,0}}

7 : 7 () = {0,0,0,0,0,0,0,0,0}

2 8 : 8 () = { ( ), ( ), ()} = {0, , {0,0,0,0,0,0.5,1,1,1}} 3 8 : 8 () = {0,0,0,0,0,0,0,0,0}

1 9 : 9 () = { ( ), ( ), ()} = {0, , {0,0,0,0,0,0.5,1,1,1}} 2 9 : 9 () = {0,0,0,0,0,0,0,0,0}

() = { ()} = { , , , , , , , , }

By centroid defuzzifier: = .

41

ATTACHMENT IV

Below are the scripts and functions utilized to do this project.


% % % % % % % +-----------------------------------------------------------------------+ | PI Fuzzy Logic Controller | | | | Bruno Sergio Adamczyk (PUCPR) | | Cleiton Ferreira dos Santos (PUCPR) | | Larissa Rodrigues Custodio (IFG) | +-----------------------------------------------------------------------+

% +-----------------------------------------------------------------------+ clear all, close all, clc, warning off; step_length = input('Please insert the step: '); e = -1:step_length:1; ce = -1:step_length:1; for r=1:length(e) for c=1:length(ce) cu_star(r,c) = defuzzification(e(r), ce(c), step_length); end end surf(e,ce, cu_star); % +-----------------------------------------------------------------------+ function cu_star = defuzzification(e_star, ce_star, step_length) %% if (e_star <= -0.75) uN_e_star = 1; uZ_e_star = 0; uP_e_star = 0; elseif (e_star > -0.75) && (e_star <= -0.5) uN_e_star = 1; uZ_e_star = (4/3)*e_star + 1; uP_e_star = 0; elseif (e_star > -0.5) && (e_star <= 0) uN_e_star = -2*e_star; uZ_e_star = (4/3)*e_star + 1; uP_e_star = 0; elseif (e_star > 0) && (e_star <= 0.5) uN_e_star = 0; uZ_e_star = -(4/3)*e_star + 1; uP_e_star = 2*e_star; elseif (e_star > 0.5) && (e_star <= 0.75) uN_e_star = 0; uZ_e_star = -(4/3)*e_star + 1; uP_e_star = 1; else uN_e_star = 0; uZ_e_star = 0; uP_e_star = 1; end 42

%% if (ce_star <= -0.75) uN_ce_star = 1; uZ_ce_star = 0; uP_ce_star = 0; elseif (ce_star > -0.75) && (ce_star <= -0.5) uN_ce_star = 1; uZ_ce_star = (4/3)*ce_star + 1; uP_ce_star = 0; elseif (ce_star > -0.5) && (ce_star <= 0) uN_ce_star = -2*ce_star; uZ_ce_star = (4/3)*ce_star + 1; uP_ce_star = 0; elseif (ce_star > 0) && (ce_star <= 0.5) uN_ce_star = 0; uZ_ce_star = -(4/3)*ce_star + 1; uP_ce_star = 2*ce_star; elseif (ce_star > 0.5) && (ce_star <= 0.75) uN_ce_star = 0; uZ_ce_star = -(4/3)*ce_star + 1; uP_ce_star = 1; else uN_ce_star = 0; uZ_ce_star = 0; uP_ce_star = 1; end %% cu = -1:step_length:1; u_cu_N = trapmf(cu,[-2 -1 -0.5 0]); u_cu_Z = trimf(cu,[-0.5 0 0.5]); u_cu_P = trapmf(cu,[0 0.5 1 2]); i = 1; % R1 B_cu_prime(i,:) = rule(uN_e_star, uN_ce_star, u_cu_N); i = i+1; % R2 B_cu_prime(i,:) = rule(uN_e_star, uZ_ce_star, u_cu_N); i = i+1; % R3 B_cu_prime(i,:) = rule(uN_e_star, uP_ce_star, u_cu_Z); i = i+1; % R4 B_cu_prime(i,:) = rule(uZ_e_star, uN_ce_star, u_cu_N); i = i+1; % R5 B_cu_prime(i,:) = rule(uZ_e_star, uZ_ce_star, u_cu_Z); i = i+1; % R6 B_cu_prime(i,:) = rule(uZ_e_star, uP_ce_star, u_cu_P); i = i+1; % R7 B_cu_prime(i,:) = rule(uP_e_star, uN_ce_star, u_cu_Z); i = i+1; % R8 B_cu_prime(i,:) = rule(uP_e_star, uZ_ce_star, u_cu_P); i = i+1;

43

% R9 B_cu_prime(i,:) = rule(uP_e_star, uP_ce_star, u_cu_P); %% [m,n] = size(B_cu_prime); % m = row = #of rules; n = column = step for k=1:n B_cu(k) = max(B_cu_prime(:, k)); end %% cu_star = defuzz(cu, B_cu, 'centroid'); disp(sprintf('cu* = %0.4f', cu_star)); plot(cu_star, 0, 'r*'); hold on; plot(cu, B_cu, 'LineWidth',2); hold on legend(sprintf('Centroid = %0.4f', cu_star)); line([cu_star cu_star],[0 1],'Color','k'); text(cu_star,0.2,' centroid','FontWeight','bold'); hold off; pause(1); title('\mu(cu*)'); xlabel('cu'); ylabel('\mu(cu)'); %% function [B_cu_prime] = rule(uN_e_star, uN_ce_star, u_cu_N) for j=1:length(u_cu_N) B_cu_prime(j) = min(uN_e_star, min(uN_ce_star, u_cu_N(j))); end % +-----------------------------------------------------------------------+ clear all, close all, clc, warning off;close all, clc, clear all; e = -1:.05:1; cu = -1:.05:1; %% uN_e = trapmf(e, [-2 -1 -0.5 0]); uZ_e = trimf(e, [-0.75 0 0.75]); uP_e = trapmf(e, [0 0.5 1 2]); figure; plot(e, uN_e, e, uZ_e, e, uP_e, 'LineWidth',2); title('Membership Function'); xlabel('e, ce'); ylabel('\mu(e), \mu(ce)'); axis([-1 1 -0.05 1.1]); text(-0.74,1.04,'N','FontWeight','bold'); text(-0.01,1.04,'Z','FontWeight','bold'); text(0.74,1.04,'P','FontWeight','bold'); %% uN_cu = trapmf(cu, [-2 -1 -0.5 0]); uZ_cu = trimf(cu, [-0.5 0 0.5]); uP_cu = trapmf(cu, [0 0.5 1 2]); figure; plot(cu,uN_cu, cu,uZ_cu, cu,uP_cu, 'LineWidth',2); title('Membership Function'); xlabel('cu'); ylabel('\mu(cu)'); axis([-1 1 -0.05 1.1]); 44

text(-0.74,1.04,'N','FontWeight','bold'); text(-0.01,1.04,'Z','FontWeight','bold'); text(0.74,1.04,'P','FontWeight','bold'); % +-----------------------------------------------------------------------+ close all, clear all, clc, warning off; FuzzyRules_seven_atenuado = readfis('FuzzyRules_three'); V1 = 3; % [V] T1 = 0; V2 = -6; % [V] T2 = 0.1; V3 = 9; % [V] T3 = 0.2; Tau = 3; % [V] Disturbance Time_Tau = 0.3; % [sec] Time_Tau Tau_end = 0; Time_Tau_end = 0.02; Ts = 0.001; % Sampling time Simulation_Time = 0.4; D = 0.0638; % [N.m.s] (motor viscous friction constant) J = 5.9e-4; % [kg.m^2] (moment of inertia of the rotor) Ke = 2.58; % [N.m/A] (motor torque constant) Kv = 0.0182; % [V/rad/sec] (electromotive force constant) Lf = 0.63e-3; % [Henry] (electric inductance) Rf = 0.83; % [Ohm] (electric resistance) %% % Motor Transfer Function A = Ke/(D*Rf); B = Ke/((-D*Lf)*((-D/J) + (Rf/Lf))); C = Ke/((-J*Rf)*((-Rf/Lf) + (D/J))); x = exp(-(D/J)*Ts); y = exp(-(Rf/Lf)*Ts); Coef1 = (A + B + C); Coef2 = -(A*(x+y) + B*(1+y) + C*(1+x)); Coef3 = (A*(x*y) + B*y + C*x); %% % Disturbance Transfer Function % num = [N_Dist] N_Dist = (1/D)*(exp(-(D/J)*Ts) - 1); % den = [1 D_Dist] D_Dist = -exp(-(D/J)*Ts); 45

%% sim('FuzzyLogic_PI_Discrete_Controller.slx'); fuzzy_Input = Input; fuzzy_resp = PID_resp_V; fuzzy_cont = cont; fuzzy_error = error; fuzzy_change_error = change_error; fuzzy_disturbance = disturbance; %% Kp = 1; Ki = 100; Kd = 0.0; sim('PID_Controller_Discrete.slx'); discretePI_Input = Input; discretePI_resp = PID_resp_V; discretePI_cont = cont; discretePI_error = error; discretePI_change_error = change_error; % it's not being utilized discretePI_disturbance = disturbance; %% FIGURES % Fuzzy Controller figure; hold on; plot(fuzzy_Input, 'b'); plot(fuzzy_resp, 'r'); plot(fuzzy_cont, 'g'); plot(fuzzy_error, 'k'); plot(fuzzy_change_error, 'c'); plot(fuzzy_disturbance, 'm'); hold off; title(sprintf('PI Fuzzy Controller')); axis([0 Simulation_Time -7 12.5]); xlabel('Time [sec]'); ylabel('Voltage [V]'); legend('Set point','Response','Controller signal',... 'Error','Change in error','Disturbance','location', 'southeast'); %% % Discrete PI Controller figure; hold on; plot(discretePI_Input, 'b'); plot(discretePI_resp, 'r'); plot(discretePI_cont, 'g'); plot(discretePI_error, 'k'); plot(discretePI_change_error, 'c'); plot(discretePI_disturbance, 'm'); hold off; title(sprintf('Discrete PI Controller')); axis([0 Simulation_Time -7 12.5]); xlabel('Time [sec]'); ylabel('Voltage [V]'); legend('Set point','Response','Controller signal',... 'Error','Change in error','Disturbance','location', 'southeast'); % +-----------------------------------------------------------------------+

46

Das könnte Ihnen auch gefallen