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

The text of a manual · part 23 of 60

C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 214 to 223

Pages 214 to 223 of 586

The original document is the PDF (3.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 Omron C200HE-CPU42-E

Page 214

Section 5-17

Data Comparison

5-17-3 DOUBLE COMPARE – CMPL(60) Ladder Symbols

Operand Data Areas Cp1: First word of first compare word pair

CMPL(60) IR, SR, AR, DM, HR, TC, LR Cp1 Cp2: First word of second compare word pair Cp2

IR, SR, AR, DM, HR, TC, LR

000 (fixed)

Limitations

Cp1 and Cp1+1 must be in the same data area, as must Cp2 and Cp2+1.

Description

When the execution condition is OFF, CMPL(60) is not executed. When the execution condition is ON, CMPL(60) joins the 4-digit hexadecimal content of Cp1+1 with that of Cp1, and that of Cp2+1 with that of Cp2 to create two 8-digit hexadecimal numbers, Cp+1,Cp1 and Cp2+1,Cp2. The two 8-digit numbers are then compared and the result is output to the GR, EQ, and LE flags in the SR area.

Precautions

Placing other instructions between CMPL(60) and the operation which accesses the EQ, LE, and GR flags may change the status of these flags. Be sure to access them before the desired status is changed. CMPL(60) cannot be used to compare signed binary data. Use CPSL(––) instead. Refer to 5-17-9 DOUBLE SIGNED BINARY COMPARE – CPSL(––) for details.

Flags

ER:

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

GR:

ON if Cp1+1,Cp1 is greater than Cp2+1,Cp2.

EQ:

ON if Cp1+1,Cp1 equals Cp2+1,Cp2.

LE:

ON if Cp1+1,Cp1 is less than Cp2+1,Cp2.

196

Page 215

Section 5-17

Data Comparison

The following example shows how to save the comparison result immediately. If the content of HR 10, HR 09 is greater than that of 011, 010, then 00200 is turned ON; if the two contents are equal, 00201 is turned ON; if content of HR 10, HR 09 is less than that of 011, 010, then 00202 is turned ON. In some applications, only one of the three OUTs would be necessary, making the use of TR 0 unnecessary. With this type of programming, 00200, 00201, and 00202 are changed only when CMPL(60) is executed.

Example: Saving CMPL(60) Results

00000

TR 0 CMPL(60) HR 09 010 --25505 00200

Greater Than

00201

Equal

00202

Less Than

25506

25507

Address

Instruction

00000 00001 00002

LD OUT CMPL(60)

Operands

TR HR

00003

AND

Address

Instruction

00004 00005 00006 00007 00008 00009 00010

OUT LD AND OUT LD AND OUT

00000 0 09 010 25505

Operands

TR

TR

00200 0 25506 00201 0 25507 00202

5-17-4 BLOCK COMPARE – BCMP(68) Operand Data Areas CD: Compare data

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR, # BCMP(68)

@BCMP(68)

CD

CD

CB

CB

R

R

CB: First comparison block word

Limitations

IR, DM, HR, TC, LR R: Result word IR, SR, AR, DM, HR, TC, LR

Each lower limit word in the comparison block must be less than or equal to the upper limit.

197

Page 216

Section 5-17

Data Comparison Description

When the execution condition is OFF, BCMP(68) is not executed. When the execution condition is ON, BCMP(68) compares CD to the ranges defined by a block consisting of of CB, CB+1, CB+2, ..., CB+31. Each range is defined by two words, the first one providing the lower limit and the second word providing the upper limit. If CD is found to be within any of these ranges (inclusive of the upper and lower limits), the corresponding bit in R is set. The comparisons that are made and the corresponding bit in R that is set for each true comparison are shown below. The rest of the bits in R will be turned OFF. CB ≤ CD ≤ CB+1 Bit 00 CB+2 ≤ CD ≤ CB+3 Bit 01 CB+4 ≤ CD ≤ CB+5 Bit 02 CB+6 ≤ CD ≤ CB+7 Bit 03 CB+8 ≤ CD ≤ CB+9 Bit 04 CB+10 ≤ CD ≤ CB+11 Bit 05 CB+12 ≤ CD ≤ CB+13 Bit 06 CB+14 ≤ CD ≤ CB+15 Bit 07 CB+16 ≤ CD ≤ CB+17 Bit 08 CB+18 ≤ CD ≤ CB+19 Bit 09 CB+20 ≤ CD ≤ CB+21 Bit 10 CB+22 ≤ CD ≤ CB+23 Bit 11 CB+24 ≤ CD ≤ CB+25 Bit 12 CB+26 ≤ CD ≤ CB+27 Bit 13 CB+28 ≤ CD ≤ CB+29 Bit 14 CB+30 ≤ CD ≤ CB+31 Bit 15 Normally the first word in the range is less than the second, but if the first word in the range is greater than the second, the corresponding bit in R will be turned OFF when CD is outside of the range defined by the two words, as shown in the following diagram. CB

CB + 1

0000

9999 CB+1

0000

Flags

ER:

CB

9999

The comparison block (i.e., CB through CB+31) exceeds the data area. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)

