130

1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Embed Size (px)

Citation preview

Page 1: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual
Page 2: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

1. Introduction to LabVIEW

1

Page 3: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench)

is a platform and development environment for a visual programming language from

National Instruments. The graphical language is named "G". Originally released for the

Apple Macintosh in 1986, LabVIEW is commonly used for data acquisition, instrument

control, and industrial automation on a variety of platforms including Microsoft Windows,

various flavors of UNIX, Linux, and Mac OS X (www.ni.com).

Figure 1.1. Labview lounching

The code files have the extension ―.vi‖, which is an abbreviation for ―Virtual

Instrument‖. LabVIEW offers lots of additional Add-Ons and Toolkits.

The programming language used in LabVIEW, also referred to as G, is a

dataflow programming language. Execution is determined by the structure of a graphical

block diagram (the LV-source code) on which the programmer connects different

function-nodes by drawing wires. These wires propagate variables and any node can

execute as soon as all its input data become available. Since this might be the case for

multiple nodes simultaneously, G is inherently capable of parallel execution. Multi-

processing and multi-threading hardware is automatically exploited by the built-in

scheduler, which multiplexes multiple OS threads over the nodes ready for execution.

2

Page 4: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

LabVIEW ties the creation of user interfaces (called front panels) into the

development cycle. Each VI has three components: a block diagram, a front panel, and

a connector panel. The last is used to represent the VI in the block diagrams of other.

Controls and indicators on the front panel allow an operator to input data into or extract

data from a running virtual instrument. However, the front panel can also serve as a

programmatic interface. Thus a virtual instrument can either be run as a program, with

the front panel serving as a user interface, or when dropped as a node onto the block

diagram, the front panel defines the inputs and outputs for the given node through the

connector pane. This implies each VI can be easily tested before being embedded as a

subroutine into a larger program.

The graphical approach also allows non-programmers to build programs simply

by dragging and dropping virtual representations of lab equipment with which they are

already familiar. The LabVIEW programming environment, with the included examples

and the documentation, makes it simple to create small applications. This is a benefit on

one side, but there is also a certain danger of underestimating the expertise needed for

good quality "G" programming. For complex algorithms or large-scale code, it is

important that the programmer possess an extensive knowledge of the special

LabVIEW syntax and the topology of its memory management. The most advanced

LabVIEW development systems offer the possibility of building stand-alone applications.

Furthermore, it is possible to create distributed applications, which communicate by a

client/server scheme, and are therefore easier to implement due to the inherently

parallel nature of G-code.

One benefit of LabVIEW over other development environments is the extensive

support for accessing instrumentation hardware. Drivers and abstraction layers for

many different types of instruments and buses are included or are available for

inclusion. These present themselves as graphical nodes. The abstraction layers offer

standard software interfaces to communicate with hardware devices. The provided

driver interfaces save program development time. Many libraries with a large number of

functions for data acquisition, signal generation, mathematics, statistics, signal

conditioning, analysis, etc., along with numerous graphical interface elements are

provided in several LabVIEW package options. Another benefit of the LabVIEW

3

Page 5: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

environment is the platform independent nature of the G‐code (graphical programming

language), which is (with the exception of a few platform‐specific functions) portable

between the different LabVIEW systems for different operating systems (Windows,

MacOSX and Linux).

The above‐mentioned data‐flow (which can be "forced", typically by linking inputs

and outputs of nodes) completely defines the execution sequence, and that can be fully

controlled by the programmer. Thus, the execution sequence of the LabVIEW

graphical syntax is as well‐defined as with any textually coded language such as

C, Visual BASIC, etc. Furthermore, LabVIEW does not require type definition of the

variables; the wire type is defined by the data‐supplying node. LabVIEW supports

polymorphism in that wires automatically adjust to various types of data.

Screenshot of a simple LabVIEW program that generates, synthesizes, analyzes

and displays waveforms, showing the block diagram and front panel.

Each VI contains three main parts:

1. Front Panel ‐ How the user interacts with the VI.

2. Block Diagram ‐ The code that controls the program.

3. Icon/Connector ‐ Means of connecting a VI to other VIs.

The Front Panel is the user interface of the VI, to interact with the user when the

program is running. Users can control the program, change inputs, and see data

updated in real time. You build the front panel with controls and indicators (available

on the Control Palette), which are the interactive input and output terminals of the

VI, respectively. Controls are knobs, pushbuttons, dials, and other input devices.

Indicators are graphs, LEDs, and other displays.

4

Page 6: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.2. Front panel

Controls simulate instrument input devices and supply values to the block

diagram of the VI. Indicators simulate instrument output devices and display values the

block diagram acquires or generates. These may include data, program states, and

other information. Every front panel control or indicator has a corresponding terminal on

the block diagram. When a VI is run, values from controls flow through the block

diagram, where they are used in the functions on the diagram, and the results are

passed into other functions or indicators. The Controls palette is available only on the

front panel. Go to Window»Show Controls Palette or right‐click the front panel

workspace to display the Controls palette.

5

Page 7: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.3. Controls pallete

The Block Diagram contains this graphical source code. Front panel objects appear

as terminals on the block diagram. Additionally, the block diagram contains functions

and structures from built‐in LabVIEW VI libraries. These can be accessed from the

Functions Palette.

Figure 1.4. Block diagram

Wires connect each of the nodes on the block diagram, including control and

indicator terminals, functions, and structures.

6

Page 8: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

The Functions palette is available only on the block diagram. Select Window»Show

Functions Palette or right‐click the block diagram workspace to display the

Functions palette.

Figure 1.5. Functions pallete

The Icon/Connector may represent the VI as a subVI in block diagrams of calling

VIs. Controls and indicators on the front panel allow an operator to input data into or

extract data from a running virtual instrument. However, the front panel can also

serve as a programmatic interface. Thus a virtual instrument can either be run as a

program, with the front panel serving as a user interface, or, when dropped as a node

onto the block diagram, the front panel defines the inputs and outputs for the given node

through the connector pane. This implies each VI can be easily tested before being

embedded as a subroutine into a larger program.

The graphical approach also allows non‐programmers to build programs by

simply dragging and dropping virtual representations of the lab equipment with

which they are already familiar. The LabVIEW programming environment, with the

included examples and the documentation, makes it easy to create small applications.

For complex algorithms or large‐scale code it is important that the programmer possess

an extensive knowledge of the special LabVIEW syntax and the topology of its

memory management. The most advanced LabVIEW development systems offer

the possibility of building stand‐alone applications.

7

Page 9: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Other features that you will need include the Tools Palette which is a Floating

Palette that is used to operate and modify front panel and block diagram objects and the

Status Toolbar. They contain the following tools and buttons, respectively:

Figure 1.6. Additional pallete

8

Page 10: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

2. Basic exercises

9

Page 11: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 1. Open and Run a Virtual Instrument

Examine the Signal Generation and Processing VI and run it. Change the frequencies and types of the input signals and notice how the display on the graph changes. Change the Signal Processing Window and Filter options. After you have examined the VI and the different options you can change, stop the VI by pressing the Stop button.

1. Select Start»Programs»National Instruments»LabVIEW 7.0»LabVIEW to launch LabVIEW. The LabVIEW dialog box appears.

2. Select Help»Find Examples. The dialog box that appears lists and links to all available LabVIEW example VIs.

3. On the Browse Tab, select browse according to task. Choose Analyzing and Processing Signals, then Signal Processing, then Signal Generation and Processing.vi. This will open the Signal Generation and Processing VI Front Panel.

Front Panel

4. Click the Run button on the toolbar, shown at left, to run this VI. This VI determines the result of filtering and windowing a generated signal. This example also displays the power spectrum for the generated signal. The resulting signals are displayed in the graphs on the front panel, as shown in the following figure.

5. Use the Operating tool, shown at left, to change the Input Signal and the Signal Processing, use the increment or decrement arrows on the control, and drag the pointer to the desired Frequency.

6. Press the More Info… button or [F5] to read more about the analysis functions.

7. Press the Stop button or [F4] to stop the VI.

10

Page 12: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Block Diagram 8. Select Window»Show Diagram or press the <Ctrl‐E> keys to display the block diagram for the Signal Generation and Processing VI. This block diagram contains several of the basic block diagram elements, including subVIs, functions, and structures, which you will learn about later in this course.

9. Select Window»Show Panel or press the <Ctrl‐E> keys to return to the Front Panel.

10. Close the VI and do not save changes.

End of Exercise

11

Page 13: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 2. Building a VI: Convert °C to °F

Complete the following steps to create a VI that takes a number representing degrees Celsius and converts it to a number representing degrees Fahrenheit. In wiring illustrations, the arrow at the end of this mouse icon shows where to click and the number on the arrow indicates how many times to click.

1. Select File»New to open a new front panel.

2. (Optional) Select Window»Tile Left and Right to display the front panel and block diagram side by side.

3. Create a numeric digital control. You will use this control to enter the value for degrees

a. Select the digital control on the Controls»Numeric Controls palette. If the Controls

palette is not visible, right‐click an open area on the front panel to display it. b. Move the control to the front panel and click to place the control. c. Type deg C inside the label and click outside the label or click the

Enter button on the toolbar. If you do not type the name immediately, LabVIEW uses a default label. You can edit a label at any time by using the Labeling tool.

4. Create a numeric digital indicator. You will use this indicator to display the value for degrees Farenhrit

a. Select the digital indicator on the Controls»Numeric Indicators palette. b. Move the indicator to the front panel and click to place the indicator. c. Type deg F inside the label and click outside the label or click the Enter button.

LabVIEW creates corresponding control and indicator terminals on the block diagram. The terminals represent the data type of the control or indicator. For example, a DBL

terminal represents a double‐ precision, floating‐point numeric control or indicator.

Note Control terminals have a thicker border than indicator terminals.

5. Display the block diagram by clicking it or by selecting Window»Show Diagram.

12

Page 14: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Note: Block Diagram terminals can be viewed as icons or as terminals. To change the way LabVIEW

displays these objects right click on a terminal and select View As Icon.

6. Select the Multiply and Add functions on the Functions»Numeric

palette and place them on the block diagram. If the Functions palette is

not visible, right‐click an open area on the block diagram to display it. 7. Select the numeric constant on the Functions»Numeric palette and

place two of them on the block diagram. When you first place the numeric constant, it is highlighted so you can type a value.

8. Type 1.8 in one constant and 32.0 in the other. If you moved the constants before you typed a value, use the Labeling tool to enter the values.

9. Use the Wiring tool to wire the icons as shown in the previous block diagram.

• To wire from one terminal to another, use the Wiring tool to click the first terminal, move the tool to the second terminal, and click the second terminal, as shown in the following illustration. You can start wiring at either terminal.

• You can bend a wire by clicking to tack the wire down and moving the cursor in a perpendicular direction. Press the spacebar to toggle the wire direction.

• To identify terminals on the nodes, right‐click the Multiply and Add functions and select Visible Items»Terminals from the shortcut menu to display the connector pane. Return to the icons after

wiring by right‐clicking the functions and selecting Visible Items»

• Terminals from the shortcut menu to remove the checkmark.

13

Page 15: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

• When you move the Wiring tool over a terminal, the terminal area blinks, indicating that clicking will connect the wire to that terminal and a tip strip appears, listing the name of the terminal.

• To cancel a wire you started, press the <Esc> key, right‐click, or click the source terminal.

10. Display the front panel by clicking it or by selecting Window»Show Panel. 11. Save the VI for later use (have a folder by your own name). 12. Enter a number in the di gital control and run the VI.

a. Use the Operating tool or the Labeling tool to double‐click the digital control and type a new number.

b. Click the Run button to run the VI. c. Try several different numbers and run the VI again.

End of Exercise

14

Page 16: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 3. Using Loops

Use a while loop and a waveform chart to build a VI that demonstrates software timing.

Front Panel 1. Open a new VI.

2. Build the following front panel.

a. Select the horizontal pointer slide on the Controls»Numeric Controls palette and place it on the front panel. You will use the slide to change the software timing.

b. Type millisecond delay inside the label and click outside the label or click the Enter button on the toolbar, shown at left.

c. Place a Stop Button from the Controls»Buttons palette. d. Select a waveform chart on the Controls»Graph Indicators palette

and place it on the front panel. The waveform chart will display the data in real time.

e. Type Value History inside the label and click outside the label or click the Enter button. f. The waveform chart legend labels the plot Plot 0. Use the Labeling tool

to triple‐click Plot 0 in the chart legend, type Value, and click outside the label or click the Enter button to relabel the legend.

g. The random number generator generates numbers between 0 and 1, in a classroom setting you could replace this with a data acquisition VI.

Use the Labeling tool to double‐click 10.0 in the y‐axis, type 1, and click outside the label or click the Enter button to rescale the chart.

h. Change –10.0 in the y‐axis to 0.

i. Label the y‐axis Value and the x‐axis Time (sec).

Block Diagram

3. Select Window»Show Diagram to display the block diagram.

15

Page 17: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

4. Enclose the two terminals in a While Loop, as shown in the following block diagram.

a. Select the While Loop on the Functions»Execution Control palette. b. Click and drag a selection rectangle around the two terminals. c. Use the Positioning tool to resize the loop, if necessary.

