DirectLOGIC PLCs - the most practical PLCs in the industry......from AutomationDirect go back to Do-more home AutomationDirect online store

Spend Less; Do More

Do-more™ PLC: Video - Intro to Stage Programming

Video Transcript:

Ladder programming is ideal for taking lots of inputs and using those inputs to control lots of outputs.

Ladder logic can also be used to manage sequences of events, but it does involve some additional interlocking, control bits, and housekeeping logic. Stage programming doesn't replace ladder coding, it makes it easier to use ladder logic to control sequences of events.

Let's look at a side by side example comparing the two methods. Picture a drill head mounted on a carriage. We want the carriage to move out to a fixed location, the drill to move down and drill a single hole, the drill to retract, and the carriage to return 'home'.

Here's how you might do that in ladder – note that this is simplified for example purposes and is NOT intended to be a fully implemented or tested code set. We'll run this in the simulator over here so we can follow along. Let's turn that on … put it in run mode … and let's turn our status on se we can see all of the bits.

On Rung 1 we make sure the Carriage is pulled back in and that the Drill position is up. We'll simulate that by punching X2 and X4. OK, our system is ready to go and we'll accept the start button from the user. When the user hits the start button - which is our X1 input – we turn on the move out interlock. That tells the rest of the system that the carriage is moving out. And we turn on the motors so the carriage starts moving. When the carriage starts moving this IN limit switch is going to release. So we'll do that. And that moves us down onto this rung.

Rung number 2. Now this rung is enabled with this interlock bit until we're waiting until the carriage hits the OUT limit switch. When that happens, X3 gets set, we turn off the motor moving the carriage out, We turn off this rung, We enable the interlock to the next rung, and we turn on the Drill Down Motor.

Now all future scans will ignore this rung, and we'll come down and run this one. So now the drill is moving down, which will release the UP Limit Switch, and when it hits the DOWN limit switch, X5, It stops the drill from moving down, turns off this rung, turns on the drill moving up and enables the next rung with this interlock.

As the drill starts moving up, the down limit switch will turn off, and eventually we will hit the upper limit switch, X4. When that happens, we stop the Drill Up Motor, we turn off this rung, we turn on the motor that moves the carriage back to the home position, and we turn on the next rung with this interlock. As the carriage moves back in, it will release the OUT limit Switch, and we'll move down to the next rung.

Now only this rung is enabled with this interlock bit. And it is simply waiting for the carriage to come all the way back in. When that happens, it turns off the carriage motor, and it turns off the MoveBack In interlock. And of course by now the user would have let go of the button, hopefully …

And we are right back to the beginning of the ladder logic where both limit switches are set and we are waiting for the user to press the button.

We'll, that's not too bad, especially when you give each control bit a good nickname like you see here.

Now let's do the exact same thing in stage programming – with one exception. The Stage Program code is in its own code block called "Drill_1." I've also made multiple copies of this for something we are going to do later. Drill_1 is enabled back in main. On the first scan, we enable that drilling routine, and it runs continuously until the PLC is turned off. So we are just going to focus on Drill_1 so we can do a side by side comparison with the Ladder Logic we just saw.

We're going to run it in our simulator, so let's turn him on, and let's turn on the status bits so we can see what's going on. The first rung is just a comment, so you can ignore that.

The second rung is our first stage. As you can see from the status bits, this stage is enabled. The cool thing about this is - over here in program view, if you open up the program code block – you can see exactly which stage you are in. In stage 0 – just like the ladder code – we're waiting for the motor carriage to be back in and the drill to be up. Let's go ahead and force that by turning on those bits.

When that happens, Stage 0 transitions to stage 1. So Stage 0 rungs are no longer run, and every time we come into this code block, we only run the stage 1 ladder code. In Stage 1, we are waiting for the user to press the start button. Let's do that. I'm going to press it and release it. What that did, is it started the motor to move the carriage out. As that starts to move, the IN limit switch is going to release. And eventually it hits the OUT limit switch at X3.

When that happens, we turn off the motor, and we transition to stage 2. Now these rungs will no longer be run, and the stage 2 rungs WILL be run. And again, you can see here and here which stage we are in.

In stage 2, we unconditionally enable the Drill Down motor, which is going to release the UP limit switch, and eventually hit the down limit switch. When that happens, we turn off that motor, and transition to Stage 3.

In Stage 3, we unconditionally turn on the Drill Up Motor, which is going to release the drill down limit switch, and eventually hit the Up limit switch, X4. When that happens, we turn off the motor, and we transition down to Stage 4.

In stage 4, we unconditionally turn on the motor that pulls the carriage back in … which is going to release the OUT limit switch, and eventually hit the IN switch. When that happens, we turn off the motor, and we jump back to Stage 1. Let's go up there and look. In stage 1, we wait for the user to press the button, and we start the sequence all over again.

We didn't need to go back to stage 0 because we know the motor is in and up. So we can go straight to Stage 1 and wait for the user to press the start button again.

As you can see, both ladder and stage are very similar. But with stage we didn't have to create and manage a bunch of interlock bits and logic – stage did it for us. And here's a real big advantage of using stage: Suppose we have a number of these drilling heads. With Stage, I can simply copy this entire code block and paste it into another drilling code block like I did here: Here's Drill_1 and Drill_2 … Look, this code is identical to the code we just looked at. Now, of course, in this new routine all of your motors and limit switches would change, but what Stage saves us is, having to create a whole new set of interlock logic and interlock control bits. We get to reuse these S-bits because they don't interfere with the S-Bits in the other code block. So you can see while I have S0 through S4 here, and S0 through S4 here, and S0 through S4 here, none of these interfere with each other. These S-Bits are unique to this code block. And that's where stage saves you a lot of time and headache when you are setting up sequences of events. With Ladder you would have to create a whole new set of control bits for each code block you create.

And of course, the other cool thing is if multiple of these heads are running, you can see what stage each head is head is in, in real time as the program runs. That's really handy when you are trying to figure out what is going on.

Not having to worry about all of these control bits and interlock logic, is especially helpful when you are trying to control sequences of sequences. Imagine having to keep up with all of THOSE interlock bits.

So again, you can use stage or ladder to manage sequences. Stage just makes handling sequences easier when creating the sequencing code, when debugging the sequencing code, and when maintaining the sequencing code.

A word of caution, though … make sure you fully understand ladder BEFORE trying to use Stage. Stage doesn't replace ladder, it just helps manage it.

Well, that should be enough to get you going. Please send us any comments or suggestions you may have. We appreciate the feedback.

Spend Less. Do-more. From Automation Direct.


Check-out all the Do-more™ Videos

  The Do-more Way
  Do-more Designer Software
  Do-more Ethernet I/O
  Do-more Motion Control Videos
  Do-more with ViewMarq Message Display

User Application Stories
Encompassing all AutomationDirect PLCs

Helpful PLC guides



Copyright © All rights reserved.All prices are U.S. list prices.