198

Page 217

Section 5-17

Data Comparison Example

The following example shows the comparisons made and the results provided for BCMP(68). Here, the comparison is made during each cycle when 00000 is ON.

00000 BCMP(68)

Address

Instruction

00000 00001

LD BCMP(68)

001 HR 10

Operands 00000

HR 05

HR HR

CD 001 001

Lower limits 0210

HR 10 HR 12 HR 14 HR 16 HR 18 HR 20 HR 22 HR 24 HR 26 HR 28 HR 30 HR 32 HR 34 HR 36 HR 38 HR 40

Compare data in IR 001 (which contains 0210) with the given ranges.

Upper limits

0000 0101 0201 0301 0401 0501 0601 0701 0801 0901 1001 1101 1201 1301 1401 1501

HR 11 HR 13 HR 15 HR 17 HR 19 HR 21 HR 23 HR 25 HR 27 HR 29 HR 31 HR 33 HR 35 HR 37 HR 39 HR 41

001 10 05

R: HR 05 0100 0200 0300 0400 0500 0600 0700 0800 0900 1000 1100 1200 1300 1400 1500 1600

HR 0500 HR 0501 HR 0502 HR 0503 HR 0504 HR 0505 HR 0506 HR 0507 HR 0508 HR 0509 HR 0510 HR 0511 HR 0512 HR 0513 HR 0514 HR 0515

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

5-17-5 TABLE COMPARE – TCMP(85) Operand Data Areas CD: Compare data

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR, # TCMP(85)

@TCMP(85)

CD

CD

TB

TB

R

R

TB: First comparison table word IR, AR, DM, HR, TC, LR R: Result word IR, SR, AR, DM, HR, TC, LR

Limitations

TB and TB+15 must be in the same data area.

Description

When the execution condition is OFF, TCMP(85) is not executed. When the execution condition is ON, TCMP(85) compares CD to the content of TB, TB+1, TB+2, ..., and TB+15. If CD is equal to the content of any of these words, the corresponding bit in R is set, e.g., if the CD equals the content of TB, bit 00 is turned ON, if it equals that of TB+1, bit 01 is turned ON, etc. The rest of the bits in R will be turned OFF.

Flags

ER:

EQ:

The comparison table (i.e., TB through TB+15) exceeds the data area. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.) ON if none of the words in the comparison table match CD, i.e., all of the bits in R are OFF.

199

Page 218

Section 5-17

Data Comparison Example

The following example shows the comparisons made and the results provided for TCMP(85). Here, the comparison is made during each cycle when 00000 is ON.

00000 TCMP(85) 001

Address

Instruction

00000 00001

LD TCMP(85)

Operands 00000

HR 10 HR 05

CD: 001 001

Upper limits 0210

Compare the data in IR 001 with the given ranges.

HR 10 HR 11 HR 12 HR 13 HR 14 HR 15 HR 16 HR 17 HR 18 HR 19 HR 20 HR 21 HR 22 HR 23 HR 24 HR 25

HR HR

001 10 05

R: HR 05 0100 0200 0210 0400 0500 0600 0210 0800 0900 1000 0210 1200 1300 1400 0210 1600

HR 0500 HR 0501 HR 0502 HR 0503 HR 0504 HR 0505 HR 0506 HR 0507 HR 0508 HR 0509 HR 0510 HR 0511 HR 0512 HR 0513 HR 0514 HR 0515

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

5-17-6 AREA RANGE COMPARE – ZCP(88) Operand Data Areas CD: Compare data

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR, # ZCP(88) LL: Lower limit of range CD

IR, SR, AR, DM, HR, TC, LR, #

LL

UL: Upper limit of range

UL

IR, SR, AR, DM, HR, TC, LR, #

Limitations

LL must be less than or equal to UL.

Description

When the execution condition is OFF, ZCP(88) is not executed. When the execution condition is ON, ZCP(88) compares CD to the range defined by lower limit LL and upper limit UL and outputs the result to the GR, EQ, and LE flags in the SR area. The resulting flag status is shown in the following table. Flag status

Comparison result

200

CD < LL

GR (SR 25505) EQ (SR 25506) 0 0

LE (SR 25507) 1

