I want to build a pulse counter for the S0 interface of three electricity meters. The counting of the pulses works already. Now I want to reproduce the current meter value via Rules.
My electricity meters emit 100 and 1000 pulses per kWh. The counted pulses must be divided by 100 or 1000 to calculate the actual meter value. Furthermore, I would like to calculate the meter reading to 1 decimal digit.
I have used "generic pulse counter" as devices. The variables count and total are filled accordingly.
Now I have created a rule that should do the calculation:
Code: Select all
// -------------------------------------------------------
// Set the pulses per kWh per counter unit
// -------------------------------------------------------
//
On System#Boot do
let,11,100 // Electricity meter 1: 100 pulses per kWh
let,12,1000 // Current counter 2: 1000 pulses per kWh
let,13,1000 // Current counter 3: 1000 pulses per kWh
endon
// -------------------------------------------------------
// current total divided by pulses = meter value
// so that the meter value contains only one decimal digit
// round the quotient to (pulses per kWh) 10 and later divide by 10
// -------------------------------------------------------
//
on Pulse1#Total > 0 do
let,1,round(Pulse1#Total/([int#12]/10))/10
endon
on Pulse2#Total > 0 do
let,2,round(Pulse2#Total/([int#12]/10))/10
endon
on Pulse3#Total > 0 do
let,3,round(Pulse3#Total/([int#13]/10))/10
endon
The devices are defined as: What am I doing wrong?
Many greetings and thanks
Sepp