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

The text of a manual · part 32 of 60

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

Pages 289 to 298 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 289

Section 5-19

Conversion Instructions Example

The status of 00101 determines the sign of the BCD source word in the following example. If 00101 is ON, then the source word is negative. When 00100 is turned ON, the BCD source data in LR 02 is converted to signed binary according to the parameters in DM 0000 to DM 0004. The result is then written to DM 0100. (In the second conversion, the signed binary equivalent of –1035 is less than the lower limit specified in DM 0004, so the lower limit is written to DM 0100.) 25313 (Always ON) CLC(41) 00101 STC(40) 00100 @SCL3(––)

Address

Instruction

00000 00001 00002 00101 00004 00005

LD CLC(41) LD STC(40) LD SCL3(––)

LR 02

Operands 25313 00101 00100 LR DM DM

DM 0000 DM 0100

02 0000 0100

Signed hex. CY=1

CY=0 DM 0000 DM 0001 DM 0002 DM 0003 DM 0004

6 3 0005 BCD

0005 0003 0006 07FF F800

LR 02

0100

LR 02

1035

DM 0100

00CD

DM 0100

F800

5-19-13 HOURS-TO-SECONDS – SEC(––) Ladder Symbols

Operand Data Areas

SEC(––)

@SEC(––)

S

S

R

R

000

000

S: Beginning source word (BCD) IR, SR, AR, DM, HR, TC, LR R: Beginning result word (BCD) IR, SR, AR, DM, HR, TC, LR 000: No function 000

Limitations

This instruction is available in the CQM1 only. S and S+1 must be within the same data area. R and R+1 must be within the same data area. S and S+1 must be BCD and must be in the proper hours/minutes/seconds format. DM 6143 to DM 6655 cannot be used for R.

Description

SEC(––) is used to convert time notation in hours/minutes/seconds to an equivalent in just seconds. For the source data, the seconds are designated in bits 00 through 07 and the minutes are designated in bits 08 through 15 of S. The hours are designated in S+1. The maximum is thus 9,999 hours, 59 minutes, and 59 seconds. The result is output to R and R+1. The maximum obtainable value is 35,999,999 seconds.

271

Page 290

Section 5-19

Conversion Instructions Flags

ER:

S and S+1 or R and R+1 are not in the same data area. S and/or S+1 do not contain BCD. Number of seconds and/or minutes exceeds 59. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) ON when the result is zero.

EQ: Example

When 00000 is OFF (i.e., when the execution condition is ON), the following instruction would convert the hours, minutes, and seconds given in HR 12 and HR 13 to seconds and store the results in DM 0100 and DM 0101 as shown.

00000 SEC(––) HR 12 DM 0100 000

HR 12 HR 13

3 2

2 8

0 1

7 5

2,815 hrs, 32 min, 07 s

DM 0100 DM 0101

5 1

9 0

2 1

7 3

10,135,927 s

Address

Instruction

00000 00001

LD NOT SEC(––)

Operands 00000 HR DM

12 0100 000

5-19-14 SECONDS-TO-HOURS – HMS(––) Operand Data Areas

Ladder Symbols HMS(––)

@HMS(––)

S

S

R

R

000

000

S: Beginning source word (BCD) IR, SR, AR, DM, HR, TC, LR R: Beginning result word (BCD) IR, SR, AR, DM, HR, TC, LR 000: No function 000

Limitations

This instruction is available in the CQM1 only. S and S+1 must be within the same data area. R and R+1 must be within the same data area. S and S+1 must be BCD and must be between 0 and 35,999,999 seconds. DM 6143 to DM 6655 cannot be used for R.

Description

HMS(––) is used to convert time notation in seconds to an equivalent in hours/ minutes/seconds. The number of seconds designated in S and S+1 is converted to hours/minutes/ seconds and placed in R and R+1. For the results, the seconds are placed in bits 00 through 07 and the minutes are placed in bits 08 through 15 of R. The hours are placed in R+1. The maximum is 9,999 hours, 59 minutes, and 59 seconds.

Flags

ER:

EQ:

272

S and S+1 or R and R+1 are not in the same data area. S and/or S+1 do not contain BCD or exceed 36,000,000 seconds. Indirectly addressed DM word is non-existent. (Content of DM word is not BCD, or the DM area boundary has been exceeded.) ON when the result is zero.

Page 291

Section 5-19

Conversion Instructions Example

When 00000 is OFF (i.e., when the execution condition is ON), the following instruction would convert the seconds given in HR 12 and HR 13 to hours, minutes, and seconds and store the results in DM 0100 and DM 0101 as shown.

00000 HMS(––) HR 12 DM 0100

Address

Instruction

00000 00001

LD NOT HMS(––)

Operands 00000 HR DM

000

HR 12 HR 13

5 1

9 0

2 1

7 3

DM 0100 DM 0101

3 2

2 8

0 1

7 5

10,135,927 s

12 0100 000

2,815 hrs, 32 min, 07 s

5-19-15 COLUMN-TO-LINE – LINE(––) Operand Data Areas

Ladder Symbols

S: First word of 16 word source set LINE(––)

@LINE(––)

S

S

C

C

D

D

IR, SR, AR, DM, HR, TC, LR C: Column bit designator (BCD) IR, SR, AR, DM, HR, TC, LR, # D: Destination word IR, SR, AR, DM, HR, TC, LR

Limitations

This instruction is available in the CQM1 only. S and S+15 must be in the same data area. C must be BCD between #0000 and #0015. DM 6144 to DM 6655 cannot be used for D.

Description

When the execution condition is OFF, LINE(––) is not executed. When the execution condition is ON, LINE(––) copies bit column C from the 16-word set (S to S+15) to the 16 bits of word D (00 to 15). C

Bit 15

Bit 00

S S+1 S+2 S+3 . . .

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

S+15

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

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

. . .

. . .

. . . Bit 15

D

Flags

ER:

0

Bit 00

. . .

0 1 1 1

The column bit designator C is not BCD, or it is specifying a non-existent bit (i.e., bit specification must be between 00 and 15).

273

Page 292

Section 5-19

Conversion Instructions

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

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

The following example shows how to use LINE(––) to move bit column 07 from the set (IR 100 to IR 115) to DM 0100.

00000 LINE(––)

Address

Instruction

00000 00001

LD LINE(––)

100 #0007

Operands 00000

DM 0100

# DM

100 0007 0100

5-19-16 LINE-TO-COLUMN – COLM(––) Operand Data Areas

Ladder Symbols

S: Source word COLM(––)

@COLM(––)

S

S

D

D

C

C

IR, SR, AR, DM, HR, TC, LR D: First word of the destination set IR, SR, AR, DM, HR, TC LR C: Column bit designator (BCD) IR, SR, AR, DM, HR, TC, LR, #

Limitations

This instruction is available in the CQM1 only. D and D+15 must be in the same data area. DM 6129 to DM 6655 cannot be used for D. C must be BCD between #0000 and #0015.

Description

When the execution condition is OFF, COLM(––) is not executed. When the execution condition is ON, COLM(––) copies the 16 bits of word S (00 to 15) to the column of bits, C, of the 16-word set (D to D+15). Bit 15

S

0

Bit 00

.

.

.

.

.

.

0 1 1 1

C

Bit 15

D D+1 D+2 D+3 . . .

.

Bit 00

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

. . .

. . .

. . .

D+15 0 1 1 1 0 0 0 1 1 0 0 0 1 0 1 0 Flags

274

ER:

The bit designator C is not BCD, or it is specifying a non-existent bit (i.e., bit specification must be between 00 and 15).

Page 293

Section 5-19

Conversion Instructions

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

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

The following example shows how to use COLM(––) to move the contents of word DM 0100 (00 to 15) to bit column 15 of the set (DM 0200 to DM 0215).

00000 COLM(––) DM 0100 DM 0200

Address

Instruction

00000 00001

LD COLM(––)

Operands 00000 DM DM #

#0015

5-19-17

0100 0200 0015

2’S COMPLEMENT – NEG(––) Ladder Symbols

Operand Data Areas

NEG(––)

@NEG(––)

S

S

R

R