LL ≤ CD ≤ UL

0

1

0

UL < CD

1

0

0

Page 219

Section 5-17

Data Comparison Precautions

Placing other instructions between ZCP(88) and the operation which accesses the EQ, LE, and GR flags may change the status of these flags. Be sure to access them before the desired status is changed.

Flags

ER:

Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.) LL is greater than UL. ON if LL ≤ CD ≤ UL

LE:

ON if CD < LL.

GR:

ON if CD > UL.

The following example shows how to save the comparison result immediately. If IR 100 > AB1F, IR 00200 is turned ON; if #0010 ≤ IR 100 ≤ AB1F, IR 00201 is turned ON; if IR 100 < 0010, IR 00202 is turned ON.

Example: Saving ZCP(88) Results

00000

EQ:

TR 0 ZCP(88) IR 100 #0010 #AB1F

25505 00200

Greater Than (above range)

00201

Equal (within range)

00202

Less Than (below range)

25506

25507

Address

Instruction

00000 00001 00002

LD OUT ZCP(88)

Operands

TR IR # #

00003

AND

00000 0 100 0010 AB1F 25505

Address

Instruction

00004 00005 00006 00007 00008 00009 00010

OUT LD AND OUT LD AND OUT

Operands

TR

TR

00200 0 25506 00201 0 25507 00202

5-17-7 DOUBLE AREA RANGE COMPARE – ZCPL(––) Operand Data Areas Ladder Symbols

CD: Compare data IR, SR, AR, DM, HR, LR

ZCPL(––) LL: Lower limit of range CD LL UL

Limitations

IR, SR, AR, DM, HR, LR UL: Upper limit of range IR, SR, AR, DM, HR, LR

The 8-digit value in LL+1,LL must be less than or equal to UL+1,UL. CD and CD+1 must be in the same data area, as must LL and LL+1, and UL and UL+1.

201

Page 220

Section 5-17

Data Comparison Description

When the execution condition is OFF, ZCPL(––) is not executed. When the execution condition is ON, ZCPL(––) compares the 8-digit value in CD, CD+1 to the range defined by lower limit LL+1,LL and upper limit UL+1,UL and outputs the result to the GR, EQ, and LE flags in the SR area. The resulting flag status is shown in the following table. Flag status

Comparison result GR (SR 25505)

EQ (SR 25506)

LE (SR 25507)

CD , CD+1< LL+1,LL

0

0

1

LL+1,LL ≤ CD, CD+1 ≤ UL+1,UL

0

1

0

UL+1,UL < CD, CD+1

1

0

0

Precautions

Placing other instructions between ZCPL(––) and the operation which accesses the EQ, LE, and GR flags may change the status of these flags. Be sure to access them before the desired status is changed.

Flags

ER:

Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.) LL+1,LL is greater than UL+1,UL.

Example

EQ:

ON if LL+1,LL ≤ CD, CD+1 ≤ UL+1,UL

LE:

ON if CD, CD+1 < LL+1,LL.

GR:

ON if CD, CD+1 > UL+1,UL.

Refer to 5-17-6 AREA RANGE COMPARE – ZCP(88) for an example. The only difference between ZCP(88) and ZCPL(––) is the number of digits in the comparison data.

5-17-8 SIGNED BINARY COMPARE – CPS(––) Operand Data Areas Ladder Symbols

Cp1: First compare word IR, SR, AR, DM, HR, TC, LR, #

CPS(––) Cp2: Second compare word Cp1 Cp2 000

Description

IR, SR, AR, DM, HR, TC, LR, # Third operand: Set to 000. ---

When the execution condition is OFF, CPS(––) is not executed. When the execution condition is ON, CPS(––) compares the 16-bit (4-digit) signed binary contents in Cp1 and Cp2 and outputs the result to the GR, EQ, and LE flags in the SR area. Note

1. Refer to page 27 for details on 16-bit signed binary data. 2. Refer to 5-17-2 Compare – CMP(20) for details on saving comparison results.

Precautions

202

Placing other instructions between CPS(––) and the operation which accesses the EQ, LE, and GR flags may change the status of these flags. Be sure to access them before the desired status is changed.

Page 221

Section 5-17

Data Comparison Flags

ER:

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

EQ:

ON if Cp1 equals Cp2.

LE:

ON if Cp1 is less than Cp2.

GR:

ON if Cp1 is greater than Cp2. Flag status

Comparison result Cp1 < Cp2

GR (SR 25505) EQ (SR 25506) 0 0

LE (SR 25507) 1

Cp1 = Cp2

0

1

0

Cp1 > Cp2

1

0

0

5-17-9 DOUBLE SIGNED BINARY COMPARE – CPSL(––) Operand Data Areas Cp1: First compare word