5. Select the Random Number (0‐1) on the Functions»Arithmetic and Comparison»Numeric

palette. Alternatively you could use a VI that is gathering data from an external sensor.

6. Wire the block diagram objects as shown in the previous block diagram. 7. Save the VI as Use a Loop.vi in your folder 8. Display the front panel by clicking it or by selecting Window»Show Panel. 9. Run the VI. The section of the block diagram within the While Loop border

executes until the specified condition is TRUE. For example, while the STOP button is not pressed, the VI returns a new number and displays it on the waveform chart.

10. Click the STOP button to stop the acquisition. The condition is FALSE, and the loop stops executing.

11. Format and customize the X and Y scales of the waveform chart.

a. Right‐click the chart and select Properties from the shortcut menu. The following dialog box appears.

b. Click the Scale tab and select different styles for the y‐axis. You also can select different mapping modes, grid options, scaling factors, and formats and precisions. Notice that these will update interactively on the waveform chart

c. Select the options you desire and click the OK button.

16

Page 18: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

12. Right‐click the waveform chart and select Data Operations»Clear

Chart from the shortcut menu to clear the display buffer and reset the waveform chart. If the VI is running, you can select Clear Chart from the shortcut menu.

Adding Timing When this VI runs, the While Loop executes as quickly as possible. Complete the

following steps to take data at certain intervals, such as once every half‐second, as shown in the following block diagram.

a. Place the Time Delay Express VI located on the Functions»Execution Control palette.

In the dialog box that appears, insert 0.5. This function would

make sure that each iteration occurs every half‐second (500 ms). b. Divide the millisecond delay by 1000 to get time in seconds. Connect the output of the

divide function to the Delay Time (s) input of the Time Delay Express VI. This will allow you to adjust the speed of the execution from the pointer slide on the front panel.

17

Page 19: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

13. Save the VI, because you will use this VI later in the course. 14. Run the VI. 15. Try different values for the millisecond delay and run the VI again. Notice

how this effects the speed of the number generation and display. End of Exercise

18

Page 20: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 4. Error Clusters & Handling Front Panel

1. Open a new VI and build the following front panel using the following tips.

a. Create a numeric control and change the Label to Square Root Input. Create a numeric indicator for Square Root.

b. Place Error In 3D.ctl from Controls»All Controls»Arrays & Clusters. c. Place Error Out 3D.ctl from Controls» All Controls»Arrays & Clusters.

Block Diagram

2. Build the following block diagram.

a. Place a Case Structure from Functions»Execution Control palette.

19

Page 21: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

b. Place a Greater or Equal to 0? from the Functions»Arithmetic and

Comparison»Comparison palette and wire it to the condition terminal of the case structure.

In the True Case:

c. Place the Square Root function from Functions»Arithmetic and Comparison»Numeric

d. Create a numeric constant from Functions»Arithmetic and

Comparison»Numeric palette and type ‐9999.90. e. Place the Bundle By Name from Functions»All Functions»Arrays & Clusters palette. Wire

from Error in to the center terminal of Bundle by Name to make status show up. Create constants. Wire from the Error Out indicator to the output of Bundle By name.

3. Save the VI as Square Root.vi. 4. Display the front panel and run the VI. 5. Save and close the VI.

End of Exercise

20

Page 22: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 5. Modifying a Signal

Complete the following steps to scale the signal by 10 and display the results in the

graph on the front panel

1. The Functions palette opens with the Express subpalette visible by default. If

you have selected another subpalette, you can return to the Express

subpalette by clicking Express on the Functions palette.

2. On the Arithmetic & Comparison palette, select the Formula Express VI,

shown, and place it on the block diagram inside the loop between the Simulate

Signal Express VI and the Waveform Graph terminal. You can move the Waveform

Graph terminal to the right to make more room between the Express VI and the

terminal. The Configure Formula dialog box appears when you place the Express

VI on the block diagram. When you place an Express VI on the block diagram, the

configuration dialog box for that VI always appears automatically.

3. Click the Help button, in the bottom right corner of the Configure Formula dialog

box to display the LabVIEW Help topic for this Express VI. The Formula help topic

describes the Express VI, the configuration dialog box options, and the inputs and

outputs of the Express VI. Each Express VI has a corresponding help topic you can

access by clicking the Help button in the configuration dialog box or by right‐clicking the

Express VI and selecting Help from the shortcut menu

21

Page 23: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

4. In the Formula topic, find the dialog box option whose description indicates

that it enters a variable into the formula.

5. Minimize the LabVIEW Help to return to the Configure Formula dialog box.

6. Change the text in the Label text box of the dialog box option you read about

from X1 to Sawtooth to indicate the input value to the Formula Express VI. When you

click in the String text box at the top of the Configure Formula dialog box, the text

changes to match the label you entered.

7. Define the value of the scaling factor by entering *10 after Sawtooth in the String text box. You can use the Input buttons in the configuration dialog box or you can use the *, 1, and 0 keyboardbuttons to enter the scaling factor. If you use the Input buttons in the configuration dialog box, LabVIEW places the formula input after the Sawtooth input in the String text box. If you use the keyboard, click in the String text box after Sawtooth and enter the formula you want to appear in the text box. The Configure Formula dialog box should appear similar to

8. Click the OK button to save the current configuration and close the Configure Formula dialog box.

9. Move the cursor over the arrow on the Sawtooth output of the Simulate Signal Express VI.

10. When the Wiring tool appears, click the arrow on the Sawtooth output and then click the arrow on the Sawtooth input of the Formula Express VI, shown at left, to wire the two objects together.

11. Use the Wiring tool to wire the Result output of the Formula Express VI to the Waveform Graph terminal.

22

Page 24: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

End of Exercise

23

Page 25: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 6. Displaying Two Signals on a Graph

To compare the signal generated by the Simulate Signal Express VI and

the signal modified by the Formula Express VI on the same graph, use the Merge

Signals function. Complete the following steps to display two signals on the same

graph.

1. On the block diagram, move the cursor over the arrow on the Sawtooth output of

the Simulate Signal Express VI.

2. Use the Wiring tool to wire the Sawtooth output to the Waveform Graph terminal.

The Merge Signals function, shown, appears where the two wires connect. A function is

a built‐ in execution element, comparable to an operator, function, or statement in a

text‐ based programming language. The Merge Signals function takes the two separate

signals and combines them so that both can display on the same graph

3. Press the <Ctrl‐ S> keys or select File»Save to save the VI.

4. Return to the front panel, run the VI, and turn the knob control. The graph plots

the sawtooth wave and the scaled signal. The maximum value on the y‐ axis

automatically changes to be 10 times the knob value. This scaling occurs because

you configured the Formula Express VI to generate a slope of 10.

5. Click the STOP button to stop the VI.

24

Page 26: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Customizing a Knob Control

The knob control changes the amplitude of the sawtooth wave, so labeling it

Amplitude accurately describes the behavior of the knob. Complete the following

steps to customize the appearance of the knob.

1. On the front panel, right‐click the knob and select Properties from the

shortcut menu to display the Knob Properties dialog box.

2. In the Label section on the Appearance page, delete the label Knob, and enter

Amplitude in the text box

3. Click the Scale tab and in the Scale Style section, place a checkmark in

the Show color ramp

checkbox. The knob on the front panel updates to reflect these changes.

25

Page 27: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

4. Click the OK button to save the current configuration and close the Knob

Properties dialog box.

5. Save the VI.

6. Reopen the Knob Properties dialog box and experiment with other properties

of the knob. For example, on the Scale page, try changing the colors for the

Marker text color by clicking the color box.

7. Click the Cancel button to avoid applying any changes you made while

experimenting. If you want to keep the changes you made, click the OK

button.

26

Page 28: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Customizing a Waveform Graph

The waveform graph indicator displays the two signals. To indicate which plot is the scaled signal and which is the simulated signal, you can customize the plots. Complete the following steps to customize the appearance of the waveform graph indicator.

1. On the front panel, move the cursor over the top of the plot legend on

the waveform graph.

Though the graph has two plots, the plot legend displays only one plot.

2. When a double‐headed arrow appears, shown in Figure 1‐11, click and drag the border of the plot legend to add one item to the legend. When you release the mouse button, the second plot name appears.

3. Right‐click the waveform graph and select Properties from the shortcut menu to display the

Waveform Graph Properties dialog box.

4. On the Plots page, select Sawtooth from the pull‐down menu. In the Colors section, click the Line

color box to display the color picker. Select a new line color.

5. Select Sawtooth (Formula Result) from the pull‐down menu. 6. Place a checkmark in the Do not use waveform names for plot names

checkbox.

7. In the Name text box, delete the current label and change the name of this plot to Scaled Sawtooth.

8. Click the OK button to save the current configuration and close the Waveform Graph Properties

dialog box. The plot color on the front panel changes. 9. Reopen the Waveform Graph Properties dialog box and experiment with

other properties of the graph. For example, on the Scales page, try disabling

automatic scaling and changing the minimum and maximum value of the y‐axis. 10. Click the Cancel button to avoid applying any changes you made while

experimenting. If you want to keep the changes you made, click the OK button. 11. Save and close the VI.

End of Exercise

27

Page 29: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 7. Using Waveform Graphs

Front Panel

1. Open a new VI and build the following front panel using the following tips.

a. Create a waveform graph indicator from the Controls»Graph Indicators palette. Use the position/size/select tool to move the plot legend to the side, and expand it to display two plots. Use the labeling tool to change the plot names and the properties page to choose different colors for your plots.

b. Place a Stop button on the front panel. c. Place two vertical pointer slides from the Controls»Numeric

Controls palette. Use the properties page again to change the slide fill color.

Block Diagram

2. Build the following block diagram.

28

Page 30: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

a. Place a While Loop from Functions»Execution Control palette. b. Place a Wait Until Next ms Multiple from Functions»All Functions

»Time & Dialog and create a constant with a value of 100. c. Place two Simulate Signal Express VIs from the Functions»Input and leave the Signal type

as Sine for the first Simulate Signal VI and change the Signal Type to Square for the second VI. Wire both of the outputs into the waveform graph. A Merge Signals function will automatically be inserted.

d. Expand the Simulate Signal Express VIs to show another Input/Output. By default, error

out should appear. Change this to Frequency by clicking on error out and choosing Frequency.

3. Save the VI as Multiplot Graph.vi.

4. Display the front panel and run the VI.

5. Save and close the VI.

End of Exercise

29

Page 31: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

3. Mechatronics kit

30

Page 32: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

The mechatronics kit (figure 1) is a devise designed for educational purposes for

the mechatronics students.

Figure 3.1. Mechatronics kit

Each kit consists of National Instruments USB NI6008 DAQ card and basic

electronic components (Buttons, Switches, Potentiometer, DC Motor, Piezo Buzzer, 6

LED diodes: 3 White and 3 RGB, 2 IR Diodes, Photo resistor and Opto switch). The kit

was designed as a standalone device and doesn’t need any other additional external

elements to function properly. It only needs to be connected by a USB connector to a

PC or laptop with LabVIEW installed on it. The purpose of the kit is to introduce to the

students basic electronic components that can be used as sensors, actuators or

indicators.

With the support of LabVIEW and Multifunction DAQ NI6008, the intention is to

present the concepts of measurement, signal processing and control.

Figure 3.2. DAQ card: USB-NI 6008

The NI 6008 is 10 ks/s multifunctional USB-DAQ card from National Instruments.

31

Page 33: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

It consists of:

- 8 Analog inputs

- 2 Analog outputs

- 12 Digital input/output terminals

- 32 bit -5 MHz counter

Fig. 3.3. NI6008 architecture

32

Page 34: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 3.1: Simulation of device

Simulate the taster, switch, potentiometer and LED diodes. The taster should

turn the blue LED diode on, the swith should turn the green diode on, and when the

taster and the swith are on the red diode should turn on. The potentiometer has range

from 0 to 5, and the white LED diodes are turned on at 1,2 and 3. With the

potenciometar we can simulate analog signal.

Solution:

Figure 3.4. Front panel

Figure 3.5. Block diagram

33

Page 35: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 3.2. Mechatronic kit start up

Implement the mechatronic kit for the taster, switch, potentiometer and LED

diodes. The taster should turn the blue LED diode on, the swith should turn the green

diode on. Set the potentiometer to range from 0 to 5, and the white LED diodes are

turned on at 1,2 and 3.

Solution:

Get the DAQ Assist – block in Express - Input / Output menu

Figure 3.6. DAQ assistant

Open the DAQ – Assistant block and choose Aquire signals - Digital Input – Line Input

Figure 3.7. DAQ configuration

34

Page 36: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Select port0/line0 and click Finish.

Figure 3.8. Line selection

Figure 3.9. Functionality check

At the end Click OK.

For signal manupalitiom open express/signal manipulation and select ―to DDT‖. In the

block ―to DDT‖ select (1D array of scalars – single channel) and check the Boolean

(TRUE and FALSE).

35

Page 37: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 3.10. Data conversion

As the previous blocks continue to integrate the components from the mechatronic kit.

Figure 3.11. Final front panel

36

Page 38: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Fig. 12. Final block diagram

37

Page 39: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 3.3.

Build a VI where the DC motor will start with the taster from the mechatronic kit. The

speed of the motor will be controlled by a Knob control. The gree LED diode indicates

