# Experimental Measurements And Instrumentation Laboratory Biology Essay

Published:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

In this experiment, the sampling frequency used to measure and wave form of an analog signal are varied to examine how this affects the validity of acquired data. The goal was to determine the sampling frequencies needed to provide accurate reconstruction of amplitude and frequency and define techniques required for proper data acquisition. Experimental data is the basis of design decisions and used to validate theories; thus, there is a high cost to acquiring poor data. To avoid this, the sampling frequency is can be set orders of magnitude higher than the analog frequency. However, high sampling frequencies require more expensive equipment and are not always feasible. Thus, it is beneficial to understand how sampling frequency affects results so it can be an appropriate frequency can be chosen and inaccurate data can be recognized when it occurs. An analog sine wave with constant frequency and amplitude was digitized using sampling frequencies that were , 2, and 100 times the analog frequency. The lower two both produced significantly non-constant amplitudes with secondary harmonic waveforms. A square wave of the same frequency as the sine wave was used to determine amplitude uncertainty in the system used to take measurements.

1. NOMENCLATURE

= Sampling frequency

= Analog frequency

= Maximum analog frequency

= Nyquist frequency

= Time when at the previous amplitude

= Time when at the new amplitude

N = Number of samples taken

2. INTRODUCTION

The objective of this experiment is to use LabVIEW for data acquisition and to test the effects of sampling frequency in accurately reproducing an analog. Some secondary areas of investigation are the Nyquist frequency, frequency aliasing, amplitude accuracy, and uncertainty analysis. Being able to accurately attain experimental results is of paramount importance as they are used in a plethora of ways, such as a deciding factor in designs, to validate a theory, or to monitor the safe operation of gas turbines, where inaccurate data can cost companies millions of dollars.

The sampling theorem and Nyquist frequency are two sources used to determine the proper amount of samples to be taken and the sampling interval used. If the sample frequency,, is less than twice the analog frequency, an alias frequency is will be measured rather than the true analog frequency. This phenomenon was discussed by Texas Instruments in its "An Introduction to the Sampling Theorem" paper in the National Semiconductor. Texas Instruments did a mathematical computation to prove the sampling theorem using the Fourier transform of a signal function. (1) In "Theory and Design for Mechanical Measurements, Example 7.2 describes the sampling of three analog frequencies 25Hz, 75Hz, and 125 Hz with a sampling frequency of 100Hz. The measured frequencies of the three signals were all 25Hz, which is explained by the alias frequencies created by too low a sampling frequency. (2)

The experiment was set up and executed according to the standards in the lab manual. Four separate sampling tests were conducted. The first three used a 120Hz sine wave as the analog frequency and compared the results from using a 96Hz, 240Hz, and 12000Hz sampling frequencies. The fourth test included an analog a square wave, also 120Hz, and a sampling rate of 12000Hz. The results from this test were used to compare response time and to calculate amplitude uncertainty. All tests were run using a LabVIEW program to control the sampling frequency and graph the measurements taken.

## 3. THEORY

There are several key theories that are examined and tested during this experiment. They include the sampling theory, aliasing of frequencies, the Nyquist Frequency, and the concept of amplitude accuracy. The first of these, the theory of sampling states that the commonly occurring analog signals found in nature can be represented by a discrete number of samples transforming the continuous analog into an easy to interpret digital signal.(2) The following four theories explain how this process is done and the requirements necessary for proper sampling of analogs.

The sample frequency is the number of times an analog signal is measured per second; the Sampling Theorem describes the minimum value of the sample frequency in order to properly describe its frequency and general behavior with a discrete digital signal. Improper sampling frequency can cause the signal to be misrepresented as shown in Figure 1.

C:\Documents and Settings\Steveo\My Documents\Engineering\BCS\figliola_0471445932\jpgs\ch07\07_02.jpg

Figure : Demonstrates how poor sampling can cause the wrong signal to be seen. It shows the under-sampled signal overlapping the actual analog frequency. (2)

To properly prevent this occurrence the correct sample frequency must be used with the original analog signal. The Sampling Theory explains that in order to fully evaluate any signal the sampling frequency (denoted as fs) must be at least two times greater than the analyzed signal's maximum frequency. This relationship is shown in the equation below, where fmax is the maximum frequency of the analog signal.

fs>2fmax (1)

When the Sampling Theorem is not satisfied, several phenomena can occur including the second theory examined within this experiment, frequency aliasing. The frequency aliasing occurs when a sample is taken for an analog signal that is less than 2fmax and causes an incorrect frequency to be measured, known as the alias frequency. The alias frequency is lower than analog signal that is measured; see Figure 2 for an example of an aliased frequency overlaid the true analog frequency. (3).

