(View more DSP or Integrated Systems information or download the preliminary implementation.)
Under some operating conditions, power system devices exhibit nonlinear characteristics such as magnetic saturation, resulting in distorted voltage and current waveforms that can interfere with other devices on the power system. The first step in controlling the distortions is measuring them accurately. This seems like a relatively easy application for Fourier analysis. For example, collect 256 samples that span one power cycle at the fundamental frequency. A 256-point FFT would then deliver an analysis of the first 128 harmonics, more than enough to cover the 40 or so needed for a harmonic distortion analysis.
While the basic idea is good, this turns out to be seriously over-simplified, and measurements obtained that way would be unsatisfactory. The rest of this note discusses how to extend the basic idea so that it yields fully satisfactory results. Actually, the results are much better than merely satisfactory. How much better might surprise you.
Hazards and Solutions for FFT Harmonic Analysis
The basic idea of applying an FFT for a spectrum analysis is a good one, but it must be applied carefully. To begin cataloging the difficulties and the solutions:
- Transient noise. The ordinary chatter of various small transients from circuit switching, regulation, and load disturbances should not make any significant difference. With very small data sets, the results are sensitive to them.
Solution. Averaging can reduce the effects of the small random disturbances, so a good test must cover data from multiple power cycles. Standards typically require a minimum of 4 cycles per analysis. Using more cycles is better.
- Subharmonic and modulation effects. Some power system disturbances result from coupling to dynamic systems whose modes produce off-harmonic disturbances. These effects distort the FFT's harmonic profile.
Solution. It is not possible to correct for the modulation effects completely, but modulation disturbances tend to spread their energy across a band of FFT locations. If the resolution of the FFT is greatly increased, much of the disturbance energy effects appear at locations that are not relevant to harmonic analysis, reducing the impact on the important harmonic frequencies.
- Frequency drift. The fundamental frequency of the power system is a nominal figure that represents a long-term average but not necessarily an accurate short-term condition. The frequency might drift a significant fraction of a percent above or below the nominal operating frequency.
When the harmonic frequencies match the discrete frequencies of an FFT exactly, the harmonics appear as a precise "picket fence" in the spectrum, with intermediate frequency terms zero, as in the following plot.
After frequency drift shifts the harmonic frequencies so that they no longer align to the frequencies specifically analyzed by the FFT, the FFT attempts to represent them as an artificial combination of the analyzed frequencies. This causes an apparent "smearing" of the harmonic peaks, making the true harmonics difficult to analyze. Observe how the peaks are reduced, wider, and have their energy "smeared" into side bands.
Frequency shifts have little effect on the lower harmonics, but higher harmonics can be shifted to FFT locations where they are not expected, complicating the analysis considerably.
Solution. Align the sampling frequency to the current power frequency. This forces the harmonic frequencies to stay aligned with the discrete frequencies analyzed by the FFT. Use a higher-resolution FFT so that residual effects do not spread from one harmonic to its neighbors.
- Block truncation. An FFT analysis chops a signal into discrete data blocks that are supposed to contain exact multiples of the waveform cycle. If a cycle is incomplete, or if there are a few samples from the next cycle, this can cause a response in the FFT analysis much as if a transient disturbance arrived at the very end of the block. The artificial disturbance can have a very significant effect on the apparent magnitudes of harmonic frequencies.
Windowing Solution. A windowing operator has the property that it attenuates disturbances at the ends of data blocks, and this can be used to advantage to suppress the artificial transient disturbances. This is the traditional DSP solution, but, unfortunately, windowing has the side effect of losing good information as it suppresses bad artifacts. To minimize the loss of information, the input data blocks must be 50% overlapped and partially re-analyzed, doubling the computational effort. The following plot shows the original distorted spectrum resulting from frequency shift, and the correction that windowing provides.
For this particular test case, a perfect correction would produce harmonic peaks along a straight line. You can see that the corrections are very good but not perfect.
Adjustable Sampling Solution. If the data sampling is locked to the observed system frequency, a data set of a fixed number of samples corresponds exactly to a fixed number of fundamental cycles. This eliminates FFT "smearing", so windowing operations are not needed. The usual way of adjusting the sampling – estimating the power system frequency and controlling the sampling time clock hardware dynamically – is expensive to implement and carries its own set of problems. Identifying cycles from a zero crossing analysis and resampling using well-known DSP techniques achieves the same effect, but more easily, with almost perfect correction.
To summarize then, features needed to make an FFT analysis effective are:
- high sampling rates, to characterize the waveform accurately and avoid aliasing effects;
- long data blocks for high frequency resolution, so harmonic frequencies are well isolated from the others, and random noise is attenuated;
- sampling rates adjusted to the current value of the power system frequency, so that the harmonic frequencies of interest align with the frequency samples analyzed by the FFT.
There is insufficient room in this article to fully discuss the solution method. The basic idea can be outlined.
- Maintain data in a buffer, with extra measured samples before and after to support filtering.
- Identify the desired number of power cycles by identifying locations of zero crossings.
- Resample the data  between the zero crossings to establish a fixed 4096-point data block well-suited for FFT analysis.
- Apply decimation techniques  to simplify the FFT, for improved processing efficiency.
- Complete the FFT analysis to yield the 40 desired harmonic power terms.
- Shift data so that the next analysis begins at the same point where the previous one ended, losing no information.
The critical step in the sequence above is the resampling operation.
Select the sampling rate so that the number of samples collected would be exactly 4096 at the exactly nominal power system frequency. As the actual operating frequency will not be exactly nominal, the actual number of samples collected will be N, which can be lower or higher. To resample into a new data set with exactly 4096 equally-spaced samples, the new sample values must be taken from the locations
0 * (N/4096)
1 * (N/4096)
4095 * (N/4096)
But these are fractional locations! This turns out to be the classical problem of reconstructing signal values at any desired point in time, given a set of sample values. The mathematical operations for this are discussed in another note  on this site. Here, the resampling must establish a slightly different spacing between samples, where in the other note, the goal is to keep the original spacing but shift all sample locations equally. As far as the digital signal processing goes, the mathematical formulas turn out to be exactly the same.
A Packaged Solution
All of this might sound complicated, but it really boils down to only a few operations:
- Data management method for refilling buffers
DAPL system processing commands really shine when it comes to specialized buffer management.
- Data resampling technique for rebuilding FFT blocks.
The interpolation filtering code is borrowed from the
MTSFILT package, also available on this site.
- A special function to apply the FFT decimation operation.
This requires just some simple arithmetic and indexing.
- Conventional FFT with power spectral density post-processing.
No need to reinvent this. FFT services are supported directly by the Developer's Toolkit for DAPL.
Putting these pieces together to form a customized power system harmonic analyzer is easy. What remains is your choice about which processing to perform in the Data Acquisition Processor.
- Nothing. If you use primitive data acquisition hardware, this would be your only choice. Your application must then cope with all the serious number crunching for the interpolation filters, data buffer management, and FFT mathematics. It can be done, of course, but you will pay the price in complicated software. Some people never learn.
- Let the Data Acquisition Processor precondition the data stream so that it is resampled and ready for straightforward FFT analysis. After the data are appropriately reduced to the required fixed block size, the FFT analysis is vastly more straightforward on the host processor.
- It is no harder to ask the Data Acquisition Processor for a block of finished FFT results than it is to ask for raw data. When the data arrive in finished form, they can be pumped straight through to the logs and graphical displays. So why make anything more complicated than that?
We have provided a
HARMONM command module that you may download. Included in the download is an application demo configuration for DAPstudio. That application sets up the Data Acquisition Processor and displays results continuously. Of course, you are not limited to this. Any application software could download the same configuration to the Data Acquisition Processor, and obtain the same results. The data can then be logged or displayed in any desired manner. The following is a snapshot of the DAPstudio application in action.
HARMONICSM downloadable module provides the following processing variants.
HRESAMPLE, a command for the resampling only, producing 4096 sample regular blocks for your host application to process
HARMONICS, a 40-harmonic analyzer for a single-phase signal, delivering a finished harmonic power spectrum analysis
HARMON3, a 40-harmonic analyzer for a three-phase system, delivering a finished harmonic power spectrum for three phases plus their combination
HARMON6, a 40-harmonic analyzer for a three-phase voltage-and-current system, delivering 3-phase harmonic analyses for both voltages and for currents
We have just seen that an analysis usually considered difficult and specialized is actually straightforward data capture and processing that a Data Acquisition Processor can do routinely, on multiple channels, in real time. Instead of awkward and irregular data streams with an undetermined number of samples spanning the desired power cycles at the unknown fundamental frequency, you can use Data Acquisition Processor power to adjust the sampled data so that you receive regular data blocks, aligned to the fundamental frequency, so that the analysis is easy. Since the analysis is easy, you can have all of the rest of the number crunching completed automatically and in real time as well, so that you receive just the results that you need, keeping your application software as simple as possible — your choice.
If you pay many thousands of Euros more, you can get a complete, standards-conforming test instrument that can do the same things as the harmonic analysis commands in the
HARMONICSM package. Are the results of the certified instruments better? No, not really, but the assurances for meeting test standards can be important. If that is what really matters, you should get a certified test instrument and pay the price. If you need results, and can validate the results on your own, the low cost with free analysis software might have a certain appeal.
You might suppose a wise manufacturer of certified test instruments would wrap one of their instrument boxes around one of these systems, and pocket the savings from the reduced manufacturing costs. You might suppose that. If they do, they would never tell you of course... and neither would we.
Footnotes and References:
- Time-Shift Filtering, a note on this site.
- "Window-presum FFT achieves high dynamic range, resolution," Charles C. Gumas, Personal Engineering, July 1997, p. 58-65. Unfortunately, out of print. Call us if you need details. Perhaps someday we will have a page on this topic?
Return to the Integrated Systems page.