the the DC motor is on. The motor vibration are shown on a graph. When the vibration

level increses above a certan value the motor should stop.

Solution:

Fig.13. Front panel

Fig.14. Block diagram

38

Page 40: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

1.Data acquisition with Labview

39

Page 41: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Introduction

Data acquisition is the process of sampling signals that measure real world physical conditions

and converting the resulting samples into digital numeric values that can be manipulated by a

computer. Data acquisition systems (abbreviated with the acronym DAQ) typically convert

analog waveforms into digital values for processing. The components of data acquisition

systems include:

- Sensors that convert physical parameters to electrical signals.

- Signal conditioning circuitry to convert sensor signals into a form that can be converted to

digital values.

- Analog-to-digital converters, which convert conditioned sensor signals to digital values.

Data acquisition applications are controlled by software programs developed using various

general purpose programming languages such as BASIC, C, Fortran, Java, Lisp, Pascal.

Specialized software tools used for building large-scale data acquisition systems

include EPICS. Graphical programming environments include: ladder logic, Visual C++, Visual

Basic, and LabVIEW.

Data acquisition begins with the physical phenomenon or physical property to be measured.

Examples of this include temperature, light intensity, gas pressure, fluid flow, and force.

Regardless of the type of physical property to be measured, the physical state that is to be

measured must first be transformed into a unified form that can be sampled by a data

acquisition system. The task of performing such transformations falls on devices called sensors.

A sensor, which is a type of transducer, is a device that converts a physical property

into a corresponding electrical signal (e.g., a voltage or current) or, in many cases, into a

corresponding electrical characteristic (e.g., resistance or capacitance) that can easily be

converted to an electrical signal.

The ability of a data acquisition system to measure differing properties depends on

having sensors that are suited to detect the various properties to be measured. There are

specific sensors for many different applications. DAQ systems also employ various signal

conditioning techniques to adequately modify various electrical signals into voltage that can then

be digitized using an Analog-to-digital converter (ADC).

Signals may be digital (also called logic signals sometimes) or analog depending on

the transducer used. Signal conditioning may be necessary if the signal from the transducer is

not suitable for the DAQ hardware being used. The signal may need to be amplified, filtered or

40

Page 42: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

demodulated. Various other examples of signal conditioning might be bridge completion,

providing current or voltage excitation to the sensor, isolation, and linearization. For

transmission purposes, single ended analog signals, which are more susceptible to noise can

be converted to differential signals. Once digitized, the signal can be encoded to reduce and

correct transmission errors.

DAQ hardware is what usually interfaces between the signal and a PC. It could be in

the form of modules that can be connected to the computer's ports (parallel, serial, USB, etc.) or

cards connected to slots (S-100 bus, AppleBus, ISA, MCA, PCI, PCI-E, etc.) in

the motherboard. DAQ cards often contain multiple components (multiplexer, ADC, DAC, TTL-

IO, high speed timers, RAM). These are accessible via a bus by a microcontroller, which can

run small programs.

Software for data acquisition hardware is required when the acquisition of data

is connected and works with PC.

41

Page 43: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

1.1 NI USB-6008

The National Instruments USB-6008 provides basic data acquisition functionality for

applications such as simple data logging, portable measurements, and academic lab

experiments. It is affordable for student use, but powerful enough for more sophisticated

measurement applications.

Figure 1.1. NI USB-6008 in Millimeters (Inches)

Figure 1.2. NI USB-6008 Top View

42

Page 44: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

The NI USB-6008 device has a green LED next to the USB connector. The LED

indicator indicates device status, as listed in Table 2.1. When the device is connected to a USB

port, the LED blinks steadily to indicate that the device is initialized and is receiving power from

the connection.

If the LED is not blinking, it may mean that the device is not initialized or the computer

is in standby mode. In order for the device to be recognized, the device must be connected to a

computer that has NI-DAQmx installed on it.

Table 1.1. LED state/Device status

Figure 1.3. Analog Terminal Assignments

43

Page 45: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.4. Digital Terminal Assignments

Figure 1.5. NI USB-6008 Signal Labels (1 Terminal Number Labels (Use Both Together), 2 Digital I/O

Label, 3 Differential Signal Name Label (Use Either), 4 Single-Ended Signal Name Label (Use Either))

44

Page 46: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Table 1.2. Signal descriptions

Analog input signals are connected to the NI USB-6008 through the I/O connector.

Refer to Table 2.2. for more information about connecting analog input signals.

Figure2.6. illustrates the analog input circuitry of the NI USB-6008.

45

Page 47: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.6. Analog input circuitry

The NI USB-6008 has one analog-to-digital converter (ADC). The multiplexer (MUX)

routes one AI channel at a time to the PGA.

The programmable-gain amplifier provides input gains of 1, 2, 4, 5, 8, 10, 16, or 20 when

configured for differential measurements and gain of 1 when configured for single-ended

measurements. The PGA gain is automatically calculated based on the voltage range selected

in the measurement application.

The analog-to-digital converter (ADC) digitizes the AI signal by converting the analog

voltage into a digital code.

The NI USB-6008 can perform both single and multiple A/D conversions of a fixed or

infinite number of samples. A first-in-first-out (FIFO) buffer holds data during AI acquisitions to

ensure that no data is lost.

You can configure the AI channels on the NI USB-6008 to take single-ended or

differential measurements. Refer to Table 6 for more information about I/O connections for

single-ended or differential measurements.

46

Page 48: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Connecting Differential Voltage Signals

For differential signals, connect the positive lead of the signal to the AI+ terminal, and

the negative lead to the AI– terminal.

Figure 1.7. Connecting a differential voltage signal

The differential input mode can measure ±20 V signals in the ±20 V range. However,

the maximum voltage on any one pin is ±10 V with respect to GND. For example, if AI 1 is +10

V and AI 5 is –10 V, then the measurement returned from the device is +20 V.

Figure 1.8. Example of a differential 20 V measurement

Connecting a signal greater than ±10 V on either pin results in a clipped output.

47

Page 49: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.9. Exceeding ± 10 V on AI returns clipped output

Connecting Referenced Single-Ended Voltage Signals

To connect referenced single-ended voltage signals (RSE) to the NI USB-6008, connect

the positive voltage signal to the desired AI terminal, and the ground signal to a GND terminal,

as illustrated in Figure2.10.

When no signals are connected to the analog input terminal, the internal resistor divider

may cause the terminal to float to approximately 1.4 V when the analog input terminal is

configured as RSE. This behavior is normal and does not affect the measurement when a signal

is connected.

Figure 1.10. Connecting a referenced single-ended voltage signal

When an AI task is defined, you can configure PFI 0 as a digital trigger input. When the

digital trigger is enabled, the AI task waits for a rising or falling edge on PFI 0 before starting the

48

Page 50: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

acquisition. To use ai/Start Trigger with a digital source, specify PFI 0 as the source and select

rising or falling edge.

The NI USB-6008 has two independent AO channels that can generate outputs from

0–5 V. All updates of AO lines are software-timed.

Figure2.11 illustrates the analog output circuitry for the NI USB-6008.

Figure 1.11. Analog output circuitry

Digital-to-analog converts (DACs) convert digital codes to analog voltages.

To connect loads to the NI USB-6008, connect the positive lead of the load to the AO

terminal, and connect the ground of the load to a GND terminal.

Figure 1.12. Connecting a load

49

Page 51: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

When you use a DAC to generate a waveform, you may observe glitches in the output

signal. These glitches are normal; when a DAQ switches from one voltage to another, it

produces glitches due to released charges. The largest glitches occur when the most significant

bit of the DAC code changes. You can build a low pass deglitching filter to remove some of

these glitches, depending on the frequency and nature of the output signal. Refer to

ni.com/support for more information about minimizing glitches.

The NI USB-6008 has 12 digital lines, P0. <0..7> and P1.<0..3>, which comprise the

DIO port. GND is the ground-reference signal for the DIO port. You can individually program all

lines as inputs or outputs.

Figure2.13. shows P0.<0..7> connected to example signals configured as digital inputs

and digital outputs. You can configure P1. <0..3> similarly.

Figure 1.13. Example of connecting a load

1 P0.0 configured as an open collector digital output driving an LED

2 P0.2 configured as an active drive digital output driving an LED

50

Page 52: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

3 P0.4 configured as a digital input receiving a TTL signal from a gated inverter

4 P0.7 configured as a digital input receiving a 0 V or 5 V signal from a switch

The default configuration of the NI USB-6008 DIO ports is open collector, allowing 5 V

operations, with an onboard 4.7 kΩ pull-up resistor. An external user-provided pull-up resistor

can be added to increase the source current drive up to a 8.5 mA limit per line as shown in

Figure2.14. The NI USB-6008 ports can also be configured as active drive using the NI-DAQmx

API, allowing 3.3 V operation with a source/sink current limit of ±8.5 mA. Refer to the NI-DAQmx

Help for more information about how to set the DIO configuration.

Figure 1.14. Example of connecting an external user-provided resistor

Complete the following steps to determine the value of the user-provided pull-up resistor:

1. Place an ammeter in series with the load.

2. Place a variable resistor between the digital output line and the +5 V supply.

3. Adjust the variable resistor until the ammeter current reads as the intended current. The

intended current must be less than 8.5 mA.

4. Remove the ammeter and variable resistor from your circuit.5. Measure the resistance of the

variable resistor. The measured resistance is the ideal value of the pull-up resistor.

6. Select a static resistor value for your pull-up resistor that is greater than or equal to the ideal

resistance.

51

Page 53: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

7. Re-connect the load circuit and the pull-up resistor.

To protect the NI USB-6008 against over voltage, under voltage, and over current

conditions, as well as ESD events, you should avoid these fault conditions by using the

following guidelines:

• If you configure a DIO line as an output, do not connect it to any external signal source, ground

signal, or power supply.

• If you configure a DIO line as an output, understand the current requirements of the load

connected to these signals. Do not exceed the specified current output limits of the DAQ device.

National Instruments has several signal conditioning solutions for digital applications requiring

high current drive.

• If you configure a DIO line as an input, do not drive the line with voltages outside of its normal

operating range. The DIO lines have a smaller operating range than the AI signals.

• Treat the DAQ device as you would treat any static sensitive device.

Always properly ground yourself and the equipment when handling the DAQ device or

connecting to it.

At system startup and reset, the hardware sets all DIO lines to high-impedance inputs.

The DAQ device does not drive the signal high or low. Each line has a weak pull-up resistor

connected to it.

Each of the NI USB-6008 DIO lines can be used as a static DI or DO line. You can use

static DIO lines to monitor or control digital signals. All samples of static DI lines and updates of

DO lines are software-timed.

You can configure PFI 0 as a source for a gated inverter counter input edge count task.

In this mode, falling-edge events are counted using a 32-bit counter.

The NI USB-6008 creates an external reference and supplies a power source. All

voltages are relative to COM unless otherwise noted.

The NI USB-6008 creates a high-purity reference voltage supply for the ADC using a

multi-state regulator, amplifier, and filter circuit. You can use the resulting +2.5 V reference

voltage as a signal for self test.

The NI USB-6008 supplies a 5 V, 200 mA output. You can use this source to power external

components.

52

Page 54: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

MAX testing

Before you start to use the USB-6008 in an application, you should test the device in

the MAX utility, which is available via Start / Programs / National Instruments. Figure2.15.

shows MAX.

Figure 1.15. MAX (Measurement and Automation Explorer)

In the MAX window, expand the Devices and Interfaces item, see Figure2.16

Figure 1.16. The Devices and Interfaces item

53

Page 55: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

If MAX recognizes the USB-6008, the device appears under NI-DAQmx Devices.

Assuming that MAX recognizes the device, you can now run a self-test of it by selecting Self-

Test in the menu. Hopefully the self-test passes without errors. Then, you should test the

individual channels of the USB-6008 to check that the input signals are detected correctly by the

USB-6009, and that the output signals generated by the USB-6008 have correct values. This

I/O can be tested in several ways, depending on which channels you actually want to test. Here,

let us test analog output channel 0 (AO0) and the analog input channel 0 (AI0) to see if they

work correctly. We will perform a very simple test, which is sufficient if we are to check that both

AO0 and AI0 work correctly. The test procedure, which is denoted loop back, is to connect the

AI0 channel to the AO0 channel. Then we generate some legal voltage at AO0. If AI0 detects

the same voltage, we know that both AO0 and AI0 works. (We may then repeat this procedure

for other channels.) If for some reason AI0 detects some other voltage than the value we set for

AO0, then there is an error in either the AI0 channel or in the the AO0 channel, and further

investigations are necessary.

To prepare for the loop back test, we wire together AI0 and AO0. To see the terminals of

the USB-6008, select Device Pinouts in the menu shown in Figure2.16. The terminals or pins

are shown in the NI-DAQmx Device Terminals window, see Figure 2.17.

Figure 1.17 The terminals or pins are shown in the NI-DAQmx Device Terminals window

54

Page 56: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 2.18 shows the AI0 and AO0 channels wired together.

Figure 1.18. To prepare for the loop back test, AI0 and AO0 are wired together.

To actually perform the loop back test, right-click on the device labeled NI USB-6008:

