Showing posts with label LabVIEW is Easy. Show all posts
Showing posts with label LabVIEW is Easy. Show all posts

Sunday, July 5, 2009

Displaying SubVIs as Expandable Nodes [LabVIEW Tutorial]

SubVIs may be viewed as either icons or expandable nodes. Express VIs are viewed as expandable nodes, by default. To view a subVI as an expandable node, right-click on it and uncheck the View As Icon option by selecting it from the pop-up menu, as shown in Figure 71. This will cause the subVI's appearance to change, such that its icon is surrounded by a yellow background, as shown in Figure 72.



Figure 71. SubVI with View As Icon setting enabled, as also indicated in its visible pop-up menu




Figure 72. SubVI with View As Icon setting disabled, appearing as an expandable node

We can resize the subVI vertically, which causes inputs and outputs to appear below the subVI's icon, as shown in Figure 73. Note that inputs and outputs made available are no longer available to the left and right of the subVI's icon.



Figure 73. Resizing (expanding) a subVI configured as an expandable node

You can also show and hide inputs and outputs from the subVI's pop-up menu, using the Select Input/Output submenu to change an input/output, Insert Input/Output to insert a new input/output, and Remove Input/Output to remove an input/output (see Figure 74).



Figure 74. Selecting the visible inputs and outputs of a subVI configured as an expandable, from its pop-up menu

Sunday, June 21, 2009

The Toolbar in LabVIEW

The Toolbar, located at the top of LabVIEW windows, contains buttons you will use to control the execution of your VI, as well as text configuration options and commands to control the alignment and distribution of objects (see Figure 59). You'll notice that the Toolbar has a few more options in the block diagram than in the front panel, and that a few editing-related options disappear when you run your VI. If you're not sure what a button does, hold the cursor over it until a tip strip appears, describing its function.

Figure 59. Toolbar




Run Button

Run Button (Active)

Run Button (Broken)

The Run button, which looks like an arrow, starts VI execution when you click on it. It changes appearance to active when a VI is actually running. When a VI won't compile, the run button appears broken.

Continuous Run Button

The Continuous Run button causes the VI to execute over and over until you hit the stop button. It's kind of like a GOTO statement (sort of a "programming no-no"), so use it sparingly.

Abort Button

The Abort button, easily recognizable because it looks like a tiny stop sign, becomes active when a VI begins to execute; otherwise, the Abort button is grayed out. You can click on this button to halt the VI.
Using the Abort button is like pulling the power cord on your computer. Your program will stop immediately rather than coming to a graceful end, and data integrity can be lost this way. You should always code a more appropriate stopping mechanism into your program, as we will demonstrate later.

Pause Button

The Pause button pauses the VI so that you can use single-step debugging options such as step into, step over, and step out. Hit the Pause button again to continue execution.

Step Into Button

Step Over Button

Step Out Button

The single-step buttonsStep Into, Step Over, and Step Outforce your VI to execute one step at a time so you can troubleshoot.

Execution Highlight Button

The Execution Highlight button causes the VI to highlight the flow of data as it passes through the diagram. When execution highlight is on, you can see intermediate data values in your block diagram that would not otherwise appear.

Retain Wire Values

The Retain Wire Values button causes the VI's wires to store the value that flowed through them the last time the VI executed. This is very useful for debugging. You can view the value stored in a wire by placing a probe on the wire. The probe value will be set to the value stored in the wire.

Warning Button

The Warning button appears if you have configured your VI to show warnings and you have any warnings outstanding. You can list the warnings by clicking on the button. A warning is not an error; it just alerts you that you are doing something you may not have intended (for example, if there are objects on the block diagram that are hidden behind other objects and cannot be seen).

Sunday, May 31, 2009

Floating Palettes in LabVIEW

LabVIEW has three often-used floating palettes that you can place in a convenient spot on your screen: the Tools palette, the Controls palette, and the Functions palette. You can move them around by clicking on their title bar and dragging. Close them just like you would close any window in your operating system. If you decide you want them back, select the palette you want from the View menufor example, View>>Tools Palette opens the Tools palette.

Controls and Functions Palettes

You will be using the Controls palette a lot, because that's where you select the controls and indicators that you want on your front panel. You will probably use the Functions palette even more often, because it contains the functions and structures used to build a VI.

