Prev: Exocortex.DSP FFT implimentation? What should my result look like.
Next: invert filter bank of parallel second order sections?
From: Jerry Avins on 12 Jul 2010 14:25 On 7/12/2010 1:51 PM, holychicken wrote: > 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. You haven't fully answered my original question: "THD of what?" Do you know the precise frequency(s) of the fundamental(s)? Another question is how many bits you calculate with. That bears on the the depth of the notch you can expect from a notch filter. Yet another: how much error can you tolerate? Bleed-through in the notch filter that is -60 dB will show up as 0.1% THD. -80 dB will appear as .01%. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
From: holychicken on 12 Jul 2010 14:55 > >You haven't fully answered my original question: "THD of what?" Do you >know the precise frequency(s) of the fundamental(s)? Another question is >how many bits you calculate with. That bears on the the depth of the >notch you can expect from a notch filter. Yet another: how much error >can you tolerate? Bleed-through in the notch filter that is -60 dB will >show up as 0.1% THD. -80 dB will appear as .01%. > >Jerry >-- >Engineering is the art of making what you want from things you can get. >����������������������������������������������������������������������� > What I am looking for is the THD as defined by the IEEE 519 spec: "The ratio of the root-mean-square of the harmonic content to the root-meansquare value of the fundamental quantity, expressed as a percent of the fundamental" It will be for power transmission and distribution systems so I know the fundamental will be 60hz. I am using a 12 bit ADC, taking 128 samples over a single 60Hz cycle. They are looking for THDs between 5-10% so .1% might be pushing it as I think 10% is a good number to shoot for. I hope that is enough information.
From: dbd on 12 Jul 2010 21:03 On Jul 12, 2:57 pm, Jerry Avins <j...(a)ieee.org> wrote: >... > > THD is usually defined as a voltage ratio, rather than a power ratio, so > if noise is negligible (as it should be with good instrumentation) it is > the square root of the power ratio. That's where my numbers came from. > Since the processing doesn't need to be done in real time, it should be > easy to design a deep notch. > > Jerry IEEE 519 is a standard for power line distortion where loads are not resistive or even necessarily linear. This makes the comparison of voltage and power ratios inappropriate. In IEEE 519-1992 the THD seems to be defined as the RMS combination of current components. The OP's statement about having 128 samples in a single cycle may indicate that he has synchronous samples as some other power measurement standards require. This makes the use of the FFT straightforward as the harmonics are then bin centered. Dale B. Dalrymple
From: kevin on 13 Jul 2010 05:34 On 07/12/2010 11:55 AM, holychicken wrote: >What I am looking for is the THD as defined by the IEEE 519 spec: "The >ratio of the root-mean-square of the harmonic content to the >root-meansquare value of the fundamental quantity, expressed as a percent >of the fundamental" >It will be for power transmission and distribution systems so I know the >fundamental will be 60hz. >I am using a 12 bit ADC, taking 128 samples over a single 60Hz cycle. They >are looking for THDs between 5-10% so .1% might be pushing it as I think >10% is a good number to shoot for. >I hope that is enough information. I may be missing something here (my sanity, perhaps?), but doesn't the THD for a 60 Hz line refer to the fundamental versus the harmonics at 120, 180, 240 Hz ... etc.? I am admittedly not an expert at this, so please bear with me if it is indeed my sanity that has gone missing (I think I misplaced it in the fruit and nut section of a local supermarket - I'll look for it later). I did a little Googling, and it seems that you can start religious wars over definitions of THD, as in: http://www.hydrogenaudio.org/forums/index.php?showtopic=51180 I hope no one gets burned at the stake over the above (that was the penalty for heresy in the Middle Ages - supposedly to mimic the fires of Hell). Especially not you or me (well ... especially not me). It just seems to me that you'd want the info of your 60, 120, 180 Hz .. etc. waveforms. According to your post, you're computing a 128 point FFT based on one cycle of your 60 Hz line (sample_rate = 128 and N = 128, for a 'df' in the frequency domain of sample_rate/N = 1), which puts your (supposedly) 60 Hz line at bin 60. Now I am well aware of the fact that if you don't have an anti-aliasing filter, the 120 Hz 2nd harmonic will show up at bin 120, and higher harmonics will be aliased back into other bins. Is this what you intend? For a simple estimate of THD, might you not compute a single frequency DFT at 60, 120, 180 Hz. .. etc., and then do the THD calculation in the heretical manner of your choosing? You might not need very many single frequency DFT's to get 10% accuracy. Admittedly, I'm not an expert at THD, so keep that in mind. I'm sure that others can offer you better insight. Kevin McGee
From: Grant Griffin on 13 Jul 2010 08:43 holychicken wrote: > 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. For a change of pace, I think I'll answer your question rather than chide you about it. :-) I did a THD+N calculation awhile back, and here's what I learned from that. Be warned, though: it's not the simple problem that it seems, and it took a lot of time to get it right. My basic method was to mix a complex (sine and cosine) version of the analysis frequency with the input signal. The result was integrated and summed to form an estimate of the fundamental in complex form. From there, you could calculate the magnitude of the fundamental. This amounts to a bandpass filter around the fundamental. The width of the bandpass filter is proportional to the number of samples you integrate to make the measurement. Calculating THD+N was straightforward from there because you could calculate the magnitude of the total signal as via RMS value and you had the magnitude of the fundamental. (Formulas are available on Wikipedia.) Now we get to the hard part: it's _critical_ to integrate a whole number of periods of your fundamental of interest. Otherwise, you get what would be called "spectral leakage" in an DFT/FFT analysis. Basically, you have to calculate how many samples make up a whole number of periods and integrate that many samples after you determine approximately how many periods or samples you want to use. It's critically important to be accurate about this because any amount of spectral leakage can dominate the THD calculation and give you inaccurate results. In fact, I ended up using a frequency that was an exact number of samples per period. Alternatively, you can use windowing to counteract spectral leakage. However, when I tried that (short story), I found that it caused more problems than it saved. So I ultimately abandoned that approach. If you need THD rather than THD+N, you can adapt the method by using the harmonic frequencies as additional analysis frequencies. Taking this to its logical conclusion when analyzing with many frequencies, you might want to use an FFT. In that case, you will need to set the number of points in the FFT such that all your analysis points align on the exact centers of FFT bins. Generally speaking, you will need a "mixed radix" (not power-of-2) FFT for this. Alternatively, if you can control your analysis frequency, you can pick it such that its fundamental and harmonics align on some convenient power-of-2 FFT size. ScopeDSP (my product) was a useful reference for this because it does many of these same operations. I have a tutorial for ScopeDSP that illustrates the idea of aligning the input frequency to the FFT bins. See http://www.iowegian.com/scopedsp and http://www.iowegian.com/dsp/tutorial/adc . Grant -- _____________________________________________________________________ Grant R. Griffin Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com See http://www.iowegian.com/img/contact.gif for e-mail address
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: Exocortex.DSP FFT implimentation? What should my result look like. Next: invert filter bank of parallel second order sections? |