|
|
|
1. Introduction
The first part of this self-taught unit presents background
information on many aspects of computer data acquisition. The
most important aspect, however, has nothing to do with the
computer itself but with the signal you feed it. The use of PC's
in the laboratory can greatly improve the experimentalist's
productivity. However, the computer cannot be viewed as a magic
box that will do the thinking for you. It is no more than a
sophisticated tool and no smarter than a Crescent wrench. Just as
you can get into trouble rounding off the head of a bolt with
improper use of the Crescent wrench, you can get into (much
deeper) trouble with improper use of the PC. This section is
meant to familiarize you with the characteristics and
capabilities of this tool. It is important to be aware of the
limitations of the computer as well as its strengths. Perhaps the
most important limitation has to do with the signals you feed
into the computer and ask it to measure. Many real world signals
are not compatible with the narrow requirements of the PC and
must be conditioned before they can be accurately measured. Heed
the old adage - "Garbage in - Garbage out" and pay
careful attention to these signal requirements as you learn how
to use this new tool. The second part of this chapter introduces
the concept of the frequency spectrum. Spectra are used to
characterize complicated signals that are difficult to describe
as functions in the time domain. Random or pseudo-random signals
are often analyzed in this way. The idea is that if you can't
make much sense of a signal in the time domain, perhaps you can
extract some information about the frequency content of its
fluctuations by analyzing the signal in what we call the
frequency domain. This may allow you to pick out certain
frequencies that contribute more to the signal than others and
perhaps yield some insight into the physical process that created
the signal.
In order for the computer to understand and manipulate physical data we first need a transducer to convert the physical phenomenon to an electrical signal whose amplitude (or frequency) is proportional to the data. This electrical signal is an analog input which must be converted to a digital code of 1's and 0's that the computer can understand. The device which does the conversion is aptly called an analog to digital converter (A/D). There are also devices which perform the inverse operation-digital to analog converters. These give the computer the ability to control a physical system. Figure 1 shows the components of a data acquisition and control system. Besides the converters, other components such as signal amplifiers, input multiplexers, counter/timers and sample-and-hold amplifiers may be a part of the system. There are two ways to get the data acquisition hardware to communicate with a PC: direct connection to the internal PC bus, where the data acquisition hardware resides on a plug-in circuit board, or connection via a standard external communication channel such as RS-232, RS-422 or IEEE-488, where the data is acquired by a separate instrument (perhaps remote to the host computer). We will be using the internal bus method. It has the advantages of lower cost and smaller size since the data acquisition hardware does not need a separate enclosure or power supply (these are supplied by the PC). It also has the advantage of a higher speed data transfer capability. For example, using RS-232 communications at 9600 baud you'll be limited to about 20 analog readings per second. Some PC bus systems can take data faster than 1 million samples per second. Figure 2 shows a block diagram of an internal bus system. You will be using a Lab PC 1200/AI data acquisition board from National Instruments.
Analog-to-Digital Converters
The A/D converter is the heart of a data acquisition system. There are several different types on the market today. They differ in the way in which they perform the conversion and this impacts on their resolution and speed. The most common type uses the successive approximation method to do the conversion. It offers the best trade-off between resolution, speed and cost. A/D's which use the integrating method offer higher accuracy at lower cost than successive approximation types but they are very slow. The fastest and most expensive A/D's use the parallel or flash method. While they achieve very high conversion rates, they are limited to low resolutions.
Resolution
The resolution of an A/D is determined by the number of bits it uses to represent the value of the analog signal. A bit is a binary digit, a 1 or 0. With one bit you can represent only 2 values, 0, and 1. 2 bits can represent 4 values, 00, 01, 10, and 11. 3 bits can represent 8 values, etc. In general, n bits can represent 2n values. An A/D takes it's entire input range, typically 5 V (as it is in the one you will be using) and divides it into 2n pieces. When the analog input voltage falls within the range covered by one of these pieces, the A/D outputs the digital code (an n digit binary number) which corresponds to this piece. Obviously, the larger n is, the narrower the range each piece covers and the more closely the digital output represents the analog input. In today's market, a 12 bit resolution is the most common, however, resolutions as low as 8 bits and as high as 16 bits are not uncommon. Higher resolution converters of a given type are typically more expensive and slower. With a 12 bit resolution, the converter is capable of outputting 4096 values. If these values are spread over a range of 5 V, each value represents a range of 2.44 millivolts (=10/4096) or about 0.024% of the full range. A 16 bit converter has 65,536 possible output states for a resolution of about 0.0015% of the full range. The converter you will be using has a 12 bit resolution. Note that there is a subtle difference between resolution and accuracy. The accuracy of an A/D board is limited by the resolution of the A/D converter but can also be affected by other board components (which will be discussed below). Most 12 bit systems do achieve an accuracy close to the resolution of the A/D but many 16 bit systems do not.
Speed
There are two measures of speed of a data acquisition system. The time it takes the A/D to complete a single conversion, called the conversion time, and the time it takes from the start of the acquisition to the completion of the data transfer to a specified location, the PC's memory or disk, is called the throughput time. This time includes the A/D conversion time plus the settling times of the various other components on the board and the transfer time of the converted data. If direct control from the PC's CPU is required in the process, the throughput time will be dependent on the speed of the host computer. Throughput rates (the inverse of throughput time) are generally quoted as samples per second or Hz. The actual throughput achievable with the LabPC card is 100kHz, which puts it in the mid to upper range of data acquisition systems.
Amplifiers
The board you will be using has a 12 bit A/D, so with your 10 volt input range, you have about a 2.5 millivolt resolution, but the amplitude of analog input signals can vary over a wide range. For example, what do you do when you want to measure a strain gauge signal which is only a few millivolts? In order to get meaningful results, you must first amplify the signal to the point where your 2.5 millivolt resolution is comparable to the accuracy of your strain gauge measurement. Or, looking at the situation from the opposite point of view, if the signal is amplified by 1000 before conversion, the input range ahead of the amplifier is 5 millivolts and you are getting an effective resolution of 2.5 microvolts. (But be cautious of the noise in the amplifier affecting your accuracy!) In order to make the best use of the limited resolution of the A/D, you will want to amplify (and perhaps shift) your input signal such that it's range matches the full input range of the A/D. Since many real world signals require this amplification, most data acquisition boards include an instrumentation amplifier on the board with perhaps 4 or 5 selectable gain values. Many boards allow the software to change the gain value (Programmable Gain Amplifier) including the present one which has software selectable gains of 1, 2, 5, 10, 20, 50 and 100 . These gains provide effective input ranges of 5, 2.5, 1, 0.5, 0.25, 0.1, and 0.05 V. For this lab, the effective input range will be fixed at 5 V. A simple analog input channel is shown in Figure 3. While a small amount of over-voltage may be tolerated and most systems contain over-voltage protection devices, it is important to realize that many board components can be permanently damaged if connected to voltages over 35 volts. Signals higher than 5V can often be reduced before being measured simply by using resistors to form a voltage divider.
Multiplexers
What if you have more than one signal to sample? You could duplicate the circuit of Figure 3 for each channel, but this would be very expensive. A cheaper way to accommodate more channels is to introduce a multiplexer (Mux) as in Figure 4. A multiplexer is a software controllable switch which can select any one of several channels for processing at a given time. With a Mux, all channels share a single amplifier and A/D. This will of course slow down the data acquisition rate at a given channel if more than one channel is being used. Note that stated throughput rates are total, not per channel, samples per second. The multiplexer on the board you will be using can select from 8 different input channels.
Sample/Hold
Also shown in the circuit of Figure 4 is a sample/hold amplifier (S/H). Successive approximation A/D's require that the input signal remain constant during the conversion process, however, real world signals may fluctuate rapidly. The S/H is a device that tries to make its output follow its input until it is told to hold a value. It then maintains the output as steady as possible, regardless of fluctuations of the input, until released to follow the input again. This assures that the successive approximation A/D is not trying to hit a moving target. Another important use of the S/H is shown in Figure 5. Note that the system of Figure 4 will sample channels sequentially, sweeping through a specified number of channels at a specified rate. Many applications however, require that you sample two or more channels at the same instant. This can be nearly achieved by a simultaneous sample/hold system. When instructed to take a sample, this system can capture the inputs on all channels within a few nanoseconds and hold those values until they have each been read by the A/D. A system of this type, while more expensive, is useful when cross-correlations of rapidly varying signals are to be calculated such as in turbulent flow studies. The board we will be using do not have this capability.
Single-ended vs. Differential Input Modes
Most multiplexers use single-ended input connections where only the high (+) end of the signals are connected to the amplifier by the Mux. Single-ended inputs share a common ground or return line which connects to the amplifier through the system ground connections. When measuring low amplitude signals in an electrically noisy environment or when there exists a large difference in ground potentials, it may be desirable to directly measure the difference between an input's high and low lines. Multiplexers with differential input modes allow you to do this at the cost of having half the number of inputs available as in single-ended input mode, i.e. 8 single-ended or 4 differential inputs. Differential inputs provide common-mode rejection, that is, a voltage common to both input lines, be it a fluctuating noise or a steady offset, is canceled out before the signal is read by the A/D. We will be using the LabPC 1200/AI configured for 4 differential inputs.
Clock
A data acquisition board which will automatically perform a series of data conversions will have an onboard pacer clock circuit which is used to initiate the conversions. These clocks typically use a 5 to 10 MHz oscillator and a programmable divider circuit. Many clocks will accept an external oscillator signal to facilitate synchronizing the measurements with external events.
Counter/Timer
The counter/timer (C/T) circuits present on many boards can be used for frequency measurements as you have done with the Tektronix counter, however, they can also help time and synchronize events. C/T's will accept as input and will output TTL level digital signals (0 - 5 volts recognized in two states only, high or low). They can count the number of input pulses in a fixed time interval (this is how you used the Tektronix counter), or count clock cycles between input pulses (which is another method of measuring frequency). It can also be set to output a pulse after a given number of input pulses have been counted. This signal can be used to activate external events or to trigger data acquisition.
The Software Link
Each of the data acquisition board components must of course
be told what to do and when to do it. Commands are communicated
to the board by writing the proper digital code to a particular
board register. While this is usually well documented, it is a
significant task to instruct the PC to write the proper codes in
the proper order to perform a given task. Board manufacturers
usually provide example routines written in standard languages
(e.g. Visual BASIC, C++, FORTRAN) or instrumentation based
graphical programming languages (e.g. LabView, HPVEE) to perform
range of standard tasks. However, the importance of understanding
what is going on at the hardware level cannot be over-emphasized.
The software you will be using for the first experiment in this
unit is programmed in LabView. LabView is a sophisticated
graphical programming language specifically designed for
instrumentation applications that is in fairly wide use across
industry and academia. While there is not time in this
self-taught unit to teach you LabView programming, you will be
experiencing the look and feel of a LabView application. You
already met a LabView program in experiment 5 (Fracture Toughness
Testing) and will meet other LabView programs in experiment 7
(Aerodynamic Testing) and in the senior lab course.
Name four components you would expect to find on our data acquisition boards.
1.________________________________________
2.________________________________________
3.________________________________________
4.________________________________________
What is the resolution of our A/D converters? (# of bits)
____________
What is the effective full input range as the board as we will
use it? ___________
With this resolution and range, what is the size of the step
between possible output values from the board? (in volts)
___________________
According to the manufacturer, how many conversions will our
A/D boards do per second (i.e. the throughput)?
________________________
Is common-mode rejection possible with our A/D boards?____________________
Objectives
This lab is meant to introduce you to computer data acquisition and provide hands-on experience with the necessary equipment. This lab will also introduce you to some of the limitations of A/D converters specifically their limited range, resolution and the problem of frequency aliasing that is introduced by their limited sampling rate.
Equipment
Procedure
Locate the
connection box which has 4 BNC sockets labeled '1' through '4'.
Use the BNC cables and "Tee" connectors to connect the
output (main) of the frequency generator to 1) the channel 1
input of the connection box, 2) the frequency input of the
counter, and 3) the channel 1 input of the oscilloscope - see the
wiring diagram on the right. It is always a good idea, and often
imperative, to monitor the input to the data acquisition system
with an oscilloscope. Before turning the instruments on, check to
see that on the function generator, the volts out switch is in
the 0-20 V PP position (out), the amplitude knob is all the way
down (counterclockwise), the DC offset and duty knobs are in the
off position (pushed in) and the sweep switch is in the ext
position (out). Set the oscilloscope sweep trigger mode to the PP
AUTO position and trigger source to Ch 1. Start with a 5 msec/div
sweep rate, and a CH1 VOLTS/DIV setting of 0.5V. Check that on
the counter, the input voltage button is out (80mV-5V) and the
low-pass filter button is in (On). Turn on the power to the
counter, function generator and oscilloscope. Adjust the function
generator to produce a 100 Hz sine wave (as determined by the
counter) of peak to peak amplitude 2V (you'll need to turn the
amplitude up a little). You should check that the DC offset is
near zero. You can find zero by switching the oscilloscope's
channel 1 coupling switch to the ground (GND) position. If this
is not the center of the wave seen with DC input coupling, the DC
offset switch on the function generator might be in the out
position - push it in.
What are the maximum and minimum voltages of the signal as measured with the oscilloscope?
_____________________________________
What is the time between positive peaks for the 100Hz sine
wave? _________________
Now you're ready to use the LabView program,
called 'Acquire'. Log on to the computer - userid
"3054", password "3054". Double click on the
Acquire icon on the desktop to launch the program. Acquire starts
with a window like that shown below.
The window contains a typical menu bar at the top followed by 4
buttons used to control the application, specifically , which
runs the program (the program then stops after collecting one
complete set of data), , which runs the program repeatedly, ,
which stops the program and , which pauses the program (this
button only works in conjuction with the single run button).
Below the buttons are five panels. The first, labelled
'Acquisition' contains two fields 'No. of samples' and 'Sampling
rate' (in Hz). You can edit these to change the length of each
record measured and the rate at which it is measured. Change the
number of samples to 50 and the sampling rate to 1000Hz now. The
next window labelled 'Analysis' contains two fields 'Window' and
'No. of Averages'. These primarily affect how the program
calculates spectra, so we will discuss them later. For now,
change the number of Averages to 1. The third panel 'Results'
display the mean and rms voltage for each record measured. There
are two graph panels the first 'Time series' shows each record
after it is measured. This will be the primary focus of our
initial measurements. This panel has a selector that toggles
between 'Windowed' and 'Measured'. Switch it to 'Measured'. The
second graph panel shows the averaged spectrum of the measured
records and a selector that toggles between 'Logarithmic' and
'Linear' (refering to the y-axis scale). We will work with this
later. Note that this program gives you no control over which
channel is measured - this is fixed at channel 1 - or the range
of the A/D board - which is fixed at +/-5V. To change these you
would have to modify the original program.
Press the run button to acquire one record (set of samples) of the 100Hz sine wave. After a short pause the record will be displayed in the time series and spectrum windows and its mean and rms (in volts) will appear in the results panel. The mean should be about zero and the rms about 0.7. The time series should appear like the example shown here. Note that the horizontal axis of the time series plot is the time in seconds and the vertical axis is the voltage in volts. Note that the time series shows the sine wave with a period (time between successive peaks) of 1e-2 seconds and a peak-to-peak amplitude of about 2 volts, consistent with our function generator settings. If you don't see this, recheck your set up, make any necessary adjustments and run the program again.
Test 1. Illustration of Frequency Aliasing
Run the program 10 times, increasing the frequency of the signal
produced by the function generator each time by 100Hz. For each
run measure the apparent period of the signal as it is seen on on
the time series plot. Put your results in the following table.
| Frequency (Nominal, Hz) | Frequency (from counter, Hz) | Apparent period (from Acquire, secs) | Apparent frequency (1/period, Hz) |
| 100 | |||
| 200 | |||
| 300 | |||
| 400 | |||
| 500 | |||
| 600 | |||
| 700 | |||
| 800 | |||
| 900 | |||
| 1000 |
Note that there appears to be a maximum frequency that Acquire
can measure, and that frequencies above that appear as though
they were lower frequencies (i.e. they are aliased). This maximum
frequency is called the Nyquist frequency and it is half the
sampling rate. To put it another way, the lowest sampling rate
you can use and still obtain the wave's true frequency is twice
the frequency of the wave, i.e. you need at least two points on
each wave.
What is the minimum sampling rate you need to use to reveal the true frequency of the 1000Hz sine wave? _______________.
Check your answer using the program. Note: Although at the
minimum sampling rate you see the true frequency, you do not get
an accurate representation of the shape of the wave. For that you
need a much higher sampling rate.
Try to determine a formula to predict the apparent frequency that will result from a given combination of waveform frequency and sample rate.
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
______________________________________________________________________________________
Test 2. Voltage range and resolution.
Adjust the function generator so it is once more producing a
100Hz 2Vp-psine wave. This time, however, set the
sampling rate to 10000Hz and the number of samples to 500. Run
the program and the time series should appear like that shown on
the right. Note that this is the same as when we started except
that the signal appears smoother. This is because we are using 10
times as many samples over the same total sampling time, so its
shape is better defined.
Run the program two more times. First with the amplitude turned all the way up to produce an near 20Vp-p sine wave, and second with the amplitude turned nearly all the way down to produce a 10 millivoltp-p wave (you will need to adjust the VOLTS/DIV on the scope so you can properly see these signals). Sketch the resulting time series you measure below. In each case (a) explain why you don't see a sine wave and (b) explain how what you see is quantitatively consistent with the hardware/software limitations of this A/D converter (described above).
20Vp-p sine wave:
(a)___________________________________________________________________________________
______________________________________________________________________________________
(b)___________________________________________________________________________________
______________________________________________________________________________________
10mVp-p sine wave:
(a)___________________________________________________________________________________
______________________________________________________________________________________
(b)___________________________________________________________________________________
______________________________________________________________________________________
3. Frequency Analysis and Spectra
The concept of a spectrum
Often when dealing with time varying signals, it is more
convenient to consider the signal as being the superposition of a
number of sinusoidal components of different amplitudes,
frequencies and phases than to deal with the time variation
directly. This is especially true if the process we are trying to
measure is random as in the case of turbulent flow or ocean
surface waves. One is then considering the signal in the
frequency domain rather than in the time domain, i.e. looking at
the frequency content of the signal rather than the time
variation of its amplitude. You were exposed to this concept, in
a limited way, when you studied Fourier series. You have seen how
any periodic signal can be represented as the sum of an
infinite number of sines and cosines (sometimes called harmonics)
each with a particular amplitude and with frequencies which are a
multiple of a base frequency equal to 1/T where T
is the period of the signal, i.e.;
g(t)= (ao/2)+[ancos(2nt/T)
+ bnsin(2nt/T)]
where; an= (2/T) g(t)cos(2nt/T)
dt n=0,1,2,...
bn= (2/T) g(t)sin(2nt/T) dt n=0,1,2,...
We can rewrite the summation using trig
identities as; g(t)=(A0 /2) + Ansin[(2nt/T)+n]
where; An= (an2
+ bn2) , n=
tan-1 (an/bn)
Try this. ( Recall: sin(a + b) = sinacosb + cosasinb ) The An is the amplitude of the nth frequency component of g(t) and n is its phase. By varying the phase, you shift the sine wave horizontally along the time axis. In general, each frequency component will have a different phase. The series of discrete frequencies used to make up g(t) is nf0 , n=0, 1, 2, ... where f0= (1/T) . The zero frequency component, A0/2 , is the mean of g(t).
So, using the results of such a Fourier analysis we can plot, for any periodic signal, the amplitude and phase as functions of frequency. Such plots are called amplitude and phase spectra and contain a set of discrete points spaced at f0. For many physical signals, however, it is the proportion of the total energy or power represented by each frequency component we are most interested, not the amplitude or phase. Usually the power is represented by the amplitude squared. For example, for a turbulent flow, the energy (kinetic) is proportional to the the amplitude of the velocity fluctuations squared, (1/2)V2 . The power of an a.c. electrical signal is proportional to the square of the amplitude of the fluctuations in voltage.
You may be forgiven for thinking then that the power spectrum (also known as the autospectrum or power spectral density) is a plot of An2 vs. frequency. Actually it is a plot of An2/f0 vs. frequency, where f0 is 1/T, the frequency increment. This way, the area under the spectrum is proportional to the power in it.
The idea of a spectrum can be easily extended to non-periodic signals. Note that as you increase the period of a periodic signal, the frequency increment f0 = 1/T at which the spectral values are spaced gets smaller. Now, given that one can think of any non-periodic signal as being a periodic signal with infinite period, it follows that the spectrum of a non-peridic signal will be a continuous function of frequency. In this limit the summation in the Fourier series representation of the signal becomes a continuous integral known as a Fourier integral. g(t)=A()sin[t + ()]d where is the angular frequency (=2f). The series of An's, the amplitudes of the discrete components, now becomes a continuous function of frequency, A() , as does the phase. The spectrum is now a continuos function of frequency, defined again such that the mean energy (or power) of the signal is equal to the area under the spectrum curve.
Estimating a spectrum from a A/D converter measurement Consider now the task of estimating the spectrum of a signal measured with an A/D converter. Unlike the idealized mathematical situation, in which we have a continuous and complete representation of the signal g(t), we only have a sequence of samples of it g(mt) taken at integer multiples m of the sampling period t for a finite period of time (i.e. for m=1 to N where N is the total number of samples). One can compute the spectrum of such a sampled signal by using an adapted form of the Fourier series equations known as the discrete Fourier transform - Using trig identities as before we write, To understand these equations it is helpful to realize that the arguments to the sine and cosine functions are actually simplifications of the expression 2[mt][n/(Nt)], [mt] representing the time and [n/(Nt)] the frequency. Take a look at these equations and then answer the following questions.
In terms of N and t what will be the maximum frequency in the computed spectrum?
________________________________________________________________________
What will be the lowest, non zero, frequency?
________________________________________________________________________
If we use the results of the above equations to determine the power spectrum of the signal, how many points will there be in the power spectrum, compared to the number of samples in the record N?
________________________________________________________________________
How can I change the way I sample the signal to get more frequency resolution in the spectrum?
________________________________________________________________________
How can I change the way I sample the signal so that the spectrum covers a greater range of frequecies?
________________________________________________________________________
The purpose of applying these equations is, of course, to obtain the spectrum of the actual signal. What we get from these equations is the spectrum of the sampled version (the so-called spectral estimate). If we are not careful the latter can be a very poor estimate of the former. Differences can arise for a number of reasons.
First of these is the Nyquist criterion we have already met. This limits the range of frequencies at we can resolve using the measured record to frequencies below the Nyquist (half our sampling rate). Any energy in the original signal at frequencies above the Nyquist will have been aliased by the sampling process and tend to appear at lower frequencies currupting our spectral estimate. One way of avoiding this type of corruption problem is to filter the low-pass filter the original signal at the Nyquist frequency before it is sampled.
The second problem stems from the fact that we
only have a finite length record of the signal not its complete
history. The discrete Fourier transform computed by the above
expression gets around this problem by treating the sampled
signal as though it were periodic, with a period equal to the
record length. If the signal is not periodic in this way this
implies a discontinuities at the start and end of the record, see
Figure 6. These discontinuities in turn imply
frequencies in the spectrum that are not actually in the signal -
yes more corruption. This problem, known as broadening can be
minimized by multiplying the signal by a smooth function that
goes to zero or nearly zero at the ends of the record, called a
window. There are a variety of different commonly used windowing
functions. Some are listed in the table below and illustrated in Figure 7. All these have the form where where T
is the total record length and the constants c0
, c1 , and c2
are as follows:
| Window type | c0 | c1 | c2 |
| Blackman | 0.42 | 0.5 | 0.08 |
| Blackman-Harris | 0.42323 | 0.49755 | 0.07922 |
| Exact Blackman | 7938/18608 | 9240/18608 | 1430/18608 |
| Flat top | 0.2810639 | 0.5208972 | 0.1980399 |
| Hamming | 0.54 | 0.46 | 0 |
| Hanning | 0.5 | 0.5 | 0 |
The third problem arises when our measured record is part of a random (or non-periodic) signal. Since a random signal is random two spectral estimates of the signal calculated from two successive records will not be the same. In fact, the spectra can be quite different and are often of an erratic shape. To get a better estimate of the spectrum of such a signal we can average the two spectra (assuming the properties of the system being measured have not changed between records). The average will also be smoother making it easier to pick out significant features. In practice, we usually average many calculated spectra (sometimes hundreds) to arrive at a final estimate of the spectrum.
It is important to be aware that spectra are normally calculated using the Fast Fourier Transform (FFT). This algorithm produces exactly the same results as the discrete Fourier transform discussed above but exploits computational symmetries to greatly accelerate the speed of the calculation.
Objectives
This experiment is designed to illustrate the problems and their remedies associated with estimating spectra from sampled data - one of the commonest applications of the A/D converter.
Equipment
Procedure
Test 3. The Aliasing Problem
Adjust the function generator so it is once more producing a 100Hz 2Vp-psine wave. Set the sampling rate in Acquire to 1000Hz and the number of samples to 50. Select 'Linear y' for the (power) spectrum plot, and check that the window and number of averages in the analysis panel are still sert to 'None' and 1. Run the program and the time series and spectrum plot should appear as shown on the right. The horizontal axis of the spectrum is frequency in Hertz, the vertical axis (with Linear y' selected) is voltage squared per Hertz. Note that the spectrum contains al large peak at 100Hz consistent with the signal we supplied and apparently little else (but wait until later).
Increase the frequency to 300Hz and run the program once more. Note the peak frequency in the spectrum here _________. Increase the frequency again to 700Hz, run the program again and take a very good look at the spectrum. Note the new peak frequency here _________. Explain your results below - if necessary try some other frequencies to convince yourself.
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
_________________________________________________________________________
This is the phenomenon of aliasing as seen from the frequency domain. The corrupting effect of aliasing can be devastating on real signals containing multiple frequency components. For an unknown signal (with unknown frequency content) the only satisfactory way of preventing aliasing is to low-pass filter the signal (using an analogue filter circuit) at the Nyquist frequency before sampling it - as we discussed above. For this reason some of the most expensive A/D converters (but not the Lab PC 1200) have in built 'antialiasing' filters that automatically do this for you.
Test 4. The Broadening Problem
Return the function generator so it is once more producing a 100Hz 2Vp-psine wave. Run the program and the time series and spectrum plot should appear again as shown above. Note the nice sharp peak in the spectrum. Now adjust the function generator frequency to 90Hz and repeat the measurement. The spectral peak should not only change its position to 90Hz, but become a lot broader and possibly asymetric. At 100Hz exactly 5 periods of our sine wave fit into our measured record, but at 90Hz on 4.5 periods fit. Since the Fourier transform assumes periodicity with a period equal to the record length this results in discontinuous changes at the ends of the record for 90Hz. These implied discontinous changes are what is responsible for the wider peak.
To minimize this problem we need to use one of the window functions. To see the window functions and their effects clearly, increase the sampling rate to 3000Hz and the number of samples to 150. Change the y scale on the spectrum plot to logarithmic (this expands out the y scale to show the broadening much more clearly). Run the program again and you should see a time series and spectrum like that shown on the right. Note that the time series appears the same as before, but the spectral peak has shifted to the left. This is because we increased our sampling rate and thus the frequency range of the spectrum. Note that since the frequency range is now to '1.5E+3' (i.e. 1500Hz) our peak is still at around 90Hz. With the logaritmic scale we can also see much more clearly the 'skirt' around the peak produced by the broadening. One way of measuring the extent of the broadening is to take the difference (on this log scale) between the height of the peak at 90Hz and the level of the rest of the spectrum (all of which is produced by the broadening) at another frequency, say 250Hz. For this unwindowed signal the difference should be about 2 (i.e. a factor of 100 bearing in mind that this is a log10 scale). Mark the value you read onto the table below. Now lets try to improve things by using a window. Change the 'Window' to Hanning (click up once), and run the program again. At first sight the spectrum looks even worse than before (i.e. even less like a single spike at 90Hz which is what our signal is). However, this is because the spectrum plot autoscales. Check the difference between the level of the spectrum at 90Hz and that at 250Hz and you should find that it has increased considerably, implying a substantial reduction in the part of the spectrum due to the broadening compared to that due to the signal. Mark the difference you measure on the table below. You can see directly the effect of the window on the signal if you change the Time Series plot from 'Measured' to 'Windowed' and retake the data. It is this windowed signal that the spectrum is actually being calculated from.
Run the program for all the other window functions in turn marking the difference between the level of the spectrum at 90Hz and that at 250Hz in each case in the table below. Which window do you think does the best job?
| Window function | Difference between log10 spectral level at 90Hz and 250Hz |
| None | |
| Hanning | |
| Hamming | |
| Blackman-Harris | |
| Exact Blackman | |
| Blackman | |
| Flat Top | |
| 4-term Blackman Harris | |
| 7-term Blackman Harris |
Test 5. The Problem of Random Signals
For the last task in this experiment, you will be digitally
recording your own voice and doing a spectral analysis of it.
Your voice is a good example of a non-periodic signal with random
components. We will be running a microphone signal through the
phono (or tape) input of the stereo amplifier. Although we have
adapters that will link the microphone jack with the phono plug
on the amplifier, these inputs are not designed to accommodate a
microphone signal. As a result, you will have to adjust the
channel you are using to maximum volume and speak loudly into the
microphone to get an output signal of reasonable amplitude. Be
sure that both channels are properly loaded with 8 - 16 resistors
and that the input selector switch is in the position for the
input you are using (tape or phono). Connect the output from the
channel you are using to both the oscilloscope and the A/D board
terminal box. Speak into the microphone and observe the signal on
the scope. When doing this test, it's best to repeat the same
word over and over, such as 'hello, hello, hello, ...' Speak loud
enough to fill as significant a portion of the 5 V range of the
A/D board as possible (signals of more than 1V amplitude are hard
to acheive without embarrasment). You may find it convenient to
cup the microphone with your hands to your mouth to get a larger
signal. Try not to muffle the sound of your voice if you do this
however.
The human voice typically produces sounds with frequencies from 10 to 20000Hz, but this (relatively cheap) amplifier/microphone combination has little if any response beyond 5000Hz. How many samples should you take and at what sampling frequency to ensure you capture the full range of the voice signal output by the amplifier without aliasing?
___________________________________________________________________________________________
___________________________________________________________________________________________
Set this sample rate and number of samples in Acquire. Select 'Logarithmic y' for the y-scale of the spectrum. This is the natural choice for a voice spectrum since the human ear responds logarithmically to the sound intensity. Select a suitable window (all except 'None' are suitable) to prevent broadening, and note your choice below.
Window used ____________________________
Begin talking/shouting/singing into the microphone and run the program several times. You will notice that the spectrum looks noisy and each time it is different than the last. This is because your voice is more random than periodic so that successive records measured from it will have different looking spectra. Sketch a sample spectrum below.
Voice spectrum, No averaging:
To obtain a spectrum more representative of your whole speaking voice (rather than just the bit spoken when the record was being measured) it is necessary to average the power spectrum. Begin talking and run the program twice more, once with 10 averages and once with 100 (you will have to talk for longer). Sketch the spectra you measure below. The 100 averages should provide a lot smother and more repeatable spectrum than none at all. Note that the spectrum may contain a number of sharp spikes - these are almost always electical interference. The source of this interference is usally the mains or a computer. Getting rid of such interference to get a 'clean' spectrum can be a major challenge when setting up an experiment.
Voice spectrum, 10 averages:
Voice spectrum, 100 averages:
Finally take the opportunity to find out what a spectrum really is (a profile showing the frequency content of the signal). Try recording low pitched speaking/singing vs high pitched, clipped vs slurred speach etc. The spectra should look different. Indeed, spectra play a key role in voice recognition systems.