ME-546 Computer Aided Manufacturing

INTRODUCTION TO LABVIEW SOFTWARE

Topic:

Data collection, processing and telemetry encoding for remote process control.

Objectives:

  1. Gain familiarity with typical software for data collection.
  2. Learn to set-up virtual instruments.
  3. Discuss possibilities for process control.

Deliverables:

  1. Complete working copy of your program for problem 5.
  2. Printout of your team's Panel and Diagrams for Problem 5. (Print in color/grayscale!!)
  3. Discussion of the features, uses, problems, possibilities, etc. of Labview used or discovered during the problem set.
  4. One or more clearly indicated extra features in Problem 5 that enhance the capabilities of this VI. An example is the Toggle Switch operating the temperature scale °F to °C conversion in the second problem diagram in this handout. Make up your own.

Equipment:

  • PC
  • Labview hardware
  • Labview software

Basically, LabVIEW is a programming language like Fortran. It was built primarily for data acquisition The essential difference is, instead of using words, LabVIEW uses pictures. For example, in Fortran:

X * Y = Z

In LabVIEW,

where EXT means EXTended precision real number.

LabVIEW has two parts: the panel and the diagram. The panel is where the user controlled or observed actions take place. This is like the computer screen when running a Fortran program or the control panel at a power station. The diagram is the guts of the program, where the numerical manipulation goes on. This is like the actual Fortran code or the piping and valves of a power station. If you close the panel, you close the program (in other words, the panel must be open for the diagram to be open). To switch between the two, use Control-f. This means press Control and f at the same time.

To run the program either use Control-r or click in the arrow symbol on the upper bar. If there is a broken arrow, there is an error in your program. Click on the broken arrow to find out what is wrong with your program. To manually stop a run, hit the stop sign shaped symbol on the upper bar. This is like a control-c for a Fortran run. Different types of data are color coded; light blue is an 8 bit integer, for example.



Some important terms:

VI (Virtual Instrument): These are like subroutines in Fortran. Many of the most useful are already in the LabVIEW library, and you can make your own. They only appear on the diagram.

Click: Quickly press and release the mouse button.

Press: Press the specified mouse button down and hold it down.

Finger: This is the cursor with the index finger extended. It is used for changing values of control, switching switches, etc. It appears mostly on the panel.

Hand: This is the cursor that looks like an open hand. It is used for moving things around the screen.

Letter: This is the typing cursor. It allows you to type like a normal typewriter.

Wire: The spool cursor. It is not used on the panel, but is used extensively on the diagram to 'wire' (connect) VI's. To release a wire that you did not want, double click. To remove bad wires, Control-w

Tab: The tab (key on the keyboard) allows you to toggle between the finger, hand, letter and wire cursors.

Control: These are user-interfaces with the program.

Indicator: These display the results of the program.

Boolean: A true-false operator.

Cluster: A 'bundle' of data. Instead of (X,Y,Z) with three values, a bundle is more like (XYZ). A bundle may contain mixed types of data, like strings and numbers.

Graph: Requires an X and a Y operator and plots Y vs. X. When wiring to a graph on the Diagram, a cluster input is required.

Chart: Graphs an Y for each reading of Y, as in temperature (Y) versus time.

Brush: This is the brush icon, (small pictures), this is used to paint the screen in pretty colors. Must be manually selected from TOOLS.

Arrays: These must be selected for their type (numeric, Boolean, string, cluster) with the Control key.

Select: when you select an object, click to highlight it and then let go.

Move: To move an object, using the hand, press the mouse button over the object and move the mouse, releasing when you have reached the area you want it to be in.

Arrow, Broken Arrow: This refers to the arrow symbol in the upper bar, second to the right. If it is complete, the program is OK. If it is broken, the program will not run.

The 'power key' is the Control key. To get additional menus for any object, press the right-most mouse button.

Control-C This is the copy Control. It copies whatever is selected, into a part of the computer's memory, called the clipboard. You then can paste these anywhere using Control-v, below.

Control-V This 'pastes' (or deposits) whatever is in the buffer wherever you have last clicked.

Control-T (tile) This puts the diagram and the panel side by side on the screen. Whenever you open a LabVIEW file, you will have to use this Control to bring up the diagram next to the panel.

Control-E Toggles from panel to diagram (to panel). If you make the panel or the diagram as large as the screen, you will have to use this key to switch between the panel and the diagram.

Control-B Removes bad wires.

