Re: [PATCH 1/3] iio: add power and energy measurement modifiers

From: Jonathan Cameron
Date: Thu Jul 24 2025 - 09:10:22 EST


On Fri, 11 Jul 2025 14:23:14 -0500
David Lechner <dlechner@xxxxxxxxxxxx> wrote:

> On 7/11/25 8:02 AM, Antoniu Miclaus wrote:
> > Add new IIO modifiers to support power and energy measurement devices:
> >

Sorry I'm late to the game. Busy few weeks :(

> > Power modifiers:
> > - IIO_MOD_ACTIVE: Real power consumed by the load
> > - IIO_MOD_REACTIVE: Power that oscillates between source and load
> > - IIO_MOD_APPARENT: Magnitude of complex power
>
> These make sense a modifiers since they are components of a single
> measured value.

Agreed. Oddly I thought we already had these. Maybe there was a proposal
at some point that never got adopted. Maybe I just had a nightmare



>
> > - IIO_MOD_FUND_REACTIVE: Reactive power at fundamental frequency
>
> This one seems like there should just be a separate channel
> with IIO_POWER + IIO_MOD_REACTIVE since it is measuring a different
> value.

Hmm. This one is new to me. A separate channels sounds fine to me
with a label to provide the info on what it is.

>
> > - IIO_MOD_FACTOR: Power factor (ratio of active to apparent power)
>
> Power factor seems like it should be a IIO_CHAN_INFO_ rather than
> IIO_MOD_. It is also unitless, so doesn't make sense to be part
> of power_raw which would imply that it shuold be converted to Watts.

Agreed.

>
> >
> > Energy modifiers:
> > - IIO_MOD_ACTIVE_ACCUM: Accumulated active energy
> > - IIO_MOD_APPARENT_ACCUM: Accumulated apparent energy
> > - IIO_MOD_REACTIVE_ACCUM: Accumulated reactive energy
>
> As below, this one seems like there should be a separate
> energy channel for accumulated energy.

What sort of energy measurement isn't accumulated? If it's
divided by time then it's power anyway.


>
> >
> > Signal quality modifiers:
> > - IIO_MOD_RMS: Root Mean Square value
>
> Suprised we don't have something like this already. altvoltageY isn't
> clear about if the value is peak-to-peak or RMS.

Hohum.. My vague recollection is peak to peak, but oops we should
have documented that better. Someone want to audit existing drivers?

>
> > - IIO_MOD_SWELL: Voltage swell detection
> > - IIO_MOD_DIP: Voltage dip (sag) detection
>
> These sound like events, not modifiers.
Agreed. Those look fun.


> > What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw
> > KernelVersion: 3.2
> > Contact: linux-iio@xxxxxxxxxxxxxxx
> > @@ -1593,6 +1603,12 @@ Description:
> >
> > What: /sys/.../iio:deviceX/in_energy_input
> > What: /sys/.../iio:deviceX/in_energy_raw
> > +What: /sys/.../iio:deviceX/in_energyY_active_raw
> > +What: /sys/.../iio:deviceX/in_energyY_reactive_raw
> > +What: /sys/.../iio:deviceX/in_energyY_apparent_raw
> > +What: /sys/.../iio:deviceX/in_energyY_active_accum_raw
> > +What: /sys/.../iio:deviceX/in_energyY_reactive_accum_raw
> > +What: /sys/.../iio:deviceX/in_energyY_apparent_accum_raw
>
> I think the accumulated would just be a separate channel, not a modifier.

I'm confused what energy is vs accumulated energy.