Int. J. Systems, Control and Communications, Vol. 6, No. 1, 2014
69
Design and simulation of fuzzy membership functions for the fuzzification module of fuzzy system using operational amplifier Shruti Jain Department of Electronics and Communication, Jaypee University of Information Technology, Waknaghat, P.O. Dumehar Bani, PIN – 173234, Distt. Solan, Himachal Pradesh, India E-mail:
[email protected] Abstract: This paper presents design methods for the designing and simulation of fuzzy membership functions (S, Z, trapezoidal and triangular) using operational amplifier in SPICE. This is the interactive tool which gets the design requirements for the system to be designed from the user. I have also calculated the electrical parameters like slew rate, common mode rejection ration, gain, power dissipation and resistances for each membership function. An operational amplifier is a DC coupled high gain electronic voltage amplifier with a differential input and a single ended output. Keywords: operational amplifier; fuzzy system; membership functions; SPICE. Reference to this paper should be made as follows: Jain, S. (2014) ‘Design and simulation of fuzzy membership functions for the fuzzification module of fuzzy system using operational amplifier’, Int. J. Systems, Control and Communications, Vol. 6, No. 1, pp.69–83. Biographical notes: Shruti Jain is with Department of Electronics and Communication Engineering, Jaypee University of Information Technology, Waknaghat, Solan, Himachal Pradesh, India.
1
Introduction
An operational amplifier (op-amp) is a direct coupled high gain amplifier usually consisting of one or more differential amplifiers and usually followed by a level translator and an output stage. The output stage is generally a push pull or push pull complementary symmetry pair. The op-amp is a versatile device that can be used to amplify dc as well as ac input signals and was originally designed for computing such mathematical functions as addition, subtraction, multiplication, and integration (Gayakwad, 2002). Various electrical parameters of op-amp (Gayakwad, 2002) are:
Copyright © 2014 Inderscience Enterprises Ltd.
70
S. Jain
•
Differential input resistance: Differential input resistance is the equivalent resistance that can be measured at either the inverting or non-inverting input terminal with the other terminal connected to ground.
•
Output resistance: Output resistance is the equivalent resistance that can be measured between the output terminal of the op-amp and the ground.
•
Large signal voltage gain: Since the op-amp difference voltage between two input terminals, the voltage gain of the amplifier is defined as the ratio of output voltage to differential input voltage. That is: A=
VO Vid
Because output signal amplitude is much larger than the input signal, the voltage gain is commonly called large signal voltage gain. •
Common mode rejection ratio (CMRR): It is defined as the ratio of differential gain to common mode gain. A high CMRR helps to reject common mode signals such as noise successfully. CMRR = Ad Acm CMRR (dB ) = 20 log ( Ad Acm )
•
Slew rate (SR): It is defined as the maximum rate of change of output voltage per unit time and it is expressed in volts/microseconds. SR = max [ dVo dt ]
Fuzzy logic is a powerful problem solver methodology with wide range of applications in industrial control, consumer electronics, management, medicine, expert system and information technology (Berkan and Trubatch, 1997). It provides a simple way to draw definite conclusions from vague, ambiguous or imprecise and incomplete information. It is a natural way of making a decision and is very close to the way the human beings think and make decision even under highly uncertain environments. Fuzzy logic is a departure from classical two-valued sets and logic, that uses ‘soft’ linguistic (e.g., large, hot, tall) system variables and a continuous range of truth values in the interval [0, 1], rather than strict binary (true or false) decisions and assignments (Drankov et al., 1993). Formally, fuzzy logic is a structured, model-free estimator that approximates a function through linguistic input/output associations. Fuzzy rule-based systems apply these methods to solve many types of ‘real-world’ problems, especially where a system is difficult to model, is controlled by a human operator or expert, or where ambiguity or vagueness is common. In this paper, I will discuss regarding the designing and electronic implementation of fuzzy membership functions (S, Z, triangular, and trapezoidal) using operational amplifier and simulating it with PSPICE software. PSPICE is a programme that simulates electronic circuits in our PC. We can view any voltage or current waveform in our circuit. SPICE calculates these voltages and currents versus time (transient analysis) or versus frequency (AC analysis) (Nguyen, EE563). Most SPICE programmes also perform other analysis like DC, sensitivity, noise and
Design and simulation of fuzzy membership functions
71
Distortion. Today, SPICE is available from many vendors who have added schematic drawing tools to the front end and graphics post processors to plot the results (Rashid, 2009).
2
Fuzzy system
There are five parts of the fuzzy system shown in Figure 1. Fuzzification of the input variables, application of the fuzzy operator (AND or OR) in the antecedent, implication from the antecedent to the consequent, aggregation of the consequents across the rules, and defuzzfication. Step 1
Fuzzification: The first step is to take the inputs and determine the degree to which they belong to each of the appropriate fuzzy sets via membership functions. In the fuzzy logic, the input is always a crisp numerical value limited to the universe of discourse of the input variable and the output is a fuzzy degree of membership in the qualifying linguistic set (always the interval between 0 and 1).
Step 2
Apply fuzzy operator: Rule composition: once the inputs have been fuzzified, we know the degree to which each part of the antecedent has been satisfied for each rule. If the antecedent of a given rule has more than one part, the fuzzy operator is applied to obtain one number that represents the result of the antecedent for that rule. This number will then be applied to the output function. The input to the fuzzy operator is two or more membership values from fuzzified input variables. The output is a single truth value. There are different fuzzy operators: AND methods are supported: min (minimum) and prod (product), OR methods are also supported: max (maximum), and the probabilistic OR method probor.
Step 3 Implication: Before applying the implication method, we must take care of the rule’s weight. Every rule has a weight (a number between 0 and 1), which is applied to the number given by the antecedent. Generally, this weight is 1 and so it has no effect at all on the implication process. From time to time we may want to weight one rule relative to the others by changing its weight value to something other than 1. Step 4 Aggregation: Since decisions are based on the testing of all of the rules in an FIS, the rules must be combined in some manner in order to make a decision. Aggregation is the process by which the fuzzy sets that represents the output variable, just prior to the fifth and final step, defuzzification. The input of the aggregation process is the list of truncated output functions returned by the implication process for each rule. The output of the aggregation process is one fuzzy set for each output variable. Different types of aggregation functions are max (maximum), probor (probabilistic OR) and sum (simply the sum of each rule’s output set).
72
S. Jain
Step 5 Defuzzification: The input for the defuzzification process is a fuzzy set (the aggregate output fuzzy set) and the output is a single number. As much as fuzziness helps the rule evaluation during the intermediate steps, the final desired output for each variable is generally a single number. However, the aggregate of a fuzzy set encompasses a range of output values and so must be defuzzified in order to resolve a single output value form the set. Perhaps the most popular defuzzification method is the centroid calculation, which returns the centre of area under the curve. Figure 1
3
Fuzzy system model
Fuzzification technique
Fuzzification is the process of changing a real scalar value into a fuzzy value (Yen and Langari, 1998). This is achieved with the different types of fuzzifiers. The first step is to take the inputs and determine the degree to which they belong to each of the appropriate fuzzy sets via membership functions. Let’s take an example of a motor, i.e., controlling the speed of a motor by changing the input voltage. When a set point is defined, if for some reason, the motor runs faster, we need to slow it down by reducing the input voltage. If the motor slows below the set point, the input voltage must be increased so that the motor speed reaches the set point. So, the input variable is VOLTAGE and output variable is SPEED. Now, let’s divide input and output variables in their linguistic variables (for body temperature linguistic variables are no fever, slight fever, high fever and very high fever). Let’s define linguistic variables for output as slow, normal, fast and that for input as less voltage, no change and more voltage. Each of these linguistic terms is associated with a fuzzy set defined by a corresponding membership functions. Membership function of a Fuzzy set is defined as the characteristic function or curve of a fuzzy set, which assigns to each element in a Universe of Discourse a value between 0 and 1 defining its degree of presence in the fuzzy set and is known as the membership value and is designated as μ(x). The simplest membership functions are formed using straight lines. Of these, the simplest is the triangular membership function, and it has the function name trimf [shown in Figure 2(a)]. It is nothing more than a collection of three points forming a triangle. The trapezoidal membership function, trapmf [shown in Figure 2(b)], has a flat top and really
Design and simulation of fuzzy membership functions
73
is just a truncated triangle curve (Zadeh, 1995). These straight line membership functions have the advantage of simplicity. Figure 2
(a) Triangular membership function (b) Trapezoidal membership function
(a)
(b)
Next, I define the sigmoidal membership function, which is either open left or right. Asymmetric and closed (i.e., not open to the left or right) membership functions can be synthesised using two sigmoidal functions, so in addition to the basic sigmf [shown in Figure 3(a)], we also have the difference between two sigmoidal functions, dsigmf [shown in Figure 3(b)], and the product of two sigmoidal functions psigmf [shown in Figure 3(c)] (Zadeh, 1995). Figure 3
(a) Sigmoidal memebrship function (b) Difference between two sigmoidal membership function (c) product of two sigmoidal membership function
(a) Figure 4
(b)
(c)
(a) Z-membership function (b) Pi membership function (c) S-membership function
(a)
(b)
(c)
Polynomial-based curves account for several of the membership functions. Three related membership functions are the Z, S, and Pi curves, all named because of their shape (Rashid, 2009). The function zmf [shown in Figure 4(a)] is the asymmetrical polynomial curve open to the left, smf is the mirror-image function that opens to the right [shown in
74
S. Jain
Figure 4(b)], and pimf is zero on both extremes with a rise in the middle [shown in Figure 4(c)]. This paper shows the design and electronic circuit implementation of the S, Z, triangular and trapezoidal membership functions using op-amp.
4
Methodology
Our main target is to design a circuit for membership functions. S-membership function: The S function can be generated by using the op-amp as a differential amplifier. The two inputs to the amplifier are Vx to the non-inverting terminal and Vc to the inverting terminal. The voltage Vx gives the variable crisp input voltage for which the fuzzified output is to be determined. The voltage Vc gives the constant input voltage up to which the output voltage will be zero. For voltages greater than Vc, the output voltage Vo will increase according to this slope of the S curve. The slope is given by the gain of the op-amp RF / R1. The output voltage is obtained from the formula:
dy = slope x−c dy = ( x − c)
RF R1
In terms of voltages, VO = (VX − VC )
RF R1
(1)
The max output voltage that can be obtained has been set at 12 V because VCC = 12 V and therefore, the max output is +Vsat = 12 V, VEE = 0 so all negative voltages will give 0 output. The S-membership function using op-amp is designed for gain (RF / R1) as 2, constant input voltage (VC) as 1 V and the saturation voltage as 10 V. According to the formula given in equation (1), I get 10 = (VX − 1) * 2
So, VX comes out to be 6 V. Figure 5 illustrates the electronic implementation of S function. I have assumed gain as 2 so let’s assume R1 as 10 K than RF (for Figure 5 RF = R2) is coming out to be 20 K. At non-inverting terminal R4 is feedback resistance so its value is 20 K and R3 = R1, i.e., 10 K. VC is constant voltage which is at inverting terminal and given as 1 V, VX is crisp voltage which is coming out to be 6 V by calculation. In this case saturation voltage is given as 10 V so pin 7 is connected to 10 V. Corresponding output of Figure 5 is shown in Figure 6.
Design and simulation of fuzzy membership functions Figure 5
75
S membership function using op-amp (see online version for colours)
Figure 6 illustrates that slope starts with constant input voltage, i.e., 1 V and ends at the crisp input voltage which is 6 V (by calculation) with gain 2. Figure 6
Output corresponding to S-membership function
Z-membership function: The Z-membership function generator can be designed by inverting the output of the circuit for the S function generator. The two voltage inputs are VC and VX, VX, is the variable crisp input voltage for which the fuzzified output is to be determined. VC is the input voltage up to which the output voltage will be the maximum (12 V). For input voltage greater than VC, the output voltage VO decreases with increasing VX according to the slope of the curve. This slope is again given by the gain RF / R1 of the amplifier. The output voltage is obtained from the formula: Vsat − dy = slope x−c Vsat − VO = (VX − VC )
RF R1
(2)
S. Jain
76
The maximum output voltage that can be obtained is 12 V because VCC = 12 V. All negative voltages will be obtained as 0 at the output because VEE = 0 V. To change the slope of the curve, the gain RF / R1 of the op-amp is to be changed. Also in order to change the voltage VC up to which the output voltage remains maximum (12 V) voltage VC is changed. If the gain remains same then the output voltage obtained for a certain input voltage VX will be different from the output voltage obtained for a circuit with the same input voltage VX and the gain but different VC. If the same output voltages are desired for a given input voltage after changing VC, then the gain (slope) of the circuit will have to be changed, accordingly. The Z-membership function using op-amp is designed for gain (RF / R1) as 2.5, constant input voltage (VC) as 3 V and the saturation voltage (VO) as 10 V. According to the formula shown in equation (2), I get 10 = (VX − 3) * 2.5 4 = (VX − 3) VX = 7V
So, VX comes out to be 7 V. Figure 7
Z-membership function using op-amp (see online version for colours)
Figure 7 illustrates the electronic implementation of Z-membership function. I have assumed gain as 2.5 so, let’s assume R1 as 10 K than RF (for Figure 7, RF = R2) is coming out to be 25 K. At non-inverting terminal R4 is feedback resistance so its value is 25 K and R3 = R1, i.e., 10 K. VC is constant voltage which is at inverting terminal and given as 3 V, VX is crisp voltage is coming out to be 7 V by the calculation. In this case saturation voltage is given as 10 V so pin 7 is connected to 10 V. Corresponding output of Figure 7 is shown in Figure 8.
Design and simulation of fuzzy membership functions Figure 8
77
Output corresponding to Z-membership function
Trapezoidal membership function generator: The trapezoidal function generator can be designed by minimising the output of the S and Z function generators. The generator of this function is explained with the help of the diagram shown in the Figure 9. Figure 9
Block diagram showing how trapezoidal function is made
Figure 10 illustrates how I get output corresponding to each input for trapezoidal function.
•
for VX ≤ 4 V, the output voltage will increase with increasing voltage, according to the slope of S function
•
for 4 V ≤ VX ≤ 8 V, the output voltage VO will remain constant at 12 V
•
for 8 V ≤ VX ≤ 11 V, VO will decrease with increasing input voltage VX according to the slope of Z function
•
for VX ≥ 11 V, VO will be zero.
In the S function generator, VC1 = 1 V and the slope RF/R is adjusted to 4. Therefore, in the circuit, for input voltage greater than 1 V the output voltage will increase with a slope of 4 as the input voltage VX increases. Here I use saturation voltage as 12 V. The voltage at which the output voltage becomes maximum is given by equation (1), i.e. V0( S ) = (VX − 1) * 4 VX (for S function) = 4V
78
S. Jain
In the Z function generator VC2 = 8 V and the slope is RF / R4 = 4. Therefore, in the circuit for voltages less than 8 V, the output voltage is 12 V. For the input greater than 8 V, the output voltage decreases with increasing voltage input. The input voltage at which the output voltage becomes zero is given by equation (2), i.e. 12 − V0(2) = (VX − VC ) RF R
(VX
− 8 ) * 4 = 12
VX (for Z function) = 11V Figure 10
How I get output corresponding to each input for trapezoidal function
Design and simulation of fuzzy membership functions Figure 11
79
MIN circuit using op-amp (see online version for colours)
Thus, for voltages greater than VX = 12 V the output will be zero. Now, if the outputs of the Z and S function generators are connected to the inputs of MIN function, i.e., similar to AND gate (connected two diodes in reverse order) will be of the shape shown in Figure 10. MIN circuit: As seen from Figure 11, a two input MIN circuit can be designed by using the output of a diode logic AND circuit as the input to the non-inverting terminal of an op-amp. Let V1 and V2 be the two voltage inputs to two similar diodes D1 and D2 respectively. The voltage obtained at node A is the output of the AND logic gate and is therefore the minimum of the two voltages V1 and V2. If V1 < V2, then V1 will appear at node A. However, the actual voltage at node A, VA will be V1 + Vγ where Vγ is the cut-in voltage of the diode. This voltage will be the input to the non-inverting terminal of the op-amp. For an effective gain of 1, the output of the op-amp will be VA which is V1 + Vγ. In order to obtain V1 at the output, a diode D3, and a resistance RL are connected in series at the output of the op-amp and the output, VO is measured across the resistance RL, and ground and is equal to V1 because D3 provides a voltage drop of Vγ. For V1 < V2
Voltage at node A VA = V1 + Vγ VO = VA Voltage developer across D3 = VD 3 = Vγ Now
VO = VO − VD 3 = VA − Vγ = V1 + Vγ − Vγ
Therefore, VO = V1, which is required output.
80
S. Jain
Thus, I see that the output of the Figure 11 circuit is equal to the MIN of the two voltages and therefore acts as MIN circuit. Now, let us assume that V2 = 3 volts and V1 = 6 volts, then the Figure 11 circuit will give us: VO = MIN (6,3) = 3 volts
The shape of the trapezoidal function can be changed by changing the values of VC1, VC2 and also by changing the gains of S and Z function. The corresponding output is shown in Figure 12. Figure 12
Output of trapezoidal function
Triangular membership function generator: The triangular function generator can be designed by minimising the output of the S and Z function generators. The circuit used is the same as that used in the generator of trapezoidal function. But certain modifications have to been made regarding the inputs to the circuit. The generation of the triangular function will be explained with the help of the diagram shown in the Figure 13. In the S function generator, VC1, below which the output voltages for all input voltages are 0 is taken as 3 V. For the input voltage VX greater than 3 V, the output voltage will increase with increasing VX, with a slope of RF / R as 4. The voltage VX at which the output voltage becomes maximum and remains so, even for increasing values of VX is given by equation (1), i.e. V0( S ) = (VX − VC1 ) * RF R 12 = (VX − 3) * 4 VX = 6V
In the Z function generator VC2, given the input voltage below which the output voltage is always 12 V. For input voltage VX greater than VC2, the output voltage will decrease with increasing values of VX according to the slope RF / R. The values of VX for which the output voltage becomes zero is given by equation (2), i.e. 12 − V0(2) = (VX − VC 2 ) RF R
(VX
− VC 2 ) *3 = 12
VX − VC 2 = 4
Design and simulation of fuzzy membership functions
81
Now, if I wish to generate a triangular function, I need to align the voltage VC2 of the Z function with 6 V, the input voltage at which the output voltage of the S generator becomes equal to 12 V. Figure 13
How I get output corresponding to each input for triangular function
Therefore, I take VC2 = 6 V the from above equation, the input voltage at which the output of the Z generator becomes equal to 0 is VX = 10 V. For input voltages greater than 12 V the output voltages is 0. Now, if the outputs of the Z and S function generators are connected to the inputs of a MIN circuit the output obtained will be of the shape shown in Figure 14. Where •
for VX ≤ 3 V, the output voltage will be zero
•
for 3 V ≤ VX ≤ 6 V, the output voltage will increase with a slope of 4 (equivalent of S function), as the input voltage increases
•
for 6 V ≤ VX ≤ 10 V, the output voltage will decrease with a slope 3 (equivalent of Z function), as the input voltage increases
•
For VX ≥ 10 V, the output voltage will be zero, for all values of the input voltage.
82
S. Jain
The shape of the triangular function can be changed by changing the values of VC1, VC2 and also by changing the gains of S and Z function. The final output of triangular function is shown in Figure 14. Figure 14
Output of triangular function
So, I have successfully implemented the membership functions. Figure 15
Comparison of membership functions on the basis of electrical parameters (see online version for colours)
Next part is calculation of electrical parameters like SR, CMRR, power dissipation, gain and their resistances corresponding to every membership function. Figure 15 shows the comparison of membership functions using op-amp.
5
Conclusions
In this paper, an attempt has been made for designing the fuzzy membership functions and its electronic implementation using operational amplifier. I have successfully designed and implemented S, Z, triangular and trapezoidal functions. I have also calculated its various parameters like SR, CMRR, power dissipation, gain, etc.
Design and simulation of fuzzy membership functions
83
References Berkan, R.C. and Trubatch, S.L. (1997) Fuzzy System Design Principles, 1st ed., Wiley-IEEE Press. Drankov, D., Hellendoorn, H. and Reinfrank, M. (1993) An introduction to Fuzzy Control, Springer-Verlag, New York. Gayakwad, R.A. (2002) Op-Amps and Linear Integrated Circuits, 3rd ed., Prentice Hall of India Pvt. Ltd., New Delhi. Nguyen, M.A. (EE563) PSPICE Tutorial, Class: Power Electronic 2, Colorado State University Student [online] http://www.engr.colostate.edu/ECE562/Pspicetutorial.pdf (accessed around 2011 or 2012). Rashid, M.H. (2009) Introduction to PSICE Using OrCAD for Circuits and Electronics, 3rd ed., PHI Learning Pvt. Ltd., New Delhi. Yen, J. and Langari, R. (1998) Fuzzy Logic: Intelligent Control and Information, US ed., Prentice Hall, Texas A&M University. Zadeh, L.A. (1995) 10 January, Berkeley, CA [online] http://radio.feld.cvut.cz/matlab/toolbox/ fuzzy/fuzzytu3.html.