Designing a controller for non-linear systems is difficult. For conventional controller design we require mathematical model and higher order differential equations. Some times we linearize mathematical model and design controller for system by applying well developed techniques for solving linear equations. But, as we know that real life problems are non-linear in nature and their models are not easy to handle mathematically.
We solve daily life problems by if-else rules. For example, if the ball is coming fast then swing the bat early. So, fuzzy rules logic is heuristic based which takes if-else conditions to solve daily life problems. It is linguistic based technique to design controller. It takes conditions from experience and intuition. Fuzzy logic is imitations of control laws that humans use.
Fuzzy tool in MATLAB:
MATLAB has built-in fuzzy controller designing tool. This tool allows to design rule base for controller in linguistics. Inputs and outputs are defined and membership functions of each input and outputs. This tool also allows you to select different membership functions and deffuzzification methods.
- Write fuzzy in MATLAB command window and a new window will pop-up.
- Select number of inputs from Edit>>add variables>>input/output
- Double Click the input and a new window will pop-up containing membership functions of that input. if you want to change MFs click Edit>> and find your required option for membership functions.
- click on controller to change model parameters and add rule base for fuzzy controller.
- In first window, in left bottom defuzzification methods can be changed. We will use centroid method.
Cruise Control is for maintaining fixed sped of object (car, for example). This is a feedback closed loop control system. A reference input at which speed is to be maintained is fed to the controller as reference input and actual speed of system is taken as feedback. The difference between these two is termed as error velocity. This error velocity is one input to the controller. Figure 1
The objective is to eliminate this error. If there is some error, controller must act accordingly.
Cruise Controller using Fuzzy:
Following is block diagram of complete system with controller, plant (to be controlled), input to the plant (control signal from fuzzy controller) and inputs to the fuzzy controller.
Input Membership functions:
Using Fuzzy tool in MATLB we can input membership function of desire shape. In this example we have velocity error and derivative of velocity error i.e. acceleration. The membership function of both are given below in triangular shape. we are considering three membership functions for each inputs.
For Error Velocity:
- NE: Negative error
- ZE: Zero Error
- PE: Positive Error
- NA: Negative Acceleration
- ZA: Zero Acceleration
- PA: Positive Acceleration
Base rule for controller is designed in such way that:
- if the actual speed of car is less than desired/set speed, error will be positive which means car needs to be speed up.
- if the actual speed of car is greater, error will be negative and there is need to slow down it.
Further, if speed is slow and acceleration is negative, which means that its speed is constantly decreasing and vice versa for increasing acceleration with negative error.
Now, the fuzzy controller from above rules is implemented in a Simulink model of cruise control as shown in following figure. It has a set value (reference point of velocity) as 10. There is summer which takes this reference and feedback actual velocity and generate a velocity error. Derivative of it (acceleration) is input with velocity to fuzzy controller. And fuzzy controller has file of above designed controller. Then state space of cruise control system and finally scopes to see the output.
Now, following is graphs for velocity error, acceleration, control signal to the system and velocity (in same order). It can be seen that when velocity is decreasing, acceleration is increasing and controller generates signal accordingly and it removes the error. (or add the decreased velocity).
This output window of cruise control shows that when velocity drops (decreasing) and acceleration is increasing and becomes constant. This shows that velocity is continuously decreasing. A control signal is generated by fuzzy controller according to rule base. Velocity is added the same amount which was required.