[CNT_UPDN] Upward & downward counter

Function block CNT_UPDN is an edge-controlled up/down counter.

CNT_UPDN is a edge-controlled up/down counter with set value 1 as increment, and upper counter value limit and counter value limit 0.

Functioning

Counter increments and counting

CNT_UPDN counts up via increasing edge (counter pulses) at input [CntUp] max to the counter value limit [CntValLm] or counts down via increasing edges at input [CntDn] to counter value limit 0. If CNT_UPDN receives increasing edges at the inputs [CntUp] and [CntDn], the counter value [CntVal] remains unchanged. The counting increments are 1.

info

The counter value [CntVal] can be incremented or decremented at the earliest at each second machine cycle due to slope control.

Counter value.

The present counter value is at output [CntVal]. The present counter value states are available at output [LmRd] (upper counter limit [CntValLm] reached or exceeded) or [ZeRd] (counter value limit 0 reached or exceeded).

Counter limit.

  • If the upper counter limit 0 [CntValLm] is reached, counting is stopped and output upper limit is reached [ZeRd] = 1.
  • If counter limit 0 is reached, counting is stopped and output zero is reached [ZeRd] = 1.
  • If the counter value limit [CntValLm] is thus exceeded, so that a counter value [CntVal] above the counter limit value [CntValLm] is used for starting or the counter upper limit [CntValLm] is set to a value below the present counter value [CntVal], then [LmRd] = 1. The counter value [CntVal] does not change for other counter pulses at input [CntUp]. Counting down by counting pulses at input [CntDn] is possible, however.
  • The number of possible increments to reach a limit depends on the counter start value [SttVal] or the counter reset [CntReset], on the counting direction, on the present counter value [CntVal] as well as on if the present counter value [CntVal] is below 0 or above the counter upper limit [CntValLm] (counter [LmRd] or [ZeRd]).
  • The counter can accept values above the counter upper limit [CntValLm], as values above [CntValLm] are possible for the counter start value [SttVal]. In addition, negative values are possible for the counter upper limit [CntValLm].

Reset counter

  • Reset the counter value [CntVal] via the reset input [CntReset].
  • When [CntReset] = 1, the counter value is set to [CntVal] = 0.
  • A new count down process can be started simultaneously with [SetStt] and [CntDn]. The counter value [CntVal] is initialized and decreased accordingly.
  • A new count up process can be started simultaneously with [CntReset] and [CntUp]. The counter value [CntVal] is initialized and increased accordingly.
  • If there is a simultaneous [CntReset], it has priority.

Set start value.

  • The counter value [CntVal] can also be set to a start value [SttVal].
  • If the input Set start value is [SetStt] = 1, the counter value remains at [CntVal] = [SttVal].
  • If there is a negative counter start value [SttVal], value "0" is set for [CntVal] at the SetStt signal ([SetStt] = 1).
info

[SetStt] and [CntReset] are not slope-controlled.

Pins

Input

Description

Data type

Default value
Value range

CntUp

Count up

Boolean

0

0 - No
1 - Yes

CntDn

Count down

Boolean

0

0 - No
1 - Yes

CntReset

Reset counter

Boolean

0

0 - No
1 - Yes

CntValLm

Counter value limit

Double integer

0

SetStt

Set start value

Boolean

0

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

SttVal

Start value

Double integer

0

Pers

Persistent

Boolean

0

0 - No
1 - Yes: the values are stored persistently.

BaObjRef

BA-Object reference
Link between function block and BACnet object.

Structure

---

BaObjRef
> DeviceID

Device identifier
[DeviceID] includes object type and object instance in one ID.
Identifies the device object: local or remote. A local device object can also be identified by value 16#3FFFFF.

Double Word

16#3FFFFF

BaObjRef
> ObjectID

Object identifier
[ObjectID] includes object type and object instance in one ID.
Identifies the object on a device.

Double Word

16#3FFFFF

BaObjRef
> ItemID

Item identifier
[ItemID] represents an index in a view node object that references the BACnet object.
[ObjectID] and [ItemID] together define an indirect reference to the BACnet object.
Value -1 indicates a direct interface.

Integer

-1

 

Output

Description

Data type

Default value
Value range

CntVal

Counter value

Double integer

0

LmRd

Limit reached

Efficiency [Efcy] has reached the efficiency limit [EfcyLm].

Boolean

0

0 - Limit not reached.
1 - Limit reached.

ZeRd

Zero reached

Boolean

0

0 - Zero not reached.
1 - Zero reached.

Dstb

Disturbed

[Dstb] indicates whether the referenced BACnet object was accessed.
[Dstb] = 0, if:
BACnet object access = Access successful
[Dstb] = 1, if:
BACnet object access = Error during access

Boolean

0

ErrCode

Error code indication

Integer

0: No error

= 0 - No error
> 0 - Error codes

Application

CNT_UPDN is used to count events which can be evaluated via an edge. These are, e.g. switching operations of twin-actuators (pumps, fans, compressors) to change the reference component as per a defined control sequence. Additionally, maintenance messages can be generated in dependence of these switches.

Process response

CNT_UPDN is processed with the values at the inputs from the second process cycle, 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 [CntUp] or [CntDn] is identified as an increasing slope on startup.

At start-up, CNT_UPDN reads the last saved counter value from the BACnet object and uses the value as the initial counter value if [Pers] = 1. In the event of fault or for [Pers] = 0, the counter value begins at 0.

The value of property 'Upward counter'/'Downward counter' must be available on the associated BACnet object as an extension property ('Extension by persistence' = 'Upward counter'/'Downward counter')