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

The text of a manual · part 38 of 68

DL405 User Manual: Chapter 5: Standard RLL Instructions, pages 333 to 342

Pages 333 to 342 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 333

5--161

Standard RLL Instructions Table Instructions

The following diagram shows the scan-by-scan results of the execution for our example program. The table counter is set to 2 initially, and it will automatically increment from 2 -- 6 as the instruction is executed. Notice how SP56 comes on when the table counter is 6, which is equal to the table length. Plus, although our example does not show it, we are assuming that there is another part of the program that changes the value in V1500 (data source) prior to the execution of the ATT instruction. Example of Execution Scan N Before ATT Execution Table

After ATT Execution Table Counter

V1401

0

5

0

0

1

V1402

9

9

9

9

2

V1403

3

0

7

4

3

V1404

8

9

8

9

4

V1405

1

0

1

0

5

V1406

2

0

4

6

6

V1407

X

X

X

X

0

0

0

2 V1400

Data Source 1

2

3

4 V1500

SP56 SP56 = OFF

V1401

1

2

3

4

1

V1402

0

5

0

0

2

V1403

9

9

9

9

3

V1404

3

0

7

4

4

V1405

8

9

8

9

5

V1406

1

0

1

0

6

V1407

X

X

X

X

S S

Scan N+1

Before ATT Execution

1

2

3

4

1

V1402

0

5

0

0

2

V1403

9

9

9

9

3

V1404

3

0

7

4

4

V1405

8

9

8

9

5

V1406

1

0

1

0

6

V1407

X

X

X

X

0

0

0

3 V1400

Data Source 5

6

7

8 V1500

SP56 SP56 = OFF

Before ATT Execution

V1401

5

6

7

8

1

V1402

1

2

3

4

2

V1403

0

5

0

0

3

V1404

9

9

9

9

4

V1405

3

0

7

4

5

V1406

8

9

8

9

6

V1407

X

X

X

X

5

6

7

8

1

V1402

1

2

3

4

2

V1403

0

5

0

0

3

V1404

9

9

9

9

4

V1405

3

0

7

4

5

V1406

8

9

8

9

6

V1407

X

X

X

X

0

0

0

Data Source 4

3

3

4 V1500

SP56 SP56 = OFF

Scan N+3

Table

V1401

4

3

4

3

1

5

6

7

8

2

V1403

1

2

3

4

3

V1404

0

5

0

0

4

V1405

9

9

9

9

5

V1406

3

0

7

4

6

V1407

X

X

X

X

4

3

4

3

1

V1402

5

6

7

8

2

V1403

1

2

3

4

3

V1404

0

5

0

0

4

V1405

9

9

9

9

5

V1406

3

0

7

4

6

V1407

X

X

X

X

S S

0

0

0

Table Counter (Automatically Incremented) 5

6

0 7

8

Data Source 7

7

7

7 V1500

SP56 SP56 = OFF

0

4 V1400

6

7

8 V1500

SP56 SP56 = OFF

Table Counter (Automatically Incremented) 4

3

0 4

3

0

0

5 V1400

Data Source 4

3

4

3 V1500

SP56 SP56 = OFF Discard Bucket 8989

V1401

7

7

7

7

1

V1402

4

3

4

3

2

V1403

5

6

7

8

3

V1404

1

2

3

4

4

V1405

0

5

0

0

5

V1406

9

9

9

9

6

V1407

X

X

X

X

S S

0

Data Source 5

Table Counter (Automatically Incremented)

Table

5 V1400

V1500

7

7

0 7

7

0

0

6 V1400

Data Source 7

7

7

7 V1500

SP56 Discard Bucket 3074

SP56 = ON until end of scan or next instruction that uses SP56

DL405 User Manual, 4th Edition

Standard RLL Instructions

V1401

4

SP56 = OFF

After ATT Execution Table Counter

3

Discard Bucket

S S

Before ATT Execution

2

1010

V1402

S S

3 V1400

SP56

Table

4 V1400

0

Data Source 1

After ATT Execution Table Counter

V1401

4

0

2046

S S

Table

0 3

Table

S S

Scan N+2

2

After ATT Execution Table Counter

V1401

1

Discard Bucket

S S

Table

Table Counter (Automatically Incremented)

Table

