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

The text of a manual · part 28 of 60

SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual: SECTION 5 Instruction Set, pages 249 to 258

Pages 249 to 258 of 520, from SYSMAC CQM1/CPM1/CPM1A/SRM1 Programmable Controllers Programming Manual

The original document is the PDF (2.1 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 Omron CQM1-CPU21

Page 249

Section 5-16

Shift Instructions Description

When the execution condition is OFF, ASFT(17) does nothing and the program moves to the next instruction. When the execution condition is ON, ASFT(17) is used to create and control a reversible asynchronous word shift register between St and E. This register only shifts words when the next word in the register is zero, e.g., if no words in the register contain zero, nothing is shifted. Also, only one word is shifted for each word in the register that contains zero. When the contents of a word are shifted to the next word, the original word’s contents are set to zero. In essence, when the register is shifted, each zero word in the register trades places with the next word. (See Example below.) The shift direction (i.e. whether the “next word” is the next higher or the next lower word) is designated in C. C is also used to reset the register. All of any portion of the register can be reset by designating the desired portion with St and E.

Control Word

Bits 00 through 12 of C are not used. Bit 13 is the shift direction: turn bit 13 ON to shift down (toward lower addressed words) and OFF to shift up (toward higher addressed words). Bit 14 is the Shift Enable Bit: turn bit 14 ON to enable shift register operation according to bit 13 and OFF to disable the register. Bit 15 is the Reset bit: the register will be reset (set to zero) between St and E when ASFT(17) is executed with bit 15 ON. Turn bit 15 OFF for normal operation. Note If the non-differentiated form of ASFT(17) is used, data will be shifted every cycle while the execution condition is ON. Use the differentiated form to prevent this.

Flags

ER:

The St and E words are in different areas, or St is greater than E. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)

Example

The following example shows instruction ASFT(17) used to shift words in an 11-word shift register created between DM 0100 and DM 0110 with C=#6000. Non-zero data is shifted towards St (DM 0110).

00000 ASFT(17) #6000 DM 0100

Address

Instruction

00000 00001

LD ASFT(17)

Operands 00000 # DM DM

DM 0110

Before execution

After one execution

DM 0100

1234

1234

1234

DM 0101

0000

0000

2345

DM 0102

0000

2345

3456

DM 0103

2345

0000

4567

DM 0104

3456

3456

5678

DM 0105

0000

4567

6789

DM 0106

4567

0000

789A

DM 0107

5678

5678

0000

DM 0108

6789

6789

0000

DM 0109

0000

789A

0000

DM 0110

789A

0000

0000

6000 0100 0110

After seven executions

Note The zeroes are shifted “upward” if C=4000, and the entire shift register is set to zero if C=8000.

231

Page 250

Section 5-17

Data Movement Instructions

5-17 Data Movement Instructions 5-17-1 MOVE – MOV(21) Ladder Symbols

Operand Data Areas S: Source word

MOV(21)

@MOV(21)

S

S

D

D

IR, SR, AR, DM, HR, TC, LR, # D: Destination word IR, SR, AR, DM, HR, LR

Limitations

DM 6144 to DM 6655 cannot be used for D.

Description

When the execution condition is OFF, MOV(21) is not executed. When the execution condition is ON, MOV(21) copies the content of S to D. Source word

Destination word Bit status not changed.

Precautions

TC numbers cannot be designated as D to change the PV of the timer or counter. You can, however, easily change the PV of a timer or a counter by using BSET(71).

Flags

ER:

Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)

EQ:

ON when all zeros are transferred to D.

Example

The following example shows @MOV(21) being used to copy the content of IR 001 to HR 05 when IR 00000 goes from OFF to ON.

00000 @MOV(21) 001 HR 05

Address

Instruction

00000 00001

LD @MOV(21)

Operands 00000

HR

IR 000

0 1 1 1 0 0 1 1 1 0 0 0 0 1 0 1

HR 05

0 1 1 1 0 0 1 1 1 0 0 0 0 1 0 1

001 05

5-17-2 MOVE NOT – MVN(22) Ladder Symbols

Operand Data Areas S: Source word

MVN(22)

@MVN(22)

S

S

D

D

IR, SR, AR, DM, HR, TC, LR, # D: Destination word

Limitations

232

DM 6144 to DM 6655 cannot be used for D.

IR, SR, AR, DM, HR, LR

Page 251

Section 5-17

Data Movement Instructions Description

When the execution condition is OFF, MVN(22) is not executed. When the execution condition is ON, MVN(22) transfers the inverted content of S (specified word or four-digit hexadecimal constant) to D, i.e., for each ON bit in S, the corresponding bit in D is turned OFF, and for each OFF bit in S, the corresponding bit in D is turned ON. Source word

