Submitted by Juan Pablo Angulo J.
This project solves a tipping problem that considers the quality of service and the taste of food in order to determine the proper amount of tip to be given. It may sound simple yet it is solved using a Sugeno Fuzzy Logic Inference System with 2 input variables and 1 output variable, all of this has been programmed into a Basic STAMP 2. Fuzzyfication, Rule evaluation and defuzzyfication are all written in BS2's code, the result is a nonlinear surface that can be evaluated in real time for different values of its inputs.This project was based on MATLAB's Fuzzy Logic Toolbox User's Manual, and the output generated by the BS2 can be compared to that produced by MATLAB to prove the functionality of the routine and the utility of having a Fuzzy Logic controller run from within a BS2 microcontroller.

Figure 1. Output from Matlab’s Fuzzy Tipper Example.
The graph is made using PLXDAQ with Excel, and for a little extra precision, food and service are graded on a 0 to 20 scale (instead of 0 to 10). Also, fuzzyfication process within BS2 occurs with integers (BS2 only supports integer math), so the “membership degree” to each of the “membership functions” is represented between 0 and 100 instead of 0.00 and
1.00.

Figure 2. Output from Basic STAMP 2 Fuzzy Tipper program.
This example can be modified to be a 2 variable controller, similar to a PD or PI controller, and it can even be trained within Matlab with the aid of ANFIS (Adaptive NeuroFuzzy inference system) so the process of development can be much quicker and precise. What Matlab can do is train the Fuzzy controller until de desired output is achieved, then all you have to do is copy the membership functions geometry and values of the Singleton functions into the BS2 and the program will behave very similarly to the one running in Matlab.
Downloads and Resources:
Fuzzy Logic Tipper Full Description and Data (.pdf)
Contact Juan Pablo Angulo J.