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

The text of a manual · part 22 of 68

Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual: SECTION 5 Instruction Set, pages 184 to 193

Pages 184 to 193 of 613, from Programmable Controllers C200HX-CPU-ZE, C200HG-CPU-ZE, C200HE-CPU-ZE Operation Manual

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

Filed in the catalog under the Omron C200H-SP001 and Omron C200HW-PA204

Page 184

Section 5-14

Timer and Counter Instructions

Each TC number can be used as the definer in only one TIMER or COUNTER instruction. TC 000 through TC 015 should not be used in TIM if they are required for TIMH(015). Refer to 5-14-2 HIGH-SPEED TIMER – TIMH(015) for details. Description

A timer is activated when its execution condition goes ON and is reset (to SV) when the execution condition goes OFF. Once activated, TIM measures in units of 0.1 second from the SV. If the execution condition remains ON long enough for TIM to time down to zero, the Completion Flag for the TC number used will turn ON and will remain ON until TIM is reset (i.e., until its execution condition is goes OFF). The following figure illustrates the relationship between the execution condition for TIM and the Completion Flag assigned to it. ON

Execution condition

OFF ON

Completion Flag

OFF

SV

SV

Precautions

Timers in interlocked program sections are reset when the execution condition for IL(002) is OFF. Power interruptions also reset timers. If a timer that is not reset under these conditions is desired, SR area clock pulse bits can be counted to produce timers using CNT. Refer to 5-14-4 COUNTER – CNT for details. Program execution will continue even if a non-BCD SV is used, but timing will not be accurate. Jumps Never program TIM between JMP(004) 00 and JME(005) 00 with an SV of #0000. The Completion Flag will turn ON even when the execution condition for JMP(004) 00 is ON (i.e., even when the program section with TIM is jumped). TIM can be programmed successfully between JMP(004) and JME(005) as long as a jump number between 01 and 99 is used. Step Instructions Never program TIM between STEP(008) and SNXT(009) with an SV of #0000. The Completion Flag will turn ON even when the step containing TIM is reset. The SV of the timers can be set in the range #0000 to #9999 (BCD). If the SV for a timer is set to #0000 or #0001, it will operate in the following way. If the SV is set to #0000, when the timer input goes from OFF to ON, the Completion Flag will turn ON. If the SV is set to #0001, because the timer accuracy is 0 to –0.1 s, the actual time will be a value between 0 and 0.1 s, and the Completion Flag may turn ON as soon as the timer input goes from OFF to ON. With other values also, allow for a timer accuracy of 0 to –0.1 s when setting the SV.

Flags

ER:

SV is not in BCD. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.

Examples

All of the following examples use OUT in diagrams that would generally be used to control output bits in the IR area. There is no reason, however, why these diagrams cannot be modified to control execution of other instructions.

Example 1: Basic Application

The following example shows two timers, one set with a constant and one set via input word 005. Here, 00200 will be turned ON after 00000 goes ON and stays ON for at least 15 seconds. When 00000 goes OFF, the timer will be reset and 00200 will be turned OFF. When 00001 goes ON, TIM 001 is started from the SV

172

Page 185

Section 5-14

Timer and Counter Instructions provided through IR word 005. Bit 00201 is also turned ON when 00001 goes ON. When the SV in 005 has expired, 00201 is turned OFF. This bit will also be turned OFF when TIM 001 is reset, regardless of whether or not SV has expired.

00000 TIM 000 #0150

015.0 s

Address

Instruction

00000 00001

LD TIM

00002 00003 00004 00005

LD OUT LD TIM

00006 00007

AND NOT OUT

TIM 000 00200 00001 TIM 001 IR 005

IR 005

TIM 001 00201

Example 2: Extended Timers

Operands 00000 000 #0150 TIM 000 00200 00001 001 005 TIM 001 00200

