Post on 12-Jan-2017
Bruno Diaz and George RosenbaumIntelligent Control - EE 4733
Final Project Report
INTRODUCTION:
A fuzzy controller must be designed for a fan actuated, imbalanced lever and fulcrum. A
lever has a fixed weight and a magnet on one side, and a battery operated fan on the other. A
Hall Effect sensor detects the distance of the magnet from the ground, and represents this as a
non-zero number. The fan voltage must be controlled to balance the distance of the weight from
the floor so as to keep the lever balanced. This system is mathematically complex, which makes
modeling a transfer function very difficult. So a fuzzy logic controller is favored in this scenario.
Two different fuzzy logic controllers’ rulesets will be investigated. One controller
contains three rules, and another contains five rules. Then a method of increasing performance
by making changes to how error is read will be explored.
PROCEDURE:
The method for making these controllers will require a combination of observation,
intuition, and trial-and-error. The best way to design a good controller requires the user to know
the advantage of fuzzy logic over traditional “crisp” logic. Crisp logic has very discrete states
that the controller must stay in. As a result, such controllers can easily end up on the border of
two different states, getting stuck and unable to move to the desired target. This can only be
defeated with many redundant rules that slowly “fade” into the desired operation by creating lots
of states. This process is tedious, time consuming, and very difficult to update and experiment
with.
With fuzzy logic, the user can actually fade into the desired operation by allowing
multiple states at the same time. This reduces the number of states needed, eliminating brute-
force redundancy and allowing for more intuitive design. The amount of each state used can be
controlled easily, allowing for infinite states generated in a gradient of effect.
Bruno Diaz and George RosenbaumIntelligent Control - EE 4733
Final Project Report
The fuzzy logic technique we used was the DOF which will serve as the controller in the
algorithm shown below.
The DOF method is essentially shown below.
The range of different sensor values must first be collected using “s.inputSingleScan()” to
find the universe for error. Use this command once when the sensor is far away, and again when
the sensor is close. These values will be different depending on the Hall sensor and the magnet
being sensed. A third target voltage must also be found with “s.inputSingleScan()” so the
controller will know what voltage to track.
The universe generated from these values will not actually be the lowest and highest
value the sensor records. Instead the difference between the two values is calculated, which was
found to be about. 5703, and the universe will range from the negative difference to the positive
difference. This should create an error universe of about [-5703, 5703].
With the universe found, the rules and gain change are experimentally created until the
controller becomes reliable and effective. The gain change that is the weights attached to du after
the defuzzified output is found to be most effective around 0.1.
The rules specify what state the controller is in, and the gain value alters how quickly the
fan voltage is allowed to change. The three rule controller has a “too high” state (called P), a “too
Bruno Diaz and George RosenbaumIntelligent Control - EE 4733
Final Project Report
low” state (called N), and a “just right” state (called Z). The 5 rule controller has a “very high”
state (called PB), a “slightly high” state (called PS), a “just right state” (also called Z), a “slightly
low” state (called NS), and a “very low” state (called NB).
For the three rule controller, most of the universe was taken up by the “P” and “N” states.
The “Z” state takes is a narrow triangle placed on the target. Depending on how large the
controller gain is, the controller will require more room to fade from an outer state to the “Z”
state. With a 5 rule controller, care must be taken in how large the “PS” and “NS” states are, as
the controller can easily be stuck in these states if they are made too large. But careful design of
these rules will provide faster response and steadier tracking.
The boundaries chosen for the 3 rule controller were
N=trapmf(Err_X, [(-.5703 -.5703 -.5 .2)]);Z=trimf(Err_X, [(-1*.03) mid .03]);P=trapmf(Err_X, [.2 .5 .5703 .5703 ]);
For the 3 rule controller, the boundaries for the “N” and “P” controller are left very large.
Without any finer way of specifying rules, the “Z” rule had to be left slightly large. The
controller eventually works, but has a lot of overshoot and takes a long time to settle.
The boundaries for the 5 rule controller were
PB=trapmf(Err_X, [-.5703 -.5703 -.4 -.2]);PS=trimf(Err_X, [-.3 -.25 -.2]);Z=trimf(Err_X, [-.02 0 .02]);NS=trimf(Err_X, [.2 .25 .3]);NB=trapmf(Err_X, [.2 .4 .5703 .5703]);
For this controller we found improvement in performance by narrowing the Z boundary
so that we could have the fan could be leveled out at the VR more easily and evenly since we
were noticing that the fan would level of at a height near the VR but wouldn’t reach it for some
time.
Bruno Diaz and George RosenbaumIntelligent Control - EE 4733
Final Project Report
We also introduced a new feature to improve both controllers, referred to in this paper as
“future tracking.” While making the original controllers, a delay was noticed between a change
in voltage and effecting the operation of the fan. If the fan is set to a certain voltage that levels
out at a certain height we can see that it takes some time before it reaches that height, which
appears to take about 30 to 40 steps. This presents a problem since within those 40 steps the error
will still show up and the controller will continue to increase the voltage unnecessarily, causing
extreme overshoot. To remedy this problem, the error that the fan will have in the future is also
calculated in the adjusted algorithm seen below.
This is accomplished by creating a buffer that stores the last several values of recorded
voltages, the size of which can be controlled with the variable PD. Then it uses the latest point
and the oldest point in the buffer to calculate the slope of the fan speed relative to those two
points. The right length of the buffer has to be found, a buffer too short may be subject to erratic
behavior from noise and a buffer too long may not respond fast enough to changes. For our
purposes we found a buffer size of 3 to be adequate. After the slope has been found multiply that
by PF which represents how far we want to assume this will continue into the future (we choose
Bruno Diaz and George RosenbaumIntelligent Control - EE 4733
Final Project Report
30 steps) and add that to the current voltage. That becomes our future voltage and we subtract
our target voltage “VR” from that to get our error.
MAIN RESULTS:
We performed experimentally found our value for the weight in front of du to be 0.15.
We then ran two for the 3 and 5 rules using the original algorithms and another two for the
adjusted 3 and 5 rule algorithms. The results of all four experiments are shown below, with a VR
of 2.1 V.
Bruno Diaz and George RosenbaumIntelligent Control - EE 4733
Final Project Report
The same controllers were used on a different my VTOL board with a VR of 2.15, which
changed the behavior of the circuit somewhat. While there was some performance improvement
with the original algorithm the adjusted remained consistent.
3 rules original 5 rules original
Bruno Diaz and George RosenbaumIntelligent Control - EE 4733
Final Project Report
3 rules adjusted 5 rules adjusted
CONCLUSION AND DISCUSSION:
Approximating even a 3-rule controller is difficult for crisp logic. For any mode of
operation where a fuzzy logic uses a combination of states, a crisp controller must use a
completely unique state. This results in a crisp controller that has many different states that are
very close to each other, more lines of code, more chances to make mistakes, and more difficulty
changing the behavior of the controller to add better performance. There are room for
performance an issue we had with the controller