fabianoriccardi/dimmable-light

THDi calculation

mathieucarbou opened this issue · 1 comments

THDi can be calculated based on the power factor and phase angle (deplacement factor).

Since we know in the dimmer library the time when the dimmer is activated, is there a way to derive the angle to get the cosPhi ?

      // https://fr.electrical-installation.org/frwiki/Indicateur_de_distorsion_harmonique_:_facteur_de_puissance
      const float phi = 0; // TODO: find angle
      const float pf = getTotalPowerFactor();
      return sqrt(pow(cos(phi), 2) / pow(pf, 2) - 1);

Actually, thinking about it... This is a resistive load so as looking at the oscilloscope graphs (https://yasolr.carbou.me/overview), there is no phase shift between U and I so phi should be 0 and cos phi 1.