Beee305l Exp 1 SW
Beee305l Exp 1 SW
NOTE:
FOR EACH EXPERIMENT, ATLEAST FIVE PROGRAMS
SHOULD BE DONE AND THE RESULTS TO BE SUBMITTED.
1. Objectives
2. Equipment required
3. Algorithm
4. Procedure
5. Block Diagram
6. Front Panel with sample results
7. Result
Experiment No: S1
DEVELOPING A VI FOR SIMPLE APPLICATIONS
Date:
OBJECTIVES:
To learn the three parts of a VI, the three palettes, and the data flow in LabVIEW
To distinguish between controls and indicators on the front panel and block diagram
EQUIPMENT REQUIRED:
Computer with LabVIEW
THEORY:
LabVIEW Programming Basics
LabVIEW is a graphical programming language that uses icons instead of lines of text to create
applications. In contrast to text-based programming languages, where instructions determine program
execution, LabVIEW uses dataflow programming, where the flow of data determines execution.
In LabVIEW, you build a user interface by using a set of tools and objects. The user interface is
known as the front panel. You then add code using graphical representations of functions to control the
front panel objects. The block diagram contains this code. In some ways, the block diagram resembles a
flowchart.
LabVIEW programs are called virtual instruments or VIs, because their appearance and operation
imitate physical instruments, such as oscilloscopes and multimeters. Every VI uses functions that
manipulate input from the user interface or other sources and display that information or move it to
other files or other computers.
The front panel is the user interface of the VI. You build the front panel with
controls and indicators, which are the interactive input and output terminals of the VI,
respectively. Controls are knobs, pushbuttons, dials, and other input devices.
Indicators are graphs, LEDs, and other displays. Controls simulate instrument input
devices and supply data to the block diagram of the VI. Indicators simulate instrument
output devices and display data the block diagram acquires or generates.
Block Diagram
After you build the front panel, you add code using graphical representations
of functions to control the front panel objects. The block diagram contains this
graphical source code. Front panel objects appear as terminals on the block diagram.
Additionally, the block diagram contains functions and structures from built-in
LabVIEW VI libraries. Wires connect each of the nodes on the block diagram,
including control and indicator terminals, functions, and structures.
LabVIEW Palettes
LabVIEW palettes give you the options you need to create and edit the front
panel and block diagram.
The Tools palette is available on the front panel and the block diagram.
A tool is a special operating mode of the mouse cursor. When you select a tool,
the cursor icon changes to the tool icon. Use the tools to operate and modify front panel
and block diagram objects.
Select Window»Show Tools Palette to display the Tools palette. You can
place the Tools palette anywhere on the screen.
If automatic tool selection is enabled and you move the cursor over objects on
the front panel or block diagram, LabVIEW automatically selects the corresponding
tool from the Tools palette.
The Controls palette is available only on the front panel. The Controls palette
contains the controls and indicators you use to create the front panel. Select
Window»Show Controls Palette or right-click the front panel workspace to display the
Controls palette. You can place the Controls palette anywhere on the screen.
The Functions palette is available only on the block diagram. The Functions
palette contains the VIs and functions you use to build the block diagram. Select
Window»Show Functions Palette or right-click the block diagram workspace to
display the Functions palette. You can place the Functions palette anywhere on the
screen.
Dataflow Programming
Creating SubVIs
After you build a VI and create its icon and connector pane, you can use it in
another VI. A VI called from the block diagram of another VI is called a sub VI. A
subVI corresponds to a subroutine in text-based programming languages. A sub VI
node corresponds to a subroutine call in text-based programming languages. The
node is not the subVI itself, just as a subroutine call statement in a program is not the
subroutine itself.
Setting up the Connector Pane
To use a VI as a subVI, you need to build a connector pane. The connector pane
is a set of terminals that corresponds to the controls and indicators of that VI, similar
to the parameter list of a function call in text-based programming languages. The
connector pane defines the inputs and outputs you can wire to the VI so you can use it
as a subVI.
The connector pane has, at most, 28 terminals. If your front panel contains more
than 28 controls and indicators that you want to use programmatically, group some of
them into a cluster and assign the cluster to a terminal on the connector pane.
If you create a group of subVIs that you use together often, give the subVIs a
consistent connector pane with common inputs in the same location to help you
remember where to locate each input. If you create a subVI that produces an output
another subVI uses as the input, align the input and output connections to simplify the
wiring patterns. Place the error in clusters on the lower left corner of the front panel
and the error out clusters on the lower right corner.
You can designate which inputs and outputs are required, recommended, and
optional to prevent users from forgetting to wire subVI connections.
Creating an Icon
Every VI displays an icon in the upper right corner of the front panel and block
diagram windows. An icon is a graphical representation of a VI. It can contain text,
images, or a combination of both. If you use a VI as a subVI, the icon identifies the
subVI on the block diagram of the VI.
The default icon contains a number that indicates how many new VIs you have
opened since launching LabVIEW. Create custom icons to replace the default icon by
right-clicking the icon in the upper right corner of the front panel or block diagram and
selecting Edit Icon from the shortcut menu or by double-clicking the icon in the upper
right corner of the front panel.
You also can drag a graphic from anywhere in your file system and drop it in
the upper right corner of the front panel or block diagram. LabVIEW converts the
graphic to a 32 X 32 pixel icon.
Depending on the type of monitor you use, you can design a separate icon for
monochrome, 16-color, and 256-color mode. LabVIEW uses the monochrome icon for
printing unless you have a color printer.
Creating SubVIs from Sections of a VI
Convert a section of a VI into a subVI by using the Positioning tool to select the
section of the block diagram you want to reuse and selecting Edit»Create SubVI. An
icon for the new subVI replaces the selected section of the block diagram. LabVIEW
creates controls and indicators for the new subVI and wires the subVI to the existing
wires.
Equations
Example: Converting ºC to ºF
Slope of a Line
PROCEDURE:
Exercise 1. Converting ºC to ºF
2. (Optional) Select Window»Tile Left and Right to display the front panel
and block diagram side by side.
3. Create a numeric digital control. You will use this control to enter the value for
degrees Centigrade.
a. Select the digital control on the Controls»Numeric palette. If the Controls palette
is not visible, right-click an open area on the front panel to display it.
b. Move the control to the front panel and click to place the control.
c. Type deg C inside the label and click outside the label or click the Enter button on
the toolbar, shown at left. If you do not type the name immediately, LabVIEW
uses a default label. You can edit a label at any time by using the Labeling tool,
shown at left.
4. Create a numeric digital indicator. You will use this indicator to display the value
for degrees Fahrenheit.
b. Move the indicator to the front panel and click to place the indicator.
c. Type deg F inside the label and click outside the label or click the Enter
button.
6. Select the Multiply and Add functions on the Functions»Numeric palette and
place them on the block diagram. If the Functions palette is not visible, right-
click an open area on the block diagram to display it.
7. Select the numeric constant on the Functions»Numeric palette and place two of
them on the block diagram. When you first place the numeric constant, it is
highlighted so you can type a value.
If you moved the constants before you typed a value, use the Labeling tool to enter
the values.
9. Use the Wiring tool to wire the icons as shown in the block diagram.
• To wire from one terminal to another, use the Wiring tool to click the first
terminal, move the tool to the second terminal, and click the second terminal,
as shown in the following illustration. You can start wiring at either terminal.
• You can bend a wire by clicking to tack the wire down and moving the cursor
in a perpendicular direction. Press the spacebar to toggle the wire direction.
• To identify terminals on the nodes, right-click the Multiply and Add functions
and select Visible Items»Terminals from the shortcut menu to display the
connector pane. Return to the icons after wiring by right-clicking the functions
and selecting Visible Items»Terminals from the shortcut menu to remove the
checkmark.
• When you move the Wiring tool over a terminal, the terminal area blinks,
indicating that clicking will connect the wire to that terminal and a tip strip
appears, listing the name of the terminal.
• To cancel a wire you started, press the <Esc> key, right-click, or click
the source terminal.
11. Save the VI because you will use this VI later in the course. Select
File»Save.
Type Convert C to F.vi in the dialog box. Click the Save button.
12. Enter a number in the digital control and run the VI.
a. Use the Operating tool or the Labeling tool to double-click the digital control
and type a new number.
13. Right-click the icon in the upper right corner of the front panel and select Edit
Icon from the shortcut menu. The Icon Editor dialog box appears.
14. Double-click the Select tool on the left side of the Icon Editor dialog box to
select the default icon.
b. Type C and F.
Note To draw horizontal or vertical straight lines, press the <Shift> key while
you use the Pencil tool to drag the cursor.
e. Use the Select tool and the arrow keys to move the text and arrow you
created.
f. Select the B&W icon and select 256 Colors in the Copy from field to create a
black and white icon, which LabVIEW uses for printing unless you have a
color printer.
g. When the icon is complete, click the OK button to close the Icon
Editor dialog box. The icon appears in the upper right corner of the front
panel and block diagram.
18. Right-click the icon on the front panel and select Show Connector from the
shortcut menu to define the connector pane terminal pattern.
LabVIEW selects a connector pane pattern based on the number of controls
and indicators on the front panel. For example, this front panel has two
terminals, deg C and deg F, so LabVIEW selects a connector pane pattern with
two terminals.
19. Assign the terminals to the digital control and digital indicator.
a. Select Help»Show Context Help to display the Context Help window. View
each connection in the Context Help window as you make it.
b. Click the left terminal in the connector pane. The tool automatically changes
to the Wiring tool, and the terminal turns black.
c. Click the deg C control. The left terminal turns orange, and a marquee
highlights the control.
d. Click an open area of the front panel. The marquee disappears, and the
terminal changes to the data type color of the control to indicate that you
connected the terminal.
e. Click the right terminal in the connector pane and click the deg F indicator.
The right terminal turns orange.
f. Click an open area on the front panel. Both terminals are orange.
g. Move the cursor over the connector pane. The Context Help window shows
that both terminals are connected to floating-point values.
Using the techniques you learned in Part 1, create a VI to calculate the slope of
a line. Then, transform the code into a subVI using the Edit»Create SubVI
method. Save the VI as Slope.vi. Save the subVI as SlopeSub.vi. The equation for
slope is given in the Theory section.
Open a new VI and complete the front panel and block diagram as follows:
Front Panel
?
VIVA QUESTIONS:
1. What is VI?
2. What is LabVIEW?
3. What is front panel?
4. Define loop.
5. How to create indicators?
6. Icon editor is -----------------------
7. Differentiate the control and indicators.
RESULT: