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

The text of a manual · part 20 of 60

C200HX/C200HG/C200HE Programmable Controllers Operation Manual, pages 184 to 193

Pages 184 to 193 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 184

Section 5-14

Timer and Counter Instructions Example

The following figure illustrates the relationship between the execution conditions for a totalizing timer with a set value of 2 s, its PV, and the Completion Flag. 00000 TTIM(87) TIM 000 #0020

Address

Instruction

00000 00001

LD TTIM(87)

Operands 00000 TIM # LR

LR 2100

000 0020 2100

Timer input (I: IR 00000) Reset bit (RB: LR 2100) Completion Flag (TIM 000)

Present value: 0020

0000

5-14-4 COUNTER – CNT Definer Values N: TC number

Ladder Symbol

# (000 through 511) CP R

CNT N SV

Operand Data Areas SV: Set value (word, BCD) IR, AR, DM, HR, LR, #

Limitations

Each TC number can be used as the definer in only one TIMER or COUNTER instruction.

Description

CNT is used to count down from SV when the execution condition on the count pulse, CP, goes from OFF to ON, i.e., the present value (PV) will be decremented by one whenever CNT is executed with an ON execution condition for CP and the execution condition was OFF for the last execution. If the execution condition has not changed or has changed from ON to OFF, the PV of CNT will not be changed. The Completion Flag for a counter is turned ON when the PV reaches zero and will remain ON until the counter is reset. CNT is reset with a reset input, R. When R goes from OFF to ON, the PV is reset to SV. The PV will not be decremented while R is ON. Counting down from SV will begin again when R goes OFF. The PV for CNT will not be reset in interlocked program sections or by power interruptions.

166

Page 185

Section 5-14

Timer and Counter Instructions

Changes in execution conditions, the Completion Flag, and the PV are illustrated below. PV line height is meant only to indicate changes in the PV.

Execution condition on count pulse (CP)

ON

Execution condition on reset (R)

ON

OFF

OFF ON

Completion Flag

OFF SV

SV

PV

0002

SV – 1

0001

SV – 2

0000

Precautions

Program execution will continue even if a non-BCD SV is used, but the SV will not be correct. Jumps Never program CNT between JMP(04) 00 and JME(05) 00 with an SV of #0000. The Completion Flag will turn ON even when the execution condition for JMP(04) 00 is ON (i.e., even when the program section with CNT is jumped). CNT can be programmed successfully between JMP(04) and JME(05) as long as a jump number between 01 and 99 is used. Step Instructions Never program CNT between STEP(08) and SNXT(09) with an SV of #0000. The Completion Flag will turn ON even when the step containing CNT is reset.

Flags

ER:

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

Example 1: Basic Application

00000

In the following example, the PV will be decremented whenever both 00000 and 00001 are ON provided that 00002 is OFF and either 00000 or 00001 was OFF the last time CNT 004 was executed. When 150 pulses have been counted down (i.e., when PV reaches zero), 00205 will be turned ON.

00001

CP

Address

Instruction

00000 00001 00002 00003

LD AND LD CNT

00004 00005

LD OUT

Operands

CNT 004 00002

R

#0150

CNT 004 00205

# CNT

00000 00001 00002 0004 0150 004 00205

Here, 00000 can be used to control when CNT is operative and 00001 can be used as the bit whose OFF to ON changes are being counted.

167

Page 186

Section 5-14

Timer and Counter Instructions

The previously-shown CNT can be modified to restart from SV each time power is turned ON to the PC. This is done by using the First Cycle Flag in the SR area (25315) to reset CNT as shown below. 00000

00001

CP

Address

Instruction

00000 00001 00002 00003 00004

LD AND LD OR CNT

00005 00006

LD OUT

Operands

CNT 004 00002

R

#0150

25315

CNT 004 00205

Example 2: Extended Counter

00000 00001

CP

R

#0100

CNT 001

Address

Instruction

00000 00001 00002 00003 00004 00005

LD AND LD NOT OR OR CNT

00006 00007 00008

LD LD NOT CNT

00009 00010

LD OUT

CNT 002

CNT 001

CP CNT 002

00002

# CNT

