I am using STPM34 module for measuring AC signals , the output of the STPM34 is digital and it calculates instantaneous current and voltage , fundamental current and voltage, RMS current and voltage, i want to calculate the thd of a 50-60 Hz instantaneous current signal in real time, there is method using fft but it is not applicable on a real time digital signal of an energy meter ic ,any methods or algorithms please ?!!
Page 52 of the data sheet:
Raw ADC samples are also available for post-processing by MCU in registers from
DSP_REG2 to DSP_REG9.
By taking into account the internal parameters in Table 13 and the analog front end
components in Table 14, LSB values of voltage and current registers are the following:
The data is there - you can work out THD just the same way as a distortion meter does, with a notch filter to remove the fundamental. You might get away with a high pass filter. You can then mimic the kind of processing the STPM34 uses to derive RMS from data samples to get the RMS distortion and noise. If you want to get rid of the noise you will need to use a comb filter to only pass the harmonics. If you are only interested in a few harmonics it will be easier to filter them out with band pass filters.
Unless you need all the other features of the STPM34 chip it would be easier to use a standard ADC without the signal processing.