The text of a manual · part 25 of 41
DL305 User Manual: Chapter 10: RLLPLUS Programming Basics, pages 202 to 211
Pages 202 to 211 of 357, from DL305 User Manual
The original document is the PDF (3.4 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 PLC Direct D3-08TD1, PLC Direct D3-16NA, Koyo D3-08TD1 and Koyo D3-16NA
Page 202
RLL PLUS Programming Basics
110
In This Chapter. . . ., Introduction, An Example Machine, An RLL Solution, An RLL PLUS Solution, Stage Instruction Execution, Activating Stages, Using Outputs in Stages, Using Timers and Counters in Stages, Using Data Instructions in Stages, Using Comparative Contacts in Stages, Parallel Branching Concepts, Unusual Operations in Stages, Two Ways to View RLL PLUS Programs, Designing a Program Using RLL PLUS Instructions
Page 203
10--2
RLL PLUS Programming Basics
Introduction If you’ve ever been around some really accomplished RLL programmers you have probably been amazed at how easily they seem to be able to create programs of incredible complexity. Well, not everyone has years of experience in programming PLCs. Because of this the DL330P CPU has RLL PLUS instructions that make it considerably easier to design and create programming solutions. These instructions are especially useful to those of you who aren’t that familiar with the interlocking concepts commonly used in RLL programs. You can still use the normal instructions you’ve already seen, plus you only have to become familiar with a few new instructions that help you organize your program into manageable pieces. This programming method is similar to Sequential Function Chart programming and literally allows you to design a flowchart of the program operation sequence and load it into the CPU! You can expect to see several benefits by using this method. S Considerably reduced program design time. We’ve seen many, many cases where these few instructions have cut program design time by well over 50%. S Shorter, more simple programs. Later in this chapter we’ll show you why your programs sometimes end up being a lot larger than you first anticipated. The RLL PLUS instructions can help make your programs simple for everyone to understand. S Easier program troubleshooting. How many times have you tried to troubleshoot or modify a program that was written by someone else? If you’ve done this very often you know it’s not an easy task. This chapter will show you a few instructions that will also help with this problem as well. The following paragraphs discuss several RLL PLUS programming concepts. We’ll use a simple example to show you how to use the various types of instructions. Also, we’ll show you the equivalent program without RLL PLUS instructions to give you an idea of the differences between the two approaches.
RLLPLUS Programming Basics
NOTE: The DL330P has several instructions that do not operate quite the same as the equivalent instructions in the DL330 or DL340. If you want to take advantage of the benefits associated with the RLL PLUS instructions, make sure you also take time to review Chapter 12. This chapter discusses the instructions that are unique or different with the DL330P CPU.
DL305 User Manual, Rev. D
Page 204
10--3
RLL PLUS Programming Basics
An Example Machine Machine Operation
Most any application can be described as a sequence of events. The PLC program merely makes sure the events are completed in a specific order. Not only does the program control normal operation, but it also has to allow for machine failures and emergency conditions. Consider a simple example. 1. The operator presses the start switch. 2. The machine checks for a part. If the part is present, the process continues. If not, the conveyor moves until a part is present. 3. The part is locked in place with a clamp. 4. The press stamps the part. 5. The clamp is unlocked and the finished piece is moved out of the press. 6. The process stops if the machine is in one-cycle mode, or the process continues if automatic mode is selected.
On/Off Switch Press Arm Part Part Detection Sensor
Clamp
Machine Flowchart The following diagram provides a flowchart of this operations sequence. The flowchart breaks the program into logical steps Wait for Start
Check for Part
Lock the clamp
Press the Part
Unlock clamp
Move Conveyor
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
One Cycle
Continuous
Check Mode Inputs Start Switch Part Present Part Locked Part Unlocked Lower Limit Upper Limit Conveyor Indexed One-Cycle Switch
Outputs 000 001 002 003 004 005 006 007
Clamp Press Conveyor
020 021 022
DL305 User Manual, Rev. D
RLLPLUS Programming Basics
Step 7
Page 205
10--4
RLL PLUS Programming Basics
An RLL Solution
RLLPLUS Programming Basics
Why is RLL so popular? Simple. Before the PLC arrived control problems were generally solved with hardwired relays and switches. About 30 years ago people started experimenting with a way to make quick and easy changes without changing the actual panel wiring. Thus, the PLC was born. Since the people developing and using this new technology were familiar with the relay and switch solution, it made sense to have this new technology emulate something that was familiar to them. That’s why RLL programs emulate a relay panel solution. When you supply power to a relay panel the combination of contact and coil status determines what actions take place. Since the RLL program emulates the relay panel solution, the entire program is scanned left-to-right, top-to-bottom. The program executes the operations sequence when a certain combination of contacts are activated. This process is known as interlocking. Since many PLCs do not have instructions to help manage the operations sequence, the programmer has to make sure the program carries out the correct sequence by adding the required interlocks. One great thing about the RLL solution is the individual rungs are easy to understand. By examining the contacts you can easily determine if the output will be on or off.
Executes all rungs Left to Right, Top to bottom Run
1 Cycle
Stop
RUN OUT
160
163
011
160
Start 000 RUN
Part Present
160
001
MCS
Part Unlocked
Release Clamp
003
162
Clamp OUT 020
Clamp 020 Press
Lower Limit
Index Conveyor
Press Complete OUT
004
006
161
021 Press Complete 161 Part Locked
Lower Limit
Press Complete
002
004
161
Press OUT 021
Press 021 Press Complete
Upper Limit
Release Clamp OUT
161
005
162
MCR
Press Complete 161
Part Index Unlocked Conveyor
Run
003 Part Present
160
001
1 Cycle
Index Conveyor
007
006
006
Conveyor OUT 022
1 Cycle OUT 163
-- Interlock
Many accomplished RLL programmers use things such as Master Control Relays and Subroutines to reduce the amount of interlocking required. However, these instructions can sometimes make the program more difficult to understand. There are several things you should notice about our simple press program. S Most all rungs use some amount of interlocking. S The number of interlocks is usually proportional to the number of tasks in the operations sequence. S Most of the instructions are devoted to processing the interlocks. (Plus, since the program is larger, it takes more time to process.) S It usually requires several attempts until a program is designed that is not susceptible to inadvertent activation and deactivation. S The program can be difficult to debug if you do not have a considerable amount of RLL programming experience.
DL305 User Manual, Rev. D
Page 206
RLL PLUS Programming Basics
10--5
An RLL PLUS Solution The RLL PLUS instructions keep the simplicity of the contacts and coils while removing some of the problems associated with the enormous amount of interlocks. There are several RLL PLUS instructions, but the most often used are the Initial Stage (ISG), Stage (SG), and Jump (JMP) instructions. Here’s the example press program created using RLL PLUS instructions. There are two things you should notice. Control Relay interlocks are not required. S The program directly follows the flowchart of the press operation. How can this happen? Simple. The interlocks were added to the RLL program to keep the outputs from coming on at the improper time. This is because every rung of the RLL program was examined on every scan. The Stage instructions (and the logic between the Stage instruction and the next stage instruction) are not necessarily examined on every scan. Only stages that are on are examined. Each stage instruction has a status bit that is on when the stage is active, and off when the stage is inactive. On every scan the CPU examines which stage status bits are on and only examines the logic in those stages. If a stage is inactive, the CPU skips the logic between that stage and the next active stage. The following pages will talk about several different aspects of the CPU execution for the Stage Instructions. It will help to understand the pieces of an individual stage. Stage Nomenclature As we discuss the examples it will be necessary for you to understand the various pieces that can make up a program stage. S
S
S
Stages, a instruction that denotes a piece of the program Actions - an event in the program, such as an output, jump, or some other instruction. Transitions, the event that causes the program to move to the next stage.
ISG
Wait for start
S000 Start
S1 JMP
000 SG
Check for a part
S001
Part Present
S2 JMP
001 Part Present
S5 JMP
001 SG
Lock the clamp
S002
Part Locked
Clamp SET 020 S4 JMP
002 SG
Press the part
S003
Press Down 021 Lower Limit
S4 JMP
004 SG
Unlock the clamp
S004 Top Limit
Clamp RST 020
005 Part Unlocked
S5 JMP
003 SG
Index the conveyor
S005
Move Conveyor 022 Conveyor Moved
S6 JMP
006 SG
One cycle or automatic?
S006
One Cycle
S0 JMP
007 One Cycle 007
DL305 User Manual, Rev. D
S1 JMP
RLLPLUS Programming Basics
S
Only executes logic in stages that are active
Page 207
10--6
RLL PLUS Programming Basics
Stage Instruction Execution Stage Instruction Numbering
Stages are numbered in octal, so you can’t have any stages with the numbers 8 or 9 in them. Notice the stages skipped from 7 to 10 since the numbers 8 and 9 are not used. There are 128 (decimal) stages available in the DL330P CPU, numbered 0 through 177. Since each stage has a unique status bit, you cannot have stages with the same address number. For example, since the example program already has a Stage1, we wouldn’t want to use that number again. There’s another advantage to having a status bit for each stage. This allows you to skip stage numbers as necessary. This is a good practice to follow because it makes it easier to insert stages later without affecting the appearance of the program flow. The stage numbers do not necessarily have to be numbered sequentially, but it can be extremely helpful to use sequential numbers if you are working with large programs. Also, the stages do not have to be entered sequentially with the programming device. For example, you could have Stage 100 be the first entry in the program. This is not a good programming practice, but since the CPU looks at the active status bits to determine which stages to execute, it doesn’t care where the stages are physically located in the program.
Octal Numbering SG S007
SG S008
No Duplicate Numbers SG S001
SG S001
RLLPLUS Programming Basics
The section on Designing an RLL PLUS Program at the end of this chapter provides guidelines for assigning numbers to the stage instructions.
DL305 User Manual, Rev. D
SG S002
Skip Numbers if Necessary SG S010
SG S020
SG S030
Non-sequential Numbering SG S012
SG S001
SG S020
Only executes logic in stages that are active SG
Press the part
S003
Press Down 021 Lower Limit
S4 JMP
004 ISG
Wait for start
S000 Start
NOTE: Remember, machines do break. We recommend you use numbering that matches the machine flowchart. Also, we recommend you enter the program in the same order whenever possible. This will make troubleshooting much easier.
SG S010
S1 JMP
000 SG
Check for a part
S001
Part Present
S2 JMP
001 Part Present 001
S5 JMP
Page 208
RLL PLUS Programming Basics A Few Simple Rules for Execution
10--7
Since the CPU will only examine the logic in those stages that are active, it is important you understand how stages can be turned on and off. There are a few simple rules that dictate how this works. This may seem like quite a few things to remember, but it’s really pretty simple. We’ll show examples in the following pages that show how each of these rules apply to the program execution. 1. Only active stages are executed. If a stage is inactive, the CPU skips the logic between that stage and the next active stage. 2. You can turn stages on by the following methods. 2.a Initial Stages are automatically turned on when the CPU transitions from Program Mode to Run Mode. 2.b A stage can be turned on when the program “jumps” from stage to stage with the Jump (JMP) instruction. 2.c You can use the SET instruction to set a stage status bit just like you would SET an output. 2.d A stage can be turned on when the program has power flow between two stages that are tied together by a single transition element. 3. You can turn stages off by the following methods. 3.a An active stage is automatically turned off if the program jumps from the active stage to another stage. 3.b You can use the Reset (RST) instruction to turn off a stage just like you use Reset to turn off an output point. 3.c The current stage is automatically turned off if the program has power flow between the current stage and the next stage.
RLLPLUS Programming Basics
DL305 User Manual, Rev. D
Page 209
10--8
RLL PLUS Programming Basics
Activating Stages Using Initial Stages
Any initial stages (ISG instructions) are automatically turned on when the CPU goes from Program Mode to Run Mode. For example, when the CPU executing our example program enters Run Mode, the Initial Stage (ISG 000) will be turned on automatically. The other stages are off, so the CPU only scans the portion of the program associated with ISG 000. Since there’s only one rung in Stage 0, the CPU continually monitors the start switch. Nothing else will happen until the start switch is pressed.
Only executes logic in stages that are active ISG
Wait for start
S000 Start
S1 JMP
000 SG
Check for a part
S001
Part Present
S2 JMP
001 Part Present
S5 JMP
001
RLLPLUS Programming Basics
Although it is unusual, there may be times when you need more than one initial stage. There is nothing at all wrong with this. If your application has a need for more than one starting point, you can use more than one initial stage. For example, if you had three initial stages, then those three stages would all be active when the CPU entered the Run Mode.
DL305 User Manual, Rev. D
Page 210
RLL PLUS Programming Basics Using Jump Instructions
When the operator presses the start switch input 000 comes on. When 000 comes on the CPU executes the Jump instruction and “jumps” to Stage 1. Now the CPU only scans Stage 1. Stage 0 is no longer scanned after the program jumped to stage 1. This means the Jump instruction did two things. S It activated the destination stage. In this case, it activated stage 1. S It deactivated the stage it came from, which was stage 0 in this case. So, you can jump to a stage to turn it on, and when you jump from a stage it turns off.
10--9
Only executes logic in stages that are active ISG
Wait for start
S000 Start
S1 JMP
000 SG
Check for a part
S001
Part Present
S2 JMP
001 Part Present
S5 JMP
001 SG
Lock the clamp
S002
Part Locked
Clamp SET 020 S3 JMP
002
This example only shows an action that initiates a jump to one destination. You can use several jumps ORed together if necessary. Examples of this will be shown later. Only executes logic in stages that are active There’s also another type of Jump instruction called a Not Jump. This ISG Wait for start S000 instruction only works if the input conditions are not true, whereas the Start S1 JMP regular JMP instruction only works if the 000 input conditions are true. SG Check for a part S001 In the previous example we examined a Part single contact to determine which part of Present S2 JMP the program to jump to next. If the part is 001 present (001 closed), the program jumps S5 NJMP to Stage 2. If a part is not present (001 open), the program jumped to Stage 5. SG We could have used a single contact and Lock the clamp S002 the NJMP instruction. Clamp The program example to the right shows SET 020 Part how the NJMP instruction would be used Locked S3 JMP in this situation. Notice there is one less 002 instruction required in this example compared to the previous one.
DL305 User Manual, Rev. D
RLLPLUS Programming Basics
NOTE: We strongly recommend you avoid using the NJMP instruction. This is because program debugging can become more difficult, especially for those who are not so familiar with structured programming concepts.
Page 211
10--10
RLL PLUS Programming Basics
Using Set Instructions with Stages
When you examine the instruction set more carefully you’ll notice the DL330P CPU offers a Set (SET) instruction that works similarly to a latching operation. For example, you could use a SET instruction to latch an output point. The output point can then be unlatched with the Reset (RST) instruction. You can also use a SET instruction to turn on a stage. To show how this works, we’re going to add a stage to the program. You may have noticed the original flowchart did not contain a stop switch. Well, we don’t want to make these little widgets forever, so we’re adding Stage 150, which monitors for a stop switch. (This is also a good example of how you can skip stage numbers.) Notice we added a SET instruction in the first stage. Now when the start switch is pressed, two stages will be activated. The CPU examines Stage 1, which monitors for a part, and it also examines Stage 150, which monitors the stop switch.
Only executes logic in stages that are active ISG
Wait for start
S000 Start
S0 JMP
000
SG
S150 SET
Check for a part
S001
Part Present
S2 JMP
001 Part Present
S5 JMP
001 SG
Lock the clamp
S002
Part Locked
Clamp SET 020 S3 JMP
002
SG
Monitor for stop
S150 Stop
020 -- 022 RST
010 S0 -- S6 RST
RLLPLUS Programming Basics
S0 JMP
We did not absolutely have to use a SET instruction in the example. We could have used a Jump, since you can jump to more than one stage. We just used a SET to show how it works. If you examine Stage 150, you’ll notice we do three things when the stop switch is pressed. S The RST 020 -- 022 instruction makes sure all the outputs are turned off. (We’ll discuss this in more detail in the next section.) S The RST S0--S6 instruction resets (turns off) stages 0 through 6. We reset the entire range so that we guarantee we can stop the press no matter which stage is currently executing. Notice we reset stages that were not necessarily turned on with the SET instruction. The Reset (RST) instruction can be used to turn off stages, no matter how they were turned on. This is especially handy in larger, more complex programs. S The program jumps back to Stage 0 and starts over again. Note, just because Stage 0 is an initial stage does not mean it can only be active at a transition to Run Mode. You can return to an Initial Stage at any time. It’s just the CPU automatically activates Initial Stages at the Run Mode transition.
DL305 User Manual, Rev. D