Counters that can count past 9,999 can be programmed by using one CNT to count the number of times another CNT has counted to zero from SV. In the following example, 00000 is used to control when CNT 001 operates. CNT 001, when 00000 is ON, counts down the number of OFF to ON changes in 00001. CNT 001 is reset by its Completion Flag, i.e., it starts counting again as soon as its PV reaches zero. CNT 002 counts the number of times the Completion Flag for CNT 001 goes ON. Bit 00002 serves as a reset for the entire extended counter, resetting both CNT 001 and CNT 002 when it is OFF. The Completion Flag for CNT 002 is also used to reset CNT 001 to inhibit CNT 001 operation, once SV for CNT 002 has been reached, until the entire extended counter is reset via 00002. Because in this example the SV for CNT 001 is 100 and the SV for CNT 002 is 200, the Completion Flag for CNT 002 turns ON when 100 x 200 or 20,000 OFF to ON changes have been counted in 00001. This would result in 00203 being turned ON.

CNT 001 00002

00000 00001 00002 25315 004 0150 004 00205

R

#0200

Operands

CNT CNT # CNT

# CNT

00000 00001 00002 001 002 001 0100 001 00002 002 0200 002 00203

CNT 002 00203

CNT can be used in sequence as many times as required to produce counters capable of counting any desired values. Example 3: Extended Timers

168

CNT can be used to create extended timers in two ways: by combining TIM with CNT and by counting SR area clock pulse bits. In the following example, CNT 002 counts the number of times TIM 001 reaches zero from its SV. The Completion Flag for TIM 001 is used to reset TIM 001 so that it runs continuously and CNT 002 counts the number of times the Completion Flag for TIM 001 goes ON (CNT 002 would be executed once each time be-

Page 187

Section 5-14

Timer and Counter Instructions tween when the Completion Flag for TIM 001 goes ON and TIM 001 is reset by its Completion Flag). TIM 001 is also reset by the Completion Flag for CNT 002 so that the extended timer would not start again until CNT 002 was reset by 00001, which serves as the reset for the entire extended timer. Because in this example the SV for TIM 001 is 5.0 seconds and the SV for CNT 002 is 100, the Completion Flag for CNT 002 turns ON when 5 seconds x 100 times, i.e., 500 seconds (or 8 minutes and 20 seconds) have expired. This would result in 00201 being turned ON. 00000 TIM 001

CNT 002 TIM 001 #0050

TIM 001

005.0 s

CP CNT 002

Address

Instruction

00000 00001 00002 00003

LD AND NOT AND NOT TIM

00004 00005 00006

LD LD CNT

00007 00008

LD OUT

00001 #0100 R CNT 002 00201

Operands 00000 001 002 001 0050 001 00001 002 0100 002 00201

TIM CNT # TIM

# CNT

In the following example, CNT 001 counts the number of times the 1-second clock pulse bit (25502) goes from OFF to ON. Here again, 00000 is used to control the times when CNT is operating. Because in this example the SV for CNT 001 is 700, the Completion Flag for CNT 002 turns ON when 1 second x 700 times, or 11 minutes and 40 seconds have expired. This would result in 00202 being turned ON. 00000 25502

CP CNT 001

00001

R

#0700

CNT 001

Address

Instruction

00000 00001 00002 00003

LD AND LD NOT CNT

00004 00005

LD OUT

0202

Operands

# CNT

00000 25502 00001 001 0700 001 00202

Note The shorter clock pulses will not necessarily produce accurate timers because their short ON times might not be read accurately during longer cycles. In particular, the 0.02-second and 0.1-second clock pulses should not be used to create timers with CNT instructions.

5-14-5 REVERSIBLE COUNTER – CNTR(12) Definer Values N: TC number

Ladder Symbol

# (000 through 511) II DI R

CNTR(12) N

Operand Data Areas

SV

SV: Set value (word, BCD) IR, AR, DM, HR, LR, #

169

Page 188

Section 5-14

Timer and Counter Instructions Limitations

Each TC number can be used as the definer in only one TIMER or COUNTER instruction.

Description

