Table of Contents

Counter

Block name

BD30_COUNTER

ST call

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

Library

LIB\CORE

Version

V1.0

Description

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:

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

Inputs

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

Outputs

OutputTypeDescription
OUT LINTCounter value (OUT may be equal to MINIMUM,MINIMUM+1,MINIMUM+2,…,MAXIMUM-1,MAXIMUM)

Application example


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.