Using NI LabVIEW 2009 - National...

48
Build Your Own Computer Based DAQ System Using NI LabVIEW 2009

Transcript of Using NI LabVIEW 2009 - National...

Page 1: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

Build Your Own Computer Based DAQ System

 

 

Using NI LabVIEW 2009   

Page 2: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

Exercise 1: Acquire a Signal Exercise Overview Objective  To create from scratch a data acquisition system capable of measuring the ambient Temperature, conducting simple analysis and then presenting the results to the user.  

Goals  When you have completed this exercise, you will: 

• Know how to configure a data acquisition device  • Know how to use the DAQ Assistant and take measurements with NI LabVIEW 

 

Exercise Instructions 1. Open NI LabVIEW 2009 and press <Ctrl‐N> to open a blank VI. 

2. Press <Ctrl‐T> to tile front panel and block diagram windows. 

3. Pull up the Functions Palette by right‐clicking on the white space on the LabVIEW block diagram window. 

4. Move your mouse over the Express » Input palette and click the DAQ Assist Express VI. Click again on the white space of the LabVIEW block diagram to place the DAQ Assistant VI. 

Page 3: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

5. The Create New Express Task… window appears:

6. To configure a temperature measurement application with a thermocouple, click on Analog Input » Temperature » Thermocouple. Click the + sign next to the cDAQ1Mod1 (NI 9211), highlight channel ai0 and click Finish. This adds a physical channel to your measurement task. 

7. Change the CJC source to Built In and Acquisition Mode to Continuous. Click the Run button. You will see the temperature readings from the thermocouple in test panel window.

 

Page 4: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

8. Click OK to close the Express block configuration window to return to the LabVIEW block diagram. 

9. Notice that LabVIEW automatically creates the code for you for this measurement task. Click Yes to automatically create a While Loop. 

 

10. Right‐click the data terminal output of the DAQ Assistant Express VI (the blue output arrow on the right side) and select Create » Graph Indicator. 

11. Notice that a graph indicator is placed on the front panel. 

12. Your block diagram should now look like the figure below. The while loop automatically adds a stop button to your front panel that allows you to stop the execution of the loop. 

 

 

 

 

 

 

 

Page 5: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

13. Rather than displaying our data in a graph indicator, we want to display our temperature readings in a thermometer indicator. To do this, go to the front panel by pressing <Ctrl‐E>. Right‐click the graph indicator and select Replace. The Controls palette will appear. Select Modern » Numeric » Thermometer. The thermometer indicator should now appear instead of the graph indicator. 

14. Also, right‐click on the stop (F) button and select Replace. The Controls palette will appear. Select Boolean » Stop Button. 

 

Page 6: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

15. Modify the thermometer indicator by right‐clicking it and selecting Properties. On the Appearance Tab, change the Label to Temperature. 

On the Scale tab, change the Minimum to 20 and the Maximum to 30. 

 

 

 

 

 

 

 

 

 

 

 

Click OK when you are finished. 

Page 7: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

16. Switch to the block diagram. Expand the While Loop. Your block diagram should now resemble the following illustration. 

 

17. To perform analysis on your data, select the Express » Signal Analysis » Statistics Express VI and place it on your block diagram. 

Page 8: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

18. A properties window will appear. Make the following selections and click OK. 

Statistical Calculations: Arithmetic Mean 

Extreme Values: Maximum, Minimum 

 

 

 

 

 

 

 

 

 

 

 

19. Connect the data output of the DAQ Assistant VI to the Signals input of the Statistics VI.  

 

 

 

 

 

 

 

 

 

 

Page 9: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

20. Right‐click the Arithmetic Mean output of the Statistics VI and select Create » Numeric Indicator. This will create a numeric indicator on the front panel that will display the mean. Repeat this step for both the Maximum and Minimum outputs of the Statistics VI. Your block diagram should resemble the following.  

21. Switch to the front panel and rearrange your controls and indicators to resemble the following. 

 

22. Save the VI in the C:\Seminars\Taster Day\Exercises folder by using the File menu and name it Exercise1a.vi.

Page 10: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

23. Run the VI. Hold the thermocouple between your fingers to raise the temperature. Notice the change in temperature on the thermometer. If you are not seeing enough of a temperature fluctuation, stop the VI and decrease the range on your thermometer indicator. 

