DOC PREVIEW
PSU EE 200 - Lab_7_EE200_f13 auto-indexing, Shift register and feedback node

This preview shows page 1-2-3-25-26-27-28-50-51-52 out of 52 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 52 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 52 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 52 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 52 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 52 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 52 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 52 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 52 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 52 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 52 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 52 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ColorGrayscaleEE 200 Fall 2013Lab 7.EE 200Design ToolsLaboratory 7Professor Jeffrey SchianoDepartment of Electrical Engineering1EE 200 Fall 2013Lab 7.Laboratory 7 Topics• LabVIEW Programming– Auto-indexing inputs and outputs– Iterative data transfer– Feedback nodes2EE 200 Fall 2013Lab 7.Arrays – Auto-indexing • By wiring an array to or from a For Loop or While Loop, you can link each iteration of the loop to an element in that array by enabling auto-indexing on tunnel• Auto indexing is enabled by default on For Loops, but disabled on While Loops• The tunnel changes from a solid square to the image shown above to indicate auto-indexing 3EE 200 Fall 2013Lab 7.Arrays – Auto-indexing Input• If the iteration count terminal is unwired, the For Loop executes a number of times equal to the number of elements in the array 4EE 200 Fall 2013Lab 7.Arrays – Auto-indexing Input• If the iteration count terminal is wired and arrays of different sizes are wired to auto-indexed tunnels, the actual number of iterations becomes the smallest of the choices• In this example, the loop iterates five times5EE 200 Fall 2013Lab 7.Arrays – Auto-indexing Output• When you auto-index an array output tunnel, the output array receives a new element from every iteration of the loop• Auto-indexed output arrays are always equal in size to the number of iterations6EE 200 Fall 2013Lab 7.Arrays – Creating 2D Arrays• Nest two For Loops to create a 2D array (Matrix)7EE 200 Fall 2013Lab 7.Exercise 1• Use a While Loop and auto-indexing to create a row of six random numbers between 0 and 10• Arrange the Front Panel as shown below8EE 200 Fall 2013Lab 7.Exercise 2• Use two nested For Loops and auto-indexing to create a 4 by 6 matrix of random numbers ranging between -1 and 1• Arrange the Front Panel as shown below9EE 200 Fall 2013Lab 7.Exercise 2• Show only four significant digits for each number– Right click any element– Select Display Format–Set Digits to 4 and Precision Type to Significant digits10EE 200 Fall 2013Lab 7.Iterative Data Transfer• When programming with loops, you often need to know the values of data from previous iterations of the loop• Shift registers transfer values from one loop iteration to the next11EE 200 Fall 2013Lab 7.Iterative Data Transfer12Iteration input output01 (initial value)31 3 (last output)5• The indicator Output updates only after the For Loop completes its last iterationEE 200 Fall 2013Lab 7.Iterative Data Transfer –Adding Shift Registers• Right-click the border and select Add Shift Registerfrom the shortcut menu• Right shift register stores data on completion of an iteration• Left shift register provides stored data at beginning of the next iteration13EE 200 Fall 2013Lab 7.Exercise 3• Code the block diagram• Execute the code twice using the run button • What is the output after each execution?• Delete the initial constant 1• Execute the code twice using the run button • What is the output after each execution?14EE 200 Fall 2013Lab 7.Iterative Data Transfer – Initializing15Block Diagram 1st run 2nd runInitializedShiftRegisterOutput = 5 Output = 5Output = 4 Output = 8Not InitializedShiftRegisterEE 200 Fall 2013Lab 7.Exercise 4• Using a For Loop and shift register, write a VI that determines the factorial of an integer NBy convention, the value of 0! = 1• Restrict the input control to accept integers N ≥ 0• Terminate the program execution using a While Loop• Arrange the Front Panel as shown below16EE 200 Fall 2013Lab 7.Exercise 4• How does the following solution determine that 0! is 1?• When N = 0 the For loop does not execute, and the initial value at the shift register input is passed through the output shift register17EE 200 Fall 2013Lab 7.Iterative Data Transfer –Stacked Shift Registers• Stacked shift registers remember values from multiple previous iterations and carry those values to the next iterations • Right-click the left shift register and select Add Element from the shortcut menu18EE 200 Fall 2013Lab 7.Exercise 5• What output does the following block diagram generate?• Verify through execution19EE 200 Fall 2013Lab 7.Iterative Data Transfer –Feedback Nodes• Operates similarly to shift registers in loops• Used in programming FPGAs with LabVIEW• Stores data when the loop completes an iteration and then sends the stored data to the next loop iteration20InitializerterminalEE 200 Fall 2013Lab 7.Initializer Terminal• Sets the initial value for the first loop iteration• Place inside the loop at the bottom of the feedback node • Or outside on the boundary of the loop structure21EE 200 Fall 2013Lab 7.Placing the Initializer Terminal22right click onfeedback nodeEE 200 Fall 2013Lab 7.Equivalent Loop Structures23EE 200 Fall 2013Lab 7.Equivalent Loop Structures24EE 200 Fall 2013Lab 7.Exercise 6• Do these VIs yield the same output when N > 0?• Do these VIs yield the same output when N = 0?25EE 200 Fall 2013Lab 7.Exercise 7• Using a For Loop and a feedback node, write a VI that determines the factorial of an integer N• Restrict the input control to accept integers N ≥ 0• Use a Case structure to enforce 0! = 1• Terminate the program execution using a While Loop• Arrange the Front Panel as shown below26EE 200 Fall 2013Lab 7.EE 200Design ToolsLaboratory 7Professor Jeffrey SchianoDepartment of Electrical Engineering1EE 200 Fall 2013Lab 7.Laboratory 7 Topics• LabVIEW Programming– Auto-indexing inputs and outputs– Iterative data transfer– Feedback nodes2EE 200 Fall 2013Lab 7.Arrays – Auto-indexing • By wiring an array to or from a For Loop or While Loop, you can link each iteration of the loop to an element in that array by enabling auto-indexing on tunnel• Auto indexing is enabled by default on For Loops, but disabled on While Loops• The tunnel changes from a solid square to the image shown above to indicate auto-indexing 3EE 200 Fall 2013Lab 7.Arrays – Auto-indexing Input• If the iteration count terminal is unwired, the For Loop executes a number of times equal to the number of elements in the array 4EE 200 Fall 2013Lab 7.Arrays – Auto-indexing Input• If the iteration count terminal is wired and arrays of different sizes are wired to auto-indexed tunnels, the actual number of iterations becomes the smallest of the choices• In this example, the loop iterates five times5EE 200 Fall 2013Lab 7.Arrays – Auto-indexing Output• When


View Full Document

PSU EE 200 - Lab_7_EE200_f13 auto-indexing, Shift register and feedback node

Download Lab_7_EE200_f13 auto-indexing, Shift register and feedback node
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_7_EE200_f13 auto-indexing, Shift register and feedback node 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_7_EE200_f13 auto-indexing, Shift register and feedback node 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?