Using The FFT On Sigma-Delta ADCs

2y ago
66 Views
3 Downloads
1,006.76 KB
16 Pages
Last View : 16d ago
Last Download : 2m ago
Upload by : Mya Leung
Transcription

Freescale Semiconductor, Inc.Application NoteDocument Number: AN4847Rev. 2, 07/2015Using the FFT on Sigma-DeltaADCsby: Ludek Slosarcik1IntroductionThis application note deals with two topics in digitalsignal processing and metering, namely the Fast FourierTransform (FFT) and sigma delta Analog-to-DigitalConverters (SD ADCs).First, the FFT is a mathematical technique fortransforming a time-domain digital signal into afrequency-domain representation of the relativeamplitudes of the different frequency regions in thesignal. The FFT is extremely important in the area offrequency (spectrum) analysis. Second, SD ADCs arehigh resolution, high integration, and low-cost ADCs forapplications such as metering, process control, andmonitoring.Both topics are outlined in depth in this application note,and some interested parties may find more details onrelevant web pages or reference sources. The mainpurpose of this application note is to describe somemethods for properly using the FFT in cooperation withthe SD ADCs, especially in power metering applications. 2015 Freescale Semiconductor, Inc.Contents1234Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Basic problem description . . . . . . . . . . . . . . . . . . . . . . . . 2Use case 1 synchronous processing . . . . . . . . . . . . . . 2Use case 2 asynchronous processing . . . . . . . . . . . . . 24.1 Linear interpolation . . . . . . . . . . . . . . . . . . . . . . . . . 34.2 Polynomial interpolation . . . . . . . . . . . . . . . . . . . . . 45Practical implementation . . . . . . . . . . . . . . . . . . . . . . . . . 75.1 METERLIBFFT Interpolation . . . . . . . . . . . . . . . . . 75.2 Simulation results . . . . . . . . . . . . . . . . . . . . . . . . . . 96Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10Appendix AExample of using the interpolation function in thesingle-phase user code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Appendix BResults of simulation Example 1. . . . . . . . . . . . 12Appendix CResults of simulation Example 2 . . . . . . . . . . . 13Appendix DResults of simulation Example 3 . . . . . . . . . . . 14Appendix EResults of simulation Example 4. . . . . . . . . . . . 15

Basic problem description2Basic problem descriptionUsing the FFT in power (energy) metering applications has some specific requirements, which aredescribed in FFT-Based Algorithm for Metering Applications (document AN4255). The basic requirementis to have a power-of-two number of input samples during one input signal period. To fulfill thisrequirement, know the input signal frequency to be able to compute the correct period of time between theneighboring samples. This is due to having the power-of-two number of samples during the signal period.This assumes that the time between each ADC sample may be slightly adjusted by a Programmable DelayBlock (PDB) or by another special timer which is able to provide a controllable interval tick to thehardware trigger of the ADC used. Strictly speaking, we need to synchronize the input signal frequencywith the ADC sampling rate. For example, this technique may be simply used on the ADCs based on theSuccessive Approximation Register (SAR), which may be hardware-triggered by the PDB. On the otherhand, there are also other types of ADCs and applications where this described technique cannot be used.This problem appears in the sigma-delta ADCs, whose sampling interval cannot be modified slightly.There are some use cases for bypassing this issue. Therefore, the current application note is a logicalcontinuation of the original AN4255, which doesn’t resolve this issue.3Use case 1 synchronous processingThe simplest way to get the power-of-two samples from the SD ADC for a subsequent FFT computationis to synchronize both processes; the signal frequency and the ADC sampling rate. This process isdescribed in AN4255. It requires knowledge of the frequency of the measured signal and being able to runthe SD ADC in the single conversion mode too. The detection of the signal frequency (period) may beperformed by the Zero-Crossing Detection (ZCD) technique, described in AN4255, Section 3.2.1.Although the SD ADCs are not very suitable for the single-conversion configuration due to a longerstart-up time, we may use this AD conversion mode in some cases. The main limiting factor in using theSD ADCs in this mode is the start-up time, which may be several times higher than the time for normalAD conversion. This is due to a latency of the decimation filter. For example, the start-up time for the SDADC used in the Freescale MKM34Z128 MCU (ARM Cortex -M0 core)[2.] is typically three timeshigher in comparison to its normal conversion time. This feature limits the use of this mode to higheroutput sample rates (OSR) in cooperation with the subsequent FFT computation.4Use case 2 asynchronous processingThe other way to resolve the issue with using the FFT on the SD ADCs is to use an oversampling. Inpractical terms, the SD ADC collects more samples during the signal period than are really needed. Thenext step of this process is to use some type of re-computing technique, which transforms the originalnon-power-of-two ADC samples into the power-of-two samples required by the FFT. We may simply termthis whole process as an interpolation of the input signal. This process is graphically represented inFigure 1. For simplification, there are only eight FFT points used and 12 measured samples (ratio is 1.5).Theoretically, it would be possible to use an undersampling method with the same subsequent process(interpolation to the power-of-two samples), but practically it is better to have a higher number of inputsamples than the FFT really needs. This is due to having a minimum computation error of the interpolatedsignal. Therefore, the ratio between the number of input samples and the power-of-two samples should behigher than 1. The upper bound of this ratio is limited by the power of the MCU used. The general rule is:a higher ratio, a lesser interpolation error, but a higher MCU (ADC) workload.Using the FFT on Sigma-Delta ADCs, Rev. 2, 07/20152Freescale Semiconductor,Inc.

Use case 2 asynchronous processingFigure 1. FFT oversampling use caseGenerally, this computing technique supposes that both processes, the signal frequency, and the ADCsampling rate, are mostly purely asynchronous. Thanks to this computing technique we may let the SDADC run in a continuous conversion mode, which is much more natural for this type of ADCs than thesingle conversion mode (see Section 3, “Use case 1 synchronous processing,” on page 2).As mentioned above, the key point for this use case is the interpolation. In the mathematical field ofnumerical analysis, interpolation is a method of constructing new data points within the range of a discreteset of known data points. With respect to Figure 1, the new data points are on its right-hand side (red dataset), whereas the known data points are on its left-hand side (blue data set). While the known data pointsare measured by the ADC, the new data points are computed by the MCU. Therefore, the interpolationprovides a means of estimating the function at intermediate known (for example measured) points.There are plenty of known interpolation methods, some of which are described below. These methods weretested practically on the two-phase metering reference design based on the MKM34Z128 MCU.4.1Linear interpolationLinear interpolation is the simplest method of getting values at positions in between the data points. Thepoints are simply joined by straight line segments. Each segment (bounded by two neighboring data points)can be interpolated independently. With respect to the example in Figure 1, we will have the set of datapoints (x0,y0), (x1,y1),.,(x11,y11). Linear interpolation on this set of data points is defined as theconcatenation of linear interpolants between each pair of data points. A linear interpolant is the straightline between neighboring points. The detail of the interpolation of one segment is pictured in Figure 2. Thecolor representation is the same as in Figure 1, that is the blue points are measured values, whereas the redpoints are computed values.Using the FFT on Sigma-Delta ADCs, Rev. 2, 07/2015Freescale Semiconductor, Inc.3

Use case 2 asynchronous processingFigure 2. Example of linear interpolationFor a value x in the interval (x0,x1), the value y along the straight line is given by the following equation:y – y0y1 – y0------------- ---------------x – x0x1 – x0Eqn. 1Solving this equation for y, which is the unknown value at x, gives:x – x0y y 1 – y 0 ---------------- y 0 ax b x1 – x0Eqn. 2Where a and b are linear coefficients; a is the gain, while b is the offset.Linear interpolation is a special case of a polynomial interpolation with the degree of one. It is quick andeasy, but it is not very precise, especially when there are higher harmonics in the input signal and a lowratio between the input samples and the computed points. We may resolve this issue by extending this ratio,if possible.4.2Polynomial interpolationPolynomial interpolation is the interpolation of a given data set by a polynomial. Let us assume that wehave n 1 discrete data points (x0,y0), (x1,y1),.,(xn,yn) with different x-coordinates. The main objective isto find a polynomial function of degree n that passes through these n 1 points. This polynomial is calledan interpolating polynomial. There are plenty of known methods for solving this assignment. One of thesimplest solution methods is using the Lagrange interpolating polynomial. This is a well-known techniquein numerical analysis. The general equation for the Lagrange interpolating polynomial is:ny L x yi Li x Eqn. 3i 0Where n is the degree of the polynomial, and Li(x) are Lagrange basic polynomials, expressed as:Using the FFT on Sigma-Delta ADCs, Rev. 2, 07/20154Freescale Semiconductor,Inc.

