Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 46 of 68

DL405 User Manual: Chapter 7: RLLPLUS Stage Programming, pages 399 to 408

Pages 399 to 408 of 608, from DL405 User Manual

The original document is the PDF (8.2 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the AutomationDirect D4-08B-1, AutomationDirect D4-08ND3S, AutomationDirect D4-16TA, PLC Direct D4-16TD2, AutomationDirect D4-32ND3-1, Konnect-It D4-08B-1, Koyo D4-08B-1, Konnect-It D4-08ND3S, and 6 more models

Page 399

RLL PLUS Stage Programming

17

In This Chapter. . . ., Introduction to Stage Programming, Learning to Draw State Transition Diagrams, Using the Stage Jump Instruction for State Transitions, Stage Program Example: Toggle On/Off Lamp Controller, Four Steps to Writing a Stage Program, Stage Program Example: a Garage Door Opener, Stage Program Design Considerations, Parallel Processing Concepts, Managing Large Programs, RLL PLUS Instructions, Questions and Answers About Stage Programming

Page 400

7--2

RLL PLUS Stage Programming

Introduction to Stage Programming

RLL PLUS Stage Programming

430 440 450

Overcoming “Stage Fright”

Stage Programming (available in all DL405 CPUs) provides a way to organize and program complex applications with relative ease, when compared to purely relay ladder logic (RLL) solutions. Stage programming does not replace or negate the use of traditional boolean ladder programming. This is why Stage Programming is also called RLL PLUS. You won’t have to discard any training or experience you already have. Stage programming simply allows you to divide and organize a RLL program into groups of ladder instructions called stages. This allows quicker and more intuitive ladder program development than traditional RLL alone provides.

Many PLC programmers in the industry have become comfortable using RLL for every PLC program they write... but often remain skeptical or even fearful of learning new techniques such as stage programming. While RLL is great at solving boolean logic relationships, it has disadvantages as well: S Large programs can become almost unmanageable, because of a lack of structure. S In RLL, latches must be tediously created from self-latching relays. S When a process gets stuck, it is difficult to find the rung where the error occurred. S Programs become difficult to modify later, because they do not intuitively resemble the application problem they are solving.

X0

X4

C0 RST C1

Y0 SET

STAGE! X3

Y2 OUT

It’s easy to see that these inefficiencies consume a lot of additional time, and time is money. Stage programming overcomes these obstacles! We believe a few moments of studying the stage concept is one of the greatest investments in programming speed and efficiency a PLC programmer can make! So, we encourage you to study stage programming and add it to your “toolbox” of programming techniques. This chapter is designed as a self-paced tutorial on stage programming. For best results: S Start at the beginning and do not skip over any sections. S Study each stage programing concept by working through each example. The examples build progressively on each other. S Read the Stage Questions and Answers at the end of the chapter for a quick review.

DL405 User Manual, 4th Edition

Page 401

RLL PLUS Stage Programming

7--3

Learning to Draw State Transition Diagrams Introduction to Process States

Inputs

Ladder Program

Outputs

PLC Scan 1) Read

Execute

Write

2) Read

Execute

Write

3) Read

(etc....)

Most manufacturing processes consist of a series of activities or conditions , each lasting for several seconds, minutes, or even hours. We might call these “process states”, which are either active or inactive at any particular time. A challenge for RLL programs is that a particular input event may last for just a brief instant. We typically create latching relays in RLL to preserve the input event in order to maintain a process state for the required duration. We can organize and divide ladder logic into sections called “stages”, representing process states. But before we describe stages in detail, we will reveal the secret to understanding stage programming: state transition diagrams. The Need for State Sometimes we need to forget about the scan nature of PLCs, and focus our thinking toward the states of the process we need to identify. Clear thinking and concise Diagrams analysis of an application gives us the best chance at writing efficient, bug-free programs. State diagrams are just a tool to help us draw a picture of our process! You’ll discover that if we can get the picture right, our program will also be right! Inputs Outputs A 2--State Process Consider the simple process shown to the right, which controls an industrial motor. On We will use a green momentary SPST X0 Motor pushbutton to turn the motor on, and a red Ladder Y0 one to turn it off. The machine operator will Program Off X1 press the appropriate pushbutton for just a second or so. The two states of our process are ON and OFF. Transition condition The next step is to draw a state transition State diagram, as shown to the right. It shows X0 the two states OFF and ON, with two transition lines in-between. When the OFF ON event X0 is true, we transition from OFF to X1 ON. When X1 is true, we transition from Output equation: Y0 = ON ON to OFF. If you’re following along, you are very close to grasping the concept and the problem-solving power of state transition diagrams. The output of our controller is Y0, which is true any time we are in the ON state. In a boolean sense, Y0=ON state. Next, we will implement the state diagram first as RLL, then as a stage program. This will help you see the relationship between the two methods in problem solving.