Destination word Bit status inverted.

Precautions

TC numbers cannot be designated as D to change the PV of the timer or counter. However, these can be easily changed using BSET(71).

Flags

ER:

Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)

EQ:

ON when all zeros are transferred to D.

Example

The following example shows @MVN(22) being used to copy the complement of #F8C5 to DM 0010 when IR 00001 goes from OFF to ON.

00001 @MVN(22) #F8C5 DM 0010

Address

Instruction

00000 00001

LD @MOV(21)

Operands 00001 # DM

#F8C5

1 1 1 1 1 0 0 0 1 1 0 0 0 1 0 1

DM 0010

0 0 0 0 0 1 1 1 0 0 1 1 1 0 1 0

F8C5 0010

5-17-3 BLOCK TRANSFER – XFER(70) Operand Data Areas N: Number of words (BCD)

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR, # XFER(70)

@XFER(70)

N

N

S

S

D

D

S: Starting source word

Limitations

IR, SR, AR, DM, HR, TC, LR D: Starting destination word IR, SR, AR, DM, HR, TC, LR

S and S+N must be in the same data area, as must D and D+N. DM 6144 to DM 6655 cannot be used for D.

233

Page 252

Section 5-17

Data Movement Instructions Description

Flags

When the execution condition is OFF, XFER(70) is not executed. When the execution condition is ON, XFER(70) copies the contents of S, S+1, ..., S+N to D, D+1, ..., D+N.

ER:

S

D

3 4 5 2

3 4 5 2

S+1

D+1

3 4 5 1

3 4 5 1

S+2

D+2

3 4 2 2

3 4 2 2

S+N

D+N

6 4 5 2

6 4 5 2

N is not BCD S and S+N or D and D+N are not in the same data area. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)

5-17-4 BLOCK SET – BSET(71) Operand Data Areas S: Source data

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR, # BSET(71)

@BSET(71)

S

S

St

St

E

E

St: Starting word IR, SR AR, DM, HR, TC, LR E: End Word IR, SR, AR, DM, HR, TC, LR

Limitations

St must be less than or equal to E, and St and E must be in the same data area. DM 6144 to DM 6655 cannot be used for St or E.

Description

When the execution condition is OFF, BSET(71) is not executed. When the execution condition is ON, BSET(71) copies the content of S to all words from St through E. S

St

3 4 5 2

3 4 5 2 St+1 3 4 5 2 St+2 3 4 5 2

E 3 4 5 2

BSET(71) can be used to change timer/counter PV. (This cannot be done with MOV(21) or MVN(22).) BSET(71) can also be used to clear sections of a data area, i.e., the DM area, to prepare for executing other instructions. It can also be used to clear words by transferring all zeros.

234

Page 253

Section 5-17

Data Movement Instructions Flags

ER:

St and E are not in the same data area or St is greater than E. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)

Example

The following example shows how to use BSET(71) to copy a constant (#0000) to a block of the DM area (DM 0000 to DM 0500) when IR 00000 is ON.

00000 @BSET(71) #0000

Address

Instruction

00000 00001

LD @BSET(71)

DM 0000

Operands 00000 # DM DM

DM 0500

0000 0000 0500

5-17-5 DATA EXCHANGE – XCHG(73) Ladder Symbols

Operand Data Areas E1: Exchange word 1

XCHG(73)

@XCHG(73)

E1

E1

E2

E2

IR, SR, AR, DM, HR, TC, LR E2: Exchange word 2 IR, SR, AR, DM, HR, TC, LR

Limitations

DM 6144 to DM 6655 cannot be used for E1 or E2.

Description

When the execution condition is OFF, XCHG(73) is not executed. When the execution condition is ON, XCHG(73) exchanges the content of E1 and E2. E1

E2

If you want to exchange content of blocks whose size is greater than 1 word, use work words as an intermediate buffer to hold one of the blocks using XFER(70) three times. Flags

Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)

ER:

5-17-6 SINGLE WORD DISTRIBUTE – DIST(80) Operand Data Areas S: Source data

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR, # DIST(80)

@DIST(80)

S

S

DBs

DBs

C

C

DBs: Destination base word

Limitations

IR, SR, AR, DM, HR, TC, LR C: Control word (BCD) IR, SR, AR, DM, HR, TC, LR, #

C must be BCD. DM 6144 to DM 6655 cannot be used for DBs or C.

235

Page 254

Section 5-17

Data Movement Instructions Description

DIST(80) can be used for single-word distribution or for a stack operation depending on the content of the control word, C.

Single-word Distribution

