This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.
This is a report on the feasibility of developing a software with the help of Delphi for function generation and signal analysis using the PC sound card. Although the operation will be limited to the audio range, the use of sound card will lead to the development of a low cost and easily available system compared to the standard waveform generators. The line-in and line-out of the sound card will be used as ADC and DAC convertors. The different approaches to the successful completion of the software are discussed. The sound card driver interacts with the operating system which exposes it to the above application layer through the Application Programming Interface (API). A windows software system will be developed which makes use of the wave function interface of the Windows API to directly interact with the sound card driver. The function generator signals created used the software will be output through the speaker out of the sound card and the line-in port of the sound card will be used for recording, real-time display and spectral analysis of the incoming signal.
Signal generation and analyzing equipments are used widely to test electronic devices and to analyze its characteristics and how it responds to different signals. Standard function generators available are used to generate basic pre-defined waveform such as sine, square, saw tooth and triangle waves of varying frequency, amplitude and DC offset. Also, there are highly functional oscilloscope and spectrum analyzer to get the time domain and frequency domain analysis of the input signal. Initially these devices were designed using analog components which required lots of parts and suffered with the precision and accuracy as it gets aged. With the coming of new highly computational Digital Signal Processors, signal generation and analysis was done with digitally using different algorithms with the help of these DSP processors. The signals generated using Digital Signal generators were more spectrally pure than that of the analog generator. Complex waveforms can be generated much easily using digital signal generators.
These standard laboratory devices provide highly stable and spectrally pure signals over a wider range of frequencies. They are also costly. This project aims at developing sound card based software that can be used as function generator and a spectrum analyzer. This will be a low cost alternative for function generator and spectrum analyzer for signals having frequencies in the range of 20 Hz to 22 KHz. The sound card will function as a DAC to output the digital signal generated using the software and as an ADC to capture the analog signal to be analyzed. The function generator outputs the predefined waveforms of desired frequency and amplitude through the speaker/line out of the sound card. The line in of the sound card will be used to acquire the signal data used for spectral analysis.
This report will list the features that this software aims to provide. Give an overview of the basic theory and about digital signal synthesis. Some existing research works regarding the different methods and algorithm for digital signal generation and analysis have been reviewed. The report will also detail about the step by step approach in which the project will be dealt with. Also a detailed plan with time line and various milestones in the execution of the project are included. The risks that might come up are also identified.
1.1 Features of the Software
A software that runs on Windows platform and using an on-board or external sound card device.
Generate sine, square, saw tooth and triangular waves of user defined frequencies, amplitude and DC Offset.
Option to adjust the frequency and amplitude dynamically.
Option to save the generated waveform as .wav file.
Provide a real time display of the wave that is currently being output through the line out of the sound card.
Digital Oscilloscope for time domain analysis of the signal acquired using the line in of the sound card.
Real time Spectral Analyzer for the frequency domain analysis of signal coming in through the line in of sound card.
Option to save the acquired signal and do spectral analysis on the saved signal.
Option to freeze the display and save it as an image.
1.2.1 Digital Function Generator
In modern digital function generators, the signal samples are generated digitally using a DSP processor which is then fed to a high speed Digital to Analog convertor followed by an analog/digital filter to output the actual analog waveform.
188.8.131.52 Direct Digital Synthesis (DSS)
This is a common method to create digital signal samples. High frequency resolution can be obtained using DSS. Also the generation of signals are less computationally complex.
Using DDS, we can generate different frequencies of a particular waveform provided we do have a look up table containing the samples of that waveform at a reference frequency.
Figure : A General block diagram to show the DDS Fundamental (Source: L.Cordesses, 2004)
An incremental phase value (âˆ†ACC) calculated using the desired frequency (Fo) and the sample frequency (Fs). This âˆ†ACC added with the phase accumulator value (ACC) to get the new ACC which is N bit value. The phase to waveform convertor is a look up table that stores the samples (amplitudes) of the waveform corresponding to different phase. In order to minimise the memory overhead, the ACC value is quantized to a P bit address that will point to a location in the look up table. That is, the most significant P bits are selected from the N bit ACC.
phase register computation.JPG
Figure : Example showing computation of phase register (Source: http://zone.ni.com/devzone/cda/tut/p/id/5516)
The Phase accumulator is a modulo N counter. One cycle of the waveform of desired frequency will be generated when the phase accumulator rolls over once. The output of the phase to waveform convertor is passed onto a DAC to get the analog waveform.
1.2.2 Digital Spectral Analyzer
Digital Spectral Analyzers uses Discrete Fourier Transform to transform the time domain based signal to frequency domain. A much faster version of the DFT known as the Fast Fourier Transform is used which enables a speedy display of the spectrum.
Since the sound card can sample the input analog signal with a maximum sampling rate of 44.1 KHz, the fourier analysis can be used to display the spectrum of signals having a frequency range within 22 KHz.
For real time spectral analysis the time domain data have to repeatedly fourier transformed. This may require the use of internal buffers to which the input signal data will be acquired and performed FFT continuously. For a spectral analysis to be real-time it is important that the processing of the signal has to be quite fast enough to avoid missing any of the time domain input signal data.
1.2.3 Sound Card Specification
PC sound card will be used as DAC for analog reconstruction of digital waveforms and as a ADC for data acquisition.
Standard sound cards usually have 16-bit or 24-bit resolution. The sound card with higher resolution will have lesser quantization error at the output.
PC sound cards usually support a maximum sampling rate of around 44.1 KHz. Based on sampling theorem, the maximum operation frequency has to less than half the sampling frequency which would come around 22 KHz. So the software will be dealing only with signals of frequency less than 22 KHz.
1.2.4 Standard Waveforms and the spectral components
If the amplitude (A), frequency (f), DC offset is known, then a sine wave can be represented as follows:
The fourier series analysis of the square wave shows that a square wave can be generated using odd harmonics of sine wave.
The fourier series representation of triangular wave:
In other words, square and triangle wave generated will have odd harmonic sine components. So the maximum frequency of square and triangle wave that can be generated using the sound card will be limited to about 5 KHz or lesser.
The fourier series representation of saw tooth wave:
The maximum frequency of saw tooth wave generated by the software will be limited to 7 KHz or lesser.
(L. Cordesses, 2004) A DDS System with a phase accumulator of size N bits, sampling frequency of Fs and a phase increment of âˆ†ACC can be used to output a signal of frequency Fo given by
Thus the minimum frequency that can be generated FOmin is Fs/2N and the maximum frequency FOmax is Fs/2. It also suggests that it is better to keep the FOmax well below the Nyquist criterion.
Spurious spectral components will be introduced due to the phase and amplitude quantization that occurs during the DDS operation. The Spurious Free Dynamic Range (SFDR) can be improved using sine wave compression thereby reducing the total size of the look up table that is to be stored in the memory (L. Cordesses, 2004).
The use of a new unique interpolation algorithm for function generation instead of the more popular DDS look up table system suggest a reduction in the memory requirement and the ease of frequency alteration in real time (Patrick Gaydecki, 2009). It demonstrates the approximation of a sine wave using a 4th order polynomial fit.
The limitations of DDS system using look up table to generate signals of varying frequency are "first, the better the frequency resolution needed, the larger the look-up table must be; second; given that an entirely new look up table must be computed for each frequency, the method is not fast enough to permit frequency alteration in real time" (Patrick Gaydecki, 2009). The need to compute new look up table for each frequency does not match with the theory of Direct Digital Synthesis.
Considering the ease of creating a standard Windows Graphical User Interface and Multimedia interface, Delphi will be used to develop the software. It provides wrapper function for the Windows Multimedia API using which the data can be sent to and from the sound card.
A modular approach will be taken. The whole project will be divided into different modules. The development and testing of each of the module will be done before it can be integrated.
The full project will be divided into two modules:
3.1 Function Generator Module
3.1.1 Waveform Generation
The digital samples of a simple sine wave will be created in memory in wave file format and played out through the line out of the sound card using the WaveOut function provided by the Windows Multimedia Interface.
The output from the sound card will be observed using a standard spectral analyzer by varying the frequency. The frequency, amplitude and spectral purity of the signal generated will be checked. Will try with a different algorithm for function generation if found not satisfactory.
This step will be followed to generate square, saw tooth and triangular waveforms.
3.1.2 Real-Time Display of Wave Out
The current waveform that is being played out through the sound card will be displayed real-time in a window. A separate thread will be created for plotting the waveform so that it will not hinder the flow of data to the sound card. The data used for plotting the waveform will be:
The signal data stored in same memory location that was used by the sound card.
A copy of the signal data in memory.
The unit will be tested in both cases and the better approach will be chosen.
3.1.3 Integration of the different unit
The waveform generation code and the real-time display code will be integrated to the main GUI of the Function Generator appropriately.
3.2 Spectral Analyzer Module
3.2.1 Digital Data Acquisition of Input Signal
Before developing the spectral analyzer, we need to make sure that the input signal to the line in of the sound card is acquired and stored in the memory without any errors. This can be verified by displaying the signal data in real time.
The WaveIn API of the Windows Multimedia Interface will be used to acquire the input signal in wave file format and stored in some internal buffers. The WaveIn API demands the use of more than two internal buffers for the smooth acquisition of data.
The line in of the sound card will be fed using a standard function generator and the real-time display will be compared and verified.
3.2.2 Real-Time Spectral Analysis
A function for transforming the time domain samples stored in memory to the corresponding frequency domain samples using FFT will be developed. The input samples will be multiplied with a window function to avoid spectral leakage. This function will be tested using the digital samples of a known waveform.
This FFT function will be repeatedly used to transform the samples in the internal buffers that were used for data acquisition. The fourier transformed samples are plotted on to a graph.
3.2.3 Integration of the different units
The data acquisition and the real-time spectral analyzing logic are integrated onto the GUI of the spectral analyzer module.
Figure : Gantt Chart
If the sound card I/O ports are AC coupled, the software will produce wrong results if the signals in operation have a DC component.
No other serious risks have been identified at this stage.
Patrick Gaydecki, (2009), New real-time algorithms for arbitrary, high precision function generation with applications to acoustic transducer excitation, Journal of Physics: Conference Series 178, 3-5.
Lionel Cordesses, (2004), Direct Digital Synthesis: A Tool for Periodic Wave Generation (Part 1), IEEE SIGNAL PROCESSING MAGAZINE, July 2004, 50-54.
Lionel Cordesses, (2004), Direct Digital Synthesis: A Tool for Periodic Wave Generation (Part 2), IEEE SIGNAL PROCESSING MAGAZINE, September 2004, 110-117.
Analog Devices, (1999), A Technical Tutorial on Digital Signal Synthesis.
Signal Generator Fundamentals, http://zone.ni.com/devzone/cda/tut/p/id/4089
Tektronix, Fundamentals of Real-Time Spectral Analysis, http://www.tektronix-resources.com/0803pulsedrf/fundamentals_spectrumanalysis.pdf