Figure : Illustrates a falsely constructed signal overlapping the original higher frequency signal. (3)

The Nyquist Frequency, the third theory tested in this lab, is the largest frequency that can be described by the given sample rate and is found using the equation below.

(2)

C:\Documents and Settings\Steveo\My Documents\Engineering\BCS\figliola_0471445932\jpgs\ch07\07_03.jpg

Figure : Frequency Folding Diagram (2)

Any frequencies in the original analog signal that occur above this frequency result in alias frequencies; the relation between an alias frequency and the original analog frequency can be found using the folding diagram in Figure 3.

Amplitude accuracy is the last concept explored in this experiment; it concerns finding the true amplitude of the signal. In doing that, the uncertainty of the experiment must be found through uncertainty analysis. The uncertainty analysis is the process of identifying, quantifying, and combining the errors for each device used within in the experiment.(2) To find the uncertainty of the experiment defined by the following equation several other pieces of statistical data must be taken into account.

(3)

(4)

Most of the sampling done throughout the experiment is done using sine waves, however, when examining amplitude accuracy the square wave is analyzed. The ideal square wave is defined as having two amplitudes with instantaneous jumps between the two. (4) However, in non-ideal setting, as all experiments are, this rise does not occur instantaneously. The time in between the rise is known as the rise time and is described by equation 5. (5)

(5)

## 4. EXPERIMENTAL APPARATUS AND PROCEDURE

## 4.1 Experimental Apparatus

The experiment was conducted using the following pieces of equipment: computer, LabVIEW Software, function generator, data acquisition card, connector box, short wires and a voltmeter. (6) These instruments are all used to acquire the data needed for this experiment, and their individual specifications are presented below.

The computer used in this experiment was a Hewlett-Packard Desktop PC, model dc7900 Convertible Minitower. The computer ran Windows Vista Basic and used an IntelÂ® Coreâ„¢ 2 Duo CPU. The model number was E8600 with 3.33 GHz CPU and 3.49GB of RAM.

The function generator used in this experiment was manufactured by BK PRECISION, model number 4003A. The function generator has a 4 MHZ Sweep Function Generator with 60 Hz Auto-range counter. The range for this particular device is 0.5 Hz to 4MHz and has a maximum amplitude of 20V peak to peak. Other elements of this devices output include: DC offset +10V (pull ADJ), a distortion <1%, (1 Hz to 100KHz), a Rise/Fall time <60ns, and has an output impedance of 1Kâ„¦ + 2%.

The connector box is made by National Instruments, model SCC - 68, and comes with 4SCC Signal Conditioning Slots for DAQ devices. This device has a maximum sample rate of 250kS/s for a single channel and a timing resolution of 50ns. It can read an input range of Â±10V.

The data acquisition card, DAQ, is also made by National Instruments, model class NI 622x. For systematic error calculations the residual gain error is marked as 75 (ppm of reading). The temperature coefficient of the gain is 25 (ppm/ËšC) for temperature increase over 25ËšC and the INL Error is 76 (ppm of Range). A operating temperate of 20 ËšC is assumed for uncertainty analysis. (7)

The voltmeter used to conduct this experiment is Extech 420 digital Multimeter manufactured by Extech Instruments. It can handle a maximum input voltage of 1000V DC and has a range of 200Vrms on 400mV. This particular device also features a 4000 count LCD display. (8)

## 4.2 Procedure:

Figure 4: Inside cover of connector box

The first step is to turn on the computer and open LabVIEW. The next step is removing the cover from the connector box and connecting wires to the appropriate ports. To accomplish that, the screws holding the cover down are untightened and the cover is lifted up and off of the box. Then, the ports labeled 57 and 23 are loosened using a small screw driver. These ports correspond to AI7, analog input 7, and AI15, ground.(9) The locations of these ports are indicated on the inside cover, as seen in Figure 4. Finally, a short wire is inserted into each of the two ports.

The third step is checking the offset of the waveform generator is set to zero using the voltmeter described above. Then, the function generator is hooked up to the connector box. This is done by attaching the leads from the function generator to the short wires; the red lead, positive, should go to the wire attached to port 57; the black lead, negative, should go the wire attached to port 23. (6) The setup is shown in Figure 5.

Figure 5 - Shows experimental setup.