When bits 12 to 15 of C=0 to 8, DIST(80) can be used for a single word distribute operation. The entire contents of C specifies an offset, Of. When the execution condition is OFF, DIST(80) is not executed. When the execution condition is ON, DIST(80) copies the content of S to DBs+Of, i.e., Of is added to DBs to determine the destination word.

Note DBs and DBs+Of must be in the same data area and cannot be between DM 6144 and DM 6655. Example The following example shows how to use DIST(80) to copy #00FF to HR 10 + Of. The content of LR 10 is #3005, so #00FF is copied to HR 15 (HR 10 + 5) when IR 00000 is ON. 00000 @DIST(80) #00FF

Address

Instruction

00000 00001

LD @DIST(80)

HR 10

Operands 00000 # HR LR

LR 10

LR 10

#00FF

HR 10

3 0 0 5

0 0 F F

0 0 0 0

00FF 10 10

HR 15 0 0 F F

Stack Operation

When bits 12 to 15 of C=9, DIST(80) can be used for a stack operation. The other 3 digits of C specify the number of words in the stack (000 to 999). The content of DBs is the stack pointer. When the execution condition is OFF, DIST(80) is not executed. When the execution condition is ON, DIST(80) copies the content of S to DBs+1+the content of DBs. In other words, 1 and the content of DBs are added to DBs to determine the destination word. The content of DBs is then incremented by 1. Note

236

1. DIST(80) will be executed every cycle unless the differentiated form (@DIST(80)) is used or DIST(80) is used with DIFU(13) or DIFD(14). 2. Be sure to initialize the stack pointer before using DIST(80) as a stack operation.

Page 255

Section 5-17

Data Movement Instructions

Example The following example shows how to use DIST(80) to create a stack between DM 0001 and DM 0005. DM 0000 acts as the stack pointer. 00000 @DIST(80) 001

Address

Instruction

00000 00001

LD @DIST(80)

Operands 00000

DM 0000 216

Flags

IR 001

FFFF

IR 216

9005

DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005

0000 0000 0000 0000 0000 0000

First execution

Stack pointer incremented

ER:

DM

DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005

0001 FFFF 0000 0000 0000 0000

DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005

Second execution Stack pointer incremented

001 0000 216

0002 FFFF FFFF 0000 0000 0000

The offset or stack length in the control word is not BCD. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) During stack operation, the value of the stack pointer+1 exceeds the length of the stack.

EQ:

ON when the content of S is zero; otherwise OFF.

5-17-7 DATA COLLECT – COLL(81) Operand Data Areas SBs: Source base word

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR COLL(81)

@COLL(81)

SBs

SBs

C

C

D

D

C: Control word (BCD)

Limitations

IR, SR, AR, DM, HR, TC, LR, # D: Destination word IR, SR, AR, DM, HR, TC, LR

C must be BCD. DM 6144 to DM 6655 cannot be used for D.

Description

COLL(81) can be used for data collection, an FIFO stack operation, or an LIFO stack operation depending on the content of the control word, C.

Data Collection

When bits 12 to 15 of C=0 to 7, COLL(81) is used for data collection. The entire contents of C specifies an offset, Of. When the execution condition is OFF, COLL(81) is not executed. When the execution condition is ON, COLL(81) copies the content of SBs + Of to D, i.e., Of is added to SBs to determine the source word. Note SBs and SBs+Of must be in the same data area.

237

Page 256

Section 5-17

Data Movement Instructions

Example The following example shows how to use COLL(81) to copy the content of DM 0000+Of to IR 001. The content of 010 is #0005, so the content of DM 0005 (DM 0000 + 5) is copied to IR 001 when IR 00001 is ON. 00001 @COLL(81) DM 0000

Address

Instruction

00000 00001

LD @DIST(80)

Operands 00001

010

DM

001

010

DM 0000

001

0 0 0 5

0 0 0 0

0 0 F F

0000 010 001

DM 0005 0 0 F F

FIFO Stack Operation

When bits 12 to 15 of C=9, COLL(81) can be used for an FIFO stack operation. The other 3 digits of C specify the number of words in the stack (000 to 999). The content of SBs is the stack pointer. When the execution condition is ON, COLL(81) shifts the contents of each word within the stack down by one address, finally shifting the data from SBs+1 (the first value written to the stack) to the destination word (D). The content of the stack pointer (SBs) is then decremented by one. Note COLL(81) will be executed every cycle unless the differentiated form (@COLL(81)) is used or COLL(81) is used with DIFU(13) or DIFD(14). Example The following example shows how to use COLL(81) to create a stack between DM 0001 and DM 0005. DM 0000 acts as the stack pointer. When IR 00000 goes from OFF to ON, COLL(81) shifts the contents of DM 0002 to DM 0005 down by one address, and shifts the data from DM 0001 to IR 001. The content of the stack pointer (DM 0000) is then decremented by one.

