Sign in to follow this  
Followers 0
psc57

fuzzy logic and plc

29 posts in this topic

Hey guys i need to ask you something. Issit possible to control the ge fanuc plc using fuzzy logic. I have seen people do the controlling using PID and using the ladder logic. How would i be able to control the PLC(its for a water tank system) using fuzzy logic? Will i still be able to write the programs in ladder logic or is there some other program? Thanks. Prash

Share this post


Link to post
Share on other sites
I really didn't want to reply to this post as I'm kind of biased against Fuzzy Logic, so please keep this in mind. Fuzzy Logic is... well, "fuzzy". I have not seen it work any better than anything else in "real" life and there does not appear to be a "standard". It looks to me that any logic that adapts to conditions and adjusts parameters based on these conditions is called fuzzy logic. This type of logic can be written in any language, even ladder logic. What it takes is someone who really understands the process that is being controlled and knows how to build the proper algorithms and/or look-up tables to make it all work. So, in this context, you can build fuzzy logic in your PLC. I do not believe that this type of logic is very efficient, at least no better than a well written "normal" ladder program by someone who really understands the process. There may be fuzzy programs out there that are very specific to an application that work better than anything else tried, but one can say the same thing of most any way or means of programming. i.e. There are some software programs written in assembler that out perform any 'C' program ever written, but these are small and very specific, not whole applications that assist in CAD or Spreadsheet work. Edited by RussB

Share this post


Link to post
Share on other sites
PID control is tried and true and well documented. Why would you want to try something that no one can support?

Share this post


Link to post
Share on other sites
How would you, as a person manually operating the tank fill valve, approach the problem? There are three things you are going to observe and react to. 1) You observe that the tank is low so you open the fill valve. If its only a little low you open the valve only a little. If its a lot low you open the valve a lot. As it gets closer to the right level, you adjust how much you have the valve opened. And when it gets to the right level, you close the valve. 2) But you soon observe that the tank level drops as soon as you close the valve. This is happening because fluid is being drawn from the tank, so you adjust the valve open a little to maintain level. If you observe the level to still be dropping or still rising, you adjust the valve just a little bit more. 3) Last, as you are adjusting the valve you notice that the level is either rising or falling too fast so you anticipate a response from the observed rate of chang in level and adjust the valve to keep from going past the fill line or to make up for a sudden change in outflow. 1 is proportional control 2 is integral control 3 is differential control P + I + D. So you can spend weeks writing a fuzzy program and characterizing the system and the programed response to do 1, 2, and 3, or you can use a neat precise equation that has been developed by some very smart people and use well established tuning rules to get the same result.

Share this post


Link to post
Share on other sites
Aah nice. Thanks for the advice guys. The thing is alot of work has already been done controlling the system with PID. So now im supposed to use something else for this uni project. I was recommended fuzzy logic. Is there anything else i should consider that would be easier(other than fuzzy and PID)?

Share this post


Link to post
Share on other sites
Fuzzy logic implemented in a PLC is a waste of time. I would give you a failing grade if you implemented fuzzy logic on a PLC is not the best platform for implementing fuzzy logic. Call it PLC abuse. There are Freescale (ex Motorola) 68HC11 or 68HC12 micro controllers that have fuzzy logic features added to the instruction set. Get one of the development kits. http://www.freescale.com/webapp/sps/site/o...2OV&fsrch=1 If you are in university then you had better be learning how to be a designer and not a user anyway. A designer would use a development kit to get the basic functionality of the fuzzy logic working. Then he would lay out a board that would fit into the PLC of choice. Building boards for the PLC is beyond the scope of college work though. The developer would also have to provide examples that would make it easy for the PLC user ( Average Joe ) to use you fuzzy logic card. For a university project I would write an auto tuning program. I can help if you get stuck. I actually have one done in Scilab but I wouldn't want to ruin your fun. Otherwise, I would look into sliding mode control, SMC. SMC is perfect for those applications that don't need an analog output and a PWM or switching output will do. Switch power supplies, some drives, valve control, and heating systems use SMC. At first it looks very easy and it is. I wonder why PLCs don't have sliding mode control functions. However, process dead time is a problem. The methods of getting around these problems is where one begins to learn something useful.

Share this post


Link to post
Share on other sites
Very simple and elegant explanation! I'll have to bookmark this

Share this post


