646 IEEE TRANSACTIONS ON INSTRUMENTATION AND MEASUREMENT, VOL. 55, NO. 2, APRIL2006 Simulation and Experimental Results of Multiharmonic Least-Squares Fitting Algorithms Applied to Periodic Signals Pedro M. Ramos, Member, IEEE, Manuel Fonseca da Silva, Raúl Carneiro Martins, Member, IEEE, and António M. Cruz Serra, Senior Member, IEEE Abstract—A new generation of multipurpose measurement equipment is transforming the role of computers in instrumen- tation. The new features involve mixed devices, such as analog- to-digital and digital-to-analog converters and digital signal processing techniques, that are able to substitute typical dis- crete instruments like multimeters and analyzers. Signal-process- ing applications frequently use least-squares (LS) sine-fitting algorithms. Periodic signals may be interpreted as a sum of sine waves with multiple frequencies: the Fourier series. This paper describes an algorithm that is able to fit a multiharmonic acquired signal, determining the amplitude and phase of all harmonics. Simulation and experimental results are presented. Index Terms—Data analysis, digital signal processing algo- rithms, LS methods, sine fitting, spectral analysis. I. I NTRODUCTION A NALOG-TO-DIGITAL converter (ADC) testing fre- quently uses periodic signals to obtain most of the spec- ification parameters, such as the effective number of bits (ENOBs), signal-to-noise and distortion (SINAD) ratio, integral nonlinearity (INL), differential nonlinearity (DNL), and the transfer function. Sine fitting is a very efficient and fast way to help in the evaluation of most of these characteristic parameters. IEEE Standards 1057 [1] and 1241 [2] present two methods that estimate three (amplitude, phase, and dc component) or four parameters (including also the frequency) of a sine wave that best fit a set of acquired samples. The three and four parameters sine-fitting algorithms [1], [2], when applied to a multiharmonic signal perform a rough esti- mation because they fit one sine wave to a set of nonsinusoidal samples. This fitted sine wave is not exactly the fundamental because the presence of harmonics corrupts the minimization of the difference between a simple sine wave and a multiharmonic signal. Errors can arise in frequency, amplitude, and phase. One way to best fit multiple harmonics using the methods presented in the IEEE standards is described in [3]. In it, the Manuscript received June 15, 2004; revised August 3, 2005. This work was sponsored by the Portuguese national research project reference POCTI/ESE/46995/2002, entitled “New error correction techniques for digital measurement instruments.” The authors are with the Institute for Telecommunications and Department of Electrical and Computers Engineering, Instituto Superior Técnico (IST), Technical University of Lisbon (UTL), Av. Rovisco Pais, Lisbon 1049-001, Portugal (e-mail: pedro.ramos@lx.it.pt; fonseca.silva@lx.it.pt; rcmartins@ lx.it.pt; acserra@ist.utl.pt). Digital Object Identifier 10.1109/TIM.2006.864260 four-parameter algorithm is applied to the sampled data to obtain the amplitude, phase, and frequency of the fundamen- tal (f ) and the dc component. After reconstruction of this best fitted sine wave, it is subtracted from the sampled data to obtain the fitting residuals. From this point on, the three parameter algorithm is applied with a multiple frequency (nf ) to obtain the amplitude and phase of the nth harmonic. It is then subtracted from the residuals before the three parameter algorithm is again applied to determine the nth +1 harmonic parameters. With this method, all the parameter errors of the four-parameter fitting will influence the determination of the harmonics parameters. For example, a 1-MHz error in the fre- quency estimation will cause a large error in the 50th harmonic since the frequency used will have a 50-MHz error. The ampli- tude errors of the fundamental will propagate thru the method since the amplitudes are used to reconstruct the detected sine wave and obtain the residuals before they are used to deter- mine the next harmonic parameters. Overall, the frequency and amplitude errors from the first calculation are propagated to the higher harmonics and the calculation of the nth harmonic will invariably be contaminated by the errors of the phases and amplitudes of previous steps. The algorithm to estimate the offset, fundamental frequency, and the amplitude and phase values of the harmonics of a multi- harmonic signal is detailed in the next section. The third section describes the numerical simulations and results, while in Sec- tion IV, the experimental results are presented and discussed. An maximum likelihood improved sine-wave fitting proce- dure for characterizing data acquisition (DAQ) channels and ADC, which is also capable of fitting multiple harmonics of an input signal, was presented in [4]. A different method was pro- posed in [5] based on the spectral analysis and fitting by interpo- lating the acquired samples. However, the application of these two methods is more complex than the method described here. II. LEAST-SQUARES (LS) MULTIHARMONIC FITTING METHOD The sampled periodic signal may be described as a sum of sine waves with different frequencies, multiple of the funda- mental (f ), individual amplitudes (D h ), and phases (φ h ) y(t)= C + H h=1 D h cos(2hπft + φ h ). (1) 0018-9456/$20.00 © 2006 IEEE