Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
emSwLib.h File Reference

Detailed Description

Contains all Energy Measurement SW Library enums, structs, macros, function and global variables defintions.

#include <msp430.h>
#include <stdint.h>
#include <stdbool.h>
#include "IQmathLib.h"
#include "QmathLib.h"
Include dependency graph for emSwLib.h:

Go to the source code of this file.

Data Structures

struct  _EM_Pulse_Settings_
 Contains EM SW Lib Phase Calibration. More...
 
struct  _EM_System_Configuration_
 Contains EM SW Lib System Configuration. More...
 
struct  _EM_Phase_Calibration_
 Contains EM SW Lib Phase Calibration. More...
 
struct  _EM_Phase_Configuration_
 Contains EM SW Lib System Configuration. More...
 
struct  _EM_Meter_Configuration_
 Contains EM SW Lib Meter Configuration. More...
 
struct  _EM_Algorithm_Configuration_
 Contains EM SW Lib Algorithm Configuration. More...
 
struct  _EM_SW_Lib_Config_Handle_
 Contains EM SW Lib Config Handle. More...
 
struct  _EM_Metrology_
 
struct  _EM_Phase_BG_Results_
 Contains EM Phase Background Results. More...
 
struct  _EM_Phase_Results_
 Contains EM Phase Result. More...
 
struct  _EM_Total_Results_
 Contains EM Total Results. More...
 
struct  _EM_SW_Lib_Result_Handle_
 Contains EM SW Lib Result Handle. More...
 

Macros

#define EM_PHASE_RESULT_CALC_VRMS   BIT0
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the VRMS is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_IRMS   BIT1
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the IRMS is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_V_PEAK   BIT2
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the V-PEAK is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_I_PEAK   BIT3
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the I-PEAK is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_POWER_FACTOR   BIT4
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the POWER FACTOR is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_FREQ   BIT5
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the Frequency is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_ACTIVE_POWER   BIT6
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the ACTIVE POWER is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_REACTIVE_POWER   BIT7
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the REACTIVE POWER is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_APPARENT_POWER   BIT8
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the APPARENT POWER is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_ACTIVE_ENERGY   BIT9
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the ACTIVE ENERGY is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_REACTIVE_ENERGY   BIT10
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the REACTIVE ENERGY is calculated by the EM_processSample(). More...
 
#define EM_PHASE_RESULT_CALC_APPARENT_ENERGY   BIT11
 This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the APPARENT ENERGY is calculated by the EM_processSample(). More...
 
#define EM_PULSE_GEN_PHASE_NONE   (0x00)
 This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase A. More...
 
#define EM_PULSE_GEN_PHASE_A   (0x01)
 This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase A. More...
 
#define EM_PULSE_GEN_PHASE_B   (0x02)
 This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase B. More...
 
#define EM_PULSE_GEN_PHASE_C   (0x04)
 This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase C. More...
 
#define EM_PULSE_GEN_PHASE_D   (0x08)
 This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase D. More...
 
#define EM_PULSE_GEN_PHASE_E   (0x10)
 This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase E. More...
 
#define EM_PULSE_GEN_PHASE_F   (0x20)
 This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase F. More...
 
#define EM_PULSE_GEN_PHASE_NEUTRAL   (0x40)
 This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase neutral. More...
 
#define EM_PULSE_GEN_PHASE_AGGREGATE   (0x80)
 This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseTotalPhases() to generate pulses for the aggregate total. More...
 

Typedefs

typedef enum _EM_message_code_ EM_message_code
 The following enumeration contain all possible EM SW Library return message codes. More...
 
typedef enum _EM_Current_Sensor_ EM_Current_Sensor
 Selects appropriate EM Sensor for the corresponding channel. More...
 
typedef int64_t EM_Power_t
 Type for Power variables. More...
 
typedef uint64_t EM_Energy_t
 Type for Energy variables. More...
 
typedef enum _EM_Phase_ EM_Phase
 Selects appropiate phase to provide results for. More...
 