DL405 User Manual, 4th Edition

RLL PLUS Stage Programming

Those familiar with ladder program execution know that the CPU must scan the ladder program repeatedly, over and over. Its three basic steps are: 1. Read the inputs 2. Execute the ladder program 3. Write the outputs The benefit is that a change at the inputs can affect the outputs in just a few milliseconds.

Page 402

7--4

RLL PLUS Stage Programming The state transition diagram to the right is a picture of the solution we need to create. The beauty of it is this: it expresses the problem independently of the programming language we may use to realize it. In other words, by drawing the diagram we have already solved the control problem!

X0

OFF

ON X1

Output equation: Y0 = ON

RLL PLUS Stage Programming

First, we’ll translate the state diagram to traditional RLL. Then we’ll show how easy it is to translate the diagram into a stage programming solution. RLL Equivalent

Stage Equivalent

The RLL solution is shown to the right. Output Y0 has a dual purpose. When the On momentary pushbutton, X0, is pressed, output coil Y0 turns on and the Y0 contact on the second row latches itself on. So, X0 sets the latch Y0 on, and it remains on after the X0 contact opens. The output Y0 has power flow on a field device. When the Off pushbutton (X1) is pressed, it opens the normally-closed X1 contact, which resets the latch, and output Y0 turns off. The stage program solution is shown to the right. The two inline stage boxes S0 and S1 correspond to the two states OFF and ON. The ladder rung(s) below each stage box belong to each respective stage. This means that the PLC only has to scan those rungs when the corresponding stage is active! For now, let’s assume we begin in the OFF State, so stage S0 is active. When the On pushbutton (X0) is pressed, a stage transition occurs. The JMP S1 instruction executes, which simply turns off the Stage bit S0 and turns on Stage bit S1. So on the next PLC scan, the CPU will not execute Stage S0, but will execute stage S1! In the On State (Stage S1), we want the motor to always be on. The special relay contact SP1 is defined as always on, so Y0 turns the motor on.

Set

Reset

Latch

X0

X1

Y0 OUT

Latch Y0

SG S0

OFF State Transition S1

X0

JMP SG S1

ON State SP1 Always on

Output Y0 OUT

Transition X1

S0

JMP

When the Off pushbutton (X1) is pressed, a transition back to the Off State occurs. The JMP S0 instruction executes, which simply turns off the Stage bit S1 and turns on Stage bit S0. On the next PLC scan, the CPU will not execute Stage S1, so the motor output Y0 will turn off. The Off state (Stage 0) will be ready for the next cycle.

DL405 User Manual, 4th Edition

Page 403

RLL PLUS Stage Programming Let’s Compare

7--5

Right now, you may be thinking “I don’t see the big advantage to Stage Programming... in fact, the stage program is longer than the plain RLL program”. Well, now is the time to exercise a bit of faith. As control problems grow in complexity, stage programming quickly out-performs RLL in simplicity, program size, etc. For example, consider the diagram below. Notice how easy it is to correlate the OFF and SG S0 ON states of the state transition diagram OFF State below to the stage program at the right. Now, S1 X0 we challenge anyone to easily identify the JMP same states in the RLL program on the previous page! SG SP1

X0

OFF

ON State

S0 JMP

X1

ON

Y0 OUT

X1

Initial Stages

At powerup and Program-to-Run Mode transitions, the PLC always begins with all normal stages (SG) off. So, the stage programs shown so far have actually had no way to get started (because rungs are not scanned unless their stage is active). Assume that we want to always begin in the Off state (motor off), which is how the RLL program works. The Initial Stage (ISG) is defined to be active at powerup. In the modified program to the right, we have changed stage S0 to the ISG type. This ensures the PLC will scan contact X0 after powerup, because Stage S0 is active. After powerup, an Initial Stage (ISG) works just like any other stage! We can change both programs so that the motor is ON at powerup. In the RLL below, we must add a first scan relay SP0, latching C0 on. In the stage example to the right, we simply make Stage S1 an initial stage (ISG) instead of S0.

Powerup in OFF State ISG S0

Initial Stage S1

X0

JMP SG S1 SP1

Y0 OUT S0

X1

JMP

Powerup in ON State SG S0 S1

X0

JMP

Powerup in ON State X0

X1

C0 SP0

C0 OUT Y0 OUT

ISG S1 SP1

X1

First Scan

Initial Stage

Y0 OUT S0 JMP

NOTE: If the ISG is within the retentive range for stages, the ISG will remain in the state it was in before power down and will NOT turn itself on during the first scan.

