Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 22 of 68

DL405 User Manual: Chapter 5: Standard RLL Instructions, pages 173 to 182

Pages 173 to 182 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 173

Standard RLL Instructions

15

In This Chapter. . . ., Introduction, Boolean Instructions, Comparative Boolean Instructions, Immediate Instructions, Timer, Counter, and Shift Register Instructions, Accumulator / Data Stack and Output Instructions, Accumulator Logic Instructions, Math Instructions, Bit Operation Instructions, Number Conversion Instructions, Table Instructions, Clock / Calender Instructions, CPU Control Instructions, Program Control Instructions, Interrupt Instructions, Intelligent I/O Instructions, Network Instructions, Message Instructions

Page 174

5--2

Standard RLL Instructions

Introduction The DL405 instruction set can perform many different types of operations. This chapter shows you how to use these individual instructions. The following table provides a quick reference listing of the instruction mnemonic and the page(s) defining the instruction. Each instruction definition will show in parentheses the HPP keystrokes used to enter the instruction. There are two ways to locate instructions:

S

If you know the instruction category (Boolean, Comparative Boolean, etc.), just use the header at the top of the page to find the pages that discuss the instructions in that category.

S

If you know the individual instruction mnemonic, use the following table.

The DL450 provides all of the instructions in the table, the DL440 provides a subset, and the DL430 a smaller subset. The instruction definitions indicate which CPUs feature the instruction. In Example 1, only the DL440 and DL450 have the instruction. In Example 2, all CPUs have the instruction.

Example 1

Example 2

430 440 450

430 440 450

If you are using a DL450 PLC (with firmware v3.30 or later) with DirectSOFT5 programming software, you can also use the IBox instructions covered in the DL405--IBOX--S Supplement.

Standard RLL Instructions

Instruction

Page

ACON

5--196

ACOSR

5--119

ADD

5--87

ADDB

5--99

ADDBD

5--100

ADDBS

5--113

ADDD

5--88

ADDF

5--105

ADDR

5--89

ADDS

5--109

AND

5--14, 5--31, 5--70

Instruction

Page

Instruction

Page

5--16, 5--118

DEGR

5--134

ASINR

5--118

DISI

5--186

ATANR

5--119

DIV

5--96

ATH

5--135

DIVB

5--104

ATT

5--159

DIVBS

5--116

BCALL

7--27

DIVD

5--97

BCD

5--129

DIVF

5--108

DIVR

5--98

DIVS

5--112

DLBL

5--196

DRUM

6--15

EDRUM

6--18

ENCO

5--126

END

5--177

ENI

5--186

FAULT

5--195

FDGT

5--144

FILL

5--142

FIND

5--143

ANDSTR

BCDCPL

5--131

BEND

7--27

BIN

5--128

BLK

7--27

ANDD

5--71

BREAK

5--178

ANDND

5--23

BTOR

5--132

ANDS

5--73

CMP

5--82

CMPD

5--83

CMPF

5--84

CMPR

5--86

CMPS

5--85

CNT

5--47

FINDB

5--173

COSR

5--118

FOR

5--180

CV

7--25

GOTO

5--179

5--15

CVJMP

7--25

GRAY

5--139

ANDNE

5--28

DATE

5--175

GTS

5--181

ANDNI

5--34

DEC

5--117

HISTRY

5--197

ANDPD

5--23

DECB

5--120

HTA

5--136

ANDS

5--73

DECO

5--127

INC

5--117

ANDSTR

5--16

ANDB

5--15

ANDD

5--71

ANDE

5--28

ANDF

5--72

ANDI

5--34

ANDMOV

5--171

ANDN

5--14, 5--31

ANDNB

DL405 User Manual, 4th Edition

Page 175

5--3

Standard RLL Instructions

Instruction

Page

Instruction

Page

Instruction

Page

INCB

5--120

ORND

5--22

SGCNT

5--49

INT

5--185

ORNE

5--27

SHFL

5--122

INV

5--130

ORNI

5--33

SHFR

5--123

IRT

5--186

OROUT

5--19

SINR

5--118

IRTC

5--186

OROUTI

5--35

SQRTR

5--119

ISG

7--24

ORPD

5--22

SR

5--53

JMP

7--24

ORS

5--77

STOP

5--177

LBL

5--179

ORSTR

5--16

STR

5--10, 5--29

LD

5--59

