Page |1 Introduction In this experiment, we studied periodic signals of various types. The signals obtained in the time domain were converted to digital form using the analog to digital converter (ADC), and a Fast Fourier Transform (FFT) was performed to obtain a frequency spectrum of the signal. The decomposition of a signal into its component frequencies is often very useful, especially in the analysis of noise in spectra, finding weak periodic signals in the presence of large background signals. The aim here was to obtain an appreciation of both the utility and the practical limits of this technique, which arise from discrete data sampling. Section 1 Purpose To build a spectrum analyzer, test it and obtain the frequency domain decomposition of a sinusoidal, triangle and a square waveform using FFT and analyze them for aliasing. Theory For any data sampling interval, sample, there is a frequency called the Nyquist frequency given by: fNyquist = 1/(2sample) which is half the sampling frequency. This is the maximum frequency that can be determined from the data. The following figures illustrate the importance of the Nyquist frequency: Fig. 1 Sampling at Nyquist Frequency, the frequency information is preserved but the amplitude information is lost Page |2 Fig. 2 Sampling at signal frequency, both the frequency and amplitude information is lost The FFT obtains the correct RMS voltage values for the frequency components below Nyquist frequency but not for the components above this value. In fact any component above than the Nyquist Frequency is mapped to a frequency value lower than the Nyquist frequency. This process is known as aliasing. We need at least two points per cycle of the signal to obtain the frequency information correctly. For signals greater than the Nyquist value we get 1 or a fewer sampling points per cycle of the signal and hence this information is lost. The following figure illustrates this point clearly: Fig. 3 Effect of Aliasing, figure shows that there is not even a single point per signal cycle. To avoid aliasing a low pass filter that removes frequencies above the Nyquist frequencies is usually required. The FFT algorithm can also be thought to be a binning algorithm. The frequency bins are set up with each bin having the same bandwidth df and each bin corresponding to a different frequency level. Thus the ith bin corresponds to the frequencies in the range idf to (i+1)df. The bin width or the bandwidh is given by the following equation: df = FNyquist/(N/2) = Fsample/N. where N is the number of data points usually of the form 2M.. The algorithm then determines how much of the signal power is stored within each frequency bin which is then returned in the form of an array. In order to be able to visualize the result better, we build a spectrum analyzer on the Lab Windows Environment. The code for the same is being attached as answer to 14.8. The spectrum analyzer is different from an oscilloscope because a spectrum analyzer displays the signal in the frequency domain whereas an oscilloscope displays the result in the time domain. A spectrum analyzer thus helps in better visualization of the signal in the frequency domain. Page |3 The Lab Windows function used to transform the voltage data into the frequency domain is called the AmpPhaseSspectrum which can be found under the Libraries/ Advanced Analysis Library / Measurement. This function requires an input array containing 2M voltage data points and returns the result in two arrays, Amplitude Spectrum and Phase spectrum, of 2M-1 points each. The following figure shows the input and the output of the algorithm in brief. Fig. 4 Schematic showing the details of the input and output of the AmpPhaseSpectrum function The Amplitude Spectrum returns the RMS voltage of the ith frequency component and the Phase Spectrum consists of the phase of the corresponding component. The zeroth frequency component corresponds to the frequency level of zero or the DC offset of the signal. The last frequency corresponds to the FNyquist-df frequency level. The RMS voltage of the signal can be calculated from the following equation : VRMS=√ (∑Ai2)------------------------------------------------------------------------------------(1) Here it must be noted that the number of input data points are always of the form 2 M because the FFT algorithm divides the voltage data using the binary search algorithm which is the best algorithm with least time complexity of nlogn. In other words it uses the fastest algorithm for this process. Results and Conclusion For our experiment we used a sampling frequency of 10 kHz. The number of voltage data points was 2048. An input of 2.5 kHz, 1 V amplitude sinusoidal waveform was applied to test the spectrum analyzer’s functioning. A multimeter was connected to compare the RMS voltage Page |4 measured by the spectrum analyzer with the actual RMS value of the signal as given by the multimeter. The RMS voltage measured by multimeter was 0.7082 V and the value displayed by the spectrum analyzer was 0.7068 V, Thus the two values are in good agreement with an error of only 0.2 %. Theoretically this value should be 0.707VAMPwhich is what is being observed. A slight deviation between the theoretical and calculated values can be attributed to the presence of other frequency components (noise) in the signal produced by the frequency generator. For our case the Nyquist Frequency was 5kKz. We expected to see some changes in the frequency spectrum as well as the time domain plot of the signal when the frequency of the signal went pass the 5kHz signal. What we observed was that for inputs below the Nyquist frequency the signal in the time domain and the frequency domain were being reproduced. But when the signal frequency was increased beyond the sampling frequency aliasing was observed i.e. a higher signal was being mapped to a lower frequency value following a definite pattern. Any signal of 5000+x Hz was being mapped to 5000-x Hz. For eg 6.5 kHz signal was mapped to a 3.5 kHz signal in the frequency spectrum as shown in the results. Data was obtained at other frequency levels as well to corroborate the same fact. This agrees well with what we observed in 13.12 in the time domain. For frequencies higher than the Nyquit Frequency, both the amplitude and the frequency information of the signal was lost and at the Nyquist frequency level though the frequency data was intact the amplitude information was lost (Answer 14.1). The spectrum analyzer was then used to obtain the frequency decomposition of a square and a triangle wave as well and then compare them with the sine wave. For this case we used a frequency of 300 Hz for all the three kinds of inputs. The corresponding outputs have been attached and the harmonics (aliased or not) have been identified as well. Refer to the plots for the solution. (Answer 14.2) Page |5 Section 2 Purpose To detect a very small signal amid lots of background noise and using signal averaging and phase synchronization, Theory For each frequency component the FFT returns 2 quantities, the amplitude of the component and its phase angle. Thus any individual frequency component of the signal can be thought of as a vector in the complex plane characterized by its magnitude An, and its phase angle, n i.e., H H ( Ann ) An Hˆ (n ) ------------------------------------------------------------------------(2) Fig. 5 Frequency Components in the Argand Plane Let us now apply a process known as signal averaging. A signal is acquired and then transformed using FFT repeatedly over some time interval; finally all identical frequency components from each acquisition are added together. For simplicity if we consider only one such vector and assume that its amplitude remains constant during the M acquisitions, i.e. , M M ˆ H ( A ) A H ( ) A n n n, j n n n, j n Hˆ (n, j ) ------------------------------------------------(3) M j 1 j 1 j 1 Now the averaging can be done in two ways: 1. Phase angle changes at random between the M acquisitions. 2. Keeping the phase angle constant during the M acquisitions.(Phase locked or Phase Synchronized Averaging). In 1st case, the signal averaging procedure results in a random walk in a two-dimensional plane with the same starting point and same distance but in different directions. Page |6 Fig. 6 Resultant of the frequency component with different phase angles Thus we expect the resultant vector to remain close to zero as we expect the directions to cancel out over a large number of data acquisitions. However, statistics show that the resultant vector has a good chance (probability of about 63%) to be of magnitude AnM or less. Therefore we get the following result: M H j 1 n ( Ann , j ) An M Hˆ (random) , when n, j is random. -------------------------------------(4) In 2nd case when the phase angles remain constant for each data acquisition. The sum of all vectors would look like: Fig. 7 Resultant of the frequency component with same phase angle The resultant vector would be M H n ( Ann, j ) An MHˆ (n ) , when n, j is constant.---------------------------------------------(5) j 1 Page |7 Now let us see how this procedure can be used to track noise in a signal. In most experimental situations a signal exists among noise. In other words we can think of H n as a vector composed of a noise and a signal vector: H H n _ signal ( An _ signal, n _ signal ) H n _ noise( An _ noise, n _ noise ) ---------------------------------------(6) Considering the fact that the noise signal is random, the phase angle of the noise can be considered to be random. Thus after M data acquisitions the resultant magnitudes for the two cases are; 2 H n M 2 An2_ signal MAn2_ noise , at constant n,signal ---------------------------------------------(7) 2 H n M ( An2_ signal An2_ noise ) , at random n,signal -----------------------------------------------(8) (Please note the here we are neglecting the cross terms in the calculation of the resultant magnitude.) In other words the for a constant n_signal, An_signal grows like M while An_noise grows like The same results could be obtained if the analysis is done in the time domain, The analysis here is being done in the frequency domain as it easy to understand. In the explanation given so far, it has been assumed that analog signals would be digitized first, transformed using FFT and then the corresponding components would be added together: M [h(t ) H ( w)] ------------------------------------------------------------------------------------(9) j 1 For M data acquisitions this process requires M FFT calls which requires a lot of computer time. Nevertheless, identical results could also be obtained if the digitized data is first added and together (in the time domain) and then transformed using FFT, In that case, only one FFT call is required. M [h(t )] H ( w) ------------------------------------------------------------------------------------(10) j 1 We used the second method for our experiments. Results and Conclusion To incorporate the theory developed, two functionalities were added to the C code. The first functionality was the Trigger Switch which provided user with the choice to trigger the data acquisition internally or externally and the second functionality was the Averaging switch which provided user with the choice of averaging the RMS amplitudes of individual frequency components or not. Page |8 It was found that the internal triggering was not effective as we were getting a wandering signal in the time domain, which in words meant that the phase angle was different during different data acquisitions. This was overcome by triggering the data acquisition externally by using a SYNCH output from the waveform generator as the External Trigger Input. A nice steady signal was observed when the external trigger mode was selected. The trigger functionality was tested using a 2 V(p-p), 20 Hz sinusoidal input and the averaging functionality was tested using a 2V(p-p), 1.234 kHz, sinusoidal input. After the initial testing a small sinusoidal signal of 0.002V RMS or 0.0028 V, 99 Hz was applied to the ADC board. The data acquisition was done in 4 modes. No averaging with internal triggering. Time domain: We had a wandering signal that appeared to be moving across the screen. Besides we sometimes had voltage values that were greater than the applied amplitude. Since the applied signal is of the order of the resolution of the ADC, and there is a small noise as well on it, whenever the signal value becomes more than the resolution of the ADC because of the random noise we see a sudden jump or dip in the value which corresponds to a voltage of 2xresolution level. Frequency domain : The RMS amplitudes of both the 99 Hz component and the noise components appeared to be changing with each data acquisition cycle, because of the differences in the phases between different data acquisition cycles. No averaging with external triggering. Time domain: We had a nice steady signal, which implied that the phase of the 99 Hz frequency component was same across the different data acquisition cycles. The same problem of sudden jumps or dips in the signal persisted which can be attributed to the small amplitude of the voltage applied together with the noise on it. Frequency domain: The RMS amplitudes of the 99 Hz and some other frequency components, till now conceived to be noise did not fluctuate with data acquisition cycles because of the same phase for these components. However the other noise components still had fluctuating RMS amplitudes because of the inherent randomness in their phase values. The fact that there were some other components other than the 99Hz component whose amplitudes were not fluctuating can be attributed to the fact that the signal is being approximated by finite step sizes or a square waveform sort of signal. So these other non fluctuating components actually correspond to the harmonics of this step size or square wave type signal. Averaging 10 times with internal triggering Time domain: We had a wandering signal across the screen. In this case, however the magnitude of the sudden jumps and dips in the signal were reduced because of the averaging which was cancelling the effect of noise. Though the extent of fluctuations reduced the frequency of Page |9 fluctuations increased. This can be attributed to the fact that the averaging was not phase synchronized. It is very probable that a particular data point in two different acquisitions can have different voltage value – one affected by noise and one which is not. So if we average this for one particular data point the extent of fluctuation will go down, but there shall be fluctuations for more data points. This is what is being shown in the time domain plot of the signal. Frequency domain: The RMS amplitudes of both the 99 Hz frequency component, harmonics of the step size signal and the noise components reduced when compared to the cases without averaging. The theory says that the resulting amplitude is √M times of the individual amplitude for frequency component, However, if an average is taken then the amplitude becomes √M/M or 1/√M times the individual value. Hence we should observe a decrease in the RMS amplitudes of all the frequency components, which is what is being observed. Averaging 10 times with external triggering. Time domain: We had a stable signal across the screen. In this case both the frequency of the fluctuations and their amplitude were reduced. The amplitude was reduced because we are averaging the data over a certain data acquisitions and the frequency of fluctuations reduced because of the same phase of the signal being captured at each data point. Frequency domain: The amplitude of the main frequency component and the harmonics of the step size waveform were more than that in the case with internal triggering and almost equal to that in the cases with no averaging. This is in perfect agreement with the theory. The theory says that the resulting amplitude is √M times the individual amplitude for the noise components and M times the individual amplitude for the non-noise components. Thus, if an average is taken then the amplitude becomes √M/M or 1/√M times the individual value for the noise components and M/M =1 times for the non-noise components. Hence we should observe a decrease in the RMS amplitudes of all the noise components and same value for the main frequency and step size harmonic (non-noise) components when compared with the cases where no averaging is being done. Thus taking a note of the fact that there are bound to be some harmonics of the step size waveform the signal is best observed in the case with averaging and external triggering. The harmonics of this step size waveform appear as spurious signals in the frequency domain. If the amplitude of the applied signal is increased then the RMS amplitudes of the harmonics shall be very small as compared to the RMS amplitude of the harmonic signal. Hence we can rate the modes of data acquisition in terms of the observability of the applied signal as follows: (the best is the first one) 1. Averaging with external triggering. 2. Averaging with internal triggering. 3. No averaging with external triggering. 4. No averaging with internal triggering. (Answer 14.3). If we pay close attention to the averaging and external triggering case we see that there are discrete jumps in the values of the voltages in the time domain. This is because the ADC board has a finite resolution and cannot display any voltage less than 2.44 mV. Thus we see discrete jumps of this P a g e | 10 value in the time domain plot of the signal. The value observed from the outputs matches well with what was calculated in the previous chapter in 13.2 i.e. 5/(211-1). (Answer 14.4) Since the resolution of the board is 2.44 mV this is the smallest voltage value that can be read by the ADC board. Thus our program can determine voltages reliably only if they are above this value. This was confirmed by the observations as well. So the minimum voltage level at which the RMS can be determined reliably is when the amplitude of the applied signal is greater than or equal to 2.44mV. In our case the applied amplitude is 2.82 mV and hence the RMS can be determined quite accurately. (Answer 14.5) P a g e | 11 Section 3 Purpose To improve the sensitivity of the spectrum analyzer by incorporating dithering. Theory Dithering describes the process of adding a small amount of random noise to a signal. ADC and DAC conversion are one of the rare and strange situations where adding a random noise to a signal will actually improve the sensitivity of the conversion process and in a sense, decrease noise. The ADC boards which you are using have been designed to include a circuit which, when enabled, will add random noise to the signal. The random noise’s amplitude is equivalent to the sensitivity of the ADC, or one bit. Consider a process where a DC signal is acquired M times and then its average is being determined from these readings. If there is no noise imposed on it, then every time the ADC conversion will yield the same value for the signal. Hence its average value shall also be the same value and there will be no improvement in the accuracy. On the other hand if a small random noise is imposed on the signal to be measured, each ADC conversion shall produce a slightly different value because of the noise. If the average random noise is equal to the sensitivity of the ADC, it is very likely that the conversion values would be either one value higher or lower than the value that would have been without the noise. In rare cases the value may even fall 2 or 3 values above or below. But overall, all various conversions will produce a random distribution centered on the average value which can then be determined by averaging the values. (Answer 14.7) Results and Conclusion When dithering was switched on the time domain plot of the signal appeared to be noisy. This is because we are imparting some noise to the signal over and above the phase locked averaged signal. Since the magnitude of the noise and the magnitude of the applied signal is comparable the signal appeared to be more noisy than in the case without dithering. However, because of the noise, the step sizes were smoothed out In frequency domain the RMS amplitude of the 99 Hz component increased a little and the RMS amplitude of the harmonics of the step size waveform decreased when compared to the case with no dithering. This can be attributed to the fact that the random noise was essentially smoothing out the resolution steps in the signal ad therefore they do not get reflected in the frequency domain as well. The measured RMS value as shown in the GUI is 2.1 mV. The calculated value is 2 mV. So the two values are in close agreement with an error of 5%. (Answer 14.6) Next we applied a signal of 0.100 mV RMS or 0.1414 mV signal to the ADC input. The RMS value shown by the GUI was off because of the noise imposed. Though the plot looked haphazard in the P a g e | 12 time doman, in the frequency domain, we could clearly notice a peak at 99 Hz frequency value. The fact that must be appreciated here is that the spectrum analyzer is able to pick up a signal that is around 18 times smaller than its resolution (2.44 mV). The reason behind this has already been explained in the ‘Theory’ section. Had we not imposed this noise the spectrum analyzer could not have detected this signal because every conversion would have yielded a value of zero for this signal because it is less than the resolution of the signal. We expect the amplitude of the signal to remain constant and the amplitude of the noise to decrease √M times when we have switched on external triggering, where M is the number of data acquisitions. With internal triggering we expect both the signal and the noise amplitudes to become 1/√M times when there is no averaging. (Answer 14.7) P a g e | 13 Section 4 Purpose To obtain the frequency response of high pass and low pass filters using White noise. Theory An ideal white noise’ time and frequency domain response have been shown below: Fig. 8 Time Domain and Frequency Domain response of a white noise Thus essentially a white noise contains all the frequencies and has the same amplitudes of each. Results and Conclusion In our case the white noise was not produced using the HP33120 A’s internal white noise generator but by multiplying a Delta function produced by the HP 33120 A in its burst modulation mode with a 10 V p-p, 40 kHz square waveform. The sampling frequency was increased to 100 kHz. The function generator’s burst mode frequency was set to 10 Hz . A RC filter was built with a resistor of 1kΩ and a capacitor of 0.01μF. When the output was taken across the resistor the RC assembly acted as a high pass filter and when the output was taken across the capacitor it acted as low pass filter with the same -3dB frequency in both the cases. The -3dB frequency for this RC filter was 1/(2лRC) = 15.92 kHz. The frequency responses of the filters have been shown in the results. The -3dB frequency from the plots came out to be 14.75 kHz and 14.38 kHz for low pass and high pass filters respectively. Thus these values were off by 7.35% and 9.67% respectively which are within permissible limits. (Answer 14.9). If we use the HP’s internal white noise generator and the same high and low pass filters, we would observe a rather noisy signal. This can be attributed to the fact that the two signals that the internal noise generator couples to produce a white noise are not phase locked. Hence sometimes we get no peak when we expect to get a peak. Even if averaging is done, signal to noise amplitude remains the same as both reduce by a factor of √M where M is the number of times the signal has been acquired and the averaging has been done. P a g e | 14 The solution here is to somehow lock the phases of the two signals and then perform the averaging, or instead use the bust modulation mode coupled with a square waveform to produce a white noise. (Answer 14.10) P a g e | 15 Appendix 1. Print out of the results in the order in which the respective questions appear in the lab manual.