Class EnergyMeter3Module

Inheritance Relationships

Base Type

Class Documentation

class EnergyMeter3Module : public Module

This class represents the 3 Phase Energy Meters Module connected via eMOD bus to controller module. This module is a three-phase 4 quadrants energy meter that allows to monitor the electrical parameters of your installation including active energy, reactive energy, voltage, current, power, maximum demand and more.

Class example 1

/*
 * This example uses a EnergyMeter3Module to configure and display some meters.
 */
#include "EnergyMeter3Module.hpp"
#include "EmodRetMng.hpp"
#include "HAL.hpp"

int main() {
    EnergyMeter3Module module;
    if (module.init() != 0) {
        printf("Module could not be initialized!\n");
        return 1;
    }

    // Configures transformers, work mode and metering standard
    module.configCurrentFullScale(1000, 1000, 1000);
    
    module.configVoltageFullScale(230, 230, 230);

    module.configSecondaryVoltageFullScale(230, 230, 230);

    module.configCurrentDirection(true, false, true);
    
    uint16_t work_mode = 0;
    module.configWorkMode(work_mode);
    
    uint16_t metering_standard = 0;
    module.configMeteringStandard(metering_standard);

    // Gets the power and energy measurements of phase 1
    PhasePowerParameters power_L1; 
    EnergyParameters energy_L1; 
    while (1) {
        if(module.getPowerParameters(1, &power_L1) == EmodRetOk){
            printf("Power-Phase-L1    Voltage=%010.3f V  Current    =%010.3f A    Frequency   =%010.3f Hz    Cosine        =%010.3f        Angle          =%010.3f º\n", power_L1.voltage, power_L1.current, power_L1.frequency, power_L1.cosine, power_L1.angle);
            printf("                                        ActivePower=%010.3f kW   AparentPower=%010.3f kVA   ReactivePower =%010.3f kVAr\n", power_L1.active_power, power_L1.aparent_power, power_L1.reactive_power);
            printf("                  /*EXPORTED*/          ActivePower=%010.3f kW   AparentPower=%010.3f kVA   InductivePower=%010.3f kVArl  CapacitivePower=%010.3f kVArc\n", power_L1.exported_active_power, power_L1.exported_aparent_power, power_L1.exported_inductive_power, power_L1.exported_capacitive_power);
            printf("                  /*IMPORTED*/          ActivePower=%010.3f kW   AparentPower=%010.3f kVA   InductivePower=%010.3f kVArl  CapacitivePower=%010.3f kVArc\n", power_L1.imported_active_power, power_L1.imported_aparent_power, power_L1.imported_inductive_power, power_L1.imported_capacitive_power);
            printf("                  MaximumPower(15')=%010.3f kW \n\n", power_L1.maximeter);
        }

        if(module.getEnergyParameters(1, &energy_L1) == EmodRetOk){
            printf("Energy-Phase-L1                         ActiveEnergy=%010.3f kWh   AparentEnergy=%010.3f kVAh   InductiveEnergy=%010.3f kVArlh  CapacitiveEnergy=%010.3f kVArch\n", energy_L1.active_energy, energy_L1.aparent_energy, energy_L1.inductive_energy, energy_L1.capacitive_energy);
            printf("                  /*EXPORTED*/          ActiveEnergy=%010.3f kWh   AparentEnergy=%010.3f kVAh   InductiveEnergy=%010.3f kVArlh  CapacitiveEnergy=%010.3f kVArch\n", energy_L1.exported_active_energy, energy_L1.exported_aparent_energy, energy_L1.exported_inductive_energy, energy_L1.exported_capacitive_energy);
            printf("                  /*IMPORTED*/          ActiveEnergy=%010.3f kWh   AparentEnergy=%010.3f kVAh   InductiveEnergy=%010.3f kVArlh  CapacitiveEnergy=%010.3f kVArch\n\n", energy_L1.imported_active_energy, energy_L1.imported_aparent_energy, energy_L1.imported_inductive_energy, energy_L1.imported_capacitive_energy);
        }

    }
}

Public Functions

EnergyMeter3Module()
~EnergyMeter3Module()
EmodRet init(const ModuleType em3_type = ModuleType::typeEM3, const EnergyMeter3ModuleCallback_Type callback_func = nullptr, void *const callback_context = nullptr, const uint8_t variant = 1)

