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

The text of a manual · part 12 of 27

SYSMAC C20P/C28P/C40P/C60P P-type Programmable Controllers Operation Manual: SECTION 5, pages 83 to 92

Pages 83 to 92 of 211, from SYSMAC C20P/C28P/C40P/C60P P-type Programmable Controllers Operation Manual

The original document is the PDF (2.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 Omron C28P

Page 83

Section 5–11

Timer and Counter Instructions the high-speed counter, programming is easier with CNTR since an ordinary counter is decrementing.

1813 (normally ON) MOV(21) #0000 DM 32

MOV(21) #5000 DM 33

0002 (start input) HDM(98) HR 0 CNT 47

II

1814 (normally OFF)

DI

CNTR(12) 46 #9999

1810 (turns On for 1 scan upon hard reset)

R

1813 (normally ON) CMP(20) CNT 46 #0002

1906 (EQ)

HR 000 0500

In the above program example, output 0500 is turned ON when the following condition is satisfied (where S is the present count value of the high-speed counter): 20,000 ≤ S ≤ 25,000. Note In hard reset mode, program SR 1810, which turns ON for one scan time upon input of the hard reset signal, to CNTR as the reset input. Unless CNTR and CMP are programmed immediately after the high-speed counter, the correct corresponding outputs may not be produced. Packaging Machine

The high-speed counter is very useful in the following application. Here, packages are being carried on a conveyor belt at random intervals. Some of them are spaced far apart and others are clustered together, making it impossible to accurately detect and count them with photoelectric switches alone. By presetting the number of pulses generated when a single package is detected and by counting those pulses, the number of packages can be accurately counted, regardless of whether the packages are spaced or clustered. The following diagram shows the packaging system and the corresponding timing chart.

75

Page 84

Section 5–11

Timer and Counter Instructions Reflective photoelectric switch PH1 (0002) Motor 2 (M2) Rotary encoder E6A (0000) Pusher

Rear limit switch for pusher LS1 (0003) Fixed stopper Front limit switch for pusher LS2 (0004)

Packages

Upper limit switch for stopper LS3 (0005) Moving stopper Motor 1 (M1)

Lower limit switch for stopper LS4 (0006)

PH1 (0002) E6A (0000) M1 rise (0100) LS4 (0006) LS3 (0005) M2 forward (0102) LS2 (0004) LS1 (0003) M2 backward (0103) M1 fall (0101)

In this example, “x” is the number of pulses per package. To detect four packages therefore, 4x must be set as the preset value of the high-speed counter. Here is the program example for the application.

76

Page 85

Section 5–12

Data Shifting 1813 (normally ON)

MOV(21) #0905 DM 32 MOV(21) #1150 DM 33 Transfer limit values MOV(21) #1450 DM 34 MOV(21) #1550 DM 35 1815 1807

0005

0002

HDM(60) HR 0 HR 000

HR 001

0011

0006

0005

Normally counts 4 packages. When input 0011 is ON, counts 6 packages. Pushes stopper up at count-up to stop following packages

0102

Pushes packages out

0011

0003

0100

0004

0102

0004

0102

Counts pulses from encoder only when PH1 is ON

0100

0100

0005

Resets counter upon power application or at stopper operation

0003 0103

0103

Returns pusher to original position after operation

0003 DIFU(13) 1000 1000

0005

0006 0101

0101

Pushes stopper down and continues operating when pusher returns to original position

5–12 Data Shifting This section describes the instructions that are used to create and manipulate shift registers. SFT(10) creates a single- or multiple-word register that shift in a second execution condition when executed with an ON execution

77

Page 86

Section 5–12

Data Shifting condition. SFTR(84) creates a reversible shift register that is controlled through the bits in a control word. WSFT(16) creates a multiple-word register that shifts by word.

5–12–1 Shift Register – SFT(10) Ladder Symbol

Operand Data Areas St : Starting word

I SFT(10)

IR, HR

P St R

E

E : End word IR, HR

E must be less than or equal to St, and St and E must be in the same data area.

Limitations

If a bit address in one of the words used in a shift register is also used in an instruction that controls individual bit status (e.g., OUT, KEEP(11)), an error (“COIL DUPL”) will be generated when program syntax is checked on the Programming Console or another Programming Device. The program, however, will be executed as written. See Example 2: Controlling Bits in Shift Registers for a programming example that does this. SFT(10) shifts an execution condition into a shift register. SFT(10) is controlled by three execution conditions, I, P, and R. If SFT(10) is executed and 1) execution condition P is ON and was OFF the last execution and 2) R is OFF, then execution condition I is shifted into the rightmost bit of a shift register defined between St and E, i.e., if I is ON, a 1 is shifted into the register; if I is OFF, a 0 is shifted in. When I is shifted into the register, all bits previously in the register are shifted to the left and the leftmost bit of the register is lost.