Use case 2 asynchronous processingn Li x j 0 j i x – xj ------------------ xi – xj Eqn. 4The basic polynomial Li(x) has the property that: 0Li xj 1j ij iEqn. 5Polynomial interpolation is a generalization of linear interpolation, but it is more precise than the linearinterpolation. Its precision depends on the degree of the polynomial (n-size in Equation 3). It gives a betteraccuracy for functions with larger variations. On the other hand, calculation of the interpolatingpolynomial is computationally expensive compared to linear interpolation, mainly for real-timeapplications (for example power metering). Due to this, the following text focuses only on the polynomialinterpolation with a maximum degree of three. In other words, we will not compute one interpolatingpolynomial of degree n, but we will divide this task by finding several elementary interpolatingpolynomials of a lower degree (n 2 or n 3 at maximum). In practical terms, we will compute the y value,which is the unknown value at x, using three or four neighboring data points. The same process will berepeated for each pair of (x,y) values using several new neighbouring data points (xi,yi). This process isdescribed in the following subheads.4.2.1Lagrange quadratic interpolationSolving the basic Equation 3 of the Lagrange form of the interpolating polynomial for n 2 for generalvalue y, which is the unknown value at x, gives: x – x1 x – x2 x – x0 x – x2 x – x0 x – x1 y ------------------------------------------y 0 ------------------------------------------y 1 ------------------------------------------y 2 x0 – x1 x0 – x2 x1 – x0 x1 – x2 x2 – x0 x2 – x1 Eqn. 6 y0 L0 x y1 L1 x y2 L2 x Where Li(x) are basic Lagrange quadratic polynomials.There is supposed to be three pairs (generally, n 1) of input data points (x0,y0),(x1,y1), and (x2,y2) forsolving this equation. The new x-value should be between one of these values, x0 - x1 or x1 - x2. This newx-value is in fact a recalculated value (see also Figure 1 for new xi’ values). It is the multiple of the ratiobetween the number of the ADC values to the number of the power-of-two FFT points.The example of the interpolation for n 2 is pictured in Figure 3. The three input points (measured values)are shown in blue. The interpolating function passing through them is the red parabola. Generally, theLagrange basic polynomials Li(x) of degree two are quadratic functions. Their curve is a parabola.Using the FFT on Sigma-Delta ADCs, Rev. 2, 07/2015Freescale Semiconductor, Inc.5

Use case 2 asynchronous processingFigure 3. Example of quadratic interpolationIn general, the three x-values do not need to be spaced evenly (x0 - x1 may differ from x1 - x2). However, auniform distribution of points is a typical use case for ADC periodic sampling intervals, that is, formetering applications. Thanks to this simplification, we may rewrite Equation 6 to the following form: x – x0 – 1 x – x0 – 2 x – x0 x – x0 – 1 y -----y 0 – x – x 0 x – x 0 – 2 y 1 ----------------------------------------------y 2224.2.2Eqn. 7Lagrange cubic interpolationSolving the basic Equation 3 of the Lagrange form of the interpolating polynomial for n 3 for generalvalue y, which is the unknown value at x, gives: x – x1 x – x2 x – x3 x – x0 x – x2 x – x3 x – x0 x – x1 x – x3 y -------------- y 0 -------------- y 1 -------------- y 2 x0 – x1 x0 – x2 x0 – x3 x1 – x0 x1 – x2 x1 – x3 x2 – x0 x2 – x1 x2 – x3 Eqn. 8 x – x0 x – x1 x – x2 -------------- y 3 y 0 L 0 x y 1 L 1 x y 2 L 2 x y 3 L 3 x x3 – x0 x3 – x1 x3 – x2 Where Li(x) are basic Lagrange cubic polynomials.Given four discrete input data points (x0,y0),(x1,y1),(x2,y2), and (x3,y3), we can find each individual cubicpolynomial Li(x). The new x-value should be between one of these three intervals, x0 - x1, x1 - x2, or x2 x3. This new x-value is in fact a recalculated value (see also Figure 1 for new xi’ values). It is the multipleof the ratio between the number of the ADC values to the number of the power-of-two FFT points.The example of the interpolation for n 3 is pictured in Figure 4. The four input points (measured values)are shown in blue. The interpolating function passing through them is the red cubic curve. Generally, theLagrange basic polynomials Li(x) of degree three are cubic functions.Using the FFT on Sigma-Delta ADCs, Rev. 2, 07/20156Freescale Semiconductor,Inc.