000

000

S: Source word IR, SR, AR, DM, HR, TC, LR, # R: Result word IR, SR, AR, DM, HR, LR 000 Not used. Set to 000.

Limitations

This instruction is available in the only. DM 6144 to DM 6655 cannot be used for R.

Description

Converts the four-digit hexadecimal content of the source word (S) to its 2’s complement and outputs the result to the result word (R). This operation is effectively the same as subtracting S from 0000 and outputting the result to R; it will calculate the absolute value of negative signed binary data. If the content of S is 0000, the content of R will also be 0000 after execution and EQ (SR 25506) will be turned on. If the content of S is 8000, the content of R will also be 8000 after execution and UF (SR 25405) will be turned on. Note Refer to 1-10 Calculating with Signed Binary Data for more details.

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 the content of R is zero after execution; otherwise OFF.

UF:

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

275

Page 294

Section 5-19

Conversion Instructions Example

The following example shows how to use NEG(––) to find the 2’s complement of the content of DM 0005 and output the result to IR 105. 00100 NEG(––) DM 0005 105

Address

Instruction

00000 00001

LD NEG(––)

Operands 00100 DM

000

0005 105 000

#0000

– 5-19-18

#001F

Content of DM 0005.

#FFE1

Output to IR 105.

DOUBLE 2’S COMPLEMENT – NEGL(––) Ladder Symbols

Operand Data Areas

NEGL(––)

@NEGL(––)

S

S

R

R

000

000

S: First source word IR, SR, AR, DM, HR, TC, LR R: First result word IR, SR, AR, DM, HR, LR 000 Not used. Set to 000.

Limitations

This instruction is available in the only. DM 6143 to DM 6655 cannot be used for R. S and S+1 must be in the same data area, as must R and R+1.

Description

Converts the eight-digit hexadecimal content of the source words (S and S+1) to its 2’s complement and outputs the result to the result words (R and R+1). This operation is effectively the same as subtracting the eight-digit content S and S+1 from $0000 0000 and outputting the result to R and R+1; it will calculate the absolute value of negative signed binary data. If the content of S is 0000 0000, the content of R will also be 0000 0000 after execution and EQ (SR 25506) will be turned on. If the content of S is 8000 0000, the content of R will also be 8000 0000 after execution and UF (SR 25405) will be turned on. Note Refer to 1-10 Calculating with Signed Binary Data for more details.

Flags

276

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 the content of R+1, R is zero after execution; otherwise OFF.

UF:

ON when the content of S+1, S is 8000 0000; otherwise OFF.

Page 295

Section 5-19

Conversion Instructions Example

The following example shows how to use NEGL(––) to find the 2’s complement of the hexadecimal value in IR 151, IR 150 (001F FFFF) and output the result to HR 04, HR 03. 00000 NEGL(––) 150 LR 03

Address

Instruction

00000 00001

LD NEGL(––)

Operands 00000

000

LR

0000 S+1: IR 151

–

001F R+1: LR 04 FFE0

150 03 000

0000 S: IR 150 FFFF R: LR 03 0001

277

Page 296

Section 5-20

BCD Calculation Instructions

5-20 BCD Calculation Instructions 5-20-1 SET CARRY – STC(40) Ladder Symbols STC(40)

@STC(40)

When the execution condition is OFF, STC(40) is not executed. When the execution condition is ON, STC(40) turns ON CY (SR 25504). Note Refer to Appendix B Error and Arithmetic Flag Operation for a table listing the instructions that affect CY.

5-20-2 CLEAR CARRY – CLC(41) Ladder Symbols CLC(41)

@CLC(41)

When the execution condition is OFF, CLC(41) is not executed. When the execution condition is ON, CLC(41) turns OFF CY (SR 25504). CLEAR CARRY is used to reset (turn OFF) CY (SR 25504) to “0.” Note Refer to Appendix B Error and Arithmetic Flag Operation for a table listing the instructions that affect CY.

5-20-3 BCD ADD – ADD(30) Operand Data Areas Au: Augend word (BCD)

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR, # ADD(30)

@ADD(30)

Au

Au

Ad

Ad

R