"Dev1" in MAX, and then select Test Panels, thereby opening the Test Panels. In the Test

Panels window, select the Voltage Output tab, see Figure2.19.

Figure 1.19. The Voltage Output dialog window in the Test Panels window

55

Page 57: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

In the Voltage Output dialog window, select any voltage between 0V and 5V. In Figure

2.19., an output voltage of 3.57V is set.

Next, click the Analog Input tab in the Test Panels window, see Figure2.20. You may

deselect Auto-scale chart in the window.

Figure 1.20 The Analog Input dialog window in the Test Panels window

If the channel testing passed without problems, you may end the testing session by

setting 0V on the output (in the Voltage Output window).

The Analog Input window should indicate the same (or almost the same) voltage as is

set out on AO0. There may be a small difference between the values due to the limited

resolution in the DA-converter (digital-to-analog) and in the AD-converter (analog-to-digital).

56

Page 58: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

1.2 DESCRIPTION OF THE DEMONSTRATIVE DEVICE

In this subtitle is shown a picture of the demonstrative device that shows despite NI

USB 6008 card and other hardware components such as: electric motor, buzzer, potentiometer,

slotted optical switch, photo-resistor, LEDs, push-button and switch.

Figure 1.21. Picture of the demonstrative device druga slika

Light-emitting diode (LED)

Diode is an electronic component that allows the flow of electric current in one

direction without any resistance (or with very low resistance), while in the opposite direction is

infinite (or at least very large) resistance. Therefore, for the diode is said that there is

nonconductive and conductive direction. It can be considered that for current flow in conductive

direction diode has a resistance as the wire conductor (zero resistance), and the nonconducting

direction can be seen as a broken-down conductor (infinite resistance).

A light-emitting diode (LED) is a semiconductor light source. LEDs are used as

indicator lamps in many devices and are increasingly used for other lighting. Introduced as a

57

Page 59: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

practical electronic component in 1962, early LEDs emitted low-intensity red light, but modern

versions are available across the visible, ultraviolet, and infrared wavelengths, with very high

brightness. When a light-emitting diode is switched on (forward bias, the p-type is connected

with the positive terminal and the n-type is connected with the negative terminal), electrons are

able to recombine with electron holes within the device, releasing energy in the form of photons.

This effect is called electroluminescence and the color of the light (corresponding to the energy

of the photon) is determined by the energy gap of the semiconductor. LEDs are often small in

area (less than 1 mm2), and integrated optical components may be used to shape its radiation

pattern. LEDs present many advantages over incandescent light sources including lower energy

consumption, longer lifetime, improved robustness, smaller size, and faster switching. LEDs

powerful enough for room lighting are relatively expensive and require more precise current and

heat management than compact fluorescent lamp sources of comparable output. Light-emitting

diodes are used in applications as diverse as replacements for aviation lighting, automotive

lighting (in particular brake lamps, turn signals, and indicators) as well as in traffic signals. LEDs

have allowed new text, video displays, and sensors to be developed, while their high switching

rates are also useful in advanced communications technology. Infrared LEDs are also used in

the remote control units of many commercial products including televisions, DVD players, and

other domestic appliances.

Figure 1.22. Symbol and display of LED diode

Conventional LEDs are made from a variety of inorganic semiconductor materials, the following

table shows the available colors with wavelength range, voltage drop and material.

58

Page 60: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Color Wavelength

[nm]

Voltage drop

[ΔV] Semiconductor material

Infrared λ > 760 ΔV < 1.9 Gallium arsenide (GaAs)

Aluminium gallium arsenide (AlGaAs)

Red 610 < λ <

760

1.63 < ΔV <

2.03

Aluminium gallium arsenide (AlGaAs)

Gallium arsenide phosphide (GaAsP)

Aluminium gallium indium

phosphide (AlGaInP)

Gallium(III) phosphide (GaP)

Orange 590 < λ <

610

2.03 < ΔV <

2.10

Gallium arsenide phosphide (GaAsP)

Aluminium gallium indium

phosphide (AlGaInP)

Gallium(III) phosphide (GaP)

Yellow 570 < λ <

590

2.10 < ΔV <

2.18

Gallium arsenide phosphide (GaAsP)

Aluminium gallium indium

phosphide (AlGaInP)

Gallium(III) phosphide (GaP)

Green 500 < λ <

570 1.9< ΔV< 4.0

Indium gallium nitride (InGaN) / Gallium(III)

nitride (GaN)

Gallium(III) phosphide (GaP)

Aluminium gallium indium

phosphide (AlGaInP)

Aluminium gallium phosphide (AlGaP)

Blue 450 < λ <

500

2.48 < ΔV <

3.7

Zinc selenide (ZnSe)

Indium gallium nitride (InGaN)

Silicon carbide (SiC) as substrate

Silicon (Si) as substrate – (under

development)

Violet 400 < λ < 2.76 < ΔV < Indium gallium nitride (InGaN)

59

Page 61: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

450 4.0

Purple multiple

types

2.48 < ΔV <

3.7

Dual blue/red LEDs,

blue with red phosphor,

or white with purple plastic

Ultraviolet λ < 400 3.1 < ΔV <

4.4

Diamond (235 nm)

Boron nitride (215 nm)

Aluminium nitride (AlN) (210 nm)

Aluminium gallium nitride (AlGaN)

Aluminium gallium indium nitride (AlGaInN) –

(down to 210 nm)

White Broad

spectrum ΔV = 3.5 Blue/UV diode with yellow phosphor

Table 1.3. The available colors with wavelength range, the voltage drop and materials for LED diodes

There are two primary ways of producing high-intensity white-light using LEDs. One is to use

individual LEDs that emit three primary colors: red, green and blue and then mix all the colors to

form white light. The other is to use a phosphor material to convert monochromatic light from a

blue or UV LED to broad-spectrum white light.

Detecting obstacle with IR (Infrared) sensor

The basic concept of infrared detection of obstacles is to transmit the IR signal

(radiation) of the IR transmitter in the direction of the object and receiving the infrared signal

from the IR receiver when the infrared radiation reflects of the surface of the object. The IR

receiver can be a IR photodiode, phototransistor or a ready made module which decodes the

signal. The IR transmitter need to transmit wave with the same frequency of that of the IR

receiver. А thick enclosure is necessary for both IR transmitter and IR receiver, because the IR

radiation may directly reach the receiver. The enclosure can be made out of plastic or even

metal materiel which is painted black. Infrared sensors or infrared LED diodes have usage in

remote controls, infrared wireless communication and data transfer and other applications.

60

Page 62: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.23. Detecting Obstacle with IR (Infrared) Sensor

Photo-resistor

Photo-resistor or light dependent resistor - LDR is a resistor whose electrical

resistance decreases with increasing intensity of incoming light. Photo-resistor is made of a

semiconductor with high electrical resistance. If light falls on photo-resistor, with sufficient

frequency (cutoff frequency), the semiconductor will absorb photons of light and release

electrons, which generate electricity, in a closed circuit. Semiconductor can be with or without

additions. Semiconductors without additions have its own charge carriers and are not effective

semiconductors such as silicon. Semiconductors without additions electrons are available only

in certain energy field and therefore photons must have enough energy to incite electrons in the

entire spectrum. Semiconductors with the additions have dirt in it or additives, which increase

the conductivity of electrons, so that photons can eject electrons with lower energy. Silicon is

usually added phosphorus, to increase the electrical conductivity.

61

Page 63: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.24. Symbols and display of photo-resistor

Photo-resistors are available in different types. They are used as light detectors in the cameras,

street lights, security alarms at night, and elsewhere. Special types are used to detect the

infrared spectrum. Cadmium sulfide (CdS) is the most common material. Lead sulfide (PbS) and

indium-antimonid are used in the mid-infrared spectrum. Copper-Germanium (Ge, Cu) detectors

are used in further infrared spectrum in infrared astronomy and spectroscopy. The advantages

are low cost and reliability, and disadvantages of slow response. It usually takes a few seconds

to complete the change of resistance at sudden change of brightness. Because of the slowness,

photo-transistors and photo-diodes are used for applications that depend on the speed of

response elements.

Figure 1.25. The control system of street lamps with a photo-resistor

62

Page 64: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.26. The dependence between the light intensity and photo-resistor resistance

Switch

In electronics, a switch is an electrical component that can break an electrical circuit,

interrupting the current or diverting it from one conductor to another. The most familiar form of

switch is a manually operated electromechanical device with one or more sets of electrical

contacts, which are connected to external circuits. Each set of contacts can be in one of two

states: either "closed" meaning the contacts are touching and electricity can flow between them,

or "open", meaning the contacts are separated and the switch is nonconducting. The

mechanism actuating the transition between these two states (open or closed) can be either a

"toggle" (flip switch for continuous "on" or "off") or "momentary" (push-for "on" or push-for "off")

type. A switch may be directly manipulated by a human as a control signal to a system, such as

a computer keyboard button, or to control power flow in a circuit, such as a light switch.

Automatically operated switches can be used to control the motions of machines, for example,

to indicate that a garage door has reached its full open position or that a machine tool is in a

position to accept another work piece. Switches may be operated by process variables such as

pressure, temperature, flow, current, voltage, and force, acting as sensors in a process and

used to automatically control a system. For example, a thermostat is a temperature-operated

switch used to control a heating process. In electronics, switches are often referred to other

electronic components that perform the role of stopping power. So we can talk about

the transistor, relay, or an electronic tube as a switch.

63

Page 65: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.27. Various types of electrical switches

Push-button

Push-button is a type of circuit breaker that interrupts or connects two or more

conductors only when it is pressed by the user. Otherwise, automatically, via springs or other

solutions returns in the starting position. The button is used in calculators, push-button

telephones, computer keyboard, kitchen appliances and various other mechanical and

electronic devices, home and commercial. In industrial and commercial applications, push

buttons can be linked together by a mechanical linkage so that the act of pushing one button

causes the other button to be released. In this way, a stop button can "force" a start button to be

released. This method of linkage is used in simple manual operations in which the machine or

process have no electrical circuits for control. Pushbuttons are often colored to associate them

with their function so that the operator will not push the wrong button in error. Commonly used

colors are red for stopping the machine or process and green for starting the machine or

process. Red push-buttons can also have large heads (called mushroom heads) for easy

operation and to facilitate the stopping of a machine. These pushbuttons are called emergency

stop buttons.

64

Page 66: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.28. Push-buttons (Tactile Switches)

Potentiometer

The potentiometer is a three-terminal resistor with a sliding contact that forms an

adjustable voltage divider. If only two terminals are used (one side and the wiper), it acts as

a variable resistor or rheostat. Potentiometers are commonly used to control electrical devices

such as volume controls on audio equipment. Potentiometers are rarely used to directly control

power (watt). Instead they are used to adjust the level of analog signals (e.g. volume controls

on audio equipment), and as control inputs for electronic circuits. For example, a light dimmer

uses a potentiometer to control the switching of a TRIAC and so indirectly to control the

brightness of lamps.

Potentiometer is constructed with a resistive element formed into an arc of a circle,

and a sliding contact (wiper) traveling over that arc. The resistive element, with a terminal at one

or both ends, is flat or angled, and is commonly made of graphite, although other materials may

be used. The wiper is connected through another sliding contact to another terminal. On panel

potentiometers, the wiper is usually the center terminal of three. For single-turn potentiometers,

this wiper typically travels just under one revolution around the contact.

65

Page 67: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.29. Singleturn potentiometer

"Multiturn" potentiometers are usually constructed of a conventional resistive element

wiped through a worm gear, although other types exist with a helical resistive element and a

wiper that turns through 10, 20, or more complete revolutions. Besides graphite, materials used

to make the resistive element include resistance wire, carbon particles in plastic, and a

ceramic/metal mixture called cermet.

Figure 1.30. Multiturn potentiometer

A linear taper potentiometer has a resistive element of constant cross-section,

resulting in a device where the resistance between the contact (wiper) and one end terminal is

proportional to the distance between them. Linear describes the electrical characteristic of the

66

Page 68: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

device, not the geometry of the resistive element. Linear taper potentiometers are used when an

approximately proportional relation is desired between shaft rotation and the division ratio of the

potentiometer.

A logarithmic taper potentiometer has a resistive element that either 'tapers' in from

one end to the other, or is made from a material whose resistance varies from one end to the

other. This results in a device where output voltage is a logarithmic function of the mechanical

angle of the potentiometer.

Figure 1.31. The dependence between the knob rotation and potentiometer resistance

A string potentiometer is a multi-turn potentiometer operated by an attached reel of

wire turning against a spring, enabling it to convert linear position to a variable resistance.

In a linear slider potentiometer, a sliding control is provided instead of a dial control.

The resistive element is a rectangular strip, not semi-circular as in a rotary potentiometer.

Electric motor (DC motor)

The electric motor is an electric machine that converts electrical energy into

mechanical energy. The reverse process, converting mechanical energy into electrical energy,

is made by generator.

67

Page 69: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Electric Motors in DC (DC motor)

They differ in how the field coils (stator) and armature (rotor) connected, and its

characteristics. They usually have a commutator.

Motor with independent excitation - Requires two sources of power - less power to the stator

winding and the nominal (rated, designated) power to the rotor winding. The relatively stable

rate at different loads, if the voltage is fixed. Speed is easily adjusted by changing the supply