Next, the function generator is set to generate an analog sine wave signal with frequency 120Hz and amplitude near 4 volts. This is done by turning on the function generator, pushing the button for sine wave, and using the dials for amplitude and frequency to set them as close to the desired values as possible. The offset is reduced by pressing the range button and dialing with the offset knob.

The different wave forms are measured with LabVIEW software using the steps below to create a program, take samples, and display results.

How to create the program to measure the waveforms:

Open LabVIEW and start a blank VP.

In the block diagram section of LabVIEW make sure the funtion panel is open. If not click view and select funtions palette.

In the block diagram section selct the DAQ from the function panel. Drag the DAQ to any location on the block diagram.

A window will open for the DAQ. When is does, select voltage and set the range between -10V and 10V, then click ok.

Create the controls for number of samples, rate (sample rate), and time by clicking the coresponding nodes on the DAQ item near the text, and selecting create followed by control.

Generate a graph to plot the signal by clicking the data node and then selecting create graph indicator.

Connect the waveform generator to the graph.

Add a numeric indicator for the amplitude by going to the functions palette, selecting the express category, clicking signal analysis, and dragging the amplitude and level measurment item onto the block diagram. When a window appears, maximum and mininum peak should be selected.

Add the ability to save data to a file by going back to the express section again, selecting output then write measurment file, and dragging it onto the block diagram.When a window appears, ask user to choose file should be chosen.

Create a text control so that the file name to save in can be edited from the front screen. This is done by clicking the node next to the file name text and selecting create, then control. (6)

The block diagram used to create the program is shown in Figure 6.

Figure 6 - Shows the block program needed to run the experiment.

How to sample the wave forms:

Use the created program to sample a 120 Hz sine wave at 96 samples/s (fs = 96 Hz). Save the data to a file to work with later. Ensure at least two full waveforms are sampled.

Use the program to sample a 120 Hz sine wave at 240 samples/s (fs = 240 Hz). Save the data to a file to work with later. Ensure at least two full waveforms are sampled.

Use the program to sample a 120 Hz sine wave at 12000 samples/s (fs = 1200 Hz). Save the data to a file to work with later. Ensure at least two full waveforms are sampled.

Use the program to sample a 120 Hz square wave at 1200 samples/s (fs = 1200 Hz). Save the data to a file to work with later. Ensure at least two full waveforms are sampled.(6)

## 5. RESULTS AND DISCUSSION

## 5.1 Results

For the sinewave, the true analog frequency was 120.04Hz according to the readout on the signal generator and the amplitude was about 3.85 volts as measured by the voltmeter. For the square wave, the true analog frequency was 120.07Hz and the amplitude was 5.0 volts. The amplitude and frequency are different for the different waveforms because the data for the square wave was taken at a slightly different time. Neither analog frequency is exactly 120Hz, but both are less 0.1% off from the expected value. This was deemed sufficient because the frequencies were adjusted with a dial which is inherently less precise.

The measured frequencies and amplitudes were measured for each of the four tests and recorded in Table 1.

Table : Specifics of Sampling Scenarios

N

Amplitude

Mean

Phase

120Hz Sine

96Hz

24000

24.0414

2.6624*

.0189

96.30

120Hz Sine

240Hz

15000

119.95

3.54294

.0203

-158.82

120Hz Sine

1200Hz

60000

120.042

3.84744

.0175

-120.04

120Hz Square

1200Hz

12000

120.072

5.02173

-.0423

-62.5941

The first test measured an analog sine wave with frequency 120Hz with a sampling rate of 96Hz. It should be noted the analog frequency is greater than both the Nyquist frequency of the sampling rate and the sampling rate itself. The results were graphed over two intervals, micro and macro picture, Figure 7.

Figure a:120 Hz Sine wave sampled at 96Hz

Figure 7b: 120Hz Sine wave sampled at 96Hz

Over the micro interval, Figure 7a, the points at which the samples are taken can be seen to shift. This is a result of the sampling rate being too small for the frequency being measured.

Figure : 120Hz Sine wave sampled at 96Hz over 0-150.0m

In Figure 8, the time interval is adjusted so that only three periods of the wave are shown. From the three waves, it would seem the amplitude is constant at 3.7 volt. However, the measured amplitude provided LabVIEW is 2.6624 volt. The probable cause of this is the mixed harmonic shape that can be observed in the macro scale picture in Figure 1b.