Control-S Saves the program.

Control-H (help window) Displays wiring connections and names for icons touched with the wire cursor. The help window is color coded to match the type of input/output expected.

Control-Q Quits the program.

On the following pages are four problems that will help you become familiar with LabVIEW.

 



Problem 1: Getting started

(refer to Figure 1)

Suppose we wish to graph:

y = A sin (BQ)

where A and B are variable parameters.

1. Turn on a PC.

2. Open LabVIEW 4.0, it should be a desktop icon: LabVIEW may take a minute to load. You are looking at Untitled 1 Panel. Press Control-T. This will display the Panel and the Diagram side by side.

3. Icons for internal programming elements are found on the functions or controls toolbars. Only one of these will show up at a time. These may be called up using the right-most mouse button while on the desktop. They may be tecked open using the little push-pin in their upper-left corners. Functions selected from the functions toolbar only go onto the diagram; controls only on the panel. Each toolbar contains icons which themslves reveal other icons. Press the mouse button and hold down until finished with the entire selection. A selection is made by releasing the mouse button.

4. Go to NUMERIC on the controls toolbar and select the first icon, (small picture) the Digital Control box. Move your cursor into the panel and click where you wish the icon to be placed. Notice that every item you place on the panel has a counterpart on the diagram. Label this box "A VAR" (for variable A) Just start typing right after the icon has been placed. This control will vary the amplitude. Put the cursor on the panel (left) side. Find the hand cursor. If you have the arrow cursor, press the tab button until you get the hand cursor. Using the hand cursor, move this box to the upper left by clicking and dragging the icon NOT THE LABEL! Similarly, place a box titled "B VAR" in the upper right.

5. Go to CONTROLS. Go to BOOLEAN and select the round button. Name this "ON/OFF". Place in the upper middle.

6. Go to CONTROLS. Go to GRAPHS and select WAVEFORM CHART. Name the chart "Wave". Move the chart to the middle. This is where your sine wave graph will appear.

7. Place the cursor over the diagram and click. This makes the diagram the active window and this is where you will program. Go to FUNCTIONS. Go to STRUCTS & CNSTS (abbreviation for STRUCTURES AND CONSTANTS). Select the while loop.

8. Move all previous icons to upper portion of the screen.

9. Using the arrow cursor, move slowly across the lower corner of the while loop until the hand turns into a right angle. Press and drag the corner out to a good size (about a half of the diagram screen). DO NOT COVER ANY ICONS YOU JUST CREATED!

10. Using the arrow cursor, place all the icons on the screen inside the while loop as follows.

10.1 Place the "ON/OFF" icon in the lower right next to the loop arrow.

10.2 Place the "Wave" icon in the middle right.

10.3 Place the "A VAR" icon in the upper middle.

10.4 Place the "B VAR" icon in the upper left.

11. Go to FUNCTIONS. Go to NUMERIC. Go to TRIG and select the Sine. Place this icon in the middle of the while loop.

12. Go to FUNCTIONS. Go to NUMERIC and select the multiply icon. Place this in the middle left, between "B Var" and the boxed "i".

13. Repeat the previous step, but place the multiply icon between the Sine icon and the "Wave" icon. Press Control-S to save the program (please call it "your name_1.vi").

14. Now that all the pieces are in place, it is time to wire them together. Notice that the arrow symbol on the upper bar is broken; your program does not work. Place the cursor over the diagram. Press the tab button several times. Notice the arrow cursor change to a letter cursor and then a wire cursor. You wire with the wire cursor.

14.1 Move the spool cursor to the ON/OFF icon (it will be blinking). Click once on the "ON/OFF" icon and then on the loop arrow. This will wire the "ON/OFF" button to the while loop's operator. A while loop executes as long as the Boolean's value is true.

14.2 Press Control-h (help window) to see the icon terminals. Move the wire cursor to one of the multiply icons. Notice how the multiply icon is split into three parts and what each part represents (X,Y,X*Y). Do the same to the Sine icon, and notice it is in two parts (x and sin x).

14.3 Click on the "B VAR" icon and then on the "y" part of the multiply icon below it, thus wiring the two together.

14.4 Click on the boxed "i" in the lower left and then on the "x" part of the same (left) multiply icon. The "i" counts iterations, and will serve as our theta variable.

14.5 Click on the "x*y" part of the multiply icon and then on the x part of the Sine icon.