Link to post
Share on other sites
I’ll second Peter. An autotuner would be much more useful and it will have a much broader application, now and in the future. During WWII at Oak Ridge the government hired thousands of girls to operate the Calutrons that were separating uranium isotopes. The “Calutron girls” had no idea what the equipment was doing; they were there to adjust the knobs to keep a gauge needle on a mark. Some of the Manhattan Project scientists questioned hiring a bunch of girls to do the work and believed that they could do a better job because they understood the science behind the process. So a study was commissioned. Care to guess who won? The Calutron girls were able to produce more enriched uranium than the scientists who had intimate knowledge of how the Calutron worked. Why? Because of their experience the Calutron girls understood the response of the system to adjustments. It the same thing in PID control;. The controller doesn’t need to know what it is controlling, it doesn’t need to know what the actuators are, it doesn’t even need to know what the controlled item is – all it needs to know is how the system responds. That’s why it’s such a versatile and dependable method of control. It’s also why auto-tuners don’t have to be custom written for each application. All it needs to be is a “Calutron girl.”

Share this post


Link to post
Share on other sites
I do not doubt that at all, however given the same amount of time and attention one could get the same results from a PID using adaptive tuning based on "other" conditions. Would that make it a "fuzzy PID"?

Share this post


Link to post
Share on other sites
You are obviously more experienced at control than the average guy. What technique did you use? I will understand. One thing bothers me about those that think their way of control is better than another is that a control system still has a response as a function of its poles and zeros. If you can place the poles and zeros properly you can get the desired response. Basically, I agree with RussB. I think if you put the same effort into the PID you would get the same response.

Share this post


Link to post
Share on other sites
sorry for the late response guys havent been checking this forum because of exams. But thanks for all your responses. I guess PID has a proven track record in this area. Fuzzy logic i would say is not as widely used in this area. Are there any good sites i can read up on fuzzy logic and implementing it and also programming it with ladder logic and coming up with stuff?My prof wants me to investigate and implement controlling the water level in a water tank system using fuzzy logic. I think he wanted the change to fuzzy logic as the previous guys implemented it using PID and did the autotuning etc. Thanks again guys Cheers

Share this post


Link to post
Share on other sites
When you click on reply you need to scroll down. There is a button and field where you can add attachments. I think must must also zip it first on this forum.

Share this post


Link to post
Share on other sites
Hi geeks; I think the gent who has used Fuzzy logic is the only one talking sense. For loop control, albeit cascaded a few times PID would be the best bet. But there are some real problems such as distillation column control where the problem is of a different complexity and does not lend itself to control in a straightforward manner; ie. the phenomena encountered do not lend themselves to be framed within traditional logic. It is these situations where fuzzy logic will help. PID control is not a substitute for fuzzy logic. Even so, to really implement fuzzy logic, one needs to have witnessed experimentally, the behaviour of the controlled variable when manipulated by the other variables.. These observed results are put within "probable- weighted" end result boundaries that could be predicted with reasonable accuracy. If it is not possible to state the probable outcomes of any control schemes, fuzzy logic becomes meaningless. Based on these results," Fuzzy patches" are plotted on a graph so as to formulate the "Rules" of logic.A fuzzy system must have a set of overlapping "patches" that cover the entire range of all possible relationships between inputs and outputs. It must be understood that these are rules where the outcomes are approximations. Accordingly the maximum error of approximation is usually predictable from the Patch Diagram. It goes without saying that there must be enough rules. A fuzzy system "reasons or infers" from its rule patches. To put things in perspective, regarding fuzzy logic take a look at the ancient greek paradox. -A Cretan asserts that all Cretans lie. -So is he lying ? -If he lies,then he tells the truth and does not lie. -If he does not lie then he tells the truth and so he lies. Classic logic surrenders here, but it is fuzzy logic which has the right answer.. ie. the answer is Half true. Bye for now, lest you drop asleep.. Raj s Iyer

Share this post


Link to post
Share on other sites
Well done. Your version is very straight forward, relatively efficient and I think the student should copy this. However, I still think it is a lot of code that does no more than than a properly tuned PI controller. The advantage that a fuzzy controller has is that it can be non-linear like yours but a PID controller can be non-linear too. Unless the system is non-linear or has multiple inputs and outputs a fuzzy logic controller has no advantage. "Hi geeks; I think the gent who has used Fuzzy logic is the only one talking sense" WTF DO YOU KNOW? "For loop control, albeit cascaded a few times PID would be the best bet." This is nuts. There is no need for cascaded PIDs when there is just one feedback. "PID control is not a substitute for fuzzy logic." No but why complicate the control when there is only one input and one output. "Even so, to really implement fuzzy logic, one needs to have witnessed experimentally, the behaviour of the controlled variable when manipulated by the other variables." That is called system identification. Do you know how to do that? What you find is a system transfer functon defined by a gain, poles and maybe some zeros. I mentioned that above but you don't seem to think it makes sense because you think I know nothing about fuzzy logic. Guess again. If one knows the system transfer function then one can calculate PID gains to give a critically damped response ( no overshoot). Does that make sense? If one has a optimizing algorithm one can find the parameters to almost any control algorithm.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites
Hey raj, peter, KP_ENG thanks for everything. Maybe for my project ill compare fuzzy logic and PID for the water tank system. Is there any books that u guys would recommend to read up on fuzzy logic? Thanks a million for everything guys.

