## PLCs and Fuzzy Logic (6)

Defuzzification
The final output value from the fuzzy controller depends on the defuzzification method used to compute the outcome values corresponding to each label. The defuzzification process examines all of the rule outcomes after they have been logically added and then computes a value that will be the final output of the fuzzy controller. The PLC then sends this value to the output module. Thus, during defuzzification, the controller converts the fuzzy output into a real-life data value (e.g., 1720 counts).

There are many defuzzification methods, but all are based on mathematical algorithms. The two most common defuzzification methods are:
• maximum value
• center of gravity

Maximum Value Method.
The maximum value defuzzification method bases the final fuzzy output value on the rule output with the highest membership function grade. This method is mainly used with discrete output membership functions. Referring to the chart in Figure 9, the maximum value defuzzification method would specify that the output value of 2048 counts be chosen as the final output value because it has the largest grade value. If two or more outcomes from two or more rules have the same grade level, then the controller will select the final outcome value based on criteria supplied by the user during the fuzzy system programming. Such criteria specifies choosing either the left-most or right-most grade value of the two equal labels and their corresponding number of counts. The left-most criteria selects the lowest output value (the one with the fewest counts), while the right-most criteria selects the highest output value (the one with the most counts). So if both ZR and PL in Figure 9 had output grade values of 0.6, a fuzzy controller using the left-most criteria would select the ZR output value (2048 counts). A controller using the right-most criteria would select the PL output (4095 counts).

Center of Gravity Method.
The center of gravity defuzzification method, also referred to as “calculating the centroid,” mathematically obtains the center of mass of the triggered output membership functions. In mathematical terms, a centroid is the point in a geometrical figure whose coordinates equal the average of all the other points comprising the figure. This point is the center of gravity of the figure. In simple terms, the center of gravity for a fuzzy output is the output data value (as shown on the X-axis), that divides the area under the fuzzy membership function curve into two
equal parts. The center of gravity method is the most commonly used defuzzification method because it provides an accurate result based on the weighted values of several output membership functions. The output value that is sent to the output interface module is the output data value at the intersection of the horizontal axis and the centroid.
The center of gravity method applies to noncontinuous output membership functions as well as
continuous ones. In noncontinuous functions, the final output value for a seven-label output membership function (labels A through G) is expressed by the formula:

This equation implies that the final value of the output will be equal to the sum of each rule outcome grade multiplied by its actual output data value (i.e., counts) divided by the sum of the rule outcome grades. Referring to the noncontinuous membership example in Figure 9, the fuzzy logic controller will decide to send an output of 2867 counts to the output interface after completing the center of gravity calculation, which is as follows:

The fuzzy controller’s output is more than it would have been using the maximum value method (the maximum output label is ZR, which is 2048 counts). This indicates that the weighted value of the 0.4PL label pulls the value to the right (more counts).
Fuzzy controllers that use continuous membership functions and the center of gravity defuzzification method also use the previous summation equation to approximate the centroid value. However, in this case, the controller uses approximate digitized values for each membership function to compute each of the points in the summation.