Experiment

advertisement

Simple Spectrum Analysis

Paul J. Litke

Mechanical Engineering

Purdue University

Instructor’s Portion

Summary

In this lab, students will gain experience decomposing and reconstructing periodic signals. Periodic signals can be represented using a summation of sine waves of differing phases and amplitudes. This summation is better known as a Fourier sine series. Thus, a signal can be analyzed to find is power spectrum and recreated using a Fourier sine series. Students will generate two simple periodic signals and use LabVIEW to analyze them for their power spectrum. They will then build their own VI to recreate the signals using a series of sine waves. Another objective of this lab is to provide hands-on experience with system measurement and data acquisition that allows the students to develop necessary skills and background using industry standard software and hardware.

Uses

This experiment has applications in mechanical and electrical engineering.

It also incorporates some important mathematical concepts used in engineering. This experiment analyzes and recreates some known input signals. Later in the semester, students are asked to choose a short project that utilizes some of what they have learned in the course. One of those projects involves the decomposition and analysis of sounds, making this lab directly applicable.

Equipment List

 Computer (Dell XPS T550, www.dell.com

) with the LabVIEW software installed. (LabVIEW 6 or later)

 PCI-MIO-16XE-10 Data Acquisition Card (National Instruments, www.ni.com

)

Submitting an Experiment 1

 Shielded Data Acquisition Cable (National Instruments, www.ni.com

)

 Oscilloscope (Tektronix 2225 50MHz Oscilloscope), shown in

Figure 1

Figure 1: Oscilloscope

 Function Generator (Tektronix TM504), shown in Figure 2

Figure 2: Tektronix TM504 Function Generator

 BNC-2120 Shielded BNC Connector Block (National Instruments, www.ni.com

), shown in Figure 3

Submitting an Experiment

Figure 3: BNC-2120 Shielded BNC Connector Block

 BNC-to-BNC cables for connecting the function generator to the BNC

2120

2

 Copy of “Fourier.vi,” shell of VI to be written to recreate a waveform from the fourier sine components, shown in Figure 4

Figure 4: Fourier.vi Front Panel

 Copies of “BigSum.vi” and “Scope.vi” for use in “Fourier.vi”

 Copy of “Simple Spectrum Analyzer.vi,” a VI that decomposes a given waveform, shown in Figure 5

Setup

Figure 5: Simple Spectrum Analyzer.vi Front Panel

The laboratory is setup with several sets of work areas consisting of a computer workstation and the appropriate equipment depending on the specific lab assigned. The students will work in 2-3 person teams at each station to collect the required data and analyze it. Figure 6 shows the workstation setup for this lab.

LabVIEW and the PCI-MIO-16XE-10 Data Acquisition Card need to be installed in the PC prior to lab.

Submitting an Experiment 3

The BNC-2120 Shielded BNC Connector Block needs to be connected to the PCI-MIO-16XE-10 Data Acquisition Card with the Shielded Data

Acquisition Cable.

The four VIs need to be saved on the workstation PC and be accessible from LabVIEW

References

Figure 6: Lab Workstation Setup

 King, Galen B., 1998, ME365: Systems and Measurements Course

Notes , the course notes distributed by Mechanical Engineering at

Purdue University, West Lafayette for Spring Semester, 2002.

Submitting an Experiment 4

Student’s Portion

Introduction

In the Frequency Analysis lab, you will use LabVIEW to analyze an incoming waveform. You will then write your own VI that will reconstruct the waveform. The purpose of this lab is to reinforce your knowledge of Fourier series analysis and to improve your LabVIEW programming skills.

Objective

After completing this lab, you should be able to:

1.)

Find the Fourier coefficients for a periodic signal

2.) Express a periodic signal in its Fourier series form and understand its usefulness

3.)

Reconstruct a periodic signal using a combination of sinusoids.

Theory

This laboratory experiment centers on using a Fourier series to breakdown and represent a periodic signal. As you learned in class, the principle of a

Fourier sine series states that any periodic signal can be broken down into a series of sine waves of differing amplitudes and frequencies. Equation 1 shows the formulation of a periodic function, y(t), in terms of a Fourier sine series. The superposition of the individual components will reproduce the original signal. You should recognize Equation 1 from the prelab.

M

2 o  n

1

M n sin

2

 nt

  n

T

(1)

Where:

M n

is the amplitude n is the frequency multiplier

 n

is the phase shift

T is the period (1/f

0

, where f

0

is the fundamental frequency)

Pre-Lab Preparation

 Complete the prelab

Submitting an Experiment 1

Workstation Details

At your lab work station, you will find the following items needed to complete the lab:

 Dell Dimension XPS T550 Computer, equiped with the following:

 PCI-MIO-16XE-10 Data Acquisition Card

 LabVIEW 6 or later

 D:\userVI folder containing the following files:

 Simple Spectrum Analyzer.vi

 Fourier.vi

 Bigsum.vi

 Scope.vi

Tektronix 2225 50MHz Oscilloscope, shown in Figure 1

Figure 1: Tektronix 2225 50MHz Oscilloscope

 Tektronix TM504 Function Generator

BNC-2120 Shielded BNC Connector Block, shown in Figure 2

Submitting an Experiment

Figure 2: BNC-2120 Shielded BNC Connector Block

 Shielded Data Acquisition Cable

 BNC-to-BNC cables

2

Lab Procedure

This experiment is broken into two sections: Simple Spectrum Analysis and reconstruction of a periodic signal using LabVIEW.

1.

Simple Spectrum Analysis a.

In the first part of the lab, you will use Simple Spectrum

Analyzer.vi, shown in Figure 3, to analyze some periodic signals to

find their Fourier components. The periodic signals you will be analyzing and reconstructing in Part 2 will be the square and sawtooth waves from the prelab. Launch LabVIEW and open

Simple Spectrum Analyzer.vi (D:\userVI\Simple Spectrum

Analyzer.vi).

Submitting an Experiment

Figure 3: Simple Spectrum Analyzer.vi Front Panel for an Example Square Wave

Simple Spectrum Analyzer.vi acquires and analyzes a waveform input by breaking the signal up into its individual frequency components and displaying their magnitudes. Simple Spectrum

Analyzer.vi allows the user to control the following operating parameters:

 Device – This determines which A/D board is to be used.

 Channel – The A/D channel being used as the input channel for the waveform

 Number of Samples – Total number of points used in the

Fourier analysis. For quickest results, this should be a power of two.

 Sample Rate – Frequency at which to sample the data. Recall that the VI needs to be set at a sample rate of at least twice the number of samples to avoid aliasing.

 Window – Used to force periodicity on experimental data.

“None” and “Hanning” are most commonly used.

 Display Unit – Select the Amplitude units for the spectral plot.

 Log/Linear – Allows the axes to be toggled between logarithmic and linear.

3

 Data Logging – ON writes data to a file, OFF does not

 Run Mode – Toggles between collecting a single data set and continuous data logging. b.

Set the function generator to generate the square wave, found in

Part 2-h and in the prelab, using the oscilloscope to view the

waveform and verify that it is correct. Figure 4 shows the example

square wave analyzed in Figure 3.

Figure 4: Oscilloscope View of Sample Square Wave c.

Play with the VI settings to gain a familiarity with its operation.

Analyze the incoming waveform. d.

Once you have analyzed the square wave, set the function generator to produce the sawtooth wave, also from Part 2-h and the prelab, and analyze it as well.

2.

Building a VI to reconstruct a Periodic Signal a.

In the second part of the lab, you will build your own VI to generate a periodic waveform. This VI, named Fourier.vi, is

shown in Figure 5.

Submitting an Experiment

Figure 5: Fourier.vi Front Panel for an Example Square Wave

4

Submitting an Experiment

Fourier.vi generates a periodic waveform from six components of a

Fourier sine series. The inputs on this VI are amplitude, phase and a frequency multiplier, which correspond to M n

,  n

, and n in

Equation 1, respectively. Equation 2 shows the periodic function, y(t), which is generated by Fourier.vi. This continuously generated voltage signal is routed to the D/A output channel 0 of the data acquisition board. This signal is then viewed with an oscilloscope and analyzed with Simple Spectrum Analyzer.vi to verify that the

VI is working properly. Figure 5 shows the generation of the

Fourier representation of the example square wave from Part 1 using the first six non-zero terms.

 m

2

0

 m

1

 m

3 sin

2

1

  f

0 sin

2

1

  f

0

 p

3

 p

1

  

   m

2

  

   m

4 sin

2

1 sin

2

1

  t f

0

  t f

0

 p

4

 p

2

 

 

 

  

   m

5 sin

2

1

  f

0

 p

5

 

 

 

(2) b.

Open Fourier.vi (D:\userVI\Fourier.vi) in LabVIEW. c.

You will find that the VI is a skeleton of what the final VI will be once you are done. Before you do any wiring, you should be comfortable with what the inputs are. Each row of amplitude, phase, and frequency multiplier will provide information for the generation of one sinusoid. The inputs of fundamental frequency and sampling frequency are used several times. For example, they will be used in the generation of each sinusoid. Locate each of these inputs in the Wiring Diagram and make an effort to keep them organized. d.

As the Fourier series is a collection of sinusoids, you will need a method of sine wave generation. To do this, we will use Sine

Patterm.vi, an existing VI in the LabVIEW VI library (LabVIEW

6/vi.lib/analysis/1siggen.lib/Sine Pattern.vi). Its wiring icon is

shown in Figure 6.

npts inputs: amplitude phase frequency multiplier output array

Figure 6: Sine Pattern.vi Wiring Icon

This VI has four inputs:

 NPTS, the number of points to be generated (sampling frequency / fundamental frequency, f s

/f

0

in Figure 6)

 Amplitude (m i

in Figure 6)

5

Submitting an Experiment

 Phase (in degrees, p i

in Figure 6)

 Fundamental frequency multiplier (n i

in Figure 6)

When n=1, the Sine Pattern.vi will generate the fundamental sinusoidal component of the Fourier series. Thus, this component’s period, T

0

, is equal to the reciprocal of the fundamental frequency, 1/ f

0

. When n=2, you will generate a sinusoidal component that goes through two of full oscillations in

T

0

seconds. Fourier.vi uses six components, and one of those

terms, the n=0 term in Figure 5, can be used as a DC shift term. A

DC shift by the amplitude input m0 is created by setting the fundamental multiplier, n0, to zero, and then setting the phase, p0, equal to 90°, thus making the sine term for the 0 th input equal to 1.

The Sine Pattern.vi outputs the generated waveform, and although it is not necessary, it is easiest to use a separate Sine Pattern.vi for each of the six input sets e.

Once all the appropriate sinusoids are generated, they must be summed together. For this task, you will use BigSum.vi

(D:\userVI\BigSum.vi) whose wiring icon is shown in Figure 7.

array inputs output array

Figure 7: BigSum.vi

This VI replaces multiple summing blocks. It takes up to six arrays as inputs and sums them term by term to generate one array as its output. This simplifies the wiring in the Fourier.vi Wiring

Diagram. f.

The summed function is then sent to the Front Panel’s Time

History plot, but first it must be bundled for the Time History plot input. This is accomplished with Scope.vi, whose wiring icon is

shown in Figure 8.

inputs:

sampling freq fundamental freq array loop counter "i" output bundle

Figure 8: Scope.vi

Scope.vi provides two major services. It creates the appropriate time axis for the Time History on the Front Panel, and it

6

automatically sends the generated waveform to the D/A port

(channel 0) to be viewed on the oscilloscope. Wire each sinusoid into Scope.vi, along with the other required inputs. Finally, wire the bundled output to the Front Panel’s Time History plot. g.

You will need to incorporate a while loop into the VI to create a continuous signal from a waveform of finite length. This loop requires that you add an index counter and a logical constant, set to true so that the loop will run continuously. Looping the code like this allows you to observe the contribution of each sinusoidal component as you enter it into the Front Panel. The final wiring diagram of your completed VI should look like that shown in

Figure 9.

Submitting an Experiment

Figure 9: Fourier.vi Wiring Diagram h.

Now you will use your new VI to generate the following signals, which are also the waveforms from the prelab.

1. Square Wave: The ratios of the coefficients for a square wave with odd symmetry will have only odd number terms. Enter your coefficients and generate the wave. Amplitude of 2 volts, a period of 2  seconds, and x

2.0, x

 

 

2.0

2. Sawtooth Wave: The ratios of the coefficients of an odd symmetry sawtooth wave will have both even and odd number terms. Enter your coefficients and generate the wave.

Amplitude of 1 volt, a period of 2  seconds, and x

  

0, x 0 >0

7

Lab Report

Data Sheet

References

i.

Display the generated signal on your oscilloscope and measure it with Simple Spectrum Analyzer.vi. Use the continuous run mode on the Simple Spectrum Analyzer.vi in order to see how the various waves are formed as individual sinusoids are added one by one.

Complete the Postlab exercise for submission during the next laboratory session.

Please print out a copy of the following for submission to your TA at the end of lab:

 Printouts of the Simple Spectrum Analyzer.vi Front Panel for the analysis of the square and sawtooth waves you generated using the function generator in Part 1.

 Print out of the wiring diagram for the complete Fourier.vi

 Printouts of the Fourier.vi front panels showing the generation of the square wave and sawtooth wave.

 Printouts of the Simple Spectrum Analyzer.vi Front Panel for the analysis of the square and sawtooth waves you generated using

Fourier.vi in Part 2.

 King, Galen B., 1998, ME365: Systems and Measurements Course

Notes , the course notes distributed by Mechanical Engineering at

Purdue University, West Lafayette for Spring Semester, 2002.

Submitting an Experiment 8

Prelab

GENERATION OF PERIODIC SIGNALS USING SUMS OF SINUSOIDS

During the course of this laboratory you will be generating different periodic signals, using the data acquisition cards in the laboratory PC’s. In particular, you will be generating a square wave and a sawtooth wave, each with a specific amplitude and fundamental frequency. To accomplish this task, you will be using a new VI that allows you to specify sinusoidal signals in terms of both amplitude and phase. As you have learned in class, it is possible to generate complex periodic signals by summing a series of simple sine and cosine signals.

To prepare for the laboratory, perform the following exercises.

1.

A common representation of the Fourier Series for a signal is:

A

2

0

 k

1

A k

 sin

 k

 

B k

 cos

 k

 t

The above expression may be condensed into the sine-only form:

  

M

2

0

 k

1

M k

 sin

2

T

  k 

Derive the coefficients

M

0

,

M k

,

T

, and  k

for the sine-only form, in terms of the coefficients

A

0

,

A k

, and

B k

. Show all steps in the derivations

2.

Sketch the following waveforms. For each, indicate the signal period and amplitude. a.

Square wave with amplitude of 2 volts, a period of 2π seconds, and the characteristics: x 0

 

2.0, x

 

 

2.0

b.

Sawtooth wave with an amplitude of 1 volt, a period of 2π seconds and the characteristics: x 0

  

(Do no confuse this with a triangle wave.)

3.

Calculate the first six non-zero Fourier series coefficients (

A k

and

B k

) for the waveforms in

Problem 2.

4.

Take the

A k

and

B k

coefficients of Problem 3 and convert them to the

M k

and  k coefficients for the sine-only form of the Fourier series. You will be using these values in the laboratory.

Submitting an Experiment 9

Postlab

MEMORANDUM

To: Students

From: Jack O. Lantern

Re: Calculation of Fourier Coefficients

Date: October 30

______________________________________________________________________________

I am doing some tests on a communications network and need to output a specific signal to the system during the tests. The only equipment that I have to output the signal is a number of function generators and a 12-volt battery with a variable voltage divider. The signal that I need to provide looks like the following:

I understand that you have some experience in generating sets of Fourier coefficients, given a certain waveform. Please provide me with the first twelve Fourier coefficients for the signal shown above, so that I can use my function generators to produce a fair approximation of the signal. Also, please provide plots of the signal that will be produced if I use the Fourier coefficients that you provide.

Submitting an Experiment 10

Download