24. Click the STOP button on the front panel when you are finished. 

25. Close the VI. 

End of Exercise 1

Page 11: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

Exercise 2: File I/O in LabVIEW Exercise Overview Objective Log data to a file using LabVIEW. 

Goals When you have completed this exercise, you will: • Know how to use Write to Measurement File express VI and how to log data to a file using 

LabVIEW. 

Exercise Instructions 1. Open the VI from Exercise 1a (navigate to C:\Seminars\Taster Day\Exercises). 

2. Right‐click on the block diagram and select Express» Output» Write to Measurement File and place it inside the While Loop on the block diagram. 

 

 

Page 12: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

3. A configuration window will appear. Enter the following parameters and click OK. 

4. Wire the output of the DAQ Assistant Express VI to the input of the Write to Measurement File Express VI.   

5. Your block diagram should now resemble the following figure.

Page 13: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

6. Save the VI in the C:\Seminars\Taster Day\Exercises folder by using the File menu and name it Exercise1b.vi.

7. Run the VI momentarily and press STOP to stop the VI. 

8. Your file will be created in the folder specified.  

9. Open the file using Microsoft Office Excel or Notepad. Review the header and temperature data saved in the file.  

10. Close the data file and the LabVIEW VI.  

End of Exercise 2

Page 14: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

Exercise 3 (Optional): Automatic Code Generation in LabVIEW Exercise Overview Objective

Create DAQmx code from the DAQ Assistant. 

Goals

When you have completed this exercise, you will: • Know how to generate code automatically from the DAQ Assistant. • Have experience using some of the NI‐DAQmx VIs. 

Exercise Instructions 1. Open the VI from Exercise 1a (navigate to C:\Seminars\Taster Day\Exercises). 

2. Delete all the functions and terminals from the block diagram except the DAQ Assistant. Delete all the wires as well.  

3. Right‐click on the DAQ Assistant and select Generate NI‐DAQmx Code.  

Page 15: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

4. NI‐DAQmx will now generate LabVIEW code using the NI‐DAQmx API. Your block diagram should now resemble this: 

 

5. Double‐click on the configuration VI (shown below) that NI‐DAQmx generated for you on your block diagram 

 

6. The block diagram of the configuration VI should appear as shown below. This is an example of how you can use the DAQmx VIs if you need to create customised DAQ code that includes features beyond those offered by the DAQ Assistant. 

 

 

Page 16: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

In this block diagram, you will see 3 SubVIs: 

        DAQmx Create Task.vi 

 

           DAQmx Create Channel.vi 

 

  DAQmx Timing.vi 

 

To learn about each VI, hover your mouse over each one and press <Ctrl‐H>. This will bring up the Context Help which explains the parameters and functionalities of each VI. 

7. Close the VI and do not save any changes. 

 

End of Exercise 3  

 

Page 17: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

Exercise: Parallel For Loop  

The Parallel For Loop is new functionality added to the original For Loop in LabVIEW 2009.  This new functionality, also known as “loop unrolling” allows you to distribute individual iterations of a For Loop across multiple processors, without rewriting your code. Designed to enhance your ability to fully utilize multicore processors, this feature further simplifies parallel programming within LabVIEW. 

Compare Parallel For Loops with a Single For Loop 1. Launch the Parallel For Loop exercise by clicking on the appropriate icon. 

2. A VI opens designed to help demonstrate the speed improvements possible with the Parallel For Loop by performing a point‐by‐point FFT on our data in a parallel For Loop and then in a serial For Loop, and then compare the differences. 

3. Switch to the Block Diagram 

4. Change one of the For Loops to run in parallel. 

a. Right click on the For Loop beneath the title FFT on Large Array with Multiple Loops. Select Configure Iteration Parallelism… 

b. Place a check mark next to Enable loop iteration parallelism 

c. Increase the number of generated parallel loop instances to two. 

d. Click OK. 

e. Notice the new “P” glyph has been added to the For Loop border 

5. Add the new CPU Information (Functions » Application Control » CPU Information) to the left of the For Loop. Wire the Number of logical function processors output from the CPU Information function to the new workers node of the For Loop. This new function is designed to give you programmatic access to information about your computer: such as logical processors, memory cache, threads, etc. 

 

Page 18: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

6. Return to the Front Panel and run the VI. 