typedef struct _EM_Pulse_Settings_ EM_Pulse_Settings
 Contains EM SW Lib Phase Calibration. More...
 
typedef struct _EM_System_Configuration_ EM_System_Configuration
 Contains EM SW Lib System Configuration. More...
 
typedef struct _EM_Phase_Calibration_ EM_Phase_Calibration
 Contains EM SW Lib Phase Calibration. More...
 
typedef struct _EM_Phase_Configuration_ EM_Phase_Configuration
 Contains EM SW Lib System Configuration. More...
 
typedef struct _EM_Meter_Configuration_ EM_Meter_Configuration
 Contains EM SW Lib Meter Configuration. More...
 
typedef struct _EM_Algorithm_Configuration_ EM_Algorithm_Configuration
 Contains EM SW Lib Algorithm Configuration. More...
 
typedef struct _EM_SW_Lib_Config_Handle_ EM_SW_Lib_Config_Handle
 Contains EM SW Lib Config Handle. More...
 
typedef struct _EM_Metrology_ EM_Metrology
 
typedef struct _EM_Phase_BG_Results_ EM_Phase_BG_Results
 Contains EM Phase Background Results. More...
 
typedef struct _EM_Phase_Results_ EM_Phase_Results
 Contains EM Phase Result. More...
 
typedef struct _EM_Total_Results_ EM_Total_Results
 Contains EM Total Results. More...
 
typedef struct _EM_SW_Lib_Result_Handle_ EM_SW_Lib_Result_Handle
 Contains EM SW Lib Result Handle. More...
 

Enumerations

enum  _EM_message_code_ {
  EM_message_code_no_error =0, EM_message_code_pulseArray_error =1, EM_message_code_indPhaseMeter_error =2, EM_message_code_indPhasePulseDuration_error =3,
  EM_message_code_totalPhaseMeter_error =4, EM_message_code_totalPhasePulseDuration_error =5, EM_message_code_samplingFrequency_error =21, EM_message_code_reactPowLength_error =22,
  EM_message_code_reactPowIIRTable_error =23, EM_message_code_phaseLength_error =41, EM_message_code_phaseConfig_error =41, EM_message_code_calibrate_invalidPhase_error =81,
  EM_message_code_error_occurred =255
}
 The following enumeration contain all possible EM SW Library return message codes. More...
 
enum  _EM_Current_Sensor_ { EM_Phase_Sensor_CT =0, EM_Phase_Sensor_Shunt =1, EM_Phase_Sensor_RC =2 }
 Selects appropriate EM Sensor for the corresponding channel. More...
 
enum  _EM_Phase_ {
  EM_Phase_A =0x01, EM_Phase_B =0x02, EM_Phase_C =0x04, EM_Phase_D =0x08,
  EM_Phase_E =0x10, EM_Phase_F =0x20, EM_Phase_Neutral =0x40
}
 Selects appropiate phase to provide results for. More...
 

Functions

EM_message_code EM_configureEnergyMeasurement (EM_SW_Lib_Config_Handle *config, EM_SW_Lib_Result_Handle *result)
 The following API initializes the variables needed by the library at run time. This includes the G constant value used for the IIR filter, 1 over sample count and 1 / (3600 * sampling frequency) which are used to calculate metrology results. This function also checks for configuration errors. More...
 
void EM_initDCFilters (EM_SW_Lib_Config_Handle *config, EM_SW_Lib_Result_Handle *result)
 The following API initializes the voltage / current DC filters to 0. More...
 
void EM_initalizeCalibrationValues (uint8_t *pWorkingCalibration, uint8_t *pFlashCalibration)
 The following API is used to copies calibration values from flapFlashCalibration to pWorkingCalibration if the flash has been written to during the calibration process. If the flash buffer has not been written to, then the default values stored in pWorkingCalibration will be used at run time. More...
 
void EM_updateFlashCalibrationValues (uint8_t *pWorkingCalibration, uint8_t *pFlashCalibration)
 The following API is used store working (RAM) pWorkingCalibration values to the pFlashCalibration structure stored in flash. When there is a power cycle this values will be loaded to the working calibration buffer by using the EM_initalizeCalibrationValues API. More...
 
