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

The text of a manual · part 42 of 61

DL205 PLC User Manual, Volume 1 of 2: Chapter 5: RLL and Intelligent Box Instructions, pages 393 to 402

Pages 393 to 402 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 393

Chapter 5: Standard RLL Instructions - Table

AND Move (ANDMOV)

1 2 ORMOV 3 Vaaa OR Move (ORMOV) The Or Move instruction copies data from a table to the 4 specified memory location, ORing each word with the XORMOV accumulator contents as it is written. 5 Vaaa Exclusive OR Move (XORMOV) The Exclusive OR Move instruction copies data from a table to 6 the specified memory location, XORing each word with the accululator value as it is written.

The following description applies to the AND Move, OR Move, and Exclusive OR Move

7 instructions. A table is just a range of V-memory locations. These instructions copy the data of a table to another specified location, preforming a logical operation on each word with the accumulator contents as the new table is written. 8 Step 1: Load the length of the table (number of V-memory locations) into the first level of the accumulator stack. This parameter must be a HEX value, 0 to FF. 9 Step 2: Load the starting V-memory location for the table into the accumulator. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. 10 Step 3: Load the BCD/hex bit pattern into the accumulator which will be logically combined with the table contents as they are copied. 11 Step 4: Insert the AND Move, OR Move, or XOR Move instruction. This specifies the starting location of the copy of the original table. This new table will automatically be the same length as the original table. 12 Operand Data Type DL260 Range 13 aaa 14 The example table to the right contains BCD data as shown (for demonstration purposes). Suppose we want to A move a table of two words at V3000 and AND it with K6666. The copy of the table at V3100 shows the result B of the AND operation for each word. The program on the next page performs the ANDMOV operation example above. It assumes that the data in the table at V3000 – V3001 already exists. First we load the table length (two C words) into the accumulator. Next we load the starting addrss of the source table, using the LDA instruction. Then we load the data into the accumulator to be ANDed with the table. D In the ANDMOV command, we specify the table destination, V3100. 230 240 250-1 260

ANDMOV Vaaa

The AND Move instruction copies data from a table to the specified memory location, ANDing each word with the accumulator data as it is written.

230 240

250-1 260

DS Used HPP Used

V-memory

V

All (See page 3 - 56) V 3000

3 3 3 3

ANDMOV K 6666

F F F F

DL205 User Manual, 4th Edition, Rev. A

V 3100

2 2 2 2 6 6 6 6

5–171

Page 394

Chapter 5: Standard RLL Instructions - Table DirectSOFT

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D 5–172

Handheld Programmer Keystrokes $ STR

A 0

SHFT

L D ANDST 3

SHFT

L D 3 ANDST

SHFT

L D 3 ANDST

V AND

SHFT

M ORST

X0

LD

ENT

K2 PREV

A

C 2 D

0 PREV O INST#

A

A 0

3 G

G

A G 6

6 D

0

0 G

6

V AND

Load the constant value 2 (Hex.) into the lower 16 bits of the accumulator.

ENT

B 3

6 A

1

ENT

LDA ENT A

0

0

0 3000 Convert otal 3000 to HEX and load the value into the accumulator. This is the table beginning.

ENT

The example to the right shows a table of two words at V3000 and logically ORs it with K8888. The copy of the table at V3100 shows the result of the OR operation for each word. The program to the right performs the ORMOV example above. It assumes that the data in the table at V3000 – V3001 already exists. First we load the table length (two words) into the accumulator. Next we load the starting address of the source table, using the LDA instruction. Then we load the data into the accumulator to be ORed with the table. V 3000 In the ORMOV command, we specify the table 1 1 1 1 destination, V3100.

LD K6666 Load the constant value 6666 (Hex.) into the lower 16 bits of the accumulator. ANDMOV 0 3100 Copy the table to V3100, ANDing its contents with the accumulator as it is written.

V 3100

OR MOV K 8888

9 9 9 9

