The text of a manual · part 21 of 36
DL305 User Manual, pages 197 to 206
Pages 197 to 206 of 356
The original document is the PDF (3.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 GE DL330 / D3-330, Fanuc DL330 / D3-330 and GE Fanuc DL330 / D3-330
Page 197
9–11 Programming Basics
Changing the Accumulator Data
Instructions that change or manipulate data in some way also use the accumulator. The result of the change resides in the accumulator. The original data that was being changed is cleared from the accumulator. In the following example, when input 000 is on the value in R000 and R010 is loaded into the accumulator using the Data Store 5 (F55) instruction. The bit pattern in the accumulator is shifted to the left 4 bit positions using the Shift Left (F80) instruction. Notice how the result resides in the accumulator. The value in the accumulator is copied to data registers R404 and R405 using the Data Out (F60) instruction. DirectSOFT Display 000
R 010
R 000
6
3
9
5
DSTR5 (F55) R 000 Load the value in registers R0 and R10 into the accumulator 7
6
0
1
I/O Points 100-107 5 4 3 2 1 0 1
0
1
0
Acc.
1
S S
Shifted out of accumulator
SHFL (F80) K4
0
7
6
0
0
I/O Points 000-007 5 4 3 2 1 0 1
1
0
1
0
1
S S
15 14 13 12 11 10 9
8
7
6 5
4 3
2
1
0
1
1
0
1
1
0
0
0
0
0
1
0
0
1
0
0
Shift the value in the accumulator 4 bits to the left 776 will be ON after the shift 777 will be OFF after the shift
9
DOUT (F60) R 404 Copy the value in the accumulator to registers R404 and R405
3
R 405
5
0
R 404
776 Shifted a “1” out of Accumulator 777
Programming Basics
Accumulator equals zero after shift
Page 198
9–12 Programming Basics
Accumulator Operations
The following table lists several instructions that utilize the accumulator. Not all instructions allow you to use all the different memory types. Chapters 11 & 12 provide details on these instructions. Memory Areas
Category
Data Load
Programming Basics
4-digit BCD Const.
Shift Register Coils
Description
I/O
CRs
DSTR (F50)
Load a 4-digit constant or a 2-bytes of register data into the accumulator
DSTR 1 (F51)
Load 1-byte of register data into the accumulator
DSTR 2 (F52)
Load the upper 4 bits of a register into the lower 4 bits of the accumulator
DSTR 3 (F53)
Load the lower 4 bits of a register into the upper 4 bits of the accumulator
DSTR 5 (F55)
Load the digital values of 16 I/O points (2 bytes) into the accumulator
DOUT (F60)
Write the accumulator to 2 sequential registers
DOUT 1 (F61)
Write the lower byte of the accumulator to a register
DOUT 2 (F62)
Write the lower 4 bits of the accumulator to the upper 4 bits of a register
DOUT 3 (F63)
Write the lower 4 bits of the accumulator to the lower 4 bits of a register
DOUT 5 (F65)
Write the contents of the accumulator to a 16-point output module (2 bytes)
CMP (F70)
Compare a 2-byte BCD reference or a 4-digit BCD constant to the accumulator
ADD (F71)
Add a 2-byte BCD reference or a 4-digit BCD constant to the accumulator
SUBTRACT (F72)
Subtract a 2-byte BCD reference or a 4-digit BCD constant from the accumulator
MULTIPLY (F73)
Multiply a 2-byte BCD reference or a 4-digit BCD constant by the value in the accumulator
DIVIDE (F74)
Divide the accumulator by a 2-byte BCD reference or a 4-digit BCD constant
Mnemonic
Data Out
Math
Current Values
Data Register, Memory Type available for use with the instruction X, Not available
Page 199
9–13 Programming Basics
Memory Areas
Category
Bit Manipulation
Data Conversion
Fault Detection
Current Values
4-digit BCD Const.
Shift Register Coils
Description
I/O
CRs
Data Register
DAND (F75)
Performs a bit “AND” on a 2-byte reference or a 4-digit BCD constant and the bits in the accumulator
DOR (F76)
Performs a bit “OR” on a 2-byte reference or a 4-digit BCD constant and the bits in the accumulator
SHIFT RIGHT (F80)
Shifts the contents of the accumulator to the right a specified number of times. 1 – 15 bits can be shifted.
SHIFT LEFT (F81)
Shifts the contents of the accumulator to the left a specified number of times. 1 – 15 bits can be shifted.
DECODE (F82)
Decodes the first 4 bits of the accumulator into a decimal number.
ENCODE (F83)
Encodes an accumulator bit into a 4-bit code that represents the decimal number (0–15).
INV (F84)
Logically inverts the contents of the accumulator (1 to 0, 0 to 1).
BCD–BIN (F85)
Converts the accumulator value from BCD to Binary
BIN–BCD (F86)
Converts the accumulator value from Binary to BCD
FAULT (F20)
Sends a 4-digit BCD number, from a 2-byte reference or a constant, to the programmer display
Mnemonic, Memory Type available for use with the instruction X, Not available Programming Basics
Page 200
Page 201
RLL PLUS Programming Basics In This Chapter. . . .
110
Ċ 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 202
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.
Page 203
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
Continuous One Cycle 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
RLLPLUS Programming Basics
Step 7
Page 204
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.
Page 205
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. S
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
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
S1 JMP
RLLPLUS Programming Basics
S
Only executes logic in stages that are active
Page 206
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
SG S010
SG S020
RLLPLUS Programming Basics
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
S1 JMP
000 SG
Check for a part
S001
Part Present
S2 JMP
001 Part Present
The section on Designing an RLL PLUS Program at the end of this chapter provides guidelines for assigning numbers to the stage instructions.
SG S002
Skip Numbers if Necessary
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
001
S5 JMP