pulse metering: maximum size meterconstant?

Hi,

In our final setup we need to make use of a quite big meterconstant (between 200 and 875).
I noticed in a test setup that with a meterconsant of 100 data was reported correctly, but when using 875 measured value is incorrect.
Could there be an overflow problem when using big meterconstants?

Kind Regards,

Frederik

gebhardm's picture

The source provides the answer...
flm02/openwrt/package/flukso/luasrc/fsync.lua

  1. local meterconst = math.floor(real)
  2. local fraction = math.floor((real % 1) * 1000)

flm02/avr/a/ctrl.c
  1. ctrlWriteShortToTxBuffer(sensor[i].meterconst);
  2. [...]
  3. ctrlWriteShortToTxBuffer(sensor[i].fraction);

flm02/avr/a/main.c
  1. MacU16X16to32(state[sensor_id].nano, sensor[sensor_id].meterconst, ADC);

flm02/avr/a/main.h
  1. struct sensor_struct {
  2.         uint32_t counter;
  3.         uint16_t meterconst;
  4.         uint16_t fraction;      // expressed in milli
  5. };

So, if the multiplication runs into an overflow...

gebhardm's picture

By the way: What do you mean by "measured"? Displayed in the dash or provided via REST or MQTT???
It maybe also the backward calculation of Wh into W with large time intervals...
You have to be a bit more precise in where you see an "error"...

enervalis's picture

Thanks

enervalis's picture

Related question: is there a way to reset the accumulated Wh (the counter value)?