You are on page 1of 7

Jefferson C.

Pabatang BSECE-4

ACTIVITY 1

SOLAR TRACKER FUZZY LOGIC

I. Introduction

The activity is about creating a set of commands for a solar tracker with the use of
fuzzy logic. The solar tracker is to operate in a manner that is based on how much voltage
is generated from the solar panels attached to it. The solar panels can only generate
voltage not exceeding twelve volts, and the solar tracker is to rotate from 0 to 100 percent
capacity. The tracker is supposed to rotate at one hundred percent (100%) power capacity
when there is no voltage (0 V) generated and is to stop when an amount of twelve volts
(12V) is generated.

II. Objective

The objective of this activity is to provide a set of commands for the operation of
a solar tracker based on the idea of fuzzy logic. Specifically the activity aims to:
a) Create a set of fuzzy linguistic variables representing the inputted voltage
b) Create a corresponding set of rules for the output of the solar tracker
c) Understand the idea behind the use of fuzzy logic on practical applications

III. Membership functions and Rules

A. Linguistic Variables
INPUT OUTPUT
VERY LOW (VL) VERY FAST (VF)
LOW (L) FAST (F)
HIGH (H) MODERATE (M)
VERY HIGH (VH) SLOW (S)
HIGHEST (HT) STOP (SP)
B. Rules
INPUT VOLTAGE (V) OUTPUT PERCENT (%)
VERY LOW (0-3) VERY FAST (100-80)
LOW (3-6) FAST (80-60)
HIGH (6-9) MODERATE (60-40)
VERY HIGH (9-12) SLOW (40-0)
HIGHEST (12) STOP (0)

C. Membership Functions

INPUT
VL L H VH HT
1
VL L1 L2 H1 H2 VH1 VH2 HT

0 V
0 3 6 9 12

OUTPUT
VF F M S SP
1
VF F1 F2 M1 M2 S1 S2 SP

0 %
100 80 60 40 0

FINDING THE EQUATION OF THE LINES

From 𝑦 = 𝑎1x+ 𝑎0 ,
𝑦VF= 𝑦VL= 𝑎1x + 𝑎0
when x = 0, y = 1 ; 1 = 𝑎1(0) + 𝑎0
x = 3, y = 0 ; 0 = 𝑎1(3) + 𝑎0

0 1 𝑎1 1
=
3 1 𝑎0 0
Solving for the values of 𝑎1 and 𝑎0 we get:
1
𝑎1 = − 3
𝑎0 = 1
Therefore, the equation of the first line is:
1
𝑦VF= 𝑦VL= − 3x + 1
Following the same process we get the equations of the other lines:
1
𝑦F1= 𝑦L1= 3x
1
𝑦F2= 𝑦L2= − x + 2
3
1
𝑦M1= 𝑦H1= 3x − 1
1
𝑦M2= 𝑦H2= − 3x + 3
1
𝑦S1= 𝑦VH1= 3x − 2
1
𝑦S2= 𝑦VH2= − 3x + 4
1
𝑦SP= 𝑦HT= 3x – 3

IV. Source Code

x = float(input('Enter the Voltage(0-12): '))


y = [0,0,0,0,0]

if(x>=0 and x<=12):

#VL
if(x>=0 and x<=3):
y[0] = (-1/3.)*(x)+1
else:
y[0] = 0
#L
if(x>=0 and x<=6):
#L1
if(x>=0 and x<=3):
y[1] = (1/3.)*(x)
#L2
elif(x>=3 and x<=6):
y[1] = (-1/3.)*(x)+2
else:
y[1]=0

#H
if(x>=3 and x<=9):
#H1
if(x>=3 and x<=6):
y[2] = (1/3.)*(x)-1
#H2
elif(x>=6 and x<=9):
y[2] = (-1/3.)*(x)+3
else:
y[2] = 0

#VH
if(x>=6 and x<=12):
#VH1
if(x>=6 and x<=9):
y[3]=(1/3.)*(x)-2
#VH2
elif(x>=9 and x<=12):
y[3] = (-1/3.)*(x)+4
else:
y[3] = 0
#HT
if(x>=9 and x<=12):
#HT1
if(x>=9 and x<=12):
y[4] = (1/3.)*(x)-3
else:
y[4] = 0

a=(((y[0])*(100)+(y[1])*(80)+(y[2])*(60)+(y[3])*(40)+(y[4])*(0))/(y[0]+y[1]+y[2]+y[3]+y[4]))
print('The solar tracker is rotating at', "%.2f" % a, '%')
else:
print('Input 0-12 only.')
V. Results and Discussion
When no voltage is generated

When voltage generated is 12V


When voltage generated is outside the 0-12V range

When voltage generated is 10 V


Computing for the output when input(x) is 10V
Since the input x falls within the range 9-12 volts, the output is under the lines
1
𝑦VH2= 𝑦S2= − 3x +4
&
1
𝑦HT= 𝑦SP= 3x − 3
Substituting 11.3 into the equations and then computing for 𝑦M2 and 𝑦S1 we get:
𝑦VH2 = 0.67
𝑦HT= 0.33
VF F M S SP
10.933
- - VF
- - - -F1
- - - - - - F2
- - - - -M1
- - - - - -M2
- - - -S1- - - - - -S2
- SP

----------------------------------
0.067
0 %
100 80 60 a 40 0

Using the weighted average method to solve for output a:


(0.67)(40) + (0.33)(0)
𝑎=
0.67 + 0.33
𝑎 = 26.8 %
Therefore, when 10V is generated by the panels the tracker rotates at 26.8% capacity.
VI. Conclusion

The approach of fuzzy logic can be applied in control systems in order to improve
the efficiency of the design.

You might also like