DOC PREVIEW
PSU EE 200 - Lab_6_EE200_s14

This preview shows page 1-2-3-4-5-6-39-40-41-42-43-79-80-81-82-83-84 out of 84 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 84 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ColorGrayscaleEE 200 Spring 2014Lab 6.EE 200Design ToolsLaboratory 6Professor Jeffrey SchianoDepartment of Electrical Engineering1EE 200 Spring 2014Lab 6.Laboratory 6 Topics• LabVIEW – Programming Structures• While Loop• For Loop• Case Structure– Arrays– Timing– DIO using the myDAQ2EE 200 Spring 2014Lab 6.LabVIEW While Loop3LabVIEW While LoopC Codecodedo {code }while (expression)YesFlowchartNoendconditiontrue?code• Analogous to a Do While loop in C• Code executes at least onceEE 200 Spring 2014Lab 6.While Loops• Iteration Terminal: Returns number of times loop has executed; i = 0 for first iteration (zero indexed)• Conditional Terminal: Defines when the loop stops4EE 200 Spring 2014Lab 6.Terminating VI Execution• Terminating VI execution using the abort execution button is not desirable • Aborting the program does not allow the code to safely shutdown hardware, for example, a machine5EE 200 Spring 2014Lab 6.Preferred VI Termination Method• Use a front panel control to terminate VI execution• A common technique is to wrap the code in a While Loop structure and use the Conditional Terminal to terminate program execution6EE 200 Spring 2014Lab 6.Exercise 1• Terminate Open Add&Subtract(Main).vi using a While Loop7EE 200 Spring 2014Lab 6.LabVIEW For Loop8codeLabVIEW For Loopint i;for (i = 0; i < 100; i++){ code }C CodeFlowchartYesNoi<100?i = 0codeendi = i + 1EE 200 Spring 2014Lab 6.For Loops• Create a For Loop the same way you create a While Loop• If you need to replace an existing While Loop with a For Loop, right-click the border of the While Loop, and select Replace with For Loop from the shortcut menu• The value in the count terminal (an input terminal) indicates how many times to repeat the subdiagram• The iteration terminal provides the current loop iteration count, which ranges from 0 to N - 19EE 200 Spring 2014Lab 6.For Loops – Conditional Terminal• You can add a conditional terminal to configure a For Loop to stop when a Boolean condition or an error occurs10EE 200 Spring 2014Lab 6.For Loops – Conditional Terminal• For Loops configured for a conditional exit have– Red glyph next to the count terminal – Conditional terminal in the lower right corner11CodeLabVIEW For LoopEE 200 Spring 2014Lab 6.For Loop/While Loop Comparison12CodeLabVIEW While LoopCodeLabVIEW For Loop• Executes a set number of times unless a conditional terminal is added• Can execute zero times• Stops executing only if the value at the conditional terminal meets the condition• Must execute at least onceEE 200 Spring 2014Lab 6.For Loops – Numeric Conversion• The number of iterations a For Loop executes must be specified in nonnegative integers• If the number of iterations is a negative integer or zero, the For Loop does not execute• If you wire a double-precision, floating-point numeric value to the count terminal, LabVIEW converts the larger numeric value to a 32-bit signed integer13EE 200 Spring 2014Lab 6.Coercion Dots• Typically, when you wire different representation types to the inputs of a function, the function returns an output in the larger or wider format• LabVIEW chooses the representation that uses more bits• However, the For Loop count terminal always coerces to a 32-bit signed integer14coercion dotEE 200 Spring 2014Lab 6.Numeric Conversion• Avoid coercion for better performance– Choose matching data type– Programmatically convert to the matching data type15EE 200 Spring 2014Lab 6.Exercise 2• Use a For Loop to display an integer count from 0 to 100 million• Include a Conditional Terminal so that the user can halt execution16EE 200 Spring 2014Lab 6.LabVIEW Case Structures• Case Selector Label: Contains the name of the current case and decrement and increment buttons on each side • Selector Terminal: Wire an input value, or selector, to determine which case executes17EE 200 Spring 2014Lab 6.LabVIEW Tunnels• Tunnels transfer data into and out of structures• The tunnel adopts the color of the data type wired to the tunnel18tunnelsEE 200 Spring 2014Lab 6.LabVIEW Case Structures19• Have two or more subdiagrams or cases• Execute and displays only one case at a time• An input value determines which subdiagram to executeEE 200 Spring 2014Lab 6.Boolean Case Structure• A Boolean case structure has only two frames (called subdiagrams) • The value of the Selector Terminal determines which subdiagram executes20EE 200 Spring 2014Lab 6.Exercise 3• Use a LabVIEW Boolean case structure to realize the absolute value of a real-valued input of type double21EE 200 Spring 2014Lab 6.LabVIEW Arrays• An array consists of elements and dimensions– Elements: data that make up the array– Dimension: array length, height, or depth – May have one or more dimensions – As many as (231)–1 elements per dimension, memory permitting• Consider using arrays when working with a collection of similar data and whenperforming repetitive computations22EE 200 Spring 2014Lab 6.Arrays – 1D Array • Index of first element is 0• The first element shown in the array (3.00) is at index 1 and the second element (1.00) is at index 2– The element at index 0 is not shown in this image, because element 1 is selected in the index display• The element selected in the index display always refers to the element shown in the upper left corner of the element display23EE 200 Spring 2014Lab 6.• Stores elements in a grid• Requires a row index and a column index to locate an element, both of which are zero-based• To create a multidimensional array on the front panel, right-click the index display and select Add Dimension from the shortcut menu• You also can resize the index display until you have as many dimensions as you wantArrays – 2D Array 24EE 200 Spring 2014Lab 6.Arrays – Initializing• You can initialize an array, or leave it uninitialized• For initialized arrays, you define the number of elements in each dimension, and the contents of each element• Uninitialized arrays have dimension but no elements25EE 200 Spring 2014Lab 6.Exercise 4• Use an array a 1D array of eight Boolean controls to write to a 1D array of eight Boolean indicators• Use a While Loop structure to control VI termination• Stop Execution when a stop button is pressed, or when the input sequence is 01010101– Use the Equal? Function node and set the Compare Mode to Compare Aggregates26EE 200 Spring 2014Lab 6.Exercise


View Full Document

PSU EE 200 - Lab_6_EE200_s14

Download Lab_6_EE200_s14
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lab_6_EE200_s14 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab_6_EE200_s14 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?