Share this post


Link to post
Share on other sites
Adieu my worthy friend, It is beautifully simple.Now I know that ordinary problems can be controlled by FL . I have a perennial problem with the automated control of distillation columns, The simplicity of your methodology certainly encourages me to experiment. Please keep posting your work here. I find it of a very high standard. With best wishes to all your endeavours, I remain, Raj S. Iyer

Share this post


Link to post
Share on other sites
Exactly! Thats the essence of the discussion in this thread. Edited by Alaric

Share this post


Link to post
Share on other sites
Good question alaric Quite a few actually....Please read the responses carefully again. Notice that the chap begins the thread by asking "Issit possible to control the ge fanuc plc using fuzzy logic. I have seen people do the controlling using PID and using the ladder logic." It seems the guy has some familiarity with PID usage already Despite this, replies to the topic were generally against the use of Fuzzy logic control, until the time of KP_EENG's reply, no one seems to heed the intervention "The thing is alot of work has already been done controlling the system with PID. So now im supposed to use something else for this uni project. I was recommended fuzzy logic" At that point it seemed that the guy was'nt looking for PID help Mind you, KP_EEng has actually had a successful experience with Fuzzy logic. I'm happy that he shared his work. After all it does take heat to produce light! and it is just as well. We stand enlightened And to pcs57, who started this ruckus, Please look up the book "Practical Process control for Engineers and Technicians", by Wolfgang Altman, (Newnes-Elsevier) It contains a few pages as introduction to Fuzzy logic usage. Then the Seattle Robotics Society has a good website with tutorials etc... Anyway before ending my words for the last time on this thread, I remeber with gratitude the help you gave me with RSView. Beer's on me if at all we run into each other.. Regards, best wishes to all here... Raj S. Iyer

Share this post


Link to post
Share on other sites
The very first reply clearly states, plus a few other other things. Edited by RussB

Share this post


Link to post
Share on other sites
Am I missing something? KP_EEng's program doesn't appear to me to be "fuzzy". The set membership is set by a bit, whereas I thought the essence of fuzzy logic is that set membership is a value between 0 and 1. Thus a temperature value could be a member of both "far above setpoint" and "above setpoint", but to a different degree. This would make de-fuzzifying rather more complicated.

Share this post


Link to post
Share on other sites
Right again. To implement a proper fuzzy logic routine would take a lot of resources. Centroid defuzzification is very math intensive. KP_ENG is cheating to some extent. He is integrating the output of the rules and there isn't a proper defuzzification routine. Since KP_ENG's system is a temperature system there must be an integrator some where to reduce the error to 0. I think I could do better with a PID and that fuzzy logic is mostly a bunch of hype unless the system is non-linear or has multiple inputs and outputs. However, there are state space and non-linear state space control methods that would be just as good or better.

Share this post


Link to post
Share on other sites
Mr. Nachtwey: I have Associate's and Bachelor's degrees in electrical engineering and a Bachelor's degree in Computer Science and I have never cheated on anything. I have removed all references to my work and will certainly never share any of my code again on this or any other forum. Regards

Share this post


Link to post
Share on other sites
Aaargh! Kpeeng; Do not despair., Please bear in mind that there are always rules and fools and schools! It is a pity that you take these trivial remarks so seriously. Let me say for one thing, that your code is a useful contribution on this forum and your few detractors do not really own this place!. The rules of FLC are not hard and fast. In PLC control, anything that works, is allowed and even if the de-fuzziification is'nt perfect, the results are more than workable. Fuzzy Logic isn't really about exactness. Also control stability is a very important consideration for most systems and it is a prime mover for interest in FLC. It cannot be denied that your code or rough calculations that you posted here (and you placed it here at our request , and with exemplary humility) has taken my own understanding of the FLC concept to the next level. My interest will sustain and it is the few fellows like you who have courageously gone against the grain and tread the path of authenticity who will always evoke our genuine respect!! So kindly withdraw your negative intentions and continue to share what you know. I'll be most disappointed otherwise. Cheer-up and begin your day with love, light and happiness. Raj S. Iyer

Share this post


Link to post
Share on other sites
So how does one prove a fuzzy logic system is stable? I can prove a classiacal control system is stable over a wide range of variations in the plant attributes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0