Complete the following steps to create a VI that reads a
measurement from the temperature sensor on the DAQ Signal
Accessory 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 of
Device 1. Device 1 is the DAQ device. On some systems, the DAQ
device may have another device number.
-
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 Media 3, 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.
-
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 temperature
sensor 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 on
the front panel
or block diagram when you move the cursor over the objects while
the 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.
-
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 DAQ
Assistant 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 it
from 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 data
type. 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 and
select Visible Items>>Terminals from the
shortcut menu.
- 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 of
the VI.
-
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 Media 12, to redraw the border.
-
Use
the Pencil tool, shown in Media 13, 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 Media 14, 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.
"A full introductory course on programming with LabVIEW."