Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SSS148 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

emulating "state machine" programming with ladder logic

Status
Not open for further replies.

eeinpa

Electrical
Nov 12, 2006
65
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!



 
Replies continue below

Recommended for you

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
--------------------------------------
100 % recycled posting: Electrons, ideas, finger-tips have been used over and over again...
 
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.
 
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
 
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?
 
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.
 
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.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor