State logic

SFC vs State

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

a k_map.gif
 
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).
 
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.
 
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.
 
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!
 
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 & 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.
 
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?
 
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?
 
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:
 
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
 
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.
 
Last edited:
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.
 

Similar Topics

I'm trying to add on to a safety circuit and trying to make sure this is fail-safe. My safety scanner needs some muting when things aren't running...
Replies
8
Views
853
Hi, I have read a few threads here at plctalk on the GE State Logic Processor, an IC693CSE313B in my case. I have the Eclips software V3.01 but...
Replies
1
Views
1,992
Hello, I work at a facility where there are a number of older 9030's that we communicate with a Laptop with Eclipse software installed, which is...
Replies
9
Views
7,520
Hello All, I am using Cimplicity Machine Edition (TM) v4.50 Build 3173 and programming using State Logic, I have configured a CPX935. I have a...
Replies
7
Views
3,255
Hi all, Back in 1995 I was exposed to GE Fanuc’s State Logic as the client recommended solution to two batching projects; one using the 9030...
Replies
7
Views
4,474
Back
Top Bottom