PDA

View Full Version : PLC State Machines / Sequences


davidd31415
March 9th, 2010, 10:47 PM
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 bits being turned one seconds after each other.

For instance, bit one on, delay one second, bit two on, delay one second, bit three on, and so on. Can someone point me to an example ladder logic code which accomplishes this?

Will I need to use a separate timer for each state or can a single timer be used?

Thanks!

jstolaruk
March 10th, 2010, 04:18 AM
Welcome to the forum.

Homework, eh?

A starting hint will be to use separate timers. Now, give something a try & post what you've completed and you'll get some help without actually giving you the answer. Good luck!

davidd31415
March 10th, 2010, 06:13 AM
Homework? No. I studied PLCs for about two weeks back in the late 90s while working on my BSEE but it was the manufacturing engineering students who focused on them.

If you'd like to discuss the application feel free to send me a PM and I'll respond with my phone number. I'll buy you lunch if you're ever out in the Troy area. I might have some future work for you to, if you're looking.

Meanwhile, if this forum does not assist with simple questions then hopefully this thread can be deleted. I'd hate for anyone, student or professional alike, to search the internet, find this thread, and then read your response.

bernie_carlton
March 10th, 2010, 06:24 AM
AutomationDirect provides for some of its lines a helpful add-on to the Relay Ladder Logic called Stage Programming. They have a demo version of their software (DirectSoft - limited to a fairly small 100 steps). I use Stage Programming for our machines to control specific processing steps.

mordred
March 10th, 2010, 06:48 AM
which processor ? I didn't see anything on processor type?

jstolaruk
March 10th, 2010, 06:55 AM
Homework? No. I studied PLCs for about two weeks back in the late 90s while working on my BSEE but it was the manufacturing engineering students who focused on them.

If you'd like to discuss the application feel free to send me a PM and I'll respond with my phone number. I'll buy you lunch if you're ever out in the Troy area. I might have some future work for you to, if you're looking.


PM sent.

Meanwhile, if this forum does not assist with simple questions then hopefully this thread can be deleted. I'd hate for anyone, student or professional alike, to search the internet, find this thread, and then read your response.

This site is often a target for students that just want to complete the homework by having someone else provide the answers. Forum members are happy to assist the student in learning by trying to lead the student to the answers by themselves.

Bobbias
March 10th, 2010, 08:25 AM
Yes, sorry if we sounded like a bunch of grumpy old codgers trying to keep people from learning anything. If you do a search of the forums for State Machines, you'll see quiute a few posts discussing them, and the various uses, ways of programming, and such.

As for something like what your doing, if your using Allen Bradley PLCs, there's the SQO function. Using that, you could accomplish what you want. I did a quick google search and came across this (http://www.ent.ohiou.edu/~tscott/IT435/PLC%20RSLogix%20Sequencer(Help).doc), which looks helpful. However, it explains the function using tags, which are only available in RSlogix5000, not 500.

mordred
March 10th, 2010, 08:36 AM
also do a search n this forum SQO has been under discussion numerous times

Bobbias
March 10th, 2010, 08:50 AM
That too, lol. This forum has HUGE amounts of knowledge available for you to search through. It is quite possibly the best place to learn about PLCs online.

davidd31415
March 10th, 2010, 11:47 AM
Bobbias,

Actually I've been using DL PLCs but I'd like to be able to quickly write state machines regardless of what PLC I'm using.

Using the term SQO should help narrow my searches.

I found this book online this morning: http://webbooks.net/freestuff/plc.pdf which shows a few different state machine design examples on pages 289-298. I'll take a look at other discussions on here tonight.

Regards,

David

Bobbias
March 10th, 2010, 11:58 AM
Also, searching Washing Machine may bring up a lot of stuff about state machines, lol.

Doug-P
March 10th, 2010, 12:37 PM
A common method of doing what you want is to use an integer register to enable various sections of logic as the sequence progresses.

