PY 452 Advanced Physics Laboratory
Labview is a graphical programming interface to electronics instruments from a computer. It is from National Instruments who call the programming language G. We will use LabView for most of the measurements in this lab. This document is to provide you with a rudimentary introduction to G and the interfaces.
Labview provides two ‘views’ of each graphical program or virtual instrument (vi): (1) the front panel and (2) the diagram. A menu item (or control key ‘e’) switches between the two. Each has its own set of cursor modes, auto-selected by default, or chosen in a toolbar or with the tab key or space bar for editing, coloring, text wiring, etc: know what cursor mode you are in. The front panel is supposed to represent the face of a virtual instrument. This is where the user interacts with the program (sets variables) and where results are displayed. If you want to set something or look at something, you must insert it into the front panel. Use the right mouse button (PC) or control-mouse button (Mac) in the panel to get a pop-up window (when in doubt of what to do for anything in LabView, not just this, right click on the object). You can choose from numeric controls (inputs) numeric displays (prog fills in) graphs, etc. Choose what you need and click in the window to place it. Type the name, etc. Right mouse or cmd-mouse to change options, etc. Jump to the diagram panel when the human interface (front panel) is finished. Any graphical program (VI) can be a graphical sub-program (sub-VI). Set the connections in a diagram defined in the front panel at the box in the upper right – right click.
The objects you entered on the front panel show up in the diagram. To connect them, choose the wire tool (wiring cursor mode). To add more things (such as data acquisition or processing), get a pop up menu with the right mouse button (PC) or cmd-mouse (Mac). They are grouped by function (numeric, acquisition, analysis, user-defined, etc). This is a full service programming environment with all the standard tools, etc -- although it takes a lot of space. Once you choose a type of object, click in the diagram to insert; it will appear as an icon, which can be wired to and from. Use the right mouse button or cmd-mouse on the wiring nodes in wiring mode to get a constant; use it on objects to change their parameters. The names (given in front panel) of sub-programs (sub-VI’s) show up when the wiring tool is over them. Double click to bring the sub-VI up as an editable item. When wiring, note that the color represents data type and the width of the line the array type (0-d, 1-d, 2-d, etc.). Black dotted lines means you have goofed and the things can’t be wired. The VI won’t run until all wires are O.K. Structures can be an issue here. An output has to be wired from each case of a case statement.
For/while structures (loops) have special ways of transfering data from one iteration to the next -- see help or manual. There are a number of ways to get the number of iterations set for a for loop (wiring an array input -- it automatically figures it out, or wiring to the N block). Special structures not found in other prog environments are the formula node (which saves space and works much like a standard programming language) and the sequence (when you want to insure that things happen in a certain order -- useful here is the wait routine).
Some notes about execution order: don’t worry about it if you don’t care what happens first - LabView follows the ‘data-path’ of what needs the output of what to execute. Usually there are several data-paths that execute concurrently. To control the execution (many times not needed), use the sequence box or use dummy inputs/outputs to make a ‘dummy’ data-path. Often the error clusters set the data-path. (Yes, you should watch your errors. Otherwise you may never find out that the problem is that your computer doesn’t see your card.)
Another thing you should know about are clusters, known in some languages as structures. These allow you to keep related things together. Some outputs, such as plots, take several types of inputs including clusters, see the help (wire it and it changes its type). One can also get attribute nodes for many objects (right mouse or cmd-mouse) on the object in the front panel. The node shows up in the diagram and you can choose one or more attributes and wire.
How do the input/ output VI’s get to the real world? The LabView drivers are quite smart and can adapt to the board. You will get an error if the acquisition VI is not supported by the hardware. Otherwise, it will appear/ come from the channel you programmed. The national instrument card manuals have diagrams that tell you where each comes out on the ribbon cable (find the chart in the card’s manual). It has TTL inputs/outputs for digital lines (use for running stepper motors), counters, and timing; and analog inputs/ outputs. There is a NI-DAQ configuration utility to set/check device locations, etc.
Other questions: Help, manuals, or ask.
PY 452 Advanced Physics Laboratory
Measure the frequency output by a signal generator:
Connect the signal generator to the card via a BNC on one end cable and the green connector block w/ribbon cable. Use the chart in the manual (taped onto the top of most computers) to guide you in connections (ADC is analog to digital converter, or input; in differential mode, ADC0 is the one so labeled and the one across from it – it subtracts those two voltages to get the differential signal)
(do) Use the DAQ card to read in voltages (waveform). Justify your sampling rate and amplification. Plots (graph) the signal as a function of time on the front panel. Enable (right click) the cursor view to get accurate info from the plot.
(suggested) I suggest that you use the LabView analysis vi’s to obtain the frequency and amplitude, and display it on the front panel. If so, you will get the frequency spectrum of the data – why not plot that as a separate graph?
(optional) If you want to learn more or have time to kill, use a multimeter with a RS-232 (serial) interface (the Metex meters in the maroon cases). Find the commands in the manual – you need to send it a ‘D’ character and it sends you back the data it is displaying. Use the metex.vi and others in the user.lib folder (something like c:programs\national instruments\labview\) as examples to start. Remember that the serial interface sends characters.
(do) Demonstrate the program to me.
I suggest that you use LabView for most measurements throughout the semester, such as for your electronics lab. You will use it for your experiment (probably), although I can put together the routines if you ask me to. In my experience, LabView is good, but few supplied instrument control vi’s (not National Instrument products) work, so you will need to know how to debug them.
(You should be able to finish this in the rest of the lab time.)