In Figure 7b, the time interval in increased from 150 milliseconds to 9.5 seconds. Three separate sine waves are observed. The outermost wave, partially outlined by red points, has sinusoidal amplitude that varies between about 3.8 volt and 2.7 volt. The two inner waves are identical waves that are half a period out of phase. This wave has maximum amplitude of 2.7 volts and minimum amplitude of zero volts. The two identical overlapping wave forms create the appearance of a single wave form when viewed over a long time range, as shown by Figure 9a. It should also be noted these macro waves do not have a constant period as shown by Figure 9b. These irregularities in the waves demonstrate potential errors that occur when the sampling rate it less than the analog frequency. Additionally, it indicates that sampling for too short of a length of time can cause significant errors in predication of the amplitude.

Figure a: 120Hz Sine wave sampled at 96Hz over 0-15s

Figure 9b: 120Hz Sine wave sampled at 96Hz over 0-25s

For the second test the analog frequency remained constant and sampling frequency was increased to 240 Hz. Comparing the sample frequency and analog frequency, it is observed that the sampling frequency is twice the analog frequency. It should be noted, this still does not satisfy the sampling theorem. From Figure 10a, a triangular wave can be observed with sample points taken from maximum and minimum points. This triangular waveform has a measured frequency close to frequency of the analog signal.

Figure 10a: 120Hz Sine wave sampled at 240Hz from 14.9s to 15.1s

Figure 10b: 120Hz Sine wave sampled at 240 Hz from 3s to 23s

While the 240Hz does provide a measured frequency within a reasonable margin of error, it is not as useful in determining the amplitude of the wave. The maximum and minimum sampling leading to the triangular is a result of the ratio of sampling and analog frequencies. The points are taken at indeterminate points on the analog signal; as such, it cannot be concluded that the amplitude of triangular waves is relatable to the amplitude of the analog signal.

Analog signals rarely have perfectly integer frequencies; sampling at the expected lowest possible valid frequency, Nyquist, has potential for significant errors for that reason. As seen in this test, if the analog frequency is even 0.033% larger than expected

The macro waveform depicted in Figure 10b arises from two phenomena. First, while the frequency is close to the analog frequency, they are not exactly equal so the sample point is taken from a slightly different location on the analog wave every time, there are only two points two define each wave therefore there is no check for accuracy. These two factors combine to produce a larger waveform with amplitude varying between 0.0 and 3.8 volts. See Figure 11 for an example of the amplitude decreasing to zero.

Figure : 120Hz Sine wave sampled at 240 Hz from 3.5s to 3.7s

In the third test, the analog frequency remained at 120Hz and the sampling frequency was increased to 12,000Hz. Comparing the sample rate to analog frequency, it is observed that the sampling frequency is 100 times the analog frequency. Figure 12a shows two and a half periods of the measured waveform. The consistency of the amplitude and period of the measured signal are depicted in Figure 12b.

Figure 12a: 120Hz Sine wave sampled at 12000Hz from 0 to 20ms

Figure 12b: 120Hz Sine wave sampled at 12000Hz from 0 to 500ms

From the clearly defined waveform in Figure 12a, it appears that taking one hundred sample points per period of the analog signal is sufficient. From comparing the measured frequency and amplitude in Table 1 with the period and amplitude of the analog signal, it can also be stated that the sampling rate is sufficient for the numerical values.

The results of the first three tests indicate that, as the sampling frequency increases, the accuracy with which the amplitude and frequency are measured also increase. When the sampling frequency is significantly less than twice the analog, only 96 Hz, there are an alias frequency and two minor frequencies creating a complex, non-periodic signal with an overall amplitude that varies by almost 1 volt. This indicates when the sampling rate is less than of the analog frequency, it is impossible to determine an accurate frequency and, if the sample is taken for a short time period, the amplitude cannot be determined with certainty. When the sampling frequency is twice the analog frequency, 240 Hz, the signal becomes clearer and the frequency measured is almost the analog frequency, 119.95 Hz compared to 120.04 Hz. However, there are still secondary frequencies causing overlap and forming the 120Hz sine signal into a irregularly shaped periodic signal with a period of about 10s. When the sampling frequency is one hundred times the analog frequency, the measured signal is extremely clear and accurate with no secondary frequencies. These three tests underscore the benefits of a high ratio of the sampling frequency to the analog frequency.

However, the maximum sampling frequency is limited by the equipment available. The sampling theorem is important because it provides a definitive break point for when a given sampling frequency cannot be used to measure an analog signal. A frequency just under half the sampling frequency is the absolute maximum analog frequency that can be measured. The importance of this criteria is demonstrated by the distortion present in the measurement performed with 240Hz sampling frequency. After this condition is applied, the analog frequency to sampling frequency can be intelligently chosen to maximize clearness of data collected while staying within the possible frequencies for a specific measurement system.

