As mentioned previously, you can use the VI Properties»Window
Appearance options to modify the appearance of the front panel when a VI is running. With the VI Properties»Window Size options, you can set the minimum size of a window, keep the window proportion with screen changes, and set front panel objects to resize in two different modes. Most professional applications do not enlarge each and every control when the window changes size, but pick a table, graph, or list to enlarge with the window, leaving other objects near the window’s edge. To resize one front panel object with the front panel, select that object, and select Edit»Scale Object With Panel.
The following exercise uses some of the techniques described to create a VI with a user interfaces that is easy to use.
Exercise 2-1 Scope Panel.vi
Objective: To logically arrange and separate front panel objects to make the user interface of a VI easier to read and use.
You will resize, reorganize, and rearrange the objects on the front panel to make the user interface easier to use. You will also setup the graph to resize along with the front panel.
Front Panel
1. Open the Scope Panel VI from thec:\exercises\LV basics 2 directory. The front panel is shown previously.
2. Move the controls around as to logically group the controls that share similarities (not all can relate to a group). For example the Channel A ON/OFF button, Channel A Position knob, and Channel A Volts/Div knob all operate on channel A and it makes sense to have them close to one another. Two other example groups would be the three Channel B controls and the three trigger controls.
Tip Remember to use the Align Objects and Distribute Objects features in the tool bar.
between the groups. And resize your window so the front panel fits inside the window, as shown in the following example.
Tip You need to use the Reorder button in the tool bar on the decorations to Move to Back, so that the controls are visible and on top of the raised boxes.
4. Select File»VI Properties to display the VI Properties dialog box.
Select Window Size from the top pull-down menu of the VI Properties dialog box. In the Minimum Panel Size section, click the >>Set to Current Window Size button to set your minimum screen size to the current size of the window. Click OK to return to the front panel.
5. Select the graph on the front panel then select Edit»Scale Object With Panel. LabVIEW resizes the graph when the entire window is resized and moves the other objects.
6. Save the VI under the same name.
7. Resize the window. You notice that the graph does resize with the window and the controls maintain a proportional distance to the graph and each other but do not grow or shrink. However, you notice that the decorations do not resize. In order to do this, you must use Boolean buttons that look the same in each state and resize them programmatically. This requires the use of Property Nodes and is covered later in this lesson.
8. Close the VI when you are finished.
Exercise 2-2 Acquire Data.vi
Objective: To modify a VI to use the Tab Control along with proper user-interface design techniques.
You will modify the Generate & Analyze VI so that it uses the tab control.
One page of the tab will be for the generation of data as before and a second page will be for acquiring the data from a DAQ device.
Note You will use this VI in the project in Lesson 5.
Front Panel
1. Open the Generate & Analyze VI you built in Exercise 1-1. Resize the front panel to make room on the left of the other front panel objects as you will be adding the tab control.
2. Place a Tab Control located on the Controls»Array & Cluster palette on the front panel as shown previously. Select the Sine Frequency, Sine Amplitude, Sampling Info, and Noise Amplitude controls and place them into the first page of the Tab Control.
3. Name the two pages of the tab control Simulate and DAQ respectively.
Click the DAQ page and add the objects as follows:
4. Save this VI asAcquire Data.vi.
5. Right-click the DAQ Channel Name control and make sure the Allow Undefined Names option is selected.
6. To change the scale on the knob to read20.0kinstead of20,000, right-click the knob and select Format & Precision. Select
Engineering Notation and thekis added to represent one thousand.
Block Diagram
7. Open and modify the block diagram as shown previously using the following components:
a. Place a Case structure located on the Functions»Structures palette on the block diagram. When used with the tab control—one case handles the Simulate page and the other case is for the DAQ page.
b. Place the AI Acquire Waveform VI located on the Functions»Data Acquisition»Analog Input palette on the block diagram. This VI acquires data from an analog input channel on the DAQ device.
Note If you do not have a DAQ device or a DAQ Signal Accessory, use the Demo Acquire Waveform VI located on the Functions»User Libraries»Basics 2 Course palette on the block diagram in place of the AI Acquire Waveform VI. The Demo Acquire Waveform VI simulates acquiring data from an analog input channel at a specified sampling rate and returning the specified number of samples.
c. Create a Cluster constant by right-clicking the Case structure tunnel and selecting Create»Constant from the shortcut menu. This constant passes the default values for the error cluster out of the DAQ case.
8. Save the VI.
9. Observe how you have added quite a bit of new functionality to this VI without adding a lot of extra code. Using the Tab Control is a very efficient way to add new front panel objects to the user interface and also add block diagram functionality without having to enlarge the front panel and block diagram windows.
10. Run the VI. You can adjust the front panel controls to see the time and frequency waveforms change. Click between the Simulated and DAQ pages in the Tab Control.
11. Stop and close this VI when you are finished.