DL405 User Manual, 4th Edition

RLL PLUS Stage Programming

S1

Page 404

7--6

RLL PLUS Stage Programming We can mark our desired powerup state as shown to the right, which helps us remember to use the appropriate Initial Stages when creating a stage program. It is permissible to have as many initial stages as the process requires.

Powerup

X0

OFF

ON X1

What Stage Bits Do You may recall that a stage is just a section of ladder program which is either active or inactive at a given moment. All stage bits (S0 -- Sxxx) reside in the PLC’s image register as individual status bits. Each stage bit is either a boolean 0 or 1 at any time. Program execution always reads ladder rungs from top to bottom, and from left to right. The drawing below shows the effect of stage bit status. The ladder rungs below the stage instruction continuing until the next stage instruction or the end of program belong to stage 0. Its equivalent operation is shown on the right. When S0 is true, the two rungs have power flow. S If Stage bit S0 = 0, its ladder rungs are not scanned (executed). S If Stage bit S0 = 1, its ladder rungs are scanned (executed). Actual Program Appearance

SG S0

Functionally Equivalent Ladder

S0

(includes all rungs in stage)

Stage Instruction Characteristics

The inline stage boxes on the left power rail divide the ladder program rungs into stages. Some stage rules are: S Execution -- Only logic in active stages are executed on any scan. S Transitions -- Stage transition instructions take effect on the next occurrence of the stages involved. S Octal numbering -- Stages are numbered in octal, like I/O points, etc. So “S8” is not valid. S Total Stages -- The maximum number of stages is CPU-dependent. S No duplicates -- Each stage number is unique and can be used just once. S Any order -- You can skip numbers and sequence the stage numbers in any order. S Last Stage -- the last stage in the ladder program includes all rungs from its stage box until the end coil.

DL405 User Manual, 4th Edition

SG S0

SG S1

SG S2

END

Page 405

7--7

RLL PLUS Stage Programming

Using the Stage Jump Instruction for State Transitions Stage Jump, Set, and Reset Instructions

The Stage JMP instruction we have used deactivates the stage in which the instruction occurs, while activating the stage in the JMP instruction. Refer to the state transition shown below. When contact X0 energizes, the state transition from S0 to S1 occurs. The two stage examples shown below are equivalent. So, the Stage Jump instruction is equal to a Stage Reset of the current stage, plus a Stage Set instruction for the stage to which we want to transition. X0

S1

SG S0

SG S0

Equivalent

S1

X0

S0

X0

JMP

RST S1 SET

Please Read Carefully -- The jump instruction is easily misunderstood. The “jump” does not occur immediately like a GOTO or GOSUB program control instruction when executed. Here’s how it works: S The jump instruction resets the stage bit of the stage in which it occurs. All rungs in the stage still finish executing during the current scan, even if there are other rungs in the stage below the jump instruction! S The reset will be in effect on the following scan, so the stage that executed the jump instruction previously will be inactive and bypassed. S The stage bit of the stage named in the Jump instruction will be set immediately, so the stage will be executed on its next occurrence. In the left program shown below, stage S1 executes during the same scan as the JMP S1 occurs in S0. In the example on the right, Stage S1 executes on the next scan after the JMP S1 executes, because stage S1 is located above stage S0. SG S0

Executes on next scan after Jmp

SG S1 X0

S1

S1

JMP

Executes on same scan as Jmp

SG S1 S1

Y0 OUT

Y0 OUT

SG S0 X0

S1 JMP

NOTE: Assume we start with Stage 0 active and Stage 1 inactive for both examples.

DL405 User Manual, 4th Edition

RLL PLUS Stage Programming

S0

Page 406

7--8

RLL PLUS Stage Programming

Stage Program Example: Toggle On/Off Lamp Controller

RLL PLUS Stage Programming

A 4--State Process

In the process shown to the right, we use an ordinary momentary pushbutton to control a light bulb. The ladder program will latch the switch input, so that we will push and release to turn on the light, push and release again to turn it off (sometimes called toggle function). Sure, we could just buy a mechanical switch with the alternate on/off action built in... However, this example is educational and also fun! Next we draw the state transition diagram. A typical first approach is to use X0 for both transitions (like the example shown to the right). However, this is incorrect (please keep reading).

Inputs Toggle

X0

Outputs Ladder Program

Powerup

Y0

X0

OFF

ON X0

Output equation: Y0 = ON

Note that this example differs from the motor example, because now we have just one pushbutton. When we press the pushbutton, both transition conditions are met. We would just transition around the state diagram at top speed. If implemented in Stage, this solution would flash the light on or off each scan (obviously undesirable)! The solution is to make the push and the release of the pushbutton separate events. Refer to the new state transition diagram below. At powerup we enter the OFF state. When switch X0 is pressed, we enter the Press-ON state. When it is released, we enter the ON state. Note that X0 with the bar above it denotes X0 NOT. Powerup

