ChipCenter Questlink
SEARCH CHIPCENTER
Search Type:
Search for:




Knowledge Centers
Product Reviews
Data Sheets
Guides & Experts
News
International
Ask Us
Circuit Cellar Online
App Notes
NetSeminars
Careers
Resources
FAQ
EE Times Network
Electronics Group Sites


Fuzzy Logic In An Inexpensive Micro-Controller
by Darren Ashby

You should always have more one tool in your toolbox to solve any problems you may have. There are many out there. One of them that caught my eye several years ago is known as "Fuzzy Logic." So how can logic be fuzzy? It does in fact sound a bit like an oxymoron. I personally think that fuzzy logic got a bad rap for many years just because of its name. I think it would have been more widely accepted initially with a name like "intelligent sets" or "human logic." In fact, it literally took off in Japan where the translation completely lost its English meaning. You could buy Fuzzy washing machines years before they were available in the U.S., and when they did come to the States, they were simply intelligent washing machines.

So to understand how to implement fuzzy logic, you must first understand what it is. Fuzzy logic is an extension of Boolean logic. In Boolean logic there are two states, true and false. If a statement is true, it implies that the reverse is false. Imagine a stool in the room. If someone asked you if there was a chair in the room, you could answer no and be telling the truth. But if asked if there was a place to sit, you would have to say yes. But the quandary occurs when you equate a place to sit with a chair, which is true. But how can there be a room with a place to sit, and yet not have a chair in it? Think about it like a computer would.

    Chair in room = Statement 1 = False
    Place to sit = Chair
    Place to sit in room = Statement 2 = True

By substitution,

    Statement 1 = Statement 2
    or,
    True = False (not something you want to happen in your software!)

It does not compute. And if it doesn't compute, computers have a tough time dealing with it. That is why fuzzy logic was invented. Even though it doesn't compute, we as humans can easily understand that the above statements make sense because a stool does not typically belong to the "chair" category. However, it is definitely a place to sit.

Fuzzy logic quantifies the fact that a stool can be a place to sit and still not be a chair. It fits 100% in the stool category, 100% in the place to sit category, and some percentage less in the chair category. These categories are known as sets, and how much they are part of each set is the membership function.

When you start to study fuzzy logic in all its glory, you will see these neat triangles drawn all over to represent the membership functions of each set. Here is a link1 with a more in-depth lesson.

The way these sets interact is used to determine a specific output. This is done with rule sets and de-fuzzification. A rule set is typically an "if this, then that" statement. Using the above example, you might say if you see a chair, then sit down. Depending on how well the stool falls in the chair category determines if the action takes place. Determining exactly how well is the de-fuzzification part.

You can see how in fuzzy logic there is a gray zone in between true and false. The point is to know how true or how false. So what does this have to do with a 50-cent micro? Well, performing all the math to determine membership, then de-fuzzifying it back to a desired state can be a bit much for a small micro-controller.

So I say, why must you do all the math in the first place? Apply the rules directly to the input sets. For example, "If input is within this range, then do that." It worked well when I needed a circuit to recognize a particular wave shape and had very little code space to use. You don't have to always follow the rules. As long as the design works, you can cheat a little.

Now, please do not think that fuzzy logic is the answer to everything. I always believe in hearing both sides of the story. Bob Pease wrote a few enlightening comments about fuzzy logic, and I have included the link here.

Remember, this is another tool in your tool box, right next to the op-amps and PID control loops and filters and so on and so on. The point is you must have more than one tool. As Lotfi Zadeh, the inventor of fuzzy logic said, "When the only tool you have is a hammer, everything looks like a nail."


Additional Links
1.  For your continued research, here are some more links to links on fuzzy logic.

Product Engineering Archive

Guides and Experts   Analog Avenue   PLD EDA Tools   PLD   DSP   EDA   Embedded Systems   Power   Test
Click here to get your listing up.

Copyright © 2003 ChipCenter-QuestLink
About ChipCenter-Questlink  Contact Us  Privacy Statement   Advertising Information  FAQ