R

Ad: Addend word (BCD) IR, SR, AR, DM, HR, TC, LR, # R: Result word IR, SR, AR, DM, HR, LR

Limitations

DM 6144 to DM 6655 cannot be used for R.

Description

When the execution condition is OFF, ADD(30) is not executed. When the execution condition is ON, ADD(30) adds the contents of Au, Ad, and CY, and places the result in R. CY will be set if the result is greater than 9999.

Au + Ad + CY Flags

ER:

CY

R

Au and/or Ad 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.)

278

CY:

ON when there is a carry in the result.

EQ:

ON when the result is 0.

Page 297

Section 5-20

BCD Calculation Instructions

If 00002 is ON, the program represented by the following diagram clears CY with CLC(41), adds the content of IR 030 to a constant (6103), places the result in DM 0100, and then moves either all zeros or 0001 into DM 0101 depending on the status of CY (25504). This ensures that any carry from the last digit is preserved in R+1 so that the entire result can be later handled as eight-digit data.

Example

TR 0 00002 CLC(41)

ADD(30)

Address

Instruction

00000 00001 00002 00003

LD OUT CLC(41) AND(30)

TR

030

# DM

#6103 DM 0100 25504 MOV(21)

00004 00005

AND MOV(21)

#0001 DM 0101 25504 MOV(21)

Operands

00006 00007 00008

LD AND NOT MOV(21)

#0000 DM 0101

00002 0

030 6103 0100 25504

# DM TR

0001 0101 0 25504

# DM

0000 0101

Although two ADD(30) can be used together to perform eight-digit BCD addition, ADDL(54) is designed specifically for this purpose.

5-20-4 BCD SUBTRACT – SUB(31) Operand Data Areas Mi: Minuend word (BCD)

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR, # SUB(31)

@SUB(31)

Mi

Mi

Su

Su

R

R

Su: Subtrahend word (BCD) IR, SR, AR, DM, HR, TC, LR, # R: Result word IR, SR, AR, DM, HR, LR

Limitations

DM 6144 to DM 6655 cannot be used for R.

Description

When the execution condition is OFF, SUB(31) is not executed. When the execution condition is ON, SUB(31) subtracts the contents of Su and CY from Mi, and places the result in R. If the result is negative, CY is set and the 10’s complement of the actual result is placed in R. To convert the 10’s complement to the true result, subtract the content of R from zero (see example below).

Mi – Su – CY Flags

ER:

CY

R

Mi and/or Su 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.)

CY:

ON when the result is negative, i.e., when Mi is less than Su plus CY.

EQ:

ON when the result is 0.

279

Page 298

Section 5-20

BCD Calculation Instructions ! Caution

Example

Be sure to clear the carry flag with CLC(41) before executing SUB(31) if its previous status is not required, and check the status of CY after doing a subtraction with SUB(31). If CY is ON as a result of executing SUB(31) (i.e., if the result is negative), the result is output as the 10’s complement of the true answer. To convert the output result to the true value, subtract the value in R from 0. When 00002 is ON, the following ladder program clears CY, subtracts the contents of DM 0100 and CY from the content of 010 and places the result in HR 10. If CY is set by executing SUB(31), the result in HR 10 is subtracted from zero (note that CLC(41) is again required to obtain an accurate result), the result is placed back in HR 10, and HR 1100 is turned ON to indicate a negative result. If CY is not set by executing SUB(31), the result is positive, the second subtraction is not performed, and HR 1100 is not turned ON. HR 1100 is programmed as a self-maintaining bit so that a change in the status of CY will not turn it OFF when the program is rescanned. In this example, differentiated forms of SUB(31) are used so that the subtraction operation is performed only once each time 00002 is turned ON. When another subtraction operation is to be performed, 00002 will need to be turned OFF for at least one cycle (resetting HR 1100) and then turned back ON.

TR 0 00002 CLC(41)

@SUB(31) 010

First subtraction

DM 0100 HR 10 25504 CLC(41)

@SUB(31) #0000 HR 10 HR 10 25504 HR 1100

HR 1100

280

Turned ON to indicate negative result.

Second subtraction