Initialize module. It is important to emphasize that init() method is mandatory to call it and must be called always after instantiating the module. It can be called several times, each of which the module is initialized again.

Parameters
  • callback_func(optional) -- [in] function that will be called when a configured event occurs.

  • callback_context(optional) -- [in] context that will be passed to the callback function.

  • variant(optional) -- [in] identifies the module in case more than one module of the same type are present.

EmodRet init(const ModuleType em3_type, const EnergyMeter3ModuleCookedCallback_Type callback_func, void *const callback_context, const uint8_t variant)
EmodRet init(const uint8_t variant)

Initialize module. It is important to emphasize that init() method is mandatory to call it and must be called always after instantiating the module. It can be called several times, each of which the module is initialized again.

Parameters

variant -- [in] identifies the module in case more than one module of the same type are present.

EmodRet configCurrentFullScale(const float full_current_L1, const float full_current_L2, const float full_current_L3)

Configs the full scale amperage, 1:N ratio of the current transformer. Secondary full scale is 1 Amper.

Parameters
  • full_current_L1 -- [in] full scale or ratio of conversion of the transformer (clamp, tiroidal, ...) at L1.

  • full_current_L2 -- [in] full scale or ratio of conversion of the transformer (clamp, tiroidal, ...) at L2.

  • full_current_L3 -- [in] full scale or ratio of conversion of the transformer (clamp, tiroidal, ...) at L3.

EmodRet configVoltageFullScale(const float full_voltage_L1, const float full_voltage_L2, const float full_voltage_L3)

Configs the full scale of the primary voltage of the transformer. If no transformer is present, this value should be the means voltage, ex. 230V

Parameters
  • full_voltage_L1 -- [in] full scale of the transformer's primary at L1.

  • full_voltage_L2 -- [in] full scale of the transformer's primary at L2.

  • full_voltage_L3 -- [in] full scale of the transformer's primary at L3.

EmodRet configSecondaryVoltageFullScale(const float full_voltage_L1, const float full_voltage_L2, const float full_voltage_L3)

Configs the full scale of the secondary voltage of the transformer. In most scenarios this value is 230V. Note: this might fail with an EmodRetErrOldFirmware return error if Firmware is outdated. Contact us for a solution.

Parameters
  • full_voltage_L1 -- [in] full scale of the transformer's secondary at L1.

  • full_voltage_L2 -- [in] full scale of the transformer's secondary at L2.

  • full_voltage_L3 -- [in] full scale of the transformer's secondary at L3.

EmodRet configCurrentDirection(const bool current_direction_L1, const bool current_direction_L2, const bool current_direction_L3)

Configs the current direction of each phase. The current direction will be reversed if it is set to true.

Parameters
  • current_direction_L1 -- [in] current direction at L1.

  • current_direction_L2 -- [in] current direction at L2.

  • current_direction_L3 -- [in] current direction at L3.

EmodRet configWorkMode(const uint16_t mode)

Configs the work mode as explained in SEM Three manual

Parameters

mode -- [in] Mode 0 (All L1, L2 & L3 are single phased), Mode 1 (L2 & L3 are single phased, L1 isequilibrated three phased), Mode 2 (L3 is single phased, L1 & L2 are equilibrated three phased), Mode 3 (All L1, L2 & L3 are equilibrated three phased).

EmodRet configMeteringStandard(const uint16_t standard)

Configs the metering standard

Parameters

standard -- [in] 0 (Circutor), 1 (IEC62053-23), 2 (IEEE 1459-2000)

EmodRet resetAllEnergyMeter(void)

Resets to 0 all energy meters.

EmodRet getCurrentFullScale(float *full_current_L1, float *full_current_L2, float *full_current_L3)

Gets the full scale amperage, 1:N ratio of the current transformer.

Parameters
  • full_current_L1 -- [in] full scale or ratio of conversion of the transformer (clamp, tiroidal, ...) at L1.

  • full_current_L2 -- [in] full scale or ratio of conversion of the transformer (clamp, tiroidal, ...) at L2.

  • full_current_L3 -- [in] full scale or ratio of conversion of the transformer (clamp, tiroidal, ...) at L3.

EmodRet getVoltageFullScale(float *full_voltage_L1, float *full_voltage_L2, float *full_voltage_L3)

Gets the full scale of the primary voltage of the transformer.

Parameters
  • full_voltage_L1 -- [in] full scale of the transformer's primary at L1.

  • full_voltage_L2 -- [in] full scale of the transformer's primary at L2.

  • full_voltage_L3 -- [in] full scale of the transformer's primary at L3.

EmodRet getSecondaryVoltageFullScale(float *full_voltage_L1, float *full_voltage_L2, float *full_voltage_L3)

Gets the full scale of the secondary voltage of the transformer.

Parameters
  • full_voltage_L1 -- [in] full scale of the transformer's secondary at L1.

  • full_voltage_L2 -- [in] full scale of the transformer's secondary at L2.

  • full_voltage_L3 -- [in] full scale of the transformer's secondary at L3.

EmodRet getCurrentDirection(bool *current_direction_L1, bool *current_direction_L2, bool *current_direction_L3)

Gets the current direction of each phase. The current direction is reversed if set to true.

Parameters
  • current_direction_L1 -- [in] current direction at L1.

  • current_direction_L2 -- [in] current direction at L2.

  • current_direction_L3 -- [in] current direction at L3.

EmodRet getWorkMode(uint16_t *mode)

Gets the work mode as explained in SEM Three manual

Parameters

mode -- [out] Mode 0 (All L1, L2 & L3 are single phased), Mode 1 (L2 & L3 are single phased, L1 isequilibrated three phased), Mode 2 (L3 is single phased, L1 & L2 are equilibrated three phased), Mode 3 (All L1, L2 & L3 are equilibrated three phased).

EmodRet getMeteringStandard(uint16_t *standard)

Gets the metering standard

Parameters

standard -- [out] 0 (Circutor), 1 (IEC62053-23), 2 (IEEE 1459-2000)

EmodRet getPowerParameters(const int32_t phase, PhasePowerParameters *parameters)

Gets all the power parameters for a given phase

Parameters
  • phase -- [in] integer corresponding to phases L1 L2 L3.

  • parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet getEnergyParameters(const int32_t phase, EnergyParameters *parameters)

Gets all the energy parameters for a given phase

Parameters
  • phase -- [in] integer corresponding to phases L1 L2 L3.

  • parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet getPowerParameters_L1(PhasePowerParameters *parameters)

Gets all the power parameters for phase L1

Deprecated:

Consider using getPowerParameters() instead

Parameters

parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet getPowerParameters_L2(PhasePowerParameters *parameters)

Gets all the power parameters for phase L2

Deprecated:

Consider using getPowerParameters() instead

Parameters

parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet getPowerParameters_L3(PhasePowerParameters *parameters)

Gets all the power parameters for phase L3

Deprecated:

Consider using getPowerParameters() instead

Parameters

parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet getPowerParameters_L123Combined(CombinedPowerParameters *parameters)

Gets all the power parameters for the combination of the three phases

Parameters

parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet getEnergyParameters_L1(EnergyParameters *parameters)

Gets all the energy parameters for phase L1

Deprecated:

Consider using getEnergyParameters() instead

Parameters

parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet getEnergyParameters_L2(EnergyParameters *parameters)

Gets all the energy parameters for phase L2

Deprecated:

Consider using getEnergyParameters() instead

Parameters

parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet getEnergyParameters_L3(EnergyParameters *parameters)

Gets all the energy parameters for phase L3

Deprecated:

Consider using getEnergyParameters() instead

Parameters

parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet getEnergyParameters_L123Combined(EnergyParameters *parameters)

Gets all the energy parameters for the combination of the three phases

Parameters

parameters -- [out] Structured list of parameters as seen in EnergyMeterParameters.hpp

EmodRet configEventAtTimeInterval(const uint32_t time_interval)

Configures module for calling init callback_func at specified period.

Parameters

time_interval -- [in] period in milliseconds. Minimum value is 500ms,

EmodRet resetEventConfig(void)

Resets all previously configured events.

Protected Functions

EmodRet initFunctions()

Protected Attributes

EnergyMeterFunctions *energy_meter
EnergyMeter3ModuleCookedCallback_Type cooked_callback_func_
void *callback_ctx_

Protected Static Functions

static void cookedCallback(const uint8_t *data, const uint16_t data_len, const uint8_t id_function, void *ctx)