• No results found

N: TC number

# (00 through 47) Ladder Symbol

Definer Values

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

Each TC number can be used as the definer in only one timer or counter in-struction.

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 condi-Limitations

Description

Timer and Counter Instructions Section 5–11

tion 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. 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 for power interruptions.

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

Execution condition on count pulse (CP) Execution condition

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

ER: SV is not in BCD.

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

0000 CP

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

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

0000 CP

Timer and Counter Instructions Section 5–11

Counters that can count past 9,999 can be programmed by using one CNT to count the number of times another CNT has reached zero from SV.

In the following example, 0000 is used to control when CNT 01 operates and CNT 01, when 0000 is ON, counts down the number of OFF to ON changes in 0001. CNT 01 is reset by its Completion Flag, i.e., it starts counting again as soon as its PV reaches zero. CNT 02 counts the number of times the Completion Flag for CNT 01 goes ON. Bit 0002 serves as a reset for the en-tire extended counter, resetting both CNT 01 and CNT 02 when it is OFF.

The Completion Flag for CNT 02 is also used to reset CNT 01 to inhibit CNT 01 operation once PV for CNT 02 has been reached until the entire extended counter is reset via 0002.

Because in this example the SV for CNT 01 is 100 and the SV for CNT 02 is 200, the Completion Flag for CNT 02 turns ON when 100 x 200 or 20,000 OFF to ON changes have been counted in 0001. This would result in 0203 being turned ON.

0203 CP

R

CNT 01

#0100

CP

R

CNT 02

#0200 CNT 01

0002

CNT 02 0000 0001

0002

CNT 01

CNT 02

CNT can be used in sequence as many times as required to produce count-ers capable of counting down even higher values.

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 02 counts the number of times TIM 01 reaches zero from its SV. The Completion Flag for TIM 01 is used to reset TIM 01 so that is runs continuously and CNT 02 counts the number of times the Completion Flag for TIM 01 goes ON (CNT 02 would be executed once each time between when the Completion Flag for TIM 01 goes ON and TIM 01 is reset by its Completion Flag). TIM 01 is also reset by the Completion Flag for CNT 02 so that the extended timer would not start again until CNT 02 was reset by 0001, which serves as the reset for the entire extended tim-er.

As the SV for TIM 01 is 5.0 seconds and the SV for CNT 02 is 100, the Com-pletion Flag for CNT 02 turns ON when 5 seconds x 100 times, or 8 minutes and 20 seconds have expired. This would result in 0201 being turned ON.

Example 2:

Extended Counter

Example 3:

Extended Timers

Timer and Counter Instructions Section 5–11

0000 TIM 01 CNT 02

TIM 01

0001

CNT 00

0200 CP

R

TIM 0100 5.0 s

CNT 02

#0100

In the following example, CNT 01 counts the number of times the 1-second clock pulse bit (1902) goes from OFF to ON. Here again, 0000 is used to control when CNT is operating.

As the SV for CNT 01 is 700, the Completion Flag for CNT 02 turns ON when 1 second x 700 times, or 10 minutes and 40 seconds have expired. This would result in 0202 being turned ON.

CP

R

CNT 01

#0700 0000 1902

0001

CNT 01

0202

The shorter clock pulses may not produce accurate timers because their short ON times may not be read accurately for longer scan times. In particu-lar the 0.02-second and 0.1-second clock pulses should not be used to cre-ate timers with CNT.