Page 334

5--162

Standard RLL Instructions Table Instructions

Move Memory Cartridge/ Load Label (MOVMC/LDLBL)

430 440 450

DS

HPP

The Move Memory Cartridge instruction is used to copy data between V--memory and program ladder memory. The Load Label instruction is only used with the MOVMC instruction when copying data from program ladder memory to V--memory. To copy data between V--memory and program ladder memory, the function parameters are loaded into the first two levels of the accumulator stack and the accumulator by two additional instructions. Listed below are the steps necessary to program the Move Memory Cartridge and Load Label functions.

MOVMC A aaa

LDLBL K aaa

Step 1: - Load the number of words (255 maximum) to be copied into the second level of the accumulator stack. This must be a hex value, 0 to FF. Step 2: - Load the offset for the data label area (in HEX) in the program ladder memory and the beginning of the V--memory block into the first level of the accumulator stack. Step 3: - Load the source data label (LDLBL Kaaa) into the accumulator when copying data from ladder memory to V--memory. Load the source address into the accumulator when copying data from V--memory to ladder memory. The value will be copied from this location. If the source address is a V--memory location, the value must be entered in HEX. Step 4: - Insert the MOVMC instruction which specifies destination (Aaaa). The value will be copied to this location. Operand Data Type

DL440 Range

DL450 Range

A aaa aaa

V--memory

V

All (See p. 3--41)

All (See p. 3--42)

Constant

K

1--FFFF

1--FFFF

Discrete Bit Flags

Description

SP53 on if there is a table pointer error.

Standard RLL Instructions

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

WARNING: The offset for this usage of the instruction starts at 0, but may be any number that does not result in data outside of the source data area being copied into the destination table. When an offset is outside of the source information boundaries, unknown data values will be transferred into the destination table.

DL405 User Manual, 4th Edition

Page 335

Standard RLL Instructions Table Instructions

In the following example, data is copied from a Data Label Area to V--memory. When X1 is on, the constant value (K4) is loaded into the accumulator using the Load instruction. This value specifies the length of the destination table and is placed in the second stack location after the next Load and Load Label (LDLBL) instructions are executed. The constant value (K0) is loaded into the accumulator using the Load instruction. This value specifies the offset for the source and the destination table, and is placed in the first stack location after the LDLBL instruction is executed. The source address where data is being copied from is loaded into the accumulator using the LDLBL instruction. The MOVMC instruction specifies the destination table starting location and executes the copying of data from the source Data Label Area to V--memory.

Copy Data From a Data Label Area to V--memory

430 440 450

DS

HPP

5--163

DirectSOFT X1

Load the value 4 into the accumulator specifying the number of locations to be copied.

LD K4

K0

Load the value 0 into the accumulator specifying the offset for source and destination locations

K1

Load the value 1 into the accumulator specifying the Data Label Area K1 as the starting address of the data to be copied.

LD

LDLBL

MOVMC V1400

V1400 is the destination starting address for the data to be copied.

END

DLBL K1 NCON K 1234 Handheld Programmer Keystrokes (for MOVMC portion only) NCON K 4532 NCON K 6151 NCON K 8845

STR

X(IN)

1

LD

K(CON)

4

LD

K(CON)

0

LD

SHFT

L

B

L

SHFT

SHFT

M

O

V

M

C

SHFT

V

1

4

0

0

K(CON)

1

NCON K 7777

DL405 User Manual, 4th Edition

Standard RLL Instructions

WARNING: The offset for this usage of the instruction starts at 0, but may be any number that does not result in data outside of the source data area being copied into the destination table. When an offset is outside of the source information boundaries, then unknown data values will be transferred into the destination table.

Page 336

5--164

Standard RLL Instructions Table Instructions

The following diagram shows the result of our example. The offset is equal to zero and four words will be copied into the Data Label area. Example of Execution Offset = 0, move 4 words Before MOVMC Execution

After MOVMC Execution

Destination

Data Label Area DLBL K1

V1400

0

9

0

0

V1401

0

5

0

0

N

C O N

V1402

9

9

9

9

K

1

V1403

3

0

7

4

N

C O N 4

Start here

2

V1404

8

9

8

9

K

V1405

1

0

1

0

N

C O N

V1406

X

X

X

X

K

6

