01-10-2007 10:16 AM - edited 01-10-2007 10:16 AM
Hello,
We need to to perform frequency analysis including parameter THD+N and I believe this functionality is broken.
To show that is broken, I modified NI example THD.C by changing line 109 (in LabWindows/CVI 8.0.0 (273)):
for(i = 0; i < frame_size; i++)
*(distored_signal + i) = *(sine_wave+i) + (*(sine_wave+i) * *(sine_wave+i) * 0.5)
+ *(noise+i);
into
/*+ (*(sine_wave+i) * *(sine_wave+i) * 0.5)for(i = 0; i < frame_size; i++)
*(distored_signal + i) = *(sine_wave+i)
+ *(noise+i)*/
;and we should obtain harmonic signal with no distortion and no noise. But we get the result from the picture, where THD+N is obviously wrong. It gets worse with different window types.
Thank you
Message Edited by romanZ on 01-10-2007 10:17 AM
Message Edited by romanZ on 01-10-2007 10:18 AM
01-11-2007 06:59 PM
Hi RomanZ,
Thank you for your post. We are looking into this.
01-12-2007 03:53 PM - edited 01-12-2007 03:53 PM
Hi RomanZ,
Thanks for bringing this issue to our attention - this is a bug and we are working on it. For now, using a Hanning or Hamming window produces much better results.
Message Edited by AEDavid on 01-12-2007 03:55 PM
02-28-2007 09:36 PM
03-01-2007 11:07 AM
Hi Eric,
Thank you for the feedback. I apologize for the inconvenience. I have updated the Corrective Action Request to indicate that you are also needing a fix. There is currently no update, but R&D is examining this issue. For now, using a Hanning or Hamming window produces much better results.
03-13-2007 12:42 AM
Hello,
I think this problem is caused by spectrum leakage during the calculation of auto power spectrum.
After your change of the code, the input signal is 1000Hz sine wave. When you use default sampling rate and frame size, the discrete signal will be 1024-point signal covering 102.4 periods of the sine wave. Spectrum leakage will occur when you try to calculate the auto power spectrum of the sampled signal.
You can use Hanning window or some other window before auto power spectrum calculation to reduce spectrum leakage.
And for this particular case you can eliminate the spectrum leakage by setting the sampling rate to 10240Hz to get 100 complete periods of sine wave.
07-28-2010 04:21 AM
i got the wrong result using "Harmonic Analyzer Using Signal" function. I using a squarewave in 1kHz with 50% duty to test the funtion, but the ratio of THD is only 48%. I use a instrument to measure the same signal, and got THD ratio at 60%.
I am confused.
do you have some suggestion?Thanks
07-28-2010 04:21 AM
i got the wrong result using "Harmonic Analyzer Using Signal" function. I using a squarewave in 1kHz with 50% duty to test the funtion, but the ratio of THD is only 48%. I use a instrument to measure the same signal, and got THD ratio at 60%.
I am confused.
do you have some suggestion?Thanks
07-28-2010 10:49 PM
Hello,
Theoretically the THD of 50% duty squarewave should be 48%.
You can refer to the attachment for detailed derivation.
Could you please tell me the sampling rate and the number of samples in your use case? The result might be inaccurate if you do not set the sampling rate and the number of samples properly.
07-30-2010 01:41 AM - edited 07-30-2010 01:49 AM
Thanks
I don't have office2007 on my computer and I can't donwload the file. please, can you save your code in txt file ?
Sampling Rate is 250kHz
the number of samples is 262144
the input signal is squarewave at 1kHz