5--17, 5--65

5--11

5--61

OUT

STRB

LDA

5--59

5--18

5--26

LDD

OUTB

STRE

5--65

5--32

5--60

OUTD

STRI

LDF

5--37

5--66

5--10, 5--29

LDI

OUTF

STRN

5--35, 5--39

5--11

5--38

OUTI

STRNB

LDIF

STRND

5--21

LDLBL

5--162

STRNE

5--26

LDR

5--64

STRNI

5--32

LDSX

5--63

STRPD

5--21

LDX

5--62

STT

5--153

MDRMD

6--21

SUB

5--90

MDRMW

6--24

SUBB

5--101

MLR

SUBBD

5--102

SUBBS

5--114

SUBD

5--91

SUBF

5--106

SUBR

5--92

SUBS

5--110

SUM

5--121

SWAP

5--174

TANR

5--118

TIME

5--176

TMR

5--42

5--40

OUTL

5--68

OUTM

5--68

OUTX

5--67

PAUSE

5--20

PD

5--20

5--183

POP

5--69

MLS

5--183

PRINT

5--201

MOV

5--146

RADR

5--134

MOVMC

5--162

RD

5--189

MUL

5--93

RFB

5--150

MULB

5--103

RFT

5--156

MULBS

5--115

ROTL

5--124

MULD

5--94

ROTR

5--125

MULF

5--107

RST

5--24

MULR

5--95

RSTB

5--25

MULS

5--111

RSTBIT

5--167

NCON

5--197

RSTI

5--36

NEXT

5--180

TMRA

5--44

RSTWT

5--178

NJMP

7--24

TMRAF

5--44

RT

5--181

NOP

5--177

TMRF

5--42

RTC

5--181

NOT

5--19

TSHFL

5--169

RTOB

5--133

OR

5--12, 5--30, 5--74

TSHFR

5--169

RX

5--191

TTD

5--147

5--13

SBR

5--181

UDC

5--51

5--75

SEG

5--138

WT

5--190

ORE

5--27

SET

5--24

WX

5--192

ORF

5--76

SETB

5--25

XOR

5--78

ORI

5--33

SETBIT

5--167

XORD

5--79

ORMOV

5--171

SETI

5--36

XORF

5--80

ORN

5--12, 5--30

SFLDGT

5--140

XORMOV

5--171

ORNB

5--13

SG

7--23

XORS

5--81

ORB ORD

DL405 User Manual, 4th Edition

Standard RLL Instructions

OUTIF

Page 176

5--4

Standard RLL Instructions Boolean Instructions

Using Boolean Instructions Do you ever wonder why so many PLC manufacturers always quote the scan time for a 1K boolean program? 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 software is a similar program; therefore, you don’t necessarily have to know the instruction mnemonics in order to develop your program. However, knowledge of mnemonics will be helpful whenever it becomes necessary to troubleshoot the program using a handheld programmer (HPP). 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 box to indicate how the instruction is used with DirectSOFT and the HPP. The box will either contain IMP for implied, a for used or an for not used. The abbreviation, DS, or HPP will appear beneath the appropriate box as shown below. IMP DS

END Statement

HPP

DS

DL405 programs require an END statement (coil) as the last instruction. This tells the CPU this is the end of the program. Normally, any instructions placed after the END statement will not be executed. There are exceptions to this such as interrupt routines, etc. Chapter 5 discusses the instruction set in detail. X0

Y0

All programs must have and END statement

OUT END

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 Output or, OUT instruction. The following example shows how to enter a single contact and a single output coil. DirectSOFT Example X0

Handheld Mnemonics Y0

Standard RLL Instructions

OUT END

DL405 User Manual, 4th Edition

STR X0 OUT Y0 END

Page 177

Standard RLL Instructions Boolean Instructions Normally Closed Contact

5--5

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

X1

Y0 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

X1

Y0 OUT X2

Y1 OUT X3

Y2

STR X0 AND X1 OUT Y0 AND X2 OUT Y1 AND X3 OUT Y2 END

OUT

END

Standard RLL Instructions

DL405 User Manual, 4th Edition

Page 178

5--6

Standard RLL Instructions Boolean Instructions

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 Example

X0

Y0 OUT

X1

Handheld Mnemonics STR X0 OR X1 OUT Y0 END

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 Example X0

X1

Handheld Mnemonics Y0 OUT

X2

X3 END