X0

Push--ON

X0

OFF

ISG S0

Push--OFF

X0

JMP SG S1

DL405 User Manual, 4th Edition

Push--On State S2

X0

Output equation: Y0 = ON

When in the ON state, another push and release cycle similarly takes us back to the OFF state. Now we have two unique states (OFF and ON) used when the pushbutton is released, which is what was required to solve the control problem. The equivalent stage program is shown to the right. The desired powerup state is OFF, so we make S0 an initial stage (ISG). In the ON state, we add special relay contact SP1, which is always on. Note that even as our programs grow more complex, it is still easy to correlate the state transition diagram with the stage program!

S1

X0

ON

X0

OFF State

JMP SG S2

ON State SP1

Output Y0 OUT S3

X0

JMP SG S3

Push--Off State X0

S0 JMP

Page 407

RLL PLUS Stage Programming

7--9

Four Steps to Writing a Stage Program By now, you’ve probably noticed that we follow the same steps to solve each example problem. The steps will probably come to you automatically if you work through all the examples in this chapter. It’s helpful to have a checklist to guide us through the problem solving. The following steps summarize the stage program design procedure:

1. Write a Word Description of the application.

2. Draw the Block Diagram. Inputs represent all the information the process needs for decisions, and outputs connect to all devices controlled by the process. S Make lists of inputs and outputs for the process. S Assign I/O point numbers (X and Y) to physical inputs and outputs.

3. Draw the State Transition Diagram. The state transition diagram describes the central function of the block diagram, reading inputs and generating outputs. S Identify and name the states of the process. S Identify the event(s) required for each transition between states. S Ensure the process has a way to re-start itself, or is cyclical. S Choose the powerup state for your process. S Write the output equations.

4. Write the Stage Program. Translate the state transition diagram into a stage program. S Make each state a stage. Remember to number stages in octal. Up to 384 total stages are available in the DL430 CPU, numbered 0 to 577 octal. Up to 1024 total stages are available in the DL440/DL450 CPUs, numbered 0 to 1777 in octal. S Put transition logic inside the stage which originates each transition (the stage each arrow points away from). S Use an initial stage (ISG) for any states that must be active at powerup. S Place the outputs or actions in the appropriate stages. You’ll notice that Steps 1 through 3 just prepare us to write the stage program in Step 4. However, the program virtually writes itself because of the preparation beforehand. Soon you’ll be able to start with a word description of an application and create a stage program in one easy session!

DL405 User Manual, 4th Edition

RLL PLUS Stage Programming

Describe all functions of the process in your own words. Start by listing what happens first, then next, etc. If you find there are too many things happening at once, try dividing the problem into more than one process. Remember, you can still have the processes communicate with each other to coordinate their overall activity.

Page 408

7--10

RLL PLUS Stage Programming

Stage Program Example: A Garage Door Opener

RLL PLUS Stage Programming

Garage Door Opener Example

In this next stage programming example we’ll create a garage door opener controller. Hopefully most readers are familiar with this application, and we can have fun besides! The first step we must take is to describe how the door opener works. We will start by achieving the basic operation, waiting to add extra features later (stage programs are very easy to modify). Our garage door controller has a motor which raises or lowers the door on command. The garage owner pushes and releases a momentary pushbutton once to raise the door. After the door is up, another push-release cycle will lower the door. In order to identify the inputs and outputs of the system, it’s sometimes helpful to sketch its main components, as shown in the door side view to the right. The door has an up limit and a down limit switch. Each limit switch closes only when the door has reached the end of travel in the corresponding direction. In the middle of travel, neither limit switch is closed. The motor has two command inputs: raise and lower. When neither input is active, the motor is stopped. The door command is just a simple pushbutton. Whether wall-mounted as shown, or a radio-remote control, all door control commands logically OR together as one pair of switch contacts.

Draw the Block Diagram

Up limit switch

Door Command Down limit switch

The block diagram of the controller is Inputs shown to the right. Input X0 is from the pushbutton door control. Input X1 Toggle X0 energizes when the door reaches the full up position. Input X2 energizes when the Up limit door reaches the full down position. When X1 the door is positioned between fully up or down, both limit switches are open. Down limit The controller has two outputs to drive the X2 motor. Y1 is the up (raise the door) command, and Y2 is the down (lower the door) command.

DL405 User Manual, 4th Edition

Raise Lower

Motor

Outputs

To motor: Ladder Program Y1

Raise

Y2

Lower