Combinational logic vs Sequential logic (Petrinets) in PLC

Sioan

Member
Join Date
Jan 2014
Location
Graz
Posts
91
What about an overall strategy to program chains of finite (Mealy) state machines ?
 
Last edited:
These are but one "tool" in the arsenal for use. Like all tools, they should be used where most appropriate. There is no single solution that fits best for all applications.
 
What's this? State machines should be the heart of just about every machine control program. However, most PLC state machine programs are implemented as Moore state machines not Mealy.
If you read a comparison about the two types of state machines you will see that Moore state machines normally have more states and are easier to program. Mealy state machines usually require fewer steps but each step is more complicated. The advantage of Meal state machines is that outputs will respond to inputs one scan earlier than a Moore state machine will.

As an overall strategy, it is too complicated for most common programming.
Nonsense. Mealy state machines are used all the time. I bet my FPGA programmer uses them without even thinking about it. In a PLC one would need to save away the current state bits into a copy or last state bits. Then it is easy to simplify with a Karnaugh map. If any of you remember Terry Woods you know he was a big believer in K-maps.

I don't think I have ever had to program a chain of state machines.
What? Where have you been? You haven't lived until you have done one. :)

The programming of our motion controller basically forces you to use a Moore state machine but we make it easy by hiding a lot of the details.

Writing a PLC program for a combination lock is a good exercise for students. I would make the students slave the program using Moore and Mealy state machine just so they get fixed in their mind what the differences are.
 
...each Moore automaton can be converted into a Mealy automaton, and vice versa ! (this is not the problem)

I think (to myself) is more simpler to think in Mealy's way to code ... you can so easier capsulate ... states ! (etc.)

;)
 
...each Moore automaton can be converted into a Mealy automaton, and vice versa ! (this is not the problem)
I agree

I think (to myself) is more simpler to think in Mealy's way to code ... you can so easier capsulate ... states ! (etc.)
;)
It depends on which state machine your are most comfortable with. Both methods will work. 25 years ago I was in Turkey working in a steel mill. There was a young PLC programmer that was trying to write PLC code for a down coiler. Basically it goes up and down. The programmer thought it should have only two rungs, one to make it go up and another to make it go down. I noticed that he was having difficulty with this problem for over a week. After I go my stuff done I asked the down coiler program to show me his program and tell me what is supposed to happen. I wrote a program that required 11 states or rungs instead of two. The PLC programmer didn't like the fact that my program was much 'longer' or had more rungs but when he entered my rungs there were only a few modifications necessary before the down coiler worked perfectly. The point is that Moore state machines usually require more rungs but they are simpler to implement.

I got a big Thank You from the project manager because I wasn't there to do PLC programming.
 
For example, you have:
3 states A, B, C ;
3 inputs a, b, c ;
3 outputs x, y, z and
... the start push button:

- Do you want that after pushing the start button the automaton react to inputs so =>
IF(start push button) -> A -> x
IF
x & c -> C -> z
IF
z & b -> B -> y
IF
y & a -> A -> x ...cycle ...

How do you think it will be easier to implement? Mealy or Moore?

:D
 
Last edited:
The PLC inputs are mostly ... sensors.(the outputs are mostly ... actors of course ;) )
A major problem is: what happens when a sensor (from a set of sensors) fails in a Mealy implementation and what happens if one fails in a Moore implementation ... :confused:

🍻
 
Last edited:
What happens when a sensor (from a set of sensors) fails in a Mealy implementation and what happens if one fails in a Moore implementation?
... me think , this question awaits a non trivial answer !
 
... me think , this question awaits a non trivial answer !

The answer to your question depends on what you are using and how strict you choose to be in your definition of the state machine.

In reality, what you describe already exists part and parcel in most modern PLCs in the form of SFC (sequential function charts). These are to a certain degree an enhanced and encapsulated Petri Net structure. So if I were using a controller with one of these and the customer was not mandating ladder only, then I would use this.

If you are modeling your state machine in ladder form (or STL or ST/SCL), then there is no reason to limit ones self to the strict definition of a Mealy/Moore state machine.

In regards to a failure of a sensor ..... I would expect either a state of the machine be programmed to detect it, an external fault (time based usually) to compare said input with said action to abort if the action does not occur, or a n overall global watchdog to abort the machine if too long has passed. Each method has advantages and disadvantages.

I disagree with Peter to an extent with the notion that all programs be based on a state machine. It is quite often that programs can be devoid of any sequence of consequence. It might simply be a host of PID loops. It might be just collecting data. It might just be firing a string of outputs based on a compared time or counter value. It might just be a bunch of seal-in rungs for motors.
 
The answer to your question depends on what you are using and how strict you choose to be in your definition of the state machine.
...

Sorry... not my definition , but the generally accepted !
A Moore implementation is very dangerous in case a sensor fails !
You know why ... ? :D
It's nearly human-impossible to manually convert a Mealy to a Moore and prevent such dangerous behavior !

(therefore Mealy bites the dog )
 
A CPU is a finite state machine therefore Mealy (Moore) is ... fundamental !
( very very big never means infinite )

;)
 

Similar Topics

Which of the two types of PLC programs do you use more often at work?
Replies
16
Views
5,418
Hi everybody, I am very new to this forum. I would to develop a combinational lock system, a program using PLC to open a lock with 2 or 3 digit...
Replies
0
Views
2,476
Good morning fellow sea captains and wizards, I am being asked to do the above and obtain 4 values from each slave, I know about the MRX and MWX...
Replies
20
Views
201
I have a machine which is undergoing upgradation. As part of the process two SEW drives are being replaced., existing Gen B with new Gen C. The...
Replies
3
Views
176
Hello Dear users, I am writing about a problem that has been bothering me for a few days, i.e. I am trying to establish remote access to the Allen...
Replies
0
Views
83
Back
Top Bottom