1 1 1 1 DirectSOFT 32

Handheld Programmer Keystrokes

X0

A

$ STR

0

SHFT

L D ANDST 3

SHFT

L D ANDST 3

SHFT

L D ANDST 3

Q

SHFT

OR

M ORST

9 9 9 9

ENT

LD K2

PREV A

C D

0

A 3

PREV O INST#

ENT

2

V AND

I

A 0

I 8

A 0

I 8

D

8 B

3

0 I 8 A

1

ENT

LDA

ENT

0 3000 A

0

Load the constant value 2 (Hex) into the lower 16 bits of the accumulator.

0

ENT

Convert octal 3000 to HEX and load the value into the accumulator. This is the table beginning.

The example to the right shows a table of two words at V3000 and logicall XORs it with K3333. The copy of the table at V3100 shows the result of the XOR operation for each word. The ladder program example for the XORMOV is similar to the one above for the ORMOV. Just use the XORMOV instruction. On the handheld programmer, you must use the SHFT key and spell “XORMOV” explicitly. V 3000 1 1 1 1 1 1 1 1

DL205 User Manual, 4th Edition, Rev. A

LD K8888 Load the constant value 8888 (Hex.) into the lower 16 bits of the accumulator. ORMOV 0 3100 Copy the table to V3100, ORing its contents with the accumulator as it is written.

X OR MOV K 3333

V 3100 2 2 2 2 2 2 2 2

Page 395

Chapter 5: Standard RLL Instructions - Table

Find Block (FINDB)

1 2 stored in the accumulator. If the block is not found, flag SP53 3 will be set. 4 Operand Data Type DL260 Range A aaa 5 6 Discrete Bit Flags Description 7 The below steps are necessary to program the Find Block function. 8 Step 1: Load the number of bytes in the block to be located. This parameter must be a decimal value from 1 to 256. Step 2: Load the length of a table (number of words) to be searched. The Find Block will search 9 multiple tables that are adjacent in V-memory. This parameter must be a decimal value from 1 to 128. 10 Step 3: Load the ending location for all the tables into the accumulator. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. Step 4: Load the table starting location for all the tables into the accumulator. This parameter must be 11 a HEX value. You can use the LDA instruction to convert an octal address to hex. Step 5: Insert the Find Block instruction. This specifies the starting location of the block of data you 12 are trying to locate. 13 14 A B C D

Find Block instruction searches for an occurrence of a 230 The specified block of values in a V-memory table. The function 240 parameters are loaded into the first and second levels of the 250-1 accumulator stack and the accumulator by three additional 260 instructions. If the block is found, its starting address will be

FINDB Aaaa

DS Used HPP N/A

V-memory V-memory

SP53

V P

All (See page 3 - 56) All (See page 3 - 56)

On when the Find Block instruction was executed but did not find the block of data in table specified.

Start Addr. V2000 V2017 V2020 V2037 V2040 V2057

Sample Program of FINDB

X1

Table 1

16 words

Table 2

16 words

Start Addr.

Table 3

16 words

V3000

LD

LD

K16

Block

32 bytes

LDA O2777

V3017

V2760 V2777

Table 32

K32

LDA O2000

16 words

FINDB V3000

End Addr.

END

DL205 User Manual, 4th Edition, Rev. A

5–173

Page 396

Chapter 5: Standard RLL Instructions - Table

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Swap (SWAP)

230 240 250-1 260 DS Used HPP Used

5–174

The Swap instruction exchanges the data in two tables of equal length.

SWAP V aaa

The following description applies to both the Set Bit and Reset Bit table instructions. Step 1: Load the length of the tables (number of V-memory locations) into the first level of the accumulator stack. This parameter must be a HEX value, 0 to FF. Remember that the tables must be of equal length. Step 2: Load the starting V-memory location for the first table into the accumulator. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. Step 3: Insert the Swap instruction. This specifies the starting address of the second table.