voltage.

Series engine - Armature and field windings are connected serially. Very high speed at low load,

a very good starting torque. Operating speed is regulated by changing the supply voltage

amplitude. Often used for locomotives, trams, driver of the vehicle (starter) and hand tools in the

battery packs.

Parallel engine - Armature and field windings are connected in parallel. The relatively stable rate

at different loads, even when supply voltage changes (unstable network). They are used rarely,

for example. for conveyor belts in mines.

The serial-parallel (compound) engine - Three coils - two excitation of the stator and the rotor of

the capital. The combination of performance serial and parallel DC motor.

Motor with permanent magnets - In these engines produce a field magnets. The losses are low,

power is limited to a few kilowatts. The most common engine in toys, wipers and ventilation in

vehicles, and other.

Universal Motors - The universal motor is a motor commutator and brushes, similar to the one-

way serial engine that can run or one-way or on alternate power supply. Very common in

vacuum cleaners, kitchen tools and hand tools (drills, grinders, etc.). The high speed of rotation

allows the engine to develop a relatively small footprint of a large force.

68

Page 70: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.32. DC electric motor which is used in audio and video devices

Slotted optical switch (optical sensor) and rotating disk as encoder

Optical sensors or slotted optical switch are used to detect the presence, absence, or

motion of an object. Typical applications that include this type of sensor are sensing when a

door is open or closed, or measuring the speed of a rotating shaft. This article looks at these

two broad classes of sensors, their applications, and how they interface to processors. On

picture is shown a slotted optical switch. An LED is mounted in a plastic housing, facing a

phototransistor, but separated by a gap. If something moves into the gap, it blocks the light path

between the LED and the phototransistor. This signal is presented to

the counter events (PFI 0) of NI USB-6008 card. Slotted switches are often used to detect motor

speed by placing a slotted wheel on the motor shaft and so as the wheel rotates, it alternately

blocks and unblocks the light path. Slotted switches are also used as indicators when a door or

hood on vehicle is open or closed. A flag on the door drops into the slot and blocks the light

when the door is closed. Slotted optical sensors have a schematic symbol as is shown in

picture.

69

Page 71: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 1.33. Slotted-optical sensor with rotating disk

Figure 1.34. Slotted-optical switch electronic symbol

Buzzer

A piezo is an electronic device that generates a voltage when it's physically deformed

by a vibration, sound wave, or mechanical strain. Similarly, when you put a voltage across a

piezo, it vibrates and creates a tone. Piezos can be used both to play tones and to detect tones.

A buzzer or beeper is an audio signaling device, which may be mechanical,

electromechanical, or piezoelectric. The word "buzzer" comes from the rasping noise that

electromechanical buzzers made. Typical uses of buzzers and beepers include alarm

devices, timers, toys, doorbells etc. Early devices were based on an electromechanical system

70

Page 72: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

identical to an electric bell without the metal gong. Similarly, a relay may be connected to

interrupt its own actuating current, causing the contacts to buzz. A piezoelectric element may be

driven by an oscillating electronic circuit or other audio signal source, driven with a piezoelectric

audio amplifier. The piezoelectric buzzer requires an AC voltage to operate, a few volts to

several tens of volts (3 V to 30 V) and has a maximum resonance frequency of a few kHz

(between 1 kHz and 5 kHz).

Figure 1.35. Electronic symbol and display of piezoelectric disk, buzzer (beeper)

Figure 1.36. A piezoelectric disk generates a voltage when deformed

Figure 1.37. Piezoelectric plate used to convert audio signal to sound waves

71

Page 73: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

2.Using a multimeter (digital multimeter)

72

Page 74: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

A digital multimeter can be a very useful tool when working with anything designed to run on

electricity. Knowing how to use the different features of a digital multimeter can be very helpful

in analyzing and troubleshooting electronics devices. From circuit board repair to testing

household batteries, digital multimeters have many uses, but different settings are required in

order to perform tests properly. This guide shows the details of using different tests of a digital

multimeter.

Measuring AC Current

The digital multimeter can be used to test AC current (Amps). Set the meter dial to the AC

current setting as shown in figure3.18. Plug the red probe into the red 10A or A (Amps) jack.

Plug the black probe into the COM jack. Measure an in-circuit current by holding the red probe

on the positive side of the circuit and holding the black probe to the negative side. For

troubleshooting and building electronics projects, the ability to measure current is very

important. Make sure to limit measuring of AC current to the maximum amount shown on your

meter or in the multimeter manual to avoid damaging the meter. Never try to measure high

current sources with a standard multimeter.

Figure 2.1. Digital multimeter

73

Page 75: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Measuring DC Current

The digital multimeter can be used to test DC current (Amps). Set the meter dial to the DC

current setting as shown in figure 3.19. Plug the red probe into the red VΩmA jack and for

higher measurements in the black 10ADC jack. Plug the black probe into the COM jack.

Measure an in-circuit current by holding the red probe on the positive side of the circuit and

holding the black probe to the negative side. For troubleshooting and building electronics

projects, the ability to measure current is very important. Make sure to limit measuring of DC

current to the maximum amount shown on your meter or in the multimeter manual to avoid

damaging the meter.

Figure 2.2. Measuring direct current

Measuring DC Voltage

Use your digital multimeter to test DC voltage by using the dial setting shown in the photo

above. DC voltage is any voltage source from a battery or that has passed through a converter

like a wall wart or voltage transformer that plugs into a wall. Measuring DC voltage is typically

one of the most used features of the digital multimeter. Plug the + red probe into the red VΩmA

jack. Plug the - black probe into the COM jack. Hold the red probe on the positive side of the DC

voltage source and hold the black probe to the negative side. High voltage or current should

never be measured with a standard digital multimeter.

74

Page 76: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 2.3. Measuring DC voltage of 9V battery in wrong and right rang

Measuring AC Voltage

Use your digital multimeter to measure AC voltage by using the dial setting shown in the photo

above. AC voltage is any voltage source like a wall outlet. Things like wall warts or voltage

transformers that plug into a wall change the power from AC to DC voltage. Plug the + red

probe into the red VΩmA jack. Plug the - black probe into the COM jack. Hold the red probe on

the positive side of the AC voltage source and hold the black probe to the negative side. High

voltage or current should never be measured with a standard digital multimeter.

Figure 2.4. Measuring AC voltage on transformer

75

Page 77: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Continuity and LED Test

One of the most useful tests a digital multimeter can perform is the continuity test. This is a

great tool to test wires, circuit board traces, or fuses. Position the dial setting as shown in the

photo above. Plug the red probe into the VΩmA jack. Plug the black probe into the COM jack.

Test circuit boards or wiring by holding one lead to one end of a trace or wire and the other lead

to the other side of the lead or wire. The same is true for fuses. A beep from the multimeter

indicates a completed electrical connection. This means that the trace, wire, or fuse is good.

Figure 2.5. Continuity and LED Test

76

Page 78: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Measuring resistance

The resistor test is an often used feature used by most multimeter owners. Resistors are a

critical part of any circuit design, but when they no longer work the result can be damaging to

other more expensive chips or memory on the circuit. Use a digital multimeter to test resistors

by setting the digital multimeter on the setting shown in the photo above. Plug the + red probe

into the red VΩmA jack. Plug the - black probe into the COM jack. Hold the red probe on the

positive side of the resistor in the circuit and hold the black probe to the negative side. If the

resistor is tested loose the direction of voltage does not matter. Also this way we

can measure resistance of photo-resistors, potentiometers and other components.

Figure 2.6. Measuring resistance

77

Page 79: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

3.Virtual instrumentation

78

Page 80: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Creating program in LabVIEW for activating the LEDs using the push-button and

switch

With this program using the push-button or switch, depending on their

function will switch on and off LEDs.

Push-button is connected with the NI USB 6008 card with one terminal (yellow wire) to the

digital input port P0.0 and the other (brown wire) to ground (GND), while the switch is connected

to the NI USB 6008 card with one terminal (red wire) to the digital input port P0.1, and the other

(brown wire) that is shared with the push-button with the ground (GND).

Creating the VI

1. Right click on the Block Diagram window – Functions – Express – Input – DAQ Assist.

In DAQ Assist window select: Acquire Signals – Digital Input – Line Input – port0/line0; activate

―Invert Line‖ filed and in ―Acquisition Mode‖ window set ―1 Sample (On Demand)‖.

On this way the push-button is configured.

2. Right click on the Block Diagram window – Functions – Express – Input – DAQ Assist.

In DAQ Assist window select: Acquire Signals – Digital Input – Line Input – port0/line1; activate

―Invert Line‖ field and in ―Acquisition Mode‖ window set ―1 Sample (On Demand)‖.

On this way the switch is configured.

3. Right click on the Block Diagram window – Functions – Express – Input – DAQ Assist.

In DAQ Assist window select: Generate Signals – Digital Output – Line Output – port0/line2; in

―Acquisition Mode‖ window set ―1 Sample (On Demand)‖.

On this way the blue LED is configured.

Repeat step 3 for the green (port0/line3) and red (port0/line4) LEDs.

Figure 3.1. Front Panel window of the program

79

Page 81: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

4. - Right click on Block Diagram window – Functions – Express – Signal Manipulation –

To DDT (Convert to Dynamic Data)

Configuration: Conversion – 1D array of scalars – single channel; Scalar Data Type – Boolean

(TRUE and FALSE); Start Time –Zero;

5. - Right click on Front Panel window – Express – Buttons & Switches – Toggle Switch

Configuration: Right click – Change to Indicator.

6. - Right click on Front Panel window – Express – LEDs – Round LED

7. - Right click on Front Panel window – Classic – Classic Boolean – Round LED

8. - Right click on Block Diagram window – Programming – Boolean – Or

Figure 3.2. Block Diagram window of the program

80

Page 82: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Creating program in LabVIEW for detecting objects using infrared (IR) LEDs

With this program using the infrared LEDs we can detect objects that are located near with 3

levels of detection and text reporting on display as well as counter of the detected objects.

The first infrared LED acts as a transmitter and is connected with the NI USB-6008 card via the

analog output port AO0 - anode and GND (ground) - cathode. The second infrared LED acts as

a receiver and is connected with the NI USB-6008 card via analog input port AI2 - anode

and AI6 - cathode.

Creating the VI

1. Right click on the Block Diagram window – Functions – Express – Execution Control -While

Loop;

2. Right click on the Block Diagram window – Functions – Express – Input – DAQ Assist

In DAQ Assist window select: Generate Signals – Analog Output – Voltage – AO0; in ―Terminal

Configuration‖ window set ―RSE‖ and in ―Acquisition Mode‖ window set ―1 Sample (On

Demand)‖.

On this way the first IR LED is configured as a transmitter.

3. Right click on the Block Diagram window – Functions – Express – Input – DAQ Assist

In DAQ Assist window select: Acquire Signals – Analog Input – Voltage – AI2; in ―Terminal

Configuration‖ window set ―RSE‖ and in ―Acquisition Mode‖ window set ―1 Sample (On

Demand)‖.

On this way the second IR LED is configured as a receiver.

81

Page 83: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 3.3. Front Panel window of the program

4. - Right click on Front Panel window – Controls - Express – LEDs – Round LED

5. - Right click on Front Panel window – Controls – Express – Num Ctrls – Knob. This

controler connected with the transmitter and the receiver is used for amplifing the signal.

6. - Right click on Block Diagram window – Functions – Programming – Numeric – Multiply

7. - Right click on Block Diagram window – Functions – Programming – Comparison –

Greater?

8. - Right click on Block Diagram window – Functions – Programming – Comparison –

Select

9. - Right click on Block Diagram window – Functions – Programming – Numeric –

Increment

10. - Right click on Block Diagram window – Functions – Express – Execution

Control – Case Structure

82

Page 84: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

11. - Right click on Block Diagram window – Functions – Programming – Structures

– For Loop

12. - Right click on Front Panel window – Controls - Express – Buttons & Switches –

Toggle Switch

13. - Right click on Block Diagram window – Functions – Programming – String –

String Constant

14. - Right click on Front Panel window – Controls – Modern – String & Path – String

Control

15. - Right click on Front Panel window – Controls - Express – Num Inds – Num Ind

16. - Right click on Block Diagram window – Functions – Programming – Timming – Wait

(ms)

17. - Right click on Block Diagram window – Functions – Programming – Timming – Wait

Until Next ms Multiple

18. - Right click on Front Panel window – Controls – Modern – Graph – Waveform Chart

- This subprogram set on 10 milliseconds is pausing between every ―While Loop‖

cycle and is used for better displaying of the IR LED input signal on the diagram.

- This subprogram set on 300 milliseconds is pausing between every ―Case

Structure‖ cycle and is used for better displaying of the IR LED input signal on the diagram as

well as for not consuming all CPU time on the computer.

- With this subprogram we make the text reporting of the 3

levels of detection on the display and on the LEDs on the ―Front Panel‖ window..

83

Page 85: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

- With this subprogram through the toggle switch we

activate the counter of the detected objects.

Figure 3.4. Block Diagram window of the program

We can use this type of program for configuring parking sensors in vehicles, detecting nearby

objects in industry and manufacturing, avoiding obstacles in robot configurations and other.

