The text of a manual · part 48 of 68
DL405 User Manual: Chapter 7: RLLPLUS Stage Programming, pages 419 to 428
Pages 419 to 428 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 419
RLL PLUS Stage Programming
7--21
Managing Large Programs
430 440 450
Block 0
Block 1
Block 2
Stages outside blocks:
A program with 20 or more stages may be considered large enough to use block grouping (however, their use is not mandatory). When used, the number of stage blocks should probably be two or higher, because the use of one block provides a negligible advantage. A block of stages is separated from other ladder logic with special beginning and ending instructions. In the figure to the BLK Block Instruction C0 right, the BLK instruction at the top marks the start of the stage block. At the bottom, the Block End (BEND) marks the end of SG the block. The stages in between these S0 boundary markers (S0 and S1 in this case) All other rungs in stage... and their associated rungs make up the block. SG Note that the block instruction has a S1 reference value field (set to “C0” in the All other rungs in stage... example). The block instruction borrows or uses a control relay contact number, so Block End that other parts of the program can control Instruction BEND the block. Any control relay number (such as C0) used in a BLK instruction is not available for use as a control relay. Note that the stages within a block must be regular stages (SG) or convergence stages (CV). So, they cannot be initial stages. The numbering of stages inside stage blocks can be in any order, and is completely independent from the numbering of the blocks.
DL405 User Manual, 4th Edition
RLL PLUS Stage Programming
Stage Blocks (BLK, BEND) X
A stage may contain a lot of ladder rungs, or just one or two program rungs. For most applications, good program design will ensure the average number of rungs per stage will be small. However, large application programs will still create a large number of stages. We introduce a new construct which will help us organize related stages into groups called blocks. So, program organization is the main benefit of the use of stage blocks. A block is a section of ladder program which contains stages. In the figure below, each block has its own reference number. Just like stages, a stage block may be active or inactive. Stages inside a block are not limited in how they may transition from one to another. Note that the use of stage blocks does not require each stage in a program to reside inside a block, shown below by the “stages outside blocks”.
Page 420
7--22
RLL PLUS Stage Programming
Block Call (BCALL) X
RLL PLUS Stage Programming
430 440 450
The purpose of the Block Call instruction is to activate a stage block. At powerup or upon Program-to-Run mode transitions, all stage blocks and the stages within them are inactive. Shown in the figure below, the Block Call instruction is a type of output coil. When the X0 contact is closed, the BCALL will cause the stage block referenced in the instruction (C0) to become active. When the BCALL is turned off, the corresponding stage block and the stages within it become inactive. We must avoid confusing block call operation with how a “subroutine call” works. After a BCALL coil executes, program execution continues with the next program rung. Whenever program execution arrives at the ladder location of the stage block named in the BCALL, then logic within the block executes because the block is now active. Similarly, do not classify the BCALL as type of state transition (is not a JMP). Block C0 X0
C0 BCALL
Activate
(next rung)
When a stage block becomes active, the first stage in the block automatically becomes active on the same scan. The “first” stage in a block is the one located immediately under the block (BLK) instruction in the ladder program. So, that stage plays a similar role to the initial type stage we discussed earlier. The Block Call instruction may be used in several contexts. Obviously, the first execution of a BCALL must occur outside a stage block, since stage blocks are initially inactive. Still, the BCALL may occur on an ordinary ladder rung, or it may occur within an active stage as shown below. Note that either turning off the BCALL or turning off the stage containing the BCALL will deactivate the corresponding stage block. You may also control a stage block with a BCALL in another stage block. Stage Block
SG S0 X0
C0 BCALL
All other rungs in stage... SG S11
NOTE: Stage Block may come before or after the location of the BCALL instruction in the program.
BLK C0 SG S10
All rungs in stage... SG S11
All other rungs in stage... BEND
The BCALL may be used in many ways or contexts, so it can be difficult to find the best usage. Just remember that the purpose of stage blocks is to help you organize the application problem by grouping related stages together. Remember that initial stages must exist outside stage blocks.
DL405 User Manual, 4th Edition
Page 421
RLL PLUS Stage Programming
7--23
RLL PLUS Instructions Stage (SG)
430 440 450
The Stage instructions are used to create structured RLL PLUS programs. Stages are program segments which can be activated by transitional logic, a jump or a set stage that is executed from an active stage. Stages are deactivated one scan after transitional logic, a jump, or a reset stage instruction is executed.
Stage
S aaa
DL430 Range
DL440 Range aaa aaa aaa
0--577
0--1777
0--1777
S
DL450 Range
The following example is a simple RLL PLUS program. This program utilizes the initial stage, stage, and jump instruction to create a structured program. DirectSOFT Display
Handheld Programmer Keystrokes ISG
ISG
S(SG)
0
STR
X(IN)
0
OUT
Y(OUT)
1
STR
X(IN)
1
SET
S(SG)
2
STR
X(IN)
5
S2
JMP
S(SG)
1
SET
SG
S(SG)
1
S0
X0
Y10 OUT
X1
X5
SG
S1
STR
X(IN)
2
JMP
OUT
Y(OUT)
1
SG
S(SG)
2
STR
X(IN)
6
OUT
Y(OUT)
1
S1
X2
Y11 OUT
SG
STR
X(IN)
7
AND
S(SG)
1
JMP
S(SG)
0
0
1
2
S2
X6
Y12 OUT
X7
S1
S0 JMP
DL405 User Manual, 4th Edition
RLL PLUS Stage Programming
Operand Data Type
SG
Page 422
7--24
RLL PLUS Stage Programming
Initial Stage (ISG)
RLL PLUS Stage Programming
430 440 450
The Initial Stage instruction is normally used as the first segment of an RLL PLUS program. Initial stages will be active when the CPU enters the run mode allowing for a starting point in the program. Initial Stages are also activated by transitional logic, a jump or a set stage executed from an active stage. Initial Stages are deactivated one scan after transitional logic, a jump, or a reset stage instruction is executed. Multiple Initial Stages are allowed in a program. Operand Data Type
Stage
S
ISG
S aaa
DL430 Range
DL440 Range aaa aaa
DL450 Range aaa
0--577
0--1777
0--1777
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. Jump (JMP)
430 440 450
The Jump instruction allows the program to transition from an active stage which contains the jump instruction to another which stage is specified in the instruction. The jump will occur when the input logic is true. The active stage that contains the Jump will be deactivated 1 scan after the Jump instruction is executed. Operand Data Type
Stage
Not Jump (NJMP)
430 440 450
S
S aaa JMP
DL430 Range
DL440 Range aaa aaa aaa
0--577
0--1777
0--1777
The Not Jump instruction allows the program to transition from an active stage which contains the jump instruction to another which is specified in the instruction. The jump will occur when the input logic is off. The active stage that contains the Not Jump will be deactivated 1 scan after the Not Jump instruction is executed. Operand Data Type
Stage
DL405 User Manual, 4th Edition
S
DL450 Range
S aaa NJMP
DL430 Range
DL440 Range aaa aaa
DL450 Range aaa
0--577
0--1777
0--1777
Page 423
RLL PLUS Stage Programming
7--25
In the following example, when the CPU begins program execution only ISG 0 will be active. When X1 is on, the program execution will jump from Initial Stage 0 to Stage 1. In Stage 1, if X2 is on, output Y5 will be turned on. If X7 is on, program execution will jump from Stage 1 to Stage 2. If X7 is off, program execution will jump from Stage 1 to Stage 3. DirectSOFT Display
ISG
Handheld Programmer Keystrokes S(SG)
0
X(IN)
1
JMP
S(SG)
1
S1
SG
S(SG)
1
JMP
STR
X(IN)
2
OUT
Y(OUT)
5
STR
X(IN)
7
JMP
S(SG)
2
NOT
JMP
S(SG)
S0
X1
SG
S1
X2
X7
Y5
3
OUT S2 JMP S3 NJMP
Converge Stage (CV) and Converge Jump (CVJMP) X 430 440 450
The Converge Stage instruction is used to group certain stages together by defining them as Converge Stages. When all of the Converge Stages within a group become active, the CVJMP instruction (and any additional logic in the final CV stage) will be executed. All preceding CV stages must be active before the final CV stage logic can be executed. All Converge Stages are deactivated one scan after the CVJMP instruction is executed. Additional logic instructions are only allowed following the last Converge Stage instruction and before the CVJMP instruction. Multiple CVJUMP instructions are allowed. Converge Stages must be programmed in the main body of the application program. This means they cannot be programmed in Subroutines or Interrupt Routines. Operand Data Type
CV S aaa
S aaa CVJMP
DL440 Range aaa
Stage
S
0--1777
DL405 User Manual, 4th Edition
RLL PLUS Stage Programming
ISG STR
Page 424
7--26
RLL PLUS Stage Programming In the following example, when Converge Stages S10 and S11 are both active the CVJMP instruction will be executed when X4 is on. The CVJMP will deactivate S10 and S11, and activate S20. Then, if X5 is on, the program execution will jump back to the initial stage, S0. DirectSOFT Display
RLL PLUS Stage Programming
ISG
Handheld Programmer Keystrokes ISG
S(SG)
0
STR
X(IN)
0
OUT
Y(OUT)
0
STR
X(IN)
1
Y0
JMP
S(SG)
1
OUT
JMP
S(SG)
1
SG
S(SG)
1
STR
X(IN)
2
JMP
S(SG)
1
1
SHFT
C
V
SHFT
S(SG)
1
0
SHFT
C
V
SHFT
S(SG)
1
1
STR
X(IN)
3
JMP
S(SG)
2
S0
X0
X1
S1 JMP S10 JMP
SG
S1
X2
CV
CV
Y(OUT)
3
STR
X(IN)
4
JMP
SHFT
C
V
SHFT
SG
S(SG)
2
0
STR
X(IN)
5
JMP
S(SG)
0
S11
X4
SG
OUT
S11
S10
X3
Y3 OUT S20 CVJMP
S20
X5
DL405 User Manual, 4th Edition
0
S0 JMP
0
Page 425
RLL PLUS Stage Programming
7--27
The stage block instructions are used to activate a block of stages. The Block Call, Block, and Block End instructions must be used together. Block Call (BCALL) X 430 440 450
C aaa BCALL
Must Remain Active, The BCALL instruction actually controls all the stages between the BLK and the BEND instructions even after the stages inside the block have started executing. The BCALL must remain active or all the stages in the block will automatically be turned off. If either the BCALL instruction, or the stage that contains the BCALL instruction goes off, then the stages in the defined block will be turned off automatically. Activates First Block Stage, When the BCALL is executed it automatically activates the first stage following the BLK instructions. Operand Data Type
DL440 Range aaa
Control Relay
Block (BLK) X 430 440 450
C
0--1777
The Block instruction is a label which marks the beginning of a block of stages that can be activated as a group. A Stage instruction must immediately follow the Start Block instruction. Initial Stage instructions are not allowed in a block. The control relay (Caaa) specified in Block instruction must not be used as an output any where else in the program. Operand Data Type
BLK C aaa
DL440 Range aaa
Control Relay
Block End (BEND) X 430 440 450
C
0--1777
The Block End instruction is a label used with the Block instruction. It marks the end of a block of stages. There is no operand with this instruction.
BEND
DL405 User Manual, 4th Edition
RLL PLUS Stage Programming
The BCALL instruction is used to activate a stage block. There are several things you need to know about the BCALL instruction. Uses CR Numbers, The BCALL appears as an output coil, but does not actually refer to a Stage number as you might think. Instead, the block is identified with a Control Relay (Caaa). This control relay cannot be used as an output anywhere else in the program.
Page 426
7--28
RLL PLUS Stage Programming
RLL PLUS Stage Programming
In this example, the Block Call is executed when stage 1 is active and X6 is on. The Block Call then automatically activates stage S10, which immediately follows the Block instruction. This allows the stages between S10 and the Block End instruction to operate as programmed. If the BCALL instruction is turned off, or if the stage containing the BCALL instruction is turned off, then all stages between the BLK and BEND instructions are automatically turned off. If you examine S15, you’ll notice that X7 could reset Stage S1, which would disable the BCALL, thus resetting all stages within the block.
DirectSOFT Display
SG
SG
Y5
X2
OUT C0
X6
BLK SG
BCALL
C0 S10 Y6
X3
OUT BEND
Handheld Programmer Keystrokes
Stage View in DirectSOFT
S1
SG
SG
S(SG)
1
STR
X(IN)
2
OUT
Y(OUT)
5
STR
X(IN)
6
SHFT
B
C
A
L
L
SHFT
SHFT
B
L
K
SHFT
C(CR)
0
0
S15 S1
X7
SG
S(SG)
1
STR
X(IN)
3
OUT
Y(OUT)
6
SHFT
B
E
N
SG
S(SG)
1
5
STR
X(IN)
7
RST
S(SG)
1
C(CR)
RST
0
D
The Stage View option in DirectSOFT will let you view the ladder program as a flow chart. The figure below shows the symbol convention used in the diagrams. You may find the stage view useful as a tool to verify that your stage program has faithfully reproduced the logic of the state transition diagram you intend to realize. Stage
Transition Logic
Reference to a Stage
J
Jump
Output
S
Set Stage
R
Reset Stage
The following diagram is a typical stage view of a ladder program containing stages. Note the left-to-right direction of the flow chart. ISG S0
DL405 User Manual, 4th Edition
J
SG S1
J
SG S2
S
SG S4
J
SG S3
J
SG S5
Page 427
RLL PLUS Stage Programming
7--29
Questions and Answers about Stage Programming We include the following commonly-asked questions about Stage Programming as an aid to new students. All question topics are covered in more detail in this chapter.
Q. Isn’t a stage really just like a software subroutine? A. No, it is very different. A subroutine is called by a main program when needed, and executes just once before returning to the point from which it was called. A stage, however, is part of the main program. It represents a state of the process, so an active stage executes on every scan of the CPU until it becomes inactive. Q. What are Stage Bits? A. A stage bit is just a single bit in the CPU’s image register, representing the active/inactive status of the stage in real time. For example, the bit for Stage 0 is referenced as “S0”. If S0 = 0, then the ladder rungs in Stage 0 are bypassed (not executed) on each CPU scan. If S0 = 1, then the ladder rungs in Stage 0 are executed on each CPU scan. Stage bits, when used as contacts, allow one part of your program to monitor another part by detecting stage active/inactive status. Q. How does a stage become active? A. There are three ways: S If the Stage is an initial stage (ISG), it is automatically active at powerup. S Another stage can execute a Stage JMP instruction naming this stage, which makes it active upon its next occurrence in the program. S A program rung can execute a Set Stage Bit instruction (such as SET S0). Q. How does a stage become inactive? A. There are three ways: S Standard Stages (SG) are automatically inactive at powerup. S A stage can execute a Stage JMP instruction, resetting its Stage Bit to 0. S Any rung in the program can execute a Reset Stage Bit instruction (such as RST S0). Q. What about the power flow technique of stage transitions? A. The power flow method of connecting adjacent stages (directly above or below in the program) actually is the same as the Stage Jump instruction executed in the stage above, naming the stage below. Power flow transitions are more difficult to edit in DirectSOFT, we list them separately from two preceding questions.
DL405 User Manual, 4th Edition
RLL PLUS Stage Programming
Q. What does stage programming do that I can’t do with standard RLL programs? A. Stages allow you to identify all the states of your process before you begin programming. This approach is more organized, because you divide a ladder program into sections. As stages, these program sections are active only when they are actually needed by the process. Most processes can be organized into a sequence of stages, connected by event-based transitions.
Page 428
7--30
RLL PLUS Stage Programming
RLL PLUS Stage Programming
Q. Can I have a stage which is active for only one scan? A. Yes, but this is not the intended use for a stage. Instead, just make a ladder rung active for 1 scan by including a stage Jump instruction at the bottom of the rung. Then the ladder will execute on the last scan before its stage jumps to a new one. Q. Isn’t a Stage JMP just like a regular GOTO instruction used in software? A. No, it is very different. A GOTO instruction sends the program execution immediately to the code location named by the GOTO. A Stage JMP simply resets the Stage Bit of the current stage, while setting the Stage Bit of the stage named in the JMP instruction. Stage bits are 0 or 1, determining the inactive/active status of the corresponding stages. A stage JMP has the following results: S When the JMP is executed, the remainder of the current stage’s rungs are executed, even if they reside past(under) the JMP instruction. On the following scan, that stage is not executed, because it is inactive. S The Stage named in the Stage JMP instruction will be executed upon its next occurrence. If located past (under) the current stage, it will be executed on the same scan. If located before (above) the current stage, it will be executed on the following scan. Q. How can I know when to use stage JMP, versus a Set Stage Bit or Reset Stage Bit? A. These instructions are used according to the state diagram topology you have derived: S Use a Stage JMP instruction for a state transition... moving from one state to another. S Use a Set Stage Bit instruction when the current state is spawning a new parallel state or stage sequence, or when a supervisory state is starting a state sequence under its command. S Use a Reset Stage Bit instruction when the current state is the last state in a sequence and its task is complete, or when a supervisory state is ending a state sequence under its command. Q. What is an initial stage, and when do I use it? A. An initial stage (ISG) is automatically active at powerup. Afterwards, it works just like any other stage. You can have multiple initial stages, if required. Use an initial stage for ladder that must always be active, or as a starting point. Q. Can I place program ladder rungs outside of the stages, so they are always on? A. It is possible, but it’s not good software design practice. Place ladder that must always be active in an initial stage, and do not reset that stage or use a Stage JMP instruction inside it. It can start other stage sequences at the proper time by setting the appropriate Stage Bit(s). Q. Can I have more than one active stage at a time? A. Yes, and this is a normal occurrence for many programs. However, it is important to organize your application into separate processes, each made up of stages. And a good process design will be mostly sequential, with only one stage on at a time. However, all the processes in the program may be active simultaneously.
DL405 User Manual, 4th Edition