Help - Search - Members - Calendar
Full Version: fuzzy logic and plc
Forums.MrPLC.com > PLCs and Supporting Devices > GE
psc57
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 smile.gif
RussB
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.
Peter Nachtwey
PID control is tried and true and well documented. Why would you want to try something that no one can support?


Alaric
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.




psc57
QUOTE(Alaric @ Oct 6 2007, 03:49 AM) [snapback]60054[/snapback]

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.



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)?

smile.gif
Peter Nachtwey
QUOTE(psc57 @ Oct 13 2007, 08:51 AM) [snapback]60346[/snapback]

Aah nice. Thanks for the advice guys. The thing is alot of work has already been done controlling the system with PID.

So? Average Joe still can't tune tune a PID. Can you tune a PID without a lot of trial and error? I would do something for the Average Joe and yourself. Write an auto tuning program. That will be useful for the rest of your life as long as you are involved with PIDs.

QUOTE

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)?

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.



gravitar
QUOTE(Alaric @ Oct 5 2007, 03:49 PM) [snapback]60054[/snapback]
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


Very simple and elegant explanation! I'll have to bookmark this
Alaric
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.”




RussB
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"? blush.gif


Peter Nachtwey
QUOTE(KP_EENG @ Nov 17 2007, 07:56 PM) [snapback]61796[/snapback]
The problem is that different products absorb heat at different rates.

So what equatoins, rules or tables did you add to the fuzzy logic that compensates for different heat absorbtion of the different products? What feature of fuzzy logic do you think made the fuzzy logi beter.

QUOTE

The PID control can handle most of these product variations, but when we need to spray an enteric coating on a product, we are not allowed to overshoot our set point by more than two degrees F, otherwise, we can destroy the coating on some of the product and will have to inspect out the bad product. This means re-tuning the PID for different products to get optimal performance.

One can easily calculate gains as a function of data gather from different products based on heat absorbtion.

QUOTE

Recently, we designed and built a ninth machine and decided to implement fuzzy logic heat control as opposed to PID control. After researching fuzzy logic design and control theory, I took a couple of days to design the fuzzy logic control algorithm and another couple of days to implement the code in a MicroLogix 1500 processor. The result was about 40 rungs of ladder, but the control was incredible.

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.



psc57
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
Peter Nachtwey
QUOTE(KP_EENG @ Nov 18 2007, 05:12 AM) [snapback]61807[/snapback]

I have PDF copies of my design notes (handwritten and not much to look at) and the ladder logic of the implementation. I could not figure out how to post it here, but I can email you the information if you like.

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.


rajsiyer
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

Peter Nachtwey
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.


rajsiyer
QUOTE(Peter Nachtwey @ Nov 20 2007, 02:10 AM) [snapback]61885[/snapback]
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.

All this is fine Pete, my post is regarding the use of fuzzy logic in general. I posted because none other than KP_EENG seemed to know what it is about. Nobody in his right mind will advocate the use of fuzzy logic where PID is sufficient. My suggestion was that PID works well even when cascaded a few times... The use of fuzzy logic is advised when traditional approaches fail.

Regards, best wishes and thanks KP-Eeng for his seminal contributions here.

Raj s. Iyer



psc57
QUOTE(KP_EENG @ Nov 20 2007, 08:18 PM) [snapback]61892[/snapback]

Gentlemen,

Please, let’s keep things civil here. The only reason I posted this was to let the student know that fuzzy logic is a viable alternative where PID control fails and that the design and implementation of the algorithm is fairly simple.

Peter, thanks for the comments about my code. You are correct, I have not had much time to optimize it and saw several things that I need to do when I re-visited it last night, but the fact of the matter is it works well and keeps me from having to go out to the machine to re-tune several times per week.

Raj, thank you for your comments as well. Fuzzy logic does work well in certain situations and I plan to implement it in a GE RX3i Structured Text block sometime next year so that it is as transparent and easy to use as a PID instruction is.

This will be my last post on this topic.
Best regards




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.
rajsiyer
colgate.gif

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
Alaric
QUOTE(rajsiyer @ Nov 20 2007, 12:20 AM) [snapback]61886[/snapback]
I posted because none other than KP_EENG seemed to know what it is about.
What statement in this thread led you to make that assumption?

QUOTE

Nobody in his right mind will advocate the use of fuzzy logic where PID is sufficient.

Exactly! Thats the essence of the discussion in this thread.
rajsiyer
Good question alaric clapping.gif


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 ranting.gif 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


