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

The text of a manual · part 33 of 53

DL06 Micro PLC User Manual, Volume 1 of 2, pages 320 to 329

Pages 320 to 329 of 524

The original document is the PDF (6.4 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 Direct Logic DL06 and Koyo DL06 D0-06DD1

Page 320

Chapter 5: Standard RLL Instructions - Table Instructions Discrete Bit Flags

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

SP53 SP67

Description On when the number of bits to be shifted is larger than the total bits contained within the table On when the last bit shifted (just before it is discarded) is a “1.”

NOTE: Status flags are only valid until:, the end of the scan, another instruction that uses the same flag is executed.

V 3000 V 3000 The example table to the right contains BCD data as shown (for demonstration 1 2 3 4 6 7 8 1 purposes). Suppose we want to do a table shift right by 3 BCD digits (12 bits). 5 6 7 8 1 2 2 5 Converting to octal, 12 bits is 14 octal. Using the Table Shift Right instruction and specifying a shift by octal 14, we have 1 1 2 2 3 4 4 1 the resulting table shown at the far right. Notice that the 2–3–4 sequence has been 3 3 4 4 5 6 6 3 discarded, and the 0–0–0 sequence has been shifted in at the bottom. 5 5 6 6 0 0 0 5 The following ladder example assumes the data at V3000 to V3004 already exists as shown above. We will use input X0 to trigger the Table Shift Right operation. First, we will load the table length (5 words) into the accumulator stack. Next, we load the starting address into the accumulator. Since V3000 is an octal number we have to convert it to hex by using the LDA command. Finally, we use the Table Shift Right instruction and specify the number of bits to be shifted (12 decimal), which is 14 octal. DirectSOFT 32 5 DirectSOFT X0

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

LD K5

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

LDA 0 3000

Do a table shift right by 12 bits, which is 14 octal.

TSHFR 0 14

Handheld Programmer Keystrokes $

A STR

0

SHFT

L ANDST

D

SHFT

L ANDST

D

SHFT

T MLR

ENT PREV

3 A

F 5 D

3

0

SHFT

S RST

H

A

A

3

0

5

R ORN

F 7

ENT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

A 0

0 NEXT

ENT B

E 1

4

ENT

Page 321

Chapter 5: Standard RLL Instructions - Table Instructions

AND Move (ANDMOV) DS5 HPP

DS5 HPP

DS5 HPP

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.

ANDMO V A aaa

1 2 OR Move (ORMOV) The Or Move instruction copies data from a table to the specified ORMOV 3 A aaa memory location, ORing each word with the accumulator contents as it is written. 4 Exclusive OR Move (XORMOV) The Exclusive OR Move instruction copies data from a table to the XO R MO V specified memory location, XORing each word with the A aaa 5 accumulator value as it is written. The following description applies to the AND Move, OR Move, and Exclusive OR Move 6 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 7 accumulator contents as the new table is written. Step 1: Load the length of the table (number of V-memory locations) into the first 8 level of the accumulator stack. This parameter must be a HEX value, 0 to FF. Step 2: Load the starting V-memory location for the table into the accumulator. This 9 parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. Step 3: Load the BCD/hex bit pattern into the accumulator which will be logically 10 combined with the table contents as they are copied. Step 4: Insert the AND Move, OR Move, or XOR Move instruction. This specifies 11 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 DL06 Range aaa 13 The example table to the right contains 14 V 3000 V 3100 BCD data as shown (for demonstration ANDMOV 3 3 3 3 2 2 2 2 purposes). Suppose we want to move a K 6666 A table of two words at V3000 and AND it with K6666. The copy of the table at F F F F 6 6 6 6 V3100 shows the result of the AND B operation for each word. The program on the next page performs the ANDMOV operation example above. It assumes C 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 D LDA instruction. Then we load the data into the accumulator to be ANDed with the table. Used Used

Used Used

Used Used

....................................A V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V

See memory map

In the ANDMOV command, we specify the table destination, V3100.

DL06 Micro PLC User Manual, 3rd Edition Rev. A

5–167

Page 322

Chapter 5: Standard RLL Instructions - Table Instructions DirectSOFT 5

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

X0

LD K2

Handheld Programmer Keystrokes $ STR

A 0

SHFT

D L ANDST 3

SHFT

D L ANDST 3

SHFT

D L ANDST 3

V AND

SHFT

M ORST

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

ENT PREV A

C 2 D

0

LDA A

A

3 PREV

O INST#

ENT

0

G

G 6 D

G 6

B 3

ENT

0

G

6

V AND

A 0

6 A

1

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

ENT A

0

0

ENT

LD K6666

The example to the right shows a table of two words at V3000 Load the constant value 6666 (Hex.) into the lower and logically ORs it with K8888. The copy of the table at 16 bits of the accumulator. V3100 shows the result of the OR operation for each word. ANDMOV 0 3100 The program to the right performs the ORMOV example above. Copy the table to V3100, It assumes that the data in the table at V3000 – V3001 already ANDing its contents with the accumulator as it is written. exists. First we load the table length (two words) into the V 3000 V 3100 accumulator. Next we load the starting address of the MOV 9 9 9 9 source table, using the LDA instruction. Then we load the 1 1 1 1 OR K 8888 data into the accumulator to be ORed with the table. In 9 9 9 9 the ORMOV command, we specify the table destination, 1 1 1 1 DirectSOFT 32 DirectSOFT 5 V3100. X0

LD

Handheld Programmer Keystrokes A

$ STR

0

SHFT

L D ANDST 3

SHFT

D L ANDST 3

SHFT

L D ANDST 3

Q OR

SHFT

M ORST

K2

ENT PREV A

C

0

A 3

PREV O INST#

ENT

2 D

V AND

I

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

0 I

8

A 0

I 8

D

8 A

1

LDA

ENT

0 3000

I 8

B 3

0

ENT A

0

0

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

ENT

LD K8888

The example to the right shows a table of two words at V3000 and logically 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.

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.

V 3000 1 1 1 1 1 1 1 1

DL06 Micro PLC User Manual, 3rd Edition Rev. A

V 3100 X OR MOV K 3333

2 2 2 2 2 2 2 2

Page 323

Chapter 5: Standard RLL Instructions - Table Instructions

Find Block (FINDB) The Find Block instruction searches for an occurrence of a specified block of values in a V-memory table. The function parameters are loaded into the first and second levels of the accumulator stack and the accumulator by three additional instructions. If the block is found, its starting address will be stored in the accumulator. If the block is not found, flag SP53 will be set.

1 F INDB A aaa 2 3 Operand Data Type DL06 Range 4 aaa 5 Discrete Bit Flags Description 6 The steps listed below are the steps necessary to program the Find Block function. 7 Step 1: Load the number of bytes in the block to be located. This parameter must be a HEX value, 0 to FF. 8 Step 2: Load the length of a table (number of words) to be searched. The Find Block will search multiple tables that are adjacent in V-memory. This parameter 9 must be a HEX value, 0 to FF. Step 3: Load the ending location for all the tables into the accumulator. This 10 parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. 11 Step 4: Load the table starting 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. 12 Step 5: Insert the Find Block instruction. This specifies the starting location of the block of data you are trying to locate. 13 S tart Addr. 14 Number Table 1 of words A Table 2 S tart Addr. Table 3 Number B Block of bytes C Table n D

DS5

Used

HPP

N/A

....................................A V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P

SP56

See memory map See memory map

On when the specified block is not found.

E nd Addr.

DL06 Micro PLC User Manual, 3rd Edition Rev. A

5–169

Page 324

Chapter 5: Standard RLL Instructions - Table Instructions

Swap (SWAP)

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

DS5

Used

HPP

Used

5–170

S WAP

The Swap instruction exchanges the A aaa data in two tables of equal length. 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. This parameter must be a HEX value. You can use the LDA instruction to convert an octal address to hex. 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. The example to the right shows a table of two words at V3000. We will swap its contents Operand Data Type

DL06 Range aaa

V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V

See memory map

V 3000 with another table of two words at 3100 by using the Swap instruction. The required ladder program is given below.

V 3100

1 2 3 4

S WAP

5 6 7 8

A B C D 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 5 DirectSOFT 32 X0

LD K2

LDA 0 3000

SWAP 0 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

3 A

ENT

A 0

A 0

D CV

0 B

3

ENT A

1

A 0

0

DL06 Micro PLC User Manual, 3rd Edition Rev. A

ENT

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

Convert octal 3000 to HEX and load the value into the accumulator. This is the table beginning. Swap the contents of the table in the previous instruction with the one at V3100.

Page 325

Chapter 5: Standard RLL Instructions - Clock/Calendar Instructions

Clock/Calendar Instructions Date (DATE) DS5

Used

HPP

Used

The Date instruction can be used to set the date in the CPU. DAT E The instruction requires two consecutive V-memory locations V aaa (Vaaa) to set the date. If the values in the specified locations are not valid, the date will not be set. The current date can be read from 4 consecutive V-memory locations (V7771–V7774). 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. V-memory Location (BCD) Date Range (READ Only) Year Month Day Day of Week

0-99

V7774

1-12

V7773

1-31

V7772

0-06 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

DL06 Range aaa

V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V

See memory map

DirectSOFT DirectSOFT 32 5

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

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

0

3

GX OUT

SHFT

D

SHFT

D

A

3

3 0

B

T MLR

NEXT

A

PREV

J

A

A

0 9

4

0

Year

ENT E

4

A

0

B

V2000 1

Month 1

0

3

Day

0

1

Day of Week

ENT

ENT C

3 0

NEXT

3 1

Format

E

2 4

0

C

0 2

A A

0 0

ENT A

0

A

0

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

ENT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

5–171

Page 326

Chapter 5: Standard RLL Instructions - Clock/Calendar Instructions

Time (TIME)

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

DS5

Used

HPP

Used

5–172

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

T IME V aaa

Date

Range

VMemory Location (BCD) (READ Only)

1/100 seconds (10ms) Seconds Minutes Hour

0-99

V7747

0-59

V7766

0-59

V7767

0-23

V7770

Operand Data Type

DL06 Range aaa

V-memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . V

See memory map

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 DirectSOFT 325

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 V-memory locations (V7766-V7770)

LDD K73000

OUTD V2000

Format

V2000

V2001

V2001 TIME

0

V2000

NEXT

NEXT

SHFT

L ANDST

D

D

A

D

A

STR

0

3

GX OUT

SHFT

SHFT

T MLR

3

NEXT

3 B

0

1

D

SHFT

A

PREV

H

A

A

2 I 8

0

ENT D

7

A

A 0

3

Hour

A 0

V2000 7

0

ENT

ENT C

3

NEXT

0

Not Used

Handheld Programmer Keystrokes $

0

M ORST

0 E

A 0

0 C

4

ENT A

2

A 0

DL06 Micro PLC User Manual, 3rd Edition Rev. A

A 0

0

ENT

3

0

0

0

Minutes Seconds

Page 327

Chapter 5: Standard RLL Instructions - CPU Control Instructions

CPU Control Instructions No Operation (NOP) DS5

Used

HPP

Used

NOP

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

DirectSOFT 5 Direct SOFT32

N TMR

SHFT NOP

O INST#

P CV

ENT

End (END) DS5

Used

HPP

Used

The End instruction marks the termination point of the normal END program scan. An End instruction is required at the end of the main program body. If the End instruction is omitted an error will occur and the CPU will not enter the Run Mode. Data labels, subroutines and interrupt routines are placed after the End instruction. The End instruction is not conditional; therefore, no input contact is allowed. DirectSOFT 5 Direct SOFT32

Handheld Programmer Keystrokes SHFT END

E 4

N TMR

D

ENT

3

Stop (STOP) DS5

Used

HPP

Used

The Stop instruction changes the operational mode of the CPU from Run to Program (Stop) mode. This instruction is typically used to stop PLC operation in an error condition. In the following example, when C0 turns on, the CPU will stop operation and switch to the program mode. DirectSOFT32 5

STOP

Handheld Programmer Keystrokes $

C0

STR STOP SHFT

Discrete Bit Flags SP16 SP53

S RST

SHFT

C 2

A 0

SHFT

T MLR

O INST#

ENT P CV

ENT

Description On when the DL06 goes into the TERM_PRG mode. On when the DL06 goes into the PRG mode.

DL06 Micro PLC User Manual, 3rd Edition Rev. A

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

Page 328

Chapter 5: Standard RLL Instructions - CPU Control Instructions

Reset Watch Dog Timer (RSTWT)

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

DS5

Used

HPP

Used

The Reset Watch Dog Timer instruction resets the CPU scan timer. The default setting for the watch dog timer is 200ms. RSTWT Scan times very seldom exceed 200ms, but it is possible. For/next loops, subroutines, interrupt routines, and table instructions can be programmed such that the scan becomes longer than 200ms. When instructions are used in a manner 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. Direct SOFT 32 DirectSOFT 5

Handheld Programmer Keystrokes SHFT

R ORN

RSTWT

5–174 DL06 Micro PLC User Manual, 2nd Ed., 3/04

S RST

T MLR

W ANDN

T MLR

ENT

Page 329

Chapter 5: Standard RLL Instructions - Program Control Instructions

Program Control Instructions Goto Label (GOTO) (LBL) DS5

Used

HPP

Used

The Goto / Label skips all instructions between the Goto and the corresponding LBL instruction. The operand value for the Goto and the corresponding LBL instruction are the same. The logic between Goto and LBL instruction is not executed when the Goto instruction is enabled. Up to 256 Goto instructions and 256 LBL instructions can be used in the program.

K aaa GOTO

LBL

Operand Data Type

K aaa

DL06 Range aaa

Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . K

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 5 DirectS 32

Handheld Programmer Keys trokes C7

K5 GOTO

$ S HF T $

X1

C2 OUT

S TR

GX OUT

S HF T LBL

$

K5

G 6

C

H 2

7

MLR

O INS T#

O INS T#

T

B

E NT

1

S HF T

L B ANDS T 1 F

S TR GX OUT

X5

S HF T

S TR

5 C 2

C

E NT F 5

C 2

L ANDS T

E NT

2

F 5

E NT

E NT E NT

Y2 OUT

DL06 Micro PLC User Manual, 3rd Edition Rev. A

E NT

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

5–175