Skip to content

Class Mycila::Dimmer

ClassList > Mycila > Dimmer

  • #include <MycilaDimmer.h>

Inherited by the following classes: Mycila::CycleStealingDimmer, Mycila::PhaseControlDimmer

Classes

Type Name
struct Metrics

Public Functions

Type Name
virtual bool begin ()
bool calculateHarmonics (float * array, size_t n) const
bool calculateMetrics (Metrics & metrics, float gridVoltage, float loadResistance) const
virtual void end ()
float getDutyCycle () const
Get the power duty cycle configured for the dimmer by the user.
float getDutyCycleFire () const
Get the real firing duty cycle (conduction duty cycle) applied to the dimmer in the range [0, 1].
float getDutyCycleLimit () const
Get the power duty cycle limit of the dimmer.
float getDutyCycleMapped () const
Get the remapped power duty cycle from the currently user set duty cycle.
float getDutyCycleMax () const
Get the remapped "1" of the dimmer duty cycle.
float getDutyCycleMin () const
Get the remapped "0" of the dimmer duty cycle.
virtual float getPowerRatio () const
bool isEnabled () const
Check if the dimmer is enabled (if it was able to initialize correctly)
bool isOff () const
Check if the dimmer is off.
bool isOn () const
Check if the dimmer is on.
bool isOnAtFullPower () const
Check if the dimmer is on at full power.
virtual bool isOnline () const
Returns true if the dimmer is online.
void off ()
Turn off the dimmer.
void on ()
Turn on the dimmer at full power.
virtual bool setDutyCycle (float dutyCycle)
Set the power duty.
void setDutyCycleLimit (float limit)
Set the power duty cycle limit of the dimmer. The duty cycle will be clamped to this limit.
void setDutyCycleMax (float max)
Duty remapping (equivalent to Shelly Dimmer remapping feature). Useful to calibrate the dimmer when using for example a PWM signal to 0-10V analog convertor connected to a voltage regulator which is only working in a specific voltage range like 1-8V.
void setDutyCycleMin (float min)
Duty remapping (equivalent to Shelly Dimmer remapping feature). Useful to calibrate the dimmer when using for example a PWM signal to 0-10V analog convertor connected to a voltage regulator which is only working in a specific voltage range like 1-8V.
void setOnline (bool online)
Set the online status of the dimmer.
virtual const char * type () const
virtual ~Dimmer ()

Public Static Functions

Type Name
uint16_t getSemiPeriod ()
Get the semi-period in us used for the power LUT calculations. If LUT is disabled, returns 0.
void setSemiPeriod (uint16_t semiPeriod)
Set the semi-period of the grid frequency in us for this dimmer. This is mandatory when using power LUT.

Protected Attributes

Type Name
float _dutyCycle = 0.0f
float _dutyCycleFire = 0.0f
float _dutyCycleLimit = 1.0f
float _dutyCycleMax = 1.0f
float _dutyCycleMin = 0.0f
bool _enabled = false
bool _online = false

Protected Static Attributes

Type Name
uint16_t _semiPeriod = 0

Protected Functions

Type Name
virtual bool _apply ()
virtual bool _calculateDimmerHarmonics (float * array, size_t n) const

Protected Static Functions

Type Name
float _contrain (float amt, float low, float high)

Public Functions Documentation

function begin

inline virtual bool Mycila::Dimmer::begin () 

function calculateHarmonics

inline bool Mycila::Dimmer::calculateHarmonics (
    float * array,
    size_t n
) const

function calculateMetrics

inline bool Mycila::Dimmer::calculateMetrics (
    Metrics & metrics,
    float gridVoltage,
    float loadResistance
) const

function end

inline virtual void Mycila::Dimmer::end () 

function getDutyCycle

Get the power duty cycle configured for the dimmer by the user.

inline float Mycila::Dimmer::getDutyCycle () const


function getDutyCycleFire

Get the real firing duty cycle (conduction duty cycle) applied to the dimmer in the range [0, 1].

inline float Mycila::Dimmer::getDutyCycleFire () const

  • At 0% power, the ratio is equal to 0.
  • At 100% power, the ratio is equal to 1.

Returns:

The duty cycle applied on the hardware, or 0 if the dimmer is offline The firing ratio represents the actual proportion of time the dimmer is conducting power to the load within each AC cycle. It is computed based on the remapped duty cycle and eventually the power LUT if enabled.


function getDutyCycleLimit

Get the power duty cycle limit of the dimmer.

inline float Mycila::Dimmer::getDutyCycleLimit () const


function getDutyCycleMapped

Get the remapped power duty cycle from the currently user set duty cycle.

inline float Mycila::Dimmer::getDutyCycleMapped () const


function getDutyCycleMax

Get the remapped "1" of the dimmer duty cycle.

inline float Mycila::Dimmer::getDutyCycleMax () const


function getDutyCycleMin

Get the remapped "0" of the dimmer duty cycle.

inline float Mycila::Dimmer::getDutyCycleMin () const


function getPowerRatio

inline virtual float Mycila::Dimmer::getPowerRatio () const

function isEnabled

Check if the dimmer is enabled (if it was able to initialize correctly)

inline bool Mycila::Dimmer::isEnabled () const


function isOff

Check if the dimmer is off.

inline bool Mycila::Dimmer::isOff () const


function isOn

Check if the dimmer is on.

inline bool Mycila::Dimmer::isOn () const


function isOnAtFullPower

Check if the dimmer is on at full power.

inline bool Mycila::Dimmer::isOnAtFullPower () const


function isOnline

Returns true if the dimmer is online.

inline virtual bool Mycila::Dimmer::isOnline () const

A dimmer is considered online if it is enabled, marked online


function off

Turn off the dimmer.

inline void Mycila::Dimmer::off () 


function on

Turn on the dimmer at full power.

inline void Mycila::Dimmer::on () 


function setDutyCycle

Set the power duty.

inline virtual bool Mycila::Dimmer::setDutyCycle (
    float dutyCycle
) 

Parameters:

  • dutyCycle the power duty cycle in the range [0.0, 1.0]

function setDutyCycleLimit

Set the power duty cycle limit of the dimmer. The duty cycle will be clamped to this limit.

inline void Mycila::Dimmer::setDutyCycleLimit (
    float limit
) 

Parameters:

  • limit the power duty cycle limit in the range [0.0, 1.0]

function setDutyCycleMax

Duty remapping (equivalent to Shelly Dimmer remapping feature). Useful to calibrate the dimmer when using for example a PWM signal to 0-10V analog convertor connected to a voltage regulator which is only working in a specific voltage range like 1-8V.

inline void Mycila::Dimmer::setDutyCycleMax (
    float max
) 

Parameters:

  • max Set the new "1" value for the power duty cycle. The duty cycle in the range [0.0, 1.0] will be remapped to [min, max].

function setDutyCycleMin

Duty remapping (equivalent to Shelly Dimmer remapping feature). Useful to calibrate the dimmer when using for example a PWM signal to 0-10V analog convertor connected to a voltage regulator which is only working in a specific voltage range like 1-8V.

inline void Mycila::Dimmer::setDutyCycleMin (
    float min
) 

Parameters:

  • min Set the new "0" value for the power duty cycle. The duty cycle in the range [0.0, 1.0] will be remapped to [min, max].

function setOnline

Set the online status of the dimmer.

inline void Mycila::Dimmer::setOnline (
    bool online
) 

This flag can be used to temporarily disable the dimmer when not connected to the grid


function type

inline virtual const char * Mycila::Dimmer::type () const

function ~Dimmer

inline virtual Mycila::Dimmer::~Dimmer () 

Public Static Functions Documentation

function getSemiPeriod

Get the semi-period in us used for the power LUT calculations. If LUT is disabled, returns 0.

static inline uint16_t Mycila::Dimmer::getSemiPeriod () 


function setSemiPeriod

Set the semi-period of the grid frequency in us for this dimmer. This is mandatory when using power LUT.

static inline void Mycila::Dimmer::setSemiPeriod (
    uint16_t semiPeriod
) 

Typical values are 10000 for 50Hz and 8333 for 60Hz.

The value can also come from MycilaPulseAnalyzer


Protected Attributes Documentation

variable _dutyCycle

float Mycila::Dimmer::_dutyCycle;

variable _dutyCycleFire

float Mycila::Dimmer::_dutyCycleFire;

variable _dutyCycleLimit

float Mycila::Dimmer::_dutyCycleLimit;

variable _dutyCycleMax

float Mycila::Dimmer::_dutyCycleMax;

variable _dutyCycleMin

float Mycila::Dimmer::_dutyCycleMin;

variable _enabled

bool Mycila::Dimmer::_enabled;

variable _online

bool Mycila::Dimmer::_online;

Protected Static Attributes Documentation

variable _semiPeriod

uint16_t Mycila::Dimmer::_semiPeriod;

Protected Functions Documentation

function _apply

inline virtual bool Mycila::Dimmer::_apply () 

function _calculateDimmerHarmonics

inline virtual bool Mycila::Dimmer::_calculateDimmerHarmonics (
    float * array,
    size_t n
) const

Protected Static Functions Documentation

function _contrain

static inline float Mycila::Dimmer::_contrain (
    float amt,
    float low,
    float high
) 


The documentation for this class was generated from the following file src/MycilaDimmer.h