Practical implementationSimilarly to the previous example, we assume an uniform distributions of x-points in the meteringapplications. Therefore, the Equation 8 may be rewritten in the following form: x – x0 – 1 x – x0 – 2 x – x0 – 3 x – x0 x – x0 – 2 x – x0 – 3 y ---------------------------------y 0 ------------------------y 1 –62 x – x0 x – x0 – 1 x – x0 – 3 x – x0 x – x0 – 1 x – x0 – 2 ------------------------y 2 ------------------------y 3–26Eqn. 9Figure 4. Example of cubic interpolation5Practical implementationThis chapter describes the implementation of the FFT resampling and interpolation techniques used inthe C-code, and the simulation of these techniques in Excel . It contains a description of the applicationprogramming interface (API) of three C-functions (for most frequent power meter topologies) forinterpolation of the measured AD samples before the final FFT computation. The API for the subsequentFFT computation is described in a separate application note AN4255[1.]. The interpolation functions arepart of the FFT-based metering library called METERLIBFFT, which is used for the power computationin some of Freescale electricity meter reference designs [4.] and [5.].5.1METERLIBFFT InterpolationThese three functions are used for interpolation of the original input curve given by unsigned integersamples to the curve given by power-of-two samples, required by the FFT function. The source C-code foreach type of algorithm is included in the fft.c file of the METERLIBFFT library. These functions supportboth oversampling and undersampling. The example of using the interpolation function in the main C-codeis in the Section Appendix A, “Example of using the interpolation function in the single-phase user code.”There are also other functions used in this example. These functions, whose API is described in theAN4255[1.], are also part of the metering library, and are used for power computation based on the FFT.Using the FFT on Sigma-Delta ADCs, Rev. 2, 07/2015Freescale Semiconductor, Inc.7

Practical implementation5.1.1Syntax#include “meterlibfft.h”long METERLIBFFT1PH Interpolation (tMETERLIBFFT1PH DATA *p, unsigned long u ord, unsigned longi ord, unsigned long samples inp);long METERLIBFFT2PH Interpolation (tMETERLIBFFT2PH DATA *p, unsigned long u ord, unsigned longi ord, unsigned long samples inp);long METERLIBFFT3PH Interpolation (tMETERLIBFFT3PH DATA *p, unsigned long u ord, unsigned longi ord, unsigned long samples inp);5.1.2ArgumentsTable 1. METERLIBFFT Interpolation functions PH DATApinPointer to the one-phase metering library data structuretMETERLIBFFT2PH DATApinPointer to the two-phase metering library data structuretMETERLIBFFT3PH DATApinPointer to the three-phase metering library data structureunsigned longu ordinVoltage interpolation order see Table 2unsigned longi ordinCurrent interpolation order see Table 2unsigned longsamples inpinInput samples number can be higher or lower than the requiredpower-of-two FFT samplesTable 2. Interpolation order definesDefine name5.1.3DescriptionORD1The 1st order (linear) interpolationORD2The 2nd order (quadratic) interpolationORD3The 3rd order (cubic) interpolationReturnThese functions return one of the following error codes valid only for undersampling use, for input sampleslower than FFT samples: FFT ERROR (positive) – FFT samples are higher than input samples, and FFT samples are higherthan 128. FFT OK (zero) – undersampling ratio is correct.5.1.4Calling orderThese functions should be used only if the interpolation processing is required. In that case, these functionsshould be called periodically in a defined interval, which depends on the line frequency. These functionsshould be called closely before the main (FFT) calculation processing. The one-shot mandatory parameterinitialization must be performed before calling these functions. Apart from other things, this parameterinitialization function sets the number of required FFT points and also initializes all pointers to the inputbuffers used by the interpolation functions.Using the FFT on Sigma-Delta ADCs, Rev. 2, 07/20158Freescale Semiconductor,Inc.

