1 / 17

336540 Design of Bio-Medical Virtual Instrumentation

336540 Design of Bio-Medical Virtual Instrumentation . Tutorial 3. Outline. Enums Arrays Clusters Plotting data Type definitions Case structure. E- nums.

presley
Download Presentation

336540 Design of Bio-Medical Virtual Instrumentation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 336540Design of Bio-Medical Virtual Instrumentation Tutorial 3

  2. Outline • Enums • Arrays • Clusters • Plotting data • Type definitions • Case structure

  3. E-nums • An Enum is a combination of data types which represent a pair of values, a string and a numeric where the e-num can be one of a list of values • Enums are useful because it’s easier to manipulate numbers on the block diagram than strings

  4. Arrays • Arrays – collection of data elements that are all the same type • Arrays in LabVIEW can be of any type • The array’s indexes are in the range of 0 to N-1 • Creating array Controls and Indicators: combining an array shell with a data object:

  5. Arrays • To add n dimensions to the array control or indicator, right-click the array index display and select Add Dimension from the shortcut menu. The example below shows a 2D digital control array.

  6. Array functions: • Creating Arrays with Loops The For Loop and While Loop can index and accumulate arrays at their boundaries automatically. This capability is called auto-indexing.

  7. Polymorphism The LabVIEW numeric functions are polymorphic- the inputs to these functions can be different data structures:

  8. Clusters • Clusters group data elements of mixed types • Creating cluster controls and indicators: adding a cluster shell to the front panel and dragging the data element into the cluster shell • Use the Unbundle function to split a cluster into its individual elements

  9. Exercise 1 Identify the data type of the wires labeled with numbers 1-9

  10. Plotting data • Chart Vs. Graph: • In order to display multiple plots together use the Bundle function

  11. You can bundle data consisting of the initial X value, the delta X value, and a data array to the waveform graph • The XY Graph is a general-purpose Cartesian graphing object ideal for plotting multivalued functions such as circular shapes

  12. Exercise 2 • Build a VI that displays two random plots on a waveform chart in sweep update mode. The plots should be a random plot and a running average of the last four points. • Build a VI that generates a 2D array of three rows by 10 columns containing random numbers. After generating the array, index each row and plot each row on its own graph. The front panel should contain three graphs.

  13. Type Definitions • You can use type definitions to define custom arrays and clusters • A type definition is a master copy of a custom data type (custom control, indicator or constant) • Creating a custom control:

  14. Case structure • The Case structure is analogous to case statements or if...then...else statements in conventional, text-based programming languages • Only one case executes, depending on the value wired to the selector terminal – • You must define the output tunnel for each case • In a numeric or string case structure you must define a default case

  15. Making a decision in LabVIEW • Case Structures • Select

  16. Exercise 3 • Create an E-num control with 4 possible values: add, subtract, multiply and divide. • Create a VI which gets two numbers from the user, chooses which action to calculate according to the E-num case that the user chose and presents the result (use case structure).

More Related