Description

E

St + 1, St + 2, ...

Lost data

St

Execution condition I

The execution condition on P functions like a differentiated instruction, i.e., I will be shifted into the register only when P is ON and was OFF the last time SFT(10) was executed. If execution condition P has not changed or has gone from ON to OFF, the shift register will remain unaffected. St designates the rightmost word of the shift register; E designates the leftmost. The shift register includes both of these words and all words between them. The same word may be designated for St and E to create a 16-bit (i.e., 1-word) shift register. When execution condition R goes ON, all bits in the shift register will be turned OFF (i.e., set to 0) and the shift register will not operate until R goes OFF again. Flags

78

There are no flags affected by SFT(10).

Page 87

Section 5–12

Data Shifting Example 1: Basic Application

The following example uses the 1-second clock pulse bit (1902) to so that the execution condition produced by 0005 is shifted into a 3-word register between 10 and 12 every second.

0005

I SFT(10)

1902

P 10

0006

Example 2: Controlling Bits in Shift Registers

R

12

The following program is used to control the status of the 17th bit of a shift register running from IR 00 through IR 01 (i.e. bit 00 of IR 01). When the 17th bit is to be set, 0204 is turned ON. This causes the jump for JMP(04) 00 not to be made for that one scan and IR 0100 (the 17th bit) will be turned ON. When 1280 is OFF (all times but the first scan after 0204 has changed from OFF to ON), the jump is taken and the status of 0100 will not be changed. 0200

0201

I SFT(10)

0202

P 00

0203

01 R

0204 DIFU(13) 1280 1280 JMP(04) 00 1280 0100

JME(05) 00

When a bit that is part of a shift register is used in OUT (or any other instruction that controls bit status), a syntax error will be generated during the program check, but the program will execute properly (i.e., as written). Example 3: Control Action

The following program controls the conveyor line shown below so that faulty products detected at the sensor are pushed down a chute. To do this, the execution condition determined by inputs from the first sensor (0001) are stored in a shift register: ON for good products; OFF for faulty ones. Conveyor speed has been adjusted so that HR 003 of the shift register can be used to activate a pusher (0500) when a faulty product reaches it, i.e., when HR 003 turns ON, 0500 is turned ON to activate the pusher. The program is set up so that a rotary encoder (0000) controls execution of SFT(10) through a DIFU(13), the rotary encoder is set up to turn ON and OFF each time a product passes the first sensor. Another sensor (0002) is used to detect faulty products in the chute so that the pusher output and HR 003 of the shift register can be reset as required.

79

Page 88

Section 5–12

Data Shifting Sensor (0001) Pusher (0500)

Rotary Encoder (0000)

0001

Sensor (0002) Chute

I SFT(10)

0000

P HR 0

0003

R

HR 1

HR 003 0500

0002 0500

HR 003

5–12–2 Word Shift – WSFT(16) Ladder Symbols

Operand Data Areas St : Start word

WSFT(16) IR, DM, HR St E : End word E

IR, DM, HR

Limitations

St and E must be in the same data area and St must be less than E.

Description

When the execution condition is OFF, WSFT(16) is not executed and the next instruction is moved to. When the execution condition is ON, 0000 is moved into St, the content of St is moved to St + 1, the content of St + 1 is moved to St + 2, etc., and the content of E is lost.

80

Page 89

Section 5–13

Data Movement E F

0

St + 1 C

2

3

4

5

St 2

1

0

2

9

Lost 0000 E 3

Flags