S S

5

3

1

3 5

N

C O N

K

8

N

C O N

K

7

8

7

4

7

Destination

4 2 1 5

1

2

3

4

V1400

4

5

3

2

V1401

6

1

5

1

V1402

8

8

4

5

V1403

8

9

8

9

V1404

1

0

1

0

V1405

X

X

X

X

V1406

Start here

S S

7

The example is fairly straightforward when an offset of zero is used. However, it is also helpful for you to understand the results that would have been obtained if different offset values (1 and 2) were used. Notice how the offset is used for both the data label (source) and the destination table. Also, notice how an improper offset (two in this case) can result in unknown values being copied into the destination table. Offset = 1, move 4 words Before MOVMC Execution

After MOVMC Execution

Destination

Data Label Area DLBL K1

V1400

0

9

0

0

V1401

0

5

0

0

V1402

9

9

9

9

V1403

3

0

7

4

V1404

8

9

8

Offset

N

C O N

K

1

2

3

N

C O N

9

K

4

Start here

5

3

V1405

1

0

1

0

N

C O N

V1406

X

X

X

X

K

6

S S

1

5

N

C O N

K

8

8

4

N

C O N

K

7

7

7

Destination

4 2 1 5

0

9

0

0

V1400

4

5

3

2

V1401

6

1

5

1

V1402

8

8

4

5

V1403

7

7

7

7

V1404

1

0

1

0

V1405

X

X

X

X

V1406

Start here

S S

7

Standard RLL Instructions

Offset = 2, move 4 words Before MOVMC Execution

After MOVMC Execution

Destination

Data Label Area DLBL K1

V1400

0

9

0

0

V1401

0

5

0

0

V1402

9

9

9

9

V1403

3

0

7

4

N

C O N

V1404

8

9

8

9

K

4

V1405

1

0

1

0

V1406

X

X

X

Offset

Start here

X

S S

Since there is no NCON, the CPU does not know where to get the data. Unknown values will be copied into V1405.

DL405 User Manual, 4th Edition

N

C O N

K

1

2 5

3 3

N

C O N

K

6

N

C O N

K

8

1 8

5 4

Destination

4 2 1 5

N

C O N

K

7

7

7

7

?

?

?

?

?

0

9

0

0

V1400

0

5

0

0

V1401

6

1

5

1

V1402

8

8

4

5

V1403

7

7

7

7

V1404

?

?

?

?

V1405

X

X

X

X

V1406

S S

Start here

Page 337

Standard RLL Instructions Table Instructions

NOTE: You must use a RAM cartridge for this example to work. In this example, data is copied from V -memory to a data label area. When X1 is on, the constant value (K4) is loaded into the accumulator using the Load instruction. This value specifies the length of the destination table and is placed in the second stack location after the next Load and Load Address instructions are executed. The constant value (K0) is loaded into the accumulator using the Load instruction. This value specifies the offset for the source and destination table, and is placed in the first stack location after the Load Address instruction is executed. The source address data is being copied from is loaded into the accumulator using the Load Address instruction. The MOVMC instruction specifies the destination starting location and executes the copying of data from V--memory to the data label area.

Copy Data From V--memory to a Data Label Area

430 440 450

DS

HPP

5--165

Handheld Programmer Keystrokes (for MOVMC portion only)

DirectSOFT X1

LD K4 Load the value 4 into the accumulator specifying the number of locations to be copied. LD

STR

X(IN)

1

LD

K(CON)

4

LD

K(CON)

0

LD

SHFT

A

OCT

1

4

0

0

SHFT

M

O

V

M

C

SHFT

K(CON)

1

K0 Load the value 0 into the accumulator specifying the offset for source and destination locations. LDA O 1400 Convert octal 1400 to HEX 300 and load the value into the accumulator. This specifies the source location where the data will be copied from MOVMC

Note: This instruction works only with the RAM cartridge. It does not work with the EEPROM.

K1 K1 is the data label destination area where the data will be copied to END

DLBL K1 NCON K 1234 NCON K 4532 NCON K 6151 NCON K 8845

K 7777

WARNING: The offset for this usage of the instruction starts at 0. If the offset (or the specified data table range) is large enough to cause data to be copied from V--memory to beyond the end of the DLBL area, then anything after the specified DLBL area will be replaced with invalid instructions.

