E80 The Next Generation Spring 2009

LabVIEW Programming Assignments

Introduction and Schedule

The LabVIEW programming assignment are to be individual (not team) work. For all sections they are due by 5 PM in the Sakai drop box (one of the few actual uses for Sakai) on the date given below. If any assignment is taking more than 1/2 hour come see me. My solution will be posted by Monday morning after the due date.

File Naming Convention

Your file name should be (Last Name)_(First Initial)_A(Assignment Number)_S(Section Number).(vi or llb). For example, if I were Greg Lake in Section 4 and I was turning in Assignment 3, my file would be named Lake_G_A3_S4.llb.

Grading

Late assignments will not be accepted. The assignments will be graded on a five-point rubric scale:

5  –  Wow
4  –  Good
3  –  Fair
2  –  Poor
1  –  Ouch
0  –  Not Submitted
The LabVIEW Programming Assignment Due Dates
Due Date Number Name
23 JAN 2009 1 Read In Data File
30 JAN 2009 2 Write Out Data File
6 FEB 2009 3 Create Sub-VIs
13 FEB 2009 4 Use a For Loop
20 FEB 2009 5 Use a While Loop and Shift Register
27 FEB 2009 6 Control Execution Timing
6 MAR 2009 7 Frequency Response Function

Assignment 1 – Read In Data File

Create a VI that will open a tab-delimited text file of a matrix of values with four columns and an unspecified number of rows, such as created by Excel, and display the matrix as a 2-D array (or matrix). Separate out the columns as individual 1-D arrays, and plot the first two columns with Column 1 as the x-data and Column 2 as the y-data. Test your VI on this linked file. The result should resemble the following plot. The recommended sub-VIs, structures, and functions are: Read From Spreadsheet File.vi, Index Array, Bundle, XY Graph.

Assignment 2 – Write Out Data File

Starting from either your VI from Assignment 1 or the posted solution VI (it’s recommended to use it as a sub-VI), create a VI to read in a tab-delimited text file of a matrix with four columns, divide the first column by 60 (as in converting from seconds to minutes), take the sine of the second column, the cosine of the third column, and the square of the fourth column. Plot the second, third, and fourth columns as a function of the first. Write out the resulting data to a tab-delimited text file with the columns as columns. Test your VI on this linked file. It should resemble the following plot. The recommended sub-VIs and functions are: ReadInFile.vi (or your equivalent), Divide, Sine, Cosine, Square, Bundle, Build Array, Write To Spreadsheet File.vi, The recommended format string is "%g".

Assignment 3 – Create Sub-VIs

Create four VIs: one that adds two numbers, one that subtracts one number from another, one that multiplies two numbers together, and one that divides one number by another. Each VI must have two input terminals, at least one output terminal, and a unique icon. Use these four VIs in a fifth VI that has two numeric inputs, at least one output, and an enumeration control, that uses a case structure to let the user choose addition, subtraction, multiplication, or division. Save them all in a common .llb library.

Assignment 4 – Use a For Loop

Create a VI that uses a for loop and the random number generator on the Numeric Palette to generate an array of a specified length of uniformly distributed random numbers with a range of [0-1). Calculate the mean, standard deviation and root mean square of the array. Set the default length of the array to 100 samples.


Create another VI that replaces the for loop with the Uniform White Noise.vi on the Signal Generation Palette. Save them both in a common .llb library. Some recommended VIs and functions are: Random Number (0-1), Std Deviation and Variance.vi, RMS.vi

Assignment 5 – Use a While Loop and Shift Register

Create a VI that uses a while loop, a shift register, and the random number generator on the Numeric Palette to generate an array of a specified length of uniformly distributed random numbers with a range of [0-0.2] and from [0.3-1), In other words, the standard range for the random number generator but without any values between 0.2 and 0.3. Calculate the mean, standard deviation and root mean square of the array. Set the default length of the array to 100 samples.


Create another equivalent VI that uses the Uniform White Noise.vi on the Signal Generation Palette to generate an array and then uses a for loop to remove all of the values between 0.2 and 0.3. It is possible to make the first VI generate a list of the exact specified length with a conditional on the stop control on the while loop. Is it possible to guarantee that the array from the second VI is exact length specified? Save them both in a common .llb library. Some recommended VIs, structures, and functions are: Case Structure, Random Number (0-1), Std Deviation and Variance.vi, RMS.vi, Build Array, Greater?, Less?, And, Array Size, Array Subset.

Assignment 6 – Control Execution Timing

Create a VI that runs continuously until a front panel STOP button (not the abort button) is pushed. The VI should accept a two-digit hexidecimal number between 0 and FF inclusive. The VI should wait for 4.5 seconds, and then illuminate an LED for 0.5 seconds that indicates that the answer is about to be displayed, and then display the hexidecimal number as an array of binary LEDs. You can use TimerNoEdit.vi to view the functionality desired. Some recommended VIs, structures, and functions are: Sequence Structure or Flat Sequence Structure, Wait (ms), Number To Boolean Array, Reverse 1D Array, an array indicator with LED elements, a While Loop from the Express Palatte, one or more Local Variables. You can change the Representation and Display Format of your input control by right clicking on it.

Assignment 7 – Frequency Response Function

Create a VI that will generate a Gaussian White Noise Waveform of a given length (default 100,000) at a given sampling rate (default 10kSPS), with a given standard deviation (default 1.0). Filter the waveform with a 3rd-order Chebyshev lowpass filter with a given cutoff frequency (default 100 Hz). Plot the power spectra of the unfiltered and filtered waveforms on a single Waveform Graph with the Power in dB and the frequency on a logarithmic scale. Calculate the Frequency Response Function (FRF) of the filtered (Y) to the unfiltered (X) signal and plot both magnitude and phase with the frequency on a logarithmic scale. Use the View control to plot the magnitude of the FRF in dB, and unwrap the phase and plot it in degrees. For extra credit you can modify the VI so that it generates a specified number of waveforms (default 5) and plots the coherence of the FRF along with the magnitude and phase

Recommended VIs: Gaussian White Noise Waveform.vi, Filter (an Express VI), FFT Power Spectrum.vi, Frequency Response Function (Mag-Phase).vi. None of these VIs is in the Student Version of the software.

Assignment Solutions

Table of Assignment Solutions
Assignment Solution
Assignment 1
Assignment 2
Assignment 3
Assignment 4
Assignment 5
Assignment 6
Assignment 7

 

| ©2007 Harvey Mudd College