LabVIEW programs are called virtual instruments, or VIs, because their
appearance and operation imitate physical instruments, such as oscilloscopes
and multimeters. LabVIEW contains a comprehensive set of tools for acquiring,
analyzing, displaying, and storing data, as well as tools to help us to
troubleshoot code we write.
In LabVIEW, we build a user interface, or front panel, with controls and
indicators. Controls are knobs, push buttons, dials, and other input
mechanisms. Indicators are graphs, LEDs, and other output displays. After we
build the front panel, we add code using VIs and structures to control the
front panel objects. The block diagram contains this code.
LabVIEW used to communicate with hardware such as data acquisition,
vision, and motion control devices, as well as GPIB, PXI, VXI, RS232, and RS485
instruments.
----------------------------------------------------------------------------------------------------------------------
In this following exercises, I built a VI that generates a signal and
displays that signal in a graph. The results for this exercises is shown in
figure 1 below.
Figure 1
Let's Begin this exercise!
Step 1 : Opening a new VI from a new template
- Open the LabView then choose create project blankVI, then front panel and block digaram will popped up.
- Then on the block diagram click new then select VI>From Template>Tutorial (Getting Started)>Generate and Display. This template VI generates and displays a signal. And click OK. As shown in figure 2.
Figure 2
- LabVIEW displays two windows: the front panel window and the block diagram window.
- Examine the front panel window. The user interface, or front panel, appears with a gray background and includes controls and indicators. The title bar of the front panel indicates that this window is the front panel for the Generate and Display VI.
- Select Window>Show Block Diagram and examine the block diagram of the VI.
- The block diagram appears with a white background and includes VIs and structures that control the front panel objects. The title bar of the block diagram indicates that this window is the block diagram for the Generate and Display VI.
- On the front panel toolbar, click the Run button, shown at left. You also can press the <Ctrl-R> keys to run a VI. A sine wave appears on the graph in the front panel window.
- Stop the VI by clicking the front panel STOP button, shown at left.
Figure 3
Step 2: Adding a control to the front panel
- Complete the following steps to add a knob control to the front panel.
- If the Controls palette, shown in Figure 4, is not visible in the front panel window, select View>Controls Palette.
- If you are a new LabVIEW user, the Controls palette opens with the Express palette, shown in Figure 4, visible by default. If you do not see the Express palette, click Express on the Controls palette to display the Express palette.
Figure 4
- Move the cursor over the icons on the Express palette to locate the Numeric Controls palette. When you move the cursor over icons on the Controls palette, the name of the subpalette, control, or indicator appears in a tip strip below the icon.
- Click the Numeric Controls icon to display the Numeric Controls palette.
- Click the Knob control on the Numeric Controls palette to attach the control to the cursor, and then add the knob to the front panel to the left of the waveform graph. You will use this knob in a later exercise to control the amplitude of a signal.
- Select File>Save As and save the VI as Acquiring a Signal.vi in an easily accessible location
Step 3: Changing a signal type
- The block diagram has a blue icon labeled Simulate Signal. This icon represents the Simulate Signal Express VI. An Express VI is a component of the block diagram that you can configure to perform common measurement tasks. The Simulate Signal Express VI simulates a sine wave by default.
- Complete the following steps to change this signal to a sawtooth wave.
- Display the block diagram by pressing the <Ctrl-E> keys or by clicking the block diagram. Locate the Simulate Signal Express VI, shown at left. The Simulate Signal Express VI simulates a signal based on the configuration that you specify.
- Right-click the Simulate Signal Express VI and select Properties from the shortcut menu to display the Configure Simulate Signal dialog box. (Mac OS X) Press <Command>-click to perform the same action as right-click.
- Select Sawtooth from the Signal type pull-down menu. The waveform on the graph in the Result Preview section changes to a sawtooth wave. The Configure Simulate Signal dialog box should appear similar to Figure 5.
Figure 5
- Click the OK button to save the current configuration and close the Configure Simulate Signal dialog box.
- Move the cursor over the down arrows at the bottom of the Simulate Signal Express VI. The down arrows indicate you can reveal hidden inputs and outputs by extending the border of the Express VI.
Figure 6
- When a double-headed arrow appears, shown at left, click and drag the border of the Express VI to add two rows. When you release the border, the Amplitude input appears. In Figure 5, notice that Amplitude is an option in the Configure Simulate Signal dialog box. When inputs, such as Amplitude, appear on the block diagram and in the configuration dialog box, you can configure the inputs in either location.
Step 4: Wiring objects on the block diagram
- To use the knob to change the amplitude of the signal, you must connect two objects on the block diagram.
- Complete the following steps to wire the knob to the Amplitude input of the Simulate Signal Express VI.
- On the block diagram, move the cursor over the Knob terminal, shown at left. The cursor becomes an arrow, or the Positioning tool, shown at left. Use the Positioning tool to select, position, and resize objects.
Figure 7
- Use the Positioning tool to select the Knob terminal and make sure it is to the left of the Simulate Signal Express VI and inside the grey loop, shown at left. The terminals inside the loop are representations of front panel controls and indicators. Terminals are entry and exit ports that exchange information between the front panel and block diagram.
- Deselect the Knob terminal by clicking a blank space on the block diagram. If you want to use a different tool with an object, you must deselect the object to switch the tool.
- Move the cursor over the arrow on the Knob terminal, shown at left. The cursor becomes a wire spool, or the Wiring tool, shown at left. Use the Wiring tool to wire objects together on the block diagram.
- When the Wiring tool appears, click the arrow on the Knob terminal and then click the arrow on the Amplitude input of the Simulate Signal Express VI, shown at left, to wire the two objects together. A wire appears and connects the two objects. Data flows along this wire from the Knob terminal to the Express VI.
Figure 8
- Select File>Save to save the VI.
Step 5: Running a VI
- Complete the following steps to run the Acquiring a Signal VI.
- Display the front panel by pressing the <Ctrl-E> keys or by clicking the front panel.
- Click the Run button or press the <Ctrl-R> keys to run the VI.
- Move the cursor over the knob. The cursor becomes a hand, or the Operating tool, shown at left. Use the Operating tool to change the value of a control.
- Using the Operating tool, turn the knob to adjust the amplitude of the sawtooth wave. The amplitude of the sawtooth wave changes as you turn the knob. As you change the amplitude, the Operating tool displays a tip strip that indicates the numeric value of the knob. The y-axis on the graph scales automatically to account for the change in amplitude. To indicate that the VI is running, the Run button changes to a darkened arrow, shown at left. You can change the value of most controls while a VI runs, but you cannot edit the VI in other ways while the VI runs.
- Click the STOP button, shown at left, to stop the VI. The STOP button stops the VI after the loop completes its current iteration. The Abort Execution button, shown at left, stops the VI immediately, before the VI finishes the current iteration. Aborting a VI that uses external resources, such as external hardware, might leave the resources in an unknown state by not resetting or releasing them properly. Design the VIs you create with a stop button to avoid this problem.
Step 6 : Modifying Signal
- Complete the following steps to scale the signal by 10 and display the results in the front panel graph.
- In the block diagram, use the Positioning tool to click the wire that connects the Simulate Signal Express VI to the Waveform Graph terminal, shown at left.Press the <Delete> key to delete this wire.If the Functions palette, is not visible, select View>Functions Palette to display it.
- The Functions palette opens with the Express palette visible by default. If you have selected another palette, you can return to the Express palette by clicking Express on the Functions palette.
- On the Arithmetic & Comparison palette, select the Formula Express VI, shown at left, and place it on the block diagram between the Simulate Signal Express VI and the Waveform Graph terminal. You can move the Waveform Graph terminal to the right to make more room between the Express VI and the terminal.
- The Configure Formula dialog box appears when you place the Express VI on the block diagram. When you place an Express VI on the block diagram, the configuration dialog box for that VI always appears automatically.Click the Help button, shown at left, in the bottom right corner of the Configure Formula dialog box to display the LabVIEW Help topic for this Express VI.
- The Formula help topic describes the Express VI, the configuration dialog box options, and the inputs and outputs of the Express VI. Each Express VI has a corresponding help topic you can access by clicking the Help button in the configuration dialog box or by right-clicking the Express VI and selecting Help from the shortcut menu.
- In the Formula topic, find the dialog box option whose description indicates that it enters a variable into the formula.Minimize the LabVIEW Help to return to the Configure Formula dialog box.Change the text in the Label column of the dialog box option you read about, shown at left, from X1 to Sawtooth to indicate the input value to the Formula Express VI. When you click in the Formula text box at the top of the Configure Formula dialog box, the text changes to match the label you entered.
Figure 9
- Define the value of the scaling factor by entering *10 after Sawtooth in the Formula text box. You can use the Input buttons in the configuration dialog box or you can use the *, 1, and 0 keyboard buttons to enter the scaling factor. If you use the Input buttons in the configuration dialog box, LabVIEW places the formula input after the Sawtooth input in the Formula text box. If you use the keyboard, click in the Formula text box after Sawtooth and enter the formula you want to appear in the text box. The Configure Formula dialog box should appear similar to Figure 9.
- Click the OK button to save the current configuration and close the Configure Formula dialog box.
- Move the cursor over the arrow on the Sawtooth output of the Simulate Signal Express VI.
- When the Wiring tool appears, click the arrow on the Sawtooth output and then click the arrow on the Sawtooth input of the Formula Express VI, shown at left, to wire the two objects together.
- Use the Wiring tool to wire the Result output of the Formula Express VI to the Waveform Graph terminal. Examine the wires connecting the Express VIs and terminals. The arrows on the Express VIs and terminals indicate the direction that the data flows along these wires. The block diagram should appear similar to Figure 10.
- Use the block diagram figures as a reference. The arrangement of objects on your block diagram does not need to match the figure exactly.
Figure 10
- Press the <Ctrl-S> keys or select File>Save to save the VI.
Step 7: Displaying two signals on graph
- To compare the signal generated by the Simulate Signal Express VI and the signal modified by the Formula Express VI on the same graph, use the Merge Signals function.
- Complete the following steps to display two signals on the same graph.
- In the block diagram, move the cursor over the arrow on the Sawtooth output of the Simulate Signal Express VI.
- Use the Wiring tool to wire the Sawtooth output to the Waveform Graph terminal.The Merge Signals function, shown at left, appears where the two wires connect. A function is a built-in execution element, comparable to an operator, function, or statement in a text-based programming language.
- The Merge Signals function takes the two separate signals and combines them so that both can display on the same graph. The block diagram should appear similar to Figure 11.
Figure 11
- Press the <Ctrl-S> keys or select File>Save to save the VI.
- Return to the front panel, run the VI, and turn the knob control. The graph plots the original sawtooth wave and the scaled sawtooth wave with 10 times the amplitude, as you specified in the Formula Express VI. The maximum value on the y-axis automatically scales as you turn the knob.
- Click the STOP button to stop the VI.
Step 8: Customizing a knob control
- The knob control changes the amplitude of the sawtooth wave, so labeling it Amplitude accurately describes the behaviour of the knob. Complete the following steps to customize the appearance of the knob.
- Right-click the front panel knob and select Properties from the shortcut menu to display the Knob Properties dialog box. Click the Appearance tab to display the Appearance page.
- Label section on the Appearance page, delete the label Knob, and enter Amplitude in the text box. The Knob Properties dialog box should appear similarly Figure 12.
Figure 12
- Click the Scale tab. In the Scale Style section, place a checkmark in the Show colour ramp checkbox. The knob in the front panel window updates to reflect these changes.
- Click the OK button to save the current configuration and close the Knob Properties dialog box.
- Save the VI.
- Reopen the Knob Properties dialog box and experiment with other properties of the knob. For example, on the Scale page, try changing the colours for the Marker text colour by clicking the colour box.
- Click the Cancel button to avoid applying any changes you made while experimenting. If you want to keep the changes you made, click the OK button.
Step 9: Customizing a waveform graph
- The waveform graph indicator displays the two signals. To indicate which plot is the scaled signal and which is the simulated signal, you can customize the plots. Complete the following steps to customize the appearance of the waveform graph indicator.
- In the front panel window, move the cursor over the top of the plot legend on the waveform graph. Though the graph has two plots, the plot legend displays only one plot.
- When a double-headed arrow appears, shown in Figure 13, click and drag the border of the plot legend to add one item to the legend. When you release the mouse button, the second plot name appear.
Figure 13
- Right-click the waveform graph and select Properties from the shortcut menu to display the Graph Properties dialog box.
Figure 14
- On the Plots page, select Sawtooth from the top pull-down menu. In the Colours section, click the Line colour box to display the colour picker. Select a new line colour.
- Select Sawtooth (Formula Result) from the top pull-down menu.
- Place a checkmark in the Do not use waveform names for plot names checkbox. This action lets you edit the labels on the graph.
- In the Name text box, delete the current label and change the name of this plot to Scaled Sawtooth.
- Click the OK button to save the current configuration and close the Graph Properties dialog box. The plot color and plot legend change.
- Reopen the Graph Properties dialog box and experiment with other properties of the graph. For example, on the Scales page, try disabling automatic scaling and changing the minimum and maximum value of the y-axis.
Figure 15
Figure 16
- Click the Cancel button to avoid applying any changes you made while experimenting. If you want to keep the changes you made, click the OK button.
- Save and close the VI
----------------------------------------------------------------------------------------------------------------------
Exercise Chapter 1:
Exercise Chapter 1:
- Use DAQ USB 6210 to simulate the input signal generate from an analogue trainer.
- Connect the DAQ to your PC's and ensure your PC's communicate with the DAQ.
- Use an analogue input (AI) channel, ranging from A1 (0-15) as the input to your analogue trainer output.
- Generate an output from the analogue trainer to simulate an output display of the following.
i. Triangle with 3Vp-p
ii. Square with 1.5Vamp
iii. Sinusoidal with 2.55Vrms
- NUR WAHIDAH BINTI CHE RAHIM 51215115085
- NUR SYAFIQAH BINTI HISHAN 51215115070
- NUR IKA IREENA BINTI ISHAK 51215115065
GROUP : LO1-BO3 MONDAY 12PM-2PM CLASS
No comments:
Post a Comment