[CNT_DN] Downward counter

Function block CNT_DN is an edge-controlled down counter.

CNT_DN is a edge-controlled down counter with set value 1 as increment and counter value limit 0.

Functioning

Counter increments and counting

If an increasing edge exists at input Count down [CntDn], the CNT_DN block reduces the counter value [CntVal] by one. The counting increments are 1.

info

In order to identify a slope, CNT_DN must pass two machine cycles. As a result, the counts occur at the earliest after the second machine cycle.

Counter limit.

  • If counter limit 0 is reached or below zero, counting is stopped and output zero is reached [ZeRd] = 1.
  • If a negative counter start value [SttVal] is present and a falling edge at input [SetStt], the counter value [CntVal] = 0 and [ZeRd] = 1 is set.
  • The number of possible counter steps to reach counter limit 0 depends on the counter start value [SttVal] and on a counter reset [CntReset] and the present counter value [CntVal].

Reset counter

  • If the input Reset counter is [CntReset] = 1, the counter value remains at [CntVal] = 0 (not edge-controlled).
  • A new counter process can be started simultaneously with [SetStt] and [CntDn]. With a falling edge at input [SetStt], the counter value [CntVal] is initialized and counted down.
  • If there is a simultaneous [CntReset], it has priority.

Set start value.

  • If the input Set start value is [SetStt] = 1, the counter value remains at [CntVal] = [SttVal] (not edge-controlled).
  • If [SetStt] = 0, the counter starts at counter start value [CntVal] = [SttVal].
  • If the counter start value [SttVal] is negative, counting starts at counter value [CntVal] 0.
Pins

Input

Description

Data type

Default value
Value range

CntDn

Count down

Boolean

0

0 - No
1 - Yes

CntReset

Reset counter

Boolean

0

0 - No
1 - Yes

SetStt

Set start value

Boolean

0

0 - Do not set start value.
1 - Set start value.

SttVal

Start value

Double integer

0

 

Output

Description

Data type

Default value
Value range

CntVal

Counter value

Double integer

0

ZeRd

Zero reached

Boolean

0

0 - Zero not reached.
1 - Zero reached.

Process response

CNT_DN is processed with the values at the inputs from the second process cycle onward, as the values at the inputs are considered valid only then. Default values are issued during the first process cycle.

info

A continuous signal at input [CntDn] always is identified as an increasing slope on startup.