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... | |
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.
[in] | p | is a pointer to the filter state variable |
[in] | x | is the next signal sample |
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.
[in] | p | is a pointer to the filter state variable |
[in] | x | is the next signal sample |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Ping Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
[in] | bgData | is a pointer to the EM RP Phase Results structure |
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.
[in] | config | is a pointer to the EM SW Library user configuration |
[in] | result | is a pointer to the EM SW Library result structure |
[in] | phaseIdx | is the index for the phase |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Ping Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
[in] | bgData | is a pointer to the EM SW BG Result structure |
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.
[in] | config | is a pointer to the EM SW Library user configuration |
[in] | pulse | is a pointer to the EM SW Library pulse structure |
[in] | result | is a pointer to the EM SW Library result structure |
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.
[in] | config | is a pointer to the EM SW Library user configuration |
[in] | pulse | is a pointer to the EM SW Library pulse structure |
[in] | result | is a pointer to the EM SW Library result structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
[in] | result | is a pointer to the EM SW Result structure |
[in] | algo | is a pointer to the EM SW Algorithm structure |
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.
[in] | config | is a pointer to the EM SW Library user configuration |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Ping Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
[in] | result | is a pointer to the EM SW Result structure |
[in] | algo | is a pointer to the EM SW Algorithm structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
[in] | algo | is a pointer to the EM SW Algorithm structure |
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Ping Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
[in] | bgData | is a pointer to the EM SW BG Result structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
[in] | result | is a pointer to the EM SW Result structure |
[in] | algo | is a pointer to the EM SW Algorithm structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
[in] | algo | is a pointer to the EM SW Algorithm structure |
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
[in] | algo | is a pointer to the EM SW Algorithm structure |
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Ping Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
[in] | result | is a pointer to the EM SW Library result handle |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Ping Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
[in] | result | is a pointer to the EM SW Library result handle |
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.
[in] | result | is a pointer to the EM SW Result structure |
[in] | algo | is a pointer to the EM SW Algorithm structure |
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.
[in] | result | is a pointer to the EM SW Result structure |
[in] | algo | is a pointer to the EM SW Algorithm structure |
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 ):
[in] | metro | is a pointer to the EM SW Metrology structure (Ping Ptr) |
[in] | phase | is a pointer to the EM SW Phase structure |
[in] | bgData | is a pointer to the EM SW BG Result structure |
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.
[in] | metro | is a pointer to the EM SW Metrology structure (Pong Ptr) |
[in] | result | is a pointer to the EM SW Result structure |
[in] | algo | is a pointer to the EM SW Algorithm structure |
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.
[in] | phaseIdx | is a pointer to the phase indexes buffer |
[in] | length | is the length of the phaseIdx buffer |
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | phaseIdx | is a pointer to the phase indexes buffer |
[in] | length | is the length of the phaseIdx buffer |
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | phaseIdx | is a pointer to the phase indexes buffer |
[in] | length | is the length of the phaseIdx buffer |
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | phaseIdx | is a pointer to the phase indexes buffer |
[in] | length | is the length of the phaseIdx buffer |
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | phaseIdx | is a pointer to the phase indexes buffer |
[in] | length | is the length of the phaseIdx buffer |
[in] | result | is a pointer to the EM SW Result structure |
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.
[in] | phaseIdx | is a pointer to the phase indexes buffer |
[in] | length | is the length of the phaseIdx buffer |
[in] | result | is a pointer to the EM SW Result structure |