PDA

View Full Version : State logic


eastkodakguy
May 20th, 2002, 04:27 PM
A coworker of mine was telling me about state logic. I really didnt understand it very well and asked him how he learned it and some guy taught him. I was wondering if any of you know of any text books or websites that could help me read up on this? thanks

Pierre
May 20th, 2002, 08:08 PM
-I was wondering if any of you know of any text books or websites that could help me read up on this?_

Is he programming coffee machines? Candy distributing machines?

I know I'll get some heat from this reply. bonkhead

Any way, to learn more, search the WWW for Grafcet, SFC, or even better... if your up to it... Finite State Machine Theory. HOOOO!!! I like this one.

Eric Nelson
May 21st, 2002, 01:11 AM
Hey Pierre, I like your new avitar! :cool:

I won't ask what kind of meat he's cooking... utoh (Cat burgers, I presume?) lolis

-Eric

kalle
May 21st, 2002, 03:17 AM
Pierre, now you're flippin burgers again..... :D


eastkodakguy, here is a link to a thread: http://www.plctalk.net/qanda/showthread.php?threadid=48

kalle

paulc20
May 21st, 2002, 06:33 AM
Try this link for Finite State Machines: http://www.splatco.com/tips/fsm/fsmartcl.htm

or just www.splatco.com to view their PLC's which are low cost, have free software and simulator and do NOT use ladder logic

Pierre
May 21st, 2002, 07:34 AM
Kalle - Since this was my post number 500 I figured I should qualify for the Master Burger Flipper Guru title... :)

rsdoran
May 21st, 2002, 08:13 AM
Guess I will throw in my 2 cents worth. GE Fanuc has State Logic:
http://www.gefanuc.com/support/plc/statelogic.htm

VillaBoy
May 21st, 2002, 12:50 PM
As far as PLC's are concerned, it's a fancy name for a simple concept. Read chapter 4 of "Series 90-30 State Logic Control System User's Manual" available at http://www.gefanuc.com/infolink/manuals/gfk1056c.pdf

Pierre
May 21st, 2002, 03:58 PM
-As far as PLC's are concerned, it's a fancy name for a simple concept.-Villaboy

The concept is simple but like in many other subjects, making things simple is complicated.

The application of State Logic is not a simple thing.

Allen Nelson
May 21st, 2002, 04:13 PM
Hey Pierre.
I also like the new avatar - is that home movies from Arkansas?

The application of State Logic is not a simple thing.

If you try to do an entire project in only State Logic, then you're right, it's no only not simple, it's almost impossible.

But if you let State Logic do what it does best (sequenceing), and let ladder do what it does best (exception handling), then State is both good and simple.

Since not all PLCs support both (simulaneously), I prefer a "Ladder-ized" version of State.

Terry Woods
May 21st, 2002, 08:02 PM
I might be a little new at this game... but, it seems to me, if you can describe your system with a Karnaugh Map then you have a State-Machine System!

Pierre
--------------------------------------------------------------------------------
The application of State Logic is not a simple thing.
--------------------------------------------------------------------------------
That, I agree with!

Allen
--------------------------------------------------------------------------------
If you try to do an entire project in only State Logic, then you're right, it's no only not simple, it's almost impossible.
--------------------------------------------------------------------------------

That, I disagree with!

Granted, the larger the system, the more complicated the Karnaugh Map could become... 4x4, 5x5, 6x6,...etc.

The trick to handling larger systems is to make your Karnaugh Map Multi-Dimensional! You can develop manageable Karnaugh Maps to an infinite number of dimensions! It becomes easier if you create an additional dimension based on each module.

DAMN! I gotta get back and finish that 2-Guys/2-Gals/2-Rubbers thing! The challange, made by Kalle (almost a year ago!), was to execute the exercise with a Karnaugh Map. I've got the whole thing in my mind -if you can call it that- and it's just a matter of laying it down and and explaining the why's and wherefore's in such a way that it can be understood by all.

In fact, I already have the maps for the actual execution of the higher level processes in place. For example, my current maps indicate that it is time for "Guy-1 and Gal-1 do Horizontal Cha-Cha" or "Guy-1 and Gal-2 do Shake-n-Bake". It is a higher level map.

The details were gonna be left to those that had the imagination to continue the details of the process to the lower levels.

I was planning on leaving the details to imagination. Now I feel I have to do the whole thing! Just to show that a process can be described entirely by a Karnaugh Map!

The only thing that makes a Karnaugh Map more difficult is the case where there are data calculations. That DOES NOT prevent the Karnaugh Map from being effective - that only makes it a bit more difficult! That is, it adds a couple of elements to the grid - as in, "Do Calc such-n-Such" and "Calc is Done".

The Bottom Line is...
A complete Karnaugh Map describes a State-Machine !

rsdoran
May 21st, 2002, 08:41 PM
I am not sure I agree with the last statement. A Karnaugh map seems to be a versatile tool in explaining logic. An imaginative mind such as yours (Terry) can no doubt make it look to be all...to others as in depth as you are within the field.

We dont all think binary..and its not all as simple as some try to make it sound. The fact that you didnt show a map for the 2 guy/2girl thing is one clue.

As much as I like the concept of State Logic ( for a good ol boy like me mite make things easy), it has holes in it that needs something.

Oh well, back to working on my Eurotherm drive problem with the Linked tags and no software, just the MMI.

Pierre
May 21st, 2002, 10:58 PM
Here's a little story 'bout just these kind of things. God I start to sound like my father...

A Client had about 100 analysers systems in the field, from America to China. His systems where a masterpiece of chemical engeneering knowledge. They would analyse 5 different gazes from 50 sample lines. All gazes where going trough the same lines which where switched in the main panel with selenoid valves. For the one who know about these things it's just not a simple task. The chemical interaction between all the materials (pump seals, tubings, sensors, etc) is a real mess to deal with. But his systems where well proven and he was a happy camper!

So the marketing guru says... could we go to 9 gazes?
Mister Big says, why not, but I'll have to consult with our EE to see if the hardware can do this. This would be a real cost effective way to make more pesos out of the same boxes. Not the new ones but all of those systems in the feild.

We all know those marketing guys... He started to sell those things before they even got trough all the hardware "challenges".

Under pressure, the EE told them he could do it whit what was already in the boxes... BIG MISTAKE!

So after they fired him ... so the story goes, the owner of that eng. firm called me (I new him from way back) and asked me to look into it.

The only solution he had was to fly to every systems, replace all PLCs with bigger ones, reprogram them... there was big costs involved.

See, the system could only handle 2000 steps and they alreday had used 1550.

There apeared to be no end to this tunnel but that was because nobody tought of ...
no it's not Peter Parker, its;K-Map

I had to tell him if I was in on this project. Could it be done?
There was big money in this...

I got the purchase order and started on my truth taable ASAP.
With the Multi-dimensional Karnaugh map well defined, I started to write the State Logic program and 1998 Steps and one month later my pants where all wet. I was a happy camper.

Has for my client, he still his a client and he sold many packages,... a smal box with DIO extension module, a few selenoid and tubing, an EEPROM and Voila! No airfare, no mess.

This long story to tell you this.

I loved Karnaugh because he makes me look so brillant at times....

Seriously, this was a complicated program and I firmly beleive it could only be done in this size PLC with the use of K-Maps and State Logic.

I use K-Maps for 2 reasons:

Uno- In smaller programs, to check if my logic is good
Secundo- To minimize the size of a PLC program when really needed

I use State Logic all the time but like rsdoran does, in a ladder form.

I would not dare use these if I did not really have to... it drains my braim a lot.

TW-A complete Karnaugh Map describes a State-Machine !

You bet Sir it is.

BTW, State Logic is the way to parallel processing in PLC, i know you'll like this one :)

PS: Did ya know they had Chicken/Ranch/Mushroom Pizza in Arkansas

Allen Nelson
May 22nd, 2002, 08:57 AM
Terry & Pierre:

I'm intrigued.

First let me confirm my (weak) understanding: State Logic is exactly the same thing as Sequential Function Charts - no more and no less. SFC's are nothing more than boxes, with bars underneath them, like so:
+-------+
| Action|
+---+---+
|
-+- Transition
|

