From: Tim Wescott on
On 07/11/2010 02:51 PM, Vladimir Vassilevsky wrote:
>
>
> holychicken wrote:
>
>> I am a C programmer working on an embedded application and I am looking
>> into finding a less processor intensive algorithm for calculating the
>> Total
>> Harmonic Distortion than using an FFT.
>>
>> In my search, however, almost every calculation involves looking at
>> each of
>> the harmonics. Is there any way to subtract out the fundamental RMS value
>> and get the THD from there? I have the RMS value of the fundamental
>> already and was just wondering if I could use that in someway to get the
>> THD.
>>
>> Thanks for any input even if it is just, "tough luck."
>
> If you subtract fundamental frequency from the signal, you will get a
> mix of (THD + noise + non-harmonic components + nonstationarity +
> numeric artifacts). The result may or may not be acceptable depending on
> your application. What THD numbers are you after?

Assuming that you're doing a "run a sine through the system & look at
the results" sort of test, you could average one cycle of the output
over a number of repetitions -- that would pound down both noise and
non-harmonic components, although it wouldn't do anything with noise.
Then you could subtract out the best-fit fundamental sine for an "answer".

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
From: Jerry Avins on
On 7/12/2010 11:10 AM, Tim Wescott wrote:
> On 07/11/2010 02:51 PM, Vladimir Vassilevsky wrote:
>>
>>
>> holychicken wrote:
>>
>>> I am a C programmer working on an embedded application and I am looking
>>> into finding a less processor intensive algorithm for calculating the
>>> Total
>>> Harmonic Distortion than using an FFT.
>>>
>>> In my search, however, almost every calculation involves looking at
>>> each of
>>> the harmonics. Is there any way to subtract out the fundamental RMS
>>> value
>>> and get the THD from there? I have the RMS value of the fundamental
>>> already and was just wondering if I could use that in someway to get the
>>> THD.
>>>
>>> Thanks for any input even if it is just, "tough luck."
>>
>> If you subtract fundamental frequency from the signal, you will get a
>> mix of (THD + noise + non-harmonic components + nonstationarity +
>> numeric artifacts). The result may or may not be acceptable depending on
>> your application. What THD numbers are you after?
>
> Assuming that you're doing a "run a sine through the system & look at
> the results" sort of test, you could average one cycle of the output
> over a number of repetitions -- that would pound down both noise and
> non-harmonic components, although it wouldn't do anything with noise.
> Then you could subtract out the best-fit fundamental sine for an "answer".

It boils down to "What do you really want to know" and "What information
will you settle for instead."


Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
From: Tim Wescott on
On 07/12/2010 08:27 AM, Jerry Avins wrote:
> On 7/12/2010 11:10 AM, Tim Wescott wrote:
>> On 07/11/2010 02:51 PM, Vladimir Vassilevsky wrote:
>>>
>>>
>>> holychicken wrote:
>>>
>>>> I am a C programmer working on an embedded application and I am looking
>>>> into finding a less processor intensive algorithm for calculating the
>>>> Total
>>>> Harmonic Distortion than using an FFT.
>>>>
>>>> In my search, however, almost every calculation involves looking at
>>>> each of
>>>> the harmonics. Is there any way to subtract out the fundamental RMS
>>>> value
>>>> and get the THD from there? I have the RMS value of the fundamental
>>>> already and was just wondering if I could use that in someway to get
>>>> the
>>>> THD.
>>>>
>>>> Thanks for any input even if it is just, "tough luck."
>>>
>>> If you subtract fundamental frequency from the signal, you will get a
>>> mix of (THD + noise + non-harmonic components + nonstationarity +
>>> numeric artifacts). The result may or may not be acceptable depending on
>>> your application. What THD numbers are you after?
>>
>> Assuming that you're doing a "run a sine through the system & look at
>> the results" sort of test, you could average one cycle of the output
>> over a number of repetitions -- that would pound down both noise and
>> non-harmonic components, although it wouldn't do anything with noise.
>> Then you could subtract out the best-fit fundamental sine for an
>> "answer".
>
> It boils down to "What do you really want to know" and "What information
> will you settle for instead."

It does indeed, and so often and for so many different fields of
endeavor. I _really_ like that wording.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
From: Jerry Avins on
On 7/12/2010 11:50 AM, Tim Wescott wrote:
> On 07/12/2010 08:27 AM, Jerry Avins wrote:

...

>> It boils down to "What do you really want to know" and "What information
>> will you settle for instead."
>
> It does indeed, and so often and for so many different fields of
> endeavor. I _really_ like that wording.

A close cousin is "What do you really want to do and what action will
you settle for instead."

Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
From: holychicken on
Well, what I want is an exact measurement of the THD of both voltage and
current wave forms that takes absolutely no time, no memory, no extra code
and no time to develop. ;)

What I will settle for is a time efficient algorithm (that doesn't require
a ridiculous amount of RAM) that gives a rough estimate of the THD (+/-
10%) of a given waveform.

I currently store the raw waves and calculate a number of things, the only
really relevant I believe is the RMS, including the I and Q, value of the
fundamental of the waves.

If the FFT is the best way to do this, I will go ahead with it, but I am no
DSP expert and it just seems to me that there would be a simpler, faster
way to get a rough estimate, so I was hunting around hoping to find
something.

Again, thanks for all the input, definitely giving me things to think
about.