7. Note the Speed Improvement with Parallel Loops has increased significantly.  

Find Parallelizable For Loops in Existing Code 

8. LabVIEW 2009 also includes an analyzer tool that you can use on your existing code to identify For Loops that can take advantage of this new functionality.   

9. From the Toolbar, choose Tools » Profile » Find Parallelizable Loops…  

10. You can use this functionality to analyze your existing code. 

11. Click Done to exit the results window.  

Page 19: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 Synchronising Data with 3D Model 

 

 

Scenario:   You are an engineer in a company that produces high‐end running shoes and you need to validate the latest shoe model for foot comfort. You have already created a test sock with a matrix of pressure sensors on its sole and you have acquired preliminary data readings on all those sensors for a single step in your latest shoe. You hear that the latest version of DIAdem has the ability to project these pressure readings onto their correct locations in the CAD model you already have of your test athlete’s foot. You decide to download the DIAdem evaluation version and check it out. You will first manually assign a few strain channels to CAD model nodes to get an idea how much work that is. Then you will find a similar example that ships with DIAdem and run it to see what the finished synchronisation could look like. 

 

 

7.1 You need to start by emptying the Data Portal of data. Click on the NAVIGATOR tab at the top left of your screen to switch to the NAVIGATOR panel, then click on the “Delete Internal Data” icon at the top left of your screen to delete any data currently loaded in DIAdem. Notice that now the Data Portal to the right of the screen is empty. 

 

Page 20: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

You remember that your data file name starts with “View_3D” and to save time you decide to search for it using the DataFinder. Type in “View_3D” in the DataFinder simple search and click on the “Search” button to run the query. 

 

 

 

7.2 Now that you have found the file with the data from your pressure sensor matrix, drag the file from the search results list into the Data Portal to load this file into DIAdem. 

 

   

Page 21: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

7.3 The first step in visualising your pressure matrix data is to plot all the sensor traces. Click on the large “DIAdem VIEW” icon at the left of your screen to switch to the VIEW panel. 

 

 

 

7.4 Click on the “New Layout” icon at the top left of your screen in order to clear the current VIEW layout, so that you can create your own from scratch. 

 

   

Page 22: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

7.5 You want to have the 3D model on the top half of your screen and the data traces on the bottom half— there happens to be a template just like this you can use. Click on the “Assigned Worksheet Partitions” icon at the left of your screen, then select the “3D Model/2D Axis System” option. 

 

 

 

7.6 Now drag the “Pressure channels” group from the Data Portal at the right of your screen onto the lower VIEW area to graph them. 

 

   

Page 23: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

7.7 Now you see all 21 pressure sensor traces as coloured curves jumbled together on the 2D graph in the lower VIEW area. This doesn’t tell you much about the pressure distribution on the athlete’s foot in the shoe. In order to get a much clearer perspective on the pressures felt on the athlete’s foot, right‐click on the upper VIEW area and choose the menu “Select 3D Model…” to load in a CAD model of the athlete’s foot, onto which you will map the sensor data. 

 

 

 

7.8 Click on the “[…]” button in order to browse to the file containing the CAD model of the athlete’s foot. 

 

   

Page 24: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

7.9 Select the “View_3D_Foot.wrl” CAD model from the DIAdem example folder. If you took all the defaults when installing DIAdem, the example folder is at 

“C:\Program Files\National Instruments\DIAdem 11.1\Examples\Documents”  

If, on the other hand, you are in an official National Instruments seminar, look in “D:\Program Files\National Instruments\DIAdem 11.1\Examples\Documents” 

 

 

NOTE: By default DIAdem looks for 3D CAD model files in a different “Documents” folder. If you don’t see the “View_3D_Foot.wrl” file, double‐check that you are really looking in “Program Files\National Instruments\DIAdem 11.1\Examples\Documents”. 

 

 

7.10 Click on the “OK” button to accept this 3D CAD model file selection. 

Page 25: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

 

7.11 Click, hold and drag your mouse to rotate your foot model so that you see only the bottom of the foot. This will take several mouse nudges in all. 

 

 

7.12 Now it’s time to drag the first curve onto a node in the foot model. First click on the “Time” channel, then click on the “123” icon to the left of the “Pressure000” channel. This will highlight both the X and Y channels of this curve. 

Page 26: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