DL405 User Manual, 4th Edition

Standard RLL Instructions

NCON

Page 338

5--166

Standard RLL Instructions Table Instructions

The following diagram shows the result of our example. The offset is equal to zero and four words will be copied into the Data Label area. Example of Execution Offset = 0, move 4 words Before MOVMC Execution

After MOVMC Execution

Data Label Area DLBL K1 N

C O N

K

1

N

C O N

2 5

3

K

4

N

C O N 1

3

K

6

N

C O N 8

5

K

8

N

C O N

K

7

7

4

7

Data Label Area DLBL K1

Destination Start here

4 2 1

0

5

0

0

V1400

N

9

9

9

9

V1401

K

0

3

0

7

4

V1402

N

C O N

8

9

8

9

V1403

K

9

1

0

1

0

V1404

N

C O N

C O N 5 9

0 9

2

0

4

6

V1405

K

3

X

X

X

X

V1406

N

C O N

5

S S

7

0 9

7

K

8

N

C O N

K

7

7

8

7

0

Start here

9 4 9

7

The example is fairly straightforward when an offset of zero is used. However, it is also helpful for you to understand the results that would have been obtained if different offset values (1 and 2) were used. Notice how the offset is used for both the V--memory data table (source) and the Data Label area. Also, notice how an improper offset (two in this case) can result in invalid instructions being written over any instructions that follow the Data Label. Offset = 1, move 4 words Before MOVMC Execution

After MOVMC Execution

Data Label Area DLBL K1 N

C O N

K

1

N

C O N

K

4

N

C O N

K

6

N

C O N

2 5 1 8

3 3 5

K

8

N

C O N

K

7

7

4

7

4

Data Label Area DLBL K1

Destination Offset

0

5

0

0

V1400

N

C O N

Start here

9

9

9

9

V1401

K

1

3

0

7

4

V1402

N

C O N

8

9

8

9

V1403

K

9

1

0

1

0

V1404

N

C O N

2

0

4

6

V1405

K

3

X

X

X

X

V1406

N

C O N

2 1 5

S S

7

2 9 0 9

3 9 7

K

8

N

C O N

K

1

0

8

1

4 9

Offset

Start here

4 9

0

Offset = 2, move 4 words Before MOVMC Execution

After MOVMC Execution

Standard RLL Instructions

Data Label Area DLBL K1 N

C O N

K

1

N

C O N

2 5

3

K

4

N

C O N

K

6

N

C O N

K

8

N

C O N

K

7

1 8 7

3 5 4 7

4

Offset Start here

2 1 5 7

Data Label Area DLBL K1

Destination 0

5

0

0

V1400

N

9

9

9

9

V1401

K

1

3

0

7

4

V1402

N

C O N

8

9

8

9

V1403

K

4

1

0

1

0

V1404

N

C O N

2

0

4

6

V1405

K

3

X

X

X

X

V1406

N

C O N

S S

C O N 2 5 0 9

3 3 7

K

8

N

C O N

K

1

0

8 1

4 2 4 9 0

Invalid Instruction

DL405 User Manual, 4th Edition

Offset

Start here

Page 339

Standard RLL Instructions Table Instructions

Set Bit (SETBIT)

The Set Bit instruction sets a single bit to one within a range of V-memory locations.

5--167

SETBIT A aaa

430 440 450

DS

HPP

Reset Bit (RSTBIT)

The Reset Bit instruction resets a single bit to zero within a range of V-memory locations.

RSTBIT A aaa

430 440 450

DS

HPP

The following description applies to both the Set Bit and Reset Bit table instructions. 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. 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. Step 3:, Insert the Set Bit or Reset Bit instruction. This specifies the reference for the bit number of the bit you want to set or reset. The bit number is in octal, and the first bit in the table is number “0”. Helpful hint:, Remember that each V--memory location contains 16 bits. So, the bits of the first word of the table are numbered from 0 to 17 octal. For example, if the table length is six words, then 6 words = (6 x 16) bits, = 96 bits (decimal), or 140 octal. The permissible range of bit reference numbers would be 0 to 137 octal. Flag 53 will be set if the bit specified is outside the range of the table. Operand Data Type

DL450 Range aaa

V--memory

V

