<< Chapter < Page Chapter >> Page >
To build a VI using the Convert C to F subVI to read a temperature from the DAQ Signal Accessory in Celsius or Fahrenheit.

Complete the following steps to create a VI that reads a measurement from the temperature sensor on the DAQ SignalAccessory and displays the temperature in Celsius or Fahrenheit.

The sensor returns a voltage proportional to temperature. For example, if the temperature is 23, the sensor output voltage is 0.23 V. The sensor is connected to Channel 0 ofDevice 1. Device 1 is the DAQ device. On some systems, the DAQ device may have another device number.

Front panel

  • In the LabVIEW dialog box, click the arrow on the New button and select Blank VI from the shortcut menu or press the <Ctrl-N> keys to open a blank VI.
  • Create the following front panel.
    • Place a thermometer, located on the Controls>>Numeric Indicators palette, on the front panel.
    • Type Temperature in the label and press the <Enter> key or click the Enter button on the toolbar, shown at left.
    • Right-click the thermometer and select Visible Items>> Digital Display from the shortcut menu to show the digital display for the thermometer.
    • Place a vertical toggle switch control, located on the Controls>>Buttons&Switches palette, on the front panel.
    • Type Temp Scale in the label and press the <Enter> key or click the Enter button.
    • Use the Labeling tool, shown in , to place a free label, deg C , next to the True position of the switch. If you are using automatic tool selection,double-click the blank area of the front panel to begin typing a free label.
    • Place a free label, deg F , next to the False position of the switch.

User documentation

  • Document the VI so a description appears in the Context Help window when you move the cursor over the VI icon.
    • Select File>>VI Properties to display the VI Properties dialog box.
    • Select Documentation from the Category pull-down menu.
    • Type the following description for the VI in the VI description text box: This VI measures temperature using the temperaturesensor on the DAQ Signal Accessory.
    • Click the OK button.
  • Document the thermometer indicator and switch control so descriptions appear in the Context Help window when you move the cursor over the objects and tip strips appear onthe front panel or block diagram when you move the cursor over the objects whilethe VI runs.
    • Right-click the thermometer indicator and select Description and Tip from the shortcut menu.
    • Type the following description for the thermometer in the Description text box: Displays the temperature measurement.
    • Type temperature in the Tip text box.
    • Click the OK button.
    • Right-click the switch control and select Description and Tip from the shortcut menu.
    • Type the following description for the vertical switch control in the Description text box: Determines the scale (Fahrenheit or Celsius) to use for the temperature measurement.
    • Type scale - C or F in the Tip text box.
    • Click the OK button.
  • Select Help>>Show Context Help to display the Context Help window.
  • Move the cursor over the front panel objects and the VI icon to display the descriptions in the Context Help window.

Block diagram

  • Select Window>>Show Block Diagram to display the block diagram .
  • Place the DAQ Assistant Express VI, located on the Functions>>Input palette, on the block diagram. When you place this Express VI on the block diagram the DAQAssistant configuration dialog box appears.
    • Select Analog Input>>Voltage for the type of measurement to make.
    • Select Dev1>>ai0 (or Dev2>>ai0 ) for the physical channel and click the Finish button.
    • You must multiply the temperature by 100 to convert itfrom voltage to Celsius. On the Settings tab, select Custom Scaling>>Create New . Select a Linear scale. Name the scale Temperature . Enter a slope scale of 100 . Click the OK button.
    • Set min = 0 . Set max = 100
    • Select the Acquire 1 Sample option on the Task Timing tab. Click the OK button.
      If you do not have a DAQ device with a temperature sensor connected to your computer, use the (Demo) Read Voltage VI, located in the C:\Exercises LabVIEW Basics I directory.
  • Place the Convert from Dynamic Data Express VI, located on the Functions>>Signal Manipulation palette, on the block diagram. This VI converts the dynamic datatype. In the configuration dialog box, select Single scalar in the Resulting data type listbox.
  • Place the Convert C to F VI on the block diagram. Select Functions>>All Functions>>Select a VI , navigate to C:\Exercises\LabVIEW Basics I\Convert C to F.vi . This VI converts the Celsius readings to Fahrenheit.
  • Place the Select function, located on the Functions>>Arithmetic&Comparison>>Express Comparison palette, on the block diagram. This function returns either the Fahrenheit ( False ) or Celsius ( True ) temperature value, depending on the value of Temp Scale . Use the Positioning tool to place the icons as shown in the block diagram and use the Wiring tool to wire them together.
    To display terminals for a node, right-click the icon andselect Visible Items>>Terminals from the shortcut menu.

Front panel

  • Display the front panel by clicking it or by selecting Window>>Show Front Panel .
  • Click the Run Continuously button, shown at left, to run the VI continuously.
  • Put your finger on the temperature sensor and notice the temperature increase.
  • Click the Run Continuously button again to stop the VI. This allows the VI to finish the current run ofthe VI.

Icon and connector pane

  • Create an icon so you can use the Thermometer VI as a subVI. The following icon is an example. If necessary, create a simpler icon to save time.
    • Right-click the icon in the upper right corner of the front panel and select Edit Icon from the shortcut menu. The Icon Editor dialog box appears.
    • Double-click the Select tool, shown at left, on the left side of the Icon Editor dialog box to select the default icon.
    • Press the <Delete> key to remove the default icon.
    • Double-click the Rectangle tool, shown at , to redraw the border.
    • Use the Pencil tool, shown in , to draw an icon that represents the thermometer.
    • Use the Foreground and Fill tools to color the thermometer red.
      To draw horizontal or vertical straight lines, press the <Shift> key while you use the Pencil tool to drag the cursor.
    • Double-click the Text tool, shown in , and change the font to Small Fonts .
    • Type Temp . Reposition the text if necessary.
    • Select the B&W icon and select 256 Colors in the Copy from section to create a black and white icon, which LabVIEW uses for printing unless you have a color printer.
    • When the icon is complete, click the OK button. The icon appears in the upper right corner of the front panel.
  • Right-click the icon and select Show Connector from the shortcut menu and assign terminals to the switch and the thermometer.
    • Click the left terminal in the connector pane.
    • Click the Temp Scale control. The left terminal turns green.
    • Click the right terminal in the connector pane.
    • Click the Temperature indicator. The right terminal turns orange.
    • Click an open space on the front panel.
  • Save the VI as Thermometer.vi in the C:\Exercises\ LabVIEW Basics I directory.You will use this VI later in the course.
  • Close the VI.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Labview graphical programming. OpenStax CNX. Apr 09, 2015 Download for free at https://legacy.cnx.org/content/col11408/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Labview graphical programming' conversation and receive update notifications?

Ask