int16_t EM_voltageDCFilter (int32_t *p, int16_t x)
 The following API is intended for the removal of the DC content from 16 bit 50Hz/60Hz mains signals. All samples should be passed through the filter, in sequence, to obtain a signal free of DC content. The estimation is based on a noise shaped single pole LPF.The cutoff frequency of this filter is set very low, so its gain is essentially flat from 45Hz upwards. This means the filter can take several seconds to stabilize when the signal is initially applied. More...
 
int32_t EM_currentDCFilter (int16_t p[3], int32_t x)
 The following API is intended for the removal of the DC content from 24 bit 50Hz/60Hz mains signals. All samples should be passed through the filter, in sequence, to obtain a signal free of DC content. The estimation is based on a noise shaped single pole LPF.The cutoff frequency of this filter is set very low, so its gain is essentially flat from 45Hz upwards. This means the filter can take several seconds to stabilize when the signal is initially applied. More...
 
void EM_perSample (EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_BG_Results *bgData)
 The following API is used update the previous voltage value for a phase and to increment the number of samples processed in the ISR. This API must be called inside the ISR after all the background APIs are executed for a phase. More...
 
void EM_perDataChunk (EM_SW_Lib_Config_Handle *config, EM_SW_Lib_Result_Handle *result, uint16_t phaseIdx)
 The following API is used to swap the metrology ping and pong pointers. This API must be executed after the Frequency Function has processed N number of cycles (where N = config->algoConfig->mainNomFreq). The Metrology Ping struc is the buffer updated in the ISR, and Metrology Pong struct is used by the foreground APIs. More...
 
