336540 design of bio-medical virtual instrumentation

17
336540 Design of Bio-Medical Virtual Instrumentation Tutorial 3

Upload: presley

Post on 24-Feb-2016

62 views

Category:

Documents


0 download

DESCRIPTION

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

TRANSCRIPT

Page 1: 336540 Design of Bio-Medical Virtual Instrumentation

336540Design of Bio-Medical Virtual Instrumentation

Tutorial 3

Page 2: 336540 Design of Bio-Medical Virtual Instrumentation

Outline

• Enums• Arrays• Clusters• Plotting data• Type definitions• Case structure

Page 3: 336540 Design of Bio-Medical Virtual Instrumentation

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

Page 4: 336540 Design of Bio-Medical Virtual Instrumentation

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:

Page 5: 336540 Design of Bio-Medical Virtual Instrumentation

• 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.

Arrays

Page 6: 336540 Design of Bio-Medical Virtual Instrumentation

• 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.

Page 7: 336540 Design of Bio-Medical Virtual Instrumentation

PolymorphismThe LabVIEW numeric functions are polymorphic- the inputs to these functions can be different data structures:

Page 8: 336540 Design of Bio-Medical Virtual Instrumentation

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

Page 9: 336540 Design of Bio-Medical Virtual Instrumentation

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

Page 10: 336540 Design of Bio-Medical Virtual Instrumentation

Plotting data• Chart Vs. Graph:

• In order to display multiple plots together use the Bundle function

Page 11: 336540 Design of Bio-Medical Virtual Instrumentation

• 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

Page 12: 336540 Design of Bio-Medical Virtual Instrumentation

• 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.

Exercise 2

Page 13: 336540 Design of Bio-Medical Virtual Instrumentation

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:

Page 14: 336540 Design of Bio-Medical Virtual Instrumentation
Page 15: 336540 Design of Bio-Medical Virtual Instrumentation

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

Page 16: 336540 Design of Bio-Medical Virtual Instrumentation

Making a decision in LabVIEW 1. Case Structures

2. Select

Page 17: 336540 Design of Bio-Medical Virtual Instrumentation

• 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).

Exercise 3