California University of Pennsylvania

Department of Applied Engineering & Technology

Electrical Engineering Technology

First Experience With LabVIEW

Spring 2012

Objective:

The objective of this activity is to have a firsthand exposure to LabVIEW. After completing the activity, a student should be aware os some of the basic features of the software.

LabVIEW Basics

LabVIEW is a graphical programming language one can use to solve various problems. Having a strong problem solving skills and a strong background in mathematics and engineering/engineering technology principles are essential to create solutions in LabVIEW LabVIEW stands for: Laboratory Virtual Instrument Engineering Workbench (LabVIEW).

In order to be successful, it is important to develop habits of planning, writing proper codes, and documenting code.

A- Navigating LabVIEW

1- Click on Windows task bar >All Programs>National Instruments>LabVIEW 2010>LabVIEW to load the program

2- Click Start LabVIEW (not the Robotics)

3- on LabVIEW’s Getting Started window, click File>New VI

4- Here is the first part of the LabVIEW environment. You should see two windows:

a) Front Panel, b) Block Diagram

Front Panel is the user interface part of the GUI program (Controls and Indicators). The Block Diagram contains the code.

5- In the Front Panel, right click the mouse button. A Controls Palette comes up. Explore the contents of this palette.

6- In the Block diagram windw, right click the mouse and you should get a Functions Palette. Explore its contents.

B- First Simple LabVIEW Program.

To explore some of the vry basics of LabVIEW, let us work together on building a function generator with a scope and a DMM.

Steps:

1- on the Front Panel Build the following as shown:

- right click>Numeric>Knob

- Double click on the word knob and change it to Amplitude.

- Similarly, create another knob and call it Frequency. Double click on the 10 value in the frequency ranges and change to 1k.

- Right click on the Front Panel>Graphs>Waveform Graph. Place it as shown. Resize the graph.

- Right Click>Boolean>.Stop Button

2- In the Block Diagram, do the following:

- Right click>Structures>While Loop

- Make sure all of the objects are inside the while loop

- Connect the Stop Button to the Stop condition of the While Loop

- Right Click>Express>Signal Analysis>Simulated Signal

- Right Click>Signal Analysis>Waveform Generation>Basic Function Generator

- Place it in the While Loop.

- While still in the Block Diagram, click <CTRL> -H together . A Context Help Window appears.

- Move the mouse over the Basic Function Generator and see the explanation of inputs and outputs as shown in the Context Help Window.

- Move the Amplitude icon below the Frequency icon.

- In order to connect as shown, as you move the mouse over the Basic Function Generator, the arrow changes to a wiring spool. At this point, you are ready to connect. Click once and move the wire to the desired connection point.

- Save the VI on your network drive as lab6a.vi

Move to the Front Panel.

- Right click on the graph>X-Scale> Un-check Auto Scale

- Double Click on the maximum value in the time domain( x –axis) on the graph and change it to 0.01.

- Change the amplitude to near 4 volts.

- Right click on the frequency knob>Representation>I64

- Set the frequency to 0

-- Run the VI by clicking on the arrow on the top left corner

-- VERY SLOWLY increase the frequency. You notice the waveform starts as a sine wave, then it starts to distort. At some frequency an error message appears!!

EXPLAIN the cause of this error :------

- You guessed it correctly, the sampling rate has to be at least twice he input frequency. By default the sampling rate is 1KHz.

- Let us make two more modifications to the Basic Function Generator.

Open the Block Diagram window.

- move the mouse over the Baisc Function Generator until you see a wiring spool over the Sampling Information. At that point, Right click>Create Control

- Move the mouse over the same VI until you see the wiring spool over the Signal Type. At this point>Right Click>Create Control

- Similarly, create a control for the Duty Cycle.

- Organize the icons as shown.

Move to the Block Diagram

- Rearrange the icons and change the values of the Sampling information as shown:

Save the VI

- Run and play with the VI, obtain different waveforms, change the duty cycle for the square wave and observe the scope information.

C- Adding Some Basic Signal Analysis

On the Block Diagram, do the following:

-Right click>Signal Processing>Waveform Measurements>Basic DC and RMS.

Connect as shown

( on the DC-RMS measurement VI, move the cursor until a wiring spool appears at the DC > right click> create INDICATOR. Repeat for the RMS measurement.)

Move to the Front Panel,

- Rearrange the icons as shown.

- Run the VI and observe the DC and the RMS content of each waveform. Verify the correctness of the results.

- Observe how the DC content of the square wave changes as the duty cycle changes.

- In the Front Panel, Right Click>Graphs>Waveform Graph.

- Double click on the word Time on the x-axis and change it to Frequency.

Move back to the block diagram.

Let us add a spectrum analyzer.

- Right click>Express>Signal Analysis>Spectral

- A dialog window comes up. Complete it as follows:

- Make the two indicated choices for the Selected Measurement and the Result. Then OK

- Connect the items as shown below

D- Organizing the Results.

- On the Front Panel, Right Click>Containers>Tab Control

- Place it anywhere there is a free space.

- The Tab should have Two Tabs (Pages)

- Move the first graph and place it on the first page of the Tab Control (do not worry about

resizing ) Click on the second Page and move the second graph to it.

- Re-organize.

Save the VI.

Now, play with the VI, notice the frequency spectrum for different waveforms.

Which of those waveforms has the strongest spectrum?

D- Exploring aa PID

- on the front panel, click >Help>Find Example.

- In the Example Window, click the Search Tab> type PID

- Double click on PID. A whole family of PIDs appear. Navigate to the Manual PID Control.

- Double Click it. Run the VI. While the VI is running, change the set point and notice how the controller quickly meets the desired value. The Process Variable is the output. Of course, make sure the tuning is set to automatic and that the Set Point is turned off so it can be changed.

- Find other examples and enjoy.