Skip to content Skip to navigation

Connexions

You are here: Home » Content » Temperature Logger VI

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • National Instruments display tagshide tags

    This module is included in aLens by: National InstrumentsAs a part of collection:"LabVIEW Graphical Programming Course"

    Comments:

    "A full introductory course on programming with LabVIEW."

    Click the "National Instruments" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Also in these lenses

  • eScience, eResearch and Computational Problem Solving

    This module is included inLens: eScience, eResearch and Computational Problem Solving
    By: Jan E. OdegardAs a part of collection:"LabVIEW Graphical Programming Course"

    Click the "eScience, eResearch and Computational Problem Solving" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

Temperature Logger VI

Module by: National Instruments. E-mail the author

User rating (How does the rating system work?)
Ratings

Ratings allow you to judge the quality of modules. If other users have ranked the module then its average rating is displayed below. Ratings are calculated on a scale from one star (Poor) to five stars (Excellent).

How to rate a module

Hover over the star that corresponds to the rating you wish to assign. Click on the star to add your rating. Your rating should be based on the quality of the content. You must have an account and be logged in to rate content.

:
(0 ratings)

Summary: In this exercise, the objective is to save data to a file in a form that a spreadsheet or a word processor can access. Complete the following steps to build a VI that saves the time and current temperature to a data file.

Exercise 1

1.a) Block Diagram

  1. Open the Temperature Control VI and save it as Temperature Logger.vi in the C:\Exercises\LabVIEW Basics I directory. You do not need to modify the front panel.
  2. Open and modify the block diagram as shown in Figure 1. Resize the While Loop to add space at the top for the file I/O operations.
    Figure 1
    Figure 1 (templogbd.png)
    1. OpenFileIcon.png Place the Open/Create/Replace File VI, located on the Functions>>All Functions>>File I/O palette, on the block diagram. Right-click the prompt input, select Create Constant from the shortcut menu and type Enter File Name in the constant. Right-click the function input, select Create Constant from the shortcut menu, and click the constant with the Operating tool to select create or replace.
    2. gettmdtstrgicon.png Place the Get Date/Time String function, located on the Functions>>All Functions>>Time & Dialog palette, on the block diagram. This function returns the time, in string format, when the temperature measurement was taken. Right-click the want seconds? input, select Create>>Constant from the shortcut menu, and click the constant with the Operating tool to change the constant from False to True. The True Boolean constant sets the function to include seconds in the string.
    3. BuildIcon.png Place the Build Text Express VI, located on the Functions>>Output palette, on the block diagram. This Express VI converts the inputs to one string. The Configure Build Text dialog box appears.
      1. Type %tab%%temp%%end% in the Text with Variables in Percents text box to set up three variables; one for the tab constant, one for the temperature and one for the end of line constant. Because time uses the Beginning Text input of the Build Text Express VI, it does not need a variable.
      2. Select temp in the Configure Variables section. Select the Number option, and a format of Format fractional number. The tab and end variables do not need to be formatted. You can leave them in the default state.
      3. Click the OK button to close the configuration dialog box.
      4. Right-click the Build Text Express VI and select View As Icon to conserve block diagram space.
    4. tabicon.png eolicon.png Place a Tab constant and an End of Line constant, located on the Functions>>All Functions>>String palette, on the block diagram.
    5. WriteFileIcon.png Place the Write File function, located on the Functions>>All Functions>>File I/O palette, on the block diagram. This function writes to the file specified by refnum.
    6. CloseFileIcon.png Place the Close File function, located on the Functions>>All Functions>>File I/O palette, on the block diagram. This function closes the file.
    7. Error.png Place the Simple Error Handler VI, located on the Functions>>All Functions>>Time & Dialog palette, on the block diagram. This VI checks the error cluster and displays a dialog box if an error occurs.
    8. Complete the block diagram as shown in Figure 1.
  3. Save the VI. You will use this VI later in the course.

1.b) Run the VI

  1. Display the front panel and run the VI. The Enter File Name dialog box appears.
  2. Type temp.txt and click the Save or OK button. The VI creates a file called temp.txt. The VI takes readings every half-second and saves the time and temperature data to a file until you click the Power switch. When the VI finishes, it closes the file.
  3. Open a word processor or spreadsheet application, such as (Windows) Notepad or WordPad, (Mac OS) SimpleText, or (UNIX) Text Editor.
  4. Open the temp.txt file in the word processing or spreadsheet application. The time appears in the first column, and the temperature data appears in the second column.
  5. Exit the word processor or spreadsheet application and return to LabVIEW.
  6. If time permits, complete the optional steps. Otherwise, close the VI.

1.c) Optional

When using error handling in a VI, the While Loop should stop executing when an error occurs. Complete the following steps to modify the VI so it stops when the user clicks the Power switch or an error occurs.

  1. Edit the block diagram as shown in Figure 2.
    Figure 2
    Figure 2 (templogoptbd.png)
    1. unbundle.png Place the Unbundle by Name function, located on the Functions>>All Functions>>Cluster palette, on the block diagram. This function reads the status output from the error cluster.
    2. not.png andicon.png Place the Not function and the And function, located on the Functions>>Arithmetic & Comparison>>Express Boolean palette, on the block diagram. These functions set the conditional terminal to continue while Power is True and no error occurs.
  2. Save and run the VI.
  3. Test the error handling by deleting the refnum wire between the Write File function and the left border of the While Loop. Right-click the refnum input of Write File and select Create>>Constant.
  4. Run the VI again. The VI should wait for a path, then stop immediately with an error. If error handling was not included in this VI, the VI would not report the error until the user stopped the VI.
  5. If time permits, complete the challenge steps. Otherwise, close the VI. Do not save changes.

1.d) Challenge

  1. Replace the Build Text Express VI and the Write File function with the Format Into File function.
  2. Run the VI.
  3. Close the VI. Do not save changes.

Content actions

Give Feedback:

E-mail the module author | Rate module ( How does the rating system work?)

Rating system

Ratings

Ratings allow you to judge the quality of modules. If other users have ranked the module then its average rating is displayed below. Ratings are calculated on a scale from one star (Poor) to five stars (Excellent).

How to rate a module

Hover over the star that corresponds to the rating you wish to assign. Click on the star to add your rating. Your rating should be based on the quality of the content. You must have an account and be logged in to rate content.

(0 ratings)

Download:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.

| A lens (?)

Definition of a lens

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks