Consumption calculation with pulse counter

Pulse counters are specific sensors used to count the number of pulses provided by a third-party device/counter. Pulse counters can have a variety of applications, including reading water, electricity or gas meters, or counting the number of events (for example, the opening and closing of a door).

Pulse counters are calibrated to provide a number of pulses per unit. Pulse counters have a limit on the total number of pulses they can count. When the limit is reached, in loop mode, the total pulse counter resets to 0.

This article explains how to implement a smart device that calculates consumption linearly and takes this cyclical phenomenon into account.

To calculate consumption based on a pulse input we need to know the following parameters:

The smart device module allows you to calculate an index, increment it by a number of pulses and take the reset cycle into account. The method described below counters the undesirable effect of consumption becoming negative when the pulse counter is reset to zero.

In a smart device, we will create the variables following:

Tips:

The calculation of the index of the smart device goes through the following formula:

Where:

1. The variation in the number of pulsations (z) between two readings is:

z = (x < y) ? max + x - y : x - y

2. To know the value of the new index, you must add to the value of the initial index (i) the variation in the number of pulsations converted into the index unit.

w = index + z / ppu

3. The first occurrence of the smart device does not allow delta (w) to be calculated because pulse(t-1) is not known. The initial index is therefore the number of initial pulses of the series

w? w : x / ppu

The result is an index which will increase linearly and which will be expressed in the expected unit. To calculate consumption, you must activate the option delta and to aggregate consumption, you must select the aggregation level. Rebuild the smart device from the reading date.

Note:

? : is a conditional expression

x ? y : z

15 > 100 ? 1 : -1

Result: -1