Creating program in LabVIEW as example for street lighting

With this program using the photo-resistor the illumination can be detected and this program is

classic example of how the street lighting is working with all the consist elements.

The photo-resistor is connected in electric circuit together with one constant resistor as a

voltage divider.

84

Page 86: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 3.5. Voltage divider

The photo-resistor is connected with the NI USB 6008 card through the mutual terminal (orange

wire) to the analog input port AI0, and with the other two terminals (brown wires) to the +5V

power supply and grounding (GND). Depending on how we will connect the other terminals

such will be the output voltage in relation to brightness on the photo-resistor (figure4.5.).

Creating the VI

1. Right click on Block Diagram window – Functions – Express – Execution Control - While

Loop;

2. Right click on Block Diagram window – Functions – Express – Input – DAQ Assist

In DAQ Assist window select: Acquire Signals – Analog Input – Voltage – AI0; in ―Terminal

Configuration‖ window set ―RSE‖ and in ―Acquisition Mode‖ window set ―1 Sample (On

Demand)‖.

On this way the photo-resistor is configured.

3. Right click on Block Diagram window – Functions – Express – Input – DAQ Assist

In DAQ Assist window select: Generate Signals – Analog Output – Voltage – AO0; in ―Terminal

Configuration‖ window set ―RSE‖ and in ―Acquisition Mode‖ window set ―1 Sample (On

Demand)‖.

85

Page 87: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

On this way the white LEDs are configured.

Figure 3.6. Front Panel window of the program

4. - Right click on Front Panel window – Controls - Express – LEDs – Round LED

5. - Right click on Front Panel window – Controls – Modern – Numeric – Gauge. This

indicator measures the time that photo-resistor is darkened.

6. - Right click on Block Diagram window – Functions – Programming – Numeric – Divide

7. - Right click on Block Diagram window – Functions – Programming – Comparison –

Greater Or Equal!?

7. - Right click on Block Diagram window – Functions – Programming – Comparison –

Greater?

86

Page 88: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

8. - Right click on Block Diagram window – Functions – Programming – Comparison –

Select

9. - Right click on Block Diagram window – Functions – Programming – Numeric –

Increment

10. - Right click on Block Diagram window – Functions – Express – Execution Control

– Case Structure

11. - Right click on Block Diagram window – Functions – Programming – Structures –

For Loop

13. - Right click on Block Diagram window – Functions – Programming – Boolean – True

Constant

14. - Right click on Block Diagram window – Functions – Programming – Boolean - False

Constant

15. - Right click on Front Panel window – Controls - Express – Buttons & Switches – OK

Button (In RESET button role)

16. - Right clikc on Block Diagram window – Functions – Programming – Timming – Wait

(ms)

17. - Right click on Block Diagram window – Functions – Programming – Timming – Wait

Until Next ms Multiple

18. - Right click on Front Panel window – Controls – Modern – Graph – Waveform Chart

- This subprogram set on 100 milliseconds is pausing between every ―While Loop‖

cycle and is used for better displaying of the photo-resistor input signal on the diagram.

- This subprogram set on 10 milliseconds is pausing between every ―Case Structure‖

cycle and is used for better displaying of the photo-resistor input signal on the diagram as well

as for not consuming all CPU time on the computer.

87

Page 89: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

- This subprogram performs regulation of output voltage from the

photo-resistor to the white LEDs because their range of work is between 0 and 3V.

- This subprogram measures the time that photo-resistor is darkened.

- This subprogram trough the measuring instrument displays the time that photo-

resistor is darkened and depending on whether the time is less than or greater than 5 seconds

passes the signal in the cycle.

and - These subprograms activate when the ―timer‖ will

measure 5 seconds continuous darkening of the photo-resistor and in addition change the value

of the "Select" programming block ―False‖ to ―True‖, thereby allowing the output LED on the

Front Panel window and the white LEDs of the demonstrative device connected via "Shift

Register" constantly to illuminate until are reset through the ―RESET‖ OK button.

88

Page 90: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 3.7. Block Diagram window of the program

Creating program in LabVIEW for detecting vibrations using the buzzer (piezoelectric

device)

With this program using the buzzer we can detect vibration and make notifications on LEDs on

the demonstrative device and the screen depending on the size of the vibrations.

The buzzer is connected with the NI USB 6008 card trough the differential analog input ports

AI1 and AI5, so that one terminal (brown wire) connects to the AI1 (AI1+) pin, and the other

(yellow wire) to the AI5 (AI1-). Depending on how you connect the terminals NI USB 6008 card

can give positive or negative voltages.

89

Page 91: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Creating the VI

1. Right click on Block Diagram window – Functions – Express – Execution Control - While

Loop;

2. Right click on Block Diagram window – Functions – Express – Input – DAQ Assist

In DAQ Assist window select: Acquire Signals – Analog Input – Voltage – AI1; in ―Terminal

Configuration‖ window set ―Differential‖ and in ―Acquisition Mode‖ window set ―1 Sample (On

Demand)‖.

On this way the buzzer is configured.

3. Right click on Block Diagram window – Functions – Express – Input – DAQ Assist

In DAQ Assist window select: Generate Signals – Digital Output – Line Output – port0/line3; in

―Acquisition Mode‖ window set ―1 Sample (On Demand)‖.

On this way the green LED is configured.

Repeat step 3 for the red (port0/line4) LED.

Figure 3.8. Front Panel window of the program

4. - Right click on Front Panel window – Controls - Express – LEDs – Round LED

5. - Right click on Front Panel window – Classic – Classic Boolean – Round LED

6. - Right click on Block Diagram window – Functions – Programming – Comparison –

Greater?

90

Page 92: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

7. - Right click on Block Diagram window – Functions – Programming – Comparison –

Select

8. - Right click on Block Diagram window – Functions – Programming – Boolean – True

Constant

9. - Right click on Front Panel window – Controls – Modern – Graph – Waveform Chart

10. - Right click on Block Diagram window – Functions – Express – Signal Manipulation –

From DDT (Convert from Dynamic Data)

Configuration: Resulting data type – 1D array of scalars – automatic; Scalar Data Type –

Boolean (TRUE and FALSE);

and - With these subprograms we compare the output signal from

the buzzer and depending on whether it is greater than 1.5 or 1.8 the green and red LED

activate.

Figure 3.9. Block Diagram window of the program

91

Page 93: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Creating program in LabVIEW for regulation of the electric motor trough the

potentiometer and measuring its speed using the slotted optical switch and the rotating

disk

This program does regulation of the electric motor trough the potentiometer and thus measures

its speed by using the slotted optical switch and the rotating disk.

The electric motor is connected to the NI USB 6008 card with the terminals to the analog output

port AO1 (gray wire) and GND (grounding, blue wire). Depending on how we connect the

terminals to the ports in that direction will turn the electric motor. The potentiometer is

connected to regulatory terminal (black wire) to the NI USB 6008 card via analog input port AI3,

and the other two terminals (brown wires) to +5V power supply and grounding (GND).

Depending on how we connect these terminals so the resistance will depend to the direction of

turning the potentiometer. While the slotted optical switch with the rotating disk on the electric

motor acts as encoder and is connected with the NI USB 6008 card with the output terminal

(green wire) trough the digital port PFI0, while the other two terminals to +5V power supply

(pink wire) and GND (grounding, brown wire).

Creating the V

1. Right click on Block Diagram window – Functions – Express – Execution Control - While

Loop;

2. Right click on Block Diagram window – Functions – Express – Input – DAQ Assist

In DAQ Assist window select: Generate Signals – Analog Output – Voltage – AO1; in ―Terminal

Configuration‖ window set ―RSE‖ and in ―Acquisition Mode‖ window set ―1 Sample (On

Demand)‖.

On this way the electric motor is configured.

3. Right click on Block Diagram window – Functions – Express – Input – DAQ Assist

In DAQ Assist window select: Acquire Signals – Counter Input – Edge Count – ctr0; in ―Count

Direction‖ window set ―Count Up‖ and in ―Acquisition Mode‖ window set ―1 Sample (On

Demand)‖.

On this way the slotted optical switch is configured.

4. Right click on Block Diagram window – Functions – Express – Input – DAQ Assist

In DAQ Assist window select: Acquire Signals – Analog Input – Voltage – AI3; in ―Terminal

Configuration‖ window set ―RSE‖ and in ―Acquisition Mode‖ window set ―1 Sample (On

Demand)‖.

92

Page 94: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

On this way the potentiometer is configured.

5. - Right click on Front Panel window – Controls - Express – Num Inds – Num Ind

Configuration: Right click – Representation – I32 (word).

6. - Right click on Front Panel window – Controls – Modern – Numeric – Gauge.

Configuration: Right click – Representation – I32 (word).

With this indicators we measure the rotations od the electric motor in minute and second.

7. - Right click on Front Panel window – Controls – Express – Num Inds – Meter

8. - Right click on Block Diagram window – Functions – Programming – Comparison –

Greater Or Equal!?

9. - Right click on Block Diagram window – Functions – Programming – Numeric – Multiply

10. - Right click on Block Diagram window – Functions – Programming – Numeric – Divide

11. - Right click on Block Diagram window - Functions – Programming – Numeric – Round

To Nearest

12. - Right click on Block Diagram window – Functions – Programming – Comparison –

Select

13. - Right click on Block Diagram window – Functions – Programming – Numeric –

Subtract

14. - Right click on Block Diagram window – Functions – Express – Execution Control

– Case Structure

15. - Right click on Block Diagram window – Functions – Programming – Timming – Tick

Count (ms)

16. - Right click on Block Diagram window – Functions – Programming – Timming – Wait

Until Next ms Multiple

93

Page 95: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 3.10. Front Panel window of the program

- This subprogram trough the ―Tick Count‖ counts 500 milliseconds

and after every counting releases activating impulse on the ―Case Structure‖ cycle in ―True‖.

- This program divides the number of the received impulses from the encoder

with 3 (number of perforations of the rotating disk) and rounds the total number of revolutions of

the electric motor and shows that number to the display.

- This ―Case Structure‖ when is in ―True‖ cycle performs subtraction of the old

revolutions from the new revolutions and shows the actual running number of rotations of the

electric motor and then performs dividing of that number by 0,5 (the time of activating impulse)

and allows the signal further. When is in ―False‖ cycle connected trough ―Shift Register‖ allows

continuous display of the current speed of the electric motor.

94

Page 96: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

- This measuring instruments are displaying the revolutions per minute and per

second of the electric motor their connection with ―Shift Register‖ allows continuous display of

the current speed of the electric motor.

Figure 3.11. Block Diagram window of the program

95

Page 97: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

1. Introduction to Control Design

96

Page 98: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Control design is a process that involves developing mathematical models that describe a

physical system, analyzing the models to learn about their dynamic characteristics, and creating

a controller to achieve certain dynamic characteristics. Control systems contain components

that direct,

command, and regulate the physical system, also known as the plant. In this manual, the control

system refers to the sensors, the controller, and the actuators. The reference input refers to a

condition of the system that you specify.

The dynamic system, shown in Figure 1-1, refers to the combination of the

control system and the plant.

Figure 1.1. Dynamic System

The dynamic system in Figure 1-1 represents a closed-loop system, also known as a feedback

system. In closed-loop systems, the control system monitors the outputs of the plant and

adjusts the inputs to the plant to make the actual response closer to the input that you

designate.

One example of a closed-loop system is a system that regulates room temperature. In this

example, the reference input is the temperature at which you want the room to stay. The

thermometer senses the actual temperature of the room. Based on the reference input, the

thermostat activates the heater or the air conditioner. In this example, the room is the plant, the

thermometer is the sensor, the thermostat is the controller, and the heater or air conditioner is

the actuator.

Other common examples of control systems include the following applications:

• Automobile cruise control systems

• Robots in manufacturing

• Refrigerator temperature control systems

• Hard drive head control systems

This chapter provides an overview of model-based control design and

describes how you can use the LabVIEW Control Design and Simulation

Module to design a controller.

97

Page 99: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Model-Based Control Design

Model-based control design involves the following four phases: developing and analyzing a

model to describe a plant, designing and analyzing a controller for the dynamic system,

simulating the dynamic system, and deploying the controller. Because model-based control

design involves many iterations, you might need to repeat one or more of these phases before

the design is complete. Figure 1-2 shows how National Instruments provides solutions for each

of these phases.

Figure 1.2. Using LabVIEW in Model-Based Control Design

National Instruments also provides products for I/O and signal conditioning that you can use to

gather and process data. Using these tools, which are built on the LabVIEW platform, you can

experiment with different approaches at each phase in model-based control design and quickly

identify the optimal design solution for a control system.

Developing a Plant Model

The first phase of model-based control design involves developing and analyzing a

mathematical model of the plant you want to control. You can use a process called system

identification to obtain and analyze this model.

The system identification process involves acquiring data from a plant and then numerically

analyzing stimulus and response data to estimate the parameters and order of the model.

The system identification process requires a combination of the following components:

• Signal generation and data acquisition—National Instruments

provides software and hardware that you can use to stimulate and

measure the response of the plant.

• Mathematical tools to model a dynamic system—The LabVIEW

System Identification Toolkit contains VIs to help you estimate and create accurate

mathematical models of dynamic systems. You can use this toolkit to create discrete linear

