Professional Documents
Culture Documents
Jeff PDF
Jeff PDF
Pabatang BSECE-4
ACTIVITY 1
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
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
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
#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
----------------------------------
0.067
0 %
100 80 60 a 40 0
The approach of fuzzy logic can be applied in control systems in order to improve
the efficiency of the design.