Helpful hint:, The data swap occurs within a single scan. If the instruction executes on multiple consecutive scans, it will be difficult to know the actual contents of either table at any particular time. So, remember to swap just on a single scan. Operand Data Type

DL260 Range

V-memory

All (See page 3 - 56)

aaa V

The example to the right shows a table of two words at V3000. We will swap its contents with another table of two words at V3100 by using the Swap instruction.

V 3000

V 3100

1 2 3 4

A B C D

S WAP

5 6 7 8

0 0 0 0

The example program below uses a PD contact (triggers for one scan for off-to-on transition). First, we load the length of the tables (two words) into the accumulator. Then we load the address of the first table (V3000) into the accumulator using the LDA instruction, converting the octal address to hex. Note that it does not matter which table we declare “first”, because the swap results will be the same. DirectSOFT X0

Load the constant value 2 (Hex.) into the lower 16 bits of the accumulator.

LD K2

Convert octal 3000 to HEX and load the value into the accumulator. This is the table beginning.

LDA O 3000

Swap the contents of the table in the previous instruction with the one at V3100.

SWAP V 3100 Handheld Programmer Keystrokes $ STR

SHFT

P

D CV

SHFT

L ANDST

D

SHFT

L ANDST

D

SHFT

S RST

A 3

0 PREV

3 A

C 2 D

3

0

SHFT

W ANDN

P 0

ENT A

A 3

A

ENT

A 0

0 D

CV

DL205 User Manual, 4th Edition, Rev. A

0 B

3

ENT A

1

A 0

0

ENT

Page 397

Chapter 5: Standard RLL Instructions - Clock/Calendar

Clock/Calendar Instructions Date (DATE) The Date instruction can be used to set the date in the CPU.

DATE

230 The instruction requires two consecutive V-memory locations 240 (Vaaa) to set the date. If the values in the specified locations are 250-1 not valid, the date will not be set. The current date can be read 260 from 4 consecutive V-memory locations (V7771–V7774). DS Used HPP Used

V aaa

Date

Range

V-memory Location (BCD) (READ Only)

Year Month Day Day of Week

0-99 1-12 1-31 0-06

V7774 V7773 V7772 V7771

The values entered for the day of week are: 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday.

Operand Data Type V-memory

DL250-1 Range

V

DL260 Range aaa aaa

All (See page 3 - 55)

All (See page 3 - 56)

In the following example, when C0 is on, the constant value (K94010301) is loaded into the accumulator using the Load Double instruction (C0 should be a contact from a one shot (PD) instruction). The value in the accumulator is output to V2000 using the Out Double instruction. The Date instruction uses the value in V2000 to set the date in the CPU. DirectSOFT

Constant (K)

C0

9

4

0

1

0

3

0

1

Acc. 9

4

0

1

0

3

0

1

Acc. 9

4

0

1

0

3

0

1

9

4

0

1

0

3

0

1

LDD

In this example, the Date instruction uses the value set in V2000 and V2001 to set the date in the appropriate V memory locations (V7771-V7774).

K94010301 Load the constant value (K94010301) into the accumulator OUTD V2000 Copy the value in the accumulator to V2000 and V2001

V2000

V2001

Format DATE

V2001 V2000

9

Set the date in the CPU using the value in V2000 and 2001 Handheld Programmer Keystrokes $ STR

NEXT

NEXT D

SHFT

L ANDST

D

A

D

A

3

0

3

GX OUT

SHFT

D

SHFT

D

A 3

0

1

C

0

NEXT

A

PREV

J

A

A

0

V2000 1

Month

0

3

Day

0

1

Day of Week

ENT E

A 4

9

B 0

1

ENT

ENT

3

2 T MLR

0

Year NEXT

3 B

4

E

A 0

0 C

4

0 A

2

ENT A

0

A 0

0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

ENT

DL205 User Manual, 4th Edition, Rev. A

5–175

Page 398