The Nyquist frequency is important primarily for the role it plays in the sampling theorem. It marks the upper limits of analog frequencies that can be accurately measured by a sampling frequency.

The shape of the measured waves depends on the number of sample points taken per wave. The greater the number of sample points per wave, the more the wave resembled its true form, in this case a sine wave. As the number of points per wave decreased, the wave form begin to resemble points connected by straight lines. With only two points per wave, the sinusoidal signal appeared as a triangular wave because there were only two lines per wave.

Figure 13a: 120Hz Square Wave sampled at 12000Hz

Figure 13b: 120Hz Square Wave sampled at 12000Hz

In the fourth test, the analog frequency and sampling frequencies remained constant; the waveform type was switched from a sine wave to a square wave. The sampling ratio, sampling to analog, is still 100:1. Figure 13a shows two periods of the measured waveform. As above, the amplitude and frequency are shown to be constant over time by taking a longer period for sampling, see Figure 13b.

Table : A Sampling of Rise Times

Case

1

0.001416

0.001499

8.30E-05

2

0.022241

0.022324

8.3E-05

3

0.101376

0.101459

8.3E-05

4

0.263728

0.263811

8.3E-05

5

0.384513

0.384596

8.3E-05

6

0.413668

0.413751

8.3E-05

7

0.592763

0.592846

8.3E-05

8

0.680144

0.680227

8.3E-05

9

0.805094

0.805177

8.3E-05

10

0.942539

0.942622

8.3E-05

The rise time for the square waves couldn't be determined closely from the graphs; the micro scale graph didn't include enough samples and the macro scale was too dense. Therefore, the data points were inserted into a spreadsheet and the rise time was calculated using equation 4; where is the time directly before the change in value and is the time after the new magnitude is reached. The rise times sampled all had duration of. Expected given, the period of the sampling frequency is also .

No discrete sampling can perfectly measure an analog signal. The square signal is measured with a sampling frequency one hundred times the analog frequency; however the rise time of the square wave is still not analytically accurate. The discernible rise time of the square wave is only as accurate as the time difference between two sample point, about 0 .0833 milliseconds. The theoretical rise time is zero seconds as square waves are defined as having instantaneous jumps between two plateaus. The true rise time depends on the rate at which the DAQ card can detect changes, 50ns according to the manual. (7)

Table : Statistics and Uncertainty

No. Points

Range

Mean Magnitude

Bias Error

Standard Deviation

Uncertainty

12000

7.90822V

3.943738637V

0.001266997 V

0.034306061 V

0.03432945 V

According to equation 4, determination of the uncertainty requires the standard deviation of data collected and the value of the system, bias, error. Therefore, calculation of the uncertainty in the amplitude of the square wave consisted of two main processes: statistical analysis of data collected and application uncertainty information from equipment. Prior to the statistical analysis, all data points were converted to absolute values of the magnitude. Then, the standard deviation and mean were calculated from these purely positive numbers. The range included positive and negative magnitudes. In this experiment, the DAC card was the major source of systematic error from equipment. (5) This error was determined according to the procedures listed on page four of the DAC user's manual (6). The bias error was relatively small compared to the standard deviation, less than one a hundredth. The probable cause for this discrepancy is the square wave was not centered exactly at zero; from Table 1, it is seen the wave is centered about -.043 volts. This would cause the upper and lower lines of the square wave to not have the same absolute magnitude. Using a selection of only positive values, the standard deviation becomes volts, which agrees with the expected uncertainty.

## 6. CONCLUSIONS

Data acquisition of an analog signal requires collecting discrete points and combining them to approximate the analog waveform, frequency, and amplitude. Some information is lost in the process but distortion and loss of data can be minimized by considering the Sampling Theorem, role of the Nyquist frequency, effects of frequency aliasing, and limitations of the equipment used for sampling. The evaluation of the experiments and comparison to expected analog frequency and ideal conditions of a square wave has led to the following conclusions:

The frequency and amplitude of an analog wave are indeterminate when the sampling frequency and analog frequency do not have a greater than 2:1 ratio.

Signals sampled with less than the required ratio can look normal and correct over short periods of time. To prevent erroneously accepting these measured waveforms, measurements should be considered in macro scale as well on the micro scale.

Waveforms with sudden changes require a high sampling to avoid losing definition as the most sudden change possible to record in a measured wave is the period of the sampling frequency.

Uncertainty analysis of the square wave demonstrated the validity of the uncertainty information provided by the manufacturer.