Skip to content Skip to navigation Skip to collection information

OpenStax_CNX

You are here: Home » Content » LabVIEW Graphical Programming » Reduce Samples VI

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

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

What is in a lens?

Lens makers point to 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 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.
  • NSF Partnership display tagshide tags

    This module is included inLens: NSF Partnership in Signal Processing
    By: Sidney BurrusAs a part of collection: "LabVIEW Graphical Programming Course"

    Click the "NSF Partnership" link to see all content affiliated with them.

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

  • 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

  • Lens for Engineering

    This module is included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

  • 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.
 

Reduce Samples VI

Module by: Malan Shiralkar. E-mail the author

Summary: Use the LabVIEW documentation resources to build a VI that generates a signal, reduces the number of samples in the signal, and displays the resulting data in a table on the front panel.

Exercise 1

In the following exercises, you will open a blank VI and add Express VIs and structures to the block diagram to build a new VI. When you complete the exercise, the front panel of the VI will appear similar to the Figure 1.

Figure 1
Figure 1 (reducesamplesfp.png)

1.a) Opening a Blank VI

If no template is available for the task you want to create, you can start with a blank VI and add Express VIs to accomplish the specific task. Complete the following steps to open a blank VI.

  1. 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. Notice that a blank front panel and block diagram appear.
  2. thumbtack.png If the Functions palette is not visible, right-click any blank space on the block diagram to display the Functions palette. Click the thumbtack, shown in Media 2, in the upper left corner of the Functions palette to place the palette on the screen.

note:

You can right-click a blank space on the block diagram or the front panel to display the Functions or Controls palettes.

1.b) Adding an Express VI that Simulates a Signal

Complete the following steps to find the Express VI you want to use and then add it to the block diagram.

  1. helpbutton.png If the Context Help window is not visible, press the Ctrl-H keys to open the Context Help window. You also can press the Show Context Help Window button, shown in Media 3, to open the Context Help window.
  2. Select the Input palette on the Functions palette and move the cursor over the Express VIs on the Input palette. Notice that the Context Help window displays information about the function of each Express VI.
  3. From the information provided in the Context Help window, find the Express VI that can simulate a sine wave signal.
  4. Select the Express VI and place it on the block diagram. The Configure Simulate Signal dialog box appears.
  5. Idle the cursor over the various options in the Configure Simulate Signal dialog box, such as Frequency (Hz), Amplitude, and Samples per second (Hz). Read the information that appears in the Context Help window.
  6. Configure the Simulate Signal Express VI to generate a sine wave with a frequency of 10.7 10.7 and amplitude of 2 2.
  7. Notice how the signal displayed in the Result Preview window changes to reflect the configured sine wave.
  8. Close the Configure Simulate Signal dialog box by clicking the OK button.
  9. Move the cursor over the Simulate Signal Express VI and read the information that appears in the Context Help window. Notice that the Context Help window now displays the configuration of the Simulate Signal Express VI.
  10. Save this VI as Reduce Samples.vi in the C:\Exercises\LabVIEW Basics I directory.

1.c) Modifying the Signal

Complete the following steps to use the LabVIEW Help to search for the Express VI that reduces the number of samples in a signal.

  1. Select Help>>VI, Function, & How-To Help to open the LabVIEW Help.
  2. Click the Search tab and type sample compression in the Type in the word(s) to search for text box. Notice that this word choice reflects what you want this Express VI to do-compress, or reduce, the number of samples in a signal.
  3. To begin the search, press the Enter key or click the List Topics button.
  4. Double-click the Sample Compression topic to display the topic that describes the Sample Compression Express VI.
  5. After you read the description of the Express VI, click the Place on the block diagram button to select the Express VI.
  6. Move the cursor to the block diagram. Notice how LabVIEW attaches the Sample Compression Express VI to the cursor.
  7. Place the Sample Compression Express VI on the block diagram to the right of the Simulate Signal Express VI.
  8. Configure the Sample Compression Express VI to reduce the signal by a factor of 25 25 using the mean of these values.
  9. Close the Configure Sample Compression dialog box.
  10. Using the Wiring tool, wire the Sine output in the Simulate Signal Express VI to the Signals input in the Sample Compression Express VI.

1.d) Customizing the Front Panel

In a previous exercise, you added controls and indicators to the front panel using the Controls palette. You also can add controls and indicators from the block diagram. Complete the following steps to create controls and indicators as shown in Figure 2.

Figure 2
Figure 2 (reducesamplesbdnoWL.png)

  1. Right-click the Mean output in the Sample Compression Express VI and select Create>>Numeric Indicator from the shortcut menu to create a numeric indicator.
  2. Right-click the Mean output of the Sample Compression Express VI and select Insert Input/Output from the shortcut menu to insert the Enable input.
  3. Right-click the Enable input and select Create>>Control from the shortcut menu to create the Enableswitch.
  4. Right-click the wire linking the Sine output in the Simulate Signal Express VI to the Signals input in the Signal Compression Express VI and select Create>>Graph Indicator from the shortcut menu. Notice that you can create controls and indicators from the block diagram. When you create controls and indicators using this method, LabVIEW automatically creates terminals that are labeled and formatted correctly.
  5. Using the Wiring tool, wire the Mean output in the Sample Compression Express VI to the Sine graph indicator terminal created in the previous step. Notice that the Merge Signals function appears.
  6. Arrange the objects on the block diagram so that they appear similar to Figure 2.

    Tip:

    You can right-click any wire and select Clean Up Wire from the shortcut menu to automatically route an existing wire.
  7. Display the front panel. Notice that the controls and indicators you added automatically appear on the front panel with labels that correspond to their function.
  8. Save this VI.

1.e) Configuring the VI to Run Continuously Until the User Stops It

In the current state, the VI runs once, generates one signal, then stops executing. To run the VI until a condition is met, you can add a While Loop to the block diagram. Complete the following steps to add a While Loop.

  1. Display the front panel and run the VI. Notice how the VI runs once and then stops. Also notice how there is no Stop button.
  2. Display the block diagram and select the While Loop on the Functions>>Execution Control palette.
  3. Move the cursor to the upper left corner of the block diagram. Place the top left corner of the While Loop here.
  4. Click and drag the cursor diagonally to enclose all the Express VIs and wires, as shown in Figure 3.
    Figure 3
    Figure 3 (reducesamplesbdnoWL.png)
    whileloop.png Notice that the While Loop, shown in Media 6, appears with a Stop button wired to the condition terminal. This While Loop is configured to stop when the user clicks the Stop button.
  5. Display the front panel and run the VI. Notice that the VI now runs until you click the Stop button. A While Loop executes the functions inside the loop until the user presses the Stop button. Refer to Repetition and Loops for more information about While Loops.

1.f) Controlling the Speed of Execution

To plot the points on the waveform graph more slowly, you can add a time delay to the block diagram. Complete the following steps to control the speed at which the VI executes.

  1. On the block diagram, select the Time Delay Express VI on the Functions>>Execution Control palette and place it inside the loop.
  2. Type .250 .250 in the Time delay (seconds) text box. This time delay specifies how fast the loop runs. With a .250 .250 second time delay, the loop iterates once every quarter of a second.
  3. Close the Configure Time Delay dialog box.
  4. Save this VI.
  5. Display the front panel and run the VI.
  6. Click the Enable switch and notice the change on the graph. Notice how if the Enable switch is on, the graph displays the reduced signal. If the Enable switch is off, the graph does not display the reduced signal.
  7. Click the Stop button to stop the VI.

1.g) Using a Table to Display Data

Complete the following steps to display a collection of mean values in a table on the front panel.

  1. On the front panel, select the Express Table indicator on the Controls>>Text Indicators palette and place it on the front panel to the right of the waveform graph.
  2. Display the block diagram. Notice that the Table terminal appears wired to the Build Table Express VI automatically.
  3. clickanddrag.png If the Build Table Express VI and the Table terminal are not selected already, click an open space on the block diagram to the left of the Build Table Express VI and the Table terminal. Drag the cursor diagonally until the selection rectangle encloses the Build Table Express VI and the Table terminal, shown in Media 7. A moving dashed outline called a marquee highlights the Build Table Express VI, the Table terminal, and the wire joining the two.
  4. Drag the objects into the While Loop to the right of the Mean terminal. Notice that the While Loop automatically resizes to enclose the Build Table Express VI and the Table terminal.
  5. Using the Wiring tool, wire the Mean terminal of the Sample Compression Express VI to the Signals input of the Build Table Express VI. The block diagram should appear similar to Figure 4.
    Figure 4
    Figure 4 (reducesamplesbdwithtable.png)
  6. Display the front panel and run the VI.
  7. Click the Enable switch. The table displays the mean values of every 25 25 samples of the sine wave. Notice if the Enable switch is off, the table does not record the mean values.
  8. Stop the VI.
  9. Experiment with properties of the table by using the Table Properties dialog box. For example, try changing the number of columns to one.
  10. Save and close this VI.

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

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

| A lens I own (?)

Definition of a lens

Lenses

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

What is in a lens?

Lens makers point to 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 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

Module to:

My Favorites (?)

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

| A lens I own (?)

Definition of a lens

Lenses

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

What is in a lens?

Lens makers point to 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 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