Chapter 5: Standard RLL Instructions - Clock/Calendar

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Time (TIME) Time instruction can be used to set the time (24-hour TIME 230 The clock) in the CPU. The instruction requires two consecutive V aaa 240 V-memory locations (Vaaa) which are used to set the time. If 250-1 the values in the specified locations are not valid, the time will 260 not be set. The current time can be read from memory locations V7747 and V7766–V7770. DS Used HPP Used

5–176

Date

Range

V-memory Location (BCD) (READ Only)

1/100 seconds (10ms) Seconds Minutes Hour

0-99 0-59 0-59 0-23

V7747 V7766 V7767 V7770

Operand Data Type

DL250-1 Range

DL260 Range aaa aaa

V-memory

All (See page 3 - 55)

All (See page 3 - 56)

V

In the following example, when C0 is on, the constant value (K73000) is loaded into the accumulator using the Load Double instruction (C0 should be a contact from a one shot (PD) instruction). The value in the accumulator is output to V2000 using the Out Double instruction. The Time instruction uses the value in V2000 to set the time in the CPU. DirectSOFT

Constant (K)

C0

0

0

0

7

3

0

0

0

Acc. 0

0

0

7

3

0

0

0

Acc. 0

0

0

7

3

0

0

0

0

0

0

7

3

0

0

0

The Time instruction uses the value set in V2000 and V2001 to set the time in the appropriate Vmemory locations (V7766–V7770)

LDD K73000 Load the constant value (K73000) into the accumulator

OUTD V2000 Copy the value in the accumulator to V2000 and V2001

V2001

V2000

Format V2001

TIME

0

V2000

0

0

V2000 7

3

0

0

0

Set the time in the CPU using the value in V2000 and V2001

Not Used

Handheld Programmer Keystrokes $

NEXT

NEXT

SHFT

L ANDST

D

D

GX OUT

SHFT

D

SHFT

T MLR

SHFT

STR

3

NEXT

3 C

3

NEXT

A

PREV

H

A

A 0

2 I 8

M ORST

E

0

ENT D

7

A 3

A 0

0 C

4

Hour Minutes

A 0

DL205 User Manual, 4th Edition, Rev. A

0

ENT

ENT A

2

A 0

A 0

A 0

0

ENT

Seconds

Page 399

Chapter 5: Standard RLL Instructions - CPU Control

CPU Control Instructions No Operation (NOP)

230 240 250-1 260

The No Operation is an empty (not programmed) memory location.

DirectSOFT

Handheld Programmer Keystrokes SHFT

DS Used HPP Used

NOP

NOP

N TMR

O INST#

P

ENT

CV

End (END) The End instruction marks the termination point of the normal

230 program scan. An End instruction is required at the end of the main 240 program body. If the End instruction is omitted an error will occur and 250-1 the CPU will not enter the Run Mode. Data labels, subroutines and routines are placed after the End instruction. The End 260 interrupt instruction is not conditional; therefore, no input contact is allowed. DS Used HPP Used

DirectSOFT

END

Handheld Programmer Keystrokes SHFT

E 4

END

N TMR

D

ENT

3

Stop (STOP) The Stop instruction changes the operational mode of the CPU from

STOP 230 Run to Program (Stop) mode. This instruction is typically used to stop 240 PLC operation in a shutdown condition such as a I/O module failure.

250-1 260 In the following example, when SP45 comes on indicating a I/O module failure, the CPU will stop operation and switch to the program mode. DS Used HPP Used

DirectSOFT

Handheld Programmer Keystrokes $

SP45

STR STOP SHFT

SP45 will turn on if there is an I/O module failure.

S RST

F

SHFT

SP STRN

E

SHFT

T MLR

O INST#

5

4 P

CV

ENT ENT

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–177

Page 400

Chapter 5: Standard RLL Instructions - CPU Control

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

Reset Watch Dog Timer (RSTWT) The Reset Watch Dog Timer instruction resets the CPU scan

230 timer. The default setting for the watch dog timer is 200ms. 240 Scan times very seldom exceed 200ms, but it is possible. 250-1 For/next loops, subroutines, interrupt routines, and table can be programmed such that the scan becomes 260 instructions longer than 200ms. When instructions are used in a manner DS Used HPP Used

5–178

RSTWT that could exceed the watch dog timer setting, this instruction can be used to reset the timer. A software timeout error (E003) will occur and the CPU will enter the program mode if the scan time exceeds the watch dog timer setting. Placement of the RSTWT instruction in the program is very important. The instruction has to be executed before the scan time exceeds the watch dog timer’s setting. If the scan time is consistently longer than the watch dog timer’s setting, the timeout value may be permanently increased from the default value of 200ms by AUX 55 on the HPP or the appropriate auxiliary function in your programming package. This eliminates the need for the RSTWT instruction. In the following example the CPU scan timer will be reset to 0 when the RSTWT instruction is executed. See the For/Next instruction for a detailed example.

DirectSOFT

Handheld Programmer Keystrokes SHFT RSTWT

DL205 User Manual, 4th Edition, Rev. A

R ORN

S RST

T MLR

W ANDN

T MLR

ENT

Page 401

Chapter 5: Standard RLL Instructions - Program Control

Program Control Instructions Goto Label (GOTO) (LBL) The Goto / Label skips all instructions between the Goto

K aaa

230 and the corresponding LBL instruction. The operand 240 value for the Goto and the corresponding LBL are the same. The logic between Goto and 250-1 instruction LBL instruction is not executed when the Goto 260 instruction is enabled. Up to 128 Goto instructions and

GOTO

LBL

K aaa

64 LBL instructions can be used in the program. DS Used HPP Used

Operand Data Type Constant

K

DL240 Range

DL250-1 Range aaa aaa

DL260 Range aaa

1-FFFF

1-FFFF

1-FFFF

In the following example, when C7 is on, all the program logic between the GOTO and the corresponding LBL instruction (designated with the same constant Kaaa value) will be skipped. The instructions being skipped will not be executed by the CPU. DirectSOFT C7

Handheld Programmer Keystrokes K5 GOTO

$

SHFT

STR SHFT

G 6

O INST# B

$

1

STR X1

C2 OUT

GX OUT

SHFT LBL

$

K5

SHFT

L B ANDST 1 F

STR GX OUT X5

5 C 2

C

H 2

7

MLR

O INST#

T

ENT F 5

ENT C

C 2

L ANDST

2

ENT

F 5

ENT

ENT ENT

Y2 OUT

DL205 User Manual, 4th Edition, Rev. A

ENT

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

5–179

Page 402

Chapter 5: Standard RLL Instructions - Program Control

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A B C D

For/Next (FOR) (NEXT) For and Next instructions are used to execute a 230 The section of ladder logic between the For and Next 240 instruction a specified numbers of times. When the For 250-1 instruction is enabled, the program will loop the specified 260 number of times. If the For instruction is not energized DS Used HPP Used

5–180 the section of ladder logic between the For and Next instructions is not executed. For/Next instructions cannot be nested. Up to 64 For/Next loops may be used in a program. If the maximum number of For / Next loops is exceeded, error E413 will occur. The normal I/O update and CPU housekeeping is suspended while executing the For/Next loop. The program scan can increase significantly, depending on the amount of times the logic between the For and Next instruction is executed. With the exception of immediate I/O instructions, I/O will not be updated until the program execution is completed for that scan. Depending on the length of time required to complete the program execution, it may be necessary to reset the watch dog timer inside of the For/Next loop using the RSTWT instruction. Operand Data Type V-memory Constant

A aaa FOR

NEXT

DL240 Range

DL250-1 Range

A aaa aaa aaa

V K

All (See page 3 - 54) 1-9999

All (See page 3 - 55) 1-9999

All (See page 3 - 56) 1-9999

DL205 User Manual, 4th Edition, Rev. A

DL260 Range