The Controls and Functions palettes are unique in several ways. Most importantly, the Controls palette is only visible when the front panel window is active, and the Functions palette is only visible when the block diagram window is active. Both palettes have subpalettes containing the objects you need to access. As you pass the cursor over each subpalette button in the Controls and Functions palettes, you will notice that the subpalette's name appears in a tip strip beneath the mouse pointer (see Figure 40).



Figure 40. Controls palette




To select an object in the subpalette, click the mouse button over the object, and then click on the front panel or block diagram to place it where you want it.

Palette Item Categories

At the top level of the palettes are several "Categories," such as Modern, System, Classic, Express, Addons, Favorites, and others. You can expand and close these categories, by clicking on them, to navigate the tree of items and subcategories that are available within the palette.

One great category is Favorites (this is only present on the Functions palette, not the Controls palette). You can use this to group together items that you access frequently. When you find a function, structure, VI, or subpalette that you really like, right-click on the object and select Add Item to Favorites from the shortcut menu. This will add the object to the Favorites category, for quick and easy access.

Showing and Hiding Palette Categories

You can choose which categories you want to appear on the Controls or Functions palettes by pressing the View button and then selecting categories from the Always Visible Categories submenu. If you want all of the categories to be visible, select the Show All Categories option from the Always Visible Categories submenu (see Figure 41).



Figure 41. The Always Visible Categories
submenu of the palette View button


If a category is not selected in the Always Visible Categories, then you will not normally see it in the palette. However, you can temporarily display all of the categories by clicking on the double "down" arrows at the very bottom of the palette, as shown in Figure 42. You can hide those categories again by clicking on the double "up" arrows at the very bottom of the palette, as shown in Figure 43.



Figure 42. Functions palette with only
the "always visible" categories visible




Figure 43. Functions palette with all categories visible


Reordering Palette Categories

You can reorder the palette categories by right-clicking on them and choosing Move this Category Up, Move this Category Down, or Move to Top (Expand by Default). Additionally, you can drag and drop the categories within the list by clicking on the two vertical grab-bars (||) to the left of the category text.

Palette View Formats

The way that you navigate the palettes can be changed by choosing a different palette View Format. Pressing the View button at the top of a palette will open a menu. In the View This Palette As submenu, you can choose from six different View Formats, as shown in Figure 44.



Figure 44. The View This Palette As submenu
of the palette View button menu showing the
currently selected checked palette view format


Category (Standard) is the default View Format, and the one shown throughout this tutorial.

Category (Icons and Text), shown in Figure 45, is similar to Category (Standard), except that each item's name appears directly beneath its icon.



Figure 45. "Category (Icons and Text)" palette view format

Icons, shown in Figure 46, is the format that most are familiar with from previous versions of LabVIEW. Each subpalette and item is represented by an icon. When you mouse-over an item, its name appears at the top of the palette.



Figure 46. "Icons" palette view format

Icons and Text, shown in Figure 47, is similar to Icons, except that each item's name appears directly beneath its icon.



Figure 47. "Icons and Text" palette view format


Text, shown in Figure 48, is minimal. It behaves like the Icons and Icons and Text formats, where clicking on a subpalette navigates down into that subpalette. Subpalettes are represented by folders with names, and items are represented by their name.



Figure 48. "Text" palette view format

Tree, shown in Figure 49, is also minimal, having only folder icons and item names. However, it behaves more like the Category formats, having a tree hierarchy.



Figure 49. "Tree" palette view format

The "Icons," "Icons and Text," and "Text" palette view formats all have an "up" button (see Figure 50), which, when pressed, returns you to the previous ("owning") palettesince these view formats are not a tree view. You can search for a specific item in a palette by clicking on the spyglass icon (see Figure 50).



Figure 50. The buttons at the top of each palette are used for navigation and configuration options.

There is another way to navigate palettes that some people find a little easier. Instead of each subpalette replacing the current palette, you can pass through subpalettes in a hierarchical manner without them replacing their parent palettes. You can do this by right-clicking (Windows) or control-clicking (Mac OS X) the subpalette icons (see Figure 51).



Figure 51. A floating subpalette created by right-clicking on a subpalette icon

Note that some subpalettes have subpalettes containing more objects; these are denoted by a little triangle in the upper-right corner of the icon and a raised appearance (see Figure 52). We'll discuss specific subpalettes and their objects in the next chapter.



Figure 52. Functions palette with two levels of floating subpalettes visible

Sunday, May 24, 2009

Alignment Grid & Pull-Down Menus in LabVIEW

Alignment Grid

you probably noticed the grid lines on the VI's front panel and how the waveform chart and stop controls "snap" to the grid lines as you move them around with the mouse. This feature is very useful for keeping your front panel objects aligned. If you do not like this feature, you can turn it off in the LabVIEW Options dialog. (Figures 30 and 31 show a VI front panel with the alignment grid feature turned ON and OFF, respectively.) Open the options dialog by selecting Tools, Options. . . from the menu. Navigate to the Alignment Grid category. From here, you can choose to show or hide the grid lines and to enable or disable grid alignment. If you are not sure of your preference, leave the alignment grid onyou'll probably like it.


Figure 30. VI with alignment grid option ON



Figure 31. VI with alignment grid option OFF

Pull-Down Menus

Keep in mind that LabVIEW's capabilities are many and varied. This tutorial by no means provides an exhaustive list of all of LabVIEW's ins and outs (it would be several thousand pages long if that were the case); instead, we try to get you up to speed comfortably and give you an overview of what you can do. If you want to know everything there is to know about a subject, we'd recommend looking it up in one of LabVIEW's many manuals, attending a seminar, or going to ni.com/labview on the Web. Feel free to skim through this section and some of the subsequent ones, but remember that they're here if you need a reference.

LabVIEW has two main types of menus: pull-down and pop-up. You used some of them in the last activity, and you will use both extensively in all of your program development henceforth. Now you will learn more about what they can do. We'll cover pull-down menu items very briefly in this section. You might find it helpful to look through the menus on your computer as we explain them, and maybe experiment a little.

The menu bar at the top of a VI window contains several pull-down menus (in Mac OS X, the menu bar will be at the top of the screen, consistent with other Mac OS X applications). When you click on a menu bar item, a menu appears below the bar. The pull-down menus contain items common to many applications, such as Open, Save, Copy, and Paste, and many other functions particular to LabVIEW. We'll discuss some basic pull-down menu functions here. You'll learn more about the advanced capabilities later.

Many menus also list shortcut keyboard combinations for you to use if you choose. To use keyboard shortcuts, press the appropriate key in conjunction with the control key on PCs, the command key on Macs, and the meta key on Linux.

File Menu

Pull down the File menu , which contains commands common to many applications, such as Save and Print. You can also create new VIs or open existing ones from the File menu. In addition, you can show VI Properties information and development history from this menu.



Edit Menu

Take a look at the Edit menu (see Figure 33). It has some universal commands, like Undo, Cut, Copy, and Paste, that let you edit your window. You can also search for objects with the Find and Replace . . . command and remove bad wires from the block diagram.


Figure 33. Edit menu

View Menu

In the View menu (see Figure 34), you will see options for opening the Controls Palette, Functions Palette, and Tools Palette if you've closed them. You can also show the error list and see a VI's hierarchy. The Browse Relationships submenu contains features to simplify navigation among large sets of VIs, such as determining all of a VI's subVIs and where a VI is used as a subVI.



Project Menu

The Project menu (see Figure 35) allows you to open a LabVIEW project or create a new project, as well as operate on the project to which the active VI belongs. If the active VI does not belong to any LabVIEW project, only the Open Project and New Project menu items will be enabled.



Operate Menu

You can run or stop your program from the Operate menu (see Figure 36), although you'll usually use Toolbar buttons. You can also change a VI's default values, control "print and log at completion" features, and switch between run mode and edit mode.


Figure 36. Operate menu

Tools Menu

The Tools menu (see Figure 37) lets you access built-in and add-on tools and utilities that work with LabVIEW, such as the Measurement & Automation Explorer, where you configure your DAQ devices, or the Web Publishing Tool for creating HTML pages from LabVIEW. You can view and change the myriad of LabVIEW's Options


Figure 37. Tools menu

Window Menu

Pull down the Window menu (see Figure 38). Here you can toggle between the front panel and block diagram windows, "tile" both windows so you can see them at the same time, and switch between open VIs.


Figure 38. Window menu

Help Menu

You can show, hide, or lock the contents of the Context Help window using the Help menu (see Figure 39). You can also access LabVIEW's online reference information and view the About LabVIEW information window.


Figure 39. Help menu

Monday, May 18, 2009

LabVIEW - Getting Started