<tag>
Inside the boxes are Actions - outputs to turn on or off (by latch or by coil), timers to run, etc. The Transition is the condition that causes the SFC to leave that box, and go to the next.
There can be parallel actions/transitions to advance the sequence, or do things simultaneously as well.


What I'm missing in my lessons (not hard, being self-taught) is the relationship between Karnaugh maps and SFCs. I've seen where K-maps are used to simplify truth tables, and thus ladder, but not to generate SFCs. Terry, if you're inspired to turn the condoms thing into such a lesson, it would be a goodness.

It's the exception stuff to the sequencing that made me make the "it can be nearly impossible" comment: You wind up with so many parallel branches that you can't see or keep track of what is supposed to be happening - E-stops, interlocks (which stop half the devices set OM in the Action, but not the other half), alarms, etc, have always wreaked (also wreck) havoc on SFCs that I've seen.

That's why I prefer the ladder-ized SFC - the SFC's "suggest" that an output be on, but the "regular" ladder handles the e-stop/interlock/alarm/manual mode exceptions. And I have more control of step control ("if on step 7,8 or 9 jump back to step 6 if this alarm occurs" - kind of stuff - I can't picture how that would be done in an SFC)

VillaBoy
May 22nd, 2002, 09:22 AM
I absolutely agree with you Allen. I do not see how you can possibly use K-Maps to fully describe almost any PLC system in the real world.
There are many applications where the next state of the machine is not just determined by the current state, but of previous states. Static K-Maps cannot handle this.
Step-Transition disgrams (SFC, GrafCet etc.) are far more useful, but, as you rightly point out, have limitations. For more info on Step-Transition type programming I strongly suggest reading up on Yourdon methodology (or similar). A good read is 'Modern Structured Analysis"

Brad B
May 22nd, 2002, 11:32 AM
Is state logic essentially the same thing as stage programming in DirectSOFT? :confused:

Thanks.

VillaBoy
May 22nd, 2002, 11:52 AM
DirectSOFT is more of a Step-Transition/Ladder based package, similar(?) to SFC. I wouldn't exactly describe it as State Logic.

Gerry
May 22nd, 2002, 05:59 PM
I don't think it's correct to say they are exactly the same thing. Rather they are different methods of describing or diagramming the same thing. Depending on the nature of the "thing", one method may be more appropriate than the other for describing that nature so as to be readily understandable.

SFC's have structural rules: steps, transitions, branches, goto's that must run down the page in varying width. A state diagram is essentially free-form with only circles (or blobs) and arrows.

"And I have more control of step control ("if on step 7,8 or 9 jump back to step 6 if this alarm occurs" - kind of stuff - I can't picture how that would be done in an SFC)"

You could draw this as an SFC using selected branches and goto's but it becomes messy. It would probably be easier to draw as a state diagram. It could be drawn as a flow chart as well but that's another subject. Could it also be drawn as a Karnaugh map? I'll leave that for the KM experts to answer.

It would be nice to have graphical editors for SFC AND State diagrams to chose from - then we wouldn't need to 'ladder-ize' them.

Terry Woods
May 22nd, 2002, 08:28 PM
K-Maps ain't necessarily easy...but then, neither is Ladder, or SFC, or...

They can be as complicated and all-encompassing as you need them to be!

K-Maps can certainly describe Static situations. But that does not mean that they can only be used for Static situations.

To think of a K-Map as only being capable of handling "STATIC" situations is as short-sighted as thinking that a jet airliner is a viable way to move people from a terminal to the middle of a runway.

K-Maps certainly identify "IS-Conditions".... PB_IS_ON, DOOR_IS_OPEN, MOTOR_IS_ON,... etc.

Now, here is where a lot of guys miss the plane (or end up sitting on their a$$'s in the middle of a runway)...

While it is an indisputable FACT that a K-Map can indeed monitor Current Conditions, it is also an indisputable FACT, thanks to internal relays, that the same K-Map can maintain a Historical Record of activities.

A Karnaugh Map is not only capable of producing External Actions according to External Conditions, as in...

If (PB_1 OR AUX_A) and NOT PB_2 then MOTOR_A (typical motor circuit)

A Karnaugh Map is also capable of maintaining HISTORY, as in...

If (PB_1 OR AUX_A) and NOT PB_2 then MOTOR_A followed by...
If MOTOR_A and NOT WAS_MOTOR_A then WAS_MOTOR_A

It is also the case that the same K-Map (including the multi-dimensional aspects of the K-Map) can describe an ENTIRE system! For those that prefer using spaghetti-code this is a nightmare! A Karnaugh Map works best (and SHINES) under MODULAR conditions! Modularity in design allows for smaller, localized K-Maps which can completely describe any given module. Of course, you need to understand modularity in terms of function as well as sub-system.

This ability also allows a K-Map to act as a Sequencer as well! This could be a Timer-based, an Event-based or a Timer/Event-based Sequencer.

I've tried to include a graphic illustrating this, but it is just too painful to try to make it work.

I tried to do a fig, some text, another fig with more text... it won't work! At least, not as far as I can tell. Maybe Phil can do some work on this little problem.

I will include one fig... hopefully, you can make it out.

Allen Nelson
May 22nd, 2002, 09:11 PM
Gerry:

Ok, so "correctly", State Logic are the bubble diagrams, and SFC's are the box diagrams. If so, then you are right, they are different (I only say "if so" because I've seen people use State and SFC interchangably)

But bubble diagrams aren't an IEC 61131-3 language, nor have I heard of a PLC that you can program them in. So you wind up with messy SFCs, like I said.

Terry:

It's going to take some time to formulate a reply - I want the lesson (and I known all along that I was setting myself up to play the role of Student, with 40-odd lurkers looking over my shoulder.) Unfortunately, my keepers (I've got them too) are reminding me of other jobs and sleep, so I have no time now to do you justice. But there's a long weekend coming up.... I can see the ladder for your sequence, and I can see the SFC, but I also see something else - it's going to take more study....

A suggestion - if you can't post multiple images in a single post, do serial postings. Unlike the old site, noone can reply "between" a post, so when you're ready, just hit "Submit"-"Submit"-"Submit" (Hmmm, sounds like my keepers).

Pierre
May 22nd, 2002, 09:59 PM
Back in my younger years, making personal projects was the thing to do when you wanted to understand logic circuits.

We had no nice PCs with Labview, MathCAD or even Electronic Workbench to foul around with.

Before you got you chips on the breadboard you better be certain you where using the minimum amount of them EXPENSIVE stuff (for a student that is...)

That’s where Karnaugh Maps or Venn diagrams where coming handy. It's ho so long ago but one thing remains, minimizing is best achieve with well-planned diagrams... any which one will do

I totally agree with Terry when he talks about modularity. I personally use them K-Maps in this manner. I have many small 2 or 3 dimensional maps used has truth tables and will use them throughout a program. Testing the truth!

One must realize that any language will do. Whether it's SFC, ladder, it's only a matter of personal ease. Any program can be done with any language.

But what’s going to happen to the next guy trying to figure out your lines of code?

There is a best place for using a language.

About Karnaugh, most people think about static worksheet-type diagrams. Not so, they are has dynamic has any other graphical representation of a process.

Think about any Karnaugh line has a step. In SFC or State Logic (it really is the same) a Step comes from a transition ... an IF-this-is like-that sort of thing.

Action=Reaction

A Step cannot be driven to another one if no reaction is detected. This reaction could the simple Done BIT of a timer but it's a transition that is triggered by a previous Action.

A Karnaugh Map, just like a Venn diagram (Ze bubblez...) is a graphical representation of this process.

SFC is just moving around inside a K-Map. Back and forth, Up and Down.