SummaryNOTEThe original values in the input buffers (ADC values) will be rewritten bythe new (interpolated) values after calling these functions.5.1.5PerformanceTable 3. METERLIBFFT Interpolation functions performance for the CM0 coreCode size [B]Function name1st order2nd order3rd orderMETERLIBFFT1PH Interpolation5068421654METERLIBFFT2PH Interpolation5869221734METERLIBFFT3PH Interpolation6821018183012Stack size[B]1512Clock cycles21st order2nd order3rd 227Due to the unde

Using the FFT on Sigma-Delta ADCs, Rev. 2, 07/2015 Use case 2 _ asynchronous processing 4 Freescale Semiconductor,Inc. Figure 2. Example of linear interpolation For a value x in the interval (x 0,x 1), the value y along the straight line is given by the following equation: Eqn. 1 Solving this equation for y, which is the unknown value at x, gives: Eqn. 2

Related Documents:

May 02, 2018 · D. Program Evaluation ͟The organization has provided a description of the framework for how each program will be evaluated. The framework should include all the elements below: ͟The evaluation methods are cost-effective for the organization ͟Quantitative and qualitative data is being collected (at Basics tier, data collection must have begun)

Silat is a combative art of self-defense and survival rooted from Matay archipelago. It was traced at thé early of Langkasuka Kingdom (2nd century CE) till thé reign of Melaka (Malaysia) Sultanate era (13th century). Silat has now evolved to become part of social culture and tradition with thé appearance of a fine physical and spiritual .

On an exceptional basis, Member States may request UNESCO to provide thé candidates with access to thé platform so they can complète thé form by themselves. Thèse requests must be addressed to esd rize unesco. or by 15 A ril 2021 UNESCO will provide thé nomineewith accessto thé platform via their émail address.

̶The leading indicator of employee engagement is based on the quality of the relationship between employee and supervisor Empower your managers! ̶Help them understand the impact on the organization ̶Share important changes, plan options, tasks, and deadlines ̶Provide key messages and talking points ̶Prepare them to answer employee questions

Dr. Sunita Bharatwal** Dr. Pawan Garga*** Abstract Customer satisfaction is derived from thè functionalities and values, a product or Service can provide. The current study aims to segregate thè dimensions of ordine Service quality and gather insights on its impact on web shopping. The trends of purchases have

RESOLVED, that Sigma Sigma Sigma affirms that a chapter with a house is best served by engaging a House Director. The individual House Corporation will be charged with determining the policy for the chapter and a live-in House Director. ALCOHOL WHEREAS, Sigma Sigma Sigma recognizes

Chính Văn.- Còn đức Thế tôn thì tuệ giác cực kỳ trong sạch 8: hiện hành bất nhị 9, đạt đến vô tướng 10, đứng vào chỗ đứng của các đức Thế tôn 11, thể hiện tính bình đẳng của các Ngài, đến chỗ không còn chướng ngại 12, giáo pháp không thể khuynh đảo, tâm thức không bị cản trở, cái được

Refrigerated centrifuge SIGMA 1-15PK Page 6 Small centrifuges SIGMA 1-6P Page 10 SIGMA 2-6 Page 13 Versatile centrifuges SIGMA 2-16P Page 17 Refrigerated centrifuge SIGMA 2-16PK Page 17 SIGMA 3-16P Page 23 Refrigerated centrifuge SIGMA 3-16PK Page 23 High speed refrigerated centrifugen SIGMA 3-18 Page 29