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:
- 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.
Inputs
Input | Type | Description | Default value |
BX | BOOL | Rising edge increases the OUT value by 1 | False |
BXF | BOOL | Falling edge increases the OUT value by 1 | False |
BXD | BOOL | Rising edge decreases the OUT value by 1 | False |
BXDF | BOOL | Falling edge decreases the OUT value by 1 | False |
BR | BOOL | Reset – if BR=TRUE then OUT=MINIMUM | False |
MINIMUM | LINT | Minimum value of OUT | 0 |
MAXIMUM | LINT | Maximum value of OUT | 10000 |
BRING | BOOL | Overflow 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
Output | Type | Description |
OUT | LINT | Counter value (OUT may be equal to MINIMUM,MINIMUM+1,MINIMUM+2,…,MAXIMUM-1,MAXIMUM) |