You are on page 1of 60

LabVIEW Course

Leiden University

Contents
CONTENTS ...................................................................................... III INTRODUCTION ................................................................................ 1 STRUCTURE OF THIS LABVIEW COURSE .................................................................... 1 LAB JOURNAL AND COURSE GRADE ............................................................................ 1 SAVING YOUR VIS .................................................................................................... 1 ANNOTATE YOUR CODE ........................................................................................... 2 TIPS, TRICKS & SHORTCUT KEYS .............................................................................. 2 EXTRA CREDIT ........................................................................................................ 2 PRACTICUM 1 ................................................................................... 3 FRONT PANEL & BLOCK DIAGRAM............................................................................ 3 COMPUTER SETTINGS .............................................................................................. 3 Automatic Tool Selection .................................................................................. 4 Hello World ....................................................................................................... 4 DATA TYPES: FLOATS, BOOLEANS, ETC. .....................................................................5 EXECUTION HIGHLIGHTING ..................................................................................... 6 WHILE LOOPS ..........................................................................................................7 FOR LOOPS.............................................................................................................. 8 DATA TYPES: ARRAYS .............................................................................................. 9 DATA TYPES: STRINGS ............................................................................................ 10 DECISION MAKING .................................................................................................. 11 SHIFT REGISTERS ................................................................................................... 13 VISA COMMUNICATIONS ........................................................................................ 15 SYNTHESIZER ......................................................................................................... 17 SEQUENCE STRUCTURES ......................................................................................... 17 WAIT STATEMENTS................................................................................................. 18 GPIB READING ...................................................................................................... 19 A/D CONVERSION .................................................................................................. 19 Loudspeaker .................................................................................................... 20 PC Operated Frequency Sweep ...................................................................... 20 I/O CARDS AND DAQ ............................................................................................. 21 SINGLE POINT OUTPUT .......................................................................................... 22 MULTIPLE POINT OUTPUT ..................................................................................... 24 BASIC PLOTTING: WAVEFORM GRAPH .................................................................... 26 DATA TYPES: CLUSTERS ..........................................................................................27 CONTINUOUS OUTPUT ............................................................................................27 A LABVIEW FUNCTION GENERATOR ..................................................................... 28

SINGLE POINT INPUT ............................................................................................. 30 MULTIPLE POINT INPUT ........................................................................................ 30 CONTINUOUS INPUT .............................................................................................. 30 Continuous Input: Details .............................................................................. 32 AUTOMATED DATA STORAGE ................................................................................. 33 DATA TYPES: PATHS .............................................................................................. 34 Check the 5 V Voltage Source.......................................................................... 34 ADC LIMITATIONS ................................................................................................ 34 CUSTOM SUB-VIS .................................................................................................. 35 The Temperature Converter ........................................................................... 35 Using Custom Sub-VIs .................................................................................... 36 DATA TYPES: WAVEFORMS .................................................................................... 36 MEASUREMENT & AUTOMATION EXPLORER ............................................................37 PROPERTY NODE ....................................................................................................37 RS232 COMMUNICATION .......................................................................................37 PRACTICUM 2 ................................................................................. 39 THEORY ................................................................................................................ 39 BASIC DIGITAL FEEDBACK MECHANISMS ................................................................. 41 Proportional Feedback (P-control) ................................................................ 42 Integrating Feedback (I-control) ................................................................... 42 Differential Feedback (D-control) .................................................................. 43 COMBINED FEEDBACK MECHANISMS ....................................................................... 43 Proportional & Integrating Feedback (PI-control) ....................................... 43 Proportional, Integrating & Differential Feedback (PID-control) ............... 44 THE PHYSICS OF NTC RESISTORS .......................................................................... 45 THE HEATING DEVICE ........................................................................................... 46 EXPERIMENT ..........................................................................................................47 Precautions .......................................................................................................47 Hardware .........................................................................................................47 Thermal Response Time ................................................................................. 48 Software .......................................................................................................... 49 TEMPERATURE CONTROL WITH PI FEEDBACK.......................................................... 50 Optimization of the feedback parameters ...................................................... 50 REFERENCES .......................................................................................................... 51 PRACTICUM 3 ..................................................................................53 LABVIEW KEYBOARD SHORTCUTS ................................................55

Introduction
LabVIEW is a programming language developed by National Instruments, and designed to facilitate communication between different types of hardware, such as personal computers, function generators, A/D converters, et cetera. It has a graphical way of depicting pieces of code, instead of being text-based.

Structure of this LabVIEW course


This course is an introduction to programming with LabVIEW in an experimental physics environment. You will learn how to use a computer to control physics experiments and how to automate measurements. The course is structured as a general introduction (practicum 1, 3 afternoons), programming of feedback loop to control temperature (practicum 2, 2 afternoons) and an open experiment (practicum 3, 3 afternoons). There is sufficient time to complete the programming and keep a lab journal during the course. We do expect that you prepare at home by reading the manual and answering as much of the questions as possible.

Lab journal and course grade


You will work in pairs in this course. The two of you need only keep one lab journal. For practicum 1 you are only required to write down the answers to the questions in your lab journal, perhaps adding prints of some block diagrams; you will be asked to do so when necessary. To make effective use of the available lab facilities and the teaching assistants during the course it is important to read the text in between the questions. This text often contains the information that you need to answer the questions.Before the start of practicum 2, there are also some homework questions that you should answer in your lab journal. Do this before the start of practicum 2, otherwise you will lose valuable time. In practicum 2 and 3, you are required to keep a full lab journal, as you would with laboratory experiments. Make sure to switch tasks during the course. Do not let one person do all the programming and the other do all the writing. Turn in your lab journal at the end of practicum 3 for grading. The final grade is depends on the questions answered in practicum 1 and 2, but is mostly determined by your labjournal and your performance during the experiments in practicum 2 and 3. Incomplete labjournals will not be graded!

Saving Your VIs


Be sure to save your VIs regularly, preferably every time it is required in the course to add new functionality. This will facilitate debugging, and can be handy 1

for future reference. Saving consecutive versions of VIs is also a standard laboratory practice.
There are several saving options when you select File | Save As in LabVIEW. Choosing Substitute copy for original is most convenient if you just want to save the current VI as version x.y and continue with programming. If the LabVIEW Help is open, you can see what the different saving options exactly mean.

Annotate Your Code


In a normal programming language, you can add comments to your program. In C++, for example, you use the // characters to do this. In LabVIEW, you can double-click on the white background of the block diagram to create a box in which you can type a comment. Do not forget this! The assistants will have to review your programs when they grade your lab journal. If your programs do not make sense because of a lack of explanation, then you will get a lower grade.

Tips, Tricks & Shortcut Keys


You can find them in the addendum by National Instruments, included in this manual. Learning them by heart immediately is possible, but it is easier to learn them while you learn to use LabVIEW.

Extra Credit
Sometimes an [E]-symbol is added to a question in this manual. This means the question is optional. Skip it if you do not have enough time to complete the necessary questions; you can always do it later.

Practicum 1
In this practicum you will be introduced to the basics of LabVIEW. To start, open LabVIEW and create a Blank VI.

Front Panel & Block Diagram


What you should see in front of you are two panels: a white and a grey one. The grey one is the Front Panel, and will contain the interface of your program, with buttons, indicators, and so on. The white one is called the Block Diagram, and will contain the actual code itself, so the for-loops, the multiplications, et cetera. There are several ways to arrange these panels on your desktop: in Window, you can select the tiling Left and Right or Up and Down, which creates a nonoverlapping tiling of the two panels. You can also keep the panels overlapping, and use Ctrl - E to swap between the two while programming. The programs you make can be run with this button:

Figure 1: Run.

Ctrl - R has the same effect; try this. The button next to it can be used to run a program over and over again, but handle this button with care; with some kinds of mistakes in your program, running it in a loop can crash your computer. Note also that it is bad practice to use this button instead of a loop in your program. To interrupt programs while running use Ctrl - . (Ctrl-dot) or the Abort button depicted in Figure 2. This button is depicted as inactive, but will be active when a program is running. Dont use this button as a normal way of stopping your program, only use it when there is a problem!

Figure 2: Abort Execution.

Computer Settings
The LabVIEW interface can be customized to a large extent. However, to keep this manual readable and to facilitate teaching assistant supervision during the course, it is more convenient to use standard settings. However, there is one thing that you should change about the Functions Palette that you can open by right-clicking on the block diagram. In the palette, click on View | Change Visible Categories. Make sure that Programming is turned on (this is where all the basic functions are that you will be learning about) and Express is turned off (which you will not use in this course.) 3

Automatic Tool Selection Now open View | Tools Palette and make sure the top button with the wrench and screwdriver (automatic tool selection) is turned on, as shown in Figure 3. This makes sure that while using LabVIEW, the proper tool is selected for your needs automatically. This allows you to keep the Tools Palette closed for most of the time, freeing up space on your screen. If, for any reason, you need to select a tool manually, this is what they do: Finger: push buttons Pointer: select, resize Text Tool: write text or numbers Bobbin: create wires between objects, create connected controls/indicators Menu Tool: same as right-click Hand: pan Breakpoint: create point where program pauses (execution can be resumed) Probe: show contents of wire during execution Pipette: assume color Brush: paint with color

Figure 3: Tools Palette.

Hello World
Save your VIs before you run them. This can save you hours of work; some students have learned this the hard way.

Traditionally, when you learn a programming language, you start by writing a program that prints Hello World. The idea is that writing an entirely trivial program lets you figure out how to edit it and run it without being distracted by bugs. Since LabVIEW is a graphical programming language, we will choose a different task, but it will be just as simple. Follow the text and, if you get stuck, check the footnotes for tips. 4

Right click on the front panel and click on the drawing pin on the pop-up screen. This will lock this pop-up screen. Now place a Numeric Indicator on the front panel and obtain a picture1 as in Figure 5. Now go to the block diagram via Window | Show Block Diagram or Ctrl - E , and connect a Control to the indicator you just made. This can be done with the pop-up menu opened by rightclicking on the indicator2. See Figure 4. This will create an object that allows you to insert any number at that point into the program. Double-click now on this newly created control in the block diagram; this will make you jump to front panel (alternatively, Ctrl - E will get you back to the front panel as well), where you can enter a number in the control. The control accepts many different notations: 1E2, 2e3, 3.4, 5k, 6m and 7M are all allowed. Now use the run button to start your first LabVIEW program.

Figure 4: Create Control. Figure 5: Create numeric indicator.

Data Types: Floats, Booleans, etc.


Just as many other programming languages, LabVIEW also supports different types of data types. Examples are integers, Booleans (true/false), complex numbers, and double precision floats, like the one you just used. To see what the Booleans look like (remember: this is a graphical programming language, so all its elements have a certain look), we shall now extend the program with an element that can check whether the number you just typed is larger than a prespecified number. To do this, right-click on the block diagram, and select Programming | Comparison | Greater (from now on the Programming division shall be assumed unless otherwise stated). Place this icon on the block diagram, somewhere close to the line between the two orange boxes. You have now placed a sub-VI on your block diagram. Compared to C++, this would
Click on Express | Numeric Indicators, and select the Numeric Indicator or Num Ind (hover over the icons to see what they are called). Now place this indicator somewhere on your front panel.
1 2

Hover over the box and notice how the pointer changes into a bobbin.

roughly be a function that you can call from main. LabVIEW comes with a large library of sub-VIs with all sorts of functionalities, and they can be accessed via the function palette. In addition, you can make custom sub-VIs; that will be the subject of a later section of this practicum. Connect3 your control to the x-terminal of the comparison sub-VI. Create a control on the y-terminal with the steps outlined above. Create4 an indicator for the Boolean that comes out of the Greater? sub-VI. Now go to the front panel and check whether your program responds the way you expect it to respond. Q.1 How does the Boolean indicator change if it changes from False to True (or vice versa)?
This might be the first place where you encounter a bug in your program. If your program cannot be run, the Run button will have changed. If this is the case, you can click on this button to see where the bug(s) is (are) located.

Execution Highlighting
Once you have a program that works properly, you can look at the following functionality which makes LabVIEW very convenient at times. Go to the block diagram and click the following button (Figure 6):

Figure 6: Execution highlighting.

Now run the program and observe what happens. This Execution highlighting can be quite handy to debug your program. It slows down the program, and allows you to observe the values on all the wires, controls, indicators, et cetera, in your program. If you do not want to slow down your program, but nevertheless want to see what data is on a certain wire, right-click on the wire and use the Probe, while running the program.

Click with the bobbin on the orange line in your program, and connect the dotted line to the xterminal.
3 4

Right click on the left terminal and select Create | Indicator.

Q.2 What are the difference(s) between the block diagram icons that represent inputs and outputs? Dont be confused by the differences between the datatypes represented by the input or output!

While Loops
To repeat certain operations, LabVIEW can execute while- and for loops. Their function is virtually identical to those bearing similar names in C++. To illustrate their behavior, go to the functions palette5, select Structures | While Loop, and place6 it on your block diagram. Q.3 The program is not executable now. What is the problem according to the message you get from the broken run button?
If you need to drag a very large while-loop around your program, the program is probably taking up too much space. Make your program more compact by click-and-dragging the icons on the block diagram closer to each other. You can also select Edit | Cleanup Diagram from the menu, or use the shortcut key Ctrl - U , but this will sometimes produce results you didnt want. Cleaning up will make your program easier to read, which will become especially useful when your programs contain more and more elements. Compare this with using indentations in C++ for instance: strictly speaking the code will work without it, but it will be easier to read.

Now connect the Loop condition to the green line carrying the Boolean. Use Execution highlighting while you do a few test runs with your program, to see what this loop condition is meant for and how you can change it. Then use the LabVIEW Help, available via Ctrl - H , F1 , or the menu, to check whether your ideas about it are correct. The while loop also has a counter (the blue box with an i inscribed.) The value coming out of this counter is equal to the number of times the loop has already run: zero the first time, one the next, et cetera. You can use this to stop the while loop after a certain number of iterations. Modify your program in such a way that you get the block diagram in Figure 7.

5 6

This palette is only available when the block diagram is the active window on your desktop. Click-and-drag this loop around the program you have already made.

Figure 7: While loop.

Q.4 If y is N (with N an integer), then what is the value of Numeric after execution of the loop? Explain this.

For Loops
A for loop is a loop that is executed only a predetermined amount of times. This is similar to the comparison that you connected to the loop condition terminal in the previous exercise. When you create a for loop in your block diagram, you will see that it has a loop counter just like the while loop. But in the upper left hand corner, it has another blue box with the letter N in it. If you connect a number to this box7, then the for loop will run that many times.

Figure 8: For loop.

You might notice that the controls, indicators, and wires are blue in Figure 8. From earlier in this manual you know that a different color indicates a different data type. A thin blue wire means an integer number. You can change the data type of a control or indicator by right-clicking and selecting Representation. You will have several choices, but I32 (for integers) and DBL (for non-integers) are the most important ones.

Right-click and select Create | Control or Create | Constant.

Q.5 Look at the program in Figure 8. What does it do?

Data Types: Arrays


An array is just an ordered collection of items. In this section you shall make a one dimensional array of integers that can be used for plotting, calculations, et cetera, with the while loop from Figure 7. To make an array control on the front panel, select Modern | Array, Matrix & Cluster | Array and place that somewhere on the front panel. This creates an array control, but with a black border. That means the control doesnt have a data type, and so the program wont run. To give it a data type, place another control inside the box the easiest is the Numeric Control you are already familiar with. There is a feature of loops that can be quite helpful in this and other applications. This feature is called automatic indexing. Figure 9 shows an example; one can create similar functionality in while-loops. In this figure the basic functionality is that the for-loop automatically runs through all the elements in the array, making them individually (in the indicator in this case) available. In this case, you do not have to connect the N box, since the loop will automatically figure out how many times to run based on the length of the array.

Figure 9: Indexing in loops.

Note the change in thickness of the wire that carries the array; all different data types have a different wire.

Q.6 What happens when you connect two arrays of different length via indexing to a single for loop? Similarly, you can create an array as the output of a loop, by connecting a value inside the loop to the edge of the loop. When the loop finishes, it will take the values from each iteration and put them all together in an array.

Figure 10: Build array with indexing.

Figure 11: Array indicator.

You can apply indexing on data lines crossing a loop boundary. To do this, turn it on or off via the menu that pops up after a right click on the terminal on the edge of the loop. Do this now for your while loop from Figure 7: erase the Numeric indicator and instead run a wire from where it was to the side of the loop. Enable indexing on the terminal that appears. The brackets show that an array will come out of the loop. Unfortunately, you have no access yet to the contents of the array. In order to see the contents of the array, right-click on the terminal with the brackets, and create an indicator. Now go to the front panel and find the array. What you should see is depicted in Figure 11. You recognize the grey box: that is the indicator that shows what value is inside. But an array can have more than one element, and to visualize more than one at a time, you can grab the lower edge of the box with your mouse and pull it down. The indicator will expand to show more than one element. The white box with the number in it is the coordinate of the first element shown. If you have two or more white boxes, you actually have a two (or higher) dimensional array. Q.7 What is the length of the array in your code if the control y is set to an integer N?

Data Types: Strings


Apart from handling numbers and Booleans, LabVIEW can handle text strings. One particular use of them is in automated data storage. In such an application, one would for example like to create logically named data files in a particular directory. One way to program this is to use the Number to Decimal String sub-VI in combination with Concatenate Strings. To find them, go to the block diagram, open the functions palette with a right-click and click on the drawing pin. Then you can locate them in the String section. Use the while loop from the previous exercises, or make a new program, to construct a piece of code that automatically creates an array of numbered filenames. The length of the array should depend on the value of a control on the front panel. The filenames should include the drive and directory. as in: P:\data\measurement123.dat. The Concatenate Strings block has two inputs when you place it onto the block diagram; however, you may find that you need three or more inputs. Add an extra 10

input by expanding the sub-VI, as you did with the array indicator8. Alternatively, you can right-click on the icon and select Add Input. In one of the previous exercises you created an indicator to monitor the contents of an array (see above). This indicator was positioned outside the while loop, and only showed the content of the array after completion of the while loop. Q.8 What happens when you connect an indicator to the output of the Number to Decimal String sub-VI, and place the indicator inside the while loop? What is the difference between this and putting the indicator outside the while loop? Run the program with execution highlighting if necessary. Q.9 Save the VI you made and include a copy of its block diagram in your lab journal. Q.10 [E] Usually file managing programs, such as Windows Explorer, order files by name by looking at the first digit they encounter in the filename, starting from the left. Therefore, in order to get a properly ordered list, you usually have to add zeroes to the number in the data filename. Extend your program to add a predefined number of zeroes to the number in the filename.

Decision making
A large part of computer programming is concerned with getting the computer to make decisions for you. (If you remember C++, you might wonder where the if statement and the switch-case statement are in LabVIEW.) There are two different ways to make decisions in LabVIEW. One is the Select block (found in Programming | Comparison). This looks at a condition or question and picks one of two values based on the outcome.

Figure 12: Determining whether a student has passed or failed the LabVIEW course.

Hover over the icon until an up/down pointing arrow appears, then click-and-drag, dragging downward. This will create extra inputs.
8

11

Select is often used in combination with other blocks from the Programming | Comparison palette, as in Figure 12. This program takes a students grade for the LabVIEW course as input (from 0 to 10) and compares it to the threshold for passing, 5.5. As you have seen before, the output of the comparison is a Boolean value (true or false), indicated by the green dotted wire. The Boolean output is connected to the question mark (conditional) input of the Select block. If the conditional is true, the top value is passed through to the output and the bottom one is blocked. If the conditional is false, then the bottom value is passed through and the top is blocked.
The top and bottom inputs are strings (pink wires) here, but they dont have to be strings. They can be numbers or anything else. The only restriction is that they must be the same data type.

The Select block allows you to make a decision between two values. However, sometimes you want to make a decision between two courses of action. For this, you need the case structure (found on Programming | Structures).

Figure 13: Speed controller with emergency stop.

The program in Figure 13 features a rather stupid decision-maker, determining whether to speed up a machine based on whether it is overheating or not. (In Practicum 2 youll be learning the proper way to make these sorts of systems.) Notice the frames labeled True and False. In the program, you can switch from one to the other by clicking the arrows. Here, they are depicted next to each other due to the limitations of paper, but they are really the same frame. When the program is executed, if the outcome of the temperature comparison is false, then the False frame is executed and the True frame is ignored. If the temperature value is too high, then the True frame is executed and the False frame is ignored. If you like, you can see for yourself by building the code and executing it with execution highlighting (the lightbulb icon) switched on.

12

Q.11 [E] The Select block is usually simpler and easier to read. Why cant you use one for the program in Figure 13? Or can you? Another feature of case structures is that you can compare between multiple integer values or even strings, and not just true or false.

Figure 14: Assessment test for strategy consultant recruiters.

The program in Figure 14 again evaluates your LabVIEW grade (this time it is restricted to an integer value) using a case structure. The case structure allows you to have a different assessment text for each possible grade, without cumbersome comparisons (= 0, = 1, = 2, etc.) Build the program from Figure 14. To change the values of the cases, just click on the case label and type the number. You can also type more than one number separated by a comma. There is also a special value, Default, which is executed if none of the other values matches. To add a new case or a default case, right-click on the case label. Q.12 You will notice that the program wont run (broken arrow) when you add a new case. This has to do with the terminal on the right side of the case structure, which has a white square in it as pictured in Figure 14. Why? What can you do to fix this?

Shift registers
Sometimes it is necessary to carry over information from one loop iteration to the next. The value of the counter is an example; this memory is already implemented in the blue box with the i inscribed. But think of a situation in which you would like to compare, say, the measured temperature (yes, with LabVIEW one can ultimately measure physical observables like temperature) in the current iteration with that from the previous. For these situations one can create an additional memory element called the Shift Register. To make this memory element, simply right-click on the left or right side of a while or for loop and select Add Shift Register. You should see the two elements visible in Figure 15. At iteration N one can wire any data type into the element on the right

Figure 15: Shift register

13

edge of the while loop, which will then become available in the subsequent iteration N+1 from the left side of the loop. We will write a program that calculates factorials by using a shift register. Build the program shown in Figure 16. This program runs the for loop n times; each time, it multiplies the previous value by the counter plus one. (The plus one is because the counter starts at zero during the first run of the loop!)

Figure 16: Factorial program using a shift register.

To properly wire the shift register, wire the output of the multiplication block to the shift register sink (the box on the right side of the loop) and you will see that it changes color. Once the shift register sink is connected, the source for the subsequent iterations can be connected to the remaining open input of the multiplication block.9 Q.13 What is the value of 4! according to the program? The issue you encountered in answering question Q.13 in using the memory of the shift register is that it has to be initialized at the beginning of the program. If you dont do this, it will have whatever value it had in the previous run of the program, and if there is no previous run, then it will just start out zero. To initialize this memory before each execution of the program, right-click on the left terminal of the shift-register and create a constant. Q.14 What value do you have to initialize the shift register to, in order for the program to work? Why?

If you connect the source of the shift register before the sink, a broken wire will appear, since the data type of the source is only determined by connecting the sink.
9

14

VISA Communications
Since you are now familiar with the basics of LabVIEW, you can now put LabVIEW to use doing what it does best: input and output (I/O). You will now see that LabVIEW can be used for communication with external devices and instruments. Apart from PCs, you will find special purpose electronic hardware in almost all experimental physics setups. Figure 17: GPIB cable. These devices have knobs mostly, but being able to control these devices electronically can come in handy sometimes. It can mean the difference between collecting ten data points and copying them down by hand in your lab journal, or collecting ten thousand data points and analyzing them on your computer. To connect external devices to a PC, there are several standard ports available on a PC (USB, parallel ports, serial ports, FireWire). Some manufacturers choose to use their own communications protocol to communicate with the device on one of these ports, and write closed software for this, which they then supply with the device. However, more and more manufacturers choose to use standardized communication protocols to serve as the information channel between their device and a PC. Well-known examples of these standardized protocols are for example USB, Ethernet, WiFi and FireWire10. These worldwide standards are often defined by the Institute of Electrical and Electronics Engineers (IEEE). LabVIEW has blocks for many of these communications protocols, and it also offers the Virtual Instrument Software Architecture (VISA) interface. VISA lets you use any number of different communications protocols all in the same way, without having to bother with the details of each one. You will be learning to use the VISA blocks in LabVIEW, since you can use it to communicate with just about any lab instrument you might encounter. We will start out by communicating with the Tabor function generator, located at your table or on one of the shelves. The Tabor speaks GPIB, also known as the IEEE 488.2 protocol. It is a rather old and slow protocol, but it is still quite common. The GPIB port is not usually included in a desktop computer, but the lab PCs have one included in the back, on a PCI card. Check whether the Tabor function generator is connected to your PC via the GPIB cable (Figure 17). If not, connect it now. Open a blank VI and go to the block diagram. Now you need to find the VISA blocks: for this, LabVIEW also has search functionality. Click the Search button on the functions palette. In the search field, type visa (the search is not case sensitive). LabVIEW will find a list of VISA commands for you. The one you need now is VISA Write. Select it, and place it on the block diagram. You dont need to connect all the terminals to controls and indicators; only connect VISA resource name and write buffer.

10

Firewire refers to the port as well as to the communications protocol itself.

15

Be careful not to use the search all the time to find all the VIs you need. Using the search can be slower than simply memorizing where you can find VIs on the functions palette. Moreover, the VIs with similar or related functionality are grouped together in the functions palette, and sometimes simply by browsing you find quite useful VIs there you did not know existed.

With VISA, you have to specify which device you are sending a command to. This is the function of the VISA resource name; it should be set to GPIB::15. (This means device number 15 on the GPIB port. Why 15? That is the number that the Tabor identifies itself with. It is controlled by a setting in the Tabor itself.) To communicate with the Tabor, you need to know which commands it understands (remember: VISA only tells machines how to talk to each other, but not what to say). These commands can be found in the manual of the Tabor, in Table 4-5. This table is an additional sheet of paper stapled into the official manual. Make sure you are looking at the IEEE 488.2 commands. (You can also find the Tabor manual, including the correct table, on Blackboard.) Note that once you have activated VISA communication, the Tabor cannot be operated via its panel anymore. Press the LCL button to activate the panel again. Q.15 What are the commands to set the frequency, amplitude and type of waveform? Q.16 [E] Find out how to change the address of the Tabor from 15 to 16. You should be able to find this information in the manual. What is the exact procedure?
Do not press Enter after typing a command such as FRQ500 in the write buffer string control on your front panel. An Enter character is also a string constant, and will stay in the string control box, making all subsequent commands invalid. One of the first things to check when you encounter a malfunction of your VI is the content of the string control. To run your VI just click Run or press Ctrl - R . (You can resize the string control box so that you can see if there is more than one line in it.)

Observing a changing amplitude or frequency on the display of the Tabor is one thing, but it would be nice if you could actually check the signal on the output BNC connector from the Tabor. To visualize this signal, normally one uses an oscilloscope. Connect the output of the Tabor to the oscilloscope (with a BNC cable) and check the signal that it produces, by sending different commands to it. The command strings are case sensitive, by the way. Note that the Tabor can produce signals with frequencies up to 20 MHz. Try to create different waveforms 16

with the Tabor via your PC, such as a linear and logarithmic sweep, a DC output, et cetera.
The oscilloscope has an auto-set button that you can use after you turned it on. This makes it easier to visualize your waveform for the first time. Try to learn how to use it without the auto-set button though it does not always show you what you want to see.

Q.17 What text is displayed on the Tabor when you send an undefined command? What message is displayed when you specify a valid parameter (say the frequency) but out of range? Q.18 Send the following string: S1; FRQ1; STP1000; SWT10 hook up a scope to the Tabor and describe what this particular command does. If you need help, consult the manual.

Synthesizer
We can use the Tabor in combination with LabVIEW and a loudspeaker to construct a synthesizer, be it a very modest one. To get there, there are a few LabVIEW things to learn.

Sequence Structures
In using the GPIB commands, you have probably already noticed that the order in which you execute commands is sometimes essential. Usually LabVIEW executes code by following the wires, but two separate pieces of code on the same block diagram might be executed virtually simultaneously, resulting in undesired or unpredictable behavior. To solve this issue, one can use a Sequence Structure that forces a sequential execution of pieces of code. This structure comes in two types, their difference being only their appearance. In Figure 18 you see the Flat Sequence Structure, the other sequence structure is the Stacked Sequence Structure. The sequence structure can be useful to make an automated GPIB-query program that first sends the desired query command, and then reads the message on the GPIB bus immediately afterwards.

Figure 18: Flat sequence structure.

17

Wait Statements

Figure 19: Two different wait statements

When you send a very long string over the GPIB bus, it might take a while before the whole string is received by the Tabor. This is due to the fact that the GPIB bus is slow (9600 Baud usually, where Baud means number of symbols per second). However, once LabVIEW has completed executing the VISA Write subVI itself, it will continue with the rest of the program, regardless of the fact that the GPIB controller may still be sending data. To compensate for the fact that LabVIEW is not always aware of when your hardware has finished the operations you ordered it to execute, you can use waitstatements manually, preferably in the sequence structure you just learned. There are two different wait statements: Wait (ms) and Wait Until Next ms Multiple; Figure 19 shows how they look. The first one is used if you want your program to wait a certain amount of time at a specific location in the execution order of your program. Typically you place this sub-VI in a sequence, in order to enforce the proper moment of execution. The operation of the second timer is more complicated. In order to understand its behavior, you have to know that LabVIEW has an internal clock, counting the number of milliseconds passed since some arbitrary starting point. The value of this clock is an integer (32 bit) and will count zero when it has reached 2 32. When you execute the Wait Until Next ms Multiple sub-VI, with, say, 100 milliseconds as input, the program will wait until this internal millisecond clock has reached a value that is an integer multiple of 100. Therefore, the first time you run this sub-VI, you never know how far you are from this number, and the first waiting time after calling this VI is therefore arbitrary, but bounded from above by the number you specified. This VI is however quite handy if you use it in a while loop for instance; it will make sure your while loop is executed at regular intervals. This can be useful for synchronization purposes, for example.

Figure 20: Waiting in a loop.

18

Q.19 Examine the program in Figure 20. How long does it wait between counts? Explain why.

GPIB Reading
It is also possible to acquire information from the Tabor, for example the waveform amplitude. To get this information, you have to send a so-called query command. These commands can be found in the same table mentioned before. After you have sent this command, you can read what the Tabor is saying by using the VISA Read sub-VI11. Note that you have to send a query command before you can read anything. Q.20 With what command can you query the frequency or the amplitude? How can you tell they are query commands? Q.21 Build a VI to send a query command to the Tabor and read the answer. Use a flat sequence structure. Include the block diagram in your lab journal. If you encounter strange behavior, try solving it using one of the wait statements. Q.22 If you use a stacked sequence, you cannot simply pass data from one frame to a subsequent frame by e.g. dragging a wire. What function is available on these stacked sequences to circumvent this? Change your program from Q.21 to use a stacked sequence structure. The synthesizer you are going to make initially will be able to play a predefined number of tones with certain duration. By now you should roughly be able to see how this can be put together with a for-loop, the VISA library, indexing, string operations, and wait statements.

A/D Conversion
You will encounter the abbreviations DAC and ADC quite often in this manual. The abbreviations stand for Digital to Analog Converter and Analog to Digital Converter. They refer in most cases to the microchip that converts digital to analog signals, or vice versa. These microchips are of course essential for performing electronic measurements.

All the VISA sub-VIs can also be found via the Instrument I/O | VISA section on the functions palette.
11

19

Loudspeaker The loudspeaker you will be using to produce sound is a 6 loudspeaker (in principle the impedance of the coil in the loudspeaker is frequency dependent), with a maximum power consumption of 10 W. These numbers set a limit on the voltages you can use to modify the amplitudes of the sounds produced. Usually though the loudspeaker starts to behave non-ideally far below these upper limits. In any case, if you want to test your synthesizer (or any other piece of equipment!), start gently, with small amplitudes. The calculation you shall do below, will tell you what gently actually means in this case. Q.23 Derive what the maximum voltage is you can apply to the speaker, and what current then flows through the coils inside the speaker at that maximum. Once you know the upper limit of what the hardware can bear without breaking down, what would be a gentle initial test voltage? The Tabor can only produce a 50 mA current, so it will not be able to drive the speaker directly (or only very softly). To amplify a current without modifying the voltage, you can use a buffer amplifier. This device simply consists of an electronic amplifier with an amplification factor of 1. It is only meant to beef up the amount of current you can supply, without changing the voltage. The amplifier itself is a so-called active circuit element, requiring a power supply, so the power it funnels into the circuit can be larger than it gets from the circuit (for passive elements such as resistors or capacitors this is not true of course). The circuit in this case is the 50 mA current source. The buffer amplifier is a relatively large box with one bipolar input and one bipolar output. It is on one of the shelves; ask the assistants to show you. Q.24 Now build a synthesizer with which you can play a certain amount of tones sequentially, whose frequency, amplitude and length can be modified via the front panel. Include the front panel and block diagram in your lab journal. Dont forget to save the VIs you build for your own reference; you might be able to use pieces of code you make now later on in the course. Dont forget to demonstrate your synthesizer to the assistants before moving on! PC Operated Frequency Sweep With the string operators used in the previous section and a for-loop you can make a VI that will make the Tabor produce a frequency sweep of which you can set the start frequency and the stop frequency in LabVIEW. This functionality you have already seen in Q.18. 20

Q.25 [E] Make this program. Make sure that the frequency steps are smaller than unity for a smoother updating of the waveform. Check the sweep with the oscilloscope, and the loudspeaker. Include the block diagram of this VI in your lab journal. This effect is caused by the response of the internal high pass filter12 you switch on when you set the scope to AC. This setting is useful if you want to observe low amplitude alternating currents (AC) on a signal that also has a large direct current (DC) component.
Setting the wrong AC/DC input setting by mistake on the scope happens easily and often causes confusion. Check this setting first if you experience problems with the scope.

I/O Cards and DAQ


The Tabor converts a digital signal to an analog voltage, and the oscilloscope does the opposite. More generally, when you want to measure or generate a signal using your computer, you will use hardware built specifically for data acquisition (DAQ). This hardware, called an I/O card, or I/O board, is designed to fit into your PC. Other functionality is usually also available on these boards: digital clocks (5V square wave generators), digital ports that can either sense or output digital signals, for example for TTL circuits. These cards can be bought from different manufacturers, but not all of them work equally well with LabVIEW. The card installed on your PC is the PCI-6014 from National Instruments. Q.26 Download the datasheet from ni.com and find out the minimum and maximum output voltage and the maximum input and output sample rates. So why use an oscilloscope or a function generator if the same goal can be achieved with a cheaper and more flexible I/O card? There are advantages and disadvantages in both solutions: familiarity with the programming language is for example a strong requirement for using LabVIEW-based solutions. Flexibility in use usually also means hard to set up: you will see that programming a very basic function generator in LabVIEW takes quite some time and skill, while the Tabor works when you turn it on. Another consideration is hardware demands: to
You should have seen high and low-pass filters in the first year practicum. You will learn more about them in the course called SVR. It might be useful to remember the sweep-function; you can use it to measure the transfer function of filters.
12

21

measure picoamperes or gigahertz signals, dedicated hardware is usually required; I/O boards that do that are simply not available. Lets also not forget that all PCs run on complicated operating systems which are far more likely to stop functioning properly than a custom programmed microchip in a function generator. Yet another consideration is that a function generator might keep working for >20 years; but computer software will be completely obsolete much sooner than 20 years. Typically, when your application is either very demanding or very simple, dedicated hardware is better. For doing moderately intricate experiments, prototyping, or for applications requiring lots of flexibility, LabVIEW is an indispensable tool.

Single Point Output


An easy way to get used to the basics of I/O is to learn how to write a voltage: that is, create a potential difference between an analog output port and the ground of the I/O card. Reading the previous sentence carefully tells you how to go about it: you will have to tell the computer which port you want to address, and how large the potential difference should be. The way to control an I/O card in LabVIEW is through the DAQ Assistant block. This block is a simplification of more complicated blocks that involve talking to the hardware directly. For specified applications it might not perform as well as programming something from scratch, but in most cases it is better than good enough. If you ever find yourself needing more control, you can always right-click on the DAQ Assistant and choose Open Front Panel. This will convert the DAQ Assistant to a regular LabVIEW program and show you whats inside, so that you can change it any way you want. Go ahead and place a DAQ Assistant on a fresh block diagram. It can be found in Measurement I/O | DAQmx. It takes a few seconds to initialize, but soon a configuration window (Figure 21) should open in which you can choose what kind of DAQ operation to do. Q.27 Based on the task described at the beginning of this section, what should you choose if you want to output (write) a single voltage? Next, you can choose from a list of Supported Physical Channels. The channels here are listed under Dev1, which is the 6014 card you have. ao0 and a01 refer to the AO0 and AO1 BNC connectors on the connector box.

22

Figure 21: DAQ Assistant configuration window.

After you select the ao0 channel, you get into the DAQ control panel (Figure 22). (After you close this window, you can open it again by double-clicking on the DAQ Assistant.) You can test your DAQ task from within this control panel by clicking Run.

Figure 22: DAQ control panel.

23

Q.28 Right now, you only need to change the Generation Mode setting. If you like, experiment with different Generation Mode settings and the Run button. The top panel lets you choose what kind of signal to write. Use the oscilloscope to see what is actually output. What do you think the Generation Mode should be, given that you want analog output (AO) and a single channel, single point output? Once you are done, exit the control panel and connect a numeric control to data (Figure 23). This small program should be able to write a voltage to the AO0 BNC connector on the connector box. You can check whether this works with the scope.

Figure 23: Single point write.

Multiple Point Output


The program from the previous section can write the voltage to an output port only once. What if you want to output, say, a (discretized) sine wave? From what you have learned so far, you might expect the following solution to work:

Figure 24: Finite multiple single points output

If the Sine Wave array contains a discretized sine wave, in fact this solution will work! However, this solution is severely limited: remember that the clock in LabVIEW has only millisecond accuracy. That means that, theoretically, the forloop cannot be accurately synchronized at a rate faster than 1000x per second. That means that the voltage on AO0 cannot be updated faster than 1000x per

24

second13. This limits the frequency of your sine wave to 500 Hz14; nothing compared to the 20 MHz of the Tabor. Q.29 Build the code from Figure 24 and test it with a millisecond multiple of 1000. Instead of a sine wave, just make a small array that contains voltage steps [0, 1] so that you can easily see them on the scope. Then check the statement above by using zero for the millisecond multiple and running continuously. What is the maximum output rate of this code? There is however a hardware clock present on the 6014 board that actually goes up to 20 MHz15 (you might have seen that in the datasheet). This clock, along with some other hardware can be addressed with LabVIEW. Example code is depicted in Figure 25. To build this code, you have to select the N Samples mode in the DAQ control panel. The Staircase array should be a onedimensional array containing 10 numbers: [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]. Since this array has 10 elements, change Samples to Write to 10. In addition to this modification, to specify the rate at which the content of the array is written to the output port (in Figure 24 this is done with the metronome sub-VI), you can put a value in the Rate (Hz) control. (Leave it at 1 kHz for now.) To enable these controls, you also need to turn off the checkbox with the little clock icon next to them. Q.30 What do you observe on the scope when you run this VI?
Since the total duration of the waveform on the scope is 1 ms, you might need to adjust the time base of the scope, and configure the trigger level properly. Remember what the trigger is? The trigger sets the point where the scope starts plotting the voltage you have to set at least the level and whether the scope needs to start when the voltage has a positive or negative slope at that voltage.

Q.31 Now decrease the Rate (Hz) to 10. You should in theory observe the same waveform, but its completion should now take 1 second (adapt the time
In practice the execution of the DAQmx sub-VIs takes a few milliseconds at least (depending on the computer hardware), which makes the code even slower.
13

The largest frequency component you can generate is fmax/2, where fmax is the output (or input!) writing (reading) frequency. This is the Nyquist theorem. You will learn more about this in the SVR course.
14

The similarity with the 20 MHz limit of the Tabor is most likely coincidental; the microelectronics used in both pieces of hardware is not fully disclosed.
15

25

base of the scope accordingly). Do you still observe the same waveform? If not, what do you observe?
Have you already used the possibility to include comments in your code? The yellow boxes in Figure 25 are just that. Double click on an empty piece of block diagram to make one.

Figure 25: Finite N points output.

Basic Plotting: Waveform Graph


Visualizing the staircase waveform on the scope is a useful tool to check the behavior of your VI, but it would be convenient if you can plot simple graphs directly, inside LabVIEW. This option is indeed available: place a Waveform Graph on the front panel and hook up the staircase array to it. Running the program will not show a staircase however. Right click on the control box at the top right corner of the graph display on the front panel (with Plot 0 inscribed) to find a menu where you can change the appearance of the plot. Q.32 Change the settings of the Waveform Graph in such a way that you see both the actual datapoints, and a real staircase. Print this graph and include it in your lab journal.
Important remark on using the printer: In order to save the toner in the cartridge, dont print your graphs with the black background that LabVIEW gives them by default. You can right-click on the graph and select Export Simplified Image The simplified version has a white background and is much clearer when printed. (Make sure to click Hide Grid.) You can choose to save the simplified image to a file, or copy it to the clipboard. If you copy it to the clipboard, you can paste it into a Microsoft Word document by pressing Ctrl - V .

26

Data Types: Clusters


In order to transfer more than a single data type on a single wire, you can use the Cluster data type. Apart from being optically neat, it can also be convenient to create special purpose custom data types. One example of that is the Error Cluster of which a connection can be found on most advanced sub-VIs you have used. Connecting these properly throughout your program is not required but can be really helpful when debugging your program. The error cluster contains a Boolean that is true whenever an error occurred, an integer as an error code, and a string constant for some basic error explanations. More extensive explanation of error numbers is available via Help | Explain Error in the program menu. Usually that help also indicates where the error occurred. You can also use the cluster data type to plot a 2D graph for which the x-axis has units of time. Q.33 On the front panel add an XY Graph. This adds XY Graph and Build XY blocks to the block diagram. You can delete the Build XY block and instead use the Bundle block to group the array containing your step function together with a second array containing the elements [0, 1/ rate, 2/rate, , N/rate]. Print this graph and include it in your lab journal. Also print the block diagram.

Continuous Output
The output types encountered above are limited to the extent that one is limited to low output rates, or to the use of increasingly larger arrays to write data for longer periods at high rates. As an example: if you want to output a sine wave of changing amplitude at 20 kHz for a few days, you would need around 108 data points in your array. To avoid working with these impractically large numbers, there is a way to write data to the analog output in a streaming way. The technique employed is similar to the one used in YouTube video streams. Instead of directly streaming data from the server to your monitor, a virtual buffer is created, which is continuously filled with new video data from the YouTube server. After a short delay, these data are also continuously written to the monitor. This method of data streaming can make the data stream to your monitor insensitive to small fluctuations of data influx from the server into the buffer, and that is precisely what is necessary: the video should run smoothly on your screen irrespective of (small) network interruptions. In the LabVIEW context one would say that LabVIEW cannot directly supply a DAC element at say 1 MHz with data, but it can write bursts of data (say 1000 points) every millisecond or so quickly to a virtual buffer. If then the hardware on the card makes sure this buffer data in transferred at a constant rate of 1 MHz to the DAC (and from there to the output port), the effective, averaged influx and efflux of data to and from the buffer is 1 million data points per second: the buffer will never be empty, and it will also never be full! 27

You might expect to write this by putting your finite N-points output program into a while loop, and adding a STOP button. However, that doesnt work. In Figure 26 you can see code that will give you the desired continuous output of an array. The Generation Mode must be set to Continuous Samples. Q.34 What difference do you see on the scope between the finite N-points ouput in a loop and the program in Figure 26? What do you think might cause this difference? Q.35 [E] If you use the staircase array described above as the output array, and if you configure the trigger on the scope properly, you can find out what the slew rate of the DAC is. Is this in accordance with maximum output rate you found in the datasheet?
Two useful notes on using LabVIEW: Ctrl - B erases all broken wires on your block diagram. In the Edit menu you can find the option Make current values default that setting saves the current settings for all input and output variables of the current VI, so you dont have to insert them again the next time you start LabVIEW.

Figure 26: Continuous N points output.

A LabVIEW Function Generator


You should now be able to build your own LabVIEW function generator, with a similar or even more extensive functionality than the Tabor has.

28

Q.36 Make such a function generator, and print its block diagram. It should be able to give sine, triangle and square waves. Make sure the amplitude and frequency can be modified easily from the front panel. Can you now convert a square or triangle wave into sound? (Be careful not to destroy the speaker with too large amplitudes.) Dont forget to demonstrate your function generator to the assistants!
Note: there are sub-VIs that can generate arrays filled with sine, triangle and/or square wave signals. Find them by using the search. And again: save the VIs you make for future reference.

Q.37 [E] You can customize and beautify the front panel to a large extent. Try to build a user-friendly interface for your function generator. Please be aware of the fact that the rate at which you fill the buffer with data that are to be written should be, on average, equal to the rate at which these data are transferred to the DAC and written to the output port. If you are too slow writing samples, the card will start to write old samples to the DAC. If you are too fast, the card will not be able to generate the waveforms you want it to generate. Note that you will be able to see that this happens by monitoring the error cluster.

29

Single Point Input


In the previous sections you have seen how to build your own function generator, the Tabor functionality so to speak. The functionality of the oscilloscope, in other words the input functionality, can also be implemented with by the 6014; it is an I/O card after all. Fortunately the software structure of data acquisition is very similar to that of data writing. It will not surprise you then that Figure 27 represents code that enables you to read a single voltage value on input port AI0. Build this by placing a new DAQ Assistant and choosing Acquire Signals instead of Generate Signals in the configuration window. One important setting is the maximum input voltage the hardware can read; make sure you set it to 5 or 10 V. This input limitation can be set on the DAQ control panel.

Figure 27: Single point read.

Multiple Point Input


Knowing how finite N point writing works immediately tells you how to generalize the code above to finite N point data acquisition. Q.38 Build this N-point data acquisition LabVIEW code, based on Figure 27. With this code you acquire a single array of length A at rate B. If the rate is low, the default timeout (10 seconds) setting on the DAQ Assistant block might be too small. Implement a solution to this problem, using the timeout (s) terminal, that works for any rate. Include a print of your VI in your lab journal.

Continuous Input
As is the case for writing data to an output, you cannot use the multiple point acquisition code for both long and fast data acquisition. You could insert the whole single or multiple point acquisition code in a for or while loop. Schematically that would create reading schemes as in Figure 28 a) and b). You can see that these reading modes are slow and impose only limitedly strict timing on the acquisition. The constants and in this figure can be set by the user.

30

Figure 28: Reading modes: a) single point acquisition, b) single buffer read, c) continuous read. N is the number of samples, ti is the time between two executions of the code, tr is the rate at which data is acquired.

Q.39 With which inputs can one control the two variables

and

depends on other factors you do not have explicit control over. Examples are the background processes running on the computer, and, in case you execute the single point acquisition or the single buffer read in a while loop, on the other things you execute in the while loop. Figure 29 is by far superior to the solutions mentioned above. Be aware however that it is not always necessary to implement continuous reading. If reading speeds are of the order of 100 Hz or slower, a while loop with single or finite N-point input will suffice and is far easier to implement, certainly in combination with the possibility to create your own subVI that will be introduced below.

