首页 > > > labview数组和簇的应用教程.pdf

labview数组和簇的应用教程.pdf

labview数组和簇的应用教程.pdf

上传者: 寒江雪 2014-02-23 评分1 评论0 下载1 收藏10 阅读量285 暂无简介 简介 举报

简介:本文档为《labview数组和簇的应用教程pdf》,可适用于软件工程领域,主题内容包含wwwnicomExercise:ArraysandClustersOverviewThisexercisewillgooverhowtocreat符等。

1/6 www.ni.com Exercise: Arrays and Clusters Overview This exercise will go over how to create arrays and clusters. You will also learn about how to pass data to and from arrays and how to bundle and unbundle clusters. Goal Understand the basic behavior of arrays and clusters in the LabVIEW environment. Description  This exercise consists of a series of tasks in which will walk you through how data is passed to and from arrays. Indexing arrays will be explored in detail. How to bundle data will be explained as well as how to unbundle information from clusters. Arrays Description You are given a VI and asked to enhance it for a variety of purposes. For each part of this exercise, begin with the Array Investigation.vi located at the bottom of this page. The front panel of this VI is shown in the figure below. The next figure shows the block diagram of this VI. This exercise is divided into parts. You are given the scenario for each part first. Refer to the end of this exercise for detailed implementation instructions for each part. Part 1: Iterate, Modify, and Graph Array Modify the Array Investigation VI so that after the array is created, the array is indexed into For Loops where you multiply each element of the array by 100 and coerce each element to the nearest whole number. Graph the resulting 2D array to an intensity graph. Part 2: Simplified Iterate, Modify, and Graph Array Modify the Array Investigation VI or the solution from Part 1 to accomplish the same goals without using the nested For Loops. Part 3: Create Subset Arrays Modify the Array Investigation VI so that the VI creates a new array that contains the contents of the third row, and another new array that contains the contents of the second column. Part 1: Implementation Modify the Array Investigation VI so that after the array is created, the array is indexed into For Loops where you multiply each element of the array by 100 and coerce each element to the nearest whole number. Graph the resulting 2D array on an intensity graph. 1. Open located at the bottom of this page.Array Investigation.vi 2. Save the VI as Array Investigation Part 1.vi. 3. Add an to the front panel of the VI and autoscale the X and Y axes, as shown in the figure below. To autoscale the axes, right-click the intensity graph and select intensity graph X and .ScaleAutoScale X Y ScaleAutoScale Y : Document Type Tutorial : Yes NI Supported : Jul 2, 2008 Publish Date 2/6 www.ni.com 1. Open the block diagram of the VI. In the following steps, you create a block diagram similar to the next figure. 5. Iterate the Array. Add a to the right of the existing code.For Loop Add a second inside the first .For Loop For Loop Wire the terminal to the interior border. This creates an auto-indexed input tunnel on both For Loops.array indicator For Loop 6. Multiply each element of the array by .100 Add a function to the interior .Multiply For Loop Wire the indexed input tunnel to the input of the function.x Multiply Right-click the input and select from the shortcut menu.y CreateConstant Enter in the constant.100 7. Round each element to the nearest whole number. Add a function to the right of the function.Round To Nearest Multiple Wire the output of the function to the input of the function.Multiply Round To Nearest 8. Create a 2D array on the output of the For Loops to recreate the modified array. Wire the output of the function to the outer . This creates an auto-indexed output tunnel on both For Loops. Round To Nearest For Loop 9. Wire the output array to the indicator.Intensity Graph 10. Switch to the front panel. 11. Save the VI. 12. Enter values for Rows and Columns. 13. Run the VI. Part 2: Implementation Modify Part 1 to accomplish the same goals without using the nested For Loops. 1. Open if it is not still open.Array Investigation Part 1.vi 2. Save the VI as Array Investigation Part 2.vi. 3. Open the block diagram. 4. Right-click the border of the interior For Loop, containing the function and the function, and select .Multiply Round to Nearest Remove For Loop 3/6 www.ni.com 5. Right-click the border of the remaining and select from the shortcut menu. Your block diagram should resemble the figure below.For Loop Remove For Loop 6. Save the VI. 7. Switch to the front panel. 8. Enter values for Rows and Columns. 9. Run the VI. Notice that the VI behaves the same as the solution for Part 1. This is because mathematical functions are polymorphic. For example, because the input of the Multiply function is ax two-dimensional array, and the input is a scalar, the function multiplies each element in the array by the scalar, and outputs an array of the same dimension as the input.y Multiply x Part 3: Implementation Modify Array Investigation VI so that the VI creates a new array that contains the contents of the third row, and another new array that contains the contents of the second column. 1. Open located at the bottom of this pageArray Investigation.vi 2. Save the VI as .Array Investigation Part 3.vi 3. Open the block diagram of the VI. In the following steps, you build a block diagram similar to that shown in the next figure. 4. Retrieve the third row of data from Array using the Index Array function. Add the function to the block diagram.Index Array Wire to the input of the function.Array array Index Array Tip: The Index Array function accepts an n-dimensional array. After you wire the input array to the Index Array function, the input and output terminal names change to match the dimension of the array wired. Therefore, wire the input array to the Index Array function before wiring any other terminals. Right-click the input of the Index Array function.index(row) Select from the shortcut menu.CreateConstant Enter in the constant to retrieve the third row. Remember that the index begins at zero.2 Right-click the output of the function.subarray Index Array Select from the shortcut menu. CreateIndicator Name the indicator .Third Row 5. Retrieve the second column of data from the Array using the Index Array function. Add another function to the block diagram.Index Array Wire to the input of the function.Array array Index Array Right-click the input of the function.disable index(col) Index Array Select .CreateConstant Enter in the constant to retrieve the second column because the index begins at zero.1 Right-click the output of the function.subarray Index Array Select .CreateIndicator Name the indicator .Second Column 6. Save the VI. 4/6 www.ni.com 7. Switch to the front panel. 8. Enter values for Rows and Columns. 9. Run the VI. Clusters 1. Open a blank VI. 2. Save the VI as .Cluster Experiment.vi In the following steps, you create a front panel similar to the figure below. 3. Add a S to the front panel window.top button 4. Add a N indicator to the front panel window.umeric 5. Add a to the front panel.Round LED 6. Rename the LED .Boolean 2 7. Create a cluster named , containing a .Cluster numeric control, two toggle switches, and a slide control Add a to the front panel.Cluster Shell Add a control to the cluster.Numeric Add two to the cluster.Vertical Toggle Switches Rename the Boolean toggle switches to Boolean 1. Add a to the cluster.Horizontal Fill Slide 8. Create , containing the same contents as Cluster, but indicators instead of controls.Modified Cluster Create a copy of .Cluster Relabel the copy .Modified Cluster Right-click the shell of , and select from the shortcut menu.Modified Cluster Change to Indicator 9. Create , containing a and a .Small Cluster Boolean indicator numeric indicator Create a copy of .Modified Cluster Relabel the copy .Small Cluster Delete the second toggle switch. Delete the horizontal fill slide indicator. Right-click Small Cluster and select .AutosizingSize to Fit Relabel the numeric indicator to value.Slide Resize the cluster as needed. 10. Verify the cluster order of .Cluster, Modified Cluster, and Small Cluster Right-click the boundary of and select from the shortcut menu.Cluster Reorder Controls in Cluster 5/6 www.ni.com 1. Confirm the cluster order shown in the figure below. Click the button on the toolbar to set the cluster order and exit the cluster order edit mode.Confirm Right-click the boundary of and select from the shortcut menu.Modified Cluster Reorder Controls in Cluster Confirm the cluster orders shown in the figure below. should have the same cluster order as .Modified Cluster Cluster Click the button on the toolbar to set the cluster order and exit the cluster order edit mode.Confirm Right-click the boundary of and select from the shortcut menu. Click the button on the toolbar to set the cluster order and exit the cluster orderSmall Cluster Reorder Controls in Cluster OK edit mode. Confirm the cluster orders shown in the figure below. In the following steps, build the block diagram shown in the next figure. 11. Add the from the Structures palette to the block diagram.While Loop Disassemble Cluster. Add the function to the block diagram.Unbundle Wire to the input of the to resize the function automatically.Cluster Unbundle function 13. Assemble Small Cluster. Add the function to the block diagram.Bundle Wire the function as shown in the figure above.Bundle 14. Assemble Modified Cluster. Add the function to the block diagram.Unbundle by Name Wire the to the function.Cluster Unbundle by Name Resize the function to have two output terminals.Unbundle by Name Select in the first node, and in the second node. If a label name is not correct, use the Operating tool to select the correct item.Numeric Boolean 1 Add the function to the block diagram.Increment Wire the output of the function to the input of the function. This function adds one to the value of .Numeric  Unbundle By Name Increment Numeric Add the function to the block diagram.Not Wire the output of the function to the input of the function. This function returns the logical opposite of the value of Boolean.Boolean 1 Unbundle By Name x Not 6/6 www.ni.com Add the function to the block diagram.Bundle by Name Wire to the input.Cluster input cluster Resize this function to have two input terminals. Select in the first node and in the second node. If a label name is not correct, use the tool to select the correct item.Numeric Boolean 1 Operating Wire the output of the function to .Increment Numeric Wire the output of the function to .Not Boolean 1 Wire the output of the function to the indicator.Bundle By Name Modified Cluster 15. Add a function to provide the processor with time to complete other tasks.wait Add the function to the block diagram.Wait Until Next ms Multiple Right-click the terminal of the function.millisecond multiple Wait Until Next ms Multiple Select from the shortcut menu.CreateConstant Enter in the constant.100 16. Complete the block diagram and wire the objects as shown in the previous figure. 17. Save the VI. 18. Display the front panel. 19. Run the VI. 20. Enter different values in Cluster and notice how values entered in Cluster affect the Modified Cluster and Small Cluster indicators. Is this the behavior you expected? 21. Click the Stop button when you are done. 22. Change the cluster order of Modified Cluster. Run the VI. How did the changed order affect the behavior? 23. Close the VI. Do not save changes. Tutorial Video Arrays, Clusters, and Text Based Nodes Modules Home FIRST Community Downloads array_investigation.vi array_inv_part_1_solution.vi cluster_exp_solution.vi array_inv_part_3_solution.vi array_inv_part_2_solution.vi Legal This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE ( ).http://ni.com/legal/termsofuse/unitedstates/us/

该用户的其他资料

  • 名称/格式
  • 评分
  • 下载次数
  • 资料大小
  • 上传时间

用户评论

0/200
    暂无评论
上传我的资料

相关资料

资料评价:

/ 6
所需积分:1 立即下载
返回
顶部
举报
资料
关闭

温馨提示

感谢您对爱问共享资料的支持,精彩活动将尽快为您呈现,敬请期待!