00000 @COLL(81) DM 0000

Address

Instruction

00000 00001

LD @COLL(81)

216

Operands 00000 DM

001

LIFO Stack Operation

238

IR 216

9005

DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005

0005 AAAA BBBB CCCC DDDD EEEE

Stack pointer decremented DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005

0004 BBBB CCCC DDDD EEEE EEEE

IR 001

0000 216 001

AAAA

When bits 12 to 15 of C=8, COLL(81) can be used for an LIFO stack operation. The other 3 digits of C specify the number of words in the stack (000 to 999). The content of SBs is the stack pointer.

Page 257

Section 5-17

Data Movement Instructions

When the execution condition is ON, COLL(81) copies the data from the word indicated by the stack pointer (SBs+the content of SBs) to the destination word (D). The content of the stack pointer (SBs) is then decremented by one. The stack pointer is the only word changed in the stack. Note COLL(81) will be executed every cycle unless the differentiated form (@DIST(80)) is used or DIST(80) is used with DIFU(13) or DIFD(14). Example The following example shows how to use COLL(81) to create a stack between DM 0001 and DM 0005. DM 0000 acts as the stack pointer. When IR 00000 goes from OFF to ON, COLL(81) copies the content of DM 0005 (DM 0000 + 5) to IR 001. The content of the stack pointer (DM 0000) is then decremented by one. 00000 @COLL(81) DM 0000

Address

Instruction

00000 00001

LD @COLL(81)

216

Operands 00000 DM

0000 216 001

001

Flags

IR 216

8005

DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005

0005 AAAA BBBB CCCC DDDD EEEE

ER:

Stack pointer decremented DM 0000 DM 0001 DM 0002 DM 0003 DM 0004 DM 0005

0004 AAAA BBBB CCCC DDDD EEEE

IR 001

EEEE

The offset or stack length in the control word is not BCD. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) During stack operation, the value of the stack pointer exceeds the length of the stack; an attempt was made to write to a word beyond the end of the stack.

EQ:

ON when the content of S is zero; otherwise OFF.

5-17-8 MOVE BIT – MOVB(82) Operand Data Areas S: Source word

Ladder Symbols

IR, SR, AR, DM, HR, LR, # MOVB(82)

@MOVB(82)

S

S

Bi

Bi

D

D

Bi: Bit designator (BCD)

Limitations

IR, SR, AR, DM, HR, TC, LR, # D: Destination word IR, SR, AR, DM, HR, LR

The rightmost two digits and the leftmost two digits of Bi must each be between 00 and 15. DM 6144 to DM 6655 cannot be used for Bi or D.

239

Page 258

Section 5-17

Data Movement Instructions Description

When the execution condition is OFF, MOVB(82) is not executed. When the execution condition is ON, MOVB(82) copies the specified bit of S to the specified bit in D. The bits in S and D are specified by Bi. The rightmost two digits of Bi designate the source bit; the leftmost two bits designate the destination bit. Bit 15

Bi

Bi MSB 1

2

0

1

0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 Bit 15

LSB

S

Bit 00

1

2

0

1

Bit 00

0 1 0 1 0 1 0 0 0 1 1 1 0 0 0 1

Source bit (00 to 15) Bit 15

Destination bit (00 to 15)

D Flags

ER:

Bit 00

0 1 0 0 0 1 0 0 0 1 1 1 0 0 0 1

Bi is not BCD, or it is specifying a non-existent bit (i.e., bit specification must be between 00 and 15). Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.)

5-17-9 MOVE DIGIT – MOVD(83) Operand Data Areas S: Source word

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR, # MOVD(83)

@MOVD(83)

S

S

Di

Di

D

D

Di: Digit designator (BCD) IR, SR, AR, DM, HR, TC, LR, # D: Destination word IR, SR, AR, DM, HR, TC, LR

Limitations

The rightmost three digits of Di must each be between 0 and 3. DM 6144 to DM 6655 cannot be used for Di or D.

Description

When the execution condition is OFF, MOVD(83) is not executed. When the execution condition is ON, MOVD(83) copies the content of the specified digit(s) in S to the specified digit(s) in D. Up to four digits can be transferred at one time. The first digit to be copied, the number of digits to be copied, and the first digit to receive the copy are designated in Di as shown below. Digits from S will be copied to consecutive digits in D starting from the designated first digit and continued for the designated number of digits. If the last digit is reached in either S or D, further digits are used starting back at digit 0. Digit number:

3 2 1 0

First digit in S (0 to 3) Number of digits (0 to 3) 0: 1 digit 1: 2 digits 2: 3 digits 3: 4 digits First digit in D (0 to 3) Not used. (Set to 0.)

240