Figure 29: Continuous input.

31

Q.40 [E] Build the code shown in Figure 29. What is the influence of the number of samples port on the data acquisition task? It has an obvious effect on your output array, but it also does something else. Explain this by using the advanced help. Q.41 You can also measure the voltage on two ports simultaneously: simply clicking the Add Channels button on the DAQ control panel will do the trick. What type of output from the read sub-VI does this generate? Continuous Input: Details The DAQ control panel contains some mysterious settings. One of them is probably the Terminal Configuration. This nontrivial setting has to do with the fact that you usually (this depends on computer settings which sometimes get messed up) by default measure the potential difference between the input port and the ground of the I/O card, the Referenced Single Ended (RSE) setting. Now in some applications the ground of the I/O card (the reference) and the ground of the source of the voltage (e.g. a force sensor or light meter) you measure are only connected via some convoluted and remote ground loop. This loop will pick up the 50 Hz electromagnetic field that permeates all modern living areas since it originates from power lines (in the US this would be 60 Hz). You will see that as a 50 Hz ripple on your signal. Try to use a NRSE or differential measurement instead (they are identical for single input acquisition). If your measurement circuit is not properly connected, you can also end up measuring the potential difference across loose connectors, basically a capacitor of fluctuating capacity and charge content: any sort of noise (spikes, drift) can be expected in that case.
In short: if you encounter 50 Hz noise or intermittent noise with no obvious source, check the grounding wires and settings. Consult an assistant if you cannot solve the problem yourself, but sometimes grounding problems seem to defy logic; dont be surprised if finding the source of the noise takes some time.

If every while loop iteration in the code from Figure 29 takes too much time to complete, you might be reading data from the buffer slower than the buffer is being filled up. This can result in data loss, and is undesirable. You can however observe that this happens (at high sample rates, say 100k, and a small number of samples setting, e.g. 1) by creating an error indicator connected to the DAQmx read sub-VI. (Connecting the stopped terminal to the loop condition makes sure the program stops working in case such an error (or any other error) occurs.)

32

Q.42 Which error number occurs when you read too slowly? Which solutions are suggested?

Automated Data Storage


LabVIEW also enables you to store the numbers you measure in your experiment in a text file by using the sub-VI File I/O | Write To Spreadsheet File. This technique is usually an indispensible tool (whether you use LabVIEW or some other language), since permanent storage of measurement results allows for postprocessing and (re)interpretation of results. Storing large amounts of measurement results efficiently in such a way that they are still recoverable after a certain amount of time is an art (and also involves a proper use of your lab journal), and having some proficiency in it can make a real difference. Anyway, you can find this VI in the functions palette under the icon with the floppy (if you still know what that is). Note that this sub-VI requires a data type called Path to know where to create the data file itself. This data type is introduced below. You can create a control for this input for now.
A Spreadsheet File in LabVIEW terminology is not the same as an Excel spreadsheet! LabVIEWs spreadsheets are text files, which you can open in almost any program, including Origin, Excel, or Notepad. In many programs, they are called CSV files, which stands for Comma-Separated Values.

Q.43 If you write a one-dimensional array with numbers to a file, will the Write To Spreadsheet File sub-VI by default write this to a file as one long column with numbers, or as a long row? How can you modify this?

Figure 30: String/Array/Path conversions.

33

Data Types: Paths


You have just seen the data type Path being introduced. Earlier in this practicum you made a VI in which you concatenated different strings into one long string containing a full path. This string can be converted into a path with a standard sub-VI depicted in Figure 30. After this conversion it can be wired to the spreadsheet write (and read) sub-VIs.
Automation in data storage is, apart from being convenient, also useful to append references information consistently to data files. You can for example automatically append measurement parameters (a date, temperature, et cetera) or a unique reference number to the name of the data file.

Q.44 Include the string to path conversion in the string-path creation program you made earlier in Q.9. Print this in your lab journal. Check the 5 V Voltage Source The I/O card you have also features a 5 V voltage source. With the continuous input program you have (check the input limits!), you can monitor whether this voltage actually is equal to 5 V or whether it fluctuates a bit over time. Q.45 Measure the 5 V voltage source for at least 10 seconds at a sampling rate of 10 kHz. Store the measurement data in a single, long column on your hard drive, and plot this data with Origin or Excel. Include this plot, with proper labels on the axis, in your lab journal, together with a print of the block diagram of your program.
The default number of decimals LabVIEW uses in writing numbers to a text file is three. For Q.45 this might not be sufficient.

ADC Limitations
The analog to digital converter on the I/O card has a limited resolution. You have probably seen in the datasheet that the card has a 16 bit ADC, but what does that mean? Check the DAQmx Create Channel sub-VI in, say, Figure 29. That subVI has inputs for the minimum and maximum value that can measured on the configured input ports16. The total analog measurement range is then divided into 216 1 discrete bins. A voltage to be measured is then rounded off to the nearest
It can change these limits by dynamically amplifying the real input signal after which the amplification factor is divided out again.
16

34

bin delimiter; that will then be the digital value of the analog signal. That determines17 the resolution. Q.46 Visualize the bit levels by performing a continuous measurement, with the input and the ground shorted. Plotting the acquired data on a Waveform Graph thus reveals the bit levels, and the Gaussian noise around zero. Print this plot, and include it in your lab journal.

Custom Sub-VIs
As with other programming languages, it can be useful to build your program from small subprograms. This will make the eventual code neater, easier to debug, you can use the functionality from the subprograms multiple times without copying the actual code, and you might even be able to reuse the subprograms in other/future applications as well. If you are for example required to make a program that includes measuring, say, a temperature every 10 seconds, you might want to build the DAQmx structure into a single subprogram, or rather sub-VI as it should be called of course. The Temperature Converter Open a new, blank, VI to make a sub-VI you can use later on in Practicum 2. This VI should be able to convert any temperature in Fahrenheit, Celsius or Kelvin to all these three different temperature standards. So it should be able to return the Celsius and Kelvin equivalents of 90 F, but also the Celsius and Fahrenheit equivalents of 923 K. Q.47 Build this functionality using a case statement and a Formula Node (under Structures). Note that this sub-VI should be able to accept any temperature standard as input, and regardless of the input also convert it into the remaining two. Include the block diagram of this program in your lab journal.
The default values appearing in the controls and indicators when you open a program can be modified: fill in the desired default settings into the controls, go to Edit | Make current values default, and save your sub-VI.

Naturally if you set the limits to 1 nV, the ADC wont be able to measure a pV; there is a natural noise floor for this ADC (you can find that in the datasheet too). In typical LabVIEW applications though, you will not encounter this hardware limitation.
17

35

The program you have made should have at least two (temperature and type), but possibly three inputs and at least two outputs, possibly three. This program can now be made into a sub-VI. To do so, you have to define what the in- and outputs are of this sub-VI. This can be done on the front panel: right-click on the icon in the upper-right corner of the front panel-window, and select Show Connector. You will probably see something like Figure 31.

Figure 31: Default connection pattern.

Now all these little squares and rectangles can become in- and outputs, but now there are too many of them. In order to get a connection scheme with the desired number of in- and outputs, again right-click on this connector scheme, and go to Patterns and select the appropriate connection scheme. The convention with these connectors is to connect18 the inputs to the left, and the outputs to the right. Using Custom Sub-VIs To use the custom sub-VI you just made, open a blank VI with Ctrl - N and choose Select a VI from the functions palette. Now open the VI you just made. It will appear as an icon with an in- and output on the block diagram. Q.48 Create controls and indicators for your custom sub-VI, and test it in a main VI. (If you have any time left, design an icon for it, if you like.)

Data Types: Waveforms


A data type you will have encountered already but most certainly will encounter in the near future is the Waveform. A Waveform is actually a cluster in which a signal (e.g. measurement data) in an array is accompanied by timing information19. This timing information consists of the time step between two elements of the array, in other words, the inverse sample rate. It also includes the precise starting moment (with day, month and year) of the signal in the array. The Waveform data type is important enough to have its own subsection on the functions palette.
Hover over a connector, and click on it with the bobbin. The connector will become black, and the pointer will remain a bobbin. Click with this bobbin on the control or indicator in your front panel you want to connect the terminal to, and you will see that the rectangle assumes the color of this control.
18 19

It can also include information in Attributes, but that is be yond the scope of this manual.

36

Measurement & Automation Explorer


On the desktop of your PC you should be able to find the icon depicted in Figure 32. This program allows you to check the available hardware on your PC, and run some diagnostic tests on it. Run this explorer, and expand the My System | Devices and Interfaces | NI-DAQmx devices section. Here you should click on the NI PCI-6014: Dev1. Open the Test Panels and select the Analog Input tab.

Figure 32: Measurement & automation explorer.

Q.49 [E] Can you explain which reading modes are available under Mode?

Property Node
The looks and settings of objects on the front panel can be customized, even during the running of the program. To do this one needs to create a Property Node for the object one would like to customize. This can be done in the block diagram by right-clicking on the icon representing the object to be customized. You can select the property to be changed in Create | Property Node. Note that this affects mostly the looks of your program, and is seldom necessary to change functionality.

RS232 Communication
Suppose now that you want to measure a signal that contains relevant frequency components of up to 10 MHz. The I/O card you have cannot measure these frequency components, since its maximum sample rate is 200 kHz. The solution in this case can consist of using the Tektronix oscilloscope. This scope (as most of its more modern relatives) features an extension module via which it can communicate with a PC. Although nowadays USB connections become more and more standard, the RS232 connection you find on the back of the scope can still be found on many devices. The connector (the 9-pin sub-D connector) is still available on much equipment, and most PC motherboards feature this communication port as well. Q.50 [E] Try to figure out how to communicate with the scope over the RS232 port. Hook it directly to the Tabor and try to measure a sine wave with a frequency of 1 MHz automatically. 37

38

Practicum 2
The goal of this experiment is to build a LabVIEW-driven temperature control system, which regulates the temperature of a small block of copper. The electronic parts of the system are sketched in Figure 33, where the small block of copper is incorporated in the heater in the lower right-hand corner. The complete system uses a temperature sensitive NTC resistor as a temperature sensor, a simple heating resistor as a heater and a combination of ADC & DAC & PC for the electronic feedback.

DAC PC

I HEATER

Cu
NTC

Figure 33: Experimental setup: DAC - Digital-to-Analog Converter, I - Buffer Amplifier, ADC - Analog-to-Digital Converter, Cu - Copper Block, NTC - Negative Temperature Coefficient Resistor (temprature sensor).

Theory
Figure 34 presents a very simple model for the thermal management in the system (copper block). Energy can be fed into the system with a heating resistor that generates a heating power [W]. Energy leaks out of the system through thermal contact between the system and the environment (thermal bath). Two parameters determine the temperature dynamics of this system: i. ii. the systems heat capacity [J/K], which quantifies the thermal energy increase per Kelvin, and the thermal conductivity [W/K] between the system and its environment, which quantifies the energy leak between system and bath per Kelvin temperature difference.

With these parameters in mind it is relatively easy to write down the time evolution of the systems temperature as ( where ) (1)

is the temperature of the environment (thermal bath).

39

Figure 34: Temperature dynamics of a simple system.

At constant heating power be

the solution of this differential equation is found to ( ) (2)

is the equilibrium temperature (at where ), is the difference between the environment temperature and the equilibrium is the thermal time constant. The temperature temperature, and dynamics of this system are quite simple: the equilibrium temperature of the system is higher than that of the environment ( ) and the relaxation of the system to any new equilibrium temperature is exponential with a time constant . Q.51 Verify that Equation (2) solves Equation (1) and the expressions for and are correct and have proper dimensions. In practice the system might of course deviate from this simple system in several ways. The temperature might not be completely uniform over the system and there will probably be some time delay between the application of a heating pulse at one end of the system, and the temperature rise observed with a sensor at the 40

other end. The thermal contact between the system and its environment might be more complicated then sketched in the model, which assumes that the bath remains at a fixed temperature and must therefore be infinitely large. As a practical example of the latter complication we note that the large white plastic box which supports the copper system, might also heat up. In principle, one can model the temperature of this white plastic box in a similar way, introducing a second heat capacity and thermal conductivity (now between plastic block and larger environment). This type of modelling, however, goes way beyond present needs. The point here is to develop a feedback/control circuit that, regardless of subtleties, keeps the temperature constant.

Basic Digital Feedback Mechanisms


Feedback is a process whereby some proportion of the output signal of a system is passed (fed back) to the input. Often this is done intentionally, in order to control the dynamic behavior of the system. The importance of the feedback in our daily life can be illustrated by a vital example a man driving a car to some destination. Without a feedback system, provided by the mans eyes and his brain, the result would be disastrous: its almost impossible to predict uncontrollable external influences like pedestrians, other cars, traffic lights etc. before the trip in order to overpass them. The eyes as a comparator and the brain as a processor provide an indispensable feedback assisting a successful arrival. Feedback can be called positive or negative; this depends on the sign of the response to the feedback. Positive feedback increases the quantity measured in the feedback loop. The basic idea of any electronic feedback system is the following. Suppose you want to control a temperature ( ) and keep it at some fixed set-point . The first step is to compare these temperatures and calculate the error signal ( ) ( ) . The second step is to choose an algorithm, the details of which are given below, that uses this time-dependent error temperature ( ) to calculate the amount or feedback ( ) needed for quick reduction of the error voltage to zero. The third and the last step is to apply this feedback under the usual assumption that the system responds linearly to this control via ( ) ( ). Q.52 What type of feedback will you use in the experiment positive or negative? Systems which include feedback are prone to hunting, which is oscillation of output resulting from improperly tuned inputs. If the input changes faster than the system can respond to it, the negative feedback signal begins to act as positive feedback, causing the output to oscillate. To avoid such problems, a wide range of feedback algorithms has been developed: 41

Proportional Feedback (P-control) Proportional feedback handles the present state of the system. The feedback signal ( ) is linearly proportional to the error signal at every moment, with a dimensionless coefficient : ( ) ( ) (3) For our specific case the feedback signal is the power ( ) which we apply to our system: ( ) ( ( ) ) (4) Here is the thermal conductivity, necessary to get the units correct. The main advantage of proportional or P-control feedback is its simplicity. The main disadvantage is that this type of feedback can never reduce the error signal to exactly zero. Q.53 Show that proportional feedback can never reduce to zero. You can do this by rewriting Equation (1) with a heating power which changes linearly with temperature (Equation (4)). Hint: you dont have to solve the differential equation explicitly just consider what happens to as . One can of course make the residual error signal smaller by increasing the proportionality constant , but if you increase it too much the control system will become unstable and start to oscillate. The main reason for this behavior is the presence of unavoidable time delays between the temperature measurement and the heating response at that same position. Integrating Feedback (I-control) This feedback handles the past of the system and the feedback signal depends not only on the instantaneous error, but also on the past error values. The error is integrated (or averaged/summed in the case of discrete values) over a period of time, and then multiplied by a constant : ( ) ( ) ( ) (5)

The expression for heating power ( ) can then be given in the form of:

42

( )

( )

( )

(6)

The main advantage of integrating feedback is that it has a memory of past perturbations and in principle controls the system convergence to zero error signal. Q.54 Show that integrating feedback can reduce to zero. You can do this by rewriting Equation (1) with the heating power given by Equation (6) and differentiating so that you have a second order differential equation. Hint: you dont have to solve the differential equation explicitly you need only consider the form of the general solution of a second order DE and what happens to the derivatives and as . This memory is at the same time a disadvantage, as it reduces the control speed; the low-frequency fluctuations are much better controlled than the highfrequency ones. Differential Feedback (D-control) This type of feedback handles the future, the first derivative of the error (its rate of change) is calculated with respect to time, and multiplied by a constant . The differential term increases the feedback strength of high-frequency fluctuations and it makes the control more susceptible to noise: ( ) ( ) (7)

which is equivalent to the following discrete representation of the time derivative, less sensitive to noise: ( ) ( ) ( ) ( ) ( ) ( ) ( ) (8)

Combined feedback mechanisms


Proportional & Integrating Feedback (PI-control) This is a very popular control algorithm, which uses a combination of P- and Icontrols: ( ) ( ) ( ) (9)

43

It has the response speed of proportional feedback, while its error signal does decay to zero. There is another (more physical) parameter to quantify the relative strength of the integrating feedback ( ) as compared to the proportional feedback ( ). This parameter is called the effective integration time and it equals the time it takes the integrating control to build up to the same strength as the proportional control (at fixed error signal). In terms of this parameter the PI feedback is: ( ) ( ( ) ( ) ) (10)

Its important to note that the strength of the integrating feedback is not only proportional to , but is also inversely proportional to the sampling time . More sample points per unit time will increase the contribution of the integrating feedback term. Applied to our system, the expression for PI feedback power is then: ( ) ( ( ) ( ) ) (11)

You will use Equation (11) as a basis for our feedback scheme. However, feel free to make your VI more advanced and use a PID-control, which will be discussed below. Proportional, Integrating & Differential Feedback (PID-control) PID control is the most advanced algorithm, combining all the three controls we have considered: ( ) ( ) ( ) ( ) (12)

Figure 35 shows the typical time traces of three controlled systems and summarizes their differences. For P control the equilibrium does not correspond to the set-point. In theory, the evolution towards this equilibrium should be a simple exponential decay. In practice some overshoot can occur due to time delays between sensor read-out and actuator response. PI control is better in the sense that the equilibrium does correspond to the set-point. Theoretically, this equilibrium is reached after a damped (or possibly overdamped) harmonic oscillation. PID controls can potentially be faster, albeit somewhat more noisy.
T TS t P T TS t TS

Figure 35: Typical time traces for real P, PI and PID controls. TS is the set-point temperature.

44

T (C) 15 20 25 30 35 40 45 50 55 60 65 70

R ( ) 1508.4 1223.9 1000.0 822.5 680.9 567.0 474.9 400.0 338.6 288.1 246.3 211.6

Figure 36: NTC resistance versus temperature.

The Physics of NTC Resistors


How can you measure a temperature electronically? The temperature sensor you will be using is a so-called NTC resistor, where NTC stands for Negative Temperature Coefficient and refers to the fact that the resistance of such a device depends on its temperature, the relation having a negative coefficient; the resistance drops as the temperature increases. This decrease is quite rapid (the resistance decreases typically by as much as 4% per degree Celsius), making these sensors ideal for accurate temperature measurements. An NTC resistor is nothing more than a piece of semiconductor material with a bandgap that is small enough to allow for thermal excitation of some of the electron from the valence band to the conduction band, or (equivalently) for the thermal excitation of electron-hole pairs. When the temperature rises, the number of thermally excited electron-hole pairs will increase and the resistance goes down, thus explaining the name NTC. The conductivity of a semiconductor (proportional to the number of electrons in the conduction band) follows an exponential law:

where is the band-gap energy, is the Boltzmann constant, and is the temperature (in Kelvins). The resistance therefore follows an inverse dependence and you can write as in Equation (13): ( ) ( ) (13)

45