7.13 Now drag both the highlighted “Time” and “Pressure000” channels onto a pink model node near the top middle of the foot, where you happen to know that sensor “000” was physically located in the test shoe. 

 

Page 27: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

7.14 When you release the mouse over the pink model node, you are prompted to select the way in which the model is going to show that sensor’s values. Choose the “Coloring” menu to show the sensor values as colour changes at that point. 

 

7.15 Click on the “Time” channel, then click on the “123” icon to the left of the “Pressure114” channel. This will highlight sensor 114’s X and Y channels. 

Page 28: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

 

7.16 Drag both the highlighted “Time” and “Pressure114” channels onto a pink model node near the top right of the foot, where you know that sensor “114” was physically located in the test shoe. Choose the “Coloring” option as before. 

Page 29: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

7.17 Click on the “Time” channel, then click on the “123” icon to the left of the “Pressure112” channel. This will highlight sensor 112’s X and Y channels. 

 

Page 30: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

7.18 Drag both the highlighted “Time” and “Pressure112” channels onto a pink model node near the lower right of the foot, where you know that sensor “112” was physically located in the test shoe. Choose the “Coloring” option as before. 

 

7.19 Click on the “Time” channel, then click on the “123” icon to the left of the “Pressure107” channel. This will highlight sensor 107’s X and Y channels. 

Page 31: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

 

7.20 Drag both the highlighted “Time” and “Pressure107” channels onto a pink model node near the lower middle of the foot, where you know that sensor “107” was physically located in the test shoe. Choose the “Coloring” option as before. 

Page 32: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

Page 33: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

7.21 Click on the “Time” channel, then click on the “123” icon to the left of the “Pressure101” channel. This will highlight sensor 101’s X and Y channels. 

 

 

7.22 Drag both the highlighted “Time” and “Pressure101” channels onto a pink model node near the middle of the big toe, where you know that sensor “101” was physically located in the test shoe. Choose the “Coloring” option as before. 

Page 34: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

Page 35: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

7.23 You are now ready to test the display of 5 of your pressure sensors on your foot model. Click on the lower graph, hold and drag your mouse to the right until it is underneath the first set of sensor peaks (gray, black and dark yellow). This shows you the pressure profile at the beginning of the athlete’s step, when his weight is predominantly on his heel. 

 

 

7.24 Now drag the mouse further to the right to see the pressure distribution later in the athlete’s step when his weight is mainly on the ball of his foot and toes. 

Page 36: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

Page 37: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

7.25 Select the “File » Save As…” menu to save this VIEW layout to a *.TDV file. 

 

 

7.26 Name the file “VIEW_3D_Foot.TDV” and save it to the Desktop. If asked if you want to overwrite a file of the same name, click the “Yes” button. 

 

Page 38: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

7.27 Now you decide to check out the example in the Help system. Select the menu “Help » Examples…” to launch the example finder dialog. 

 

 

 

7.28 Navigate in the example directory structure to the folder “Examples » New Examples » New Examples for Version 11.1” and click on the “Synchronising 3D Models and Data” example, then click at the right of the dialog on the “Start example” link. 

Page 39: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

   

Page 40: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

Exercise – Build Your Own Stand‐Alone Datalogger  In this section you will learn the following:  

• How to configure the FPGA in Scan mode. • How to read analogue inputs and outputs. 

 

1. Launch LabVIEW 2009 and select Empty Project from the LabVIEW Getting Started 

window. 

 

2. Save the project as CompactRIO Scan Mode.lvproj in …\Desktop\Hands On Work\. You 

will use this project throughout the duration of this Seminar. 

 3. Right‐click on the top‐level project item and select New » Targets and Devices… 

 

4. Leave the setting on Existing Targets or devices and expand Real‐Time CompactRIO, 

select your cRIO which will be called cRIOHandsOn and click OK. 

 

Page 41: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

5. A pop‐up window will then appear. You can either chose to run in Scan mode or regular 

FPGA mode. Select Scan Interface and click Continue. LabVIEW will automatically detect 

your I/O modules and add them to the project.  

 If it brings up a dialogue box requesting you to discover the C Series modules, select 

Discover. LabVIEW will discover all C Series I/O modules currently installed in your 

CompactRIO chassis and add them to a LabVIEW project.  

 

6. Configure the NI Scan Engine from the cRIOHandsOn properties page. Right‐click 

cRIOHandsOn and select Properties… 

 

   

Page 42: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

7. Select Scan Engine from the Category field. Configure the Scan Period for 100ms and 

click OK. This setting tells the NI Scan Engine to update I/O every 100 milliseconds.  

 

8. Right‐click cRIOHandsOn and select New » VI… 

 

9. Press <Ctrl‐S> to bring up the save dialogue box. Save your new VI on your desktop as 

Scan Mode.vi. 

   

Page 43: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

10. Go back to the Project Explorer. Expand the Chassis and Module 1 (Slot 1, NI 9211). 

Click and drag AIO from the project into the block diagram of your new VI. 

 

11. Right click on the output of the AI0 terminal and select Create » Indicator.  

 

 

12. Place a Wait node from the Functions palette under Programming » Timing » Wait 

(ms). Set this wait to a period of 200ms by right clicking on the input and selecting 

Create » Constant. Set the constant to 200. 

 

Page 44: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

13. Select a While Loop from the Functions palette under Programming » Structures » 

While Loop. Drag the while loop around all the objects that you have on your block 

diagram. Right click on the input of the Condition terminal in the right‐hand corner of 

the While Loop and select Create Control. 

 

14. Switch to view the front panel by pressing <Ctrl‐E>. Right‐click on the Numeric Control 

and select Replace then select Thermometer from the Numeric Controls sub‐palette. 

 

   

Page 45: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

15. Rearrange the front panel to resemble the picture below. Save the VI and then run it, by 

clicking the white run arrow in the top‐left corner. 

 

16. Touch the Thermocouple and notice the temperature change is displayed.  

 

17. Stop the VI by clicking your stop button. 

 

18. Open the project explorer. Expand the channels available for Mod1 and Mod2. Under 

Mod1 (Slot 1, NI 9211), right‐click on AI0 and rename this Control to AI0 – 

Thermocouple. Change the name of Mod2 (Slot 2, NI 9233) to AI0 – Vibration sensor.  

 

You will notice that when you do this, LabVIEW will automatically update the shared 

variables in the project explorer. 

 

19. From your Project Explorer, expand the tree diagram to show the channels available for 

Modules 2, 3 & 4. Drag AI0 – Vibration Sensor into your while loop. 

Page 46: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

 

20. Switch to the Front Panel by using <Ctrl‐E>. Place down a Waveform Chart and a Round 

LED. Rename the controls Vibration Data and Alarm respectively. Rearrange your front 

panel to look similar to the one below. 

 

Switch back to the Block Diagram and ensure that all the new terminals are within the original 

While Loop.  

21. In the while loop, wire the AI0 Vibration Sensor to the Vibration Data Chart.  

 

Page 47: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

22. Save and Run the VI. Do not worry about the LED not being wired up; you will be wiring 

it shortly. You should see the vibration data coming back from the sensor. By pressing 

the button in the case, you should be able to switch the Motor on or off.  

 23. On the Block Diagram place down a less? from Programming » Comparison » less? On 

the top terminal of the less? node create a constant by right‐clicking on the terminal. 

Put 30 as the value for this constant. 

 

24. From the Project Explorer drag in an I/O variable for module 4 DO7 into the original 

While loop. Wire this next to the Alarm indicator to display the same information and 

wire the diagram to resemble the one shown below. 

 

25. Save and run the VI and observe the new alarm feature that you have added. If you heat 

up the thermocouple, the alarm will light up on the Front Panel.   

Page 48: Using NI LabVIEW 2009 - National Instrumentsdownload.ni.com/pub/branches/uk/handson_followup/practical_tips/... · Using NI LabVIEW 2009. ... Notice the new “P” glyph has been

 

26. Right‐click the green Boolean wire near the output of the less? node and select Insert » 

All Palettes » Real‐Time » Function Blocks » Timer » Timer On Delay.  

 

27. Wire a Numeric Constant with a value of 2000 into the preset time (ms) input by right 

clicking on the input itself and selecting Create » Constant.  

 

28. Click the Clean Up Diagram button or press <Ctrl‐U> to tidy your block diagram. 

 

29. Save and run your VI again. Notice that if the temperature goes above 30 degrees 

momentarily, the alarm is not raised. However if the temperature rises and remains 

above the threshold for more than 2 seconds, the alarm is then raised.