RussB
The very first reply clearly states, plus a few other other things.

QUOTE(RussB @ Oct 3 2007, 08:58 PM) [snapback]59928[/snapback]
So, in this context, you can build fuzzy logic in your PLC.
colgate.gif
AutomaticLeigh
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.
Peter Nachtwey
QUOTE(AutomaticLeigh @ Feb 4 2008, 02:35 AM) [snapback]64676[/snapback]

Am I missing something?

No.

QUOTE

KP_EEng's program doesn't appear to me to be "fuzzy".

It is fuzzish. ;)

QUOTE

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.

You are right.

QUOTE

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.

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.







KP_EENG
QUOTE(Peter Nachtwey @ Feb 4 2008, 09:53 PM) [snapback]64697[/snapback]

QUOTE(AutomaticLeigh @ Feb 4 2008, 02:35 AM) [snapback]64676[/snapback]

Am I missing something?

No.

QUOTE

KP_EEng's program doesn't appear to me to be "fuzzy".

It is fuzzish. ;)

QUOTE

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.

You are right.

QUOTE

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.

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.



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
rajsiyer
boxing.gif

Aaargh! Kpeeng;

Do not despair., Please bear in mind that there are always rules and fools and schools! colgate.gif 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




Peter Nachtwey
QUOTE

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.

I didn't mean cheat as in something dishonarable. You just didn't implement a true fuzzy logic control and that isn't necessarily bad as I have pointed out above. A true fuzzy logic implementation would be FAR too inefficient and cumbersome. However, AutomaticLeigh's observations are correct. As AutomaticLeigh pointed out, there is no degree of membership to a category and there is no centroid or other form of defuzzification. ( is that a word? )

Have you paid any attention to the threads about poles, feed forwards, system ideniticaion etc on the plcs.net forum?

QUOTE([b)
rajsiyer[/b]]
Fuzzy Logic isn't really about exactness.

Very true, so why bother when one can do so much better with more traditional methods?

QUOTE

Also control stability is a very important consideration for most systems and it is a prime mover for interest in FLC.

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.





rajsiyer
Hi pete,

Our common acquaintance rsdoran (who died 2-3 months ago) had referred to your capabilities and moods in one of his threads. I clearly recall having seen it someplace (the recollection of the place being fuzzy though smile.gif) I admire the spirit of the man. He went out of his way being useful to others by providing us the forums on plcs.net. He encouraged our automation community to come forth and give opinion. I was genuinely sad when he died, even though I could not put a face to his name!.

Why I recall Rsdoran here is because of his attitude!. You see the purpose of these forums is to let everybody associated with our profession to share their experience and not do or say things that hurt the sentiments of a well meaning contributor, namely KP_EENG. What is gained by switching him off ?.

Perhaps I may not prove ever that fuzzy is inherently more stable than PID.But then one cannot fail to notice that many new designs of loop controllers do feature FLC. The Japanese also have taken to them in a big way and it is not without reason. That I may not prove FLC is any better than PID is for other reasons; perhaps I am incomplete in my knowledge. Which is why I'm here... looking for a better way of doing things.Our ancestors did the right thing by not signing up for the flat earth society.

Regards and best wishes though,

Raj S. Iyer




Peter Nachtwey
Ron has nothing to do with this.
See post 14.


AutomaticLeigh
KP_EENG

I'm sure that everyone realises Mr. Nachtwey's comment was not intended to imply any dishonesty. My reason for posting is that I was looking for information on how to implement fuzzy control, not because I was trying to pick holes in someone else's work.

I have a project at the moment where I think I may need a "Plan B", and instead of simple PID control, I may need multiple-input single-output for some loops. Fuzzy logic would seem to be an obvious candidate, but I have never used it. I often find a few lines of sample code to be invaluable with a new topic, so I was interested in the program which you very kindly posted.

The value of forums such as this is the quality of the information. Having to present your solution in front of a knowledgeable community is (hopefully) what keeps the quality high. It appeared to me that your classifier was crisp, not fuzzy. I'm not suggesting that the technique won't work, only that it doesn't seem to me to be an example of fuzzy logic. In opening your work to public scrutiny, you inevitably face the risk of unfavourable criticism. Surely the response to that should be either to defend the work or accept that the comments may be valid.

rajsiyer
Oh great Brit,
you have the grit, merit and above all the right spirit thumbsupsmileyanim.gif

Thanks a millon, once again. The geeks here are indeed of a high standard.

Best wishes,

Raj S. Iyer


This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.