STR X0 AND X1 STR X2 AND X3 ORSTR OUT Y0 END

Quite often it is also necessary to join one or more parallel branches in series. The Joining Parallel Branches in Series And Store (ANDSTR) instruction allows this operation. The following example shows a simple network with contact branches in series with parallel contacts. DirectSOFT Example X0

X1

Handheld Mnemonics Y0 OUT

X2

Standard RLL Instructions

END

DL405 User Manual, 4th Edition

STR X0 STR X1 OR X2 ANDSTR OUT Y0 END

Page 179

5--7

Standard RLL Instructions Boolean Instructions 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

Comparative Boolean

Handheld Mnemonics STR X0 OR X1 STR X2 STR X3 ANDN X4 ORSTR AND X5 ORN X6 ANDSTR OUT Y0

The Comparative Boolean evaluates two 4-digit BCD/hex values using boolean contacts. The valid evaluations are: equal to, not equal to, equal to or greater than, and less than. In the following example when the value in V-memory location V1400 is equal to the constant BCD value 1234, Y3 will energize.

V1400

K1234

Y3 OUT

Standard RLL Instructions

DL405 User Manual, 4th Edition

Page 180

5--8

Standard RLL Instructions Boolean Instructions

Boolean Stack

There are limits to how many elements you can include in a rung. This is because the DL405 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. All of you software programmers may be saying, “I use DirectSOFT, so I don’t need to know how the stack works.” Not quite true. Even though you can build the network with the graphic symbols, the limits of the CPU are still the same. If the stack limit is exceeded when the program is compiled, an error will occur. The following example shows how the boolean stack is used to solve boolean logic. X0

STR

STR

STR

X1

AND X4

ORSTR

Y0 OUT

X2 AND X3

X5

Output

ANDSTR

OR

STR X0

STR X1

STR X2

AND X3

1

1

STR X1

1

STR X2

1

X2 AND X3

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

OR X5

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

X0 AND (NOT X5 OR X4) AND [X1 OR (X2 AND X3)]

2

Standard RLL Instructions

3

DL405 User Manual, 4th Edition

3

Page 181

Standard RLL Instructions Boolean Instructions

5--9

Immediate Boolean The DL405 CPUs usually can 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 DL405 CPUs 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 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 module. 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 module, 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 module again to update the status. The immediate output instruction will write the status to the module and update the image register. 8pt Input

16pt Input

8pt Input

X0 -X07

X10 -X27

X30 -X37

8pt 8pt 16pt Output Output Output Y0 -Y07

Y10 -Y17

Y20 -Y37

CPU Scan Read Inputs X320 OFF

... X2 X1 X0 ... ON OFF OFF Input Image Register

The CPU reads the inputs from the local and expansion bases and stores the status in an 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 immediately.

I/O Point X0 Changes X0 X1

Write Outputs Write Outputs to Specialty I/O Diagnostics

DL405 User Manual, 4th Edition

Standard RLL Instructions

ON OFF

Page 182

5--10

Standard RLL Instructions Boolean Instructions

Boolean Instructions Store (STR)

430 440 450

DS

HPP

Store Not (STRN)

430 440 450

DS

HPP

The Store instruction begins a new rung or an additional 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.

Aaaa

The Store Not instruction begins a new rung or an 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.

Aaaa

Operand Data Type

DL430 Range

DL440 Range

A aaa aaa aaa

X

0--477

0--477

0--1777

Outputs

Y

0--477

0--477

0--1777

Control Relays

C

0--737

0--1777

0--3777

Stage

S

0--577

0--1777

0--1777

Timer

T

0--177

0--377

0--377

Inputs

DL450 Range

Counter

CT

0--177

0--177

0--377

Special Relay

SP

0--137, 320--617

0--137 320--717

0--137, 320--717

Global

GX

0--777

0--1777

0--2777

Global

GY

--

--

0--2777

In the following Store example, when input X1 is on, output Y2 will energize. Handheld Programmer Keystrokes

DirectSOFT X1

Y2

STR

X(IN)

1

OUT

OUT

Y(OUT)

2

Standard RLL Instructions

In the following Store Not example, when input X1 is off output Y2 will energize. Handheld Programmer Keystrokes

DirectSOFT X1

Y2 OUT

DL405 User Manual, 4th Edition

STR

NOT

X(IN)

OUT

Y(OUT)

2

1