models of systems based on

measured stimulus and response data.

98

Page 100: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Designing a Controller

The second phase of model-based control design involves two steps. The first step is analyzing

the plant model obtained during the system identification process. The second step is designing

a controller based on that analysis. You can use the Control Design VIs and tools to complete

these steps. These VIs and tools use both classical and state-space techniques.

Figure 1-3 shows the typical steps involved in designing a controller.

Figure1.3.ControlDesignProcess

You often iterate these steps to achieve an acceptable design that is physically realizable and

meets specific performance criteria.

Simulating the Dynamic System

The third phase of model-based control design involves validating the controller design obtained

in the previous phase. You perform this validation by simulating the dynamic system. For

example, simulating a jet

engine saves time, labor, and money compared to building and testing an actual jet engine.

You can use the Control Design and Simulation Module to simulate linear time-invariant

systems. This module also provides a variety of numerical integration schemes for simulating

more elaborate systems, such as

nonlinear systems. You also can use this module to determine how a system responds to

complex, time-varying inputs.

Deploying the Controller

The fourth phase of model-based control design involves deploying the controller to a real-time

(RT) target. LabVIEW and the LabVIEW Real-Time Module provide a common platform that you

can use to implement the control system.

Refer to the National Instruments Web site at ni.com for information about the National

Instruments products mentioned in this section.

99

Page 101: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

2.Overview of LabVIEW Control Design

100

Page 102: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

The Control Design and Simulation Module provides an interactive Control Design Assistant, a

library of VIs, and a library of MathScript RT Module functions for designing a controller based

on a model of a plant. You can use all these tools to complete the entire control design process

from creating a model of the controller to synthesizing the controller on an

RT target.

Control Design Assistant

You can use the Control Design Assistant to synthesize and analyze a controller for a user-

defined model without knowing how to program in LabVIEW. You access the Control Design

Assistant through the LabVIEW SignalExpress environment. LabVIEW SignalExpress is a

framework that can host multiple interactive National Instruments tools and assistants

You also can use the Control Design Assistant to create a project. In one project, you can load

or create a model of a plant into the Control Design Assistant, analyze the time or frequency

response, and then calculate the controller parameters. With the Control Design Assistant, you

immediately can see the mathematical equation and graphical representation that

describe the model. You also can view the response data and the configuration of the controller.

Using the Control Design Assistant, you can convert a project to a

LabVIEW block diagram and customize that block diagram in LabVIEW. You then can use

LabVIEW to enhance and extend the capabilities of the application. Refer to the LabVIEW

SignalExpress Help for more information about using the Control Design Assistant to analyze

models that describe a physical system and design controllers to achieve specified

dynamic characteristics.

Control Design Vis

The Control Design and Simulation Module also provides VIs that you can use to create and

develop control design applications in LabVIEW. You can use these VIs to develop

mathematical models of a dynamic system,

analyze the models to learn about their dynamic characteristics, and create controllers to

achieve specified dynamic characteristics. You use these Vis to customize a LabVIEW block

diagram to achieve specific goals. You also

can use other LabVIEW VIs and functions to enhance the functionality of the application. Refer

to the LabVIEW Help, available by selecting Help» Search the LabVIEW Help, for information

about the Control Design

VIs.

Unlike creating a project with the Control Design Assistant, creating a LabVIEW application

using the Control Design VIs requires basic knowledge about programming in LabVIEW. Refer

to the LabVIEW Help for more information about the LabVIEW programming environment.

101

Page 103: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Control Design MathScript RT Module Functions

The Control Design and Simulation Module also includes numerous functions that extend the

functionality of the LabVIEW MathScript Window. Use these functions to design and analyze

controller models in a

text-based environment. The LabVIEW MathScript Window is able to process files you create

using the current LabVIEW MathScript syntax and, for backwards compatibility, files you created

using legacy MathScript

syntaxes. The LabVIEW MathScript Window also can process certain of your files that use other

text-based syntaxes, such as files you created using the MATLAB® software. Because the

MathScript RT Module engine is

used to process scripts in the LabVIEW MathScript Window, and because the MathScript RT

Module engine does not support all syntaxes, not all existing text-based scripts are supported.

102

Page 104: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

3.Constructing Dynamic System

Models

103

Page 105: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Model-based control design relies upon the concept of a dynamic system model. A dynamic

system model is a mathematical representation of the dynamics between the inputs and outputs

of a dynamic system. You

generally represent dynamic system models with differential equations or difference equations.

Obtaining a model of the dynamic system you want to control is the first step in model-based

control design. You analyze this model to anticipate the outputs of the model when given a set

of inputs. Using this analysis, you

then can design a controller that affects the outputs of the dynamic system in a manner that

you specify.

For example, consider the temperature-regulation example in the introduction of Chapter 1,

Introduction to Control Design. You can analyze the open-loop dynamics of the plant to design

an effective controller for this

closed-loop dynamic system. A model for this closed-loop dynamic system describes the input

to the plant as the air flow from the vent. The output of the plant is the temperature of the room.

By analyzing the relationship

between the inputs and output of the plant, you can predict how the plant reacts when given

certain inputs. Based on this analysis, you then can design a controller for this dynamic system.

This chapter provides information about using the LabVIEW Control Design and Simulation

Module to create dynamic system models. This chapter also describes the different forms that

you can use to represent a dynamic system model.

Constructing Accurate Models

To create a model of a system, think of the system as a black box that continuously accepts

inputs and continuously generates outputs. Figure 2-1 shows the basic black-box model of a

dynamic system.

Figure 3.1. Black-Box Model of a Dynamic System

You refer to this model as a black-box model because you often do not know the relationship

between the inputs and outputs of a dynamic system. The model you create, therefore, has

errors that you must account for when

designing a controller. An accurate model perfectly describes the dynamic system that it

represents. Real-world dynamic systems, however, are subject to a variety of non-deterministic

fluctuating conditions and interacting components that prevent you from making a perfect

model. You must consider many external factors, such as random interactions and parameter

104

Page 106: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

variations. You also must consider internal interacting structures and their fundamental

descriptions. Because designing a perfectly accurate model is impossible, you must design a

controller that accounts for these inaccuracies. A robust controller is one that functions as

expected despite some differences between the dynamic system and the model of the dynamic

system. A controller that is not robust might fail when such differences are present. The more

accurate a model is, the more complex the mathematical relationship between inputs and

outputs. At times, however, increasing the complexity of the model does not provide any more

benefits. For example, if you want to control the interacting forces and friction of a mechanical

dynamic system, you might not need to include the thermodynamic effects of the system. These

effects are complicated features of the system that do not affect the friction enough to impact

the robustness of the controller. A model that incorporates these effects can become

unnecessarily complicated.

There different classification of model types such as: Linear versus Nonlinear Models, Time-

Variant versus Time-Invariant Models, Continuous versus Discrete Models.

Table 3.1. Definitions of Continuous and Discrete Systems

105

Page 107: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Table 3.2. Dimensions and Names of State-Space Model Variables

SISO Transfer Function Models

Using the example in the RLC Circuit Example section of this chapter, you can describe the

voltage of the capacitor vc using the following second order differential equation:

After taking the Laplace transform and rearranging terms, you then can

write the transfer function between the input voltage Vi and the capacitor

voltage Vc using the following equation.

You then can use H(s) to study the dynamic properties of the RLC circuit.

The following equation defines a continuous transfer function where

Figure 2-3 shows how you use the CD Construct Transfer Function Model VI to create this

continuous transfer function model.

106

Page 108: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 3.2. Creating a Continuous Transfer Function Model

The Numerator and Denominator inputs are arrays with zero-based indexes. The ith element of

the array corresponds to the ith order coefficient of the polynomial. You define the coefficients

in ascending order.

The CD Construct Transfer Function Model VI creates a continuous model. You can create a

discrete transfer function model in one of two ways. The method you use depends on whether

you know the coefficients of the

discrete transfer function model. If you know the coefficients of the discrete transfer function

model, you can

enter in the appropriate values for Numerator and Denominator and set the Sampling Time (s)

to a value greater than zero. Figure 2-4 shows this process using a sampling time of 10 μs.

Figure 3.3. Using Coefficients to Create a Discrete Transfer Function Model

SIMO, MISO, and MIMO State-Space Models

You construct a SIMO, MISO, or MIMO state-space model by ensuring the output matrix C and

the input matrix B have the appropriate dimensions. For a SIMO system, construct an output

matrix C with more than one row.

For a MISO system, construct an input matrix B with more than one column. For a MIMO

system, construct matrices C and B with more than one row and column, respectively. When

you create a SIMO, MISO, or MIMO system, ensure that the direct transmission matrix D has

the appropriate dimensions. If you leave D

107

Page 109: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

empty or unwired, the Control Design and Simulation Module replaces the missing values with

zeros.

Table 3.3. Model Properties

You can use these data structures with every VI in the Control Design and Simulation Module

that accepts a system model as an input.

You can use the Model Information VIs to get and set various properties of the model. Refer to

the LabVIEW Help, available by selecting Help» Search the LabVIEW Help, for more

information about using the Model Information VIs to view and change the properties of a

system model.

108

Page 110: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

4.Spring-Mass Damper Example

109

Page 111: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

To illustrate the different time responses you can obtain from a model, consider the following

example of a spring-mass damper, shown in Figure 4.1.

Figure 4.1. Spring-Mass Damper System

In this example, k is the spring constant, u is a force, m is the mass, and b is the damper

coefficient. x is the displacement, which is the distance from the normal state of the spring to the

current position of the spring. You can

represent this spring-mass damper system with the following state-space model:

For this example, consider the following values:

The following equations define the state-space model.

The following sections show how this system responds to different inputs.

110

Page 112: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Analyzing a Step Response

The step response of a dynamic system measures how the dynamic system responds to a step

input signal. The following equations define a unit step input signal.

The Control Design and Simulation Module contains two VIs to help you measure the step

response of a system and then analyze that response. The CD Step Response VI returns a

graph of the step response. The CD Parametric Time Response VI returns the following

response data that helps you analyze the step response.

• Rise time (tr)—The time required for the dynamic system response to

rise from a lower threshold to an upper threshold. The default values

are 10% for the lower threshold and 90% for the upper threshold.

• Maximum overshoot (Mp)—The dynamic system response value that

most exceeds unity, expressed as a percent.

• Peak time (tp)—The time required for the dynamic system response to

reach the peak value of the first overshoot.

• Settling time (ts)—The time required for the dynamic system

response to reach and stay within a threshold of the final value. The

default threshold is 1%.

• Steady state gain—The final value around which the dynamic system

response settles to a step input.

• Peak value (yp)—The value at which the maximum absolute value of

the time response occurs.

Figure 4.2 shows a sample step response graph and the locations of the

parametric response data.

Figure 4.2. Step Response Graph and Associated Parametric Response Data

111

Page 113: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

For example, consider the system described in the Spring-Mass Damper Example section of

this chapter. Figure 4.3 shows how you determine the step response and associated parametric

response data of this system.

Figure 4.3. Step Response Block Diagram of the Spring-Mass Damper System

Figure 4.4 shows the Step Response Graph resulting from this block

diagram.

Figure 4.4. Step Response Graph of the Spring-Mass Damper System

You can see that the step input causes this system to settle at a steady-state

value of 0.02 cm.

When you use the CD Parametric Time Response VI to analyze the step response of this

system, you obtain the following response data:

• Rise time (tr)—1.42 seconds

• Maximum overshoot (Mp)—79.90%

• Peak time (tp)—4.54 seconds

• Settling time (ts)—89.89 seconds

• Steady state gain—0.02 cm

112

Page 114: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

• Peak value (yp)—0.04 cm

Figure 4.5 shows the output of the CD Parametric Time Response VI.

Figure 4.5. Parametric Data of the Spring-Mass Damper System

Analyzing an Impulse Response

The impulse response of a dynamic system measures how the system responds to an impulse

input signal. You define an impulse input signal in the following manner:

• Continuous systems - Also known as the Dirac delta function, a continuous impulse input is a

unit-area signal with an infinite amplitude and infinitely small duration occurring at a specified

time. At all other times, the input signal value is zero.

• Discrete systems - Also known as the Kronecker delta function, a discrete impulse input is a

physical pulse that has unit amplitude at the first sample period and zero amplitude for all other

times.

Use the CD Impulse Response VI to calculate the impulse response of a dynamic system to a

standard impulse input. Because the impulse signal excites all frequencies and the duration of

this signal is infinitely small, the impulse response is the natural response of the system

Figure 4.6 shows how you determine the impulse response of this system.

113

Page 115: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 4.6. Impulse Response Block Diagram of the Spring-Mass Damper System

Figure 4.7 shows the Impulse Response Graph resulting from this block diagram.

Figure 4.7. Impulse Response Graph of the Spring-Mass Damper System

Analyzing an Initial Response

The initial response of a dynamic system measures how the system responds to a set of non-

zero initial conditions. Use the CD Initial Response VI to determine the initial response of a

dynamic system.

Figure 4.8 shows how you determine the response of this system to an initial condition of 0.3

cm.

114

Page 116: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Figure 4.8. Initial Response Block Diagram of the Spring-Mass Damper System

Figure 4.9 shows the Initial Response Graph resulting from this block diagram.