ER:

4

St + 1 5

2

1

0

2

St 9

0

0

0

0

St and E 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–13 Data Movement This section describes the instructions used for moving data between different addresses in data areas. These movements can be programmed within the same data area or between different data areas. Data movement is essential for utilizing all of the data areas of the PC. All of these instructions change only the content of the words to which data is being moved, i.e., the content of source words is the same before and after execution of any of the move instructions.

5–13–1 Move – MOV(21) Ladder Symbol

Operand Data Areas S : Source word

MOV(21) IR, SR, DM, HR, TC, # S D : Destination word D

Description

IR, DM, HR

When the execution condition is OFF, MOV(21) is not executed and the next instruction is moved to. When the execution condition is ON, MOV(21) transfers the content of S (specified word or four-digit hexadecimal constant) 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.

Flags

EQ:

ON when all zeros are transferred to D.

81

Page 90

Section 5–14

Data Comparison

5–13–2 Move NOT – MVN(22) Ladder Symbol

Operand Data Areas S : Source word

MVN(22) IR, SR, DM, HR, TC, # S D : Destination word D

Description

IR, DM, HR

When the execution condition is OFF, MVN(22) is not executed and the next instruction is moved to. When the execution condition is ON, MOV(21) 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.

Flags

EQ:

ON when all zeros are transferred to D.

5–14 Data Compare – CMP(20) This section describes the instruction used for comparing data. CMP(20) is used to compare the contents of two words.

Ladder Symbols

Operand Data Areas Cp1 : First compare word

CMP(20) IR, SR, DM, HR, TC, # Cp1 Cp2 : Second compare word Cp2

IR, SR, DM, HR, TC, #

Limitations

When comparing a value to the PV of a timer or counter, the value must be four-digit BCD.

Description

When the execution condition is OFF, CMP(20) is not executed and the next instruction is moved to. When the execution condition is ON, CMP(20) compares Cp1 and Cp2 and outputs the result to GR, EQ, and LE in the SR area.

82

Page 91

Section 5–14

Data Comparison Precautions

Placing other instructions between CMP(20) and accessing EQ, LE, and GR may change the status of these flags. Be sure to access them before the desired status is changed.

Flags

EQ:

ON if Cp1 equals Cp2.

LE:

ON if Cp1 is less than Cp2.

GR:

ON if Cp1 is greater than Cp2.

Example 1: Saving CMP(20) Results

The following example shows how to save the comparison result immediately. If the content of HR 8 is greater than that of 9, 0200 is turned ON; if the two contents are equal, 0201 is turned ON; if content of HR 8 is less than that of HR 9, 0202 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, 0200, 0201, and 0202 are changed only then CMP(20) is executed.

0000

TR 0 CMP(20) HR 8 HR 9

1905 0200

Greater Than

0201

Equal

0202

Less Than

1906

1907

Example 2: Obtaining Indications during Timer Operation

The following example uses TIM, CMP(20), and LE (SR 1907) to produce outputs at particular times in the timer’s countdown. The timer is started by turning ON 0000. When 0000 is OFF, the TIM (10) is reset and the second two CMP(20)s are not executed (i.e., executed with OFF execution conditions). Output 0200 is output after 100 seconds; output 0201, after 200 seconds; output 0202, after 300 seconds; and output 0204, after 500 seconds. The branching structure of this diagram is important so that 0200, 0201, and 0202 are controlled properly as the timer counts down. Because all of the comparisons here are to the timer’s PV, the other operand for each CMP(20) must be in 4-digit BCD.

83

Page 92

Section 5–15

Data Conversion 0000

TIM 10

0500 s.

CMP(20) TIM 10 #4000 1907 0200

Output at 100 s.

0200 CMP(20) TIM 10 #3000 1907 0201

Output at 200 s.

0201 CMP(20) TIM 10 #2000 1907 0202

Output at 300 s.

0204

Output at 500 s.

TIM 10

5–15 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 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–15–1 BCD to Binary – BIN(23) Ladder Symbol

Operand Data Areas S : Source word (BCD)

BIN(23) IR, SR, DM, HR, TC S R : Result word R

Description

84

IR, DM, HR

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.