General Programming Question - Sequencing

sparkie

Lifetime Supporting Member
Join Date
Nov 2014
Location
KS
Posts
1,148
So this question has to do with sequence of events in a PLC program. I am using AB RSLogix 5k v20.01 for those interested, but this question tends to be pretty simple.

For an example, lets say I want to move a cylinder out and then back in when a photo eye is made, but I don't want to interrupt the process once it starts. I realize there is a lot more to something like that, such as alarms if the cylinder gets stuck or a sensor for extend and retract fails, etc but I would really like to focus on how to sequence it out.

Steps:
Step 1: Photo eye gets "made" and turns on an input.
Step 2: Cylinder Extends
Step 3: Cylinder Retracts

This is a really simple and dumbed down version of what I'm going to do, but I would really like some more details or even some example logic if you have some on how to accomplish this.

I guess one could use bit masks, bit shifts, a counter, etc to mark where one is at in the process so that we could pick back up in the same spot.

Thanks in advance for the help!
 
You can start by defining how you get from one step to another:

XIC Step1 XIC PhotoEye BST OTU Step1 NXB OTL Step2 BND

XIC Step2 XIC CylinderExtendLimitSwitch BST OTU Step2 NXB OTL Step3 BND

... and so on. This makes clear under what condition you change states. You will also need to think about what it takes to get into the first step.

What if you need to reset the process? Are there unsuitable steps at which to attempt this?

You can then define your outputs as a function of the state of the machine/process:

XIC Step2 OTE GreenLED

BST XIC Step2 NXB XIC Step3 BND OTE YellowLED

... for example.
 
Last edited:
I've only used sequencing when programing a machine running through a linear stepped process. The machine has to perform an output, before doing the next. I've always accomplished this through a integer tag or file. Basically list out each step the machine is to perform, and what conditions must be met to perform each individual step.

Steps:
Step 1: Photo eye gets "made" and turns on an input. (machine active) and moves an integer (1) into sequence tag.
Step 2: If sequence tag =(1) & (other conditions exist) then Cylinder Extends & move (2) into sequencer tag.
Step 3: If sequencer tag=(2) & (other conditions exist) Cylinder Retracts & move (0) into sequencer tag.

...or something like that..
 
For pick-n-place I usually use an add/sub that is a step number. Then use that step number to get the bit patterns for the IO for that step. So if an output is on in a step, it also triggers the alarm monitor for the limit switch to be made. Which is also the condition for the step to be complete.
 
if "photoeye" then seq = 1
if "extended" then seq = 2

if seq =1 then Cylinder extend
if seq =2 then cylinder retract

Your details aren't very specific, but hopefully this gives you the idea. Lots of different ways to implement.

I have also heard of people incrementing the sequencer values by multiples of 5, so that in the event they have to add an in-between step in the future, they don't have to change every single step after it.
 
Last edited:
I'll throw my vote for using an Integer Step_No tag.
Each action is preceded by a EQU Step_No x.
Conditions to move to the new step are followed by a MOV x Step_No.
It's easy to troubleshoot. Just go to the rung where Step_No matches the constant on the EQU. None of the other rungs are active.

On the subject of incrementing Step_No by 5 to leave room... We're using DINTs in the Logix world, they go to a bit over 2 billion. You can afford to skip a lot. I've been skipping by 100 on minor steps and skipping to the next even thousand or more for major steps. Step renumbering is a non-value added activity. Don't waste your time. On the other hand, when step numbers have more than 5 digits it seems to decrease your ability to notice typos etc. 4 or 5 digits seem to work fine for me.
 
There should be plenty of threads on sequencing, and opinions can vary.

Generally speaking, think of having 2 primary rungs of logic. 1st is the "Step Actions", what you need to be done in that particular step. The 2nd is the "Step Transition", what conditions need to be met to advance to the next step.

Design on paper first, a simple flow chart will do, but here is a post of mine in another thread that might be a better example.

http://www.plctalk.net/qanda/showpost.php?p=689162&postcount=4

Generally speaking you need to come up with your own "step engine". The logic that handles how the sequence operates such has, step timers, step interlocks, step manual advances/overrides, step alarms..etc. Once you have that framework then it should be easy to define the process and implement.

Some people like tracking steps by bits and bit manipulation. I prefer integer steps as it's clear and I always show the step information on the HMI so integer steps are easier for everyone. I to leave gaps for future steps, a base sequence might be 1,10,20,30,40,50....500 (where 500 is always my "complete" step).

Logic steps are incremented via hard code moves. "If step 10 transitions are complete, move 20 into next step, advance the step".
 
Read all of this. Thanks guys, I appreciate the help. I'm going to write a routine today and hopefully I'll be able to test it Sunday when production is dark.
 
Also,

if you need an action to stay on for more than one step, you can use an inrange comparator instruction instead of multiple equal's
 
To be honest I'm not familiar with the RSL5k instructions. I know in 500 though that there was an instruction, where you could reference an integer value, and say that you want it to be true while the integer is in the range 1 to 5 or 5 to 10, whatever the amount of steps you need.

Now if you need the action to be true for more than one range, then you add another of the range instructions, but hopefully you get the idea.
 
I got ya. You are referring to the Limit Instruction. I have mostly seen it used with encoders.
 
I've made a step driver that I use for my sequencers. It's based on integer stepping and encapsules the coding for shifting steps (next -> active), tipping in manual mode, step timer(s), step entering bit, and also an array with step bits. It is made for use with Simatic.

Forum member 'scameron81' is apperantly doing something similar with AB, see the very last post in this thread:

http://www.plctalk.net/qanda/showthread.php?t=102563&highlight=aoi&page=3

Kalle
 
I've made a step driver that I use for my sequencers. It's based on integer stepping and encapsules the coding for shifting steps (next -> active), tipping in manual mode, step timer(s), step entering bit, and also an array with step bits. It is made for use with Simatic.

Forum member 'scameron81' is apperantly doing something similar with AB, see the very last post in this thread:

http://www.plctalk.net/qanda/showthread.php?t=102563&highlight=aoi&page=3

Kalle

Thanks for the info, I will check it out. This is new territory, but I must admit it is kind of fun and a new way for me to program. I'm dealing with a lot more than a cylinder, but the basic idea remains the same.
 

Similar Topics

Greetings, I am an Allen-Bradley programmer who has an opportunity to work with some Siemens equipment (S7-1200). The discreet stuff is pretty...
Replies
7
Views
2,795
I have experience in multiple studios writing mostly ladder logic for smaller applications. I am about to write by far the largest program I have...
Replies
8
Views
2,367
What is your perspective? Are you a Maintenance Tech? Systems Integrator? OEM Engineer? What are your thoughts on the topic of source...
Replies
24
Views
1,198
Wizards, It has been a few, but you all have always done me well. I have acquired a 1769-L33ER and want to use it as my collection PLC to...
Replies
5
Views
550
Hi! I recently discovered how to get to configuration mode and disable printing for connecting to PanelBuilder32 and updating my Panelview...
Replies
1
Views
461
Back
Top Bottom