# Documentation

## Analogue Incremental Counter (B107)

### Block name

B107_ANALOGUEINCREMENTALCOUNTER

### ST call

`PROGRAM B107 TEST	VAR	REAL1, REAL2: REAL;	RESET: BOOL;	FB: LIB.CORE.V1_0.B107_ANALOGUEINCREMENTALCOUNTER;	END_VAR	FB(IN:=REAL1, STEP:=1, OVERFL :=0, BSET:=RESET, OUT=>REAL2);	END_PROGRAM`

LIB\CORE

V1.0

### Description

The block processes input value coming from a pulse counter. It produces weightd output with overflow protection. Used for processing of low-range counting I/O modules etc.

### Inputs

 Input Type Description Default value IN REAL Input signal (usually a pulse conter with overflow risk) 0 BSET BOOL Rising edge here sets x0=x, add=0, and y starting from 0 False STEP REAL Usual step value at x (usually step=1 for x=1,2,3,...) 1 OVERFL REAL Counting range overflow value (if x=0,...,65535 then overfl=65536, if overfl <= 0 then the overflow is calculated automatically) 0 K REAL Weighing factor 1 KY0 REAL Additional constant at the weighed output Ky (Ky=K*y+Ky0) 0

### Outputs

Output Type Description
OUT REAL Output signal (incrementing counter with no upper limit)
KY REAL Weighed output Ky=K*y+Ky0
X0 REAL Initial input value (when a rising edge of bset comes then x0=x)
BOVERFL BOOL Pulse of 1s signalizing an overflow of input x
NOVERFL INT Number of input overflows (since the last reset by bset)
XLAST REAL Value of input x in the previous Fupla time step (internally usefull for automatic overflow setting)

### Function

The block provides a counter of pulses of input x which is able to eliminates an overflow. Let us suppose that input x increases as follows 0,1,2,3,...,65534,65535,0,1,2,... then output y is as follows: 0,1,2,3,...,65534,65535,65536,65537,65538,.... The block also contains weighted output Ky=K*y+Ky0, where K and Ky0 are arbitrarily parameters. For example, if one pulse weighs 0.2 kWh then if K=0.2, and Ky0=3000, the value of Ky is a measured energy in kWh starting at the value of 3000 kWh.

The block has another parameter: step, which is an expected input increment. If the input x increases by one (i.e. input is as follows 1,2,3,4,...) then set value step=1. If x increases by decimal values (for example by 0.1, i.e. input goes as follows: 0.1,0.2,0.3,0.4,...) then set step=0.1, etc. This parameter defines a threshold value – if input x decreases more then by 5*step then it is supposed that an overflow has occured. Behaviour after an overflow has two scenarios:

• overfl=0 – an overflow is set automaticaly according to the present and last values of input x (output xlast). Implicit setting.
• overfl>0 (recommended) – value is set according to the overflow of the connected device (if x=0,...,65535 then overfl=65536). The great advantage is that the block is then able to handle overflow when Fupla is switched off for a while (for example during a power failure), and still gives the correct value of output y, see Fig. 3.

The output value y can be reset by the input bset – if a rising edge comes then y=0. It is not possible to set output y to another value. If you need a shift to another value, use output value Ky instead of output y, and shift it by parameter Ky0.

If an overflow occurs then boolean output boverfl = true for one second and output noverfl (number of overflows) is incremented by one. If the block is reseted by input bset then noverfl is set to zero.

There are more outputs with additional information: x0, bset and bset, see the table above for description.

### Note

We strongly recommend to set parameter overfl according to overflow of the device connected to input x, for example overfl=65536. The block is then able to handle overflow when Fupla is switched off for a while (for example during a power failure), and still gives the correct value of output y, see Fig. 3.

### Function in case of wrong setting

If overfl<0 then it is supposed that overfl=0.

B107 Analogue incremental counter.

B107 Analogue incremental counter at overfl =0. The block returns an incorrect value after power outage.

B107 Analogue incremental counter at overfl>0. The block returns a correct value after power outage.

### Application example

The function reads the input value from a meter, real1, with settings of step=1, overfl=1. The counter is brought to zero by a rising edge at the reset input.