EET 2259 Programming for Electronics Technology Professor Nick Reeder Reminders Please turn off cell phones. No food or soft drinks in the classroom. Stow water bottles at floor level. EET 2259 Unit 1 LabVIEW Basics Read Bishop, Chapter 1. Lab #1 and Homework #1 due next week. LabVIEW Stands for Laboratory Virtual Instrument Engineering Workbench. It’s a software package created by National Instruments (www.ni.com). This company bought Multisim a few years ago. (Bishop, p. 3) National Instruments Company founded about 30 years ago in Austin, TX. In addition to Multisim, LabVIEW, and other software packages, they sell data acquisition boards and other hardware for using computers in engineering, science, and industry. (Bishop, pp. 3-4) Some of LabVIEW’s Uses General-purpose programming Instrument control Data acquisition Data analysis Data presentation Automated testing General-purpose Programming Writing programs to perform calculations, process information, play games, etc. Examples: Checkbook balancer Calorie counter Baseball statistics calculator This is not really what LabVIEW is meant for, but you can use it to do these things. Instrument Control Using computer to control multimeters, oscilloscopes, function generators, etc. Data Acquisition (DAQ) Connecting the computer directly to circuits or sensors to measure voltage, current, temperature, pressure, light intensity, chemical composition, etc. Need to have either: a special data-acquisition board installed in your computer, or an external data-acquisition device such as an NI myDAQ. Data Analysis Performing statistical analysis, curve fitting, signal processing, or other kinds of mathematical calculations on the data that you’ve gathered from a DAQ board or from measuring instruments. Similar to what you can do with Microsoft Excel or other spreadsheet programs. Data Presentation Using tables, charts, and graphs to present the results of your data analysis. Again, similar to what you can do with Microsoft Excel or other spreadsheet programs. Automated Testing Using computers to automatically test circuit boards or other manufactured parts as they leave an assembly line. G LabVIEW is built around a programming language called G. Most of this course will be devoted to learning how to write programs in G. (Bishop, p. 4) Graphical vs. Text-Based Language Most other programming languages (Assembly, VisualBasic, C, C++, Java, etc.) are text-based languages. You write programs by typing text. G is a graphical language. You write programs by placing icons and connecting them with wires. (Bishop, p. 4) Example Program in C #include <stdio.h> int main() { float value1, value2, product; printf("Enter first number => "); scanf("%f", &value1); printf("Enter second number => "); scanf("%f", &value2); product = value1 * value2; printf("The product is %f", product); Same Program in LabVIEW “Virtual Instruments” LabVIEW programs are called virtual instruments, or VIs for short. When you save a program file in LabVIEW, its extension is “.vi” (Bishop, p. 4) Front Panel & Block Diagram Every LabVIEW program has two parts, which appear in two different windows on your computer screen: the front panel and the block diagram. You don’t have to save these two parts separately; whenever you save, they’re both saved in the same file. Front Panel The front panel is the user interface for a program. It contains controls (inputs) and indicators (outputs). Controls let the user feed data into the program. Indicators let the program give data back to the user. Sample Front Panel Block Diagram The block diagram shows the program’s underlying logic. It shows how the user’s data (entered through controls) is manipulated to give the results that are fed back to the user (through indicators). The block diagram contains components “wired” together. Sample Block Diagram Toolbar Run Button Continuous Run Button Abort Execution Additional Buttons on the Diagram Toolbar Pause/Continue Button Execution Highlighting Button Text Settings Step Into Button Align Objects Step Over Button Distribute Objects Step Out Button Reorder Resize front panel objects (Bishop, pp. 10-14) Controls Palette & Functions Palette Controls Palette (Used to place controls & indicators on Front Panel) Functions Palette (Used to place functions on Block Diagram) (Bishop, pp. 24-26) Menus LabVIEW has pull-down menus and short-cut menus (pop-up menus) that give you many options. Sections 1.6 and 1.7 in textbook discuss the menus. (Bishop, pp. 14-23) Help LabVIEW’s context help window is very useful. It automatically shows help for functions and other objects when you roll your mouse over those objects. More detailed help is also available through Help menu. (Bishop, pp. 33-34) Context Help Window Ctrl + H Detailed help Lock help Simple/Complex Diagram help Saving Your Control Values When you save a VI, values that you have set on the front panel are not saved. But you can make them be saved by selecting Edit > Make Current Values Default before you save. Or you can do this with a single control by right-clicking it and selecting Data Operations > Make Current Value Default. Example Programs LabVIEW comes with many example VIs, which you can access by clicking Help > Find Examples… in LabVIEW’s menus. More examples are in the textbook’s Learning Directory files, which you’ll download from the Web as part of Homework #1. (Bishop, p. 5)