Ladder Symbols

IR, SR, AR, DM, HR, TC, LR CPSL(––) Cp2: Second compare word Cp1

IR, SR, AR, DM, HR, TC, LR

Cp2

Third operand: Set to 000.

000

---

Limitations

Cp1 and Cp1+1 must be in the same data area, as must Cp2 and Cp2+1.

Description

When the execution condition is OFF, CPSL(––) is not executed. When the execution condition is ON, CPSL(––) compares the 32-bit (8-digit) signed binary contents in Cp1+1, Cp1 and Cp2+1, Cp2 and outputs the result to the GR, EQ, and LE flags in the SR area. Note

1. Refer to page 27 for details on 32-bit signed binary data. 2. Refer to 5-17-2 Compare – CMP(20) for details on saving comparison results.

Precautions

Placing other instructions between CPSL(––) and the operation which accesses the EQ, LE, and GR flags may change the status of these flags. Be sure to access them before the desired status is changed.

Flags

ER:

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

EQ:

ON if Cp1+1, Cp1 equals Cp2+1, Cp2.

LE:

ON if Cp1+1, Cp1 is less than Cp2+1, Cp2.

GR:

ON if Cp1+1, Cp1 is greater than Cp2+1, Cp2. Flag status

Comparison result Cp1+1, Cp1 < Cp2+1, Cp2

GR (SR 25505) EQ (SR 25506) 0 0

LE (SR 25507) 1

Cp1+1, Cp1 = Cp2+1, Cp2

0

1

0

Cp1+1, Cp1 > Cp2+1, Cp2

1

0

0

203

Page 222

Section 5-18

Data Conversion

5-18 Data Conversion The conversion instructions convert word data that is in one format into another format and output the converted data to specified result word(s). Conversions are available to convert between binary (hexadecimal) and BCD, to 7-segment display data, to ASCII, and between multiplexed and non-multiplexed data. All of these instructions change only the content of the words to which converted data is being moved, i.e., the content of source words is the same before and after execution of any of the conversion instructions.

5-18-1 BCD-TO-BINARY – BIN(23) Ladder Symbols

Operand Data Areas S: Source word (BCD)

BIN(23)

@BIN(23)

S

S

R

R

IR, SR, AR, DM, HR, TC, LR R: Result word

Description

IR, SR, AR, DM, HR, LR

When the execution condition is OFF, BIN(23) is not executed. When the execution condition is ON, BIN(23) converts the BCD content of S into the numerically equivalent binary bits, and outputs the binary value to R. Only the content of R is changed; the content of S is left unchanged. BCD

S

Binary

R

BIN(23) can be used to convert BCD to binary so that displays on the Programming Console or any other programming device will appear in hexadecimal rather than decimal. It can also be used to convert to binary to perform binary arithmetic operations rather than BCD arithmetic operations, e.g., when BCD and binary values must be added. Flags

ER:

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

204

EQ:

ON when the result is zero.

N:

25402 is always OFF.

Page 223

Section 5-18

Data Conversion

5-18-2 DOUBLE BCD-TO-DOUBLE BINARY – BINL(58) Ladder Symbols

Operand Data Areas S: First source word (BCD)

BINL(58)

@BINL(58)

S

S

R

R

IR, SR, AR, DM, HR, TC, LR R: First result word

Description

Flags

IR, SR, AR, DM, HR, LR

When the execution condition is OFF, BINL(58) is not executed. When the execution condition is ON, BINL(58) converts an eight-digit number in S and S+1 into 32-bit binary data, and outputs the converted data to R and R+1.

ER:

BCD

S+1

S

Binary

R+1

R

The contents of S and/or S+1 words are not BCD. Indirectly addressed DM word is non-existent. (Content of word is not BCD, or the DM area boundary has been exceeded.)

EQ:

ON when the result is zero.

N:

25402 is always OFF.

5-18-3 BINARY-TO-BCD – BCD(24) Ladder Symbols

Operand Data Areas S: Source word (binary)

BCD(24)

@BCD(24)

S

S

R

R

IR, SR, AR, DM, HR, LR R: Result word

Description

IR, SR, AR, DM, HR, LR

BCD(24) converts the binary (hexadecimal) content of S into the numerically equivalent BCD bits, and outputs the BCD bits to R. Only the content of R is changed; the content of S is left unchanged. Binary

S

BCD

R

BCD(24) can be used to convert binary to BCD so that displays on the Programming Console or any other programming device will appear in decimal rather than hexadecimal. It can also be used to convert to BCD to perform BCD arithmetic operations rather than binary arithmetic operations, e.g., when BCD and binary values must be added.

205