When the register EQUals '1' say, some logic is enabled causing a machine to do something. At some preprogrammed point a condition will be met (limit switch made, timer done, etc.). When this happens a new value is loaded to the integer register thus enabling a new section of logic to accomplish the next step and disabling the previous step. Each step will have this EQU comparison - using different values, of course, to enable the various sections. This is very similar to the stage programming mentioned by bernie_carlton.

Sequential Function Charts are another form of sequencing. If you can draw out your sequence with an SFC the conversion to ladder is straightforward.

I would dissuade you from SQOs.

jstolaruk
March 10th, 2010, 12:41 PM
A common method of doing what you want is to use an integer register to enable various sections of logic as the sequence progresses.

When the register EQUals '1' say, some logic is enabled causing a machine to do something. At some preprogrammed point a condition will be met (limit switch made, timer done, etc.). When this happens a new value is loaded to the integer register thus enabling a new section of logic to accomplish the next step and disabling the previous step. Each step will have this EQU comparison - using different values, of course, to enable the various sections. This is very similar to the stage programming mentioned by bernie_carlton.

Sequential Function Charts are another form of sequencing. If you can draw out your sequence with an SFC the conversion to ladder is straightforward.

I would dissuade you from SQOs.

Agreed.

Sequencers can be a bear to figure out by others or even by the author at later dates. Plus, they are not necessarily transportable between plc mfgs (some plcs don't support them). In my case, customers specifically disallow them.

PLCRookie
March 10th, 2010, 12:41 PM
This may be of help also.

PLCRookie
March 10th, 2010, 12:44 PM
It would be more helpful with the attachment, but is is too big. I will zip it. Sorry.

:D

Bobbias
March 10th, 2010, 12:47 PM
I'd forgotten about the integer-as-state-identifier method. That works, but not always as well as you'd like. It works wonders in systems where each state is mutually exlusive. And of course, you can represent a system with various non-exclusive states by expanding the number of exclusive ones to involve all possible combinations, but that can get very messy and complex if your dealing with a number of states that can go on and off independant of a certain process (such as say, a washing machine that has to control the water temp by a simple "if too cold, heat up, if too hot, turn heater off" scenario, along with various the usual sequence of events). Of course, you could go for a hybred approach and have the heater control and wash cycle control have their own independant process controlling variables as well.

This is a good example of how there are plenty of different ways to go about this sort of thing, davidd31415.

PLCRookie
March 10th, 2010, 12:50 PM
O.K. Still too big.
How about a link.

http://www.dmcinfo.com/Knowledge/White-Papers/articleType/ArticleView/articleId/94/State-Function-Chart-to-Ladder-Diagram-Translation.aspx

:reup:

Bill Wheeler
March 10th, 2010, 01:52 PM
For Allen Bradley take a look at these 2 manuals. They offer quite a bit of help in understanding SFC and Phase State programming. They can be found at the Allen Bradley site without a tech-connect contract.

SFC 1756-PM006B-en-p
Phase State LOGIX-um001A-en-p

I have only run into SFC a couple of times on a Direct Logic PLC. I was amazed how quickly I could understand how the equipment was programmed to operate.

I have not had the pleasure of using the AB Phase State programming, but had planned to use this method on a project that has since been cancelled. I really think that there is a lot of power in this method because it forces one to think in terms equipment in terms of normal states; stopped, running, idle, or faulted and the transitional actions needed to move from one state to the next. I see too many pure ladder logic routines that are poorly organized where it is difficult to key in on an equipment state and what leads to a state transition. At the very least this method looks like it forces a logical organization.

Even if you decide not to use Phase State programming, I believe using the phase state model is an excellent tool to use when developing a new project. Most processes and tools fall very neatly into this model.

Bobbias
March 10th, 2010, 02:09 PM
I'll have to look into those myself. Phase State does sound very interesting.

Archie
March 10th, 2010, 05:35 PM
A few years ago I did a short video on how to design a state diagram/SFC and represent it in ladder logic. You can find it here:

http://www.youtube.com/watch?v=rCa_U6YATTA

powereng
June 21st, 2011, 11:15 PM
If we want to design this problem using state diagrams OR Flip-Flops, How can we do that: