<< Chapter < Page Chapter >> Page >
To read a temperature once every second for one minute.

Complete the following steps to build a VI that uses the Thermometer VI to read a temperature once every second for aduration of one minute.

Front panel

  • Open a blank VI and build the front panel shown in .
    • Place a thermometer , located on the Controls>>Numeric Indicators palette, on the front panel. This provides a visual indication ofthe temperature reading.
    • Place a numeric indicator , located on the Controls>>Numeric Indicators palette, on the front panel. Label this indicator Seconds Elapsed . Right-click the indicator and select Representation>>I32 from the shortcut menu.

Block diagram

  • Build the block diagram shown in .
    • Place a For Loop , located on the Functions>>All Functions>>Structures palette, on the block diagram. Right-click the Loop Count terminal in the upper left corner of the For Loop and select Create Constant from the shortcut menu. Type 60 in the constant to set the For Loop to repeat 60 times.
    • Place the Thermometer VI on the block diagram. Select Functions>>All Functions>>Select a VI and navigate to C:\Exercises\LabVIEW Basics I\Thermometer.vi to place the VI. This VI reads the temperature from the DAQ device. Right-clickthe Temp Scale input and select Create>>Constant from the shortcut menu. Use a False constant for Fahrenheit or a True constant for Celsius.
      If you do not have a DAQ device with a temperature sensoron Channel 0, use the (Demo) Thermometer VI instead.
    • Place the Wait Until Next ms Multiple function, located on the Functions>>All Functions>>Time&Dialog palette, on the block diagram. Right-click the input and select Create>>Constant from the shortcut menu. Enter a value of 1000 to set the wait to every second.
    • Place the Increment function, located on the Functions>>Arithmetic&Comparison>>Express Numeric palette, on the block diagram. This function adds one to theiteration terminal output.
  • Save this VI as Timed Temperature.vi in the C:\Exercises\LabVIEW Basics I directory.
  • Run the VI. The first reading might take longer than onesecond to retrieve if the computer needs to configure the DAQ device.
  • If time permits, complete the following optional andchallenge steps, otherwise close the VI.

Optional

  • Build a VI that generates random numbers in a While Loop and stops when you click a stop button on the front panel.
  • Save the VI as General While Loop.vi in the C:\Exercises\LabVIEW Basics I directory.

Challenge

  • Modify the General While Loop VI to stop when the stop button is clicked or when the While Loop reaches a number of iterations specified by a front panel control.
  • Select File>>Save As to save the VI as Combo While-For Loop.vi in the C:\Exercises\LabVIEW Basics I directory.

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