The text of a manual · part 25 of 61
DL205 PLC User Manual, Volume 1 of 2: Chapter 5: RLL and Intelligent Box Instructions, pages 223 to 232
Pages 223 to 232 of 592, from DL205 PLC User Manual, Volume 1 of 2
The original document is the PDF (13 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 D2-08ND3 and Koyo D2-08ND3
Page 223
RLL AND INTELLIGENT BOX INSTRUCTIONS
CHAPTER
5
In This Chapter: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–2 Using Boolean Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–5 Boolean Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–10 Comparative Boolean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–27 Immediate Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–33 Timer, Counter and Shift Register Instructions . . . . . . . . . . . . . . . .5–41 Accumulator/Stack Load and Output Data Instructions . . . . . . . . .5–53 Logical Instructions (Accumulator) . . . . . . . . . . . . . . . . . . . . . . . . .5–71 Math Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–88 Transcendental Functions (DL260 only) . . . . . . . . . . . . . . . . . . . .5–121 Bit Operation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–123 Number Conversion Instructions (Accumulator) . . . . . . . . . . . . . .5–130 Table Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–144 Clock/Calendar Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–175 CPU Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–177 Program Control Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–179 Interrupt Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–187 Intelligent I/O Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–191 Network Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–193 Message Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–197 Modbus RTU Instructions (DL260) . . . . . . . . . . . . . . . . . . . . . . . .5–205 ASCII Instructions (DL260) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5–211 Intelligent Box (IBox) Instructions (DL250-1/DL260 Only) . . . . . .5–230
Page 224
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Introduction The DL205 CPUs offer a wide variety of instructions to perform many different types of operations. There are several instructions that are not available in all of the CPUs. This chapter shows you how to use these individual instructions. There are two ways to quickly find the instruction you need. • If you know the instruction category (Boolean, Comparative Boolean, etc.), use the header at the top of the page to find the pages that discuss the instructions in that category. • If you know the individual instruction name, use the following table to find the page that discusses the instruction.
Instruction ACON ACOSR ACRB ADD ADDB ADDBD ADDBS ADDD ADDF ADDR ADDS AEX AFIND AIN AND AND STR ANDB ANDD ANDE ANDF ANDI ANDMOV ANDN ANDNB ANDND ANDNE ANDNI ANDPD ANDS ASINR ATANR ATH ATT BCD BCDCPL
5–2
ASCII Constant Arc Cosine Real ASCII Clear Buffer Add BCD Add Binary Add Binary Double Add Binary Top of Stack Add Double BCD Add Formatted Add Real Add Top of Stack ASCII Extract ASCII Find ASCII IN And for contacts or boxes And Store And Bit–of–Word And Double And if Equal And Formatted And Immediate And Move And Not And Not Bit–of–Word And Negative Differential And if Not Equal And Not Immediate And Positive Differential And Stack Arc Sine Real Arc Tangent Real ASCII to Hex Add to Top of Table Binary Coded Decimal Tens Complement
Page 5–199 5–122 5–229 5–88 5–101 5–102 5–117 5–89 5–109 5–90 5–113 5–220 5–217 5–212 5–14, 5–32, 5–71 5–16 5–15 5–72 5–29 5–73 5–35 5–171 5–14, 5–32 5–15 5–23 5–29 5–35 5–23 5–74 5–121 5–122 5–137 5–166 5–131 5–133
DL205 User Manual, 4th Edition, Rev. A
Instruction BIN BCALL BEND BLK BTOR CMP CMPD CMPF CMPR CMPS CMPV CNT COSR CV CVJMP DATE DEC DECB DECO DEGR DISI DIV DIVB DIVBS DIVD DIVF DIVR DIVS DLBL DRUM EDRUM ENCO END ENI
Binary Block Call (Stage) Block End (Stage) Block (Stage) Binary to Real Compare Compare Double Compare Formatted Compare Real Number Compare Stack ASCII Compare Counter Cosine Real Converge (Stage) Converge Jump (Stage) Date Decrement Decrement Binary Decode Degree Real Conversion Disable Interrupts Divide Divide Binary Divide Binary Top of Stack Divide Double Divide Formatted Divide Real Number Divide Top of Stack Data Label Timed Drum Event Drum Encode End Enable Interrupts
Page 5–130 7–27 7–27 7–27 5–134 5–83 5–84 5–85 5–87 5–86 5–221 5–46 5–121 7–25 7–25 5–175 5–100 5–108 5–129 5–136 5–188 5–97 5–106 5–120 5–98 5–112 5–99 5–116 5–199 6–12 6–14 5–128 5–177 5–188
Page 225
Chapter 5: Standard RLL Instructions Instruction FAULT FDGT FILL FIND FINDB FOR GOTO GRAY GTS HTA INC INCB INT INV IRT IRTC ISG JMP LBL LD LDI LDIF LDA LDD LDF LDR LDX LDLBL LDSX MDRMD MDRMW MLR MLS MOV MOVMC MRX MWX MUL MULB MULBS MULD MULF MULR MULS NCON NEXT
Fault Find Greater Than Fill Find Find Block For/Next Goto/Label Gray Code Goto Subroutine Hex to ASCII Increment Increment Binary Interrupt Invert Interrupt Return Interrupt Return Conditional Initial Stage Jump Label Load Load Immediate Load Immediate Formatted Load Address Load Double Load Formatted Load Real Number Load Indexed Load Label Load Indexed from Constant Masked Drum Event Discrete Masked Drum Event Word Master Line Reset Master Line Set Move Move Memory Cartridge Read from MODBUS Network Write to MODBUS Multiply Multiply Binary Multiply Binary top of stack Multiply Double Multiply Formatted Multiply Real Multiply Top of Stack Numeric Constand Next (For/Next)
Page 5-197 5-152 5–150 5–151 5–173 5–180 5–179 5–141 5–182 5–138 5–100 5–107 5–187 5–132 5–188 7–188 7–24 5–24 5–179 5–58 5–39 5–40 5-61 5–59 5–60 5–64 5–62 5–145 5–63 6–19 6–21 5–185 5–185 5–144 5–145 5–205 5–208 5–94 5–105 5–119 5–95 5–111 5–96 5–115 5–199 5–180
Instruction NJMP NOP NOT OR OR OUT OR OUTI OR STR ORB ORD ORE ORF ORI ORMOV ORN ORNB ORND ORNE ORNI ORPD ORS OUT OUTB OUTD OUTF OUTI OUTIF OUTL OUTM OUTX PAUSE PD POP PRINT PRINTV RADR RD RFB RFT ROTL ROTR RST RSTB RSTBIT RSTI RSTWT
Not Jump (Stage) No Operation Not Or Or Out Or Out Immediate Or Store Or Bit–of–Word Or Double Or if Equal Or Formatted Or Immediate Or Move Or Not Or Not Bit–of–Word Or Negative Differential Or if Not Equal Or Not Immediate Or Positive Differential Or Stack Out Out Bit–of–Word Out Double Out Formatted Out Immediate Out Immediate Formatted Out Least Out Most Out Indexed Pause Positive Differential Pop Print ASCII Print from V–Memory Radian Real Conversion Read from Intelligent Module Remove from Bottom of Table Remove from Top of Table Rotate Left Rotate Right Reset Reset Bit–of–Word Reset Bit Reset Immediate Reset Watch Dog Timer
Page 7–24 5-177 5–19 5–12, 5–31, 5–75 5–19 5–36 5–16 5–13 5–76 5–28 5–77 5–34 5–171 5–12, 5–31 5–13 5–22 5–28 5–34 5–22 5–78 5–17, 5–65 5–18 5–66 5–67 5–36 5–37 5–69 5–69 5–68 5–26 5–20 5–70 5–201 5–227 5–136 5–191 5–157 5–163 5–126 5–127 5–24 5–25 5–148 5–38 5–178
DL205 User Manual, 4th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–3
Page 226
Chapter 5: Standard RLL Instructions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
Instruction RT RTC RTOB RX SBR SEG SET SETB SETBIT SETI SFLDGT SG SGCNT SHFL SHFR SINR SQRTR SR STOP STR STRB STRE STRI STRN STRNB STRND STRNE STRNI STRPD STT
5–4
Subroutine Return Subroutine Return Conditional Real to Binary Read from Network Subroutine (Goto Subroutine) Segment Set Set Bit–of–Word Set Bit Set Immediate Shuffle Digits Stage Stage Counter Shift Left Shift Right Sine Real Square Root Real Shift Register Stop Store Store Bit–of–Word Store if Equal Store Immediate Store Not Store Not Bit–of–Word Store Negative Differential Store if Not Equal Store Not Immediate Store Positive Differential Source to Table
Page 5–182 5–182 5–135 5–193 5–182 5–140 5–24 5–25 5–148 5–38 5–142 7–23 5–48 5–124 5–125 5–121 5–122 5–52 5–177 5–10, 5–30 5–11 5–27 5–33 5–10, 5–30 5–11 5–21 5–27 5–33 5–21 5–160
DL205 User Manual, 4th Edition, Rev. A
Instruction SUB SUBB SUBBD SUBBS SUBD SUBF SUBS SUBR SUM SWAP SWAPB TANR TIME TMR TMRF TMRA TMRAF TSHFL TSHFR TTD UDC VPRINT WT WX XOR XORD XORF XORMOV XORS
Subtract Subtract Binary Subtract Binary Double Subtract Binary Top of Stack Subtract Double Subtract Formatted Subtract Top of Stack Subtract Real Number Sum Swap Table Data ASCII Swap Bytes Tangent Real Time Timer Fast Timer Accumulating Timer Fast Accumulating Timer Table Shift Left Table Shift Right Table to Destination Up Down Counter ASCII Print to V–Memory Write to Intelligent Module Write to Network Exclusive Or Exclusive Or Double Exclusive Or Formatted Exclusive Or Move Exclusive Or Stack
Page 5–91 5–103 5–104 5–118 5–92 5–110 5–114 5–93 5–123 5–174 5–228 5–121 5–176 5–42 5–42 5–44 5–44 5–169 5–169 5–154 5–50 5–222 5–192 5–195 5–79 5–80 5–81 5–171 5–82
Page 227
Chapter 5: Standard RLL Instructions - Boolean
Using Boolean Instructions
1 2 3 4 5 6 The following paragraphs show how these instructions are used to build simple ladder 7 programs. END Statement 8 All DL205 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 9 statement will not be executed. There are exceptions to this such as interrupt routines, etc. Chapter 5 discusses the instruction set in detail. 10 11 12 Simple Rungs 13 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 14 Output or, OUT instruction. The following example shows how to enter a single contact and a single output coil. A B C D 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 typically very simple instructions designed to join input and output contacts in various series and parallel combinations. Our DirectSOFT programming package is a similar program. It uses graphic symbols to develop a program; therefore, you don’t necessarily have to know the instruction mnemonics in order to develop your program. Many of the instructions in this chapter are not program instructions used in DirectSOFT, 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 program has been developed and accepted (compiled). Each instruction listed in this chapter will have a small chart to indicate how the instruction is used with DirectSOFT and the HPP. DS HPP
X0
Implied Used
DirectSOFT Example
All programs must have an END statement
Y0
OUT
END
DirectSOFT Example
X0
Handheld Mnemonics
Y0
OUT
STR X0 OUT Y0 END
END
DL205 User Manual, 4th Edition, Rev. A
5–5
Page 228
Chapter 5: Standard RLL Instructions - Boolean
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–6
Normally Closed Contact 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. DirectSOFT Example
Handheld Mnemonics
X0
Y0 OUT
STRN X0 OUT Y0 END
END
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 X1, followed by OUT Y0. DirectSOFT Example X0
Handheld Mnemonics Y0
X1
OUT
STR X0 AND X1 OUT Y0 END
END
Midline Outputs Sometimes it is necessary to use midline outputs to get additional outputs that are conditional on other contacts. The following example shows how you can use the AND instruction to continue a rung with more conditional outputs. DirectSOFT Example X0
Handheld Mnemonics Y0
X1
OUT Y1
X2
OUT X3
Y2 OUT
END
DL205 User Manual, 4th Edition, Rev. A
STR X0 AND X1 OUT Y0 AND X2 OUT Y1 AND X3 OUT Y2 END
Page 229
Chapter 5: Standard RLL Instructions - Boolean
Parallel Elements
1 2 3 4 5 Joining Series Branches in Parallel Quite often it is necessary to join several groups of series elements in parallel. The Or Store 6 (ORSTR) instruction allows this operation. The following example shows a simple network consisting of series elements joined in parallel. 7 8 9 10 Joining Parallel Branches in Series 11 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. 12 13 14 A Combination Networks B You can combine the various types of series and parallel branches to solve most C any application problem. The following example shows a simple combination network. D You may 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 Example
Handheld Mnemonics
X0
Y0
OUT
X1
STR X0 OR X1 OUT Y0 END
END
DirectSOFT Example
X0
Handheld Mnemonics
Y0
X1
OUT
X2
X3
END
DirectSOFT Example
X0
STR X0 AND X1 STR X2 AND X3 ORSTR OUT Y0 END
Handheld Mnemonics
Y0
X1
OUT
X2
STR X0 STR X1 OR X2 ANDSTR OUT Y0 END
END
X0
X2
X5
Y0
OUT
X1
X3
X4
X6
END
DL205 User Manual, 4th Edition, Rev. A
5–7
Page 230
Chapter 5: Standard RLL Instructions - Boolean
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–8
Comparative Boolean 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 DL205 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 evaluations are: equal to, not equal to, equal to or greater than, and less than. Y3 V1400 K1234 In the example when the BCD value in V-memory OUT location V1400 is equal to the constant value 1234, Y3 will energize.
Boolean Stack There are limits to how many elements you can include in a rung. This is because the DL205 CPUs 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 you enter a STR instruction, the instruction is placed on the top of the boolean stack. Any other STR instructions on the boolean stack are pushed down a level. The ANDSTR, and ORSTR instructions combine levels of the boolean stack when they are encountered. Since the boolean stack is only eight levels, an error will occur if the CPU encounters a rung that uses more than the eight levels of the boolean stack. The following example shows how the boolean stack is used to solve boolean logic. X0
STR
X1 ORSTR
Y0
AND X4
STR
OUT X2 AND
X3
ANDSTR
STR X5
Output
OR
STR X0
STR X1
STR X2
AND X3
1
1
STR X1
1
STR X2
1
STR X2
2
2
STR X0
2
STR X1
2
STR X1
3
3
3
STR X0
3
STR X0
4
4
4
STR X0
4
ORSTR
AND X4
1
X1 or (X2 AND X3)
1
X4 AND {X1 or (X2 AND X3)}
1
NOT X5 OR X4 AND {X1 OR (X2 AND X3)}
2
STR X0
2
STR X0
2
STR X0
3
3
ANDSTR 1
XO AND (NOT X5 or X4) AND {X1 or (X2 AND X3)}
2 3
DL205 User Manual, 4th Edition, Rev. A
ORNOT X5
3
Page 231
Chapter 5: Standard RLL Instructions - Boolean
Immediate Boolean The DL205 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 DL205 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.
X0 _ X7
X10 _ X17
X20 _ X27
X30 _ X37
Y0 _ Y7
Y10 _ Y17
Y20 _ Y27
Y30 _ Y37
CPU Scan Th e CPU reads the inputs from the local base and stores the status in an input image register .
Read Inputs X128 OFF
... X2 X1 X0 ... ON OFF OFF Input Image Register
OFF
X0
OFF
X1
Read Inputs from Specialty I/O
Solve the Application Program X0 I
Y0
Immediate instruction does not use the input image register , but instead reads the status from the module I/O Point X0 Changes immediately. ON
X0
OFF
X1
Write Outputs Write Outputs to Specialty I/O Diagnostics
DL205 User Manual, 4th Edition, Rev. A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D
5–9
Page 232
Chapter 5: Standard RLL Instructions - Boolean
Boolean Instructions
1 Store (STR) The Store instruction begins a new rung or an 2 additional branch in a rung with a normally open contact. Status of the contact will be the same state as 3 the associated image register point or memory location.
4 Store Not (STRN) The Store Not instruction begins a new rung or an 5 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 6 location.
7 Operand Data Type DL230 Range DL240 Range DL250–1 Range DL260 Range A aaa aaa aaa aaa 8 9 10 11 In the following Store example, when input X1 is on output Y2 will energize. 12 13 14 A In the following Store Not example, when input X1 is off output Y2 will energize. B C D 230
Aaaa
240
250-1 260
230
Aaaa
240
250-1 260
Inputs Outputs Control Relays Stage Timer Counter Special Relay Global Global
DS HPP
Used Used
X Y C S T CT SP GX GY
0 – 177 0 – 177 0 – 377 0 – 377 0 – 77 0 – 77 0 – 117, 540 – 577 – –
0 – 477 0 – 477 0 – 377 0 – 777 0 – 177 0 – 177 0 – 137 540 – 617 – –
DirectSOFT X1
0 – 777 0 – 777 0 – 1777 0 – 1777 0 – 377 0 – 177 0 – 777 – –
Handheld Programmer Keystrokes
Y2
$
B
STR
OUT
DirectSOFT X1
DL205 User Manual, 4th Edition, Rev. A
GX OUT
1
C
2
ENT ENT
Handheld Programmer Keystrokes
Y2
OUT
5–10
0 – 1777 0 – 1777 0 – 3777 0 – 1777 0 – 377 0 – 377 0 – 777 0 –3777 0 – 3777
SP STRN
B
GX OUT
C
1 2
ENT ENT