All (See p. 3--42)

Octal Address

O

0--7777

Discrete Bit Flags

Description

SP53 on when the bit number which is referenced in the Set Bit or Reset Bit exceeds the range of the table

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

MSB

V3000

LSB

16 bits MSB

V3001

LSB

1 1 1 1 11 1 1 7 6 5 4 3 2 1 0 7 6 5 4 32 1 0

DL405 User Manual, 4th Edition

Standard RLL Instructions

For example, suppose we have a table starting at V3000 that is two words long, as shown to the right. Each word in the table contains 16 bits, or 0 to 17 in octal. To set bit 12 in the second word, we use its octal reference (bit 14). Then we compute the bit’s octal address from the start of the table, so 17 + 14 = 34 octal. The following program shows how to set the bit as shown to a “1”.

Page 340

5--168

Standard RLL Instructions Table Instructions In this ladder example, we will use input X0 to trigger the Set Bit operation. First, we will load the table length (2 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 Set Bit (or Reset Bit) instruction and specify the octal address of the bit (bit 34), referenced from the table beginning. 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

Set bit 34 (octal) in the table to a ”1”.

SETBIT O 34

Standard RLL Instructions

Handheld Programmer Keystrokes

DL405 User Manual, 4th Edition

STR

X(IN)

0

LD

K(CON)

2

LD

SHFT

A

OCT

3

0

0

0

SET

SHFT

B

I

T

OCT

3

4

Page 341

Standard RLL Instructions Table Instructions

Table Shift Left (TSHFL)

The Table Shift Left instruction shifts all the bits in a V-memory table to the left, the specified number of bit positions.

TSHFL A aaa

The Table Shift Right instruction shifts all the bits in a V-memory table to the right, a specified number of bit positions.

TSHFR A aaa

5--169

430 440 450

DS

HPP

Table Shift Right (TSHFR)

430 440 450

DS

HPP

The following description applies to both the Table Shift Left and Table Shift Right instructions. A table is just a range of V-memory locations. The Table Shift Left and Table Shift Right instructions shift bits serially throughout the entire table. Bits are shifted out the end of one word and into the opposite end of an adjacent word. At the ends of the table, bits are either discarded, or zeros are shifted into the table. The example tables below are arbitrarily four words long. Table Shift Left

Table Shift Right Shift in zeros

V--xxxx

Discard bits

V--xxxx +1

V--xxxx +2 Discard bits

Shift in zeros

Operand Data Type

DL450 Range aaa

V--memory

V

All (See p. 3--42)

DL405 User Manual, 4th Edition

Standard RLL Instructions

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. 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. Step 3:, Insert the Table Shift Left or Table shift Right instruction. This specifies the number of bit positions you wish to shift the entire table. The number of bit positions must be in octal. Helpful hint:, Remember that each V--memory location contains 16 bits. So, the bits of the first word of the table are numbered from 0 to 17 octal. If you want to shift the entire table by 20 bits, that is 24 octal. Flag 53 will be set if the number of bits to be shifted is larger than the total bits contained within the table. Flag 67 will be set if the last bit shifted (just before it is discarded) is a “1”.

Page 342

5--170

Standard RLL Instructions Table Instructions

Discrete Bit Flags

Description

SP53 on when the number of bits to be shifted is larger than the total bits contained within the table

SP67 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, or another instruction that uses the same flag is executed. The example table to the right contains BCD data as shown (for demonstration purposes). Suppose we want to do a table shift right by 3 BCD digits (12 bits). Converting to octal, 12 bits is 14 octal. Using the Table Shift Right instruction and specifying a shift by octal 14, we have the resulting table shown at the far right. Notice that the 2--3--4 sequence has been discarded, and the 0--0--0 sequence has been shifted in at the bottom.

V3000

V3000

1 2 3 4

6 7 8 1

5 6 7 8

1 2 2 5

1 1 2 2

3 4 4 1

3 3 4 4

5 6 6 3

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 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 O 3000

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

TSHFR O 14

Standard RLL Instructions

Handheld Programmer Keystrokes

DL405 User Manual, 4th Edition

STR

X(IN)

0

LD

K(CON)

5

LD

SHFT

A

OCT

3

0

0

0

SHFT

T

S

H

F

R

OCT

1

4