The CNTR(12) is a reversible, up/down circular counter, i.e., it is used to count between zero and SV according to changes in two execution conditions, those in the increment input (II) and those in the decrement input (DI). The present value (PV) will be incremented by one whenever CNTR(12) is executed with an ON execution condition for II and the last execution condition for II was OFF. The present value (PV) will be decremented by one whenever CNTR(12) is executed with an ON execution condition for DI and the last execution condition for DI was OFF. If OFF to ON changes have occurred in both II and DI since the last execution, the PV will not be changed. If the execution conditions have not changed or have changed from ON to OFF for both II and DI, the PV of CNT will not be changed. When decremented from 0000, the present value is set to SV and the Completion Flag is turned ON until the PV is decremented again. When incremented past the SV, the PV is set to 0000 and the Completion Flag is turned ON until the PV is incremented again. CNTR(12) is reset with a reset input, R. When R goes from OFF to ON, the PV is reset to zero. The PV will not be incremented or decremented while R is ON. Counting will begin again when R goes OFF. The PV for CNTR(12) will not be reset in interlocked program sections or by the effects of power interruptions. Changes in II and DI execution conditions, the Completion Flag, and the PV are illustrated below starting from part way through CNTR(12) operation (i.e., when reset, counting begins from zero). PV line height is meant to indicate changes in the PV only. Execution condition on increment (II)

ON

Execution condition on decrement (DI)

ON

OFF

OFF ON

Completion Flag

OFF

SV

PV

SV

SV – 1

SV – 1 0001

SV – 2 0000

SV – 2 0000

Precautions

Program execution will continue even if a non-BCD SV is used, but the SV will not be correct.

Flags

ER:

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

170

Page 189

Section 5-15

Data Shifting

5-15 Data Shifting All of the instructions described in this section are used to shift data, but in differing amounts and directions. The first shift instruction, SFT(10), shifts an execution condition into a shift register; the rest of the instructions shift data that is already in memory.

5-15-1 SHIFT REGISTER – SFT(10) Ladder Symbol

Operand Data Areas St: Starting word

I SFT(10)

IR, SR, AR, HR, LR

P St R

E

E: End word IR, SR, AR, HR, LR

Limitations

St must be less than or equal to E, and St and E must be in the same data area. 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.

Description

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. 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

There are no flags affected by SFT(10).

171

Page 190

Section 5-15

Data Shifting Example 1: Basic Application

The following example uses the 1-second clock pulse bit (25502) so that the execution condition produced by 00005 is shifted into a 3-word register between IR 010 and IR 012 every second.

00005

I SFT(10)

25502

P 010

00006

R

012

Address

Instruction

00000 00001 00002 00003

LD LD LD SFT(10)

Operands 00005 25502 00006 010 012

Example 2: Controlling Bits in Shift Registers

00200 00201

The following program is used to control the status of the 17th bit of a shift register running from AR 00 through AR 01. When the 17th bit is to be set, 00004 is turned ON. This causes the jump for JMP(04) 00 not to be made for that one cycle, and AR 0100 (the 17th bit) will be turned ON. When 12800 is OFF (i.e., at all times except during the first cycle after 00004 has changed from OFF to ON), the jump is executed and the status of AR 0100 will not be changed.

I SFT(10)

00202

P AR 00

00203

AR 01 R

Address

Instruction

00000 00001 00002 00003 00004

LD AND LD LD SFT(10)

Operands 00200 00201 00202 00203 AR AR

00004 DIFU(13) 12800 12800 JMP(04) 00 12800 AR 0100

00005 00006 00007 00008 00009 00010 00011

LD DIFU(13) LD JMP(04) LD OUT JME(05)

AR

00 01 00004 12800 12800 00 12800 0100 00

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 executed properly (i.e., as written). Example 3: Control Action

172

The following program controls the conveyor line shown below so that faulty products detected at the sensor are pushed down a shoot. To do this, the execution condition determined by inputs from the first sensor (00001) are stored in a shift register: ON for good products; OFF for faulty ones. Conveyor speed has been adjusted so that HR 0003 of the shift register can be used to activate a pusher (00500) when a faulty product reaches it, i.e., when HR 0003 turns ON, 00500 is turned ON to activate the pusher.

Page 191

Section 5-15

Data Shifting

The program is set up so that a rotary encoder (00000) 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 (00002) is used to detect faulty products in the shoot so that the pusher output and HR 0003 of the shift register can be reset as required. Sensor (00001) Pusher (00500)

Sensor (00002)

Rotary Encoder (00000)

00001

I SFT(10)

00000

P HR 00

00003

R

HR 01

Chute

Address

Instruction

00000 00001 00002 00003

LD LD LD SFT(10)

00001 00000 00003

HR 0003 00500

00002 00500

00004 00005 00006 00007 00008

Operands

LD OUT LD OUT NOT OUT NOT

HR HR HR

HR

00 01 0003 00500 00002 00500 0003

HR 0003

5-15-2 REVERSIBLE SHIFT REGISTER – SFTR(84) Operand Data Areas C: Control word

Ladder Symbols

IR, AR, DM, HR, LR SFTR(84)

@SFTR(84)

C

C

St

St

E

E

St: Starting word

Limitations

IR, SR, AR, DM, HR, LR E: End word IR, SR, AR, DM, HR LR

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

173

Page 192

Section 5-15

Data Shifting Description

SFTR(84) is used to create a single- or multiple-word shift register that can shift data to either the right or the left. To create a single-word register, designate the same word for St and E. The control word provides the shift direction, the status to be put into the register, the shift pulse, and the reset input. The control word is allocated as follows:

15 14 13 12

Not used. Shift direction 1 (ON): Left (LSB to MSB) 0 (OFF): Right (MSB to LSB) Status to input into register Shift pulse bit Reset

The data in the shift register will be shifted one bit in the direction indicated by bit 12, shifting one bit out to CY and the status of bit 13 into the other end whenever SFTR(84) is executed with an ON execution condition as long as the reset bit is OFF and as long as bit 14 is ON. If SFTR(84) is executed with an OFF execution condition or if SFTR(84) is executed with bit 14 OFF, the shift register will remain unchanged. If SFTR(84) is executed with an ON execution condition and the reset bit (bit 15) is OFF, the entire shift register and CY will be set to zero. 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 word is not BCD, or the DM area boundary has been exceeded.)

CY:

Example

Receives the status of bit 00 of St or bit 15 of E, depending on the shift direction.

In the following example, IR 00005, IR 00006, IR 00007, and IR 00008 are used to control the bits of C used in @SHIFT(84). The shift register is between LR 20 and LR 21, and it is controlled through IR 00009.

00005 05012

Direction

05013

Status to input

05014

Shift pulse

05015

Reset

00006

00007

00008

Instruction

00000 00001 00002 00003 00004 00005 00006 00007 00008 00009

LD OUT LD OUT LD OUT LD OUT LD @SFT(10)

Operands 00005 05012 00006 05013 00007 05014 00008 05015 00009

LR LR

00009 @SFTR(84) 050 LR 20 LR 21

174

Address

050 20 21

Page 193

Section 5-15

Data Shifting

5-15-3 ARITHMETIC SHIFT LEFT – ASL(25) Ladder Symbols

Description

Operand Data Areas

ASL(25)

@ASL(25)

Wd

Wd

Wd: Shift word IR, SR, AR, DM, HR, LR

When the execution condition is OFF, ASL(25) is not executed. When the execution condition is ON, ASL(25) shifts a 0 into bit 00 of Wd, shifts the bits of Wd one bit to the left, and shifts the status of bit 15 into CY.

CY

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

Flags

ER:

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

CY:

Receives the status of bit 15.

EQ:

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

N:

ON when a 1 is shifted into bit 15 of Wd.

5-15-4 ARITHMETIC SHIFT RIGHT – ASR(26) Ladder Symbols

Description

Operand Data Areas

ASR(26)

@ASR(26)

Wd

Wd

Wd: Shift word IR, SR, AR, DM, HR, LR

When the execution condition is OFF, ASR(25) is not executed. When the execution condition is ON, ASR(25) shifts a 0 into bit 15 of Wd, shifts the bits of Wd one bit to the right, and shifts the status of bit 00 into CY. Bit Bit 15 00 1 1 0 0 1 0 1 1 0 0 1 1 0 0 1 0

CY

0

Flags

ER:

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

CY:

Receives the data of bit 00.

EQ:

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

175