Class 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¶
function calculateHarmonics¶
function calculateMetrics¶
inline bool Mycila::Dimmer::calculateMetrics (
Metrics & metrics,
float gridVoltage,
float loadResistance
) const
function end¶
function getDutyCycle¶
Get the power duty cycle configured for the dimmer by the user.
function getDutyCycleFire¶
Get the real firing duty cycle (conduction duty cycle) applied to the dimmer in the range [0, 1].
- 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.
function getDutyCycleMapped¶
Get the remapped power duty cycle from the currently user set duty cycle.
function getDutyCycleMax¶
Get the remapped "1" of the dimmer duty cycle.
function getDutyCycleMin¶
Get the remapped "0" of the dimmer duty cycle.
function getPowerRatio¶
function isEnabled¶
Check if the dimmer is enabled (if it was able to initialize correctly)
function isOff¶
Check if the dimmer is off.
function isOn¶
Check if the dimmer is on.
function isOnAtFullPower¶
Check if the dimmer is on at full power.
function isOnline¶
Returns true if the dimmer is online.
A dimmer is considered online if it is enabled, marked online
function off¶
Turn off the dimmer.
function on¶
Turn on the dimmer at full power.
function setDutyCycle¶
Set the power duty.
Parameters:
dutyCyclethe 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.
Parameters:
limitthe 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.
Parameters:
maxSet 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.
Parameters:
minSet 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.
This flag can be used to temporarily disable the dimmer when not connected to the grid
function type¶
function ~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.
function setSemiPeriod¶
Set the semi-period of the grid frequency in us for this dimmer. This is mandatory when using power LUT.
Typical values are 10000 for 50Hz and 8333 for 60Hz.
The value can also come from MycilaPulseAnalyzer
Protected Attributes Documentation¶
variable _dutyCycle¶
variable _dutyCycleFire¶
variable _dutyCycleLimit¶
variable _dutyCycleMax¶
variable _dutyCycleMin¶
variable _enabled¶
variable _online¶
Protected Static Attributes Documentation¶
variable _semiPeriod¶
Protected Functions Documentation¶
function _apply¶
function _calculateDimmerHarmonics¶
Protected Static Functions Documentation¶
function _contrain¶
The documentation for this class was generated from the following file src/MycilaDimmer.h