1. Launch LabVIEW (if it's been open, you can quit it first).

2. At the LabVIEW Getting Started dialog, click Blank VI to create a new blank VI (the Blank VI option is found under the New heading, and you have to click on the "Blank VI" text, not the icon). An "Untitled 1" VI front panel will appear on your screen.

Go to the floating Controls palette and navigate (by clicking) to the Modern Graph, subpalette, shown in Figure 17. If the Controls palette isn't visible, select View Controls Palette from the menu to make it visible. Also, make sure the front panel window is active, or you will see the Functions palette instead of the Controls palette.



Figure 17. Modern Graph palette showing the Waveform 
Chart and various other charts and graphs

On the Graph subpalette, select Waveform Chart by clicking it with the mouse button.



You will notice that, as you run the cursor over the icons in the Controls palette and subpalettes, the selected button or icon's name appears in a tip strip, as shown in Figure 17.



Positioning Tool

You will see the outline of a chart with the cursor "holding" it, as shown in Figure 18. Position the cursor in a desirable spot on your front panel and click. The chart magically appears exactly where you placed it, as shown in Figure 3.19. If you want to move it, select the Positioning tool from the Tools palette, and then drag the chart to its new home. If the Tools palette isn't visible, select View , Tools Palette from the menu.



Figure 18. Waveform Chart after it has been 
dragged onto the front panel (and before it has been dropped)





Figure 19. Waveform Chart after it has been dropped onto the front panel


3. Go back to the Modern subpalette; then navigate into Boolean subpalette, and choose Stop Button (see Figure 20).


Figure 20. Modern , Boolean palette showing the 
Stop Button and other Boolean controls and indicators


Place it next to the chart, as shown in Figure 21.



Figure 21. Your VI front panel, after 
adding a Waveform Chart and Stop Button


4. Now change the chart's Y-axis scale range from -10 thru +10 to 0 thru 1. Highlight the number "10" (Y-axis range max) by click-dragging or by double-clicking on it with the Text Edit tool. Now type in 1.0 and click on the enter button that appears in the Toolbar at the top of the window. Change -10 (Y-axis range min) to 0 in a similar manner.



Enter Button

5. Switch to the block diagram by selecting Show Block Diagram from the Window menu. You should see two terminals already there, as shown in Figure 22.



Figure 22. Your VI block diagram, showing the 
Stop Button and Waveform Chart terminal


6. Now you will put the terminals inside a While Loop to repeat execution of a segment of your program. Go to the Programming , Structures subpalette of the floating Functions palette and select the While Loop (see Figure 23). Make sure the block diagram window is active, or you will see the Controls palette instead of the Functions palette.



Figure 23. Programming , Structures palette showing 
a While Loop and other LabVIEW structure


Your cursor will change to a little loop icon. Now enclose the DBL and TF terminals: Click and hold down the mouse button while you drag the cursor from the upper-left to the lower-right corners of the objects you wish to enclose (see Figure 24).


Figure 24. Dragging the mouse cursor around a region of code


When you release the mouse button, the dashed line that is drawn as you drag will change into the While Loop border (see Figure 25). Make sure to leave some extra room inside the loop.



Figure 25. A While Loop containing the code 
that was enclosed by the dragged region


7. Go to the Functions palette and select Random Number (0-1) from the Programming , Numeric subpalette. Place it inside the While Loop.

8. With the Positioning tool active, arrange your diagram objects so that they look like the block diagram in Figure 26.



Positioning Tool



Figure 26. Your block diagram after 
placing the Random Number (0-1) function

9. With the Wiring tool active, click once on the Random Number (0-1) icon, drag the mouse over to the Waveform Chart's terminal, and click again (see Figure 27).



Figure 27. Your block diagram, as you 
drag a wire from the Random Number (0-1) 
function to the Waveform Chart terminal.


You should now have a solid orange wire connecting the two icons, as shown in Figure 28. If you mess up, you can select the wire or wire fragment with the Positioning tool and then hit the key to get rid of it. Now wire the Boolean TF terminal to the conditional terminal of the While Loop. The loop will execute while the switch on the front panel is FALSE (not pressed down) and stop when the switch becomes TRUE (pressed down).



Figure 28. Your block diagram after 
completing the wiring task

10. You should be about ready to run your VI. First, switch back to the front panel by selecting Show Front Panel from the Window menu. Now click on the run button to run your VI. You will see a series of random numbers plotted continuously across the chart. When you want to stop, click on the stop Boolean button using the Operating tool (see Figure 29).



Figure 29. Your VI front panel 
after pressing the Run button


11. Create a directory or folder called MYWORK in a convenient location (such as your home or documents directory). Save your VI in your MYWORK directory or folder by selecting Save from the File menu and pointing out the proper location to save to. Name it Random Number.vi.

Your IP Address