where is related to the band-gap energy and is the resistance at some ( reference temperature . Our NTC resistors are specified for ) and at . Based on these values you can calculate a reference table for NTC resistance versus temperature, and plot the exponentially decaying function. These two are shown in Figure 36. In the experiment, the NTC resistance (and the associated temperature ) can be determined from the voltage over the NTC resistor, measured by a PC through an ADC converter. The NTC resistor is plugged into the circuit, consisting of a fixed resistor and a 5 V power supply from an I/O card. Q.55 Derive the expressions for the voltage on the NTC resistor versus its temperature and vice versa, i.e. ( ). Hint: use Equation (13) for NTC resistance versus temperature ( ), consider Ohms law for the circuit on Figure 37 and find the voltage drop on the NTC resistor. Write the derived formulas in your lab journal. These conversion formulas will be necessary while building up the VI in LabVIEW.
R1 = 1 k

PC

ADC

R
V

5V NTC

Figure 37. NTC resistor connection.

The Heating Device


As heating device we use a simple high-power resistor ( at room temperature) that is driven directly from DAC via the buffer amplifier (up to 1 A in the voltage range of 10 V). Such a buffer amplifier is needed because the DAC, just like the Tabor you have seen before, cannot supply more than 5 mA of output ( ) current. The dissipated power is equal to . At the maximum DAC output of 10 V about 4.55 W is dissipated. The quadratic relation between the dissipated power and the regulating voltage has, of course, consequences for the regulating feedback loop that you want to construct.

46

Experiment

Connection Box
(ADC & DAC)
AI 0 AO0

oo
+5V

to PC

In Current amplifier Out ADC +5V R1


RED

DAC

NTC

Cu

Heater
Ground

BLACK In / Out

Figure 38: a) Connection scheme; b) BNC-to-banana adaptor connection: ground should be plugged into a black socket.

Precautions It is important to make sure that the system (Heater + Cu block + NTC resistor) is not overheated and thus damaged. Overheating can occur when, for example, a nonzero voltage is sent to the heater and the code (your VI) crashes the heater keeps going then. Check that the Cu block doesnt get too hot and include the overheating protection into your VI. The maximum temperature for the system is 55 0C. If you are not sure of what you are doing, hook up the output of the DAC to a scope to monitor the voltage directly. Calculate the minimum voltage on the NTC then for a double safety measure. Hardware The experimental setup (Figure 38) consists of the following elements: Connection Box, comprising DAC output, ADC input and +5 V power source. Current (buffer) amplifier with banana-type In-Out sockets. 47

Heater + Cu block + NTC resistor and fixed 1 k resistor assembled in a single box. PC, plugged to Connection Box, with LabVIEW installed.

(see Figure 37),

Connect the output of the DAC (AO0 Analog Output 0) to the input of the buffer amplifier keeping in mind the polarity the banana plug ground should be connected to the black socket. Set the DAC AO0 voltage to 0 volts you dont want to start heating immediately. The output of the buffer amplifier is connected to the heater input. Connect the NTC resistor output to the AI0 (Analog Input 0) on the Connection Box. Finally, connect the +5 V output from the Connection Box to the NTC resistor circuit (BNC input on the box).
Compare your connections carefully with those depicted on Figure 38, dont mix up the +5 V input with NTC resistor output the NTC can easily be burned. Show your setup to an assistant before plugging +5 V to the circuit.

Thermal Response Time Before building your VI you have to know what sort of timescales you expect in the temperature dynamics: this timescale determines what type of DAQmx measurement system (continuous, single point, et cetera) you can or must use. What you have to estimate is the sampling time . Make a reasonable guess for the sampling time based on how quickly you expect the system to heat up under maximum heating20. You can actually check the thermal time response of the system. For this purpose you have to monitor the temperature over an extended period of time (say 20-25 minutes), and you have to be able to plot the change in temperature afterwards. You must monitor the temperature excursion under three consecutive conditions. Monitor room temperature : heater OFF (~1 minute). Measure speed of heating up: heater ON at constant voltage (set it to heat at 5 V) (~10 minutes). Wait until the temperature stops noticeably increasing, i.e. until . Measure speed of cooling down: heater OFF again (system cools down) (~10 minutes).
The system should settle at a constant value below the maximum temperature; if not set the heating voltage lower, say 4 V.

You should estimate this by calculating how fast the copper element would heat up if it did not lose heat to the environment; look up the heat capacity of copper and estimate the total volume of the copper element. An order-of-magnitude estimate will suffice here.
20

48

Software Now write a VI that monitors the voltage ( ) and corresponding temperature ( ) over the NTC. You can use an Expression Node to implement your conversion formula between the voltage and temperature. Put four digital controls on the front panel to set up the: sampling rate ( strength ). . , or the strength of the integrating set-point (desired) temperature the effective integration time feedback term .

of the proportional feedback term.

In order to prevent the Heater + Cu + NTC assembly from overheating (and possible breakage) while the VI isnt running, add a special control to your VI, which stops your VI via a button on the front panel, while setting the heating DAC voltage to zero. ( ) Derive the instantaneous error temperature ( ) , by subtracting from the measured NTC temperature. With these ingredients you are ready to write the PI control that calculates the required heating power ( ) with this error temperature, in combination with the feedback parameters and (or if you prefer.) A few tips and points of concern: Realize the program with single point input first you can always make it better later. Since feedback is of course not necessary for the thermal response time measurements, first make a program that allows you to check the thermal response time. Only then add the feedback breaking up the development of your code in this way makes building it easier. If you try to write more than the maximum output voltage to an output port, the DAQmx sub-VIs will return an error. Include this restriction in your VI. Note that negative voltages will also heat up your system! Active cooling is impossible in this system.21 You might want to monitor the heating voltage, temperature and other variables directly, and while you are measuring, in a graph. If so, make sure you use a Waveform Chart to plot data from inside the while loop. It might be convenient to start using the automatic data storage capabilities in LabVIEW; you will need to analyze the measured data after the actual acquisition has taken place.

21

Unless you get a Peltier cooler!

49

Does the system heat up and cool down exponentially with time? If so, what is the thermal response time of your system? Using the acquired time traces of the system dynamics (temperature) and measured values of and , determine the system thermal time constants for heating up ( ) and cooling down ( ). You can do that by determining when the temperature difference (T) increases/drops by a factor of e (Equation (2)), or, if you import the data into Origin, by fitting. Knowing these two time constants, do they compare well to the time constant you estimated before?

Temperature control with PI feedback


By now you have a PI control system that can control the temperature of the copper element. It is now time to optimize the values of the two free parameters in the theory. Optimization of the feedback parameters Optimization of the feedback parameters of a PI control requires some skill. A standard trick to find the limitations of the system and the control is to search for the feedback constant at which the temperature of the system just starts an undamped oscillation under proportional feedback only ( or ). As a rule of thumb, the optimum parameters for stable PI control are now for the proportional term. roughly can be determined from the oscillation period of the unstable system you just found at . Include several temperature measurements over several oscillation cycles, recorded at different , and indicate which is the best. Optimize the control system with the protocol described above. Include time traces in your lab journal of the temperature for a few different . Determine the optimum feedback parameters for PI control from these data and mention what criteria you used to select these values. Check how well the optimized feedback scheme controls the temperature and protects it from external influences like air currents (e.g. blowing). Perturb the system, record a time trace and include it in the lab journal. If you still have time left, dress up the temperature control in any way you find suited. Choose one, some or all from the following list: Include differential feedback to make it a PID instead of a PI control. In principle, this could speed up the control, but also makes it noisier. Include averaging: measure much faster than the thermal response time and average the measured temperatures to obtain a more accurate signal. You might have measured the actual value of the 5 V line used in the NTC circuit: the 5 V drifts and is actually not 5 V. This affects the temperature reading. You can correct for this when you measure the 5 V signal too. The most elegant, final extension is to let the algorithm optimize its own feedback constants. Such an intelligent control works by probing the systems dynamics during the heating and cooling trajectories and uses the 50

obtained information to optimize the feedback parameters possibly even ).

and

(and

Hats off if you can finish three out of four items from the list above!

References
I.M. Horowitz, Synthesis of feedback systems, Academic Press Inc., 1963 Wikipedia (the free encyclopedia), http://en.wikipedia.org/wiki/Feedback LabVIEW PID Control Toolkit for Windows, ni.com.

51

52

Practicum 3
The purpose of this practicum is to write and implement LabVIEW code in an experiment you design yourself. Your experiment should meet the following boundary conditions: A plan for the open experiment should be discussed with the assistants at the beginning of practicum 2. You can use the hardware that is available in the practicum room. If you have an idea for an experiment that requires more hardware, feel free to ask for it. You should pick a project difficult enough to fill the three afternoon sessions allotted to you. However, you are not allowed more time than that. You should use LabVIEW to communicate with external hardware (e.g.: GPIB, DAQ, et cetera). Naturally you will keep a lab journal.

We have at least the following hardware available. Again: if you think you need something else, just ask for it. Light sources: LEDs/lasers Stepper motor Microphones Photodetectors USB camera Speakers Optics: mirrors/lenses Set up a communication channel between two PCs with a light source and a photodetector. Measure, analyse, and modify sound spectra. Use a USB/Firewire camera for some simple computer vision experiments. Play Pong on the scope via analog I/O. Analyze the signal sent from a TV remote control and use it to control a LabVIEW program. Build an electronic musical instrument, such as a theremin (heard in every 1960s sci-fi movie soundtrack.) 53

Examples of experiments you can do are:

Use labview to control an X-Y recorder and scan an image or built an apparatus that finds the way out of a maze.

You are encouraged to come up with ideas for experiments yourself. Please note that there will be a deadline for picking a project; if you are late, then you will be responsible for procuring your own hardware!

54

LabVIEW keyboard shortcuts

55

56

You might also like