Sei sulla pagina 1di 7
Instrum. Soe. India 36(1) 1-7 DESIGN OF FFT SPECTRUM ANALYZER ON PC PLATFORM USING LABVIEW AND MICROCONTROLLER BASED DATA ACQUISITION SYSTEM K. Arun Venkatesh’, Shikha Chauhan’, S.G Hi and N. Mathivanan® "University Seience Instrumentation Centre, Madurai Kamaraj University, Madurai - 625021 *Honeywell Technologies Solutions Lab Pvt. Lid., Madutai - 625015 ‘All communication should be addressed to inya Bhatta® ABSTRACT ‘The design and development of a FFT Spectrum Analyzer on PC using Lab VIEW and ‘microcontroller based data acquisition (DAQ) system is discussed. Spectrum Analyzers find wide applications in vibration analysis, speech analysis, harmonic measurement, ete ‘There are different types of Spectrum Analyzers in use. Among them, FFT Spectrum Analyzer, which is suitable for analyzing signals containing wide range of frequencies, ‘ean be easily implemented on PC platform. The FFT Spectrum Analyzer has been implemented by interfacing a microcontroller based data acquisition system to PC through parallel port. The DAQ system has been designed around the microcontroller ATS9CS1 fand analog to digital converter ADCOS04, The microcontroller gives out signals for sampling the analog signal at specified intervals of time, stores 64 bytes of sampled data in its internal RAM and transfers the 64 bytes to the PC system in sequence. The software has been developed using LabVIEW. The FFT spectrum of the sampled data is ‘computed using LabVIEW built-in function and itis displayed on the sereen, 1. INTRODUCTION Amplitude vs. time plot of a signal represents the signal in time domain. Amplitude vs. frequency plot of a signal represents the signal in frequency domain, A Spectrum Analyzer ‘computes frequency components present in a ignal and plots amplitude vs. frequency graph. Signals represented in frequency domain provide more information and are convenient to analyze. Measurements like harmonic distortion are very difficult in time domain by inspecting the waveform in time-scale on an oscilloscope. The same signal when displayed in the frequency domain, amplitudes of various harmonics in the signal can be easily measured. Basically, Spectrum Analyzers are of two types, (i) Swept Spectrum Analyzer, and (ii). FFT ‘Spectrum Analyzer. FFT Spectrum Analyzers are suitable for analyzing signals containing wide range of frequencies. 2K Arun Venkatesh, Shikha Chauhan, G Hiranya Bhatta and N. Mathivanan 2. DESIGN OF A MICROCONTROLLER BASED DATA ACQUISITION SYSTEM Basically, a FFT Spectrum Analyzer samples the signal at regular interval of time, computes FFT on sampled data and plots the amplitude vs. frequency spectrum. In the present Spectrum Analyzer, a microcontroller based Data Acquisition (DAQ) system has been designed for sampling the analog signal. The DAQ system has been interfaced to PC through parallel port for transferring the sampled data to the PC. The DAQ system is built around a microcontroller ATS9CS1 and an analog to digital converter ADCO804. The circuit diagram is shown in Figure 1 ape fa ae? | FTE wel SS cal Ege Fig. 1: The circuit diagram of microcontroller based data acquisition system. As per the sampling theorem, the signal should be sampled at a frequency greater than twice the maximum frequency component present in the signal. Ifthe signal is undersampled (ic. sampled at a frequency less than twice the maximum frequency component in the signal) aliasing will occur. Aliasing refers to reflection of high frequency components into low frequencies in the frequency spectrum. Aliasing results in error in frequency spectrum computation. To prevent aliasing, an anti-aliasing filter (a low-pass filter) is used at the input stage. A second order (-40 dBidecade) low-pass filter with 2 kHz cut-off frequency is designed using an UA741 op-amp. The input signal is passed through the filter. ADCO804" is used to convert the analog signal to digital data. ADCO804 is an 8-bit successive approximation type ADC and operates with +5 V supply voltage. It has 100 us conversion time and operates with 600 kHz clock frequency. Successive approximation type ADCS require the analog input signal to be held constant during the conversion period. A. Sample and Hold (S/H) amplifier LF398° is used to hold the signal constant during conversion ‘The S/H amplifier is set to hold mode before AID conversion is started and driven to sample ‘mode after the conversion is over. Microcontroller ATS9CSI is used to control the operation of S/H amplifier and the ADC in the DAQ system. It is also used to read the converted data from the ADC and to transfer to PC. ATS9CSI? is an 8-bit microcontroller that operates at 11,0592 MHz clock frequency Design of PEP spectrum analyzer on PC plafrm using Labview and microcontroller based data acquisition system 3 and with +5 V power supply. It has 128 bytes of intemal RAM, two 16-bit Timers/Counters, four parallel V/O ports, one programmable serial port and six interrupt sources. Port-1 of A T89CS1 is used to get the converted data from the ADC and Port-0 is used to send the data to the PC through parallel port’. Since Port-0 is open-drain 1/0, it requires the pins of the port to be connected to Vee through 10 kO pull-up resistors. Port-2 of the ATS9CSI is used to give out control signals to CS#, WR# and RD# inputs of ADC and S/H control signal to S/H amplifier. The AID conversion is started by applying logic low to CS# and WR# pins. Conversion is monitored by polling the INTR# pin of ADC through P3.2 pin of Port-3. Logic high to low transition of INTR# indicates the end of conversion. Converted data is read by applying logic low to CS# and RD# pins of the ADC. The S/H amplifier is set to sample/hold mode by applying logic high/low to S/H control input (pin-8) of LF398 through P24 pin, 2.3 pin of Port-2 (output pin) and P3.3 pin of Port-3 (input pin) are used for handshaking. during data transfer from microcontroller to PC. The following handshaking scheme has been implemented for the data transfer. The microcontroller outputs the data on its Port-0 pins and asserts pin P2.3 of Port-2, which is connected to pin-10 of parallel port. The PC polls the signal on pin-10 of its parallel port (by polling the bit-6 of status register) and determines whether a new data is available. When it determines that a new data is available, it reads the data (from the data register ofthe parallel port) and acknowledges the same to microcontroller by asserting pin-16 (bit-2 of control register) of the parallel port. 3, SOFTWARE DESCRIPTION Programming AT89C51 ‘The program has been developed in the assembly language and the code is downloaded into the EPROM of A TS9CSI using a universal programmer kit. Timer-0 of the ATS9CS1 is, programmed to generate timer interrupt at an interval of 250 js for sampling the signal at the frequency of 4 kHz and is operated in mode-2 (auto reload). During the sampling period, all interrupts except timer interrupt are disabled to ensure precise time interval. For every timer interrupt, the AT89CS1 issues start of conversion (SOC) to ADC, polls end of conversion (EOC), reads converted data on EOC and stores in its internal RAM in sequence. Though ATS9CSI has internal RAM of size 128 bytes, only 64 bytes are used to save the sampled data. The data are then transferred to PC through the parallel port. LabVIEW Programming Program for transfer of sampled data from AT89CS1 to computer memory has been developed in LabVIEW. The 64 bytes of sampled data are stored in sequence in computer ‘memory. FFT on the sampled data is computed using the LabVIEW" built-in function “FFT Spectrum(Mag-Phase)-vi’. It uses the Radix-2 decimation in time (DIT) algorithm. In this ‘method, the samples are continuously split into odd and even components and Discrete Fourier ‘Transform is computed for the decomposed sequence. The FFT spectrum is displayed on a ‘graphic chart on the screen using LabVIEW built in function ‘Waveform Graph.vi’ which automatically calibrates the X-axis and Y-axis of the graphic chart. The X-axis is calibrated in frequency and the Y-axis is calibrated in amplitude. Each division in X-axis is separated by (sampling period * 64) Hz. Figure 2(a) shows the LabVIEW program transferring data from 4K Arun Venkatesh, Shikha Chauhan, 8. Hiranya Bhatta and N. Mathivanan DAQ system to PC and Figure 2(b) shows the LabVIEW program computing and displaying FFT spectrum of sampled data, ol x Replace aay Subset] 4] Pema © aa wrerstoral i second [Build Waveform] 0.00025] = [rraied ora Fig. 2: LabVIEW programs - (a) transferring data from DAQ system to PC, (b) computing and displaying FFT spectrum of sampled data, Design of PEP spectrum analyzer on PC plafr using Labview and microconroller based data acquisition system 5 4, EXPERIMENTAL RESULTS AND DISCUSSION ‘The Spectrum Analyzer has been tested by applying (i) square wave of known amplitude, duty cycle and frequency, and (ii) sine wave of known frequency. A square wave will produce a number of harmonics in the frequency spectrum. The amplitude of these harmonics depends on the duty cycle of the waveform. Square waves of 25% duty cycle (i.e. 25% ON time and 75% OFF time) and 50% duty cycle will generate harmonics in integral multiples of the frequency of the square wave with amplitudes in the ratios of U/Q/2), 1/2, 1BV2), 0, M2), «and 1, 0, 1/3, 0, 1/5, 0, .... respectively’. The frequency spectra displayed by the Spectrum Analyzer for square waves of duty cycles of 25% and 50% of 500 Hz frequency are shown in Figure 3 and Figure 4. It is observed that, the frequency spectrum for 500 Hz, 25% duty cycle square wave has harmonics at frequencies, in integral multiples of 500 Hz (ie. 500 Hz, 1,000 Hz and 1,500 Hz) with amplitudes in the ratio of 1/(y2), 1/2, and 1/(3y2). It is also observed that the frequency spectrum for S00 Hz, 50% duty cycle square wave has harmonies at S00 Hz and 1,500 Hz with amplitudes in the ratio of I and 1/3. Fig. 4 : FFT spectrum of square wave of frequency 500 Hz with 50% duty evele 6K. Arun Venkatesh, Shikha Chauhan, 8. Hiranya Bhatta and N. Mathivanan A sine wave of frequency of $00 Hz from a function generator is applied to the Spectrum, Analyzer and the spectrum produced by the Spectrum Analyzer is shown in Figure 5. The spectrum shows a single frequency component at frequency 500 Hz, Waveform Graph Fig. 5 : FFT spectrum of sine wave of frequency 500! i Es) i De A a aaa na ae To Tw A Erenoenea li oe a at Hae Oo a a a Ca oo Rieyerny i? Fig. 6 : Plots of FFT Spectrum computed using MATLAB on MATLAB generated sequences. Figure 6 shows the plots of FFT spectrum computed using MATLAB* on MATLAB, generated (A) 25% duty eycle, $00 Hz square wave, (B) $0% duty cycle, $00 Hz square wave and (C) 500 Hz sine wave. The MATLAB program is given in Listing 1. From the figure it is evident that the present Spectrum Analyzer produces FFT spectrum precisely. Design of FET spectrum analyzer on PC plafrm sing Labview and microcontroller based data acquisition system 7 Listing 1. MATLAB program generating the sequences and computing the FFT. i = 0:63; n=i (1:32) ; t = n*1/(0.00025*64) ; sqi = square (i*2*pi*500/4000,25) ; ampt = fft_spectrum (sq1,64) ; sq2 = square(i*2*pi*500/4000, 50) ; amp2 = fft_spectrum(sq2, 64) ; sini = sin(i*2*pi*500/4000) ; amp3 = fft_spectrum (sini, 64) ; subplot (3,1,1) ; plot (t, ampt) ; xlabel (A. Frequency in Hz--->") ; ylabel (Amplitude --->") ; subplot (3,1,2) ; plot (t, amp2) ; xlabel (°B. Frequency in Hz--->') ; ylabel (‘Amplitude --->’) ; subplot (3,1,3) ; plot (t, amp3) ; xlabel (C. Frequency in Hz--->’); ylabel(’Amplitude - i Function function [spec] = fft_spectrum(seq, 5) c= fft (seq, s) ; re = real (c) ; im = imag(c) ; amp = sqrt (re.2+im.2) ; spec = amp (1 : 5/2) j 5, CONCLUSION ‘The FFT Spectrum Analyzer can be used to analyze signals at 8-bit resolution up to 2 kHz, The maximum frequency of signal that can be analyzed with the present Spectrum ‘Analyzer is limited by the conversion time of the ADC in the DAQ system. It can be improved by using high speed ADCs. The Spectrum Analyzer gets only 64 samples from the DAQ system at a time for analysis, Size of internal RAM in ATS9CSI in the DAQ system restricts the ‘maximum number of samples that can be collected and analyzed which in turn limits the resolution of the spectrum. Microcontroller P89VS1RD2 has 1024 bytes of internal RAM and is pin-to-pin compatible to ATS9CSI, which enables computation of FFT with large number of sampled data can be used, REFERENCES. 1 National Semiconductor, ‘Linear Data Book (1982) 2. Kenneth J. Ayala, ‘The 8051 Microcontroller Architecture, Programming and Applications”, Second Euition, Penram International, (1997). 3._N. Mathivanan, “Microprocessors, PC Hardware and Interfacing’, Prentice-Hall of India, New Delhi, (2003) [National instruments, ‘User manual LabVIEW", Ver 6.1, (2000), John G. Proakis, Dimitris G. Manolakis, “Digital Signal Processing: Principles, Algorithms, and Applications’, Third Edition, Prentice-Hall of India, New Delhi, (1996), 6. Vinay K. Ingle, John G.Proakis, “Digital Signal Processing Using MATLAB”, Thomson Brooks Cole, (2003).

Potrebbero piacerti anche