14.6 Click on the "A VAR" icon and then on the "x" part of the other multiply icon.

14.7 Click on the sin x part of the Sine icon and then on the "y" part of the right hand multiply icon.

14.8 Click on the x*y part of the multiply icon and then on "Wave".

14.9 Notice the Arrow symbol in the upper bar is no longer broken: your program should work!

14.10 Press Control-S to save the program.

15. Click the cursor on the panel's side again (left side). The following steps will allow you to run your program.

16. Press the tab button to change the wire cursor to a finger cursor. You can remove the help box by clicking on the small box in the upper left corner of help window.

17. Move the finger cursor to the "ON/OFF" button and press it. The button is now on. (The default setting for any Boolean is false; your program will not run until it is true.)

18. Move slowly across the "A VAR" indicator's icon until the finger cursor turns into a letter cursor (vertical line with a split on top and bottom). Click once and move letter cursor to the one's place using arrow keys and enter a 1 in the "A VAR" box then hit return.

19. Move slowly across the "B Var" box until the finger cursor turns into a letter cursor. Place the cursor over the icon and click the right mouse button, choose choose Data Range... and make the increment 0.1. Click on this numeric contol's up arrow and enter a 0.1 in the "B VAR" box.

20. If there are no mistakes you may now click on the "ON/OFF" button and then click on the Arrow symbol on the upper bar to run your program. If it does run, click on the graph with the right mouse button, and select Autoscale Y.

21. Change the values of A and B (this can be done by using the small arrows on the "A VAR" and "B VAR" boxes or by clicking over them and typing) and observe how the wave changes. What do large values of B do to the graph? What do zeros do?

22. To stop, click on the "ON/OFF" button. To restart, be sure the "ON/OFF" button is 'on' (depressed).

23. Use the tab key and select the brush. Click on an object to paint your panel, chart or whatever else you desire.

24. LabVIEW is very fast. You should slow down your program to let you see what is being graphed.

24.1 Go to diagram side and click. Go to FUNCTIONS. Go to TIME & DIALOG.

24.2 Select the 'wrist watch' icon in the second column, called Wait (ms). Place it in the lower middle of the while loop. (You must first return to the hand cursor)

24.3 Place the cursor on the new icon and press the right-most mouse button. Select "create constant". Type in a 10.

25 Run as before.

26 Press Control-S to save program.



Figure 1 - Desired Panel and Diagram



Problem 2: Data Acquisition

Now that you are familiar with LabVIEW, we will do a data acquisition example. This is what LabVIEW was designed to do. The problem is to take a thermocouple reading and display the temperature on the screen.

Open a New VI under File... New...

Panel set-up:

  1. Create an ON/OFF switch by going to Controls-Boolean-Round Button
  2. Create a VOLTAGE chart by going to Control-Graph-Waveform Chart
  3. Create a TEMPERATURE chart by going to Control- Graph-Waveform Chart
  4. Create CURRENT ROOM TEMP control with an assumed room temperature value of 22°C by going to Control-Numeric-Digital Control

Diagram set-up (Figure 2 gives the desired result):

1. Create a sequence structure by going to Function-Struts & Cnsts-Sequence (make about 3/4 size of diagram box).

2. Enlarge the sequence by tabing to the arrow tool and and clicking and dragging its corners out.

3. Create an Analog Input by going to Function-Data Acquisition-Analog Input-AI_Sample_Channel.

4. Create a while loop by going to Functions-Structs & Cnsts-While Loop (place inside of sequence structure).

4.1 Drag the While loop open far enough to fit every node icon inside.

4.2 Control-S to save program

5. Wire the ON/OFF button to the looped arrow in the bottom left of the while loop.

6. Create a constant for the device terminal of the AI_Sample_Channel icon by using the right mouse button and enter 0 (Use Control H to see the terminals).

7. Create another constant for the "channel" terminal of the AI_Sample_Channel icon and enter 0 (Use Control H to see the terminals).

8. Wire the VOLTAGE chart to the AI_Sample_Channel icon (voltage terminal)

