×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

emulating "state machine" programming with ladder logic

emulating "state machine" programming with ladder logic

emulating "state machine" programming with ladder logic

(OP)
Howdy! I recently completed a project using the Koyo/AutomationDirect DL05/06 PLC. I was quite impressed by their cost effectiveness (though the development software could be a tad cheaper, IMHO). One thing I found very useful was the "state machine" programming they offer. Coming from a non-PLC background, I find it more intuitive to think in state machines rather than ladder logic. I actually used both in my project, depending which seemed clearer.

I am now on a simple project involving control of multiple door operators. Again, I find it simpler to think in terms of state machines. But this time I am looking at the TECO SG2 "PLRs" (which look really quite nifty!), which don't offer state machine programming. I'm curious what the "classical" method of emulating state machines in ladder logic is... My guess is that I use SET and RESET instructions to control a bit for each STATE. I then use those bits as the first element in rungs which control whether a state's actions occur or not.

Do I have the right idea? Anyone familiar with the SG2 able to suggest other methods? Anyone want to comment on the SG2 (or similar Omron ZEN) in general?

Thank you!
 


RE: emulating "state machine" programming with ladder logic

I would switch to Logic Diagram (if available) and use a set of clocked (D type) flipflops with a decoding net to read out the states.

You can probably achieve the same thing in Ladder - but I never use it. Some PLCs allow you to program in Logic Diagram (or whatever they call it) and then transform to Ladder if that is more acceptable for the end user.

Gunnar Englund
www.gke.org
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...

RE: emulating "state machine" programming with ladder logic

(OP)
Ah! Good point. Yes, the TECO does offer a "Function Block" programming mode, too.

After playing with the TECO software in ladder mode a bit, I may use the AutomationDirect DL06 for this application.  Hardware-wise, the TECO would be fine, but the AD will handle the programming of this problem so easily! I bet I can do it in 1 hour. I was more than a bit impressed with how nicely it handles state machine programming. It's not perfect, but it's competent. Plus when I am done I feel more confident that I have the solution right. We have paid for the software, so why not use it? :)

One noticeable limitation to the TECO software: you can name IO points, but you can't seem to choose them by name when you place them. For example, you can name I1 (input 1) as MY_SWITCH1, but you still must put it on a rung as I1. I don't even think you can view the list of symbolic names while working...

There also is no UNDO function. C'mon folks, it's 2007!

The TECO looks fine for small projects, but keep 'em small.

RE: emulating "state machine" programming with ladder logic

You could look into a PLS with the option to program in structured text like so. Ladder is really the way of the past that is only around because old dogs don't want to learn new tricks. I mean really, they advance the tech so you don't use big relays and switches only to program with pictures of relays and switches? It is horrible for developing a complex machine or process and for high speed machines, ladder code runs so slow that you can't get cycle times down (instruction list is fastest but Structured text will simplify the code so there is less to run). B&R stuff is normally cheaper than Rockwell and will offer Ladder, Structured Text, Automation Basic (proprietary leftover from before Structured Text was in the standard), Instruction List, ANCI C and one other I'm forgetting on all their PLC's. They also have integrated HMI editor. I'm not sure what other brands offer the higher level languages.

State machine in ST:

CASE YOUR_STATE_VAR OF

    STATE_NAME:
           your code;

    ANOTHER_STATE_NAME:
           some more code;

END_CASE

RE: emulating "state machine" programming with ladder logic

TheMcNasty,

I am an old dog with 15 years as an electrician and 20 years as an engineer who loves ST, its benefits are clean structured coding, searching, communication, data handling, the list just goes on and on.  

ST allows the PLC to live up to the fact that it IS a computer.  I just wish it would support string literals, the Rockwell implementation of ST does not.

What platforms have you used ST on, what are your likes/dislikes?

RE: emulating "state machine" programming with ladder logic

GE Fanuc does ST right in the PAC series.
If you like StateLogic they have that too but only on the older 90 Series PLCs and they don't advertise it.

RE: emulating "state machine" programming with ladder logic

Hiya-

State information is traditionally done with "latching relays" in PLC or ladder logic programming.

These are really analogus to SR flip flops.  They retain their state until explicitly set or reset by the condition of the left hand side of the ladder logic rung.  

They can be used to easy retain state information.

I come from a CS type background where ladder logic is NOT a priority.  In fact, most programmers, if asked do not know anything about ladder logic.

It is a shame.  Having both high, assembly and ladder logic experience, I find that there is a certain class of projects that are most easily solved using ladder logic programming.  

IMHO, having both ladder logic and conventional computer programming allows the engineer to pick the best tool for the job.

  Cheers,

    Rich S.

RE: emulating "state machine" programming with ladder logic

jonesy29847,

I've only used ST on B&R and one or two times with Siemens. I would assume that Siemens implementation is similar to AB and I found it to be pretty good but didn't have to do anything nifty with it so I don't know the limitations. With B&R, the only annoyance that I've run into is that you cannot define a structure in code or an array of variable size. For that I make an ANCI C task that just defines my structures and arrays. I try to stay away from C otherwise as it is more intimidating to customers.

I like everything else about it except typing := instead of just =  . And, if you are doing complex math, you can actually copy and paste formulas from/to Maple because Maple is ST!

Maybe if I didn't use as many non-bool values and loops I would like ladder, but then again, I don't automate switches and lights. I'm doing machines with servo drives, digital cams, combinatorial mathematics, pressure and temperature loops, network communications, and trending. You just can't do it all in ladder.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources