CHAPTER 3: Analyzing and Saving a Signal

Modifying a VI Created from a Template
From the Create New list, select VI»From Template»Tutorial (Getting Started)»Generate, Analyze, and Display. This template VI simulates a signal and analyzes it for its root mean square (RMS)
value. Click the OK button or double-click the name of the template to create a VI from the template.

Display the front panel and remove the RMS indicator. You will not use the RMS functionality of the Amplitude and Level Measurements Express VI for this exercise. However, you can use the Generate, Analyze, and Display template VI with the RMS functionality in the future to reduce development time.

Display the block diagram and remove any broken wires that result from removing the RMS indicator. To remove all broken wires from the block diagram, you can press the <Ctrl-B> keys. Then return to the front panel window and right-click the waveform graph indicator. Select Properties from the shortcut menu. The Graph Properties dialog box appears. On the Appearance page, place a checkmark in the Visible checkbox in the Label section and enter Unfiltered Signal in the text box. Click the OK button to save the configuration and close the Graph
Properties dialog box.



Adding a Signal
On the block diagram, use the Positioning tool to select the Simulate Signal Express VI.
Hold down the <Ctrl> key and click and drag to create an additional Simulate Signal Express VI on the block diagram. Release the mouse button to place the copied Simulate Signal Express VI below the original Simulate Signal Express VI. LabVIEW updatesthe name of the copied Simulate Signal Express VI to Simulate Signal2. Double-click the Simulate Signal2 Express VI to display the Configure Simulate Signal dialog box.

When you change the signal name in the Configure Simulate Signal dialog box, LabVIEW changes the name of the signal output on the block diagram. Changing the signal name makes it easier for you to identify the signal type when you view the Express VI on the block diagram.



Adding Two Signals
To add two signals together to create one signal, you can use the Formula Express VI. Rather than merging two signals on one graph, the Formula Express VI adds both signals together to create a single signal on the graph. You can use this Express VI to add noise to a signal.

On the Functions palette, click the Search button to search for the Formula Express VI and add it to the block diagram between the Simulate Signal Express VIs and the Amplitude and Level Measurements Express VI. The Configure Formula dialog boxappears.

In the Label column, change the label for X1 to Sine and the label for X2 to 60 Hz and Noise. The Formula Express VI automatically enters the first input, Sine, in the Formula text box. Click the + button and then the X2 button to add Sine and 60 Hz and Noise together in the Formula text box.



Filtering a Signal
You can use the Filter Express VI to process signals through filters and windows. Search for the Filter Express VI. In the Filter Specifications section, change the Cutoff Frequency.

Click the Unfiltered Signal waveform graph indicator and press the <Ctrl> key while you drag with the Positioning tool to create an additional waveform graph indicator. Triple-click the Unfiltered Signal 2 label above the new waveform graph indicator and enter Filtered Signal to change the label of the indicator. You also can change the label on the Appearance page of the Graph Properties dialog box. On the block diagram, wire the Result output of the Formula Express VI to the Signal input of the Filter Express VI and to the Unfiltered Signal waveform graph indicator. Wire the Filtered Signal output of the Filter Express VI to the Signals input of the Amplitude and Level Measurements Express VI and to the input of the Filtered Signal waveform graph indicator.



Modifying the Appearance of Graphs
You can use the Display Format page of the Graph Properties dialog box to specify how the scales of the x-axis and y-axis appear on the graph. In the front panel window, right-click the Unfiltered Signal graph indicator and select Properties from the shortcut menu. The Graph Properties dialog box appears. On the Display Format page, select Time (X-Axis) from the top pull-down menu. Select the Default editing mode option. In the Type list, select Automatic formatting. In the Digits field, enter 6 and select Significant digits from the Precision Type pull-down menu. Place a checkmark in the Hide trailing zeros checkbox. Select Amplitude (Y-Axis) from the top pull-down menu and repeat steps 3–6 so the y-axis configuration matches the x-axis configuration.

On the Scales page, select Amplitude (Y-Axis). Remove the checkmark from the Autoscale checkbox. The x-axis and the y-axis on the Unfiltered Signal and Filtered Signal graph indicators change to reflect the new configuration.




Analyzing the Amplitude of a Signal
You can use the Amplitude and Level Measurements Express VI to analyze the voltage characteristics of a signal.

On the block diagram, double-click the Amplitude and Level Measurements Express VI to display the Configure Amplitude and Level Measurements dialog box. In the Amplitude Measurements section, remove the checkmark from the RMS checkbox. Place a checkmark in the Peak to peak checkbox. Peak to peak appears in the Results section with the corresponding value of the
measurement. The RMS output of the Amplitude and Level Measurements Express VI changes to reflect the new Peak to Peak output.




Controlling the Speed of Execution
To plot the points on the waveform graphs more slowly, you can add a time delay to the block diagram. A time delay slows the speed at which a VI runs. Place the Time Delay Express VI inside the While Loop.

Another way to control the speed of the VI is to alter the rate of data acquisition. On the block diagram, double click the Simulate Signal Express VI to display the Configure Simulate Signal dialog box. Locate the Timing section in the dialog box. The Timing section contains a number of ways to alter the rate of data acquisition and the speed at which a VI runs.


Adding a Warning Light
If you want a visual cue to indicate when a value exceeds a specified limit, you can use a warning light.

Display the Controls palette by right-clicking any blank space in the front panel window. On the Express palette, select the LEDs palette. Select the round LED indicator and add it to the front panel to the left of the waveform graphs. Double-click the Boolean label above the LED and enter Warning to change the label of the LED. You will use this LED in a later exercise to indicate when a value has
exceeded its limit.



Setting a Warning Level Limit
To specify the value at which you want the LED to light, use the Comparison Express VI. In the Comparison Inputs section, select Value and enter  in the Value numeric control to assign a constant value at which you want the LED to light. The name of the Comparison Express VI changes to reflect the operation of the Express VI, shown at left. Greater indicates that the Express VI does a greater than comparison. When the Positioning tool appears, right-click the wire that connects the Peak to Peak output to the Operand 1 input and select Create» Numeric Indicator from the shortcut menu.

Warning the User
After you specify the values at which you want the LED to light, you must wire the LED to the Greater Express VI. 

Red coercion dots appear automatically at the Peak to Peak and Warning input terminals to alert you that you wired two different data types together and LabVIEW converted the value passed into the node to a different representation. The block diagram places the coercion dots on the border of the terminal where the conversion takes place. For this exercise, the conversion does not affect how the VI runs. Refer to the LabVIEW Help for more information about coercion dots.

A numeric indicator labeled Peak to Peak appears in the front panel window. This indicator displays the peak-to-peak value of the signal. When the peak-to-peak value exceeds 2.0, the Warning indicator
lights.


Configuring a VI to Save Data to a File
To store information about the data a VI generates, use the Write To Measurement File Express VI. Search for the Write To Measurement File Express VI and add it to the block diagram. The Filename text box displays the full path to the output file, test.lvm. A .lvm file is a tab-delimited text measurement file you can open with a spreadsheet application or a text-editing application. LabVIEW saves data with up to six digits of precision in a .lvm file. LabVIEW saves the .lvm file in the default LabVIEW Data directory. LabVIEW installs the LabVIEW Data directory in the default file directory of the operating system. When you want to view the data, use the file path displayed in the Filename text box to access the test.lvm file.

In the Configure Write to Measurement File dialog box, locate the If a file already exists section and select the Append to file option to write all the data to the test.lvm file without erasing any existing data in the file. In the Segment Headers section, select the One header only option to create only one header in the file to which LabVIEW writes the data. Enter the following text in the File Description text box: Sample of peak to peak values. LabVIEW appends the text you enter in this text box to the header of the file.


Saving Data to a File
When you run the VI, LabVIEW saves the data to the test.lvm file. Select File»Save As and save the VI as Save Data.vi in an easily accessible location. To view the data you saved, open the test.lvm file in the LabVIEWData directory with a spreadsheet or text-editing application. The file has a header that contains information about the Express VI.


Adding a Button That Stores Data When Clicked
If you want to store only certain data points, you can configure the WriteTo Measurement File Express VI to save peak-to-peak values only when auser clicks a button. Display the front panel and search the Controls palette for a rocker button. Select one of the rocker buttons and place it to the right of the waveform graphs.Use the Operation page to specify how a button behaves when a userclicks it. To see how the button reacts to a click, click the button in the Preview Selected Behavior section.


Saving Data When Prompted by a User
In the block diagram window, double-click the Write To Measurement File Express VI to display the Configure Write To Measurement File dialog box. Change the filename test.lvm in the Filename text box to Selected Samples.lvm to save the data to a different file.

The inputs and outputs of an Express VI appear in a predetermined order when you add new inputs and outputs. To select a specific input, you might need to add an input first, and then change the input to the specific one you want to use by right-clicking the input and selecting Select Input/Output from the shortcut menu.


Viewing Saved Data
Complete the following steps to view the data that you save to the Selected Samples.lvm file.Display the front panel and run the VI. Click the Write to File button several times. Click the STOP button. Open the Selected Samples.lvm file with a spreadsheet or text-editing application. The Selected Samples.lvm file differs from the test.lvm file. test.lvm recorded all the data generated by the Save Data VI, whereas Selected Samples.lvm recorded data only when you clicked the Write to File button. Close the file after you finish looking at it. Save and close the VI.






Comments

Popular Posts