State Machines and Sequencer Blocks?!?

Join Date
Mar 2008
Location
Vanderbijlpark
Posts
27
Hello All.

I've been reading increasingly about State Machines when browsing through these threads trying to expand my limited knowledge. Someone on another forum even suggested using them in a sequence-based program I was writing.

What exactly is a State Machine?

Furthermore, could someone give me a push in the right direction on how to use the sequencer blocks in AB RSLogix 500. I read the help files, but I'm afraid I didn't quite snap as to how they work...
 
Warren Boswell said:
Hello All.

I've been reading increasingly about State Machines when browsing through these threads trying to expand my limited knowledge. Someone on another forum even suggested using them in a sequence-based program I was writing.

What exactly is a State Machine?

Furthermore, could someone give me a push in the right direction on how to use the sequencer blocks in AB RSLogix 500. I read the help files, but I'm afraid I didn't quite snap as to how they work...

Not sure if this helps but I assume by state (unlike anybody else) you may want to look into the OMAC machine state.
Has nothing to do with sequencers as in machine steps but a bit more with a general state of a machine or sytem.
It is becoming the standard especially in the packaging world. ELAU, siemens and others have adopted it as a standard.
Not sure about the site but a google search on OMAC will be good enough to get you started.
I apologize if this is not what you are looking for, good reading though!!!
 
What exactly is a State Machine?
It refers to a machine that has been designed using logic state tables and other methods to reduce the Boolean logic to the lowest state required to do the job. Basically, you try to identify all the possible "states", or stages of the machine, and find the necessary transitions from each state to other states. Then you write the logic to perform the states.

Using logic state tables, all of the "don't care" conditions are identified and eliminated, so the the remaining logic only has the AND, OR, NAND, NOR, and NOT instructions that are absolutely necessary to accomplish the task. In simple terms, it is a method to minimize the logic statements to simulate a machine's functions.
 
Last edited:
A "state machine" is a set of "states" and "transitions". There are several mathematical models in computer science that fall under this category.

Imagine a soda machine that accepts 5, 10, and 25 coins. We could represent it as a directed graph of all combinations of money that leads to our $1.00 soda.

You certainly can reduce possible states. In my example, we could minimize our states by the amount of money in the machine. So the "5 dime" state is really the same as the "2 quarter" state or "10 nickel" state.

Lancie, I think you may be confusing Boolean Logic with state machines. What you described sounded like using Karnaugh maps to minimize the number of necessary logic gates. What that's doing is taking a set of input conditions and producing an output. In a state machine, the analogy would be that you're sitting at some state, accept an input, and determine the appropriate transition. The state machine doesn't go into detail at how it chose its transition based on the state and input conditions.

Lancie1 said:
It refers to a machine that has been designed using logic state tables and other methods to reduce the Boolean logic to the lowest state required to do the job. Basically, you try to identify all the possible "states", or stages of the machine, and find the necessary transitions from each state to other states. Then you write the logic to perform the states.

Using logic state tables, all of the "don't care" conditions are identified and eliminated, so the the remaining logic only has the AND, OR, NAND, NOR, and NOT instructions that are absolutely necessary to accomplish the task. In simple terms, it is a method to minimize the logic statements to simulate a machine's functions.
 
The state machine doesn't go into detail at how it chose its transition based on the state and input conditions.
It could be, but you haven't convinced me that the average programmer can set up a State Machine without some bit mapping to help determine what ALL the states ARE. Often, trying to do it without a K-map leads to errors, as it did for Peter in this post:

http://www.plctalk.net/qanda/showthread.php?t=1563&page=2&pp=5&highlight=K-MAP+Allen%27s+Challenge

The problem with a State Machine (as you have defined it) is that IF all the states can be correctly identified, then the machine works. If one possible state is left out, then it doesn't work. Someone has to first correctly identify the states, before your idea of a State Machine will work.
 
Last edited:
The problem I have with K-maps and other boolean logic reduction techniques as they apply to plc programming and state machines is that they will tend to obscure the relationship between states and transitions.

Take this as an analogy. Assume I give you an equation that states:

A = B * 3.141509 * 12 / 60

most of you could tell me what all the individual constants in the equation actually mean, even though I left the units out.

Now we look at the equivalent:

A = B * 0.6283184

You have no idea what the constant means. This is the decimal equivalent of what the K-map will give you.

In addition, whether you use a K-map or other boolean reduction technique you still need to know what your desired states and transision conditions are before you start that exercise. How do you know what to put into the K-map unless you have already considered the necessary conditions for the state transisions? That step is required regardless of the programming method.

Keith
 
From a previous post:


Hint? Hmmm, let's see... How about a link to about a JaZillion hits for State Machines on the InterToobs?

http://www.google.com/search?hl=en&...vending+machine


Or do yourself a favor and buy yourself a copy of Bebop to the Boolean Boogie.

BttBB has a perfect example of what you are looking for. I suggest that you plop down the $3.99 and get yourself a copy. Heck, the Gumbo recipe is worth at least that much. :)

It's an incredible book, and you'll thank me later.

http://www.amazon.com/Bebop-Boolean...s/dp/1878707221
 
State machines are simply an effective way to program your machine to follow a correct logical sequence rather than just stringing logic commands together for individual components. I work with ELAU controls and this has been a standard programming method for years. It creates a much easier flow of logic and ease of troubleshooting. For example, think in "english" terms how would you write out on a piece of paper, the step by step sequence your machine would go through to perhaps load a product in a box using a servo driven pusher:

Step 1:
Wait until product is ready in the infeed area
Step 2:
Verify that an empty box is ready to be loaded
Step 3:
Command servo pusher to move forward to push product

This is a very basic example, but if you apply the concept to your program, it can make a complicated process easy to understand. It can essentially be done with any programming language, but if you are familiar with the IEC-61131 languages, it is most effectively done in Structured Text because you can write it out in nearly the same "english" as described above:

CASE state OF:
1:
IF productsensor1 = TRUE THEN
state := 2;
END_IF
2:
IF emptyboxsensor = TRUE THEN
state := 3;
END_IF
3:
PusherAxisForwardCommand := TRUE
END_CASE


One benefit of this is that when there is a problem, you can simply check the status of your "state" variable and know exactly what the sequence is waiting for and you can ignore everything else. Again, this is extremely effective when you have a much more complex sequence of opertation because rather than going through humdreds of lines of code, you can easily isolate the sequence to one point.

I hope that explanation helps a little ...
 
You can use simple ladder logic to create a state machine or a sequencer.

Both are powerful, but have different uses. I use a state machine in cases where there are multiple branches between steps.

If you draw a flowchart of the machine behavior and it looks like a spider web, jumping from steps in a variety of patterns,m depending on the decision blocks, then a state machine type of logic is easiest and cleanest to implement.

If, on the other hand, it looks more like a straight line with few branches (decisions about which step to go to next), then a sequencer can be more effective.

The SQI/SQO instructions provide a very powerful way to organize a complex process in a small amount of code, but are best suited to process that go from step to step in order with pretty much the same repeating sequence. The SQO is not much more than a MVM with indirest addressing and a built in counter to step incrementally upward.

Somewhere I may have a ladder logic example of a state machine I can post if you'd like.

Hope this helps...

Paul
 
I am bringing this post back up because my 1 and only fellow programmer sent this to me. I scold him for using state logic. his states only start other sequences without order. In CO a company called Summit INT closed its doors probably cause they used non descriptive state logic intertwined with level II states and machine states along with there own PC.I bit sequence with descriptions. sorta the same my bits might start other bit seq,s. I would like to here more options.
 
Please clarify - I have no idea what you're asking.
SMOKE said:
I am bringing this post back up because my 1 and only fellow programmer sent this to me. I scold him for using state logic. his states only start other sequences without order. In CO a company called Summit INT closed its doors probably cause they used non descriptive state logic intertwined with level II states and machine states along with there own PC.I bit sequence with descriptions. sorta the same my bits might start other bit seq,s. I would like to here more options.
 
SMOKE said:
In CO a company called Summit INT closed its doors probably cause they used non descriptive state logic intertwined with level II states and machine states along with there own PC..

What did they do?? were they an automation company? or a manufacturing company?

If the logic works and it is well defined then whats the problem?

I do not care what style anyone uses as long as the program is stable and with the documentation I can fallow along with the logic... hell I may learn something new
 

Similar Topics

Sorry about this vague question but... How do I know, where can I find what standards a machine needs to be built to for a specific state, for...
Replies
10
Views
4,817
Quote from another thread: I wrote: Peter Nachtwey wrote: Peter showed us all some great example code how to do a basic state machine with...
Replies
12
Views
19,118
Hi, I am looking for basic ladder logic to create a PLC state machine or sequence. For starters I'd just like to alternate between different...
Replies
20
Views
7,653
K
In X years of programming I have not had one customer say that sequential function charts (or similar) PLC programming was acceptable. Everyone...
Replies
25
Views
34,205
We have a new machine that uses an armor block to transfer input signals for conveyor position that continuously alarms out on no position change...
Replies
0
Views
87
Back
Top Bottom