Fuzzy Logic

Hi everyone,
I’ve been working on fuzzy logic since that’s what I was recommended to do in this thread. I didn’t want to clutter that thread with questions about each individual topic or project, so I decided to make a new thread for the topics and discussions. My question now is what is the advantage of fuzzy logic control over a system such as PID. PID seems to be simpler and more efficient since it is math based. Fuzzy logic is instead based on conditional checks, which seems like it would take more processing time and more thought. You would need to come up with several scenarios. Based on my understanding and study of what I’ve done in the past 2 days, fuzzy logic is favored over PID and other similar controllers because it saves virtual memory usage and reduces processing time. The other reason I have seen is that PID is sometimes unsuitable in certain situations, but I have not yet seen one where PID could not handle the task much better than fuzzy logic. PID is math based which allows smooth changes whereas fuzzy logic seems like abrupt changes. Of course, it is better than traditional control/logic, but I cannot see the benefit. I would appreciate if someone could explain this to me.

Hi there! In short, PID control is almost always better than fuzzy logic, TBH, bang bang, or any other type of velocity control.

PID can be tuned and optimized to fit basically any requirement for torque, speed, and abruptness of changing direction or speed. It is also math based, as you said, so it changes speed fluidly and constantly rather than at certain checkpoints. By playing with values, it is possible to curve the acceleration to the desired value.

PID control or something similar is seen in many industrial settings. A undergraduate I was talking to from UCLA used PID control in a robotics class to program a 3 stage arm. There is a good chance the robots that build your household items and harvest your food are controlled with PID. Even amusement park rides rely on PID.

For these reasons, I would highly recommend using PID control on anything you’re able to. I was really taken aback by how much better PID was than other velocity controls when I finally learned how to use it, and it has yet to fail me.

Good luck!

@Anomaly pretty much answered, but I wanted to add…

I haven’t read up much on Fuzzy logic, so I don’t know the details. However, I gather that is essentially a more involved Bang-Bang control. Going off of that and general info, I can tell you that logic checks don’t take all that long. A couple cycles perhaps. Plus, branch prediction really comes into play here.

The floating point operations in PID take a fair amount of cycles also. In many cases, it may be slower then the logic checks. This is very application specific.

One benefit to Fuzzy Logic is to handle “Non Linear” control systems that are not handled well by standard PID algorithms. Fuzzy Logic has been used successfully for focus control of cameras and control of other types of commercial systems. It is also used in Artificial Intelligence (AI) in conjunction with Neural Networks (NN).

You may also want to investigate Neural Networks…

I’m getting a better understanding now, but could someone give some examples of situations where PID would not work and fuzzy logic would be the better choice and give an explanation of why? Thanks.

My undergrad is in Biomed and EE, for my masters in Computer Engineering my thesis was neural networks. I started a PhD in it, but went into industry. I studied it from the biological perspective as well as the math perspective. A couple of places that I used neural networks was in a classifier which would evaluate MRI images for tumor detection and secondly for a robot to teach itself how to drive. For the robot, I would randomize the 3-layer back-prop neural network interconnects and then had an autonomous onboard tutor that would train the network as the robot drove around. So it started out running into everything and eventually trained itself to navigate without any issue at very high speeds using an ultrasound sensor. This was all done on a processor with 9KBytes of ROM. Once trained it could execute in less than 2KBytes of ROM.

In both of these cases these network types were more AI classifiers than PID type controls. Fuzzy Logic can give smooth results, but to me, PID works well on it’s own or combined with an AI type classifier to “pick” certain gains and such applied to the PID on the fly. Thus giving you optimized or “learned” responses with a hybrid system.

It is nice that much of the neural and fuzzy stuff is low overhead (if you use a lookup table for the sigmoid in the neural), however, PID can be done in fixed point arithmetic in C and/or assembly language easily so the floating point overhead does not need to be there if you pick your numerical span well to fit the processor and your application.

Fuzzy was such a big deal (in talk not necessarily in implementation) years ago for embedded systems that Motorola added native processor functions just to handle it in the 68HC12.

In real life PID almost never ends up just being PID. You need to handle integral windup, system non-linearities, and dumb things a user might do. We’ve done a lot of control algorithms for everything from McD’s fryers/grills/smoothie machines to radar pointing systems to one of our present projects, a bionic pancreas with 2 dosing systems for glucagon and insulin. Almost none of these end up being pure PID, but have a PID component that is controlled by other decisions made on the fly. These decisions might be a place that you could apply the fuzzy discriminator.