void EM_delayCurrent90Degrees (EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_BG_Results *bgData)
 The following API is used to delay the current degree by 90 degrees. It uses an IIR filter with 1 pole to shift current: (all pass 90 degree filter for w = PI*f/fs, f=signal freq and fs = sampling frequency) I90(IDX0 = I(IDX-1)+G*[I(IDX) - I90(IDX-1)] G = (tan(w) - 1)/(tan(w) + 1) The G constant used by the filter is based on signal frequency which is updated ~ once a second. It updates metro Result structure; storing the temporary multiply accumulate (MAC) calculations. More...
 
void EM_genPulseIndPhase (EM_System_Configuration *config, EM_Pulse_Settings *pulse, EM_Phase_Results *result)
 The following API is used to generate pulses for an individual phase. This API checks if the config->pulseGeneration has the result-> phaseID set. If is set then it will generate EM_PHASE_IMP_PER_KWHR impulses per kWhr. This API requires that the pulse settings are initialized for the activePulse and reactivePulse Port/Pins. More...
 
void EM_genPulseTotalPhases (EM_System_Configuration *config, EM_Pulse_Settings *pulse, EM_Total_Results *result)
 The following API is used to generate pulses for the total phase. This API checks if the config->pulseGeneration has EM_PULSE_GEN_PHASE_AGGREGATE set. If is set then it will generate EM_PHASE_IMP_PER_KWHR impulses per kWhr. This API requires that the pulse settings are initialized for the activePulse and reactivePulse Port/Pins. More...
 
void EM_updateOneDivSC (EM_Metrology *metro)
 The following API is used to calculate the 1/sample_count constant. This function must be executed after EM_perDataChunk API for each phase inside the foreground code. The 1/sample_count constant will be used to calculate the results parameters. More...
 
void EM_clearMetrology (EM_Metrology *metro)
 The following API is used to clear the temporary variables inside the metro structure. This API must be called as the last API in the foreground code. More...
 
void EM_updateReactPowConst (EM_Metrology *metro, EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
 The following API is used to look up the IIR G constant used to calculate the Reactive Power using the current frequency value. The index of the G constant in the reactPowIIRTable is calculated: index = (Current Frequency - reactPowIIRMinFreq) >> reactPowIIRShift if the index is > reactPowIIRLength, then index = reactPowIIRLength. More...
 
EM_message_code EM_processSample (EM_SW_Lib_Config_Handle *config)
 The following API is used process the samples. It is used to calculate intermediate dot product results that are fed into the foreground process for the calculation of metrology readings. More...
 
void EM_calcActivePowerMultAcc (EM_Metrology *metro, EM_Phase_Configuration *phase)
 The following API is used to calculate the dot product and accumulation of Voltage and Current. This API reads the current and voltage values using the phase structure.It updates metro Result structure; storing the temporary multiply accumulate (MAC) calculations. The MAC value is used by the foreground function EM_calcActivePowerDiv to calculate Active Power. More...
 
void EM_calcActivePowerDiv (EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
 The following API is used to calculate the active power in the foreground code and store activePower in the result structure. The formula used: (metro->AP_dot_prod->P_accum x metro->oneDivSC) x phase->phaseCalibPtr->activePowerSF If the activePower calculated is less than algo->residualPowerCutoff then activePower will be set to 0. More...
 
void EM_calcActiveEnergy (EM_Metrology *metro, EM_Algorithm_Configuration *algo, EM_Phase_Results *result)
 The following API is used to calculate the active energy result. The formula used to calculate activeEnergy (uWh): (result->activePower x metro->sampleCount) x energyCalcConst Where energyCalcConst = (1/(sampling freq x 3600)) This API must be called after EM_calcActivePowerDiv. More...
 
void EM_calcReactivePowerMultAcc (EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_BG_Results *bgData)
 The following API is used to calculate the dot product and accumulation of Voltage_90 and Current. This API reads the current and voltage values using the phase structure.It uses an IIR filter with 1 pole to shift the the voltage 90 degrees: (all pass 90 degree filter for w = PI*f/fs, f=signal freq and fs = sampling frequency) V90(IDX0 = V(IDX-1)+G*[V(IDX) - V90(IDX-1)] G = (tan(w) - 1)/(tan(w) + 1) The G constant used by the filter is based on signal frequency which is updated ~ once a second. It updates metro Result structure; storing the temporary multiply accumulate (MAC) calculations. The MAC value is used by the foreground function EM_calcReactivePowerDiv to calculate Reactive Power. More...
 
void EM_calcReactivePowerDiv (EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
 The following API is used to calculate the reactive power in the foreground code and store reactivePower in the result structure. The formula used: (metro->RP_dot_prod->P_accum x metro->oneDivSC) x phase->phaseCalibPtr->reactivePowerSF If the reactivePower calculated is less than algo->residualPowerCutoff then reactivePower will be set to 0. More...
 
void EM_calcReactiveEnergy (EM_Metrology *metro, EM_Algorithm_Configuration *algo, EM_Phase_Results *result)
 The following API is used to calculate the reactive energy result. The formula used to calculate reactiveEnergy (uVArh): (result->reactivePower x metro->sampleCount) x energyCalcConst Where energyCalcConst = (1/(sampling freq x 3600)) This API must be called after EM_calcReactivePowerDiv. More...
 
void EM_calcApparentPower (EM_Phase_Results *result)
 The following API is used to calculate apparent power. The formula used to calculate apparentPower (uVA): Sqrt Root (result->activePower ^ 2 + result->reactivePower ^ 2) This API must be called after EM_calcActivePowerMultAcc and EM_calcReactivePowerMultAcc. More...
 
void EM_calcApparentEnergy (EM_Metrology *metro, EM_Algorithm_Configuration *algo, EM_Phase_Results *result)
 The following API is used to calculate the apparent energy result. The formula used to calculate apparentEnergy (uVAh): (result->apparentPower x metro->sampleCount) x energyCalcConst Where energyCalcConst = (1/(sampling freq x 3600)) This API must be called after EM_calcApparentPower. More...
 
void EM_calcPowerFactor (EM_Phase_Results *result)
 The following API is used to calculate power factor. The formula used to calculate it: activePower / apparentPower This API must be called after EM_calcActivePowerMultAcc and EM_calcApparentPower. More...
 
void EM_calcVRMSMultAcc (EM_Metrology *metro, EM_Phase_Configuration *phase)
 The following API is used to calculate the dot product and accumulation for VRMS. This API reads the voltage value from the voltage ptr in the phase structure and updates the Metro Result structure; storing the temporary multiply accumulate (MAC) calculations. The MAC value is used by the foreground function EM_calcVRMSDivSqrt to calculate VRMS. More...
 
void EM_calcVRMSDivSqrt (EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_Results *result)
 The following API is used to calculate the division and square root for VRMS. This API uses the dot product calculated by the EM_calcVRMSMultAcc function. It updates the global Phase Result structure. The result can be read inside the result structure. More...
 
void EM_calcIRMSMultAcc (EM_Metrology *metro, EM_Phase_Configuration *phase)
 The following API is used to calculate the dot product and accumulation for IRMS. This API reads the current value from the current ptr in the phase structure and updates the Metro Result structure; storing the temporary multiply accumulate (MAC) calculations. The MAC value is used by the foreground function EM_calcIRMSDivSqrt to calculate IRMS. More...
 
void EM_calcIRMSDivSqrt (EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_Results *result)
 The following API is used to calculate the division and square root for IRMS. This API uses the dot product calculated by the EM_calcIRMSMultAcc function. It updates the global Phase Result structure. The result can be read inside the result structure. More...
 
void EM_calcIPeak (EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
 The following API is used to calculate I Peak. This API updates the global Phase Result structure. The formula used to calculate: result->IRMS x algo->sqrtTwoConst Where algo->sqrtTwoConst = Sqrt(2) The result can be read inside the result structure. More...
 
void EM_calcVPeak (EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
 The following API is used to calculate V Peak. This API updates the global Phase Result structure. The formula used to calculate: result->VRMS x algo->sqrtTwoConst Where algo->sqrtTwoConst = Sqrt(2) The result can be read inside the result structure. More...
 
void EM_calcFreqPeriod (EM_Metrology *metro, EM_Phase_Configuration *phase, EM_Phase_BG_Results *bgData)
 The following API is used to calculate the period of the voltage signal. For systems with 2 voltages, this API must be used with only one of the voltage signals. This API reads the voltage using the phase structure. This API requires the initialization of the following using the function count = (256 * Sampling Freq. / Fs ): More...
 
void EM_calcFreq (EM_Metrology *metro, EM_Phase_Results *result, EM_Algorithm_Configuration *algo)
 The following API is used to calculate frequency. This API updates the global Phase Result structure. The formula used to calculate: algo->freqSampling * 256L*100L / metro->mainPeriod The result can be read inside the result structure. More...
 
void EM_calcTotalActivePower (uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
 The following API is used to calculate total active power. This API will aggregate the total power of the result->phaseResults buffer using the indexes included in the phaseIdx buffer. More...
 
void EM_calcTotalReactivePower (uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
 The following API is used to calculate total reactive power. This API will aggregate the total power of the result->phaseResults buffer using the indexes included in the phaseIdx buffer. More...
 
void EM_calcTotalApparentPower (uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
 The following API is used to calculate total apparent power. This API will aggregate the total power of the result->phaseResults buffer using the indexes included in the phaseIdx buffer. More...
 
void EM_calcTotalActiveEnergy (uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
 The following API is used to calculate total active energy. This API will aggregate the total energy of the result->phaseResults buffer using the indexes included in the phaseIdx buffer. More...
 
void EM_calcTotalReactiveEnergy (uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
 The following API is used to calculate total reactive energy. This API will aggregate the total energy of the result->phaseResults buffer using the indexes included in the phaseIdx buffer. More...
 
void EM_calcTotalApparentEnergy (uint8_t *phaseIdx, uint8_t length, EM_SW_Lib_Result_Handle *result)
 The following API is used to calculate total apparent energy. This API will aggregate the total energy of the result->phaseResults buffer using the indexes included in the phaseIdx buffer. More...
 

Variables

uint16_t * EMSWLIB_EM_HAL_ADC_maxFreqCount
 The following variable is used as a maximum ADC count to detect frequency. More...
 
uint16_t * EMSWLIB_EM_HAL_ADC_minFreqCount
 The following variable is used as a minimum ADC count to detect frequency. More...
 

Macro Definition Documentation

§ EM_PHASE_RESULT_CALC_VRMS

#define EM_PHASE_RESULT_CALC_VRMS   BIT0

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the VRMS is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_IRMS

#define EM_PHASE_RESULT_CALC_IRMS   BIT1

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the IRMS is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_V_PEAK

#define EM_PHASE_RESULT_CALC_V_PEAK   BIT2

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the V-PEAK is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_I_PEAK

#define EM_PHASE_RESULT_CALC_I_PEAK   BIT3

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the I-PEAK is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_POWER_FACTOR

#define EM_PHASE_RESULT_CALC_POWER_FACTOR   BIT4

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the POWER FACTOR is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_FREQ

#define EM_PHASE_RESULT_CALC_FREQ   BIT5

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the Frequency is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_ACTIVE_POWER

#define EM_PHASE_RESULT_CALC_ACTIVE_POWER   BIT6

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the ACTIVE POWER is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_REACTIVE_POWER

#define EM_PHASE_RESULT_CALC_REACTIVE_POWER   BIT7

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the REACTIVE POWER is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_APPARENT_POWER

#define EM_PHASE_RESULT_CALC_APPARENT_POWER   BIT8

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the APPARENT POWER is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_ACTIVE_ENERGY

#define EM_PHASE_RESULT_CALC_ACTIVE_ENERGY   BIT9

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the ACTIVE ENERGY is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_REACTIVE_ENERGY

#define EM_PHASE_RESULT_CALC_REACTIVE_ENERGY   BIT10

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the REACTIVE ENERGY is calculated by the EM_processSample().

§ EM_PHASE_RESULT_CALC_APPARENT_ENERGY

#define EM_PHASE_RESULT_CALC_APPARENT_ENERGY   BIT11

This define can be used to mask the EM_Phase->phaseResultsSupported variable and determine if the APPARENT ENERGY is calculated by the EM_processSample().

§ EM_PULSE_GEN_PHASE_NONE

#define EM_PULSE_GEN_PHASE_NONE   (0x00)

This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase A.

§ EM_PULSE_GEN_PHASE_A

#define EM_PULSE_GEN_PHASE_A   (0x01)

This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase A.

§ EM_PULSE_GEN_PHASE_B

#define EM_PULSE_GEN_PHASE_B   (0x02)

This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase B.

§ EM_PULSE_GEN_PHASE_C

#define EM_PULSE_GEN_PHASE_C   (0x04)

This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase C.

§ EM_PULSE_GEN_PHASE_D

#define EM_PULSE_GEN_PHASE_D   (0x08)

This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase D.

§ EM_PULSE_GEN_PHASE_E

#define EM_PULSE_GEN_PHASE_E   (0x10)

This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase E.

§ EM_PULSE_GEN_PHASE_F

#define EM_PULSE_GEN_PHASE_F   (0x20)

This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase F.

§ EM_PULSE_GEN_PHASE_NEUTRAL

#define EM_PULSE_GEN_PHASE_NEUTRAL   (0x40)

This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseIndPhase() to generate pulses for Phase neutral.

§ EM_PULSE_GEN_PHASE_AGGREGATE

#define EM_PULSE_GEN_PHASE_AGGREGATE   (0x80)

This define can be used to mask the EM_System_Configuration->pulseGeneration variable . This is used by the EM_genPulseTotalPhases() to generate pulses for the aggregate total.

Typedef Documentation

§ EM_message_code

The following enumeration contain all possible EM SW Library return message codes.

§ EM_Current_Sensor

Selects appropriate EM Sensor for the corresponding channel.

§ EM_Power_t

typedef int64_t EM_Power_t

Type for Power variables.

§ EM_Energy_t

typedef uint64_t EM_Energy_t

Type for Energy variables.

§ EM_Phase

typedef enum _EM_Phase_ EM_Phase

Selects appropiate phase to provide results for.

§ EM_Pulse_Settings

Contains EM SW Lib Phase Calibration.

§ EM_System_Configuration

Contains EM SW Lib System Configuration.

§ EM_Phase_Calibration

Contains EM SW Lib Phase Calibration.

§ EM_Phase_Configuration

Contains EM SW Lib System Configuration.

§ EM_Meter_Configuration

Contains EM SW Lib Meter Configuration.

§ EM_Algorithm_Configuration

Contains EM SW Lib Algorithm Configuration.

§ EM_SW_Lib_Config_Handle

Contains EM SW Lib Config Handle.

§ EM_Metrology

typedef struct _EM_Metrology_ EM_Metrology

§ EM_Phase_BG_Results

Contains EM Phase Background Results.

§ EM_Phase_Results

Contains EM Phase Result.

§ EM_Total_Results

Contains EM Total Results.

§ EM_SW_Lib_Result_Handle

Contains EM SW Lib Result Handle.

Enumeration Type Documentation

§ _EM_message_code_

The following enumeration contain all possible EM SW Library return message codes.

Enumerator
EM_message_code_no_error 

This message code is returned when no error was detected while invoking the API.

EM_message_code_pulseArray_error 

This error is returned if pulseArrayLength is greater than 0 and pulseArray is 0

EM_message_code_indPhaseMeter_error 

and indPhaseMeterConstant is 0

This error is returned if pulseArrayLength is greater than 0

EM_message_code_indPhasePulseDuration_error 

This error is returned if pulseArrayLength is greater than 0 and indPhasePulseDuration is 0

EM_message_code_totalPhaseMeter_error 

This error is returned if pulseArrayLength is greater than 0, totalPhaseMeterConstant is 0 and the pulseGeneration has the EM_PULSE_GEN_PHASE_AGGREGATE flag set

EM_message_code_totalPhasePulseDuration_error 

This error is returned if pulseArrayLength is greater than 0 and totalPhasePulseDuration is 0 and the pulseGeneration has the EM_PULSE_GEN_PHASE_AGGREGATE flag set

EM_message_code_samplingFrequency_error 

This error is returned if the sampling frequency is not greater than 0.

EM_message_code_reactPowLength_error 

This error is returned if the reactPowIIRTable ptr is null and the reactPowIIRLength variable is greater than 0

EM_message_code_reactPowIIRTable_error 

This error is returned if the reactPowIIRLength is greater than 0 and the reactPowIIRTable ptr is equal to 0

EM_message_code_phaseLength_error 

This error is returned if the phaseLength is equal to 0.

EM_message_code_phaseConfig_error 

This error is returned if the phaseConfigPtr is equal to 0.

EM_message_code_calibrate_invalidPhase_error 

This error is returned if the phase number is invalid.

EM_message_code_error_occurred 

This is a generic error this is error that is returned if an unhandled error occurs

§ _EM_Current_Sensor_

Selects appropriate EM Sensor for the corresponding channel.

Enumerator
EM_Phase_Sensor_CT 

Current Transformer (CT)

EM_Phase_Sensor_Shunt 

Shunt.

EM_Phase_Sensor_RC 

Rogowski Coil (RC)

§ _EM_Phase_

enum _EM_Phase_

Selects appropiate phase to provide results for.

Enumerator
EM_Phase_A 
  • Results requested for phase A
EM_Phase_B 
  • Results requested for phase B
EM_Phase_C 
  • Results requested for phase C
EM_Phase_D 
  • Results requested for phase D
EM_Phase_E 
  • Results requested for phase E
EM_Phase_F 
  • Results requested for phase F
EM_Phase_Neutral 
  • Results requested for phase Neutral

Variable Documentation

§ EMSWLIB_EM_HAL_ADC_maxFreqCount

uint16_t* EMSWLIB_EM_HAL_ADC_maxFreqCount

The following variable is used as a maximum ADC count to detect frequency.

§ EMSWLIB_EM_HAL_ADC_minFreqCount

uint16_t* EMSWLIB_EM_HAL_ADC_minFreqCount

The following variable is used as a minimum ADC count to detect frequency.

© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale