This page is optimized for mobile devices, if you would prefer the desktop version just
click here
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 theNew
button and selectBlank
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 theEnter
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 theEnter
button. - Use the
Labeling
tool, shown in , to place a free label,deg C
, next to theTrue
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 theFalse
position of the switch.
- Place a thermometer, located on the
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 theVI Properties
dialog box. - Select
Documentation
from theCategory
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.
- Select
- 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 theTip
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 theTip
text box. - Click the
OK
button.
- Right-click the thermometer indicator and select
- Select
Help>>Show Context Help
to display theContext 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 theFunctions>>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
(orDev2>>ai0
) for the physical channel and click theFinish
button. - You must multiply the temperature by 100 to convert itfrom voltage to Celsius. On the
Settings
tab, selectCustom Scaling>>Create New
. Select aLinear
scale. Name the scaleTemperature
. Enter aslope scale
of100
. Click theOK
button. - Set
min = 0
. Setmax = 100
- Select the
Acquire 1 Sample
option on theTask Timing
tab. Click theOK
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 theC:\Exercises LabVIEW Basics I
directory.
- Select
- Place the
Convert from Dynamic Data
Express VI, located on theFunctions>>Signal Manipulation
palette, on the block diagram. This VI converts the dynamic datatype. In the configuration dialog box, selectSingle scalar
in theResulting data type
listbox. - Place the
Convert C to F
VI on the block diagram. SelectFunctions>>All Functions>>Select a VI
, navigate toC:\Exercises\LabVIEW Basics I\Convert C to F.vi
. This VI converts the Celsius readings to Fahrenheit. - Place the
Select
function, located on theFunctions>>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 ofTemp Scale
. Use thePositioning
tool to place the icons as shown in the block diagram and use theWiring
tool to wire them together.To display terminals for a node, right-click the icon andselectVisible 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. TheIcon Editor
dialog box appears. - Double-click
the
Select
tool, shown at left, on the left side of theIcon 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 thePencil
tool to drag the cursor. - Double-click the
Text
tool, shown in , and change the font toSmall Fonts
. - Type
Temp
. Reposition the text if necessary. - Select the
B&W
icon and select256 Colors
in theCopy 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 in the upper
right corner of the front panel and select
- 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 theC:\Exercises\ LabVIEW Basics I
directory.You will use this VI later in the course. - Close the VI.
Read also:
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.