The text of a manual · part 15 of 40
DL05 Micro PLC User Manual, Volume 1 of 2: Chapter 5: Standard RLL and Intelligent Box Instructions, pages 124 to 133
Pages 124 to 133 of 379, from DL05 Micro PLC User Manual, Volume 1 of 2
The original document is the PDF (5.8 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 D0-05AA
Page 124
STANDARD RLL AND INTELLIGENT BOX INSTRUCTIONS
CHAPTER
5
In This Chapter: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–2 Using Boolean Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–4 Boolean Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–9 Comparative Boolean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–25 Immediate Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–31 Timer, Counter and Shift Register Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–35 Accumulator/Stack Load and Output Data Instructions . . . . . . . . . . . . . . . . . . . . . . .5–48 Logical Instructions (Accumulator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–60 Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–68 Bit Operation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–82 Number Conversion Instructions (Accumulator) . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–87 Table Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–96 CPU Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–99 Program Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–101 Interrupt Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–108 Message Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–111 Intelligent I/O Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–118 Network Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–120 Intelligent Box (IBox) Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5-124
Page 125
Chapter 5: Standard RLL Instructions
1 Introduction DL05 Micro PLCs offer a wide variety of instructions to perform many different types of operations. This chapter shows you how to use each standard Relay Ladder Logic (RLL) 2 instruction. In addition to these instructions, you may also need to refer to the Drum instruction in Chapter 6, or the Stage programming instructions in Chapter 7. 3 There are two ways to quickly find the instruction you need. • If you know the instruction category (Boolean, Comparative Boolean, etc.) just use the title at the top of the page to find the pages that discuss the instructions in that category. 4 • If you know the individual instruction name, use the following table to find the page(s) that discusses the instruction. 5 Instruction Page Instruction Page 6 7 8 9 10 11 12 13 14 A B C D Accumulating Timer (TMRA)
5–38
Decode (DECO)
5–86
Accumulating Fast Timer (TMRAF)
5-38
Decrement (DEC)
5–76
Add (ADD)
5–68
Decrement Binary (DECB)
5–77
Add Binary (ADDB)
5–78
Disable Interrupts (DISI)
5–109
Add Double (ADDD)
5–69
Divide (DIV)
5–74
And (AND)
5–13
Divide Binary (DIVB)
5–81
And (AND)
5–30
Divide Double (DIVD)
5–75
And (AND)
5–60
Enable Interrupts (ENI)
5–108
And Bit-of-Word (ANDB)
5-14
Encode (ENCO)
5–85
And Double (ANDD)
5–61
End (END)
5–99
And If Equal (ANDE)
5–27
Exclusive Or (XOR)
5–64
And If Not Equal (ANDNE)
5–27
Exclusive Or Double (XORD)
5–65
And Immediate (ANDI)
5–32
Fault (FAULT)
5–111
And Negative Differential (ANDND)
5–21
For / Next (FOR) (NEXT)
5–101
And Not (ANDN)
5–13
Goto Subroutine (GTS) (SBR)
5–103
And Not (ANDN)
5–30
Gray Code (GRAY)
5–93
And Not Bit-of-Word (ANDNB)
5-14
HEX to ASCII (HTA)
5–91
And Not Immediate (ANDNI)
5–32
Increment (INC)
5–76
And Positive Differential (ANDPD)
5–21
Increment Binary (INCB)
5–77
And Store (AND STR)
5–15
Interrupt (INT)
5–108
ASCII Constant (ACON)
5–112
Interrupt Return (IRT)
5–108
ASCII to HEX (ATH)
5–90
Interrupt Return Conditional (IRTC)
5–108
Binary (BIN)
5–87
Invert (INV)
5–89
Binary Coded Decimal (BCD)
5–88
Load (LD)
5–53
Compare (CMP)
5–66
Load Address (LDA)
5–56
Compare Double (CMPD)
5–67
Load Double (LDD)
5–54
Counter (CNT)
5–41
Load Formatted (LDF)
5–55
Data Label (DLBL)
5–112
Load Label (LDLBL)
5–97
5–2
DL05 Micro PLC User Manual, 6th Edition, Rev. A
Page 126
Chapter 5: Standard RLL Instructions Instruction
Page
Instruction
Master Line Reset (MLR)
5–106
Reset Bit-of-Word (RSTB)
5-23
Master Line Set (MLS)
5–106
Reset Immediate (RSTI)
5–34
Move (MOV)
5–96
Reset Watch Dog Timer (RSTWT)
5–100
Move Memory Cartridge (MOVMC)
5–97
Set (SET)
5–22
Multiply (MUL)
5–72
Set Bit-of-Word (SETB)
5-23
Multiply Binary (MULB)
5–80
Set Immediate (SETI)
5–34
Multiply Double (MULD)
5–73
Shift Left (SHFL)
5–83
No Operation (NOP)
5–99
Shift Register (SR)
5–47
Not (NOT)
5–18
Shift Right (SHFR)
5–84
Numerical Constant (NCON)
5–112
Shuffle Digits (SFLDGT)
5–94
Or (OR)
5–11
Stage Counter (SGCNT)
5–43
Or (OR)
5–29
Stop (STOP)
5–99
Or (OR)
5–62
Store (STR)
5–9
Or Bit-of-Word (ORB)
5-12
Store (STR)
5-28
Or Double (ORD)
5–63
Store Bit-of-Word (STRB)
5-10
Or If Equal (ORE)
5–26
Store If Equal (STRE)
5–25
Or If Not Equal (ORNE)
5–26
Store If Not Equal (STRNE)
5–25
Or Immediate (ORI)
5–31
Store Immediate (STRI)
5–31
Or Negative Differential (ORND)
5–20
Store Negative Differential (STRND)
5–19
Or Not (ORN)
5–11
Store Not (STRN)
5–9
Or Not (ORN)
5–29
Store Not (STRN)
5-28
Or Not Bit-of-Word (ORNB)
5-12
Store Not Bit-of-Word (STRNB)
5-10
Or Not Immediate (ORNI)
5–31
Store Not Immediate (STRNI)
5–31
Or Out (OR OUT)
5–16
Store Positive Differential (STRPD)
5–19
Or Out Immediate (OROUTI)
5–33
Subroutine Return (RT)
5–103
Or Positive Differential (ORPD)
5–20
Subroutine Return Conditional (RTC)
5–103
Or Store (OR STR)
5–15
Subtract (SUB)
5–70
Out (OUT)
5–16
Subtract Binary (SUBB)
5–79
Out (OUT)
5–57
Subtract Double (SUBD)
5–71
Out Bit-of-Word (OUTB)
5-17
Sum (SUM)
5–81
Out Double (OUTD)
5–57
Timer (TMR) and Timer Fast (TMRF)
5–36
Out Formatted (OUTF)
5–58
Up Down Counter (UDC)
5–45
Out Immediate (OUTI)
5–33
Write to Intelligent Box I/O Module (WT)
5-119
Pause (PAUSE)
5–24
Write to Network (WX)
5–122
Pop (POP)
5–58
Positive Differential (PD)
5–18
Print Message (PRINT)
5–114
Read from Intelligent Box I/O Module (RD)
5-118
Read from Network (RX)
5–120
Reset (RST)
5–22
DL05 Micro PLC User Manual, 6th Edition, Rev. A
Page
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–3
Page 127
Chapter 5: Standard RLL - Boolean Instructions
Instructions 1 Using Boolean Do you ever wonder why so many PLC manufacturers always quote the scan time for a 1K Boolean program? Simple. Most all programs utilize many Boolean instructions. These are 2 typically very simple instructions designed to join input and output contacts in various series and parallel combinations. Our DirectSOFT 5 software is a similar program. It uses graphic symbols to develop a program; therefore, you don't necessarily have to know the instruction 3 mnemonics in order to develop your program. However, knowledge of mnemonics will be helpful, whenever it becomes necessary to troubleshoot a program using a handheld 4 programmer (HPP). Many of the instructions in this chapter are not program instructions used in DirectSOFT 5, 5 but are implied. In other words, they are not actually keyboard commands, however, they can be seen in a Mnemonic View of the program once the DirectSOFT 5 program has been developed and accepted (compiled). Each instruction listed in this chapter will have a small 6 chart to indicate how the instruction is used with DirectSOFT 5 and the HPP. 7 8 The following paragraphs show how these instructions are used to build simple ladder programs. 9 END Statement All DL05 programs require an END statement as the last instruction. This tells the CPU that this is the end of the program. Normally, any instructions placed after the END statement 10 will not be executed. There are exceptions to this such as interrupt routines, etc.. This chapter will discuss the instruction set in detail. 11 12 13 14 Simple Rungs You use a contact to start rungs that contain both contacts and coils. The boolean instruction that does this is called a Store or, STR instruction. The output point is represented by the A Output or, OUT instruction. The following example shows how to enter a single contact and a single output coil. B C D DS5 Implied
HPP
Used
X0
Y0
All programs must have an END statement
OUT
END
DirectSOFT5
DirectSOFT Example
X0
Handheld Mnemonics
Y0
OUT
END
5–4
DL05 Micro PLC User Manual, 6th Edition, Rev. A
STR X0 OUT Y0 END
Page 128
Chapter 5: Standard RLL - Boolean Instructions
Normally Closed Contact
1 2 3 4 5 Contacts in Series Use the AND instruction to join two or more contacts in series. The following example shows two contacts in series and a single output coil. The instructions used would be STR X0, AND 6 X1, followed by OUT Y0. 7 8 9 10 Midline Outputs Sometimes it is necessary to use midline outputs to get additional outputs that are conditional 11 on other contacts. The following example shows how you can use the AND instruction to continue a rung with more conditional outputs. 12 13 14 A B C D Normally closed contacts are also very common. This is accomplished with the Store Not or, STRN instruction. The following example shows a simple rung with a normally closed contact. DirectSOFT5 Direct SOFT32 Example
X0
Handheld Mnemonics
Y0
OUT
STRN X0 OUT Y0 END
END
DirectSOFT5 Direct SOFT32 Example
X0
Handheld Mnemonics
Y0
X1
OUT
STR X0 AND X1 OUT Y0 END
END
DirectSOFT5
Direct SOFT32 Example
X0
X1
Handheld Mnemonics
Y0
OUT Y1
X2
OUT
X3
STR X0 AND X1 OUT Y0 AND X2 OUT Y1 AND X3 OUT Y2 END
Y2
OUT
END
DL05 Micro PLC User Manual, 6th Edition, Rev. A
5–5
Page 129
Chapter 5: Standard RLL - Boolean Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Parallel Elements You also have to join contacts in parallel. The OR instruction allows you to do this. The following example shows two contacts in parallel and a single output coil. The instructions would be STR X0, OR X1, followed by OUT Y0. DirectSOFT 5 X0
Handheld Mnemonics Y0
X1
OUT X2
X3 END
STR X0 AND X1 STR X2 AND X3 ORSTR OUT Y0 END
Joining Series Branches in Parallel Quite often it is necessary to join several groups of series elements in parallel. The Or Store (ORSTR) instruction allows this operation. The following example shows a simple network consisting of series elements joined in parallel. DirectSOFT 5
Handheld Mnemonics
X0
Y0 OUT
X1
STR X0 OR X1 OUT Y0 END
END
Joining Parallel Branches in Series You can also join one or more parallel branches in series. The And Store (ANDSTR) instruction allows this operation. The following example shows a simple network with contact branches in series with parallel contacts. DirectSOFT 5 X0
Handheld Mnemonics
X1
Y0
STR X0 STR X1 OR X2 ANDSTR OUT Y0 END
OUT X2
END
Combination Networks You can combine the various types of series and parallel branches to solve most any application problem. The following example shows a simple combination network.
X0
X2
X5
Y0 OUT
X1
X3
X4
X6
END
5–6
DL05 Micro PLC User Manual, 6th Edition, Rev. A
Page 130
Chapter 5: Standard RLL - Boolean Instructions
Comparative Boolean
1 2 3 4 5 Boolean Stack There are limits to how many elements you can include in a rung. This is because the DL05 6 PLCs use an 8-level boolean stack to evaluate the various logic elements. The boolean stack is a temporary storage area that solves the logic for the rung. Each time the program encounters 7 a STR instruction, the instruction is placed on the top of the stack. Any other STR instructions already on the boolean stack are pushed down a level. The ANDSTR, and 8 ORSTR instructions combine levels of the boolean stack when they are encountered. An error will occur during program compilation if the CPU encounters a rung that uses more than the eight levels of the boolean stack. 9 The following example shows how the boolean stack is used to solve boolean logic. 10 11 12 13 14 A B C D Some PLC manufacturers make it really difficult to do a simple comparison of two numbers. Some of them require you to move the data all over the place before you can actually perform the comparison. The DL05 Micro PLCs provide Comparative Boolean instructions that allow you to quickly and easily solve this problem. The Comparative Boolean provides evaluation of two 4-digit values using boolean contacts. The valid Y3 evaluations are: equal to, not equal to, equal to or V1400 K1234 OUT greater than, and less than. In the following example when the value in V-memory location V1400 is equal to the constant value 1234, Y3 will energize.
X0
STR
STR
STR
ORSTR
X1
AND X4
Y0
OUT
X2
AND X3
X5
OR
Output
ANDSTR
STR X0
STR X1
STR X2
1
1
STR X1
1
2
2
STR X0
2
3
3
3
4
4
4
4
5
5
5
5
6
6
6
6
7
7
7
7
8
8
8
STR X0
AND X3
STR X2
STR X1 STR X0
1
X2 AND X3
2
STR X1
3
STR X0
8
ORSTR
AND X4
ORNOT X5
1
X1 or (X2 AND X3)
1
X4 AND {X1 or (X2 AND X3)}
1
2
STR X0
2
STR X0
2
3
3
. .
STR X0
3
. .
8
NOT X5 OR X4 AND {X1 OR (X2 AND X3)}
8
. .
8
ANDSTR 1
XO AND (NOT X5 or X4) AND {X1 or (X2 AND X3)}
2 3
. .
8
DL05 Micro PLC User Manual, 6th Edition, Rev. A
5–7
Page 131
Chapter 5: Standard RLL - Boolean Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Immediate Boolean The DL05 Micro PLCs can usually complete an operation cycle in a matter of milliseconds. However, in some applications you may not be able to wait a few milliseconds until the next I/O update occurs. The DL05 PLCs offer Immediate input and outputs which are special boolean instructions that allow reading directly from inputs and writing directly to outputs during the program execution portion of the CPU cycle. You may recall that this is normally done during the input or output update portion of the CPU cycle. The immediate instructions take longer to execute because the program execution is interrupted while the CPU reads or writes the I/O point. This function is not normally done until the read inputs or the write outputs portion of the CPU cycle. NOTE: Even though the immediate input instruction reads the most current status from the input point, it only uses the results to solve that one instruction. It does not use the new status to update the image register. Therefore, any regular instructions that follow will still use the image register values. Any immediate instructions that follow will access the I/O again to update the status. The immediate output instruction will write the status to the I/O and update the image register.
CPU Scan Read Inputs X11 OFF
... X2 X1 X0 ... ON OFF OFF Input Image Register
The CPU reads the inputs from the local base and stores the status in an input image register.
ON OFF
X1
Read Inputs from Specialty I/O
Solve the Application Program X0 I
Y0
Write Outputs
Immediate instruction does not use the input image register, but instead reads the status from the module immediately.
ON OFF
Write Outputs to Specialty I/O Diagnostics
5–8
X0
DL05 Micro PLC User Manual, 6th Edition, Rev. A
I/O Point X0 Changes X0 X1
Page 132
Chapter 5: Standard RLL - Boolean Instructions
Boolean Instructions Store (STR) DS5 Implied The Store instruction begins a new rung or an additional HPP
Used
Aaaa branch in a rung with a normally open contact. Status of the contact will be the same state as the associated image register point or memory location.
Store Not (STRN) DS5 Implied The Store Not instruction begins a new rung or an HPP
Used
Aaaa additional branch in a rung with a normally closed contact. Status of the contact will be opposite the state of the associated image register point or memory location. Operand Data Type
DL05 Range aaa
....................................A Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X Outputs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Y Control Relays . . . . . . . . . . . . . . . . . . . . . . . . . . C Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . S Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T Counter C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T Special Relay . . . . . . . . . . . . . . . . . . . . . . . . . . SP
0–377 0–377 0–777 0–377 0–177 0–177 0–777
In the following Store example, when input X1 is on, output Y2 will energize. DirectSOFT 5 Direct SOFT32 X1
Handheld Programmer Keystrokes Y2 OUT
$
B STR
GX OUT
1 C 2
ENT ENT
In the following Store Not example, when input X1 is off output Y2 will energize. DirectSOFT 5 Direct SOFT32 X1
Handheld Programmer Keystrokes Y2 OUT
SP STRN
B
GX OUT
C
1 2
ENT ENT
DL05 Micro PLC User Manual, 6th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–9
Page 133
Chapter 5: Standard RLL - Boolean Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Store Bit-of-Word (STRB) DS5 Implied The Store Bit-of-Word instruction begins a new rung or an HPP
Used additional branch in a rung with a normally open contact. Status of the contact will be the same state as the bit referenced in the associated memory location.
Aaaa.bb
Store Not Bit-of-Word (STRNB) DS5 Implied The Store Not Bit-of-Word instruction begins a new rung or HPP
Used
Operand Data Type
DL05 Range
.....................................
A aaa bb
V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B PB
See memory map See memory map
BCD, 0 to 15 BCD, 0 to 15
In the following Store Bit-of-Word example, when bit 12 of V-memory location V1400 is on, output Y2 will energize. DirectSOFT 5 DirectSOFT32 B1400.12
Y2 OUT
Handheld Programmer Keystrokes STR
SHFT
B
K
1
2
2
ENT
OUT
V
1
4
0
0
ENT
In the following Store Not Bit-of-Word example, when bit 12 of V-memory location V1400 is off, output Y2 will energize. DirectSOFT 5 DirectSOFT32 B1400.12
Y2 OUT
Handheld Programmer Keystrokes STRN
OUT
5–10
Aaaa.bb an additional branch in a rung with a normally closed contact. Status of the contact will be opposite the state of the bit referenced in the associated memory location.
SHFT
B
K
1
2
V
2
ENT
ENT
DL05 Micro PLC User Manual, 6th Edition, Rev. A
1
4
0
0