Functions
Result_api

Functions

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...
 

Detailed Description

Function Documentation

§ EM_voltageDCFilter()

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.

Parameters
[in]pis a pointer to the filter state variable
[in]xis the next signal sample
Returns
None

§ EM_currentDCFilter()

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.

Parameters
[in]pis a pointer to the filter state variable
[in]xis the next signal sample
Returns
None

§ EM_perSample()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Ping Ptr)
[in]phaseis a pointer to the EM SW Phase structure
[in]bgDatais a pointer to the EM RP Phase Results structure
Returns
None

§ EM_perDataChunk()

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.

Parameters
[in]configis a pointer to the EM SW Library user configuration
[in]resultis a pointer to the EM SW Library result structure
[in]phaseIdxis the index for the phase
Returns
None

§ EM_delayCurrent90Degrees()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Ping Ptr)
[in]phaseis a pointer to the EM SW Phase structure
[in]bgDatais a pointer to the EM SW BG Result structure
Returns
None

§ EM_genPulseIndPhase()

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.

Parameters
[in]configis a pointer to the EM SW Library user configuration
[in]pulseis a pointer to the EM SW Library pulse structure
[in]resultis a pointer to the EM SW Library result structure
Returns
None

§ EM_genPulseTotalPhases()

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.

Parameters
[in]configis a pointer to the EM SW Library user configuration
[in]pulseis a pointer to the EM SW Library pulse structure
[in]resultis a pointer to the EM SW Library result structure
Returns
None

§ EM_updateOneDivSC()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
Returns
None

§ EM_clearMetrology()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
Returns
None

§ EM_updateReactPowConst()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
[in]resultis a pointer to the EM SW Result structure
[in]algois a pointer to the EM SW Algorithm structure
Returns
None

§ EM_processSample()

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.

Parameters
[in]configis a pointer to the EM SW Library user configuration
Returns
EM_message_code

§ EM_calcActivePowerMultAcc()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Ping Ptr)
[in]phaseis a pointer to the EM SW Phase structure
Returns
None

§ EM_calcActivePowerDiv()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
[in]phaseis a pointer to the EM SW Phase structure
[in]resultis a pointer to the EM SW Result structure
[in]algois a pointer to the EM SW Algorithm structure
Returns
None

§ EM_calcActiveEnergy()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
[in]algois a pointer to the EM SW Algorithm structure
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcReactivePowerMultAcc()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Ping Ptr)
[in]phaseis a pointer to the EM SW Phase structure
[in]bgDatais a pointer to the EM SW BG Result structure
Returns
None

§ EM_calcReactivePowerDiv()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
[in]phaseis a pointer to the EM SW Phase structure
[in]resultis a pointer to the EM SW Result structure
[in]algois a pointer to the EM SW Algorithm structure
Returns
None

§ EM_calcReactiveEnergy()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
[in]algois a pointer to the EM SW Algorithm structure
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcApparentPower()

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.

Parameters
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcApparentEnergy()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
[in]algois a pointer to the EM SW Algorithm structure
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcPowerFactor()

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.

Parameters
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcVRMSMultAcc()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Ping Ptr)
[in]phaseis a pointer to the EM SW Phase structure
Returns
None

§ EM_calcVRMSDivSqrt()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
[in]phaseis a pointer to the EM SW Phase structure
[in]resultis a pointer to the EM SW Library result handle
Returns
None

§ EM_calcIRMSMultAcc()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Ping Ptr)
[in]phaseis a pointer to the EM SW Phase structure
Returns
None

§ EM_calcIRMSDivSqrt()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
[in]phaseis a pointer to the EM SW Phase structure
[in]resultis a pointer to the EM SW Library result handle
Returns
None

§ EM_calcIPeak()

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.

Parameters
[in]resultis a pointer to the EM SW Result structure
[in]algois a pointer to the EM SW Algorithm structure
Returns
None

§ EM_calcVPeak()

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.

Parameters
[in]resultis a pointer to the EM SW Result structure
[in]algois a pointer to the EM SW Algorithm structure
Returns
None

§ EM_calcFreqPeriod()

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 ):

  • EMSWLIB_EM_HAL_ADC_minFreqCount - should be calculated for Fs = 70 Hz
  • EMSWLIB_EM_HAL_ADC_maxFreqCount - should be calculated for Fs = 40 Hz For example For Sampling Freq = 4096, minFreqCount = (256*4096 / 70) = 14,980 maxFreqCount = (256*4096 / 40) = 26,214 The Main Period is calculated using a running average of the main_period. To calculate the period interpolation is used using a resolution of 256. The period between two zero crossings (ZC_1 and ZC_2) is calculated using the following formula: Given, XC_N (interpolated x value) = - 256 * Y_Prev / (Y_Act - Y_Prev) Where Y_Prev and Y_Act are the Y values in the negative to positive transition (e.g. Y_Prev < 0 and Y_Act >= 0 ) Delta_N = 256 - XC_N Then, Period_N = Delta_N-1 + 256*samples (not including Y_Prev and Y_Act) + XC_N (e.g. for Period 2) = Delta_1 + 256*samples + XC_2
Parameters
[in]metrois a pointer to the EM SW Metrology structure (Ping Ptr)
[in]phaseis a pointer to the EM SW Phase structure
[in]bgDatais a pointer to the EM SW BG Result structure
Returns
None

§ EM_calcFreq()

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.

Parameters
[in]metrois a pointer to the EM SW Metrology structure (Pong Ptr)
[in]resultis a pointer to the EM SW Result structure
[in]algois a pointer to the EM SW Algorithm structure
Returns
None

§ EM_calcTotalActivePower()

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.

Parameters
[in]phaseIdxis a pointer to the phase indexes buffer
[in]lengthis the length of the phaseIdx buffer
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcTotalReactivePower()

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.

Parameters
[in]phaseIdxis a pointer to the phase indexes buffer
[in]lengthis the length of the phaseIdx buffer
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcTotalApparentPower()

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.

Parameters
[in]phaseIdxis a pointer to the phase indexes buffer
[in]lengthis the length of the phaseIdx buffer
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcTotalActiveEnergy()

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.

Parameters
[in]phaseIdxis a pointer to the phase indexes buffer
[in]lengthis the length of the phaseIdx buffer
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcTotalReactiveEnergy()

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.

Parameters
[in]phaseIdxis a pointer to the phase indexes buffer
[in]lengthis the length of the phaseIdx buffer
[in]resultis a pointer to the EM SW Result structure
Returns
None

§ EM_calcTotalApparentEnergy()

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.

Parameters
[in]phaseIdxis a pointer to the phase indexes buffer
[in]lengthis the length of the phaseIdx buffer
[in]resultis a pointer to the EM SW Result structure
Returns
None
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale