i want to use the FFT e-meter library on my TWR-KM34Z50. The problem is there is no description of the function "EnergyCalculation" (in AN4255, AN4847). The only reference to that function i have found is in DRM149. The function is used in the "Kinetis-M Two - Phase Power Meter Reference Design" Firmware. Is it possible to get that firmware, so i can see how to implement the function?
void EnergyCalculation (volatile unsigned long *energy, unsigned long *energyrem, unsigned long power, unsigned long coef);
energy - pointer to the active/reactive, import/export energy with resolutionn 0.1 Wh or 0.1 VARh, i.e. 1000=100.0 Wh/VARh.
energyrem - pointer to the energy remainder (decimal point of the energy)
power - instantaneous power (active or reactive)
coef - 'hour' coefficient = line frequency*3600, with mHz frequency resolution, i.e. 50000=50.000Hz
Description: The function upgrades both the energy and energy remainder values (addressed by respective pointers) by a new values. This function should be called after the 'PowerCalculation' processing in the user code.
Note: I will add the function description into the AN4255 soon. Currently I am preparing a new FFT metering library (METERLIBFFT 2.3.1) with different API and with different functions name (unified with the 'Filter-based' metering library).
What does that mean "import/export" energy here?
if import + export = total, why don't just use energy as a single variable instead of two params (import+export)here?
The FFT-based metering library is used for 4-quadrant energy measurement, that is: import/export, active/reactive.
It means it can measure both positive and negative active energy, and the same for reactive energy. Therefore, it uses four separated energy counters.
Identification of imported and exported active and reactive energy allows you to monitor energy flow in both directions: delivered from the utility and produced on-site which is ideal for facilities with back-up generators or green power capabilities (for example solar panels).
Thanks for your explanation.
What about the reactive energy counter with that import and export concept? how do you distinguish whether it is capacitive or inductive load . I expected the Varh counter is a signed counter, but according to the meter fft lib, the reactive energy counter is an unsigned uint 32 varaible.
All four energy counters are unsigned values. These values are incremented only!
The type of the load (i or c) is recognized by the sign of both active (P) and reactive (Q) power:
Note: for deep explanation of the power / energy measurement see here: Beckhoff Information System - English
Regarding the firmware of meterlib, I think you can download it via the AN4265SW from the website:
The meter library includes the api function to compute the RMS value for voltage and current in both time and frequency domain. You have to register on the website, then download the software.
AN4265SW includes the Filter based meterlib, but i would like to use the FFT based meterlib (AN4847SW) to analyse the harmonics of a signal. In the FFT based meterlib there exist 2 functions for calculation of the metering quantities.