Figure 4.9. Initial Response Graph of the Spring-Mass Damper System

Notice that the displacement begins at the initial condition of 0.3 cm.

Analyzing a General Time-Domain Simulation

A general time-domain simulation of a system involves input signals that are more general than

step, impulse, or initial input signals. Use the CD Linear Simulation VI to solve these equations

in response to an arbitrary input signal u into a system. This VI determines the response by

numerically integrating these equations at the specified time steps. You can define the time

steps with the Delta t input.

The system model can be continuous or discrete, but the CD Linear Simulation VI converts

continuous models to discrete models using either the exponential Zero-Order-Hold or the First-

Order-Hold method.

115

Page 117: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

If this conversion is necessary, you must specify Delta t, which becomes the sampling time. If

no conversion is necessary, Delta t must be equal to the sampling time of the output data u(t).

Figure 4.10 shows how you simulate the response of this system to a square wave input.

Figure 4.10. Linear Simulation Block Diagram of the Spring-Mass Damper

System Using a Square Wave Input

Notice that the CD Linear Simulation VI converts the continuous state-space model to a discrete

model using the Zero-Order-Hold method.This conversion uses a Delta t input of approximately

0.3. This block diagram bundles the state-space model and the square wave as the input to the

Linear Simulation Graph. Figure 4.11 shows the Linear Simulation Graph resulting from this

block diagram.

Figure 4.11. Linear Simulation Graph of the Spring-Mass Damper System

116

Page 118: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Using a Square Wave Input

The scale for the square wave input is on the right-hand side of the graph, whereas the scale for

the linear simulation output is on the left-hand side of the graph. You can specify any input and

use the CD Linear Simulation VI to observe how the system responds to that input.

Obtaining Time Response Data

The Time Response VIs return time response data that contains information about the time

response of all input-output pairs in the model. Use the CD Get Time Response Data VI to

access this information for a specified input-output pair, a list of input-output pairs, or all input-

output pairs of the system. Refer to the LabVIEW Help, available by selecting Help»Search the

LabVIEW Help, for more information about the CD Get Time Response Data VI.

Proportional-Integral-Derivative Controller Architecture

The PID controller, also known as the three-term controller, is the most widely-used controller

architecture. PID controllers compare the output against the reference input and initiate the

appropriate corrective action. PID controllers combine proportional P, integral I, and derivative D

compensation. Use the CD Construct PID Model VI to construct a PID controller.

The following equation defines control action for a general PID controller.

In this equation, Kc is the gain, is the derivative time constant, and is the integral time

constant. The following equation defines the error.

e(t) = R(t) – B(t)

In this equation, R(t) is the reference input and B(t) is the output.

Because the control action is a function of the error, the following equation defines the transfer

function for the PID controller.

This transfer function is improper, which means the transfer function has more zeros than poles.

You cannot physically realize an improper transfer function. You can place a pole at –1/ατd to

117

Page 119: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

make the transfer function proper. α is a small number, typically between 0.05 and 0.2, such

that the pole has a negligible effect on the system dynamics.

The Control Design and Simulation Module supports the PID controller in the following four

forms: PID Academic, PID Parallel, PID Parallel Discrete, and PID Serial. Table 11-1 shows the

equations for each of these forms.

Table 4.1. PID Controller Forms in the Control Design and Simulation Module

Each PID form produces the same result but incorporates information in a different manner. For

example, you can adjust each term independently using the PID Parallel form. The PID form

you use depends on the design decisions you make, such as how you need to manipulate the

output of the controller. Use the polymorphic VI selector of the CD Construct PID Model VI to

implement a PID controller using one of these four PID forms.

In some applications, you specify the gain in the PID Academic transfer function in terms of a

proportional band (PB).

A proportional band, defined by the previous equation, is the percentage of the input range of

the controller that causes a change equal to the maximum range of the output.

You can use the root locus and Bode design methods to determine appropriate gain values for

the PID controller.You also can determine appropriate PID gain values analytically by using the

CD Design PID for Discrete Systems VI. The following section describes how to use this VI.

118

Page 120: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Designing PID Controllers Analytically

Finding the proper values for the PID gains is a process known as tuning the PID controller. PID

tuning typically is an ad-hoc process that involves trial and error. However, the Control Design

and Simulation Module provides the CD Design PID for Discrete Systems VI. You can use this

VI to find tuples of stable PID gain values automatically for a given model or family of models.

The input to this VI is one or more discrete system models in transfer function, zero-pole-gain,

or state-space form. These models must be single-input single-output (SISO) and discrete. This

VI returns the following information:

• The boundary between the set of stable PID gain values and all

unstable gain values.

• Tuples of PID gain values within this boundary. Each tuple guarantees

closed-loop stability.

• The centroid, or average, of these tuples.

For example, consider the following discrete transfer function models H(z), I(z), and J(z).

Whereas traditional tuning provides one tuple of PID gains for one model, the CD Design PID

for Discrete Systems VI provides the set of all stable PID gains for all three models. This set is

the Stable Set Interior Points parameter of the VI.

Figure 4.12 shows an example Stable Set Interior Points output that corresponds to these

models

.

Figure 4.12. Set of Stable PID Gain Values for the Three Specified Models

119

Page 121: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

In Figure 4.12, each point on the graph represents a stable tuple of proportional, integral, and

derivative gain values. These points also satisfy any erformance criteria you specify.

This VI also finds the centroid of these points and returns the point closest to this centroid. This

point is the Design PID Gains parameter. Figure 4.13 shows the Design PID Gains output that

corresponds to the set of points in Figure 4.13.

Figure 4.13 Most Stable Tuple of PID Gain Values

Therefore, the design PID gains are 0.224462, 0.460137, and 0.108035, respectively. These

values guarantee simultaneous closed-loop stability of H(z), I(z), and J(z). You can use these

design PID gains with the PID VI, included with the LabVIEW PID and Fuzzy Logic Toolkit, to

implement a PID controller on a real-time (RT) target

120

Page 122: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 13: Create and show the transfer–function: Follow the next steps:

1. Open new VI. 2. Set the CD Construct Transfer Function Model.vi on block diagram. From function palette

choose Control Design and Simulation>>Control Design>>Model Construction>>Cd Construct Transfer Function Model.vi.

3. On SISO(Simbolic) with right click from Select Type check Single-Input Single- Output (simbolic).

4. Right click on Simbolic Numerator input, create control on CD Construct Transfer Function Model.vi. Repeat the same procedure for Simbolic Denominator as well as for Variables.

5. Set CD Draw Transfer Function Equation.vi on the block diagram , which CD Draw Transfer Function Equation.vi can be found in Control and Simulation>>Control Design>>Model Construction.

6. Right click on the Equation output terminal from CD Draw Transfer Function Equation.vi create indicator , changing his name into Plant Equation.

7. On the front panel enter the next values: Simbolic Numerator : [K] Simbolic Denominator: [k^2], [J*Rm] Variables: K 0.028 Rm 3.3 J 9.64E-06

8. Right click in Variable to selecet Display Format, and then Automatic Formatting. 9. Select Make Current Values Defalut in Edit. 10. Start the VI and follow the transfer function drawn in Plant Equation.

The solution is supposed to look like this:

Exercise 14: Create and show the same transfer-function from the exercise above using the MathScript Node Follow the next steps:

1. Open new VI. 2. Set the Mathscript Node block on the block diagram. Programming>> Structures>>MathScript

Node (if you don’t have the block , download it from the page NI)

121

Page 123: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

3. In Mathscript Node enter the next code: %Motor Model num=[K]; den=[J * Rm K ^ 2]; plant=tf(num,den) 4. Right click on the left side of MathScript Node to select Add Input. Insert K as input, right click

on the terminal na variable K select Create>> Control . Repeat the same procedure for J and Rm. 5. On the left side of MathScript add the output Plant. Right click on his terminal to select Choose

Data Type >> Add-ons>> TF Object. 6. Add CD Draw Transfer Function Equation.vi and create his indicator 7. On the front-panel enter the appropriate values for K, Rm and J. 8. In Edit tick Make Current Values Default. 9. Start the program

The solution is supposed to look like this

Exercise 15: Save the next transfer function in file

. The same function should be

then read and displayed. Follow the next steps

1. Open new VI 2. With the help of CD Construct Transfer Function Model.vi form the transfer function . 3. From Control Design and Simulation>>Control Design>>Model Construction take the block CD Write to file. 4. Start the program and save the model in some file

122

Page 124: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

5. When we want to read some model we use the block CD Read Model from File.vi 6. On the block diagram set CD Draw T.F, equation.vi and for the equation output create

indicator 7. Start the program and enter the file you want to read.

Exercise 16:In order to accomplish VI which will show the result transfer function from two

transfer functions serial connected (

;

).

Follow the next steps:

1. With the help of CD Construct Transfer Function Model.vi create the transfer functions. For the same functions, show the transfer function with the help of CD Draw T.F. Model.vi.

2. Connect both of the models of the transfer function with the Model 1 Model 2 from CD Series block.

3. From CD Series block, instead of State-space and State Space (ss and ss) take Transfer Function and Transfer Function.

4. With CD Draw TF equation.vi show the result transfer function. 5. Start the program

123

Page 125: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

The solution is supposed to look like this:

Exercise 17. To accomplish VI which will connect two transfer function with loopback (

;

1). Follow the next steps:

1. The way of solving this exercise is identical with the previous one. The only diference is in using CD Feedback.vi instead of CD Series.vi. You can find this block in Control Design and simulation >> Control Design>> Model Interconnection.

The solution is supposed to look like this

124

Page 126: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

P.S : arrows, rectangles, triangles etc. can be found in Modern Decorations with right-clicking on the front panel

Exercise 18: Using Simulation од Control Design and Simulation simulate rectangle signal and integrate the same one. Display both of the signals on graphs. Follow the next steps: 1. On the block diagram set the Simulation Loop, which you can find in Programming>>

Control Design and simulation>> Simulation .Right click on the node in Configure Simulation Parametars, as final time enter 5 and in ODE Solver select Runge-kutta 3.

2. Set integrator from Simulation>> Continuous Linear System. Select Terminal from Configuration under Parametar. As intial value create constant equal to 0.

3. Set Signal Generator from Simulation>> Signal Generation. Choose square wave with 1Hz frequence from Configuration.

4. From Simulation>> Graph Utilities>> SimTime Waveform enter two graphs. 5. From Simulation>> Graph Utilities>> SimTime Waveform enter two graphs. Connect one of

the graphs with the simulated signal, and the other one after the integrating. For grapsh check Autoscale.

6. Start the program.

The solution is supposed to look like this

125

Page 127: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 19. Simulate process with disorder without loopback. Follow the next steps: 1. Open new VI. 2. Set simulation loop on the block diagram, and inside him Tranfer Function and Transport

Delay ( while simulating you can find all blocks in Control Design and Simualtion>>Simualtion) , which can be found in Continuous.

3. Name the transfer function as process TF. With double click on the block enter the values for the numerator [2] and the denominator [1 15 50].

4. Copy the TF process and Transport Delay .Name the second transfer function as disorder (parametars of numeratot and denominator in this case are identical.

5. Set adder block , which can be found in Signal Arithmetic. Connect the block so you can sum up both the outputs from the Transport Delay blocks.

6. Set SimTime Waveform graph, connect it with the output of the adder. 7. Set Step Signal from Signal Generation on the left side of the the block disorder. For initial

value , final value and step time enter values equal to 0. 8. Copy this last block on the left side of the block process TF. As final value enter 1. 9. Double click on the left terminal of the loop, as final value enter 50. 10. Choose Autoscale for the graph

126

Page 128: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

11. Start the program to simulate the reaction of the process, while to simulate reaction of the disorder you need in the stop signal block the final value to be 0 for TF process, and 1 for the disorder

The solution is supposed to look like this:

Exercise 20: In the previous exercise add PID feedback control of the loop. Follow the next steps:

1. Open the previous exercise.Delete the connection between step signal and the transfer function of the process.

2. Add second adder , which will take out the signal obtained in the output of the first adder from the step signal.

3. Now you can add PID controler (in labview can be found different types of PID controler but in this example a special controler is used, which you can find in the solved exercises).

4. In Select Vi choose PID controler.Connect the same one with the output of the second adder. 5. In the PID controler as Parametar Source choose terminal. 6. For each of the terminals create control. 7. The type of the control can be replaced with right click on the control itself (front panel ) with

replace. 8. Now we can perfom the simulation with final value 1 in one of the blocks step signal.

The solution is supposed to look like this

127

Page 129: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

Exercise 21:Determine the position of the mass m in terms of the time.

Follow the next steps:

1. Set Simulation Loop.The final time can be 10 s. Maximum Step Size should be 0.01. 2. From Signal Arithemtic take Multiplication function.Change the lower symbol with

symbol. 3. Set two integrators and two grapshs (SimTime Waveform). 4. Create controls F/m in the block for determinating the acceleration. As force enter -9,8 and for

mass 1. 5. Start the program. Obviously, in reality the mass hanged on the spring oscillates up and down (

this one can be simulated in Labview)

The solution is supposed to look like this

128

Page 130: 1. Introduction to LabVIEW - sau.ac.me intro.pdf · LabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is a platform and development environment for a visual

129