While programming in SFC you can get locked within a Step, if you have done an error or forgotten some variable, (don't they all have a Reset Bit :D ) IF you start with a K-Map you'll minimize you code, hence minimizing the probability of error. The key word here is minimizing.

It was mentioned that State Logic is not good when the next Step is dependant on previous states.

(VillaBoy)
-There are many applications where the next state of the
machine is not just determined by the current state, but of
previous states. Static K-Maps cannot handle this.

Remember that machine has a finite number of states and is in exactly
one of these states at any given time. Whatever happens is just a transition. A line in a K-Map.

rsdoran
May 22nd, 2002, 10:43 PM
Personally I think y'all jes proved my case. A karnaugh map is good at providing a type of flowchart but its an advanced programmer's tool. For the majority of the people that deal with plc's it means nothing.

The day is fast upon us where you programmers will be the only one to understand what a plc is doing (and in alot of cases y'all wont know what another programmer has done), ladder logic will be a thing of the past. That is sad, its hard for companies now to get qualifed help that can just read the LED's, let alone use the software to troubleshoot.

Yeah you high paid engineers say, the electricians can/should learn...why? Learning to bend conduit is hard enough. Following code (in US) etc is even harder. Oh yeah we must know hydraulics, pneumatics...etc then be able to troubleshoot/diagnose any/all problems at any time of the day or night.

F your comments about spaghetti code, whats the difference if only SOME programmers can understand what is done when using all the new features/options that are available.

Feed your egos all you want...spaghetti code is anything that cant be understood easily.

Gerry
May 22nd, 2002, 11:20 PM
Allen:

Once the SFC or state diagram has been "ladder-ized" it becomes near impossible to determine the origins. I believe you and I are saying much the same thing.

I heard a rumour a few years ago that Siemens was developing a state logic editor, however I've never seen it or any other. Back around 1990 A-B added the SDS instruction to the PLC5 and PLC5/250 (used a CAR). It was described as a means to implement a state diagram which it did. I think it was more notable for its diagnostic and initialisation features. Sadly, only supported on 6200 s/w.

---------------------------------------

I confess I've never come across this use of Karnaugh maps and the notion of a dynamic K-map never occurred to me. But, hey, I'm not too old to learn something new!

Allen Nelson
May 23rd, 2002, 05:36 PM
OK Terry, I'm ready to give it a go.

These days I'm reverse-engineering code to generate a spec, so that's what I'll do with your Karnaugh map.

Spec:

Sequence of Operation Operator presses Start Button (PB-1) to start motor. If PB-1 is released before motor is confirmed started, generate a "Fail to Start" alarm (=X). If the aux contact drops out after the motor has been running, generate a "Tripped" alarm (=Y) When Operator presses Stop Button (PB-2), the motor stops.

Now I can see, looking at your K-map, how this is, exactly, the "bubble diagram" that I was talking about. It's even better because the usual "bubble" (Note to Pierre - those are not Venn diagrams. Venn diagrams are depictions of Sets, with overlapping (or not) areas), aren't always clear on the transitions. These are.

From the K-map, I can see how to build a table for an SFC. (Note to Lurkers: I've done these before in other postings on the old forum, and I don't feel like describing too much about the Action(=Outputs) / Transition stuff here). Translating your K-map directly, I come up with this:
<TABLE BORDER CELLSPACING=5 CELLPADDING=5>
<TR><TD>Step</TD><TD>Description</TD><TD>Transition</TD><TD>Outputs</TD><TD>Exception(s)</TD></TR><TR><TD>1</TD><TD>Wait for Start</TD><TD>PB-1</TD><TD>--</TD><TD>--</TD></TR><TR><TD>2</TD><TD>Start Motor</TD><TD>Motor</TD><TD>Motor</TD><TD>--</TD></TR><TR><TD>3</TD><TD>Confirm Start</TD><TD>Aux</TD><TD>Motor</TD><TD>If Not PB-1, go to step X</TD></TR><TR><TD>4</TD><TD>Release PB-1</TD><TD>Not PB-1</TD><TD>Motor</TD><TD>--</TD></TR><TR><TD>5</TD><TD>Set Was</TD><TD>Was</TD><TD>Motor & Was</TD><TD>--</TD></TR><TR><TD>6</TD><TD>Wait for Stop</TD><TD>Not PB-2</TD><TD>Motor & Was</TD><TD>If Not Aux, go to step Y</TD></TR><TR><TD>7</TD><TD>Stop Motor</TD><TD>Not Motor</TD><TD>Was</TD><TD>--</TD></TR><TR><TD>8</TD><TD>Confirm Stop</TD><TD>Not Aux</TD><TD>Was</TD><TD>--</TD></TR><TR><TD>9</TD><TD>Release PB-2 </TD><TD>PB-2</TD><TD>Was</TD><TD>--</TD></TR><TR><TD>10</TD><TD>End</TD><TD>--</TD><TD>--</TD><TD>If Not Was, go to step 1</TD></TR><TR><TD>X</TD><TD>Fail to Start</TD><TD>--</TD><TD>--</TD><TD>If Not Motor, go to step 1</TD></TR><TR><TD>Y</TD><TD>Tripped</TD><TD>--</TD><TD>--</TD><TD>If Not Motor, go to step 1</TD></TR>
</TABLE>

Now here is where I start to go "SO WHAT?". Did you make this chart this way because of some formal "Rules to Generate Karnaugh Maps", or were you just creating a random example?

Big question - is it permitted to move diagonally in the chart (all your motions are either horizontal or vertical)? My guess is "No", because yuo are dealing with a single transition - a diagonal move would indicate two conditions changing simultaneously (which theoretically could happen). For example - instead of having a step 'Y", could you go to step 'X' from step 6, and just have a general "Faulted" alarm?

If I were to write the same table from scratch, based on the spec that I wrote above, I would simplify it, like this:

<TABLE BORDER CELLSPACING=5 CELLPADDING=5>
<TR><TD>Step</TD><TD>Description</TD><TD>Transition</TD><TD>Outputs</TD><TD>Exception(s)</TD></TR><TR><TD>1</TD><TD>Wait for Start</TD><TD>PB-1</TD><TD>--</TD><TD>--</TD></TR><TR><TD>2</TD><TD>Confirm Start</TD><TD>Aux</TD><TD>Motor</TD><TD>If Not PB-1, go to step X</TD></TR><TR><TD>3</TD><TD>Wait for Stop</TD><TD>Not PB-2</TD><TD>Motor &amp; Was</TD><TD>If Not Aux, go to step Y</TD></TR><TR><TD>4</TD><TD>End</TD><TD>--</TD><TD>--</TD><TD>If Not Was, go to step 1</TD></TR><TR><TD>X</TD><TD>Fail to Start</TD><TD>--</TD><TD>--</TD><TD>If Not Motor, go to step 1</TD></TR><TR><TD>Y</TD><TD>Tripped</TD><TD>--</TD><TD>--</TD><TD>If Not Motor, go to step 1</TD></TR>
</TABLE>

But I don't see how to turn this into K-map. But it still works as an SFC.

Of course, If i were to do the whole thing in ladder, I could do the "ladder-ized" sequence (Note to Lurkers: Again, did it on those posts on the old forum - search for "sequencer" and you should find that method). But I'd probably just bang it out, something like this:



STANDARD MOTOR START CIRCUIT

PB-1 PB-2 X Y MOTOR
---| |---+---|/|-------|/|-------|/|-------( )
|
MOTOR |
---| |---+
<BR>
<BR>
FAIL TO START ALARM

MOTOR AUX WAS PB-1 X
---| |-------|/|-------|/|-------|/|-------( )
<BR>
<BR>
TRIPPED ALARM

MOTOR AUX WAS Y
---| |-------|/|-------| |-----------------( )
<BR>
<BR>
"WAS" LOGIC - KNOW THAT THE MOTOR HAS BEEN STARTED

MOTOR AUX WAS
---| |---+---| |---------------------------( )
|
WAS |
---| |---+


Nothing to it.

I'll admit that the K-map helped me figure out the WAS logic, but that's because I usually use a "fault timer" rather than the PB release that your K-map implied.

Now, what I'd like to see, Terry, is how you take that K-map you drew, and turn it into code. I can see the SFC easily enough (so no need to produce THAT), although again, my second chart contains all the functionality of the first, and generates a smaller SFC.

Or does it contain the same functionality? How about the ladder? Am I missing some sublety, like what happens when both buttons are pushed at the same time, or somesuch?

If this wasn't a good example (I liked it - it was managable), come up with something better.

rsdoran
May 23rd, 2002, 08:37 PM
I know I aint in y'alls league but something is strange here..I kinda understood the SFC/Karnaugh thing but the ladder has me confused.

TRIPPED ALARM

MOTOR AUX WAS Y
---| |-------|/|-------| |-----------------( )


"WAS" LOGIC - KNOW THAT THE MOTOR HAS BEEN STARTED

MOTOR AUX WAS
---| |---+---| |---------------------------( )
|
WAS |
---| |---+


If Motor is enabled but there is no AUX how can there be a WAS? If the AUX goes NOT then WAS will go NOT..correct? If there is no WAS how can there be a Y? Am I missing the obvious?

rsdoran
May 23rd, 2002, 08:42 PM
WOW what happened there?

If MOTOR is enabled and AUX is NOT then how can there ever be a WAS? Wont WAS go NOT if AUX goes NOT? SO how can you get a Y?

Eric Nelson
May 23rd, 2002, 09:19 PM
Good eye, RS! I agree with your analysis, but it's probably just a typo. I guess that's what happens when you "bang out" logic? :D

(Might this be similar to that "BAM" logic thing?) lolis lolis

If you swap the positions of the MOTOR and AUX contacts, or move the WAS branch to wrap under the AUX contact, it will work as my "cousin" Allen had intended...

-Eric

P.S. Nice job using the "table", Allen! I'll bet we'll soon see Terry using these as a solution to his image posting problem :nodi:

Eric Nelson
May 23rd, 2002, 09:28 PM
Wait a minute! My solution would make the "Tripped Alarm" rung work, but it would only turn on for one scan because it will turn off the motor (a good thing), which, in turn, will turn off Y. utoh

Looks like a good place to use one of those "dreaded" LATCHING outputs! :D

-Eric

Allen Nelson
May 23rd, 2002, 10:29 PM
Hang on guys. The logic was correct as written.

Under "normal" conditions, after the motor starts, the Aux comes in (otherwise you'd get an X fault), and therefore WAS comes on and seals.

After WAS has sealed (but before the Stop is pressed), if the AUX drops out, first you'll get a 'Y' alarm, and then WAS will drop out. On the next scan, 'Y' will drop out (but it would anyway, since on that scan, the Motor will drop out due to the existence of the 'Y' alarm.)

Another way of saying it is that you can't get the Y alarm until after the 'WAS' has been made (which is true to the spirit of Terry's K-map).

The key is that 'WAS' must follow 'Y' in the ladder - if it's the other was around, then Ron is right, and WAS will drop out first, preventing a Y.

Scan order can be critical sometimes.

---
No need for a latching - even in Terry's diagram, you would only be in State 'Y' for one scan, since the transition from Y to 10 is having the Motor Off (which presumably state 'Y' would turn off the motor)

If you want the alarm to linger for an operator... well, that's a different rung. The 'Y' one-shot (or, more correctly, one-scan) would set a coil, which would seal. The question is - what would break the seal? Alarm Ack? Timer?

Operator interface/alarm handling is a seperate module from the one being handled here (and we're writing modular code).

---

Tables are actually easy to do - create one in Word, and SaveAs an HTML. Rename it to a .TXT, re-open in Word, and clean up the "junk" that Word puts in (fonts used in each cell, specifying cell width, etc). A few quick Search/Replace and you're done.

But you can't do the Arrows thing that Terry had. Nor that PNP powerpoint presentation of last month. I think my serial posting of single images idea might still be the best work-around.

rsdoran
May 23rd, 2002, 10:47 PM
Technically I considered the scan thing, what I dont see is what will maintain the Y..ie the alarm. Considering the ladder as is, yes the alarm will trigger (for one scan) but when it does and Y is TRUE then motor will be turned off therefore on next scan no Y because MOTOR is NOT. Looks to me like motor will be turned off and no alarm will be shown because it isnt maintained. Since plc's work in milliseconds in most cases there wont be much of an alarm unless there is more action involved.

I know I am not able to program like some of y'all but I have to diagnose equipment almost daily with several brands of PLC's. I aint being funny, sarcastic or anything like that. Just being sure of what I am seeing.

rsdoran
May 23rd, 2002, 10:48 PM
Ok I didnt study your last post well enough...sorry.

Allen Nelson
May 23rd, 2002, 10:53 PM
Don't be sorry - I updated my post to include the paragraph about the one-scan alarm. We were probably posting simulateously.

Gerry
May 23rd, 2002, 10:58 PM
In the foregoing ladder examples, if AUX is an un-buffered input and you're using A-B remote I/O or ControlLogix, then state Y may or may not occur because it is possible for AUX to be updated between the evaluation of the Y rung and the WAS rung.

Just one more trap to look out for.

Peter Nachtwey
May 23rd, 2002, 11:08 PM
Originally posted by VillaBoy

There are many applications where the next state of the machine is not just determined by the current state, but of previous states. Static K-Maps cannot handle this.

Yes they can. Whether it is practical is another matter, but if the number of states is then it is easy to use the last 3 or four states.

The problem with K-MAPs is that they get big quickly.

The problem with SFCs is that they are easiest to understand when they are sequential. Using a SFC to jump around from state to state gets messy. This is why many have expressed their preference for using ladder as a state machine.

Allen Nelson
May 23rd, 2002, 11:09 PM
Gerry:

Yeah, yeah. Let's not make this more than it is, OK? I'm just trying to understand Karnaugh maps and how to use them to generate SFCs.

But, as log as you started the tangent - is there any advantage that anyone can come up with to having I/O be asynchonous to scan? Clearly, Gerry has pointed a disadvantage.

Is there another PLC besides the ControLogix that does this?

Peter:

I agree completely. And your reply to VillaBoy is correct - that's what that 'WAS' stuff has been all about. 'WAS' captured States 1-5, so that the trip alarm ('Y') can be expressed - without it, you get the alarm as soon as you start the motor, before the 'AUX' has had a chance to be made. (See, Terry, I've figured out that much of the lesson.)

Eric Nelson
May 24th, 2002, 12:24 AM
shutit Well I'll be darned.... Yes, Allen, you're right... The code is indeed correct :embar:

I should have gone with my first take on it. It made sense at first, then RS went and got me re-reading it again and again. :rolleyes:
I guess I'm too easily influenced? :p

Since this is just an exercise, I shouldn't jump to my real-world train of thought that says "What the hell good is an "ALARM" if it's only on for one scan?". I'm pretty sure this is what RS was thinking as well. I think it was just the word that tripped us up. These "ALARMS" are really only intended to be seen by the motor enable rung, which DOES get to see these alarms.

As far as the asynchonous I/O topic... Seemingly random changes in the I/O table during a scan? This would drive me nuts! mddr
I would love to see an example where this is actually NEEDED. I can see where you might want to update an input or two if you're dealing with a complex program (read: long scan time), but that's why the "immediate" instructions exist.

-Eric

Allen Nelson
May 24th, 2002, 07:21 AM
I called states 'X' and 'Y' "alarms", since they were where the program went if the motor didn't start. Due to how they're (by me, but implied by the K-map), both are active only for one scan.

Clearly they cannot be used (directly) to alert the operator, but as I said, alarm handling is in a different module ("It's not covered in the spec - I'll have to issue a change order").

It's actually a very similar module, with X (or Y) acting as PB-1, the operator alert acting as MOTOR, and some sort of acknowledgement acting as PB-2. You could even have "alarms" within that module, if the operator takes too long to acknowledge them! (probably should be called "alerts" or "faults", though)

Giving something the proper name is always tricky. I should have used the word "Fault", not "Alarm". The words are often used interchangably, but like SFC/State Logic/Grafcet, it ain't necessarily so.

------

On the tangent of asynchonous I/O scanning in the CLX: (Man, I miss the old forum's ability to branch off threads when tangents occur)

I think every CLX programmer MOVEs all their I/O into internal tags - otherwise they'd go nuts. I still haven't come up with a single good reason to do it, at least not with inputs. I could make a case for outputs, but asynchonous does not mean immediate update, so even there it doesn't buy you anything.

Rick Densing
May 24th, 2002, 07:35 AM
Perhaps a better term for X and Y would be "conditions". Like he said, alarms would be handled in different code.