There are two ways to achieve timers that operate for longer than 999.9 seconds. One method is to program consecutive timers, with the Completion Flag of each timer used to activate the next timer. A simple example with two 900.0-second (15-minute) timers combined to functionally form a 30-minute timer.

00000

Address

Instruction

900.0 s

00000 00001

LD TIM

900.0 s

00002 00003

LD TIM

00004 00005

LD OUT

TIM 001 #9000 TIM 001 TIM 002 #9000 TIM 002 00200

Operands 00000 001 #9000 TIM 001 002 #9000 TIM 002 00200

In this example, 00200 will be turned ON 30 minutes after 00000 goes ON. TIM can also be combined with CNT or CNT can be used to count SR area clock pulse bits to produce longer timers. An example is provided in 5-14-4 COUNTER – CNT. Example 3: ON/OFF Delays

TIM can be combined with KEEP(011) to delay turning a bit ON and OFF in reference to a desired execution condition. KEEP(011) is described in 5-9-4 KEEP – KEEP(011). To create delays, the Completion Flags for two TIM are used to determine the execution conditions for setting and reset the bit designated for KEEP(011). The bit whose manipulation is to be delayed is used in KEEP(011). Turning ON and OFF the bit designated for KEEP(011) is thus delayed by the SV for the two TIM. The two SV could naturally be the same if desired. In the following example, 00500 would be turned ON 5.0 seconds after 00000 goes ON and then turned OFF 3.0 seconds after 00000 goes OFF. It is necessary to use both 00500 and 00000 to determine the execution condition for TIM

173

Page 186

Section 5-14

Timer and Counter Instructions

002; 00000 in an inverse condition is necessary to reset TIM 002 when 00000 goes ON and 00500 is necessary to activate TIM 002 (when 00000 is OFF).

00000

Address

Instruction

005.0 s

00000 00001

LD TIM

003.0 s

00002 00003 00004

LD AND NOT TIM

00005 00006 00007

LD LD KEEP(011)

TIM 001 #0050 00500 00000 TIM 002 #0030 TIM 001 S KEEP(011) 00500

TIM 002

R

Operands 00000 001 #0050 00500 00000 002 #0030 TIM 001 TIM 002 00500

00000

00500 5.0 s

Example 4: One-Shot Bits

01000

3.0 s

The length of time that a bit is kept ON or OFF can be controlled by combining TIM with OUT or OUT NO. The following diagram demonstrates how this is possible. In this example, 00204 would remain ON for 1.5 seconds after 00000 goes ON regardless of the time 00000 stays ON. This is achieved by using 01000 as a self-maintaining bit activated by 00000 and turning ON 00204 through it. When TIM 001 comes ON (i.e., when the SV of TIM 001 has expired), 00204 will be turned OFF through TIM 001 (i.e., TIM 001 will turn ON which, as an inverse condition, creates an OFF execution condition for OUT 00204).

TIM 001 01000

00000

01000 TIM 001 #0015

01000 TIM 001 00204

00000

00204 1.5 s

174

1.5 s

001.5 s

Address

Instruction

00000 00001 00002 00003 00004 00005

LD AND NOT OR OUT LD TIM

00006 00007 00008

LD AND NOT OUT

Operands 01000 TIM 001 00000 01000 01000 001 #0015 01000 TIM 001 00204

Page 187

Section 5-14

Timer and Counter Instructions The following one-shot timer may be used to save memory.

00000 TIM 001 #0015

00100

001.5 s

TIM 001

Address

Instruction

00000 00001 00002

LD OR TIM

00003 00004

AND NOT OUT

00100

Example 5: Flicker Bits

Operands 00000 00100 001 #0015 TIM 001 00100

Bits can be programmed to turn ON and OFF at regular intervals while a designated execution condition is ON by using TIM twice. One TIM functions to turn ON and OFF a specified bit, i.e., the Completion Flag of this TIM turns the specified bit ON and OFF. The other TIM functions to control the operation of the first TIM, i.e., when the first TIM’s Completion Flag goes ON, the second TIM is started and when the second TIM’s Completion Flag goes ON, the first TIM is started.

00000 TIM 002 TIM 001 #0010

1.0 s

TIM 001 TIM 002 #0015

TIM 001

Address

Instruction

00000 00001 00002

LD AND NOT TIM

00003 00004

LD TIM

00005 00006

LD OUT

1.5 s

00205

Operands 00000 TIM 002 001 #0010 TIM 001 002 #0015 TIM 001 00205

00000

00205 1.0 s

1.5 s

1.0 s

1.5 s

A simpler but less flexible method of creating a flicker bit is to AND one of the SR area clock pulse bits with the execution condition that is to be ON when the flicker bit is operating. Although this method does not use TIM, it is included here for comparison. This method is more limited because the ON and OFF times must be the same and they depend on the clock pulse bits available in the SR area. In the following example the 1-second clock pulse is used (25502) so that 00206 would be turned ON and OFF every second, i.e., it would be ON for 0.5 seconds and OFF for 0.5 seconds. Precise timing and the initial status of 00206 would depend on the status of the clock pulse when 00000 goes ON.

00000 25502 00206

Address

Instruction

00000 00001 00002

LD AND OUT

Operands 00000 25502 00206

175

Page 188

Section 5-14

Timer and Counter Instructions

5-14-2 HIGH-SPEED TIMER – TIMH(015) Definer Values N: TC number

Ladder Symbol TIMH(015) N

# (000 through 511, although 000 through 015 preferred)

SV

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

Limitations

SV is between 00.00 and 99.99. (Although 00.00 and 00.01 may be set, 00.00 will disable the timer, i.e., turn ON the Completion Flag immediately, and 00.01 is not reliably cycled.) The decimal point is not entered. Each TC number can be used as the definer in only one TIMER or COUNTER instruction. If the cycle time is greater than 10 ms, use TC 000 through TC 015. The PVs and completion flags of timers 000 through 015 are refreshed every 10 ms, but the PVs of timers 016 through TC 511 are refreshed each time that TIMH(015) is executed in the program.

Description

TIMH(015) operates in the same way as TIM except that TIMH measures in units of 0.01 second. The cycle time affects TIMH(015) accuracy if TC 016 through TC 511 are used. If the cycle time is greater than 10 ms, use TC 000 through TC 015. Refer to 5-14-1 TIMER – TIM for operational details and examples. Except for the above, and all aspects of operation are the same.

Precautions

Timers in interlocked program sections are reset when the execution condition for IL(002) is OFF. Power interruptions also reset timers. If a timer that is not reset under these conditions is desired, SR area clock pulse bits can be counted to produce timers using CNT. Refer to 5-14-4 COUNTER – CNT for details. When changing between the TIM and TIMH(015) instructions during online editing, reset the Completion Flag for the TIM instruction. The TIM instruction will not execute properly unless the Completion Flag is reset. You must be in PROGRAM mode to change between these instructions. Program execution will continue even if a non-BCD SV is used, but timing will not be accurate. The SV of the timers can be set in the range #0000 to #9999 (BCD). If the SV for a timer is set to #0000 or #0001, it will operate in the following way. If the SV is set to #0000, when the timer input goes from OFF to ON, the Completion Flag will turn ON. There may be a time delay if TC 000 to TC 003 are used. If the SV is set to #0001, because the timer accuracy is 0 to –0.1 s, the actual time will be a value between 0 and 0.1 s, and the Completion Flag may turn ON as soon as the timer input goes from OFF to ON. With other values also, allow for a timer accuracy of 0 to –0.1 s when setting the SV.

Flags

ER:

SV is not in BCD. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary has been exceeded.

176

Page 189

Section 5-14

Timer and Counter Instructions

5-14-3 TOTALIZING TIMER – TTIM(087) Definer Values Ladder Symbol

N: TC number # (000 through 511)

TTIM(087) N SV RB

Operand Data Areas SV: Set value (word, BCD) IR, AR, DM, EM, HR, LR, SR, # RB: Reset bit IR, SR, AR, HR, LR

Limitations

SV is between 0000 and 9999 (000.0 and 999.9 s) and must be in BCD. The decimal point is not entered. Each TC number can be used as the definer in only one TIMER or COUNTER instruction. TTIM(087) is an expansion instruction. A Programming Device can be used to reassign function code 087 to another expansion instruction.

Description

TTIM(087) is used to create a timer that increments the PV every 0.1 s to time between 0.1 and 999.9 s. TTIM(087) increments in units of 0.1 second from zero. TTIM(087) accuracy is +0.0/–0.1 second. A TTIM(087) timer will time as long as its execute condition is ON until it reaches the SV or until RB turns ON to reset the timer. TIMM(087) timers will time only as long as they are executed every cycle, i.e., they do not time, but maintain the current PV, in interlocked program sections or when they are jumped in the program. The PVs and completion flags of timers 000 through 015 are refreshed every 10 ms, but the PVs of timers 016 through TC 511 are refreshed each time that TTIM(087) is executed in the program.

Precautions

The PVs of totalizing timers in interlocked program sections are maintained when the execution condition for IL(002) is OFF. Unlike timers and high-speed timers, totalizing timers in jumped program sections do not continue timing, but maintain the PV. Power interruptions will reset timers. Totalizing timers will not restart after timing out unless the PV is changed to a value below the SV or the reset input is turned ON. A delay of one cycle is sometimes required for a Completion Flag to be turned ON after the timer times out. The SV of the timers can be set in the range #0000 to #9999 (BCD). If the SV for a timer is set to #0000 or #0001, it will operate in the following way. If the SV is set to #0000, when the timer input goes from OFF to ON, the Completion Flag will turn ON. There may be a time delay if TC 000 to TC 003 are used. If the SV is set to #0001, because the timer accuracy is 0 to –0.1 s, the actual time will be a value between 0 and 0.1 s, and the Completion Flag may turn ON as soon as the timer input goes from OFF to ON. With other values also, allow for a timer accuracy of 0 to –0.1 s when setting the SV.

Flags

ER:

SV is not BCD. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary had been exceeded.

177

Page 190

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(087) TIM 000 #0020

Address

Instruction

00000 00001

LD TTIM(087)

Operands 00000 TIM 000 #0020 LR 2100

LR 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, EM, HR, LR, #, SR

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.

178

Page 191

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(004) 00 and JME(005) 00 with an SV of #0000. The Completion Flag will turn ON even when the execution condition for JMP(004) 00 is ON (i.e., even when the program section with CNT is jumped). CNT can be programmed successfully between JMP(004) and JME(005) as long as a jump number between 01 and 99 is used. Step Instructions Never program CNT between STEP(008) and SNXT(009) with an SV of #0000. The Completion Flag will turn ON even when the step containing CNT is reset.

Flags

ER:

SV is not BCD. The content of a word containing an indirect DM/EM address is not BCD or the DM/EM area boundary had 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

00000 00001 00002 0004 #0150 CNT 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.

179

Page 192

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

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. CP CNT 001

00002

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

00000 00001 00002 25315 004 #0150 CNT 004 00205

R

#0200

Operands 00000 00001 00002 CNT 001 CNT 002 001 #0100 CNT 001 00002 002 #0200 CNT 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

180

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 193

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

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

Operands 00000 TIM 001 CNT 002 001 #0050 TIM 001 00001 002 #0100 CNT 002 00201

00001 #0100 R CNT 002 00201

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

Operands 00000 25502 00001 001 #0700 CNT 001 00202

0202

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(012) Definer Values N: TC number

Ladder Symbol

# (000 through 511) II DI R

CNTR(012) N

Operand Data Areas

SV

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

181