9. Create a Formula Node by going to Function-Structs & Cnsts-Formula Node. Type in the following formula (don't forget the semicolon at the end!):

t=0.226585+x*(24152.109+x*(67233.4248+x*(2210340.682+x*(-860963914.9+x*(48350600000+x*(-1184520000000 +x*(13869000000000 +x*-63370800000000)))))));

This formula linearizes the voltage from a J-type thermocouple and converts it to °C.

Figure 2 - Diagram Sequence Frame 0 for Example 2

10. Create the input and output terminals for the formula nodes by placing the finger tool on the edge of the formula box and using the right-most mouse button. Use the typing tool to label the terminals x and t.

11. Wire directly to the wire going to the voltage graph and attach this to the x terminal of the formula node.

12. Create an add function by selecting Function-Arithmetic-Add

13. Wire the t terminal of the function node to the x terminal of the add icon and a Room Temp constant of 22 to the y terminal of the add icon. Wire the x+y terminal to the temp graph.




Problem 3: Timing

Now let's add a timer to the VI we wrote in Problem 2.

Panel set-up (Click on the Panel):

1. Create a Controls-Numeric-Digital Indicator and label it TIMER, and move it into the While loop.

Diagram set-up (Click on the diagram) (Figure 3 gives the desired result):

2. Create a tick count by going to Functions-TIME & DIALOG-Tick Count (place outside the while loop but inside the sequence structure)

3. Create a tick count by going to Functions-TIME & DIALOG-Tick Count (place inside the while loop)

4. Create a subtract icon and a divide icon and place them in the While loop.

5. Wire the outside Tick Count through the While loop's edge to the subtract (y block). Wire the inside Tick Count to the subtract (x block). Wire the result from the subtract to the divide (x block). Wire a constant numeric of 1000 to the divide (y block). Wire the result from the divide to the digital indicator.

6. Make sure there is no broken arrow in upper diagram. If there is, click on the run arrow and then the error description and it will be highlighted. Use Control-S to save.
7. For each chart, click with the right mouse button and select Y Axis... Autoscale Y.

Figure 3 - Frame 0 for Example 3
 


Problem 4: File Output

Now write the data being acquired from Example 3 to a file on a floppy disk.

Diagram set-up (Figure 4 gives the desired result):

1. Create a build array icon by going to Functions-Array -Build Array (place outside of while loop but inside sequence structure).

2. Press Right mouse button while on left side of build array.

3. Wire TIMER (Digital Indicator) to the build array (upper element). Wire the TEMPERATURE (waveform chart) to the build array (lower element) by wiring through the edge of the while loop.

4. Press Right mouse button on the black square on side of while loop created where wire goes through side. Select Enable Indexing. Repeat for other black square and select Enable Indexing.

5. Press Right mouse button while on right edge of sequence. Select Add Sequence Local.

6. Wire build array (array with appended element block) to the new sequence local.

7. Press Right mouse button while on the left side of sequence control. Select Add Frame After to create frame #1.

8. (#1 frame) Select Functions-File IO - Write to Spreadsheet.vi and place it in frame #1.

9. Create a constant for the Transpose terminal of the Write to Spreadsheet.vi and make it "T".

10. Wire the incoming array from the sequence local to the 2D Array terminal of the the Write to Spreadsheet.vi.

11. Create a constant for the Path terminal of the Write to Spreadsheet.vi and enter "a:\tempdata".

12. If there are no mistakes, you may now depress the ON/OFF button and then click on the Arrow symbol on the upper bar to run your program. Keep the run time brief or slow your program down because the file will quickly get very large .

13. Once you run your VI and have stopped it using the ON/OFF button and not the Stop icon, you should go out of labview and launch the file called tempdata that will be on the floppy disk in drive a.




Figure 4 - Frame 0 and 1 for Example 4



Problem 5. Telemetry (Optional)

Telemetry is the word used to describe remote measurement. Remote weather monitoring is often accomplished by connecting a radio transmitter to a sensor at some remote site. The radio signal is modulated (altered) by a wind or temperature sensor output to reflect the changes in the monitored quantity. The signal is then broadcast to a receiving station and decoded. The signal's amplitude or frequency can be modulated to produce an AM or FM broadcast respectively. Connect the output of the temperature measurement VI you created in Problem 4 to the A or B Variable of a sine wave generator like the one in Problem 1. Run the combined VI and heat and cool the thermocouple by alternately holding it between your fingers and releasing. Notice the changes in the wave depending on whether AM (Avar) or FM (Bvar) modulation is used.

Home | Mission | Courses | Personnel | Sponsors | Student Research | Improving Education | Product Realization
Research Facilities | Training Courses | Links | Newsletters | Rapid Prototyping and Design Services

Department of Mechanical Engineering | San Diego State University

This page was designed by Bryan J. Christiansen