You are on page 1of 14

EjemplodeunControlDifuso

SistemadeNiveldeLquido

We will look at the control of a water tank. This water tank has a pipe flowing in and a pipe flowing out. The input flow rate is variable by a control valve. The output flow rate is dependant on the amount of water in the tank.

The water will drain out of the tank faster when there is more water in the tank and slower when there is less water in the tank. The goal of the control system is to take a set value and change the input valve so that the inflow rate will compensate for the outflow. The tank can be represented in Simulink using the following block:

This block can then be used in developing a control system for the tank using fuzzy logic. The Simulink model that we will be using to control the tank can be seen in the following illustration. The fuzzy controller inputs are the amount of error in the tank water level and the rate of change for the tank water level. These two inputs will be considered when the fuzzy logic controller determines the proper input valve setting.

The desired water level is set using the constant input and the max inflow is also set using a constant. The inflow max is in place since a given pipe can only provide a limited amount of water. The paramaters for the water tank are shown below:

Now that the simulink model has been made the fuzzy control system needs to be designed. In MATLAB, open the FIS Editor to develop a new fuzzy system. The default FIS has only one input, however the system we will be using has two inputs so we need to add another input. To do this click: Edit > Add Variable... > Input. This will add another input variable to the system. These two inputs can be named 'error' and 'rate' and the output can be named 'valve'. The system should now look like this:

The membership functions used for this system now need to be defined for each input and for the output. The functions for each can be seen in the following images. The error input will be in the range of -1 to 1 and the rate input will be in the range of -0.1 to 0.1 while the valve output will be in the range of 0 to 1.

There are three membership functions for the error input, negative, okay, and positive. The negative function is a trapezoidal membership function which has the following paramaters: [-1.27 -1.13 -0.8 0]. The okay membership function is triangular with the following paramaters: [-0.6667 0 0.6667]. The positive membership function is trapezoidal and it has paramaters: [0 0.8 1.11 1.77].

The rate input also has three membership functions: negative, none and positive. The negative membership function is trapezoidal with params: [-0.172 -0.11 -0.06 0]. The none membership function is triangular with params: [-0.07067 0 0.07067]. The positive membership function is trapezoidal with params: [-0.07067 0 0.07067]. This set of membership functions act on the rate input of the controller.

There are five output membership functions for the valve output on the system: close_fast, close_slow, no_change, open_slow, and open_fast. They are all triangular functions with the following paramaters: close_fast: [-1 -0.9 -0.8] close_slow: [-0.6 -0.5 -0.4] no_change: [-0.1 0 0.1] open_slow: [0.4 0.5 0.6] open_fast: [0.8 0.9 1]

With all of the input and output membership functions defined the rule base needs to be defined. For this system we want to increase water in when the error is positive, but we don't want to be putting in too much water if the error is moving towards zero rapidly otherwise the water level will overshoot. So if the error is okay we want to open or close the valve slowly, but if the error is negative or positive we want to open or close fast. The rules then that we will use in the rule editor are shown below:

Rules 4 and 5, as seen above, use the AND operator to combine the error and rate membership functions, this AND is the fuzzy connective AND, which is the product of the two membership functions at the input values. This process of combination was previously explained. The second and third rules lay down the course of action in the case that the error is large, regardless of rate. The first rule is the steady state position, when the error is okay the valve stays the same. The overlap in these functions ensures a mix of all of them until the error is at zero and the rate is zero, the the only rule that will be firing will be the first rule. Another way to visualize the rules is to look at the rules surface for the system. This can be accomplished by clicking on View > Surface in the FIS Editor.

The rule surface shows the output value for any combination of the two input values. Now that all of the rules have been defined and all of the membership functions have been defined the FIS can be exported to the workspace. To do this click: File > Export > To Workspace... and then enter in the a workspace variable, for this example you can use 'tank'. Now in the Simulink model double click the Fuzzy Logic Controller and enter 'tank' for the 'FIS matrix' paramater. This is important or else the Simulink model will now know where to look for the fuzzy control system.

The Simulink model can now be simulated for 10 seconds with all of the previous water tank paramaters and the FIS matrix imported to the workspace. The resulting water level for the system can be seen through a scope on the output:

The tank begins with a water level of 0.5 and then begins to drain when the fuzzy controller picks up and opens the valve rapidly and then slows down opening and closes it a little as the tank approaches the desired level of 1 where the system reaches steady state.

You might also like