TAMPL REU 99 LabVIEW Tutorial

LabVIEW Tutorial 1: Extra Features

Goal of this tutorial:

To learn some of the neat features in LabVIEW that can make programs more user-friendly. To learn good programming habits to make it easier for other people to edit your program.

Formatting

  1. Numerical inputs and outputs:

·  create a numerical input on the front panel. The default format is 0.00 – a floating point notation with 2 decimal points.

·  changing the precision: Right-click on the icon, Format & Precision, choose # of digits (beyond the decimal), and the format of the number.

·  increment: Right-click, Data Range, Increment. This changes the increment by which the value in a numerical control changes each time you press on the up/down arrow.

  1. Graphs

·  create an array in the front panel, containing numerical controls. Type in a few numbers and plot this on a waveform graph.

·  X and Y axes: Right-click on graph, X (or Y) Scale.

–  AutoScale: turn autoscale “on” to have the graph adjust automatically to the data range. Turn this “off” to maintain a constant data spacing and range.

–  Formatting: change precision and format of the scale. Choose style (markers and axes labels).

–  Alternatively, use the palette below the graph to format the grids. The two buttons on the left side (x and y with arrows) toggle AutoScale option, and the second buttons (x.xx and y.yy) access scale options.

·  grids: Right-click on graph, choose either axes scale. In Grid Options, click on left button to choose a style and the right button to change grid color.

·  colors: Switch to the paintbrush tool using the Tools palette or Tab. Right-click inside the graph and pick a background color. If your grid is on, you might end up changing the color of the grid – if you have difficulties clicking on the graph background, turn off the grid first, change the color, and turn the graph back on.

·  points and lines:

–  re-size the legend if you have multiple lines by dragging the lower-right corner of the legend.

–  line color: right-click on the line in the legend and choose color.

–  line and point style: right-click on the line in the legend and go to appropriate options. To turn the off, go to right-click on line and go to interpolation.

·  legend: switch to text tool using the Tools palette or Tab. Click on the line names (Plot 0, …) and type in a name of your choice.

·  view: turn on/off legends and palettes by right-clicking on graph, go to Show, and choose the appropriate option.

  1. Boolean buttons

·  mechanical actions: you can choose from six type of button behavior. Right-click on button, choose Mechanical Action.

–  Switch When Pressed: value switches between True/False each time the mouse button is pressed.

–  Switched When Released: value switches between True/False each time the mouse button is released.

–  Switch Until Released: value switches between True/False each time the mouse button is pressed, and switches back to original value when you release the mouse button.

–  Latch When Pressed: value switches between True/False when the mouse button is pressed. After that value is used by the computer and the program goes onto the next step, the button returns to original setting.

–  Latch When Released: value switches between True/False when the mouse button is released. After that value is used by the computer and the program goes onto the next step, the button returns to original setting.

–  Latch Until Released: value switches between True/False each time the mouse button is pressed, and switches back to original value after you release the mouse button and the program proceeds to the next step.

·  choosing options such as “Switch Until Released” saves us from re-setting the button value every time the program is executed.

User-Friendly Features

  1. Descriptions

·  On any control or indicator, you can right-click and choose Data Operations à Description… to add comments for the icon.

·  The descriptions will show up when you use the Help window and point to that icon. Adding descriptions helps other people who may use your program.

  1. Setting Default Values

·  If there are values in control that are rarely changed, you can set this as the default value by right-clicking on the icon and choosing Data Operations à Make Current Value Default. Save the program. The next time you open the program, this value will appear as default.

·  If you want to make all the values in the program default, go to Operate à Make Current Values Default. Save the program.

Good Programming Habits

  1. Do not cross wires

·  Crossed-wires in the diagram make it very difficult for people (including yourself) to read your program.

·  Avoid wire crossing as much as possible. If you need to cross wires, do so in a non-crowded area.

·  Try to make the diagram so that the program flows from left to right (all inputs on left, all outputs on right).

  1. Sequences

·  Sequence structures help organize program by enforcing certain tasks to be performed in order.

·  If a program becomes too large to fit on one screen, it’s a good idea to create a sequence structure and continue in the next frame instead of scrolling out of the monitor.

  1. Sub-Vi’s

·  Use sub-vi’s whenever you have complex operations that appear multiple times.

·  Sub-vi’s reduce the clutter in a diagram and make it easier to read. Furthermore, organizing programs into smaller modules prevents errors and confusion.

·  It is easier to re-use or modify parts of a program if it is written using sub-vi’s.

Extras

  1. Colors

·  Front panels of LabVIEW program can be colored for visual purposes.

·  Choose the paintbrush tool (Tab, or from Tools palette), right-click on an object, and choose a color.

·  To change the font color, highlight the text, go to the font options in the middle of the lower toolbar (it should say 13pt Application Font), and choose Color. You can also change the size and style of texts.

  1. Decorations

·  Decorations can be placed around controls and indicators to organize the front panel. They are found at Controls à Decorations.

·  Once you place a decoration around the controls / indicators, click on the decoration, and arrange it so that it appears behind the objects. Click on the “arrange” option on the lower toolbar (it has two black arrows on it), and choose “Move to Back.” (If this option is missing on the toolbar, look in the Edit menu.)

  1. Aligning objects

·  You can align objects on the front panel for organization. Aligning option is at the lower toolbar, next to the font options (it has green and yellow rectangles on it).

·  Distribute options allow you to evenly space objects. The option is located next to the right of the aligning options on the lower toolbar.

  1. Program icons

·  You can make your own icon for your program. This is especially useful when you are making a sub-vi, since you will be able to recognize the program when it shows up in the diagram of another program.

·  Right-click on the icon at upper-right corner of the front panel. Choose “Edit Icon…”

·  Choose from black/white, 16-color, or 256 color.

·  Use drawing tools in the palette to draw an icon. Choose color by clicking on the front box at bottom of the palette. Choose background color by clicking on the box behind it.

·  Click on “OK” when you’re done. The new icon should appear on the upper-right corner of the front panel.

2