Counter

BD30_COUNTER

PROGRAM BD30_COUNTER_DEMO
 VAR
 L1: LINT;
 FB1: LIB.CORE.V1_0.BD30_COUNTER;
 FB2: LIB.CORE.V1_0.BD2_PULSE_GENERATOR;
 END_VAR
 
 FB2();
 FB1(BX := FB2.OUT);
 L1 := FB1.OUT;
 
END_PROGRAM

LIB\CORE

V1.0

The block is a pulse counter. Number of pulses is brought to the output OUT. The OUT value may be increased by 1 at rising edge on the BX input, or at falling edge of the BXF input. It may be also decreased by 1 at rising edge on the BXD input, or at falling edge of the BXDF input. The MINIMUM parameter specifies the lower limit of the counting range of OUT, while //// MAXIMUM is the upper limit. All possible values are thus MINIMUM,MINIMUM+1,MINIMUM+2,…,MAXIMUM-1,MAXIMUM. The behaviour at MINIMUM and MAXIMUM is given by the parameter BRING:

  • BRING=TRUE: Ring (cyclic) counter. If OUT=MAXIMUM and the value has to be increased, then it starts at MINIMUM. If OUT=MINIMUM and the value has to be decreased, it is set to MAXIMUM and counts down.
  • BRING=FALSE: If OUT=MAXIMUM and the value has to be increased, no operation is done (the value stops at MAXIMUM). If OUT=MINIMUM and the value has to be decreased, the value stops at MINIMUM.

The counter may be reset by a rising edge at the BR input. If BR=TRUE then OUT=MINIMUM and counting is stopped.

Input TypeDescription Default value
BX BOOLRising edge increases the OUT value by 1 False
BXF BOOLFalling edge increases the OUT value by 1 False
BXD BOOLRising edge decreases the OUT value by 1 False
BXDF BOOLFalling edge decreases the OUT value by 1 False
BR BOOLReset – if BR=TRUE then OUT=MINIMUM False
MINIMUMLINTMinimum value of OUT 0
MAXIMUMLINTMaximum value of OUT 10000
BRING BOOLOverflow switch. If BRING=TRUE then the counter is a cyclic counter, if BRING=FALSE then the counter stops at MINIMUM or MAXIMUM values.False
OutputTypeDescription
OUT LINTCounter value (OUT may be equal to MINIMUM,MINIMUM+1,MINIMUM+2,…,MAXIMUM-1,MAXIMUM)


The counter counts pulses generated by the BD2 block. Each rising edge increases the counter by 1. The counter is used to count events or to control a cascade heating plant.