Home

A. LabVIEW

image

Contents

1. m E hole o ern Sor a Sample Simulate Signal amp Compression Signals Enable Mean Notice that the While Loop shown at left appears with a STOP button wired to the condition terminal This While Loop is configured to stop when the user clicks the STOP button 5 Display the front panel and run the VI Notice that the VI now runs until you click the STOP button A While Loop executes the functions inside the loop until the user presses the STOP button Refer to Lesson 3 Repetition and Loops of this manual for more information about While Loops Controlling the Speed of Execution To plot the points on the waveform graph more slowly you can add a time delay to the block diagram Complete the following steps to control the speed at which the VI executes 1 On the block diagram select the Time Delay Express VI on the Functions Execution Control palette and place it inside the loop 2 Type 250 in the Time delay seconds text box This time delay specifies how fast the loop runs With a 250 second time delay the loop iterates once every quarter of a second Close the Configure Time Delay dialog box 4 Save this VI Display the front panel and run the VI National Instruments Corporation 1 49 LabVIEW Introduction Course Manual Lesson1 Introduction to LabVIEW 6 Click the Enable switch and notice the change on the graph Notice how if the Enable switch is on the graph displays
2. Type Stab temp end into the Text with Variables in Percents text box to set up three variables one for the tab constant one for the temperature and one for the end of line constant Because time uses the Beginning Text input of the Build Text Express VI it does not need a variable Select temp in the Configure Variables section Select the Number option and a format of Format fractional number The tab and end variables do not need to be formatted You can leave them in the default state Click the OK button to close the configuration dialog box Right click the Build Text Express VI and select View As Icon to conserve block diagram space Place a Tab constant and an End of Line constant located on the Functions All Functions String palette on the block diagram Place the Write File function located on the Functions All Functions File I O palette on the block diagram This function writes to the file specified by refnum Place the Close File function located on the Functions All Functions File I O palette on the block diagram This function closes the file Place the Simple Error Handler VI located on the Functions All Functions Time amp Dialog palette on the block diagram This VI checks the error cluster and displays a dialog box if an error occurs h Complete the block diagram as shown 3 Save the VI You will use this VI later in the course 8 27 LabVIEW Introduction Course Manual
3. 3 LEC JLEC LabVIEW Introduction Course Manual La LEC I 3 LEC Build Text String Length Combined String Match Pattern l abbq a Mumber Out regular expression z Place the Build Text Express VI located on the Functions Output palette on the block diagram This function converts Number to a string The Build Text configuration dialog box appears Type tHeader Number Trailer in the Text with Variables in Percents text box to create three variables The variables appear in the Configure Variables section Select Number in the Variable section Inthe Variable Properties section select the Number option set the Format to Format fractional number Place a checkmark in the Use specified precision checkbox and set the Precision to 4 Leave the Header and Trailer variables in the default state Click the OK button to close the dialog box Place the String Length function located on the Functions All Functions String palette on the block diagram This function returns the number of characters in Result Place the Match Pattern function located on the Functions All Functions String palette on the block diagram This function searches String 2 for a colon Right click the regular expression input select Create Constant from the shortcut menu type a colon and press the lt Enter gt key on the numeric keypad You also can click the Enter button on the toolbar to complete
4. es Design Patterns Master Slave Design Pattern Producer Consumer Design Pat Producer Consumer Design Patt Queued Message Handler Standard State Machine User InterFace Event Handler Instrument IO PIB TE i Read and Display 2 A Simulated a Generate and Display i Load from File and Display l et Tutorial Getting Started Generate Analyze and Display Generate and Display F d Browse For Template C Small dialog Large dialog Cancel Help E Other Document Types Figure 1 2 New Dialog Box Click the OK button to open the template You also can double click the name of the template VI in the Create new list to open the template If no template 1s available for the task you want to create you can start with a blank VI and create a VI to accomplish the specific task In the LabVIEW dialog box click the arrow on the New button and select Blank VI from the shortcut menu or press the lt Ctrl N gt keys to open a blank VI Kp Note You also can open a blank VI by selecting Blank VI from the Create new list in the New dialog box or by selecting File New VI LabVIEW Introduction Course Manual 1 4 ni com Lesson1 Introduction to LabVIEW Open Templates Use the New dialog box to create different components in LabVIEW to help you build an application You can start with a blank VI to write a VI from scratch or start with a template to simplify the programming The New dialog box includes the following componen
5. Lesson 8 Strings and File I O Run the VI Optional Display the front panel and run the VI The Enter File Name dialog box appears Type temp txt and click the Save or OK button The VI creates a file called temp txt The VI takes readings every half second and saves the time and temperature data to a file until you click the Power switch When the VI finishes it closes the file Open a word processor or spreadsheet application such as Windows Notepad or WordPad Mac OS SimpleText or UNIX Text Editor Open the temp txt file in the word processing or spreadsheet application The time appears in the first column and the temperature data appears in the second column Exit the word processor or spreadsheet application and return to LabVIEW If time permits complete the optional steps Otherwise close the VI When using error handling in a VI the While Loop should stop executing when an error occurs Complete the following steps to modify the VI so it stops when the user clicks the Power switch or an error occurs 10 Edit the block diagram as shown in the following figure prompt Enter File Mame Function topen 0 4 create or replace LabVIEW Introduction Course Manual SECT _ End of Line he k L3 LEC LALEC 5 Build Text Bundle Temperature History Warning High Value Wait Until Next 500 Tick Multiple 8 28 ni com Lesson 8 Strings and File 1 0 S status a Place the Unbund
6. Note e View an animation of the execution of the block diagram by clicking the Highlight Execution button shown at left Execution highlighting shows the flow of data on the block diagram from one node to another using bubbles that move along the wires Use execution highlighting in conjunction with single stepping to see how data move from node to node through a VI Execution highlighting greatly reduces the speed at which the VI runs Single step through a VI to view each action of the VI on the block diagram as the VI runs The single stepping buttons affect execution only in a VI or subVI in single step mode Enter single step mode by clicking the Step Over or Step Into button Move the cursor over the Step Over Step Into or Step Out button to view a tip strip that describes the next step if you click that button You can single step through subVIs or run them normally If you single step through a VI with execution highlighting on an execution glyph shown at left appears on the icons of the subVIs that are currently running Use the Probe tool shown at left to check intermediate values on a wire as a VI runs When execution pauses at a node because of single stepping or a breakpoint you also can probe the wire that just executed to see the value that flowed through that wire LabVIEW Introduction Course Manual 1 52 ni com Lesson1 Introduction to LabVIEW You also can create a custom probe to specify which indicator y
7. Save this VI as Reduce Samples vi in the C Exercises LabVIEW Basics I directory Complete the following steps to use the LabVIEW Help to search for the Express VI that reduces the number of samples in a signal l LabVIEW Introduction Course Manual Select Help VI Function amp How To Help to open the LabVIEW Help Click the Search tab and type sample compression in the Type in the word s to search for text box Notice that this word choice reflects what you want this Express VI to do compress or reduce the number of samples in a signal 1 46 ni com 9 10 Lesson1 Introduction to LabVIEW To begin the search press the lt Enter gt key or click the List Topics button Double click the Sample Compression topic to display the topic that describes the Sample Compression Express VI After you read the description of the Express VI click the Place on the block diagram button to select the Express VI Move the cursor to the block diagram Notice how LabVIEW attaches the Sample Compression Express VI to the cursor Place the Sample Compression Express VI on the block diagram to the right of the Simulate Signal Express VI Configure the Sample Compression Express VI to reduce the signal by a factor of 25 using the mean of these values Close the Configure Sample Compression dialog box Using the Wiring tool wire the Sine output in the Simulate Signal Express VI to the Signals input in the Sample Co
8. National Instruments Corporation 10 11 LabVIEW Introduction Course Manual Lesson 10 Instrument Control 8 4 To parse the data received click the Auto parse button Notice that Token now appears in the Outputs pane on the left side of the dialog box This value represents the string returned from the identification query Rename Token by typing ID String in the Token name text box 5 Click the Add Step button Click Query and Parse Type MEAS DC as the command and click the Run this step button 6 To parse the data received click the Auto parse button The data returned is a random numeric value Rename Token by typing Voltage in the Token name text box 7 Click the OK button to exit the I O Assistant and return to the block diagram b Right click the ID String output and select Create Indicator from the shortcut menu c Right click the Voltage output and select Create Indicator from the shortcut menu d Wire the Error Out output to the Simple Error Handler VI Display the front panel and run the VI Resize the string indicator if necessary Save the VI as Read Instrument Data vi inthe C Exercises LabVIEW Basics I directory Right click the I O Assistant and select Show Front Panel Click the Convert button when asked if you want to convert to a subVI View the code generated by the I O Assistant Where is the command TDN written to the Instrument Simulator Where is the voltage being read
9. Select File Exit to exit the subVI Do not save changes End of Exercise 10 2 LabVIEW Introduction Course Manual 10 12 ni com Lesson 10 Instrument Control D VISA Virtual Instrument Software Architecture VISA is the lower layer of functions in the LabVIEW instrument driver VIs that communicates with the driver software Overview In 1993 National Instruments joined with GenRad Racal Instruments Tektronix and Wavetek to form the VXIplug amp play Systems Alliance The goals of the alliance are to ensure multivendor interoperability for VXI systems and to reduce the development time for an operational system A key part of these goals was to develop a new standard for instrument drivers soft front panels and I O interface software The term V XIplug amp play has come to indicate the conformity of hardware and software to these standards In directing their efforts toward software standardization V XIplug amp play members identified the following set of guiding principles e Maximize ease of use and performance e Maintain long term compatibility with the installed base e Maintain multivendor open architectures e Maximize multiplatform capability e Maximize expandability and modularity in frameworks e Maximize software reuse e Standardize the use of system software elements e Treat instrument drivers as part of the instrument e Accommodate established standards e Maximize cooperative support of
10. The temperature sensor on the DAQ Signal Accessory outputs the voltage in degrees Celsius scaled by 100 In order to convert the voltage into degrees Celsius it is necessary to multiply the voltage by 100 You could multiply the output of the DAQ Assistant Express VI by 100 or configure the DAQ Assistant Express VI to automatically scale the voltage Using the capabilities that exist within the VI reduces block diagram clutter 6 Double click the DAQ Assistant to display the Analog Input Voltage Task Configuration dialog box 7 Select Create New in the Custom Scaling pull down menu LabVIEW Introduction Course Manual 9 16 ni com 10 11 12 Lesson9 Data Acquisition and Waveforms Select Linear and name the scale temperature Click the Finish button A dialog box appears where you can scale the data by a multiplier and an offset a Set the slope to 100 and the Scaled Units to Celsius b Click the OK button to close the dialog box In the Analog Input Voltage Task Configuration dialog box set the minimum input range to 0 set the maximum input range to 100 and click the OK button to return to the block diagram Run the VI The temperature displays in the meter The temperature values are 100 times greater than the voltage values Change the meter scale to see the correct values Stop the VI Save the VI but do not close it You will use the VI in Exercise 9 3 End of Exercise 9 2 National Instruments Co
11. 1 Open a blank VI and begin building the following front panel 2 Optional Select Window Tile Left and Right to display the front panel and block diagram side by side or Window Tile Up and Down to display the front panel and block diagram stacked 3 Create a numeric control You will use this control to enter the value for degrees Celsius a Select Controls Numeric Controls to display the Numeric Controls palette If the Controls palette is not visible right click an open space on the front panel workspace to display it b Select the Numeric Control Move the control to the front panel and click to place the control c Type deg C inside the label of the control and press the lt Enter gt key or click the Enter button shown at left on the toolbar If you do not type the name immediately LabVIEW uses a default label Tip You can edit a label at any time by double clicking the label using the Labeling tool or right clicking and selecting Properties from the shortcut menu to display the property dialog box 1 4 Create a numeric indicator You will use this indicator to display the value for degrees Fahrenheit a Select the Numeric Indicator located on the Controls Numeric Indicators palette b Move the indicator to the front panel and click to place the indicator c Type deg F inside the label and press the lt Enter gt key or click the Enter button National Instruments Corporation 2 9 LabVI
12. Contents Lesson 10 Instrument Control As Instrument Control Overview scaricare ansantidat n E Soatewenedesnunsieadaas 10 2 B GPIB Communication and Configuration ccccccccccssssessseeeeeeceeaaeeseeeeeeeeeeeaaas 10 3 C Using the Instrument I O Assistant cccecssecccececeeeeesseeeeceeeeeeaaeeeeeeeeeeeeeaaas 10 9 D NISA e a oaaa sas sae aaa e ease otsae bese nes eset 10 13 Fc ADOUt MISE ine Mt FIV CES hatacti tin Seanad einat yh araae neiticdit eaten neta agent 10 18 F Usine Instrument Driver WIS eriseeria a O Ea UREE 10 19 Ge Serial Port Commun aloe N 10 25 H Waveform Transfers Optional ssseeeeessssssssseerrsssssssscerrsssssssseererssssssseeerrssssss 10 34 Lesson 11 Customizing Vis A Configuring the Appearance of Front Panels cccceccccccccccccceesseeeeeeeeeeeeeaeeeeees 11 2 B Opening SubVI Front Panels when a VI Runs i eeeccccccceeceeeeeeseeeeeeeeeeeeaas 11 5 C Keyboard Shortcuts for C ntrolscsenensienonnitean a a a 11 9 D Edin VLEPrOP IG Seye i A este auaeeietetes 11 13 E Customizing the Controls and Functions Palettes Optional ceeeeeeees 11 16 Appendix A As OG Onal M orma eean a E TN A 1 B ASCH Character Code Equivalents Tabie rinser A 3 Ca ENSTRUG TORINO IES sci sascusekcscensasnvscadcacsccnatasrennoasdictactagvecanimeswers soeuncadsmenseeiccs aoei A 6 National Instruments Corporation V LabVIEW Introduction Course Manual Student Guide Thank you fo
13. Data directory in the default file directory for your operating system to help you organize and locate the data files LabVIEW generates By default the Write LabVIEW Measurement File Express VI stores the 1vm files it generates in this directory and the Read LabVIEW Measurement File Express VI reads from this directory The Default Data Directory constant shown at left and the Default Data Directory property also return the LabVIEW Data directory by default Select Tools Options and select Paths from the top pull down menu to specify a different default data directory The default data directory differs from the default directory which is the directory you specify for new VIs custom controls VI templates or other LabVIEW documents you create A typical file I O operation involves the following process 1 Create or open a file Indicate where an existing file resides or where you want to create a new file by specifying a path or responding to a dialog box to direct LabVIEW to the file location After the file opens a refnum represents the file A reference number or refnum is a unique identifier for an object such as a file device or network connection 2 Read from or write to the file 3 Close the file National Instruments Corporation 8 11 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O D High Level File 1 0 Vis Most File I O VIs and functions perform only one step in a file I O operation Howe
14. Deg F and the x axis Time sec Select Window Show Block Diagram to display the block diagram 3 Enclose the two terminals in a While Loop as shown in the following block diagram 6 4 ni com Lesson6 Plotting Data Temperature History pom Wait Until Next ms Multiple millisecond multiple A G 4 Right click the conditional terminal and select Continue if True 5 Wire the objects as shown in the previous block diagram rre a Place the Thermometer VI on the block diagram Select Functions All Functions Select a VI and navigate to C Exercises LabVIEW Basics I Thermometer vi This subVI returns one temperature measurement from the temperature sensor Kp Note Use the Demo Thermometer VI if you do not have a DAQ device available b Place the Wait Until Next ms Multiple function located on the Functions All Functions Time amp Dialog palette on the block diagram S00 c Right click the millisecond multiple input of the Wait Until Next ms Multiple function select Create Constant from the shortcut menu type 500 and press the lt Enter gt key The numeric constant specifies a wait of 500 ms so the loop executes once every half second Kp Note To measure temperature in Celsius wire a Boolean TRUE constant located on the Functions Arithmetic amp Comparison Express Boolean palette to the Temp Scale input of the Thermometer VI Change the scales on charts and graphs in subsequent exercises to a ra
15. Double click the Rectangle tool shown at left to redraw the border National Instruments Corporation 2 19 LabVIEW Introduction Course Manual Lesson2 Modular Programming C f Use the Pencil tool shown at left to draw an icon that represents the thermometer Use the Foreground and Fill tools to color the thermometer red Kp Note To draw horizontal or vertical straight lines press the lt Shift gt key while you use the Pencil tool to drag the cursor Double click the Text tool shown at left and change the font to Small Fonts Type Temp Reposition the text if necessary Select the B amp W icon and select 256 Colors in the Copy from section to create a black and white icon which LabVIEW uses for printing unless you have a color printer When the icon is complete click the OK button The icon appears in the upper right corner of the front panel 17 Right click the icon and select Show Connector from the shortcut menu and assign terminals to the switch and the thermometer a b C d e Click the left terminal in the connector pane Click the Temp Scale control The left terminal turns green Click the right terminal in the connector pane Click the Temperature indicator The right terminal turns orange Click an open space on the front panel 18 Save the VI as Thermometer vi in the C Exercises LabVIEW Basics I directory You will use this VI later in the course 19 Close the VI
16. Express Boolean palette on the block diagram 8 Save the Vlas Simple Data Reader vi inthe C Exercises LabVIEW Basics I directory 9 Display the front panel and run the VI In the filename prompt that appears select the logger 1vm file that you created in step 4 10 The data that was stored in the LabVIEW Measurement File appears in the waveform chart Kp Note You might need to rescale or autoscale the y axis of the waveform chart to display the data 11 Close the Simple Data Reader VI End of Exercise 9 4 LabVIEW Introduction Course Manual 9 22 ni com Lesson9 Data Acquisition and Waveforms E Analog Output Use analog output to perform digital to analog D A conversions The available analog output types for a task are voltage and current NI DAQ DAO Assistant a Measurement Types Select the measurement type for your task Analog Output Back ext gt Finish Cancel ly ee To perform a voltage or current task a compatible device must be installed that can generate that form of signal Task Timing When performing analog output the task can be timed to Generate 1 Sample Generate n Samples or Generate Continuously Generate 1 Sample Use single updates if the signal level is more important than the generation rate For example generate one sample at a time if you need to generate a constant or DC signal You can use software timing to control when the device generates a signa
17. For example a 24 bit counter can count to Counter Resolution 224 16 777 215 When a 24 bit counter reaches the value of 16 777 215 it has reached the terminal count The next active edge will force the counter to roll over and start at Q LabVIEW Introduction Course Manual 9 28 ni com Lesson9 Data Acquisition and Waveforms Exercise 9 6 Simple Event Counting VI Objective To create a simple event counting VI Complete the following steps to build a VI that counts pulses from the quadrature encoder on the DAQ Signal Accessory Front Panel 1 Open a blank VI and build the following front panel Number of Events a Block Diagram 2 Build the following block diagram le i F F DAQ Assistant Ee a Number of Events Place the DAQ Assistant Express VI located on the Functions Input palette in a While Loop Complete the following steps to configure the counter to perform event counting Select Counter Input Edge Count for the measurement to make b Select Dev1 ctr0 for the physical channel c Inthe Counter Input Edge Count Task Configuration dialog box that appears leave the settings as they are The default settings define the source of the counter as being Programmable Function Input PFI 8 which is the default source for counter 0 The DAQ Signal Accessory connects counter 0 source input to PFI 8 d Click the OK button to close the Counter Input Edge Count Task Configurati
18. However you cannot wire an orange knob to an input with a green label Notice the wires are the same color as the terminal The dynamic data type stores the information generated or acquired by an Express VI The dynamic data type appears as a dark blue terminal shown at left Most Express VIs accept and or return the dynamic data type You can wire the dynamic data type to any indicator or input that accepts numeric waveform or Boolean data Wire the dynamic data type to an indicator that can best present the data Indicators include a graph chart or numeric indicator Most other VIs and functions in LabVIEW do not accept the dynamic data type To use a built in VI or function to analyze or process the data the dynamic data type includes you must convert the dynamic data type Use the Convert from Dynamic Data Express VI shown at left to convert the dynamic data type to numeric Boolean waveform and array data types for use with other VIs and functions When you place the Convert from Dynamic Data Express VI on the block diagram the Configure Convert from Dynamic Data dialog box appears The Configure Convert from Dynamic Data dialog box displays options that let you specify how you want to format the data that the Convert from Dynamic Data Express VI returns National Instruments Corporation 1 25 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW When you wire a dynamic data type to an array indicator Lab
19. LEDs and other displays Controls simulate instrument input devices and supply data to the block diagram of the VI Indicators simulate instrument output devices and display data the block diagram acquires or generates Controls Palette The Controls palette is available only on the front panel The Controls palette contains the controls and indicators you use to create the front panel Select Window Show Controls Palette or right click the front panel workspace to display the Controls palette Tack down the Controls palette by clicking the thumbtack on the top left corner of the palette By default the Controls palette starts in the Express view The Express palette view includes subpalettes on the top level of the Controls and Functions palettes that contain Express VIs and other objects you need to build common measurement applications The All Controls and LabVIEW Introduction Course Manual 1 18 ni com Lesson 1 Introduction to LabVIEW All Functions subpalettes contain the complete set of built in controls indicators VIs and functions The Advanced palette view includes subpalettes on the top level of the Controls and Functions palettes that contain the complete set of built in controls indicators VIs and functions The Express subpalettes contain Express VIs and other objects you need to build common measurement applications Kp Note In the Express palette view toolsets and modules do not install subpalettes on the top lev
20. Number to Match and returns TRUE if the numbers are not equal otherwise it returns FALSE Place the While Loop located on the Functions Execution Control palette on the block diagram Right click the conditional terminal and select Continue if True from the shortcut menu Wire the iteration terminal to the border of the While Loop A blue tunnel appears on the While Loop border You will wire the tunnel to the Increment function Each time the loop executes the iteration terminal increments by one The iteration count passes out of the loop upon completion Increment this value by one outside the loop because the count starts at 0 3 7 LabVIEW Introduction Course Manual Lesson3 Repetition and Loops hi gt h Place the Increment function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram This function adds 1 to the While Loop count A coercion dot appears on the of iterations output to indicate that LabVIEW coerced the numeric representation of the iteration terminal to match the numeric representation of the of iterations output Refer to the For Loops section of this lesson for more information about numeric conversion 6 Save the VI as Auto Match vi inthe C Exercises LabVIEW Basics I directory Run the VI 7 Display the front panel and change the number in Number to Match Run the VI Change Number to Match and run the VI again Current Number updates at every iter
21. Select a VI and navigate to C Exercises LabVIEW Basics I Thermometer vi This subVI returns one temperature reading during each For Loop iteration Ky Note Use the Demo Thermometer VI if you do not have a DAQ device available NI b Place a For Loop located on the Functions All Functions m Structures palette on the block diagram In this exercise each For Loop iteration generates a temperature value and stores it in the indexed tunnel Create a constant of 100 for the count terminal c Wire the block diagram as shown in the previous figure iz Tip When you wire data to charts and graphs refer to the Context Help window for more information about wiring the objects including whether to use a Build Array or Bundle function the order of the input terminals and so on In general use a waveform chart for single scalar points a waveform graph for an array of y values and an XY graph for an array of x values and an array of y values For example if you move the cursor over a waveform graph terminal on the block diagram the following information appears in the Context Help window Select Help Find Examples to launch the NI Example Finder double click Fundamentals double click Graphs and Charts and double click Waveform Graph VI to open the example Refer to Lesson 9 Data Acquisition and Waveforms for more information about the waveform data type I gt Context Help Waveform Graphs Wire data directly to waveform
22. You can change the behavior and appearance of the conditional terminal by right clicking the terminal or the border of the While Loop and selecting Continue if True shown at left You also can use the Operating tool to click the conditional terminal to change the condition When a conditional terminal is Continue if True the While Loop executes its subdiagram until the conditional terminal receives a FALSE value as shown in the following block diagram The While Loop executes until the subVI output is less than 10 00 or the Enable control is FALSE National Instruments Corporation 3 3 LabVIEW Introduction Course Manual Lesson3 Repetition and Loops Structure Tunnels Data can be passed out of or into a While Loop through a tunnel Tunnels feed data into and out of structures The tunnel appears as a solid block on the border of the While Loop The block is the color of the data type wired to the tunnel Data pass out of a loop after the loop terminates When a tunnel passes data into a loop the loop executes only after data arrive at the tunnel In the following block diagram the iteration terminal is connected to a tunnel The value in the tunnel does not get passed to the Iteration Number indicator until the While Loop has finished execution Only the last value of the iteration terminal displays in the Iteration Number indicator LabVIEW Introduction Course Manual 3 4 ni com Lesson3 Repetition and Loops Exercise
23. millisecond multiple A ME as a Place the Bundle function located on the Functions All Functions Cluster palette on the block diagram This function bundles the average and current temperature for plotting on the waveform chart 10 Save the VI You will use this VI later in the course Run the VI 11 Run the VI The VI displays two plots on the waveform chart The plots are overlaid That is they share the same vertical scale 12 If time permits complete the optional steps Otherwise close the VI LabVIEW Introduction Course Manual 6 10 ni com Lesson6 Plotting Data Optional Customize the waveform chart as shown in the following front panel You can display a plot legend a scale legend a graph palette a digital display and a scrollbar By default a waveform chart displays the plot legend Running Awg Temperature History Curent Temp Time sec ne Time sec altaf Be 2 JTemp Dear SNN 13 Customize the y axis a Use the Labeling tool to double click 70 0 in the y axis type 75 0 and press the lt Enter gt key b Use the Labeling tool to double click the second number from the bottom on the y axis type 80 0 and press the lt Enter gt key This number determines the numerical spacing of the y axis divisions For example if the number above 75 0 is 77 5 it indicates a y axis division of 2 5 changing the 77 5 to 80 0 reformats the y axis to multiples of 5 0
24. 3 1 Auto Match VI Objective To pass data out of a While Loop through a tunnel Complete the following steps to build a VI that generates random numbers until the number generated matches a number you specify The iteration terminal records the number of random numbers generated until a match occurs Front Panel 1 Open a blank VI and build the following front panel Modify the controls and indicators as shown in the following front panel and as described in the following steps Sumber to Match Current Number D numeric control pumeric indicator Data Range Precision 0 Default 50 Min 0 Coerce Max 10000 Coerce of iterations Inc 1 Coerce to Nearest oo Precision 0 or numeric indicator Precision 0 a Place a numeric control located on the Controls Numeric Controls palette on the front panel Label the control Number to Match This control specifies the number to match b Place a numeric indicator located on the Controls Numeric Indicators palette on the front panel Label the indicator Current Number This indicator displays the current random number c Place another numeric indicator on the front panel Label the indicator of iterations This indicator displays the number of iterations before a match National Instruments Corporation 3 5 LabVIEW Introduction Course Manual Lesson 3 Repetition and Loops Setting the Data Range Set a data range for a control to pr
25. Fundamentals LabVIEW Real Time Systems Using PXI LabVIEW Real Time Systems Using FieldPoint LabVIEW Internet Applications LabVIEW Datalogging and Supervisory Control Module LabVIEW Introduction Course Manual viii ni com Student Guide A About This Manual This course manual teaches you how to use LabVIEW to develop test and measurement data acquisition instrument control datalogging measurement analysis and report generation applications This course manual assumes that you are familiar with Windows Mac OS or UNIX and that you have experience writing algorithms in the form of flowcharts or block diagrams The course manual is divided into lessons each covering a topic or a set of topics Each lesson consists of the following e An introduction that describes the purpose of the lesson and what you will learn e A description of the topics in the lesson e A set of exercises to reinforce those topics Some lessons include optional and challenge exercise sections or a set of additional exercises to complete if time permits e A summary that outlines important concepts and skills taught in the lesson Several exercises in this manual use one of the following National Instruments hardware products e A plug in multifunction data acquisition DAQ device connected to a DAQ Signal Accessory containing a temperature sensor function generator and LEDs e A GPIB interface connected to an NI Instrument Simulator
26. How to create string controls and indicators How to use the String functions About file I O operations How to use the high level File I O VIs How to use the low level File I O VI and functions ae Oe amp How to format text files for use in spreadsheets National Instruments Corporation 8 1 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O A Strings A string 1s a sequence of displayable or non displayable ASCII characters Strings provide a platform independent format for information and data Some of the more common applications of strings include the following e Creating simple text messages e Passing numeric data as character strings to instruments and then converting the strings to numeric values e Storing numeric data to disk To store numeric values in an ASCII file you must first convert numeric values to strings before writing the numeric values to a disk file e Instructing or prompting the user with dialog boxes On the front panel strings appear as tables text entry boxes and labels Creating String Controls and Indicators Use the string control and indicator located on the Controls Text Controls and Controls Text Indicators palettes to simulate text entry boxes and labels Use the Operating tool or Labeling tool to type or edit text in a string control Use the Positioning tool to resize a front panel string object To minimize the space that a string object occupies right click
27. However the number of bytes in the string 1s significantly lower It is more efficient to transfer waveforms as binary strings than as ASCII strings because binary encoding requires fewer bytes to transfer the same information 8 Close the VI Do not save changes End of Exercise 10 6 National Instruments Corporation 10 39 LabVIEW Introduction Course Manual Lesson 10 Instrument Control Summary Tips and Tricks e LabVIEW can communicate with an instrument that connects to the computer as long as you know what kind of interface it 1s and what cabling is required e Use MAX to configure and test GPIB interface cards connected instruments serial ports and parallel ports e LabVIEW instrument drivers eliminate the need to learn the complex low level programming commands for each instrument e The LabVIEW instrument driver library is located on the LabVIEW CD You also can download drivers from the NI Web site at ni com e All instrument drivers in the library have the same basic VI hierarchy e Use the Instrument I O Assistant to rapidly and easily build a VI to communicate with an instrument You can control VXI GPIB RS 232 and other types of instruments e Serial communication is a popular means of transmitting data between a computer and a peripheral device such as a programmable instrument or even another computer LabVIEW Introduction Course Manual 10 40 ni com Lesson 10 Instrument Control Additional E
28. If you do not have this hardware you still can complete most of the exercises Be sure to use the demo versions of the VIs when you are working through exercises Exercises that explicitly require hardware are indicated meni with an icon shown at left You also can substitute other hardware for those previously mentioned For example you can use a GPIB instrument in place of the NI Instrument Simulator or another National Instruments DAQ device connected to a signal source such as a function generator Each exercise shows a picture of a finished front panel and block diagram after you run the VI as shown in the following illustration After each block diagram picture is a description of each object on the block diagram National Instruments Corporation Ix LabVIEW Introduction Course Manual Student Guide Auto Match vi Front Panel GSES Auto Match vi Block Diagram File Edit Operate Tools Browse Window Help File Edit Operate Tools Browse Window Help 13pt Application Font 85 sia dso i starts at 0 so increment by 1 1 Front Panel 2 Block Diagram 3 Comments Do Not Enter These LabVIEW Introduction Course Manual X ni com Student Guide B What You Need to Get Started Before you use this course manual ensure you have all the following items Q Windows Windows 98 or later installed on your computer Mac OS System 10 2 or later for Mac OS X System 9 1 or later for OS 9 x or earlier UN
29. In addition every issue contains a disk of LabVIEW VIs and utilities that implement methods covered in that issue To order LabVIEW Technical Resource contact LTR publishing at 214 706 0587 or visit www Ltrpub com LabVIEW Books Many books have been written about LabVIEW programming and applications The National Instruments Web site contains a list of all the LabVIEW books and links to places to purchase these books Publisher information is also included so you can directly contact the publisher for more information on the contents and ordering information for LabVIEW and related computer based measurement and automation books The info labview Listserve Info labview is an email group of users from around the world who discuss LabVIEW issues The list members can answer questions about building LabVIEW systems for particular applications where to get instrument drivers or help with a device and problems that appear Send subscription messages to the info labview list processor at listmanager pica army mil Send other administrative messages to the info labview list maintainer at info labview REQUEST pica army mil Post a message to subscribers at info labview pica army mil You may also want to search the ftp archives at ftp ftp pica army mil pub labview The archives contain a large set of donated VIs for doing a wide variety of tasks LabVIEW Introduction Course Manual A 2 ni com Appendix A B ASCII
30. Input palette on the block diagram When you place this Express VI on the block diagram the DAQ Assistant configuration dialog box appears a Select Analog Input Voltage for the type of measurement to make b Select Dev1 ai0 or Dev2 ai0 for the physical channel and click the Finish button c You must multiply the temperature by 100 to convert it from voltage to Celsius On the Settings tab select Custom Scaling Create New Select a Linear scale Name the scale Temperature Enter a slope scale of 100 Click the OK button d Select the Acquire 1 Sample option on the Task Timing tab Click the OK button ny Note If you do not have a DAQ device with a temperature sensor connected to your computer use the Demo Read Voltage VI located in the C Exercises LabVIEW Basics I directory Ea ze 10 CF SS 11 LabVIEW Introduction Course Manual Place the Convert from Dynamic Data Express VI located on the Functions Signal Manipulation palette on the block diagram This VI converts the dynamic data type In the configuration dialog box select Single scalar in the Resulting data type listbox Place the Convert C to F VI on the block diagram Select Functions All Functions Select a VI navigate to C Exercises LabVIEW Basics I Convert C to F vi This VI converts the Celsius readings to Fahrenheit Place the Select function located on the Functions Arithmetic amp Comparison Express Comparison palette on
31. LabVIEW includes two built in palette views Express and Advanced Select Tools Advanced Edit Palette Views to create or edit custom palette views ny Note You cannot edit a built in palette view Refer to the LabVIEW User Manual and the LabVIEW Help for more information about palette views LabVIEW Introduction Course Manual 11 16 ni com Lesson11 Customizing VIS Summary Tips and Tricks e Select File VI Properties to configure the appearance and behavior of a VI You also can right click the VI icon on the front panel or block diagram and select VI Properties from the shortcut menu e Ifyou want a single instance of the subVI to open its front panel when called right click the subVI and select Sub VI Node Setup from the shortcut menu Place checkmarks in the Show Front Panel when called and Close afterwards if originally closed checkboxes e If you want every instance of the subVI to open its front panel when called select File VI Properties and select Window Appearance from the Category pull down menu Click the Customize button and place checkmarks in the Show Front Panel When Called and Close Afterwards if Originally Closed checkboxes e Assign keyboard shortcuts to controls by right clicking the control and selecting Advanced Key Navigation from the shortcut menu e Before you change VI properties save a backup of the VI to a new location by selecting File Save with Options to avoid making the VI difficult to edi
32. Loop Iteration Iteration Ends Ends lt _ lt gt e SS 2ms Internal Computer Timer 0 LabVIEW Introduction Course Manual 3 10 ni com yi Lesson3 Repetition and Loops The Wait ms function shown at left adds the wait time to the code execution time as shown in the following illustration This can cause a problem 1f code execution time is variable Pre loop Code VI Begins Pre loop Code 1st Loop Iteration Begins 1st Loop Iteration Ends Internal Computer Timer Loop Code 2nd Loop Iteration Begins Note The Time Delay Express VI located on the Functions Execution Control palette behaves similar to the Wait ms function with the addition of built in error clusters Refer to Lesson 5 Clusters of this manual for more information about error clusters Numeric Conversion LabVIEW can represent numeric data types as signed or unsigned integers 8 bit 16 bit or 32 bit floating point numeric values single double or extended precision or complex numeric values single double or extended precision When you wire two or more numeric inputs of different representations to a function the function usually returns output in the larger or wider format The functions coerce the smaller representations to the widest representation before execution and LabVIEW places a coercion dot on the terminal where the conversion takes place National Instruments Corporation 3 11 LabVIEW Intr
33. Next ms Multiple function located on the Functions All Functions Time amp Dialog palette on the block diagram Right click the input select Create Constant and type 500 in the constant to cause the For Loop to execute every 500 ms Place the Multiply function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram This function multiplies each element of the output array by 0 50 to scale the x values to represent the time interval at which the VI takes the measurements Place the Pop up Graph VI located in the C Exercises LabVIEW Basics I directory on the block diagram This VI plots the temperature data on an XY graph Complete the block diagram as shown in the previous figure 3 Save the VI as Use Pop up Graph vi in the C Exercises LabVIEW Basics I directory 4 Configure the subVI to display its front panel when called a b C d e National Instruments Corporation Double click the Pop up Graph subVI to open its front panel Select File VI Properties Select Window Appearance from the Category pull down menu Click the Customize button Configure the window appearance as shown in the following dialog box Customize Window Appearance Window has title bar Window Behavior Show menu bar 2 sae Floating Show scroll bars Hide when LabVIEW is not active Show toolbar when running Modal Show Abort button Allow user to close window
34. Part A Examining the 1 PCI 60274E Dev File Edit View Tools DAQ Device Settings Launch MAX by double clicking the icon on the desktop or by selecting Tools Measurement amp Automation Explorer in LabVIEW The utility searches the computer for installed National Instruments hardware and displays the information Expand the Devices and Interfaces section to view the installed National Instruments devices The following example shows the PCI 6024E and a PCI GPIB device Measurement t Automation Explorer Help Configuration Ee Properties JA Self Test MA Test Panels 1 E Show Help F3 My System Data Neighborhood Name Value Serial Number OxB1474F J Devices and Interfaces PY socket hi mbher a ga Traditional NI DAQ Devices FY Gus Number Ose E PCI 6024E Device 1 Pa Memory Range 1 OxFAFFFOOO 0xFAFFFFFF PXI PSI System 0 Unidentified Pa Memory Range 2 OxFAFFEOOO OxFAFFEFFF NI DAQmx Devices PAIRS Level 0x9 2 EPCI 6024E Devi GPIBO PCI GPIB y Ports Serial amp Parallel i IVT Instruments 4 Scales E Historical Data Software VI Logger Tasks F3 Remote Systems National Instruments Corporation MAX displays the National Instruments hardware and software in the computer The device number appears in quotes following the device name The Data Acquisition VIs use this device number to determine which device performs DAQ operations MAX also d
35. Query input and select Create Constant from the shortcut menu Use the Operating tool to change the constant to a FALSE value Wire the Boolean constant to the Reset input Place the NI DEVSIM Multimeter Configuration VI located on the Functions Input Instrument Drivers NI Device Simulator Configuration palette on the block diagram This VI configures the range of voltage measurements that the NI Instrument Simulator generates The default is 0 0 to 10 0 V DC Place the NI DEVSIM Measure DC Voltage VI located on the Functions Input Instrument Drivers NI Device Simulator Data palette on the block diagram This VI returns a simulated voltage measurement from the NI Instrument Simulator Place the NI DEVSIM Close VI located on the Functions Input Instrument Drivers NI Device Simulator palette on the block diagram This VI ends communication between LabVIEW and the NI Instrument Simulator 10 23 LabVIEW Introduction Course Manual Lesson 10 ii LabVIEW Introduction Course Manual Instrument Control Place the Max amp Min function located on the Functions All Functions Comparison palette on the block diagram Use two of these functions to check the current voltage against the minimum and maximum values stored in the shift registers Place the Simple Error Handler VI located on the Functions All Functions Time amp Dialog palette on the block diagram This VI displays a dialog box if an error occurs
36. The DB 25 connector is the standard RS 232 connector with enough pins to cover all the signals specified in the standard The following table shows only the core set of pins that are used for most RS 232 interfaces LabVIEW Introduction Course Manual 10 28 ni com Lesson 10 Instrument Control Output Input Output Output Output Output Input wele ee Software Overview Use the VIs and functions located on the Functions All Functions Instrument I O Serial palette for serial port communication You used some of the VISA functions on this palette for GPIB communication The VISA Write and VISA Read functions work with any type of instrument communication and are the same whether you are doing GPIB or serial communication However because serial communication requires you to configure extra parameters you must start the serial port communication with the VISA Configure Serial Port VI The VISA Configure Serial Port VI initializes the port identified by VISA resource name to the specified settings timeout sets the timeout value for the serial communication baud rate data bits parity and flow control specify those specific serial port parameters The error in and error out clusters maintain the error conditions for this VI The following example shows how to send the identification query command IDN to the instrument connected to the COM2 serial port The VISA Configure Serial Port VI opens communication with COM2 and
37. While Loop and stops when you click a stop button on the front panel Save the VI as General While Loop vi inthe C Exercises LabVIEW Basics I directory Modify the General While Loop VI to stop when the stop button is clicked or when the While Loop reaches a number of iterations specified by a front panel control Select File Save As to save the VI as Combo While For Loop vi in the C Exercises LabVIEW Basics I directory End of Exercise 3 2 3 14 ni com Lesson3 Repetition and Loops C Accessing Previous Loop Data When programming with loops you often need to access data from previous iterations of the loop For example you may have a VI that reads the temperature and displays it on a graph If you want to display a running average of the temperature as well you need to use data generated in previous iterations Two ways of accessing this data include the shift register and the Feedback Node Shift Registers Use shift registers on For Loops and While Loops to transfer values from one loop iteration to the next Shift registers are similar to static variables in text based programming languages fa A shift register appears as a pair of terminals shown at left directly opposite each other on the vertical sides of the loop border The right terminal contains an up arrow and stores data on the completion of an iteration LabVIEW transfers the data connected to the right side of the register to the next iteration Create a
38. You also can select Browse This VI s SubVIs To display the block diagram of a subVI from the calling VI press the lt Ctrl gt key and use the Operating or Positioning tool to double click the subVI on the block diagram Any changes you make to a subVI affect only the current instance of the subVI until you save the subVI When you save the subVI the changes affect all calls to the subVI not just the current instance Setting Required Recommended and Optional Inputs and Outputs In the Context Help window which you can access by selecting Help Show Context Help required terminals appear bold recommended terminals appear as plain text and optional terminals appear dimmed The labels of optional terminals do not appear if you click the Hide Optional Terminals and Full Path button in the Context Help window You can designate which inputs and outputs are required recommended and optional to prevent users from forgetting to wire subVI terminals Right click a terminal in the connector pane and select This Connection Is from the shortcut menu A checkmark indicates the terminal setting Select Required Recommended or Optional For terminal inputs required means that the block diagram on which you placed the subVI will be broken if you do not wire the required inputs Required is not available for terminal outputs For terminal inputs and outputs recommended or optional means that the block diagram on which you placed the subVI
39. a VI 4 Return to the front panel run the VI and turn the knob control Notice that the graph plots the sawtooth wave and the scaled signal Also notice that the maximum value on the y axis automatically changes to be 10 times the knob value This scaling occurs because you set the slope to 10 in the Scaling and Mapping Express VI 5 Click the STOP button Customizing the Knob The knob control changes the amplitude of the sawtooth wave so labeling it Amplitude accurately describes the function of the knob Complete the following steps to customize the appearance of a control on the front panel 1 Right click the knob and select Properties from the shortcut menu to display the Knob Properties dialog box 2 Inthe Label section on the Appearance tab delete the label Knob and type Amplitude in the text box The Knob Properties dialog box should appear similar to the following figure National Instruments Corporation 1 35 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW E Knob Properties Amplitude Amplitude pedei 3 Click the Scale tab and in the Scale Range section change the maximum value to 5 0 Notice how the knob on the front panel instantly updates to reflect these changes 4 Click the OK button to apply the current configuration and close the Knob Properties dialog box 5 Save this VI Tip As you build VIs you can experiment with different properties and configuration
40. a VI that converts a numeric value to a string concatenates the string to other strings to form a single output string and determines the output string length The VI also matches a pattern in a string and converts the remaining string to a numeric value Front Panel 1 Open a blank VI and build the following front panel Do not add labels for the comments they are shown for informational purposes only Header Combined String 7 i i i i i i 7 i Dhaene The measurement is The measurement is 6 0000 volts etring control string indicator Normal Display Normal Display String Length digital control a Trailer numeric indicator ee ee er Representation 32 etring control Normal Display string 2 Mumber Cut Offset Past Match Walts sDC s s 1 26E 1 rin 12 60 E etring control Qumeric indicator numeric indicator codes Display Representation 32 Use the following hints to build the front panel e Right click String 2 and select P Codes Display from the shortcut menu e Change String Length and Offset Past Match to 32 bit signed integer 132 representation e After entering text in the controls select Edit gt Make Current Values Default to set the text as the default values of these controls National Instruments Corporation 8 7 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O Block Diagram 2 Build the following block diagram
41. a cluster terminal on the block diagram and selecting Cluster Palette from the shortcut menu The Bundle and Unbundle functions automatically contain the correct number of terminals The Bundle by Name and Unbundle by Name functions appear with the first element in the cluster Use the Positioning tool to resize the Bundle by Name and Unbundle by Name functions to show the other elements of the cluster Assembling Clusters Use the Bundle function to assemble a cluster from individual elements or to change the values of individual elements in an existing cluster without having to specify new values for all elements Use the Positioning tool to resize the function or right click an element input and select Add Input from the shortcut menu If you wire a cluster to the cluster input the number of inputs must match the number of elements in the input cluster If you wire the cluster input you can wire only the elements you want to change For example the following cluster contains three controls input cluster output cluster VOLTS AC Function i Trigger New Command JOHMS National Instruments Corporation 5 5 LabVIEW Introduction Course Manual Lesson5 Clusters If you know the cluster order you can use the Bundle function to change the Command value by wiring the elements shown in the following figure Input Cluster Bundle Replacing or Accessing Cluster Elements Use the Bundle by Name function to replace or
42. also can copy the color of one object by using the Coloring tool and pressing the lt Ctrl gt key Select Edit Undo if you make a mistake To create more blank space on the block diagram press the lt Ctrl gt key while you use the Positioning tool to draw a rectangle on the block diagram Debugging LabVIEW Introduction Course Manual When single stepping use the following keyboard shortcuts lt Ctrl down arrow gt Steps into a node lt Ctrl right arrow gt Steps over a node lt Ctrl up arrow gt Steps out of a node 1 60 ni com Lesson1 Introduction to LabVIEW Notes National Instruments Corporation 1 61 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW Notes LabVIEW Introduction Course Manual 1 62 ni com Lesson 2 Modular Programming This lesson introduces modular programming in LabVIEW In LabVIEW when a VI is used within another VI itis called a subVI You will learn how to build the icon and connector pane of a VI so that it can be used as a subVI You Will Learn A About modular programming with subVIs B How to create an icon and connector pane C How to use a VI as a subVI D How to create subVIs from sections of another VI National Instruments Corporation 2 1 LabVIEW Introduction Course Manual Lesson2 Modular Programming A Modular Programming The power of LabVIEW lies in the hierarchical nature of the VI After you create a VI you can use i
43. and Functions Use the low level File I O VIs and functions located on the middle row of the Functions All Functions File I O palette and the Advanced File I O functions located on the Functions All Functions File I O Advanced File Functions palette to control each file I O operation individually Use the principal low level functions to create or open a file write data to or read data from the file and close the file The low level VIs and functions can handle most file I O needs Refer to the LabVIEW Basics IT Development Course Manual for more information about the Advanced File I O functions LabVIEW Introduction Course Manual 8 10 ni com Lesson 8 Strings and File I O File 1 0 Express Vis The Express VIs on the File I O palette include the Read LabVIEW Measurement File Express VI and the Write LabVIEW Measurement File Express VI The LabVIEW measurement data file 1vm is a tab delimited text file you can open with a spreadsheet application or a text editing application In addition to the data an Express VI generates the 1vm file includes information about the data such as the date and time the data was generated Refer to Lesson 9 Data Acquisition and Waveforms of this manual for more information on using the File I O Express VIs LabVIEW Data Directory Basics of File 1 0 Use the default LabVIEW Data directory to store the data files Lab VIEW generates such as lvmor txt files LabVIEW installs the LabVIEW
44. and Waveforms 2 Save the VI Display the front panel and run the VI Turn the Boolean LEDs on and off and observe the changes on the DAQ Signal Accessory 4 Stop and close the VI End of Exercise 9 7 National Instruments Corporation 9 33 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms Summary Tips and Tricks e MAX is the primary configuration and testing utility that is available for the DAQ device e The DAQ Assistant is used to configure the DAQ device and perform data acquisition e Most programs can use the DAQ Assistant For programs that require advanced timing and synchronization use the VIs that come with NI DAQmx e The DAQ Assistant can perform analog input analog output counter and digital I O and operations LabVIEW Introduction Course Manual 9 34 ni com Lesson9 Data Acquisition and Waveforms Additional Exercises 9 8 Builda VI that continuously measures temperature twice per second and displays the temperature on a waveform chart If the temperature goes over a preset limit the VI should turn on a front panel LED and LED 0 on the DAQ Signal Accessory The LEDs on the box are labeled The chart should plot both the temperature and limit Save the VI as Temp Monitor with LED vi in the C Exercises LabVIEW Basics I directory National Instruments Corporation 9 35 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms Notes LabVIEW Introd
45. and displays the error information Place the Unbundle by Name function located on the Functions All Functions Cluster palette on the block diagram This function accepts status from the error cluster Place the Or function located on the Functions Arithmetic amp Comparison Express Boolean palette on the block diagram This function controls when the While Loop ends If there is an error or you click the STOP button the While Loop stops Set the wait for the Time Delay Express VI to 1 second k Wire the block diagram as shown in the previous figure Note You do not need to wire every terminal for each node Wire only the necessary inputs for each node such as instrument descriptor VISA session and error I O 4 Save the VI as Voltage Monitor vi in the C Exercises LabVIEW Basics I directory Make sure the NI Instrument Simulator 1s powered on Display the front panel and run the VI The LEDs alternate between Listen and Talk as LabVIEW communicates with the GPIB instrument once a second to get a simulated voltage reading This voltage displays on the chart and the minimum and maximum values update accordingly 7 Stop and close the VI End of Exercise 10 4 10 24 ni com Lesson 10 Instrument Control G Serial Port Communication Serial communication is a popular means of transmitting data between a computer and a peripheral device such as a programmable instrument or even another computer Serial communi
46. and the time when the sample was taken c Set X Value Columns to One column per channel to provide a table of data that can be read by any spreadsheet editor or an ASCH text file editor d Set the Delimiter to Tab to make it easy for a spreadsheet editor to determine where a column of data starts in the file e Click the OK button to close the dialog box LabVIEW Introduction Course Manual 9 20 ni com s Lesson9 Data Acquisition and Waveforms Place the Merge Errors VI located on the Functions All Functions Time amp Dialog palette on the block diagram It is important to catch errors with both DAQ and file I O and because the code has a parallel structure it is necessary to merge the errors from all of the parallel operations to determine if the code 1s functioning properly Select File Save As to save the VI as Simple Data Logger vi in the C Exercises LabVIEW Basics I directory Run the VI A filename prompt appears Name the file logger 1vm in the C Exercises LabVIEW Basics I directory Stop and close the VI Simple Data Reader Front Panel 6 Block Diagram GG National Instruments Corporation Open a blank VI and build the following front panel by placing a waveform chart located on the Controls Graph Indicators palette on the front panel Waveform Chart ceram aehan 25 eh eal eras rean er Coy eae 26 5 26 25 0 000 at am J i p kan Build the following block di
47. array of the data type normally passed to a single plot graph Modify the block diagram as shown in the following figure waveform Array a Place the Sine function located on the Functions Arithmetic amp Comparison Express Numeric Express Trigonometric palette on the block diagram Use this function to build an array of points that represents one cycle of a sine wave b Place the Build Array function located on the Functions All Functions Array palette on the block diagram This function creates the data structure to plot two arrays on a waveform graph c Place the pi constant located on the Functions Arithmetic amp Comparison Express Numeric Express Numeric Constants palette on the block diagram d Wire the block diagram as shown National Instruments Corporation 6 19 LabVIEW Introduction Course Manual Lesson6 Plotting Data 14 Save the VI 15 Display the front panel and run the VI The two waveforms plot on the same waveform graph 16 Display the block diagram 17 Right click the wire to Waveform Array select Custom Probes Controls Graph Indicators from the shortcut menu and select a waveform graph to place a graph probe on the wire 18 Display the front panel and run the VI The probe shows only the data array The sine wave is not present because you did not place the probe on the wire to which the sine wave is bundled 19 Close the Probe window 20 Zoom in on a portion of th
48. can execute if you do not wire the recommended or optional terminals If you do not wire the terminals the VI does not generate any warnings LabVIEW Introduction Course Manual 2 14 ni com Lesson2 Modular Programming LabVIEW sets inputs and outputs of VIs you create to Recommended by default Set a terminal setting to required only if the VI must have the input or output to run properly Refer to the Read File function located on the Functions All Functions File I O palette for examples of required recommended and optional inputs and outputs National Instruments Corporation 2 15 LabVIEW Introduction Course Manual Lesson2 Modular Programming Exercise 2 2 Thermometer VI Objective To build a VI using the Convert C to F subVI to read a temperature from the DAQ Signal Accessory in Celsius or Fahrenheit Complete the following steps to create a VI that reads a measurement from the temperature sensor on the DAQ Signal Accessory and displays the temperature in Celsius or Fahrenheit The sensor returns a voltage proportional to temperature For example if the temperature is 23 C the sensor output voltage is 0 23 V The sensor is connected to Channel 0 of Device 1 Device 1 is the DAQ device On some systems the DAQ device may have another device number Front Panel l LabVIEW Introduction Course Manual In the LabVIEW dialog box click the arrow on the New button and select Blank VI from the shortcut menu or press the l
49. converts the string according to format string Use this function when you know the exact format of the input text This function can scan input string into various data types such as numeric or Boolean based on the format string Resize the function to increase the number of outputs For example use a format string of an initial search location of 8 and VOLTS DC 1 28E 2 as the input string to produce an output of 128 as shown in the following block diagram Change the precision of the output by changing the precision of the indicator output 1 126 YOLTS O 1 26E 2 In format string begins the format specifier and indicates a floating point numeric with fractional format Right click the function and select Edit Scan String from the shortcut menu to create or edit a format string The following Edit Scan String dialog box shows a configuration for the format string 4f Edit Scan String Current scan sequence Selected operation example Scan number 12 34 or 1 234614 wt Options Use Fixed Field width 40d New Operation Remove This Operation Corresponding scan string ott Refer to the LabVIEW Help for more information about format specifier syntax LabVIEW Introduction Course Manual 8 6 ni com Lesson 8 Strings and File 1 0 Exercise 8 1 Create String VI Objective To use the Build String Match Pattern Scan from String and String Length functions Complete the following steps to build
50. diagram Click the decrement or increment button to select the FALSE case ba b Place the Greater or Equal to 0 function located on the Functions Arithmetic amp Comparison Express Comparison palette on the block diagram This function returns TRUE if Numeric is greater than or equal to 0 c Right click the numeric constant and select Properties from the shortcut menu Select the Format and Precision tab Set Digits of precision to 1 select Floating point notation and click the OK button to ensure there is no data conversion between the constant and the numeric indicator outside the Case structure 39999 0 d Place the One Button Dialog function located on the Functions All Functions Time amp Dialog palette on the block diagram This function displays a dialog box that contains the message Error Negative Number LabVIEW Introduction Course Manual 8 ni com Lesson 7 Making Decisions ina VI a e Right click the message terminal of the One Button Dialog function select Create Constant from the shortcut menu type Error Negative Number 1n the constant and click the Enter button on the toolbar or click outside the control Refer to Lesson 8 Strings and File I O for more information about strings f Complete the diagram as shown in the previous figure 3 Select the TRUE case of the Case structure p gt Place the Square Root function located on the Functions Arithmetic amp Comparison Express Num
51. drivers help make test applications easier to maintain because the drivers contain all the I O for an instrument in one library separate from other code When you upgrade hardware it is easier to upgrade the application because all the code specific to that instrument is contained in the instrument driver The LabVIEW instrument driver library is located on the LabVIEW CD You also can download drivers from the National Instruments Web site at ni com idnet To install the LabVIEW instrument drivers decompress the instrument driver file to get a directory of instrument driver files Place this directory in the labview instr 1lib The next time you open LabVIEW you can access the instrument driver VIs on the Functions All Functions Instrument I O Instrument Drivers palette Getting Started Example All instrument drivers include an example that can be used to test communication with the instrument This example is usually called the Getting Started Example Specify the correct GPIB address or VISA Resource Name for the instrument as configured in MAX LabVIEW Introduction Course Manual 10 18 ni com Lesson 10 Instrument Control F Using Instrument Driver VIs Instrument drivers are developed with a specific instrument in mind and eliminate the need for the user to know the exact IEEE 488 2 commands that the instrument is expecting Components of an Instrument Driver All instrument drivers in the library have the same basic VI hi
52. for the physical channel Click the Finish button The Analog Input Voltage Task dialog box appears Configure the Task Timing to Acquire 1 Sample Click the OK button to close the Analog Input Voltage Task Configuration dialog box This saves the settings specified for the task in the DAQ Assistant Express VI Place the Wait Until Next ms Multiple function located on the Functions All Functions Time amp Dialog palette on the block diagram Right click the input and select Create Constant from the shortcut menu Type 100 in the constant to cause the loop to execute every 100 ms Place the Unbundle by Name function located on the Functions All Functions Cluster palette on the block diagram Use this function to access the status from the error cluster Place the Or function located on the Functions Arithmetic amp Comparison Express Boolean palette on the block diagram This function stops the loop if an error occurs or the user clicks the power switch on the front panel 3 Save the VI as Voltmeter vi in the C Exercises LabVIEW Basics I directory You will use this VI later in the course 4 Display the front panel and run the VI The meter displays the voltage the temperature sensor outputs Place your finger on the temperature sensor and notice that the voltage increases 5 Stop the VI by clicking the power switch Lesson9 Data Acquisition and Waveforms l b A Los m status t Scales
53. frequency mi NI DAQ DAO Assistant al a Measurement Types Select the measurement type for your task Analog Input Voltage Temperature Strain Current Resistance Back ext gt Fish Cancel ly ihe Each measurement type has its own characteristics such as resistor values for current measurements or strain gauge parameters for strain measurements When performing analog input the task can be timed to Acquire 1 Sample Acquire n Samples or Acquire Continuously Acquire 1 Sample Acquiring a single sample is an on demand operation In other words NI DAQmx acquires one value from an input channel and immediately returns the value This operation does not require any buffering or hardware timing For example if you periodically monitor the fluid level in a tank you would acquire single data points You can connect the transducer that produces a voltage representing the fluid level to a single channel on the measurement device and initiate a single channel single point acquisition when you want to know the fluid level National Instruments Corporation 9 13 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms Task Triggering Acquire n Samples One way to acquire multiple samples for one or more channels is to acquire single samples in a repetitive manner However acquiring a single data sample on one or more channels over and over is inefficient and time consuming Moreov
54. front panel and drag controls or indicators into the cluster shell Use the Cluster functions located on the Functions All Functions Cluster palette to create and manipulate clusters Error checking tells you why and where errors occur The error cluster reports the status code and source of the error Use the error cluster controls and indicators to create error inputs and outputs in subVIs 5 15 LabVIEW Introduction Course Manual Lesson5 Clusters Notes LabVIEW Introduction Course Manual 5 16 ni com Lesson 6 Plotting Data This lesson describes how to display data on waveform charts waveform graphs XY graphs and intensity plots You Will Learn A How to use waveform charts to display data B How to use waveform and XY graphs to display data C About intensity plots Optional National Instruments Corporation 6 1 LabVIEW Introduction Course Manual Lesson6 Plotting Data A Waveform Charts The waveform chart is a numeric indicator that displays one or more plots The waveform chart is located on the Controls Graph Indicators palette Waveform charts can display single or multiple plots The following illustration shows the elements of a multiplot waveform chart Two plots are displayed Raw Data and Running Avg Raw Data Waveform Chart Running wg os g TE I a9 40 50 Time Mie 1 Label 3 X scale 5 Graph Palette 2 Y scale 4 Scale Legend 6 Plot Legend Charts use three d
55. generate the data e Use the Bundle function located on the Functions All Functions Cluster palette to group the random data with the averaged data before plotting Save the VI as Random Average vi in the C Exercises LabVIEW Basics I directory 6 8 Build a VI that continuously measures the temperature once per second and displays the temperature on a scope chart If the temperature goes above or below limits specified with front panel controls the VI turns on a front panel LED The chart plots the temperature and the upper and lower temperature limits You should be able to set the limit from the following front panel Save the VI as Temperature Limit vi in the C Exercises LabVIEW Basics I directory 6 9 Modify the VI you created in Exercise 6 8 to display the maximum and minimum values of the temperature trace W Tip Use shift registers and two Max amp Min functions located on the Functions All Functions Comparison palette Select File Save As to save the VI as Temp Limit max min vi in the C Exercises LabVIEW Basics I directory National Instruments Corporation 6 31 LabVIEW Introduction Course Manual Lesson6 Plotting Data Notes LabVIEW Introduction Course Manual 6 32 ni com Lesson Making Decisions ina VI This lesson introduces methods for making decisions in a VI These methods include the Select function the Case Structure and the Formula Node The formula capabilities of the Formula Nod
56. how to store the file The Read LabVIEW Measurement File Express VI located on the Functions Input palette reads signals in a LabVIEW measurement file This Express VI reads data one point at a time so it is necessary to place this Express VI in a loop National Instruments Corporation 9 19 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms Exercise 9 4 Simple Data Logger VI Objective To learn to use a LabVIEW Measurement File Complete the following steps to modify the Measurement Averaging VI that you created in Exercise 9 3 to log the acquired data to a LabVIEW Measurement File Create another VI that reads the data file Simple Data Logger Block Diagram 1 Open the Measurement Averaging VI located in the C Exercises LabVIEW Basics I directory 2 Modify the block diagram to log the acquired data as shown in the following figure Write Lab IEW Unbundle By Mame Measurement File bo status Power IEF Place the Write LabVIEW Measurement File Express VI located on the Functions Output palette on the block diagram This Express VI stores the data acquired from the DAQ device In the Configure Write LabVIEW Measurement File dialog box that appears set the following options a Set the Action to Ask user to choose file for the filename b Set the Segment Headers to One header only to provide a header for all of the data The header contains information about the sampling rate
57. later exercise to control the amplitude of a signal 5 Select File Save As and save this VI as Acquiring a Signal viin the C Exercises LabVIEW Basics I directory Kp Note Save all the VIs you edit or create in this course in the C Exercises LabVIEW Basics I directory National Instruments Corporation 1 29 LabVIEW Introduction Course Manual Lesson1 Introduction to LabVIEW Changing the Signal Type The block diagram has a blue icon labeled Simulate Signal This icon represents the Simulate Signal Express VI The Simulate Signal Express VI simulates a sine wave by default Complete the following steps to change this signal to a sawtooth wave Simulate Signal Sine LabVIEW Introduction Course Manual k P Signal type Display the block diagram by selecting Window Show Block Diagram or by clicking the block diagram Notice the Simulate Signal Express VI shown at left An Express VI is a component of the block diagram that you can configure to perform common measurement tasks The Simulate Signal Express VI simulates a signal based on the configuration that you specify Right click the Simulate Signal Express VI and select Properties from the shortcut menu to display the Configure Simulate Signal dialog box Select Sawtooth from the Signal type pull down menu Notice that the waveform on the graph in the Result Preview section changes to a sawtooth wave The Configure Simulate Signal dialog box should appear s
58. loops using auto indexing C How to use the Array functions D About polymorphism National Instruments Corporation 4 1 LabVIEW Introduction Course Manual Lesson4 Arrays A Arrays Arrays group data elements of the same type An array consists of elements and dimensions Elements are the data that make up the array A dimension is the length height or depth of an array An array can have one or more dimensions and as many as 23 1 elements per dimension memory permitting You can build arrays of numeric Boolean path string waveform and cluster data types Consider using arrays when you work with a collection of similar data and when you perform repetitive computations Arrays are ideal for storing data you collect from waveforms or data generated in loops where each iteration of a loop produces one element of the array You cannot create an array of arrays However you can create an array of clusters where each cluster contains one or more arrays Refer to Lesson 5 Clusters for more information about clusters Array elements are ordered An array uses an index so you can readily access any particular element The index is zero based which means it is in the range 0 to n 1 where n is the number of elements in the array For example if you create an array of the planets in the solar system n 9 for the nine planets so the index ranges from 0 to 8 Earth is the third planet so it has an index of 2 Creating
59. nob Sawtooth a error out k 1 lalate Ih z val met National Instruments Corporation 5 When the Wiring tool appears click the arrow and then click the Amplitude input of the Simulate Signal Express VI shown at left to wire the two objects together Notice that a wire appears and connects the two objects Data flows along this wire from the terminal to the Express VI Select File Save to save this VI 1 31 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW Running the VI Running a VI executes your solution Complete the following steps to run the Acquiring a Signal VI 1 Display the front panel by selecting Window Show Front Panel or by clicking the front panel mK Tip Press the lt Ctrl E gt keys to switch from the front panel to the block diagram or from the block diagram to the front panel 2 Click the Run button 3 Move the cursor over the knob control Notice how the cursor becomes a hand or the Operating tool shown at left Use the Operating tool to change the value of a control or select the text within a control 4 Using the Operating tool turn the knob to adjust the amplitude of the sawtooth wave Notice how the amplitude of the sawtooth wave changes as you turn the knob Also notice that the y axis on the graph autoscales to account for the change in amplitude To indicate that the VI is running the Run button changes to a darkened arrow shown at left Y
60. of the bottom indicator Shift Register and the top indicator Feedback Node 3 19 LabVIEW Introduction Course Manual Lesson3 Repetition and Loops 6 Run the VI Notice that both the Feedback Node and the shift register portions of the block diagram have the same functionality 7 If time permits complete the following optional steps otherwise close the VI and do not save changes Optional 8 Revise the shift register to display the last three iterations of the For Loop data as shown in the following block diagram Feedback Node a Resize the left shift register to three elements Right click the shift register and select Add Element from the shortcut menu to add each shift register b Initialize each elements of the shift register to 1 c Right click each element of the shift register and select Create Indicator Label each indicator 9 Run the VI 10 Close the VI Do not save changes End of Exercise 3 3 LabVIEW Introduction Course Manual 3 20 ni com Lesson3 Repetition and Loops Summary Tips and Tricks National Instruments Corporation Use structures on the block diagram to repeat blocks of code and to execute code conditionally or in a specific order The While Loop executes the subdiagram until the conditional terminal receives a specific Boolean value By default the While Loop executes its subdiagram until the conditional terminal receives a TRUE value The For Loop executes a subdiag
61. oscilloscope returns as an ASCII or binary string For the ASCII waveform string the waveform consists of 128 points Up to four ASCII characters separated by commas represent each point The following header precedes the data points CURVE 12 28 63 128 points in total CR LF For the binary waveform string the waveform consists of 128 points Each point is represented as a 1 byte unsigned integer The following header precedes the data points CURVE Bin Count MSB Bin Count LSB n 128 bytes in total Checksum CR LF Complete the following steps to examine a VI that converts the waveform to an array of numbers The VI graphs the array and reads the waveform string from the NI Instrument Simulator or from a previously stored array NI Instrument Simulator 1 Power off the NI Instrument Simulator and configure it to communicate through the GPIB by setting the following switches on the side of the box MODE These switch settings configure the instrument as a GPIB device with an address of 2 2 Power on the NI Instrument Simulator Only the Power and Ready LEDs are lit to indicate that the NI Instrument Simulator is in GPIB communication mode Front Panel 3 Open the Waveform Example VI located in the C Exercises LabVIEW Basics I directory The following front panel is already built National Instruments Corporation 10 37 LabVIEW Introduction Course Manual Lesson 10 Instrument Contr
62. shift register by right clicking the left or right border of a loop and selecting Add Shift Register from the shortcut menu A shift register transfers any data type and automatically changes to the data type of the first object wired to the shift register The data you wire to the terminals of each shift register must be the same type To initialize a shift register wire any value from outside the loop to the left terminal If you do not initialize the shift register the loop uses the value written to the shift register when the loop last executed or the default value for the data type if the loop has never executed Use a loop with an uninitialized shift register to run a VI repeatedly so that each time the VI runs the initial output of the shift register is the last value from the previous execution Use an uninitialized shift register to preserve state information between subsequent executions of a VI After the loop executes the last value stored in the shift register remains at the right terminal If you wire the right terminal outside the loop the wire transfers the last value stored in the shift register You can add more than one shift register to a loop If you have multiple operations within a loop use multiple shift registers to store the data values from those different processes in the structure The following illustration uses two initialized shift registers National Instruments Corporation 3 15 LabVIEW Introduction Cour
63. shows a front panel and its corresponding block diagram with front panel and block diagram components LabVIEW Introduction Course Manual 1 8 ni com Lesson1 Introduction to LabVIEW Fe U sing Temperature i Front Panel Of x TEMF MoH a ST ile Edit Operate Tools Browse Window Help a n Delay sec Jo p f d 8 0 Eo 0 0 10 0 10 Temperature Graph Temp Plot a Number of Measurements Fahrenheit gt Using Temperature vi Block Diagram 1 Toolbar 7 Numeric Constant 13 Wire Data Path 2 Owned Label 8 Multiply Function 14 XY Graph Terminal 3 Numeric Control 9 Icon 15 Bundle Function 4 Free Label 10 Knob Control 16 SubVI 5 Numeric Control Terminal 11 Plot Legend 17 For Loop Structure 6 Knob Terminal 12 XY Graph National Instruments Corporation 1 9 LabVIEW Introduction Course Manual Lesson1 Introduction to LabVIEW Front Panel Toolbar Use the toolbar buttons to run and edit a VI The following toolbar appears on the front panel ol is Click the Run button to run a VI LabVIEW compiles the VI if necessary You can run a VI if the Run button appears as a solid white arrow shown at left The solid white arrow also indicates you can use the VI as a subVI if you create a connector pane for the VI While the VI runs the Run button appears as shown at left if the VI is a top level VI meaning it has no callers and therefore is not a subVI
64. temperature sensor on the DAQ Signal Accessory d Click the OK button 4 Document the thermometer indicator and switch control so descriptions appear in the Context Help window when you move the cursor over the objects and tip strips appear on the front panel or block diagram when you move the cursor over the objects while the VI runs a Right click the thermometer indicator and select Description and Tip from the shortcut menu b Type the following description for the thermometer in the Description text box Displays the temperature measurement c Type temperature in the Tip text box d Click the OK button e Right click the switch control and select Description and Tip from the shortcut menu f Type the following description for the vertical switch control in the Description text box Determines the scale Fahrenheit or Celsius to use for the temperature measurement g Type scale C or F in the Tip text box h Click the OK button Select Help Show Context Help to display the Context Help window 6 Move the cursor over the front panel objects and the VI icon to display the descriptions in the Context Help window National Instruments Corporation 2 17 LabVIEW Introduction Course Manual Lesson2 Modular Programming Block Diagram 7 Select Window Show Block Diagram to display the block diagram 8 Temperature DAQ Assistant data r Place the DAQ Assistant Express VI located on the Functions
65. the object and select the Visible Items Scrollbar option from the shortcut menu Right click a string control or indicator on the front panel to select from the display types shown in the following table The table also shows an example message for each display type Normal Displays printable characters using There are four display types Display the font of the control Non printable characters generally appear as boxes Y Codes Displays backslash codes for all There sare sfour sdisplay sty Display non displayable characters pes n sis sa sbackslash is a backslash Password Displays an asterisk for each BCA a eee re een eae Display character including spaces syd Hidden tiene Hex Display Displays the ASCII value of each 5468 6572 6520 6172 6520 666F character in hex instead of the 75122064 16973 7060 6179 2074 character itself 7970 6573 2E0A 5C20 6973 2061 2062 6163 6B73 6C61 7368 2E LabVIEW Introduction Course Manual 8 2 ni com Lesson 8 Strings and File I O Tables Use the table control located on the Controls All Controls List amp Table palette or the Express Table VI located on the Controls Text Indicators palette to create a table on the front panel Each cell in a table is a string and each cell resides in a column and a row Therefore a table is a display for a 2D array of strings The following illustration shows a table and all its parts 0 0000 0 8788 0 1 Cell indicated by Index V
66. to the following figure Tip You can right click any wire and select Clean Up Wire from the shortcut menu to automatically route an existing wire I gt Reduce Samples vi Block Diagram ojs File Edit Operate Tools Browse Window Help imal ND belt 5 sence a ell g Sample Simulate Signal Compression Signals Enable Mean 7 Display the front panel Notice that the controls and indicators you added automatically appear on the front panel with labels that correspond to their function 8 Save this VI Configuring the VI to Run Continuously Until the User Stops It In the current state the VI runs once generates one signal then stops executing To run the VI until a condition is met you can add a While Loop to the block diagram Complete the following steps to add a While Loop 1 Display the front panel and run the VI Notice how the VI runs once and then stops Also notice how there is no STOP button 2 Display the block diagram and select the While Loop on the Functions Execution Control palette 3 Move the cursor to the upper left corner of the block diagram Place the top left corner of the While Loop here LabVIEW Introduction Course Manual 1 48 ni com Lesson1 Introduction to LabVIEW 4 Click and drag the cursor diagonally to enclose all the Express VIs and wires as shown the following figure gt Reduce Samples vi Block Diagram Ox File Edit Operate Tools Browse Window Help
67. to open the Debug Exercise Main VI The following front panel appears Random umber Multiply Result Final Result Notice the Run button on the toolbar appears broken shown at left indicating that the VI 1s broken and cannot run Block Diagram 2 Select Window Show Block Diagram to display the following block diagram Random Number Multiply Result Final Result The Random Number 0 1 function located on the Functions Arithmetic amp Comparison Express Numeric palette produces a random number between 0 and 1 The Multiply function located on the Functions Arithmetic amp Comparison Express Numeric palette multiplies the random number by 10 0 W The numeric constant located on the Functions Arithmetic amp Comparison Express Numeric palette is the number to multiply by the random number The Debug Exercise Sub VI located in the C Exercises LabVIEW Basics I directory adds 100 0 and calculates the square root of the value LabVIEW Introduction Course Manual 1 54 ni com Lesson1 Introduction to LabVIEW 3 Find and fix each error a e Click the broken Run button to display the Error list window which lists all the errors Select an error description in the Error list window The Details section describes the error and in some cases recommends how to correct the error Click the Help button to display a topic in the LabVIEW Help that describes the error in detail and incl
68. values is used in a variety of applications including controlling relays and monitoring alarm states Generally measuring and generating digital values is used in laboratory testing production testing and industrial process monitoring and control Digital I O can read from or write to a line or an entire digital port which is a collection of lines You can use the digital lines in a DAQ device to acquire a digital value This acquisition is based on software timing On some devices you can configure the lines individually to either measure or generate digital samples Each line corresponds to a channel in the task You can use the digital port s in a DAQ device to acquire a digital value from a collection of digital lines This acquisition is based on software timing You can configure the ports individually to either measure or generate digital samples Each port corresponds to a channel in the task National Instruments Corporation 9 31 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms Exercise 9 7 Digital Example VI Objective To control the digital 1 0 lines on the DAQ device Complete the following steps to complete a VI that turns on the LEDs of Port 0 on the DAQ Signal Accessory based on the digital value set on the front panel Each LED 1s wired to a digital line on the DAQ device The lines are numbered 0 1 2 and 3 starting with the LED on the right Kp Note The LEDs use negative logic Th
69. vi in the C Exercises LabVIEW Basics I directory Modify the Temperature Logger VI which you built in Exercise 8 5 so the VI does not create a new file each time you run the VI Append the data to the end of the existing temp dat file that the Temperature Logger VI created Run the VI several times and use a word processor application to confirm that the VI appended new temperature readings W Tip Delete the Format Into File function and replace it with the Format Into String and Write File functions Use the pos mode and pos offset parameters of the Write File function to move the current file mark National Instruments Corporation Select File Save As to save the VI as Temperature Logger 2 vi in the C Exercises LabVIEW Basics I directory 8 33 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O Notes LabVIEW Introduction Course Manual 8 34 ni com Lesson 9 Data Acquisition and Waveforms This lesson describes how to use plug in data acquisition DAQ devices in LabVIEW Refer to the LabVIEW Measurements Manual for more information about data acquisition in LabVIEW You Will Learn About plug in DAQ devices About data acquisition in LabVIEW How to perform analog input How to store acquired data and average and log the acquired data to disk How to perform analog output About counters About digital I O a ES Aa p National Instruments Corporation 9 1 LabVIEW Introduction Course M
70. waveform and the third column contains data for a cosine waveform The VI plots each column in a graph and displays the data in a table 3 When the Choose file to write dialog box appears save the file as wave txt in the C Exercises LabVIEW Basics I directory and click the OK button Later you will examine this file National Instruments Corporation 8 13 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O Block Diagram 4 Display and examine the block diagram for this VI Sine Pattern i Ee Build Array O ae E O waveform Graph Transpose 2D Array Write To Spreadsheet File vi The Sine Pattern VI located on the Functions All Functions Analyze Signal Processing Signal Generation palette returns a numeric array of 128 elements containing a sine pattern The constant 90 0 in the second instance of the Sine Pattern VI specifies the phase of the sine pattern or cosine pattern The Uniform White Noise VI located on the Functions All Functions Analyze Signal Processing Signal Generation palette returns a numeric array of 128 elements containing a noise pattern E The Build Array function located on the Functions All Functions Array palette builds the following 2D array from the sine array noise array and cosine array Sine Array Noise Array Cosine Array The Transpose 2D Array function located on the Functions All Functions Array palette rearranges the elements o
71. 0 72 0 80 100 120 140 160 180 200 Time sec Il LE E ee E Y l I 49 10 11 12 13 14 15 2 Save the VI as Temperature Application vi 1n the C Exercises LabVIEW Basics I directory End of Exercise 8 6 National Instruments Corporation 8 31 LabVIEW Introduction Course Manual Lesson 8 Strings and File 1 0 Summary Tips and Tricks LabVIEW Introduction Course Manual Strings group sequences of ASCII characters Use the string control and indicator to simulate text entry boxes and labels To minimize the space that a string object occupies right click the object and select Show Scrollbar from the shortcut menu Use the String functions located on the Functions All Functions String palette to edit and manipulate strings on the block diagram Use the Build Text Express VI to convert a numeric value to a string Use the Scan From String function to convert a string to a numeric value Right click the Scan From String function and select Edit Scan String from the shortcut menu to create or edit a format string Use the File I O VIs and functions to handle all aspects of file I O Use the high level File I O VIs to perform common I O operations Use the low level File I O VI and functions and the Advanced File I O functions located to control each file I O operation individually Use the Express File I O VIs for simple datalogging operations When writing to a file you open create or repla
72. 12 Right click the waveform chart and select Data Operations Clear Chart from the shortcut menu to clear the display buffer and reset the waveform chart W Tip When a VI is running you can select Clear Chart from the shortcut menu 13 Each time you run the VI you first must turn on the vertical toggle switch and then click the Run button due to the current mechanical action of the switch Modify the mechanical action of the vertical toggle switch so temperature is plotted on the graph each time you run the VI without having to first set the toggle switch a Stop the VI if it is running b Use the Operating tool to click the vertical toggle switch and turn it to the ON position c Right click the switch and select Data Operations Make Current Value Default from the shortcut menu This sets the ON position as the default value d Right click the switch and select Mechanical Action Latch When pot Pressed from the shortcut menu This setting changes the control value when you click it and retains the new value until the VI reads it once At this point the control reverts to its default value even if you keep pressing the mouse button This action is similar to a circuit breaker and is useful for stopping While Loops or for getting the VI to perform an action only once each time you set the control at Run the VI 14 Run the VI 15 Use the Operating tool to click the vertical switch to stop the acquisition The switch c
73. 23 0 424 0 425 0 426 j 427 0 425 0 429 0 430 j Time sec a Place a horizontal smooth box located on the Controls All Controls Decorations palette on the front panel This decoration visibly groups the Analysis items b Create a duplicate of the Power Boolean switch Label the new switch ANALYSIS Right click the switch and select Mechanical Action Switch When Pressed from the shortcut menu c Place a numeric control located on the Controls Numeric Controls palette on the front panel Label the control High Limit d Place a round LED located on the Controls LEDs palette on the front panel Label the indicator warning e Place a numeric indicator from the Controls Numeric Indicators palette on the front panel Label the indicator High Value f Right click the chart display and select Visible Items Digital Display from the shortcut menu to display the digital values 3 Select File Save As to save the VI as Temperature Control vi in the C Exercises LabVIEW Basics I directory LabVIEW Introduction Course Manual 7 10 ni com Lesson 7 Making Decisions ina VI Block Diagram 4 Modify the block diagram as shown in the following illustration Enlarge the While Loop to create space for the new items Compound Arithmetic Divide Bundle Temperature History Warning High Value i l Wait Until Next CEF Tick Multiple a Place the Case structure located on the Functions Execution Contr
74. 6 ni com Lesson5 Clusters For example if you use the Unbundle function with the following cluster it has four output terminals that correspond to the four controls in the cluster You must know the cluster order so you can associate the correct Boolean terminal of the unbundled cluster with the corresponding switch in the cluster In this example the elements are ordered from top to bottom starting with element 0 If you use the Unbundle by Name function you can have an arbitrary number of output terminals and access individual elements by name in any order Applicant Cluster Unbundle Employed Ves J No o Company Name Unbundle By Name Company Name National Instruments Corporation 5 7 LabVIEW Introduction Course Manual Lesson5 Clusters Exercise 5 1 Cluster Exercise VI Objective To create clusters on the front panel and use the Cluster functions to assemble and disassemble clusters Front Panel 1 Open a blank VI and build the following front panel a Place a stop button located on the Controls Buttons amp Switches palette a numeric indicator located on the Controls Numeric Indicators palette and a round LED located on the Controls LEDs palette on the front panel b Place a cluster located on the Controls All Controls Array amp Cluster palette on the front panel c Place a numeric control located on the Controls Numeric Controls palette two vertical toggle switches l
75. 75 0 80 0 85 0 and so on Kp Note The waveform chart size has a direct effect on the display of axis scales Increase the waveform chart size if you encounter problems while customizing the axis National Instruments Corporation 6 11 LabVIEW Introduction Course Manual Lesson 6 Plotting Data 14 Right click the waveform chart and select Visible Items Scale Legend from the shortcut menu to display the scale legend as shown in the following illustration You can place the scale legend anywhere on the front panel 1 X axis 3 Scale Labels 5 Autoscale Button 2 Y axis 4 Scale Lock Button 6 Scale Format Button 15 Use the scale legend to customize each axis a Make sure the Lock Autoscale button appears locked and the Autoscale LED is green so the y axis adjusts the minimum and maximum values to fit the data in the chart b Click the Scale Format button to change the format precision mapping mode scale visibility and grid options for each axis 16 Use the plot legend to customize the plots a Use the Positioning tool to resize the plot legend to include two plots b Use the Labeling tool to change Temp to Running Avg and to change Plot 1 to Current Temp If the text does not fit use the Positioning tool to resize the plot legend c Right click the plot in the plot legend to set the line and point styles and the color of the plot background or traces 17 Right click the waveform chart and select Visible Item
76. 9 Data Acquisition and Waveforms Exercise 9 2 Voltmeter VI Objective To acquire an analog signal using a DAQ device Complete the following steps to build a VI that measures the voltage that the temperature sensor on the DAQ Signal Accessory outputs The temperature sensor outputs a voltage proportional to the temperature The sensor is hard wired to channel 0 of the DAQ device Front Panel 1 Open a blank VI and build the following front panel voltage a Place the Meter located on the Controls Numeric Indicators palette on the front panel Configure the meter scale for 0 0 to 0 4 Use the Labeling tool to double click 10 0 and type 0 4 You might need to enlarge the meter to display the scale as shown in the example b Place a Vertical Toggle Switch located on the Controls Buttons amp Switches palette on the front panel Configure the toggle switch to a default value of FALSE and a mechanical action of Latch When Pressed c Create two free labels Off and On using the Labeling tool Block Diagram 2 Build the following block diagram Unbundle By Name DAQ Assistant data t National Instruments Corporation 9 15 LabVIEW Introduction Course Manual Place the DAQ Assistant Express VI located on the Functions Input palette on the block diagram Configure this VI to read an analog input channel and return the voltage Select Analog Input Voltage for the measurement to make Select Dev1 ai0
77. 99 The Formula Node can perform many different operations Refer to the LabVIEW Help for more information about functions operations and syntax for the Formula Node Kp Note The Formula Express VI located on the Functions Arithmetic amp Comparison palette uses a calculator interface to create mathematical formulas You can use this Express VI to perform most math functions that a basic scientific calculator can compute Refer to the LabVIEW Help for more information about the Formula Express VI National Instruments Corporation 7 13 LabVIEW Introduction Course Manual Lesson Making Decisions ina VI Exercise 7 3 Formula Node Exercise VI Objective To use the Formula Node ina VI Complete the following steps to build a VI that uses the Formula Node to perform a complex mathematical operation and graphs the results Front Panel 1 Open a blank VI and build the following front panel Waveform Graph 10 0 a l 6 0 4 0 0 0 ele l l l l l l l l l l 0 20 40 60 100 120 140 160 180 200 Block Diagram 1 Build the following block diagram Formula Node a tanhixi costs Y atts a Waveform Graph a Place the Formula Node located on the Functions All Functions Structures palette on the block diagram b Create the x input terminal by right clicking the left border and selecting Add Input from the shortcut menu Type x into the box that appears c Create the y and a output terminals by
78. Array Controls and Indicators To create an array control or indicator as shown in the following example select an array on the Controls All Controls Array amp Cluster palette place it on the front panel and drag a control or indicator into the array shell If you attempt to drag an invalid control or indicator such as an XY graph into the array shell you are unable to drop the control or indicator in the array shell 1 Index Display 2 Element Display You must insert an object in the array shell before you use the array on the block diagram Otherwise the array terminal appears black with an empty bracket LabVIEW Introduction Course Manual 4 2 ni com Lesson4 Arrays Two Dimensional Arrays A 2D array stores elements in a grid It requires a column index and a row index both of which are zero based to locate an element The following illustration shows a 6 column by 4 row 2D array which contains 6 x 4 24 elements Column Index Row Index To add dimensions to an array one at a time right click the index display and select Add Dimension from the shortcut menu You also can use the Positioning tool to resize the index display until you have as many dimensions as you want Below is an example of an uninitialized 2D array control Creating Array Constants You can create an array constant on the block diagram by selecting an array constant from the Functions All Functions Array palette placing it on the
79. Character Code Equivalents Table The following table contains the hexadecimal octal and decimal code equivalents for ASCII character codes National Instruments Corporation A 3 LabVIEW Introduction Course Manual Appendix A LabVIEW Introduction Course Manual A 4 ni com Appendix A oct det ser ie ot ii sc 163 115 Z 6 126 cam National Instruments Corporation A 5 LabVIEW Introduction Course Manual Appendix A C Instructor Notes LabVIEW Introduction Course Manual Make sure each station has the following components e LabVIEW Basics I Introduction Course Manual e LabVIEW Professional Development System 7 0 or later e Multifunction DAQ device configured as Board ID 1 e DAQ Signal Accessory and cable to connect the DAQ device to the DAQ Signal Accessory e GPIB interface e NI Instrument Simulator power supply GPIB cable to connect the GPIB interface to the NI Instrument Simulator and serial cable to connect the computer to the NI Instrument Simulator e Wires two per station Copy the files from the CD accompanying this manual as described in the Installing the Course Software section of the Student Guide and the readme txt file on the disks Test the station by starting LabVIEW by selecting Start Programs Station Tests LV Station Test to run the LV Station Test VI Refer to the customer education resources coordinator for this VI Open MAX to verify that both the DAQ device an
80. EW Introduction Course Manual Lesson2 Modular Programming Block Diagram 5 Display the block diagram by clicking it or by selecting Window Show Block Diagram LabVIEW creates corresponding control and indicator terminal icons on the block diagram when you place controls and indicators on the front panel The terminals represent the data type of the control or indicator You should see two double precision floating point terminals on the block diagram one indicator and one control Kp Note Control terminals have a thicker border than indicator terminals 6 10 Place the Multiply function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram to the right of the deg C indicator If the Functions palette is not visible right click an open space on the block diagram workspace to display it Place the Add function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram to the right of the Multiply function Place a Numeric Constant located on the Functions Arithmetic amp Comparison Express Numeric palette to the lower left of the Multiply function Type 1 80 in the constant When you first place a numeric constant it is highlighted so you can type a value If the constant is no longer highlighted double click the constant to activate the Labeling tool Place a Numeric Constant located on the Functions Arithmetic amp Com
81. EW is similar to the architecture for DAQ The GPIB interface includes a set of drivers These drivers also are available on the LabVIEW CD and the majority of the drivers are available for download at ni com support gpib versions htm Always install the newest version of these drivers unless otherwise instructed in the release notes for either the GPIB interface or LabVIEW Windows Use MAX to configure and test the GPIB interface MAX interacts with the various diagnostic and configuration tools installed with the driver and also with the Windows Registry and Device Manager The driver level software is in the form of a DLL and contains all the functions that directly communicate with the GPIB interface The Instrument I O VIs and functions directly call the driver software Configuration Software Windows Kp Note Mac OS and UNIX Refer to the GPIB interface documentation for information about configuring and testing the interface MAX is the configuration utility for National Instruments software and hardware It can also execute system diagnostics add new channels interfaces and virtual channels and view devices and instruments connected to the system Open MAX by double clicking the icon on the desktop or by selecting Tools Measurement amp Automation Explorer in LabVIEW The Configuration pane of MAX includes the following sections under My System e Data Neighborhood Use this section to create and test virtual channel
82. End of Exercise 2 2 LabVIEW Introduction Course Manual 2 20 ni com Lesson2 Modular Programming D Creating a SubVI from Sections of a VI You can simplify the block diagram of a VI by converting sections of the block diagram into subVIs Convert a section of a VI into a subVI by using the Positioning tool to select the section of the block diagram you want to reuse and selecting Edit Create SubVI An icon for the new subVI replaces the selected section of the block diagram LabVIEW creates controls and indicators for the new subVI and wires the subVI to the existing wires The following example shows how to convert a selection into a subVI Subtract Divide Slope im Subtract The new subVI uses a default pattern for the connector pane and a default icon Double click the subVI to edit the connector pane and icon and to save the subVI Kp Note Do not select more than 28 objects to create a subVI because 28 is the maximum number of connections on a connector pane National Instruments Corporation 2 21 LabVIEW Introduction Course Manual Lesson2 Modular Programming Summary Tips and Tricks LabVIEW Introduction Course Manual A VI within another VI is called a subVI Using subVIs helps you manage changes and debug the block diagram quickly After you build a VI front panel and block diagram build the icon and the connector pane so you can use the VI as a subVI The connector pane is a set of terminals that corre
83. Functions palettes Feedback Before The 1 wired to the left terminals on the For Loop initializes the Feedback Node to 1 The Wait Until Next ms Timer slows the operation of the code You also could use Highlight Execution instead of the wait function to slow the operation LabVIEW Introduction Course Manual 3 18 ni com Run the VI National Instruments Corporation Lesson3 Repetition and Loops The same code is used twice in this block diagram with the Feedback Node in a different portion of the wire Run the VI The top section of the code reads the initialized Feedback Node and passes this value to the Multiply function The bottom section of the code reads the initialized Feedback Node and passes this value to the indicator This Multiply function does not execute until the next iteration of the loop Click the Highlight Execution button shown at left to enable execution highlighting Run the VI again to observe the order of execution Turn off execution highlighting when you understand the execution order The VI continues executing at normal speed Replace the bottom Feedback Node with a shift register as shown in the following block diagram Feedback Node a Select the bottom Feedback Node and press the lt Delete gt key to delete it b Right click the border of the For Loop and select Add Shift Register Initialize the shift register by wiring 1 to the left shift register d Change the label
84. I and add Express VIs and structures to the block diagram to build a new VI When you complete the exercise the front panel of the VI will appear similar to the following figure I gt Reduce Samples y i Front Panel 1260265 al Mean TN 1 7578 tN 1 517029 Enable i i ic l1 660773 l 376998 1 1 763462 010027 761261 0 396568 ot a 2 a BE 2 074 l l l i a O 0E 0 20E 406 2 6 0E 2 6 0E 2 Time Opening a Blank VI If no template is available for the task you want to create you can start with a blank VI and add Express VIs to accomplish the specific task Complete the following steps to open a blank VI 1 In the LabVIEW dialog box click the arrow on the New button and select Blank VI from the shortcut menu or press the lt Ctrl N gt keys to open a blank VI Notice that a blank front panel and block diagram appear 2 Ifthe Functions palette is not visible right click any blank space on the block diagram to display the Functions palette Click the thumbtack shown at left in the upper left corner of the Functions palette to place the palette on the screen Kp Note You can right click a blank space on the block diagram or the front panel to display the Functions or Controls palettes National Instruments Corporation 1 45 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW Adding an Express VI that Simulates a Signal Complete the following steps to find the Express VI yo
85. IX Sun workstation running Solaris 2 5 1 or later and X Window System server such as OpenWindows CDE or X11R6 or a PC running Linux kernel 2 0 x or later for Intel x86 processors Q Windows Multifunction DAQ device configured as device 1 using Measurement amp Automation Explorer MAX DAQ Signal Accessory wires and cable GPIB interface NI Instrument Simulator and power supply OD O oO DU LabVIEW Full or Professional Development System 7 0 or later Kp Note This course assumes you are using the default installation of LabVIEW If you have changed the palette views from the default settings some palette paths described in the course may not match your settings To reset palette views to LabVIEW defaults select Tools Options and select Controls Functions Palettes from the top pull down menu Set Palette View to Express and set Format to Standard Click the OK button to apply the changes and close the dialog box Q A serial cable Q A GPIB cable Q Optional A word processing application such as Notepad or WordPad Q LabVIEW Basics I Introduction CD containing the following files Exercises Folder for saving VIs created during the course and for completing certain course exercises also includes subVIs necessary for some exercises Solutions Folder containing the solutions to all the course exercises nidevsim zip Zip file containing the LabVIEW instrument driver for the NI Instrument Simulator National Instr
86. If the VI that is running is a subVI the Run button appears as shown at left The Run button appears broken shown at left when the VI you are creating or editing contains errors If the Run button still appears broken after you finish wiring the block diagram the VI is broken and cannot run Click this button to display the Error list window which lists all errors and warnings Click the Run Continuously button shown at left to run the VI until you abort or pause execution You also can click the button again to disable continuous running While the VI runs the Abort Execution button shown at left appears Click this button to stop the VI immediately if there is no other way to stop the VI If more than one running top level VI uses the VI the button is dimmed Kp Note Avoid using the Abort Execution button to stop a VI Either let the VI complete its data flow or design a method to stop the VI programmatically By doing so the VI is at a known state For example place a button on the front panel that stops the VI when you click it an Click the Pause button shown at left to pause arunning VI When you click the Pause button LabVIEW highlights on the block diagram the location where you paused execution and the Pause button appears red Click the button again to continue running the VI Select the Text Settings pull down menu shown at left to change the font settings for the selected portions of the VI including size styl
87. LabVIEW Basics Introduction Course Manual Course Software Version 7 0 June 2003 Edition Part Number 320628L 01 Copyright 1993 2003 National Instruments Corporation All rights reserved Under the copyright laws this publication may not be reproduced or transmitted in any form electronic or mechanical including photocopying recording storing in an information retrieval system or translating in whole or in part without the prior written consent of National Instruments Corporation Trademarks CVI IVI FieldPoint LabVIEW Measurement Studio MXI National Instruments National Instruments Alliance Program NI NI Developer Zone NI 488 2 ni com NI DAQ and SCXI are trademarks of National Instruments Corporation Tektronix and Tek are registered trademarks of Tektronix Inc Other product and company names mentioned herein are trademarks or trade names of their respective companies Patents For patents covering National Instruments products refer to the appropriate location Help Patents in your software the patents txt file on your CD or ni com legal patents Worldwide Technical Support and Product Information ni com National Instruments Corporate Headquarters 11500 North Mopac Expressway Austin Texas 78759 3504 USA Tel 512 683 0100 Worldwide Offices Australia 1800 300 800 Austria 43 0 662 45 79 90 0 Belgium 32 0 2 757 00 20 Brazil 55 11 3262 3599 Canada Ca
88. LabVIEW Introduction Course Manual Lesson3 Repetition and Loops rene b Place the Thermometer VI on the block diagram Select Functions All Functions Select a VI and navigate to C Exercises LabVIEW Basics I Thermometer vi to place the VI This VI reads the temperature from the DAQ device Right click the Temp Scale input and select Create Constant from the shortcut menu Use a FALSE constant for Fahrenheit or a TRUE constant for Celsius Kp Note If you do not have a DAQ device with a temperature sensor on Channel 0 use the Demo Thermometer VI instead gt Optional Challenge LabVIEW Introduction Course Manual c Place the Wait Until Next ms Multiple function located on the Functions All Functions Time amp Dialog palette on the block diagram Right click the input and select Create Constant from the shortcut menu Enter a value of 1000 to set the wait to every second d Place the Increment function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram This function adds one to the iteration terminal output Save this VI as Timed Temperature vi in the C Exercises LabVIEW Basics I directory Run the VI The first reading might take longer than one second to retrieve if the computer needs to configure the DAQ device If time permits complete the following optional and challenge steps otherwise close the VI Build a VI that generates random numbers in a
89. Lesson 1 Introduction to LabVIEW pee Blank wI VI From Template seen PalmScreen vit ete PocketPCScreen vit Use this template to generate a signal analyze the signal and display the result This template is used with the exercises in the Getting Started with Lab IE manual Frameworks bee Read and Display Simulated ee Generate and Display k Load From File and Display er Tutorial Getting Started Generate Analyze and Display Generate and Display Other Document Types AH naa 1 mmm Li bred hy meme E g r al A akaba i AES 4 Click the OK button to open the template You also can double click the name of the template VI in the Create new list to open the template 5 Examine the front panel of the VI The user interface or front panel appears with a gray background and includes controls and indicators The title bar of the front panel indicates that this window is the front panel for the Generate and Display VI iy Note If the front panel is not visible you can display the front panel by selecting Window Show Front Panel 6 Examine the block diagram of the VI The block diagram appears with a white background and includes VIs and structures that control the front panel objects The title bar of the block diagram indicates that this window 1s the block diagram for the Generate and Display VI Kp Note Ifthe block diagram is not visible you can display the block diagram by selecting Windo
90. Memory LF gt CR gt LB1024 gt HB1024 gt LB2 gt HB2 gt LB1 gt gt HB1 gt ATAD tap PIB A D 0 from instrument 2 sre r 2050 2052 The following block diagram shows how you can use the Type Cast function to cast the binary waveform string into an array of 16 bit integers String From instrument Swap Bytes waveform array offset 0 length rest 2046 You might need to use the Swap Bytes function located on the Functions All Functions Advanced Data Manipulation palette to swap the most significant 8 bits and the least significant 8 bits for every element Remember the GPIB 1s an 8 bit bus It can transfer only one byte at a time National Instruments Corporation 10 35 LabVIEW Introduction Course Manual Lesson 10 Instrument Control If the instrument first sends the low byte and then the high byte you do not need to use the Swap Bytes function In the previous example you needed to use the Swap Bytes function because the instrument sent the most significant byte first Because the most significant byte is received first it is placed in a lower memory location than the least significant byte sent after the most significant byte Memory T A 2050 rerai 2050 2052 2052 LabVIEW Introduction Course Manual 10 36 ni com Lesson 10 Instrument Control Exercise 10 6 Waveform Example VI Optional Objective To graph a waveform that an instrument such as a digital
91. Programming Notes LabVIEW Introduction Course Manual 2 24 ni com Lesson 3 Repetition and Loops Structures are graphical representations of the loops and case statements of text based programming languages Use structures on the block diagram to repeat blocks of code and to execute code conditionally or in a specific order LabVIEW includes the following structures the While Loop For Loop Case structure Stacked Sequence structure Flat Sequence structure Event structure and Formula Node This lesson introduces the While Loop and For Loop structures along with functions commonly used with these structures including the shift register and the Feedback Node You Will Learn A How to use a While Loop B How to use a For Loop C How to access the data from previous loop iterations National Instruments Corporation 3 1 LabVIEW Introduction Course Manual Lesson3 Repetition and Loops A While Loops A While Loop executes a subdiagram until a condition is met The While Loop is similar to a Do Loop or a Repeat Until Loop in text based programming The following illustration shows a While Loop in LabVIEW a flow chart equivalent of the While Loop functionality and a pseudo code example of the functionality of the While Loop Repeat code Until Condition met End 1 LabVIEW While Loop 2 Flow Chart 3 Pseudo Code The While Loop is located on the Functions Execution Control palette Select the While Loo
92. Show Front Panel 12 Save the VI as Convert C to F vi inthe C Exercises LabVIEW Basics I directory Run the VI 13 Enter a number in the numeric control and run the VI a Use the Operating tool shown at left or the Labeling tool to double click the numeric control and type a new number b Click the Run button shown at left to run the VI c Try several different numbers and run the VI again icon and Connector Pane 14 Right click the icon in the upper right corner of the front panel window and select Edit Icon from the shortcut menu The Icon Editor dialog box appears Pea 15 Double click the Select tool shown at left on the left side of the Icon Editor dialog box to select the default icon 16 Press the lt Delete gt key to remove the default icon E 17 Double click the Rectangle tool shown at left to redraw the border National Instruments Corporation 2 11 LabVIEW Introduction Course Manual Lesson2 Modular Programming 18 Create the following icon I Icon Editor File Edit Help Copy From Black amp White 16 Colors 256 Colors Show Terminals a Double click the Text tool shown at left and change the font to Small Fonts b Use the Text tool to click the editing area where you will begin typing c Type c and F While the text is active you can move the text by pressing the arrow keys d Use the Pencil tool shown at left to create the arrow Kp Not
93. Show Run button Allow user to resize window Allow user to minimize window Allow run time shortcut menus Show Run Continuously Button Show Front panel when called Close afterwards iF originally closed Highlight lt Enter gt Boolean Show Front panel when loaded Aubo Center Click the OK button twice and save and close the subVI If the front panel is not closed it will not close after the subVI runs 11 7 LabVIEW Introduction Course Manual Lesson11 Customizing VIs 9 Run the Use Pop up Graph VI After the VI acquires 10 seconds of temperature data the front panel of the Pop up Graph VI displays and plots the temperature data Click the DONE button to return to the calling VI Change the window appearance settings for the Pop up Graph subVI to the Dialog window style Save and close the subVI Run the Use Pop up Graph VI again The Pop up Graph subVI front panel window behaves as a dialog box For example the window stays on top of all other windows and uses the system colors Close all open VIs End of Exercise 11 1 LabVIEW Introduction Course Manual 11 8 ni com Lesson11 Customizing VIS C Keyboard Shortcuts for Controls While a VI runs you can press the lt Tab gt key to change the key focus from one control to the next The key focus is the same as 1f you had clicked the control While a control has the key focus you can use the keyboard to enter the control value If the control is a text or n
94. Step Undo Reda Run Show Help step Sequence Clear parsing v Select Instrument i i ASCII representation oo0000000000 Jational Ine al 00000000012 Lruments GFI Write 00000000024 Dewice Sim fo Read and Parse oo0000000060 Read and Parse Bin and ASCII Byte order Big Endian Motorola Separator s Selected Token Settings Outputs Token name String Length String String Data Type Scaling Instruments GPIB ae and Serial Device Simulator Rev B 1 Character Count E 10 end of data 12 Select OK to return to the block diagram b Right click the String output and select Create Indicator from the shortcut menu c Right click the String Length output and select Create Indicator from the shortcut menu W Tip Since LabVIEW is set to handle errors automatically there is no need to connect a Simple Error Handler VI to error out Display the front panel and run the VI Save the VI as Serial Communication vi inthe C Exercises LabVIEW Basics I directory 7 Close the VI when finished End of Exercise 10 5 National Instruments Corporation 10 33 LabVIEW Introduction Course Manual Lesson 10 Instrument Control H Waveform Transfers Optional Many instruments return a waveform as an ASCII string or a binary string Assuming the same waveform a binary string transfer is faster and requires less memory than an ASCII string transfer Binary encoding requires fewer
95. The block diagram should appear similar to the following figure if Reduce Samples yvi Block Diagram File Edit Operate Tools Browse Window Help Sample Simulate Signal f Compression l Table He I F elay Display the front panel and run the VI Click the Enable switch The table displays the mean values of every 25 samples of the sine wave Notice if the Enable switch is off the table does not record the mean values Stop the VI Experiment with properties of the table by using the Table Properties dialog box For example try changing the number of columns to one 10 Save and close this VI End of Exercise 1 3 National Instruments Corporation 1 51 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW G Debugging Techniques Finding Errors If a VI does not run it is a broken or nonexecutable VI The Run button often appears broken shown at left when you create or edit a VI If itis still broken when you finish wiring the block diagram the VI is broken and will not run Generally this means that a required input is not wired or a wire is broken Click the broken Run button or select Windows Show Error List to display the Error list window which lists all the errors Double click an error description to display the relevant block diagram or front panel and highlight the object that contains the error Execution Highlighting yi Single Stepping Probes el
96. VI and navigate to C Exercises LabVIEW Basics I Thermometer vi This subVI returns one point of temperature data Place the Wait Until Next ms Multiple function located on the Functions All Functions Time amp Dialog palette on the block diagram This function causes the For Loop to execute every 0 25 seconds 250 ms Place the Array Max amp Min function located on the Functions All Functions Array palette on the block diagram This function returns the maximum and minimum temperature Place the Mean VI located on the Functions All Functions Analyze Mathematics Probability and Statistics palette on the block diagram This subVI returns the average of the temperature measurements Right click the output terminals of the Array Max amp Min function and Mean VI and select Create Indicator from the shortcut menu to create the Max Min and Mean indicators Place the General Polynomial Fit VI located on the Functions All Functions Analyze Mathematics Curve Fitting palette on the block diagram This subVI returns an array that is a polynomial fit to the temperature array Place the Bundle function located on the Functions All Functions Cluster palette on the block diagram This function assembles the plot elements into a single cluster Press the lt Ctrl gt key while you drag the function to copy it The elements include the initial x value 0 the Ax value 0 25 and the y array of 6 22 ni com Le
97. VI from running LabVIEW has graphical floating palettes to help you create and run VIs The three palettes include the Tools Controls and Functions palettes You can place these palettes anywhere on the screen Tools Palette You can create modify and debug VIs using the tools located on the floating Tools palette The Tools palette is available on both the front panel and the block diagram A tool is a special operating mode of the mouse cursor The cursor corresponds to the icon of the tool selected in the Tools palette Use the tools to operate and modify front panel and block diagram objects Select Window Show Tools Palette to display the Tools palette Press the lt Shift gt key and right click to display a temporary version of the Tools palette at the location of the cursor Figure 1 3 Tools Palette If automatic tool selection is enabled and you move the cursor over objects on the front panel or block diagram LabVIEW automatically selects the corresponding tool from the Tools palette You can disable automatic tool selection and select a tool manually by clicking the tool you want on the Tools palette LabVIEW Introduction Course Manual 1 12 ni com l el G 2 Lesson1 Introduction to LabVIEW If you want to use the lt Tab gt key to cycle through the four most common tools on the Tools palette click the Automatic Tool Selection button shown at left on the Tools palette to disable automatic
98. VI that performs the following tasks a Take a temperature measurement once every second until you stop the VI or an error occurs Display both the current temperature and the average of the last three measurements on a waveform chart If the temperature exceeds a limit turn on an LED After each measurement log the date time including seconds temperature average of the last three measurements and a one word message describing whether the temperature is normal or over the limit Log data so each item appears in one column of a spreadsheet as shown in the following example al Temp Avg Comment 2 92600 12 45 17 AM 74 46 74 46 Normal 3 9 26 00 12 45 18 AM 74 46 74 46 Normal PF92600 12 45 19 AM 74 46 74 46 Normal 5 92600 12 45 20 AM 74 46 7446 Normal After you stop the acquisition plot both the raw temperature data and a best fit curve in an XY graph and display the average maximum and minimum temperatures W Tip Start with the Temperature Logger VI which you built in Exercise 8 5 To complete step e use portions of the Temperature Analysis VI which you built in Exercise 6 4 LabVIEW Introduction Course Manual 8 30 ni com Lesson 8 Strings and File 1 0 The front panel should be similar to the following figure Power S ON OFF High Limit Heo Aaw Fitted Temperature Average Current Warming LL o 80 0 T Temp Graph oe 06 0 g4 0 520 T 50 0 T 78 0 76 0 74
99. VIEW automatically places the Convert from Dynamic Data Express VI on the block diagram Double click the Convert from Dynamic Data Express VI to open the Configure Convert from Dynamic Data dialog box to control how the data appears in the array Use the Convert to Dynamic Data Express VI to convert numeric Boolean waveform and array data types to the dynamic data type for use with Express VIs When you place the Convert to Dynamic Data Express VI on the block diagram the Configure Convert to Dynamic Data dialog box appears Use this dialog box to select the kind of data to convert to the dynamic data type Automatically Wiring Objects LabVIEW automatically wires objects as you place them on the block diagram You also can automatically wire objects already on the block diagram LabVIEW connects the terminals that best match and leaves terminals that do not match unconnected As you move a selected object close to other objects on the block diagram LabVIEW draws temporary wires to show you valid connections When you release the mouse button to place the object on the block diagram LabVIEW automatically connects the wires Toggle automatic wiring by pressing the spacebar while you move an object using the Positioning tool You can adjust the automatic wiring settings by selecting Tools Options and selecting Block Diagram from the top pull down menu Manually Wiring Objects When you pass the Wiring tool over a terminal a tip stri
100. VIEW Basics I directory By default the VI plots an interference waveform A Property Node on the block diagram defines the color range used in the intensity graph You can change the color range by opening the block diagram and modifying the Color Array constant i mom oom oo oom do fo Aro dao ioo Afo Aso hoo aoo oo eoa ho so i nm oe ma E 2 Change the Plot switch on the front panel to User Data and enter values between 0 0 and 10 0 in the User Data array control Run the VI Notice how the magnitude of each element is mapped to the intensity graph LabVIEW Introduction Course Manual 6 28 ni com Lesson6 Plotting Data Ci mom oom oo oo do fho Ao dao oon Afio so ioo oo Ao o io Ao Frequency G Amplitude 8 3 Close the VI Do not save changes End of Exercise 6 6 National Instruments Corporation 6 29 LabVIEW Introduction Course Manual Lesson6 Plotting Data Summary Tips and Tricks LabVIEW Introduction Course Manual The waveform chart is a special numeric indicator that displays one or more plots The waveform chart has the following three update modes A strip chart shows running data continuously scrolling from left to right across the chart A scope chart shows one item of data such as a pulse or wave scrolling partway across the chart from left to the right A sweep display is similar to an EKG display A sweep works similarly to a scope except it shows the old
101. a menu to display all items You can display all menu items by default by selecting Tools Options and selecting Miscellaneous from the top pull down menu Kp Note Some menu items are unavailable while a VI is in run mode National Instruments Corporation 1 7 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW The File menu contains items used for basic file operations such as opening closing saving and printing files The Edit menu contains items that allow you to search for and modify LabVIEW files and their components The Operate menu contains items you use to control the operation of VIs The Tools menu contains items for configuring LabVIEW your projects and your VIs The Browse menu contains items that allow you to view aspects of the current VI and its hierarchy The Window menu contains items that allow you to configure the appearance of the current windows and palettes You also can access the Error List window and view the contents of the clipboard The Help menu contains items to explain and define LabVIEW features and other components provide full LabVIEW documentation and access National Instruments technical support Front Panel and Block Diagram Windows When you open a blank VI an untitled front panel window appears This window displays the front panel and is one of the two LabVIEW windows you use to build a VI The other window contains the block diagram The following illustration
102. a telephone cable where each wire in the cable represents a different element of the cluster A cluster is similar to a record or a struct in text based programming languages Bundling several data elements into clusters eliminates wire clutter on the block diagram and reduces the number of connector pane terminals that subVIs need The connector pane has at most 28 terminals If a front panel contains more than 28 controls and indicators that you want to use programmatically group some of them into a cluster and assign the cluster to a terminal on the connector pane Like an array a cluster is either a control or an indicator A cluster cannot contain a mixture of controls and indicators Although cluster and array elements are both ordered you must unbundle all cluster elements at once rather than index one element at a time You also can use the Unbundle By Name function to access specific cluster elements Creating Cluster Controls and Indicators To create a cluster control or indicator select a cluster on the Controls All Controls Array amp Cluster palette place it on the front panel and drag controls or indicators into the cluster shell Resize the cluster shell by dragging the cursor while you place the cluster shell The following example is a cluster of three controls Cluster Digital Control OF Button String Control Creating Cluster Constants Create a cluster constant on the block diagram by selecti
103. access labeled elements of an existing cluster Bundle by Name works similarly to the Bundle function but instead of referencing cluster elements by their cluster order it references them by their owned labels You can access only elements with owned labels The number of inputs does not need to match the number of elements in output cluster Use the Operating tool to click an input terminal and select an element from the pull down menu You also can right click the input and select the element from the Select Item shortcut menu In the following example you can use the Bundle by Name function to change Command and Function Input Cluster Commend Hl Output Cluster Foncion B E Use the Bundle by Name function for data structures that might change during development If you add a new element to the cluster or modify its order you do not need to rewire the Bundle by Name function because the names still are valid Disassembling Clusters Use the Unbundle function to split a cluster into its individual elements Use the Unbundle by Name function to return the cluster elements whose names you specify The number of output terminals does not depend on the number of elements in the input cluster Use the Operating tool to click an output terminal and select an element from the pull down menu You also can right click the output terminal and select the element from the Select Item shortcut menu LabVIEW Introduction Course Manual 5
104. acquire data from analog input channel 1 LabVIEW displays the sine wave from analog output channel 0 e Click the Digital I O tab to test the digital lines on the DAQ device f Set lines 0 through 3 as output and toggle the Logic Level checkboxes As you toggle the boxes the LEDs on the DAQ signal accessory turn on or off The LEDs use negative logic g Click the Close button to close the Test Panel and return to MAX Click the Counter I O tab to determine if the DAQ device counter timers are functioning properly To verify counter timer operation change the Counter Mode tab to Edge Counting and click the Start button The Counter Value increments rapidly Click Stop to stop the counter test Close MAX by selecting File Exit End of Exercise 9 1 LabVIEW Introduction Course Manual 9 10 ni com Lesson9 Data Acquisition and Waveforms B Data Acquisition in LabVIEW The LabVIEW Data Acquisition VIs are located on the Data Acquisition palette and the DAQmx Data Acqusition palette The Data Acquisition palette contains the traditional NI DAQ VIs The DAQmx Data Acquisition palette contains the VIs for NI DAQmx The DAQm x Data Acquisition palette contains all of the VIs necessary to perform analog I O digital I O and counter timer operations The VIs are organized so that the most common operations can be performed using the VIs You can configure a task to perform a very specific function by using the Property Nodes
105. agram F Read LabvIEW Measurement File Waveform Chart ae a Place the Read LabVIEW Measurement File Express VI located on the Functions Input palette on the block diagram Because this Express VI reads data located in a LabVIEW measurement file 9 21 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms one data point at a time it must be placed in a loop In the Configure Read LabVIEW Measurement File dialog box that appears set the following options In the Action section place a checkmark in the Ask user to choose file checkbox Set the Segment Size to Retrieve segments of original size so that all the data stored in the file is retrieved Set Time Stamps to Relative to start of measurement Because the dynamic data type stores information about the signal timing this setting aligns the data with the time of the measurement In the Generic Text File section remove the checkmark from the Read generic text files checkbox because the data is stored ina LabVIEW measurement file Click the OK button to close the dialog box b Wire the Data Available output to the While Loop conditional terminal This stops the While Loop when the entire LabVIEW Measurement File has been read status c Place the Unbundle by Name function located on the Functions All Functions Cluster palette on the block diagram d Place the Or function located on the Functions Arithmetic amp gt Comparison
106. alette on the block diagram Save the VI as Graph Circle vi inthe C Exercises LabVIEW Basics I directory Display the front panel and run the VI Close the VI End of Exercise 6 5 National Instruments Corporation 6 25 LabVIEW Introduction Course Manual Lesson6 Plotting Data C Intensity Plots Optional You can use intensity graphs and charts to display patterned data such as temperature patterns and topographical terrain where the magnitude represents altitude Like the waveform graph and chart the intensity graph features a fixed display while the intensity chart features a scrolling display The intensity graph and chart accept a 2D array of numbers Each number in the array represents a specific color The indexes of the elements in the 2D array set the plot locations for the colors The intensity graph or chart can display up to 256 discrete colors The following example shows a 4 x 3 array plotted on an intensity graph The graph transposes the array elements 2D dali Intensity Graph af a 72 00 row O 3 B o0 an O00 row T OO row 2 apnyjdury fo OO tow 3 col col 1 col 2 Intensity Graph and Chart Options The intensity graphs and charts share many of the optional parts of the waveform graphs and charts which you can show or hide by right clicking the graph or chart and selecting Visible Items from the shortcut menu In addition because the intensity graphs and charts include color as a t
107. alue appears red to indicate that you must delete or edit the value before the structure can execute Input and Output Tunnels You can create multiple input and output tunnels for a Case structure Inputs are available to all subdiagrams but subdiagrams do not need to use each input When you create an output tunnel in one case corresponding tunnels appear at the same position on the border in all other cases If at least one output tunnel is not defined all output tunnels on the structure appear as white squares Wire to the output tunnel for each unwired case clicking the tunnel each time You can define a different data source for the Same output tunnel in each case but the data types must be compatible You also can wire constants or controls to unwired cases by right clicking the tunnel and selecting Create Constant or Create Control from the shortcut menu ny Note You can right click the output tunnel and select Use Default If Unwired from the shortcut menu to use the default value for the tunnel data type for all unwired tunnels LabVIEW Introduction Course Manual 4 ni com Lesson 7 Making Decisions ina VI Examples In the following examples the numeric values pass through tunnels to the Case structure and are either added or subtracted depending on the value wired to the selector terminal Boolean Case Structure The following example is a Boolean Case structure The cases are shown overlapped to simplify the illu
108. alues 5 Row Headings 2 Column Headings 6 Horizontal Index 3 Vertical Scrollbar 7 Vertical Index 4 Horizontal Scrollbar Define cells in the table by using the Operating tool or the Labeling tool to select a cell and typing text in the selected cell The table displays a 2D array of strings so you must convert 2D numeric arrays to 2D string arrays before you can display them in a table indicator The row and column headers are not automatically displayed as in a spreadsheet You must create 1D string arrays for the row and column headers National Instruments Corporation 8 3 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O B String Functions Use the String functions located on the Functions All Functions String palette to edit and manipulate strings on the block diagram String functions include the following String Length Returns in length the number of characters bytes string including space characters For example the String Length function returns a length of 19 for the following string The quick brown fox Concatenate Strings Concatenates input strings and 1D arrays of strings into a single output string For array inputs this function concatenates each element of the array Add inputs to the function by right clicking an input and selecting Add Input from the shortcut menu or by resizing the function For example concatenate the previous string with the following array of strings Saat c
109. an include the vi 1ib files in the save After you save the backup VI change the VI properties of the original VI If you encounter a problem you can return to the backup VI UN Caution If you select the Remove diagrams option you remove the source code of the VI Select this option only if you never need to edit the VI again Before you save a VI without the block diagrams save a backup of the VI with the block diagrams If you already saved a development VI with properties that make the VI difficult to edit refer to Exercise 11 3 for more information about editing the VI National Instruments Corporation 11 13 LabVIEW Introduction Course Manual Lesson11 Customizing VIs Exercise 11 3 Edit Me VI Objective To edit a VI with properties that make it difficult to edit Complete the following steps to modify a VI that is configured to run when opened and quit LabVIEW after it runs Front Panel 1 Close any open VIs and open the Edit Me VI located in the C Exercises LabVIEW Basics I directory The following front panel is already built Ie Edit Me wi Can You Edit Me The VI is already running when it opens While the VI runs you cannot use the menu bar toolbar or keyboard shortcuts to edit or abort the VI Click the Start button After 10 seconds the VI stops running and quits LabVIEW 3 Relaunch LabVIEW and open a blank VI If the VI you want to edit either does not have subVIs or you do not know what it
110. and earlier versions virtual channels are a simple method to remember which channels are used for different measurements NI DAQmx channels are similar to the virtual channels of Traditional NI DAQ NI DAQmxx also includes tasks that are integral to the API A task is a collection of one or more channels and the timing triggering and other properties that apply to the task itself A task represents a measurement or generation you want to perform National Instruments Corporation 9 5 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms Channels created only inside a task are local Channels defined outside a task are global and can be used separately Configuring virtual channels is optional in Traditional NI DAQ and earlier versions but is integral to every measurement you take in NI DAQmx In Traditional NI DAQ you configure virtual channels in MAX In NI DAQmx you can configure virtual channels either in MAX or in a program and you can configure channels as part of a task or separately LabVIEW Introduction Course Manual 9 6 ni com Lesson9 Data Acquisition and Waveforms Exercise 9 1 Measurement amp Automation Explorer Windows Only Objective To use MAX to examine the current DAQ configuration and test the device interactively Complete the following steps to examine the configuration for the DAQ device in the computer using MAX and use the test routines in MAX to confirm operation of the device
111. and return to LabVIEW End of Exercise 8 2 8 15 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O E Low Level File I O VI and Functions OG F ei m 70 E Ti m E E HE Use the following low level File I O VI and functions to perform basic file I O operations e Open Create Replace File Opens an existing file creates a new file or replaces an existing file programmatically or interactively using a file dialog box You can optionally specify a dialog prompt default file name start path or filter pattern If file path is empty the VI displays a dialog box from which you can select a file e Read File Reads data from an open file specified by refnum and returns it in data Reading begins at the current file mark or a location specified by pos mode and pos offset How the data is read depends on the format of the specified file e Write File Writes data to an open file specified by refnum Writing begins at a location specified by pos mode and pos offset for byte stream files and at the end of the file for datalog files data header and the format of the specified file determine the amount of data written e Close File Closes an open file specified by refnum and returns the path to the file associated with the refnum Error I O operates uniquely in this function which closes regardless of whether an error occurred in a preceding operation This ensures that files are closed correctly Error H
112. and select the Time sec X axis in the top pull down menu Set the scale options as shown in the following dialog box Set the Multiplier to 0 50 to account for the 500 ms Wait function LabVIEW Introduction Course Manual 6 6 ni com Lesson6 Plotting Data gt Chart Properties Temperature History Appearance Format and Precision Plots Scales Documentation Time sec x axis wt Scale Label Visible Sutoscale Scale Visible Minimum Log Maximum 20 00 Inverted Scaling Factors Offset Multiplier 00 Scale Style and Colors Grid Style and Colors al Major Tick Color l To T Major Grid Color Eo Minor Tick Color TAL 0 0 Ei E Minor Grid Color E Marker Text Color e In the Scales tab select the Deg F Y axis in the top pull down menu Set the scale options as shown in the following dialog box gt Chart Properties Temperature History Appearance Format and Precision Plots Scales Documentation Deg F y axis Ww Name Scale Label Visible Auboscale Scale Visible Minimum 70 00 Log Maximum 90 00 C Inverted Scaling Factors Offset Multiplier 1 00 Scale Style and Colors Grid Style and Colors E Major Tick Color E T Major Grid Color 0 5 Minor Tick Color o0 E Minor Grid Color MM Marker Text Color f Click the OK button to close the dialog box when finished National Instruments Corporation 6 7 LabVIEW Introduction Course Manual Lesson6 Plotting Data
113. andling The low level File I O VIs and functions return error information Wire the error information from the beginning of the VI to the end Include an error handler VI such as the Simple Error Handler VI located on the Time amp Dialog palette at the end of the VI to determine 1f the VI ran without errors Use the error in and error out clusters in each VI you use or build to pass the error information through the VI saving Data in a New or Existing File You can write any data type to a file you open or create with the File I O VIs and functions If other users or applications need to access the file write string data in ASCII format to the file Refer to the LabVIEW Basics II Development Course Manual for more information about writing LabVIEW datalog or binary files You can access files either programmatically or interactively through a file dialog box To access a file through a dialog box do not wire file path in the Open Create Replace File VI However you can save time by programmatically wiring the default filename and path to the VI The following table describes how pathnames are organized LabVIEW Introduction Course Manual 8 16 ni com Lesson 8 Strings and File I O Consists of the drive name a colon backslash separated directory names and the filename For example c testdata test1 dat is the pathname to a file named test1 dat in the testdata directory Consists of forward slash separated directory names and
114. anual Lesson9 Data Acquisition and Waveforms A Overview and Configuration LabVIEW includes a set of VIs that let you configure acquire data from and send data to DAQ devices Often one device can perform a variety of functions analog to digital A D conversion digital to analog D A conversion digital I O and counter timer operations Each device supports different DAQ and signal generation speeds Also each DAQ device is designed for specific hardware platforms and operating systems Refer to ni com daq for more information about DAQ devices DAQ System Components Before a computer based measurement system can measure a physical signal such as temperature a sensor or transducer must convert the physical signal into an electrical one such as voltage or current You might consider the plug in DAQ device to be the entire measurement system but it is actually only one system component You cannot always directly connect signals to a plug in DAQ device In these cases you must use signal conditioning accessories to condition the signals before the plug in DAQ device converts them to digital information The software controls the DAQ system by acquiring the raw data analyzing and presenting the results Consider the following options for a DAQ system e The plug in DAQ device resides in the computer You can plug the device into the PCI slot of a desktop computer or the PCMCIA slot of a laptop computer for a portable DAQ m
115. arks in the Show Front Panel When Called and Close Afterwards if Originally Closed checkboxes National Instruments Corporation 11 5 LabVIEW Introduction Course Manual Lesson11 Customizing VIs Exercise 11 1 Pop up Graph VI and Use Pop up Graph VI Objective To display a subVI front panel when a VI runs Complete the following steps to build a VI that acquires temperature once every 0 5 seconds for 10 seconds displays a subVI front panel that shows the acquired data in a graph and keeps the front panel open until you click a button Front Panel 1 Open a blank VI and build the following front panel Temperature of data values 99 52 19 g a 0 0 40 204 Use the following guidelines to assist you in building the front panel e The indicator to the right of the thermometer is a digital display belonging to the thermometer Right click the thermometer and select Visible Items Digital Display from the shortcut menu to display the digital value e Change of data values to signed 32 bit integer 132 representation Block Diagram 2 Build the following block diagram of readings Pop up Graph vi ms Wait Until Next Bao X fn Multiple LabVIEW Introduction Course Manual 11 6 ni com rene a b a e Lesson 11 Customizing VIS Place the Thermometer VI which you built in Exercise 2 2 on the block diagram This VI acquires the current temperature value Place the Wait Until
116. at is writing a 1 to the LED digital line turns off the LED Writing a 0 to the LED digital line turns on the LED 1 Open the Digital Example VI located in the C Exercises LabVIEW Basics I directory and modify the block diagram as shown in the following figure Digital Pork 0 Array Subset DAQ Assistant DS data Place the DAQ Assistant Express VI located on the Functions Input palette in the While Loop Complete the following steps to configure the counter to perform event counting a Select Digital I O Port Output for the measurement to make b Select Dev1 port0 for the physical channel and click the Finish button c In the Digital Output Port Task Configuration dialog box that appears select Invert All Lines In Port because the LEDs use negative logic d Click the OK button to close the configuration dialog box All of the settings specified for the task are saved internally in the DAQ Assistant VI The Boolean buttons on the front panel are stored in an array to simplify the code The Array Subset function extracts only the first four elements in the array The output of the array subset needs to be reversed since element O of the array is the most significant bit The array is then converted to a number with the Boolean Array to Number function which passes its output to the DAQ Assistant Express VI to write that value to the port LabVIEW Introduction Course Manual 9 32 ni com Lesson9 Data Acquisition
117. ated on the Functions All Functions Time amp Dialog palette on the block diagram This VI checks error conditions and opens a dialog box with error information if an error occurs Save the VI as My VISA Write amp Read vi in the C Exercises LabVIEW Basics I directory Display the front panel Enter devsim into the VISA resource name input and set byte count to 200 to make sure you read all the information Type IDN in the write buffer and run the VI The top of the instrument simulator lists other commands that are recognized by this instrument Try other commands in this VI Close the VI when finished End of Exercise 10 3 National Instruments Corporation 10 17 LabVIEW Introduction Course Manual Lesson 10 Instrument Control E About Instrument Drivers An instrument driver is a set of modular software functions that use the instrument commands or protocol to perform common operations with the instrument The instrument driver also calls the appropriate VIs and functions for the instrument LabVIEW instrument drivers eliminate the need to learn the complex low level programming commands for each instrument The LabVIEW instrument driver library contains instrument drivers for a variety of programmable instruments that use the GPIB V XI PXI or serial interfaces Instrument drivers receive parse and scale the response strings from instruments into scaled data that you can use in test applications Instrument
118. ation Explorer File Edit View Tools Help Data Neighborhood 5 Devices and Interfaces N ati on al n stru me nts Traditional NI DAQ Devices Mi easurement amp PSEE PEI System 0 Unidentified Ba NI DAQmx Devices Automation Explorer B PCI 6024E Devi GPIBO PCI GPIB ip Ports Serial amp Parallel What is gt IVT Instruments Measurement A Scales Automation MAX displays Fl Historical Data interactive embedded F Software Explorer help in the right side of VI Logger Tasks the MA window to 55 Remote Systems Measurement amp guide vou through F Category Help MAX detects all the National Instruments hardware including the GPIB interface Refer to Lesson 10 Instrument Control for more information about GPIB The device parameters that you can set using the configuration utility depend on the device MAX saves the logical device number and the configuration parameters in the Windows Registry The plug and play capability of Windows automatically detects and configures switchless DAQ devices such as the PCI 6024E When you install a device in the computer the device is automatically detected Channel and Task Configuration In Traditional NI DAQ you can configure a set of virtual channels or a collection of property settings that include a physical channel the type of measurement or generation specified in the channel name and scaling information In Traditional NI DAQ
119. ation of the loop because it is inside the loop of iterations updates upon completion because it is outside the loop 9 To see how the VI updates the indicators enable execution highlighting On the block diagram toolbar click the Highlight Execution button A shown at left to enable execution highlighting Execution highlighting shows the movement of data on the block diagram from one node to another so you can see each number as the VI generates it 10 Change Number to Match to a number that is out of the data range which is O to 10 000 with an increment of 1 11 Run the VI LabVIEW coerces the out of range value to the nearest value in the specified data range 12 Close the VI End of Exercise 3 1 LabVIEW Introduction Course Manual 3 8 ni com Lesson3 Repetition and Loops B For Loops A For Loop executes a subdiagram a set number of times The following illustration shows a For Loop in LabVIEW a flow chart equivalent of the For Loop functionality and a pseudo code example of the functionality of the For Loop N 100 1 0 Until 1 N Repeat code i i 1 End 1 LabVIEW For Loop 2 Flow Chart 3 Pseudo Code The For Loop is located on the Functions All Functions Structures palette You also can place a While Loop on the block diagram right click the border of the While Loop and select Replace with For Loop from the IN shortcut menu to change a While Loop to a For Loop The value in the c
120. ator so LabVIEW displays four input terminals and one output terminal on the connector pane if Slope vi Front Panel Ox File Edit Operate Tools Browse Window Help I O n ran fE Slope im 0 00 National Instruments Corporation 2 LabVIEW Introduction Course Manual Lesson2 Modular Programming Selecting and Modifying Terminal Patterns Select a different terminal pattern for a VI by right clicking the connector pane and selecting Patterns from the shortcut menu Select a connector pane pattern with extra terminals You can leave the extra terminals unconnected until you need them This flexibility enables you to make changes with minimal effect on the hierarchy of the VIs You also can have more front panel controls or indicators than terminals A solid border highlights the pattern currently associated with the icon The maximum number of terminals available for a subVI is 28 The most commonly used pattern is shown at left This pattern is used as a H standard to assist in simplifying wiring The top inputs and outputs are commonly used for passing references and the bottom inputs and outputs are used for error handling Refer to Lesson 5 Clusters for more information about error handling Kp Note Try not to assign more than 16 terminals to a VI Too many terminals can reduce the readability and usability of the VI To change the spatial arrangement of the connector pane patterns right click the connector pan
121. ay of plots where a plot is a cluster that contains an x array and a y array The multiplot XY graph also accepts an array of clusters of plots where a plot is an array of points A point is a cluster that contains an x value and a y value Refer to the XY Graph VI in the NI Example Finder for an example of multiplot XY graph data types National Instruments Corporation 6 15 LabVIEW Introduction Course Manual Lesson6 Plotting Data Exercise 6 3 Graph Waveform Array VI Objective To create an array by auto indexing a For Loop and to plot the array on a waveform graph Complete the following steps to build a VI that generates and plots an array on a waveform graph and modify the VI to graph multiple plots Front Panel 1 Open a blank VI and build the following front panel Waveform Graph Waveform Array 1 a E p E Amplitude a fey a Place an array located on the Controls All Controls Array amp Cluster palette on the front panel b Label the array Waveform Array c Place a numeric indicator located on the Controls Numeric Indicators palette in the array shell d Place a waveform graph located on the Controls Graph Indicators palette on the front panel Block Diagram 2 Build the following block diagram waveform Array LabVIEW Introduction Course Manual 6 16 ni com Lesson6 Plotting Data rene a Place the Thermometer VI on the block diagram Select Functions All Functions
122. bVI ordinarily the subVI runs without opening its front panel If you want a single instance of the subVI to open its front panel when called use the Sub VI Node Setup dialog box If you want every instance of the subVI to open its front panel when called use the VI Properties dialog box If you want a single instance of the sub VI to open its front panel when called right click the subVI and select Sub VI Node Setup from the shortcut menu to display the Sub VI Node Setup dialog box Place checkmarks in the Show Front Panel when called and Close afterwards if originally closed checkboxes to open the subVI front panel when called This dialog box also includes the following components e Open Front Panel when loaded Displays the front panel when the subVI loads or when the VI that calls it loads e Show Front Panel when called Displays the front panel when the subVI is called e Close afterwards if originally closed If Show Front Panel when called also contains a checkmark and 1f the subVI was previously closed the front panel closes after the sub VI runs e Suspend when called Suspends a subVI when called and waits for user interaction This option is the same as selecting Operate Suspend when called If you want every instance of the subVI to open its front panel when called open the subVI and select File VI Properties Select Window Appearance from the Category pull down menu click the Customize button and place checkm
123. block diagram and dragging a constant into the array shell Array constants are useful for passing data into a subVI National Instruments Corporation 4 3 LabVIEW Introduction Course Manual Lesson4 Arrays B Auto Indexing If you wire an array to a For Loop or While Loop input tunnel you can read and process every element in that array by enabling auto indexing When you auto index an array output tunnel the output array receives a new element from every iteration of the loop The wire from the output tunnel to the array indicator becomes thicker as it changes to an array at the loop border and the output tunnel contains square brackets representing an array as shown in the following illustration Disable auto indexing by right clicking the tunnel and selecting Disable Indexing from the shortcut menu For example disable auto indexing if you need only the last value passed to the tunnel in the previous example Because you can use For Loops to process arrays an element at a time LabVIEW enables auto indexing by default for every array you wire to a For Loop and for each output tunnel that is created Auto indexing for While Loops is disabled by default To enable auto indexing right click a tunnel and select Enable Indexing from the shortcut menu Creating Two Dimensional Arrays You can use two For Loops one inside the other to create a 2D array The outer For Loop creates the row elements and the inner For Loop creates t
124. bytes than ASCII encoding ASCII Waveforms As an example consider a waveform composed of 1 024 points each point having a value between 0 and 255 Using ASCII encoding you would need a maximum of 4 bytes to represent each point a maximum of 3 bytes for the value of the point and 1 byte for the separator such as a comma You would need a maximum of 4 096 4 x 1 024 bytes plus any header and trailer bytes to represent the waveform as an ASCII string The following example is an ASCII waveform string CURVE 12 28 63 1024 points in total CR_L Header Data Point up to 4 bytes each Trailer 6 bytes 2 bytes You can use the Extract Numbers VI located in the C Exercises LabVIEW Basics I directory to convert an ASCII waveform into a numeric array as follows This VI outputs the waveform as a double precision array Extract Numbers vi Waverorm ASCE Harefann SEG Amend Array Binary Waveforms Encoded as 1 Byte Integers The same waveform using binary encoding requires only 1 024 bytes 1 x 1 024 plus any header and trailer bytes to be represented as a binary string Using binary encoding you need only 1 byte to represent the point assuming each point is an unsigned 8 bit integer The following example is a binary waveform string CURVE MSB LSB AAna 1024 bytes in total Chk CR Header Count Data Point Trailer 7 bytes 4 bytes 1 byte each 3 bytes Converting the binary string to a nume
125. can use Traditional NI DAQ on the same computer as NI DAQmx which you cannot do with NI DAQ 6 9 x e NI DAQmx is the latest NI DAQ driver with new VIs functions and development tools for controlling measurement devices The advantages of NI DAQmx over previous versions of NI DAQ include the DAQ Assistant for configuring channels and measurement tasks for a device increased performance including faster single point analog I O and multithreading and a simpler API for creating DAQ applications using fewer functions and VIs than earlier versions of NI DAQ Traditional NI DAQ and NI DAQmx support different sets of devices Refer to the National Instruments Web site at ni com dag for the list of supported devices This lesson describes the NI DAQmx API The following illustration shows the measurement software framework Your Measurement Application Application Development Environment ADE LabVIEW LabWindows CY1 Measurement Studio or other software Configuration Application Programming Interface API Measurement NI DAGQm s Traditional NI DAG NI SWITCH amp Automation and so on Explorer MAXI DAG Configuration Driver Engines and Algorithms Assistant NI DAGQm Traditional NI DAG VISA and so on Physical Components in a Typical Measurement System Data Acquisition and Modular Instrumentation Signal Conditioning Sansors Real World Signals When programming an NI measurement device you can use NI application soft
126. cation uses a transmitter to send data one bit at a time over a single communication line to a receiver You can use this method when data transfer rates are low or you must transfer data over long distances Serial communication is popular because most computers have one or more serial ports so no extra hardware is needed other than a cable to connect the instrument to the computer or two computers together 1 RS 232 Instrument 2 RS 232 Cable 3 Serial Port Serial communication requires that you specify the following four parameters e the baud rate of the transmission e the number of data bits encoding a character e the sense of the optional parity bit e the number of stop bits Each transmitted character is packaged in a character frame that consists of a single start bit followed by the data bits the optional parity bit and the stop bit or bits The following illustration shows a typical character frame encoding the letter m Idle Start Parity Stop Bit Bit Bits Bit Time pt Character Frame National Instruments Corporation 10 25 LabVIEW Introduction Course Manual Lesson 10 Instrument Control Baud rate is a measure of how fast data are moving between instruments that use serial communication RS 232 uses only two voltage states called MARK and SPACE In such a two state coding scheme the baud rate is identical to the maximum number of bits of information including control bits that are transmitted per seco
127. cators Controls are knobs push buttons dials and other input devices Indicators are graphs LEDs and other displays After you build the user interface you add code using VIs and structures to control the front panel objects The block diagram contains this code In some ways the block diagram resembles a flowchart Use LabVIEW to communicate with hardware such as data acquisition vision and motion control devices and GPIB PXI VXI RS 232 and RS 485 devices LabVIEW also has built in features for connecting your application to the Web using the LabVIEW Web Server and software standards such as TCP IP networking and Activex Using LabVIEW you can create test and measurement data acquisitions instrument control datalogging measurement analysis and report generation applications You also can create stand alone executables and shared libraries like DLLs because LabVIEW is a true 32 bit compiler LabVIEW Introduction Course Manual 1 2 ni com Lesson1 Introduction to LabVIEW B LabVIEW Environment When you launch LabVIEW the following navigation dialog box appears that includes introductory material and common commands El LabVIEW File Edit Tools Help o NATIONAL INSTRUMENTS New Open Configure q La bVI EW 1 Help Figure 1 1 LabVIEW Dialog Box The LabVIEW dialog box includes the following components e A menu with standard items such as File Exit e A set of buttons for creating and o
128. ce a file write the data and close the file Similarly when you read from a file you open an existing file read the data and close the file To access a file through a dialog box leave file path unwired in the Open Create Replace File VI To write data to a spreadsheet file the string must be formatted as a spreadsheet string which is a string that includes delimiters such as tabs Use the Format Into File function to format string numeric path and Boolean data as text and write the text to a file 8 32 ni com Lesson 8 Strings and File 1 0 Additional Exercises 8 7 Challenge Build a VI that generates a 2D array of 3 rows x 100 columns of random numbers and writes the data transposed to a spreadsheet file Add a header to each column Use the high level File I O VIs located on the File I O palette W Tip Use the Write Characters To File VI to write the header and the Write To Spreadsheet File VI to write the numeric data to the same file 8 8 Save the VI as More Spreadsheets vi in the C Exercises LabVIEW Basics I directory Build a VI that converts tab delimited spreadsheet strings to comma delimited spreadsheet strings that is spreadsheet strings with columns separated by commas and rows separated by end of line characters Display both the tab delimited and comma delimited spreadsheet strings on the front panel W Tip Use the Search and Replace String function 8 9 Save the VI as Spreadsheet Converter
129. ce also has variables or attributes that contain information related to the resource The following terminology is similar to that used for instrument driver VIs e Resource Any instrument in the system including serial and parallel ports e Session You must open a VISA session to a resource to communicate with it similar to a communication channel When you open a session to aresource LabVIEW returns a VISA session number which is a unique refnum to that instrument You must use the session number in all subsequent VISA functions e Instrument Descriptor Exact name of a resource The descriptor specifies the interface type GPIB VXI ASRL the address of the device logical address or primary address and the VISA session type INSTR or Event The instrument descriptor is similar to a telephone number the resource is similar to the person with whom you want to speak and the session is similar to the telephone line Each call uses its own line and crossing these lines results in an error The following table shows the proper syntax for the instrument descriptor E d serial ASRL annro snan SSS INSTR GPIB GPIB board primary address secondary address INSTR VXI instrument through embedded VXI board VXI logical address INSTR or MXIbus controller GPIB VXI controller GPIB VXI board GPIB VXI primary address VXI logical address INSTR You can use an alias you ass
130. ce to obtain support while developing various applications with National Instruments products is the NI Developer Zone at ni com zone The NI Developer Zone also includes direct links to the instrument driver network and to Alliance Program member Web pages The Alliance Program The National Instruments Alliance Program joins system integrators consultants and hardware vendors to provide comprehensive service and expertise to customers The program ensures qualified specialized assistance for application and system development Information about and links to many of the Alliance Program members are available from the National Instruments Web site Other National Instruments Training Courses National Instruments offers several training courses for LabVIEW users The courses are listed in the National Instruments catalog and online at ni com training These courses continue the training you received here and expand it to other areas You can either purchase the course materials or National Instruments Corporation A 1 LabVIEW Introduction Course Manual Appendix A sign up for an instructor led hands on course by contacting National Instruments LabVIEW Publications LabVIEW Technical Resource LTR Newsletter Subscribe to LabVIEW Technical Resource to discover power tips and techniques for developing LabVIEW applications This quarterly publication offers detailed technical information for novice users as well as advanced users
131. ch time you communicate with that device you must wire the VISA session input on the instrument driver VIs After you finish communicating with the instrument you use the Close VI to close all references or resources for the instrument Example Instrument Driver Application The following block diagram initializes the instrument with the devsim alias uses a configuration VI to select a waveform uses two data VIs to read the waveform and the waveform scaling information closes the instrument and checks the error status Every application that uses an instrument driver has a similar sequence of events Instr Descriptor MI DEVSIM MI DEYSIM NIDEVSIM Waveform Read MI DEVSIM Read MI DEYSIM Simple Error Initialize vi Selectii Waveformyvi Waveform Scale vi Clase vi Handler vi Eho ERDIAN Ey r E 7 a OE Se a ooo Ea waveform Type EE Waveform Graph National Instruments Corporation 10 21 LabVIEW Introduction Course Manual Lesson 10 Instrument Control Exercise 10 4 Voltage Monitor VI Objective To build a VI that uses the DevSim instrument driver Vis to acquire and plot voltages Complete the following steps to build a VI that acquires a DC voltage measurement from the NI Instrument Simulator once every second and plots itin a waveform chart until you click a button As each value is acquired the VI compares it with the previous minimum and maximum values The VI calculates and displays the minimum and maximum values conti
132. ck Diaeram vissciesscoiadinccsveutascciasiaccateveaeiveleiiacesiaduivciortadssawwinedelescacesdstvieceestadeons 1 21 Ex Datallow OSA UMN neigien eh ances aie ea soda steele cpa cou ece eoe dau eae tated elas 1 39 F LabVIEW Documentation ReEsources e essseeeeesssssssseeersssssssscererssssssseeerrsssssss 1 42 G Debusome Wares aa 06 b lox uemmreener tome er reeernnre Tree a mire rere y tree tanner sete ety trey om 1 52 Lesson 2 Modular Programming As Modula Pros rain x doncaucssattaastvanraws E O texmunsbeadabe 2 2 B Icons and Connector Panes vrssictacesnceuesiasd use ducvaw E a devas ade ulectaivens 2 5 C MUS UW US eto shee annantis nelle astm naune sls cowa E T 2 14 D Creating a SubVI from Sections Of a VI ecccccccccccesseeseeeceeeeeeaeeeaaeeseeeeeeeeeaaas 2 21 Lesson 3 Repetition and Loops Aa 8 Gut Coal Br 810 Sete e eet ee Rte e arr Cory e ONY ere ene ena Cr E en ecrnre tee 3 2 Do FEOEO S Feces aise ascension E AA TAA 3 9 C Accessing Previous Loop Datassrnenrenereiene an e EN 3 15 Lesson 4 Arrays Ay ATAY S a a ald slice le Ina veal E esac ctu hc nelle atta td alia peated 4 2 B Ano TAN IT sete cit nana a disarray a irsins lsat aS a a 4 4 C Aray Fan TO IS ag ise se latch a a a o dete ean ewe 4 6 D OVO AUS i eese a uacstaahadtuaea dnatels oamicanapisesiuleaaradhentens 4 8 National Instruments Corporation lil LabVIEW Introduction Course Manual Contents Lesson 9 Clusters A CIS WC RS gxectdaish ronicaans a T E tend
133. click the terminal and select View As Icon from the shortcut menu to remove the checkmark A DBL data type terminal shown at left represents a double precision floating point numeric control or indicator Terminals are entry and exit ports that exchange information between the front panel and block diagram Terminals are analogous to parameters and constants in text based programming languages Types of terminals include control or indicator terminals and node terminals Control and indicator terminals belong to front panel controls and indicators Data you enter into the front panel controls a and b in Figure 1 9 enter the block diagram through the control terminals The data then enter the Add and Subtract functions When the Add and Subtract functions complete their internal calculations they produce new data values The data flow to the indicator terminals where they exit the block diagram reenter the front panel and appear in front panel indicators a b and a b in Figure 1 9 The terminals in Figure 1 9 belong to four front panel controls and indicators The connector panes of the Add and Subtract functions shown at left have three node terminals To display the terminals of the function on the block diagram right click the function node and select Visible Items Terminals from the shortcut menu You transfer data among block diagram objects through wires Wires are analogous to variables in text based programming languages In Figur
134. contains complete steps 5 through 13 However if the VI you want to edit has subVIs open one of the subVIs and modify the block diagram to break the subVI For example place an Add function on the block diagram and do not wire the inputs Open the VI you want to edit Because its subVI is nonexecutable the VI that calls it is also nonexecutable It opens in edit mode and the Run button appears broken Make sure to fix the subVI after you edit the calling VI 5 Display the block diagram of the new VI LabVIEW Introduction Course Manual Place the Edit Me VI which is already built on the block diagram The front panel for the Edit Me VI displays Although you can display the block diagram of the Edit Me VI you cannot edit it Select Operate Change to Edit Mode A dialog box informs you that the VI is locked 11 14 ni com Lesson 11 Customizing VIS 8 Click the Unlock button You now can edit the VI You also can unlock a VI by selecting File VI Properties and selecting Security from the Category pull down menu 9 Select and delete the Quit LabVIEW function from the block diagram 10 Save and close the Edit Me VI Close the new VI and do not save changes 11 Open the Edit Me VI again 12 After the VI runs try to edit it 13 Close the Edit Me VI End of Exercise 11 3 National Instruments Corporation 11 15 LabVIEW Introduction Course Manual Lesson11 Customizing VIs E Customizing the Controls and Func
135. ct Create Control or Create Indicator from the shortcut menu LabVIEW Introduction Course Manual 11 2 ni com Lesson11 Customizing VIS Window Appearance In the VI Properties dialog box select Window Appearance from the Category pull down menu to customize the window appearance for VIs These options apply to the VI when it is running Use these options to change how the user interacts with the application by restricting access to LabVIEW features and by changing the way the window looks and behaves You can make the VI look and act like a dialog box so the user cannot interact with other windows while the VI window is open You also can remove the scrollbars and toolbar and you can set a window to be centered or automatically sized to fit the screen By default the VI window title is the same as the VI name You can customize the VI window title to make it more descriptive than the VI filename This is useful for localized VIs so the VI window title can be translated to the local language Remove the checkmark from the Same as VI Name checkbox to edit Window title To configure the window appearance select one of the following window styles A graphical representation of each style displays on the right when you Select the style e Top level Application Window Shows the title bar and menu bar hides the scrollbars and toolbar allows the user to close the window allows run time shortcut menus does not allow resizing and shows
136. ctors to each element in the Raw Data cluster Raw Daka Scaled Data 10000 00 Save the VI Display the front panel and run the VI Change the front panel controls and run the VI again ae oO a Close the VI when you are finished End of Exercise 5 2 National Instruments Corporation 5 11 LabVIEW Introduction Course Manual Lesson5 Clusters C Error Clusters Error Handling No matter how confident you are in the VI you create you cannot predict every problem a user might encounter Without a mechanism to check for errors you know only that the VI does not work properly Error checking tells you why and where errors occur When you perform any kind of I O consider the possibility that errors will occur Almost all I O functions return error information Include error checking in VIs especially for I O operations such as file serial instrumentation data acquisition and communication operations and provide a mechanism to handle errors appropriately Checking for errors in VIs can help you identify the following problems e You initialized communications incorrectly or wrote improper data to an external device e An external device lost power is broken or is not working properly e You upgraded the operating system software which changed the path to a file or the functionality of a VI or library You might notice a problem in a VI or a system program By default LabVIEW automatically handles any erro
137. d GPIB interface are working properly Verify that the NI DEVSIM instrument driver is installed and that the NI Instrument Simulator works in both the GPIB and serial modes A 6 ni com Documentation Comment Form National Instruments encourages you to comment on the documentation supplied with our products This information helps us provide quality products to meet your needs Title LabVIEW Basics I Introduction Course Manual Edition Date June 2003 Part Number 320628L 01 Please comment on the completeness clarity and organization of the manual If you find errors in the manual please record the page numbers and describe the errors Date manual was purchased month year Thank you for your help Name Title Company Address Email Address Phone ___ Fax __ Mail to Customer Education Fax to Customer Education National Instruments Corporation National Instruments Corporation 11500 North Mopac Expressway 512 683 6837 Austin Texas 78759 3504 Course Evaluation Course Location Instructor Date Student Information optional Name Company Phone Instructor Please evaluate the instructor by checking the appropriate circle Unsatisfactory Poor Satisfactory Good Excellent Instructor s ability to communicate course concepts O O O O O Instructor s knowledge of the subject matter O O O O O Instructor s presentation skills O O O O O Instructor s sensitivity to class needs O O O O O Instructor
138. data on the right and the new data on the left separated by a vertical line Waveform graphs and XY graphs display data from arrays Right click a waveform chart or graph or its components to set attributes of the chart and its plots You can display more than one plot on a graph using the Build Array function located on the Functions All Functions Array palette and the Bundle function located on the Functions All Functions Cluster palette for charts and XY graphs The graph becomes a multiplot graph when you wire the array of outputs to the terminal You can use intensity charts and graphs to plot three dimensional data The third dimension is represented by different colors corresponding to a color mapping that you define Intensity charts and graphs are commonly used in conjunction with spectrum analysis temperature display and image processing When you wire data to charts and graphs use the Context Help window to determine how to wire them 6 30 ni com Lesson6 Plotting Data Additional Exercises 6 7 Build a VI that displays two plots a random plot and a running average of the last four points on a waveform chart in sweep update mode Use the following tips e Use a For Loop n 200 instead of a While Loop e Use a shift register with three left terminals to average the last four data points e Use the Random Number 0 1 function located on the Functions Arithmetic amp Comparison Express Numeric palette to
139. device you must configure the device manually using the Add New Hardware option in the Control Panel You can verify the Windows Configuration by accessing the Device Manager You can see Data Acquisition Devices which lists all DAQ devices installed in the computer Double click a DAQ device to display a dialog box with tabbed pages The General tab displays overall information regarding the device The Resources tab specifies the system resources to the device such as interrupt levels DMA and base address for software configurable devices The NI DAQ Information tab specifies the bus type of the DAQ device The Driver tab specifies the driver version and location for the DAQ device LabVIEW installs Measurement amp Automation Explorer MAX which establishes all device and channel configuration parameters After installing a DAQ device in the computer you must run this configuration utility MAX reads the information the Device Manager records in the Windows Registry and assigns a logical device number to each DAQ device Use the device number to refer to the device in LabVIEW Access MAX either by double clicking the icon on the desktop or selecting Tools Measurement amp Automation Explorer in LabVIEW The following window is the LabVIEW Introduction Course Manual 9 4 ni com Lesson9 Data Acquisition and Waveforms primary MAX window MAX is also the means for SCXI and SCC configuration My System Measurement amp Autom
140. dialog box 6 Examine but do not change the settings for the GPIB interface and click the OK button 7 Make sure the GPIB interface is still selected in the Devices and Interfaces section and click the Scan for Instruments button on the toolbar 8 Expand the GPIB board section One instrument named Instrument0 appears 9 Click Instrument0 to display information about it in the right pane of MAX The NI Instrument Simulator has a GPIB primary address PAD of 2 10 Click the Communicate with Instrument button on the toolbar An interactive window appears You can use it to query write to and read from that instrument National Instruments Corporation 10 7 LabVIEW Introduction Course Manual Lesson 10 Instrument Control 11 Type IDN in Send String and click the Query button The instrument returns its make and model number in String Received You can use this window to debug instrument problems or to verify that specific commands work as described in the instrument documentation i NI 488 2 Communicator GPIBO Instrument 0 Primary Address 2 Global Send Sting 1DN am m iberr Hone lbenth Be SRAI RUS Sting Receved CMPL Configured LEK REM EIE ATH TACS LACS OTAS Show Sample DESS 12 Type MEAS DC in Send String and click the Query button The NI Instrument Simulator returns a simulated voltage measurement 13 Click the Query button again to return a different value 14 Click the Ex
141. e LabVIEW rounds 2 5 to 2 and 3 5 to 4 Refer to the Data Types section of Lesson 1 Introduction to LabVIEW of this manual or to the LabVIEW Help for more information about data types LabVIEW Introduction Course Manual 3 12 ni com Lesson3 Repetition and Loops Exercise 3 2 Timed Temperature VI Objective To read a temperature once every second for one minute Complete the following steps to build a VI that uses the Thermometer VI to read a temperature once every second for a duration of one minute Front Panel 1 Open a blank VI and build the following front panel Thermometer 100 Seconds Elapsed T a Place athermometer located on the Controls Numeric Indicators palette on the front panel This provides a visual indication of the temperature reading b Place a numeric indicator located on the Controls Numeric Indicators palette on the front panel Label this indicator Seconds Elapsed Right click the indicator and select Representation 132 from the shortcut menu Block Diagram 2 Build the following block diagram Wait Until ext ms Multiple Seconds Elapsed a Place a For Loop located on the Functions All Functions a Structures palette on the block diagram Right click the Loop Count terminal in the upper left corner of the For Loop and select Create Constant from the shortcut menu Type 60 in the constant to set the For Loop to repeat 60 times National Instruments Corporation 3 13
142. e and color Select the Align Objects pull down menu shown at left to align objects along axes including vertical top edge left and so on LabVIEW Introduction Course Manual 1 10 ni com Lesson1 Introduction to LabVIEW Select the Distribute Objects pull down menu shown at left to space objects evenly including gaps compression and so on F Select the Resize Objects pull down menu shown at left to resize multiple front panel objects to the same size F Select the Reorder pull down menu shown at left when you have objects that overlap each other and you want to define which one is in front or back of another Select one of the objects with the Positioning tool and then select from Move Forward Move Backward Move To Front and Move To Back 3 Select the Show Context Help Window button shown at left to toggle the display of the Context Help window Type appears to remind you that a new value is available to replace an old value The Enter button disappears when you click it press the lt Enter gt key or click the front panel or block diagram workspace Block Diagram Toolbar When you run a VI buttons appear on the block diagram toolbar that you can use to debug the VI The following toolbar appears on the block diagram SmE er Yoo A Click the Highlight Execution button shown at left to display an animation of the block diagram execution when you click the Run button see the flow of data thro
143. e button in the path control 5 Navigate to demofile txt and click the Open or OK button 6 Run the VI String Read from File displays the contents of the file 7 If time permits complete the following challenge step Otherwise save and close the VI Challenge 8 Modify the VI so it parses the numeric value and displays the numeric value in a numeric indicator After you finish save and close the VI W Tip Use the Match Pattern function to search for the first numeric character End of Exercise 8 4 LabVIEW Introduction Course Manual 8 22 ni com Lesson 8 Strings and File 1 0 F Formatting Spreadsheet Strings To write data to a spreadsheet file you must format the string as a spreadsheet string which is a string that includes delimiters such as tabs In many spreadsheet applications the tab character separates columns and the end of line character separates rows Kp Note Use the end of line constant located on the Functions All Functions String palette to ensure portability of VIs among platforms Windows The constant inserts a carriage return and a linefeed Mac OS The constant inserts a carriage return UNIX The constant inserts a linefeed Use the Write To Spreadsheet File VI or the Array To Spreadsheet String function to convert a set of numbers from a graph a chart or an acquisition into a spreadsheet string If you want to write numbers and text to a spreadsheet or word processing application use the String func
144. e 1 9 wires connect the control and indicator terminals to the Add and Subtract functions Each wire has a single data source but you can wire it to many VIs and functions that read the data Wires are different colors styles and thicknesses depending on their data types A broken wire appears as a dashed black line with a red X in the middle The following examples are the most common wire types LabVIEW Introduction Course Manual 1 24 ni com Lesson1 Introduction to LabVIEW mere Oare Consp floating point Blue integer ma e ei i ee sw e l el Ml MEST In LabVIEW you use wires to connect multiple terminals together to pass data in a VI The wires must be connected to inputs and outputs that are compatible with the data that is transferred with the wire For example you cannot wire an array output to a numeric input In addition the direction of the wires must be correct The wires must be connected to only one input and at least one output For example you cannot wire two indicators together The components that determine wiring compatibility include the data type of the control and or indicator and the data type of the terminal Data Types Data types indicate what objects inputs and outputs you can wire together For example a switch has a green border so you can wire a switch to any input with a green label on an Express VI A knob has an orange border so you can wire a knob to any input with an orange label
145. e To draw horizontal or vertical straight lines press the lt Shift gt key while you use the Pencil tool to drag the cursor e Use the Select tool and the arrow keys to move the text and arrow you created f Select the B amp W icon and click the 256 Colors button in the Copy from section to create a black and white icon which LabVIEW uses for printing unless you have a color printer g Select the 16 Colors icon and click the 256 Colors button in the Copy from section h When you complete the icon click the OK button to close the Icon Editor dialog box The icon appears in the upper right corner of the front panel and block diagram 19 Right click the icon on the front panel and select Show Connector from the shortcut menu to define the connector pane terminal pattern LabVIEW selects a default connector pane pattern based on the number of controls and indicators on the front panel For example this front panel has two terminals deg C and deg F so LabVIEW selects a pi connector pane pattern with two terminals shown at left LabVIEW Introduction Course Manual 2 12 ni com Lesson2 Modular Programming 20 Assign the terminals to the numeric control and numeric indicator a Select Help Show Context Help to display the Context Help window Click the left terminal in the connector pane The tool automatically changes to the Wiring tool and the terminal turns black Click the deg C control A marquee highlights th
146. e and select Flip Horizontal Flip Vertical or Rotate 90 Degrees from the shortcut menu Assigning Terminals to Controls and Indicators After you select a pattern to use for the connector pane you must define connections by assigning a front panel control or indicator to each of the connector pane terminals When you link controls and indicators to the connector pane place inputs on the left and outputs on the right to prevent complicated unclear wiring patterns in your VIs To assign a terminal to a front panel control or indicator click a terminal of the connector pane then click the front panel control or indicator you want to assign to that terminal Click an open space on the front panel The terminal changes to the data type color of the control to indicate that you connected the terminal You also can select the control or indicator first and then select the terminal ny Note Although you use the Wiring tool to assign terminals on the connector pane to front panel controls and indicators no wires are drawn between the connector pane and these controls and indicators LabVIEW Introduction Course Manual 2 8 ni com Lesson2 Modular Programming Exercise 2 1 Convert C to F VI Objective To create a VI and the icon and connector pane needed to use as a subVI Complete the following steps to create a VI that takes a number representing degrees Celsius and converts it to a number representing degrees Fahrenheit Front Panel
147. e are also described You Will Learn A About making decisions with the Select function B How to use the Case structure C How to use the Formula Node National Instruments Corporation 7 1 LabVIEW Introduction Course Manual Lesson Making Decisions ina VI A Making Decisions with the Select Function Select Function gt Every VI described in this course so far has executed in an order dependent on the flow of data There are cases when a decision must be made in a program For example if a happens do b else if c happens do d In text based programs this can be accomplished with if else statements case statements switch statements and so on LabVIEW includes many different ways of making decisions The simplest of these methods is the Select function The Select function located on the Functions Express Comparison palette selects between two values dependent on a Boolean input If the Boolean input s is TRUE this function returns the value wired to the t input If the Boolean input is FALSE this function returns the value wired to the f input You used the Select function in Exercise 2 2 Thermometer VI to determine whether to output a Fahrenheit value or a Celsius value as shown in the following block diagram Temp Scale X Temperature DAG Assistant data If the decision to be made is more complex than a Select function can execute a Case structure may be required LabVIEW Introduction Cour
148. e control on the front panel Click an open space on the front panel The marquee disappears and the terminal changes to the data type color of the control to indicate that you connected the terminal Click the right terminal in the connector pane and click the deg F indicator Click an open space on the front panel Both terminals of the connector pane are orange Move the cursor over the connector pane The Context Help window shows that both terminals are connected to double precision floating point values 21 Save and close the VI You will use this VI later in the course End of Exercise 2 1 National Instruments Corporation 2 13 LabVIEW Introduction Course Manual Lesson2 Modular Programming C Using SubVis After you build a VI and create its icon and connector pane you can use the VI as asubVI To place a subVI on the block diagram select Functions All Functions Select a VI Navigate to the VI you want to use as a subVI and and double click to place it on the block diagram You also can place an open VI on the block diagram of another open VI Use the Positioning tool to click the icon in the upper right corner of the front panel or block diagram of the VI you want to use as a subVI and drag the icon to the block diagram of the other VI Opening and Editing SubVis To display the front panel of a subVI from the calling VI use the Operating or Positioning tool to double click the subVI on the block diagram
149. e function Nodes are objects on the block diagram that have inputs and or outputs and perform operations when a VI runs They are analogous to statements operators functions and subroutines in text based programming languages Nodes can be functions subVIs or structures Structures are process control elements such as Case structures For Loops or While Loops The Add and Subtract functions in Figure 1 9 are function nodes LabVIEW Introduction Course Manual 1 22 ni com Lesson1 Introduction to LabVIEW Expandable Nodes versus Icons You can display VIs and Express VIs as icons or as expandable nodes Expandable nodes appear as icons surrounded by a colored field SubVIs appear with a yellow field and Express VIs appear with a blue field Use icons such as the Basic Function Generator VI icon shown at left if you want to conserve space on the block diagram Use expandable nodes such as the Basic Function Generator VI expandable node shown at left to make wiring easier and to aid in documenting block diagrams By default subVIs appear as icons on the block diagram and Express VIs appear as expandable nodes To display a subVI or Express VI as an expandable node right click the subVI or Express VI and select View As Icon from the shortcut menu to remove the checkmark You can resize the expandable node to make wiring even easier but it also takes a large amount of space on the block diagram Complete the following steps to
150. e graph a Click the Zoom button on the graph palette shown at left to display the Zoom pull down menu b Select Zoom by X Rectangle as shown in the following example c Click and drag a selection rectangle on the graph When you release the mouse button the graph display zooms in on the selected area d You also can select Zoom by Y Rectangle or Zoom by Selected Area Experiment with these options e Select Undo Zoom from the lower left corner of the pull down menu to undo a zoom or click the x axis single fit button and the y axis ET single fit button on the scale legend shown at left 21 Use the Panning tool shown at left to click and drag the graph display Click the x axis and y axis single fit buttons again to restore the display to its original position 22 Use the Cursor Movement tool shown at left to return the cursor to standard mode 23 Save and close the VI End of Exercise 6 3 LabVIEW Introduction Course Manual 6 20 ni com Lesson6 Plotting Data Exercise 6 4 Temperature Analysis VI Objective To graph and analyze data Complete the following steps to build a VI that measures temperature every 0 25 seconds for 10 seconds During the acquisition the VI displays the measurements in real time on a waveform chart After the acquisition is complete the VI plots the data on a graph and calculates the minimum maximum and average temperatures The VI displays the best fit of the temperature
151. e shortcut menu to display the Graph Properties dialog box On the Plots tab select Sawtooth from the pull down menu Click the Line Color color box to display the color picker Select a new line color Select Sawtooth Scaled from the pull down menu 6 Place a checkmark in the Don t use waveform names for plot names National Instruments Corporation checkbox Inthe Name text box delete the current label and change the name of this plot to Scaled Sawtooth Click the OK button to apply the current configuration and close the Graph Properties dialog box Notice how the plot color on the front panel changes Experiment with other properties of the graph by using the Graph Properties dialog box For example try disabling the autoscale feature located on the Scales tab 1 37 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW 10 Click the Cancel button to avoid applying the changes you made while experimenting If you want to keep the changes you made click the OK button 11 Save and close this VI End of Exercise 1 1 LabVIEW Introduction Course Manual 1 38 ni com Lesson1 Introduction to LabVIEW E Dataflow Programming LabVIEW follows a dataflow model for running VIs A block diagram node executes when all its inputs are available When a node completes execution it supplies data to its output terminals and passes the output data to the next node in the dataflow path Visual Bas
152. e transmission is to be even or odd If the parity is chosen to be odd the transmitter then sets the parity bit in such a way as to make an odd number of ones among the data bits and the parity bit This transmission uses odd parity There are five ones among the data bits already an odd number so the parity bit is set to 0 The last part of a character frame consists of 1 1 5 or 2 stop bits These bits are always represented by a negative voltage If no further characters are transmitted the line stays in the negative MARK condition The transmission of the next character frame if any is heralded by a start bit of positive SPACE voltage LabVIEW Introduction Course Manual 10 26 ni com Lesson 10 Instrument Control How Fast Can Transmit Knowing the structure of a character frame and the meaning of baud rate as it applies to serial communication you can calculate the maximum transmission rate in characters per second for a given communication setting This rate is just the baud rate divided by the bits per frame In the previous example there are a total of eleven bits per character frame If the transmission rate is set at 9 600 baud you get 9 600 11 872 characters per second Notice that this is the maximum character transmission rate The hardware on one end or the other of the serial link might not be able to reach these rates for various reasons Hardware Overview There are many different recommended standards o
153. easurement system e The DAQ device is external and connects to the computer through an existing port such as the serial port or Ethernet port which means you can quickly and easily place measurement nodes near sensors The computer receives raw data through the DAQ device The application you write presents and manipulates the raw data in a form you can understand The software also controls the DAQ system by commanding the DAQ device when and from which channels to acquire data Typically DAQ software includes drivers and application software Drivers are unique to the device or type of device and include the set of commands the device accepts Application software such as LabVIEW sends the drivers commands such as acquire and return a thermocouple reading The application software also displays and analyzes the acquired data NI measurement devices include NI DAQ driver software a collection of VIs you use to configure acquire data from and send data to the measurement devices LabVIEW Introduction Course Manual 9 2 ni com Lesson9 Data Acquisition and Waveforms NI DAQ NI DAQ 7 0 contains two NI DAQ drivers Traditional NI DAQ and NI DAQmx each with its own application programming interface API hardware configuration and software configuration e Traditional NI DAQ is an upgrade to NI DAQ 6 9 x the earlier version of NI DAQ Traditional NI DAQ has the same VIs and functions and works the same way as NI DAQ 6 9 x You
154. ecified for the task in the DAQ Assistant Express VI Save the VI 6 Close the block diagram but leave the front panel open Front Panel 7 Open the Voltmeter VI that you completed in Exercise 9 2 Configure the meter scale minimum to 0 0 and maximum to 10 0 LabVIEW Introduction Course Manual 9 26 ni com Lesson9 Data Acquisition and Waveforms Block Diagram 9 Display the block diagram for the Voltmeter VI and double click the DAQ Assistant Express VI to open the Analog Input Voltage Task Configuration dialog box 10 Right click Voltage in the Channel List section and select Change Physical Channel Select ail for the channel because you wired the DAQ signal accessory to output a voltage on Analog Out CHO and acquire the voltage from Analog In CH1 11 Select No Scale from the Custom Scaling pull down menu 12 Change the voltage range to 0 to 10 13 Click the OK button to close the dialog box 14 Display the front panel and run the Voltmeter VI 15 To acquire and display the voltage output run the Voltage Output VI The Voltage Output VI outputs the voltage in 0 5 V increments from 0 to 9 5 V When the For Loop executes its last iteration the VI outputs 0 V to reset the analog output channel voltage voltage Gutpuk 4 25 16 Close both VIs End of Exercise 9 5 National Instruments Corporation 9 27 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms F Counters A count
155. ecution at that location Use the Probe tool shown at left to create probes on wires on the block diagram Use the Probe tool to check intermediate values in a VI that produces questionable or unexpected results Use the Color Copy tool shown at left to copy colors for pasting with the Coloring tool Use the Coloring tool shown at left to color an object It also displays the current foreground and background color settings National Instruments Corporation 1 13 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW Controls and Functions Palettes The Controls and Functions palettes contain subpalettes of objects you can use to create a VI When you click a subpalette icon the entire palette changes to the subpalette you selected To use an object on the palettes click the object and place it on the front panel or block diagram The Controls palette shown in Figure 1 4 is available only on the front panel The Controls palette contains the controls and indicators you use to build the front panel Refer to the Front Panel section of this lesson for more information about the using the Controls palette on the front panel The controls and indicators located on the Controls palette depend on the palette view currently selected ip Controls sede o Mum Cbrls Buttons Text Ctrls User Ctrls b b Mum Inds LEDs Text Inds Graph Inds All Controls Figure 1 4 Controls Palette The Functions palet
156. ed F3 Remote Systems rg Attributes BA Device Routes El Calibration Devi PFIS Devi PFIE Devi PFI1 Dew PFIZ Dewi PFIF Devi PFIS Destinations Devi PFIO Dev1 PFIS Dev PFI4 Dev1 PFI9 Dev 1 IRTSIO LabVIEW Introduction Course Manual 9 8 ni com Lesson9 Data Acquisition and Waveforms 4 The Calibration tab provides information about the last time the device was calibrated both internally and externally PCI 6024E Devi Measurement amp Automation Explorer File Edit View Tools Help Configuration Ee Properties aself Test MA Test Panels 7 Show Help FA My System Data Neighborhood Eg Devices and Interfaces Traditional NI DAQ Devices E PCI 6024E Device 1 PXI PHI System 0 Unidentified MI DAQmx Devices i FPCI 6024E Devi GPIBO PCI GPIE a Ports Serial amp Parallel ja I T Instruments 3 Scales Fl Historical Data Software EJ VI Logger Tasks 3 Remote Systems External Calibration Last Calibration Date Expiration D ate Temperature Comments Self Calibration Last Calibration D ate 31872003 9 45 AM Temperature 25 E y Attributes E Device Routes El Calibration 5 Right click the NI DAQmx device in the configuration tree and select Self Calibrate to calibrate the DAQ device using a precision voltage reference source and update the built in calibration constants Once the device has been calibrated the Self Ca
157. ed State Enabled Disabled Disabled amp grayed Meedle1 Add Delete Colors Show digital display s E Needle P Show radix Show increment decrement buttons Cancel Help Figure 1 7 Meter Property Dialog Box National Instruments Corporation 1 17 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW C Front Panel The front panel is the user interface of the VI Figure 1 8 shows an example of a front panel f z If Power Spectrum Measurement yvi Front Panel File Edit Operate Tools Browse Window Help at ipt Application Font leif Zarfi eS Power Spectrum Plot 0 0 0 Frequency Hz Tis 4000 6000 2000 8000 ra i S 0 10000 r ri Hannin J g 20 0 averaging parameters Pa er ee eee eae See Sanaa Smear 40 0 averaging mode Himo averaging 60 0 weighting mode Exponential 80 0 umber of averages 100 0 A 10 Armplitude Y Bi 1 00 120 0 Trigger L Completed Done es 2000 4000 angg 3000 10000 1 D Frequency Hz gE y a im iON Es tf r 7 Figure 1 8 Example of a Front Panel Controls and Indicators You build the front panel with controls and indicators which are the interactive input and output terminals of the VI respectively Controls are knobs push buttons dials and other input devices Indicators are graphs
158. ee ef uy e The Concatenate Strings function returns the following string The quick brown fox jumped over the lazy dog String Subset Returns the substring of the input string beginning at offset and containing length number of characters The offset of the first character in string is 0 For example if you use the previous string as the input the String Subset function returns the following substring for an offset of 4 and a length of 5 quick Match Pattern Searches for regular expression in string beginning at offset and if it finds a match splits string into three substrings If no match is found match substring is empty and offset past match is 1 For example use a regular expression of and use the following string as the input VOLTS DC 4 1 22863E 1 The Match Pattern function returns a before substring of VOLTS DC a match substring of an after substring of 1 22863E 1 and an offset past match of 9 Converting Numeric Values to Strings with the Build Text Express VI Use the Build Text Express VI to convert numeric values into strings The Build Text Express VI located on the Functions Output palette concatenates an input string If the input is not a string this Express VI converts the input into a string based on the configuration of the Express VI LabVIEW Introduction Course Manual 8 4 ni com Lesson 8 Strings and File I O When you place the Build Text Express VI on the block diagram the C
159. el of the Controls and Functions palettes Instead toolsets and modules install on the All Controls and All Functions subpalettes In the Advanced palette view toolsets and modules install subpalettes on the top level Click the Options button on the Controls or Functions palette to change to another palette view or format Numeric Controls and Indicators The two most commonly used numeric objects are the numeric control and the numeric indicator as shown in the following illustration 1 Increment and Decrement Buttons 3 Numeric Indicator 2 Numeric Control To enter or change values in a numeric control click the increment and decrement buttons with the Operating tool or double click the number with either the Labeling tool or the Operating tool type a new number and press the lt Enter gt key National Instruments Corporation 1 19 LabVIEW Introduction Course Manual Lesson1 Introduction to LabVIEW Boolean Controls and Indicators Use Boolean controls and indicators to enter and display Boolean TRUE or FALSE values Boolean objects simulate switches push buttons and LEDs The most common Boolean objects are the vertical toggle switch and the round LED as shown in the following example Vertical Toggle Switch Found LED n LabVIEW Introduction Course Manual 1 20 ni com Lesson1 Introduction to LabVIEW D Block Diagram After you build the front panel you add code using graphical representations of funct
160. er you do not have accurate control over the time between each sample or channel Instead you can use hardware timing which uses a buffer in computer memory to acquire data more efficiently Programmatically you need to include the timing function and specify the sample rate and the sample mode finite As with other functions you can acquire multiple samples for a single channel or multiple channels With NI DAQm x you also can gather data from multiple channels For instance you might want to monitor both the fluid level in the tank and the temperature In such a case you need two transducers connected to two channels on the device Acquire Continuously If you want to view process or log a subset of the samples as they are acquired you need to continually acquire samples For these types of applications set the sample mode to continuous When a device controlled by NI DAQmx does something it performs an action Two very common actions are producing a sample and starting a waveform acquisition Every NI DAQm x action needs a stimulus or cause When the stimulus occurs the action is performed Causes for actions are called triggers The start trigger starts the acquisition The reference trigger establishes the reference point in a set of input samples Data acquired up to the reference point is pretrigger data Data acquired after the reference point is posttrigger data LabVIEW Introduction Course Manual 9 14 ni com Lesson
161. er all nodes on the block diagram execute Click the Run button to run the VI When you reach a breakpoint during execution the VI pauses and the Pause button on the toolbar appears red Click the Continue button shown at left to continue running to the next breakpoint or until the VI finishes running Use the Breakpoint tool to click the breakpoints you set and remove them 12 Click the Highlight Execution button to disable execution highlighting 13 Select File Close to close the VI and all open windows End of Exercise 1 4 LabVIEW Introduction Course Manual 1 56 ni com Lesson 1 Introduction to LabVIEW Summary Tips amp Tricks Summary National Instruments Corporation Virtual instruments VIs contain three main components the front panel the block diagram and the icon and connector pane The front panel is the user interface of a VI and specifies the inputs and displays the outputs of the VI The block diagram contains the graphical source code composed of nodes terminals and wires Use the Tools palette to create modify and debug VIs Press the lt Shift gt key and right click to display a temporary version of the Tools palette at the location of the cursor Use the Controls palette to place controls and indicators on the front panel Right click an open space on the front panel to display the Controls palette Use the Functions palette to place VIs and functions on the block diagram R
162. er is a digital timing device You typically use counters for event counting frequency measurement period measurement position measurement and pulse generation A counter contains the following four main components e Count Register Stores the current count of the counter You can query the count register with software e Source An input signal that can change the current count stored in the count register The counter looks for rising or falling edges on the source signal Whether a rising or falling edge changes the count is software selectable The type of edge selected is referred to as the active edge of the signal When an active edge 1s received on the source signal the count changes Whether an active edge increments or decrements the current count is also software selectable e Gate An input signal that determines if an active edge on the source will change the count Counting can occur when the gate is high low or between various combinations of rising and falling edges Gate settings are made in software e QOutput An output signal that generates pulses or a series of pulses otherwise known as a pulse train When you configure a counter for simple event counting the counter increments when an active edge is received on the source In order for the counter to increment on an active edge the counter must be armed or started A counter has a fixed number it can count to as determined by the resolution of the counter
163. er to the Y Multi Plot 1 graph in the Waveform Graph VI in the NI Example Finder for an example of a graph that accepts this data type A multiplot waveform graph also accepts a cluster of an x value a Ax value and a 2D array of y data The graph interprets the y data as points on the graph and increments the x index by Ax starting at x 0 Refer to the Xo dX Y Multi Plot 3 graph in the Waveform Graph VI in the NI Example Finder for an example of a graph that accepts this data type A multiplot waveform graph accepts a cluster of an initial x value a Ax value and an array that contains clusters Each cluster contains a point array that contains the y data You use the Bundle function to bundle the arrays into clusters and you use the Build Array function to build the resulting clusters into an array You also can use the Build Cluster Array which creates arrays of clusters that contain inputs you specify Refer to the Xo dX Y Multi Plot 2 graph in the Waveform Graph VI in the NI Example Finder for an example of a graph that accepts this data type Single Plot XY Graphs The single plot XY graph accepts a cluster that contains an x array and a y array The XY graph also accepts an array of points where a point is a cluster that contains an x value and a y value Refer to the XY Graph VI in the NI Example Finder for an example of single plot XY graph data types Multiplot XY Graphs The multiplot XY graph accepts an arr
164. erarchy The hierarchy sequence of VIs and error handling are the same as those used in other areas of I O in LabVIEW such as file I O DAQ TCP IP and so on Refer to the File I O VIs and Functions section of Lesson 8 Strings and File I O for more information about error handling The following illustration shows the hierarchy of an instrument driver Getting Started DEVSIM ET2TAK E Initialize Application Example DEYSIH E a TL Le Configuration Action Status Data onbir iS Data F FET rls aED Tiras The high level functions are built from the low level functions For the most control over the instrument use the low level functions The high level functions are easy to use and have soft front panels that resemble the instrument Instrument drivers have VIs in the following categories e Initialize lInitializes the communication channel to the instrument This VI also can perform an identification query and reset operation and it can perform any necessary actions to place the instrument in its default power on state or other specified state e Configuration Configures the instrument to perform operations such as setting up the trigger rate National Instruments Corporation 10 19 LabVIEW Introduction Course Manual Lesson 10 Instrument Control e Action Status Contains two types of VIs Action VIs cause the instrument to initiate or terminate test and measurement operations Status VIs
165. eric palette on the block diagram This function returns the square root of Numeric Wire the function as shown in the following block diagram freater Or Equal To 0 amp Number 4 Save the VI as Square Root vi in the C Exercises LabVIEW Basics I directory Run the VI 5 Display the front panel and run the VI J Caution Do not run this VI continuously Under certain circumstances continuously running this VI could result in an endless loop If Numeric is positive the VI executes the TRUE case and returns the square root of Numeric If Numeric is negative the VI executes the FALSE case returns 99999 and displays a dialog box with the message Error Negative Number 6 Close the VI End of Exercise 1 National Instruments Corporation 7 9 LabVIEW Introduction Course Manual Lesson Making Decisions ina VI Exercise 7 2 Temperature Control VI Objective To use the Case structure in a VI Complete the following steps to build a VI that allows the user to analyze data for limit testing and to determine the highest value Front Panel 1 Open the Temperature Running Average VI you created in Exercise 6 2 2 Modify the front panel as shown in the following example Running g B472 Temperature History Current fs 65 59 90 0 58 0 36 0 ANALYSIS a4 0 On g2 p OFF T gan 0 High Lirit e g 168 00 v a5 eo 74 0 72 0 High Value 70 0 69 4031 420 0 421 422 T 4
166. ette on the block diagram This function assembles Small Cluster National Instruments Corporation 5 9 LabVIEW Introduction Course Manual Lesson5 Clusters gt gt Numeric Boolean Run the VI LabVIEW Introduction Course Manual 8 Place the Unbundle by Name function located on the Functions All Functions Cluster palette on the block diagram This function returns two elements from Cluster Resize this function to have two output terminals If a label name is not correct right click the name and select the correct name from the Select Item shortcut menu Place the Increment function located on the Functions All Functions Numeric palette on the block diagram This function adds one to the value of Numeric Place the Not function located on the Functions Arithmetic amp Comparison Express Boolean palette on the block diagram This function returns the logical opposite of the value of the Boolean terminal of the Unbundle by Name function Place the Bundle by Name function located on the Functions All Functions Cluster palette on the block diagram This function replaces the values of Numeric and Boolean in Cluster and creates Modified Cluster Resize this function to have two input terminals If a label name is not correct right click the name and select the correct name from the Select Item shortcut menu Complete the block diagram and wire the objects as shown in the previous figure Sa
167. event the user from selecting a value that is not compatible with a range or increment You can choose to ignore a value that is out of range or coerce it to within the range Complete the following steps to set the range between 0 and 10 000 with an increment of 1 and a default value of 50 2 Right click the Number to Match control and select Data Range from the shortcut menu The Data Range page of the Numeric Properties dialog box appears a Remove the checkmark from the Use Default Range checkbox b Set the Default Value to 50 c Set the Minimum value to 0 and select Coerce from the Out of Range Action pull down menu d Set the Maximum value to 10 000 and select Coerce from the Out of Range Action pull down menu e Set the Increment value to 1 and select Coerce to Nearest from the Out of Range Action pull down menu Do not close the dialog box Modifying Digits of Precision By default LabVIEW automatically formats numeric controls You also can specify the precision or notation You can display numeric values in floating point scientific or SI notation Complete the following steps to change the precision to 0 3 Select the Format and Precision tab If you closed the Numeric Properties dialog box right click the Current Number indicator and select Format amp Precision from the shortcut menu The Format amp Precision page of the Numeric Properties dialog box appears a Select Floating Point and change Significa
168. evious array and the following array The function adds corresponding elements and returns the following array which is the size of the smaller input array You use the Numeric functions with clusters the same way you use them with arrays of numeric values Refer to Lesson 5 Clusters for more information about clusters gt e gt e gt LabVIEW Introduction Course Manual 4 8 ni com Exercise 4 1 Lesson4 Arrays Array Exercise VI Objective To create arrays and become familiar with the Array functions Complete the following steps to build a VI that creates an array of random numbers scales the resulting array and takes a subset of that final array Front Panel l Open a blank VI and build the following front panel National Instruments Corporation Place an array located on the Controls All Controls Array amp Cluster palette on the front panel Label the array Random Array Place a numeric indicator located on the Controls Numeric Indicators palette in the array shell Use the Positioning tool to resize the array control to contain 10 numeric indicators Press the lt Ctrl gt key while you click and drag the Random Array control to create two copies of the control Label the copies Final Array and Subset Array Place three numeric controls located on the Controls Numeric Controls palette and label them Scaling Factor Start Subset and of Elements Rig
169. f the box o MODE DATA FORMAT BAUD RATE T T GPIB ADDRESS G MODE These switch settings configure the instrument as a serial device with the following settings e Baud rate 9 600 e Data bits 8 e Parity no parity e Stop bits 1 e Flow control parameters hardware handshaking Handshaking is a means of data flow control Software handshaking involves embedding control characters in transmitted data For example XON XOFF flow control works by enclosing a transmitted message between the two control characters XON and XOFF Hardware handshaking uses voltages on physical wires to control data flow The RTS and CTS lines of the RS 232 device are frequently used for this purpose Most lab equipment uses hardware handshaking 2 Make sure the NI Instrument Simulator is connected to a serial port on the computer with a serial cable Make a note of the port number 3 Power on the NI Instrument Simulator The Power Ready and Listen LEDs are lit to indicate that the device 1s in serial communication mode National Instruments Corporation 10 31 LabVIEW Introduction Course Manual Lesson 10 Instrument Control Block Diagram 4 Open a blank VI and build the following block diagram Instrument Iio Sk Length Assistant ag Eng error out String Length String Error in a Place the Instrument I O Express VI located on the Functions Input palette on the block diagram Complete the following ste
170. f serial port communication including the following most common types RS 232 The RS 232 is a standard developed by the Electronic Industries Association EIA and other interested parties specifying the serial interface between Data Terminal Equipment DTE and Data Communications Equipment DCE The RS 232 standard includes electrical signal characteristics voltage levels interface mechanical characteristics connectors functional description of interchange circuits the function of each electrical signal and some recipes for common kinds of terminal to modem connections The most frequently encountered revision of this standard is called RS 232C Parts of this standard have been adopted with various degrees of fidelity for use in serial communications between computers and printers modems and other equipment The serial ports on standard IBM compatible personal computers follow RS 232 RS 449 RS 422 RS 423 The RS 449 RS 422 and RS 423 are additional EIA serial communication standards related to RS 232 RS 449 was issued in 1975 and was supposed to supersede RS 232 but few manufacturers have embraced the newer standard RS 449 contains two subspecifications called RS 422 and RS 423 While RS 232 modulates a signal with respect to a common ground or single ended transmission RS 422 modulates two signals against each other or differential transmission The RS 232C receiver senses whether the received signal is sufficientl
171. f the 2D array so element i j becomes element j i as follows S N C LabVIEW Introduction Course Manual 8 14 ni com ETERS Ly k TAT Al iy Note 5 Lesson 8 Strings and File 1 0 The Write To Spreadsheet File VI located on the Functions All Functions File I O palette formats the 2D array into a spreadsheet string and writes the string to a file The string has the following format where an arrow indicates a tab and a paragraph symbol q indicates an end of line character S N C gt q gt q gt gt q eE The Number To Fractional String function located on the Functions All Functions String String Number Conversion palette converts an array of numeric values to an array of strings that the table displays Close the VI Do not save changes This example stores only three arrays in the file To include more arrays increase the number of inputs to the Build Array function Optional National Instruments Corporation Open the wave txt file using a word processor or spreadsheet application and view its contents 6 Open a word processor or spreadsheet application such as Windows Notepad or WordPad Mac OS SimpleText or UNIX Text Editor Open wave txt The sine waveform data appear in the first column the random waveform data appear in the second column and the cosine waveform data appear in the third column Exit the word processor or spreadsheet application
172. f the icon appears in the appropriate box to the right of the editing area as shown in the following dialog box If Icon Editor File Edit Help Black amp White 16 Colors 16 Colors 256 Colors Show Terminals 256 Colors K Cancel Depending on the type of monitor you use you can design a separate icon for monochrome 16 color and 256 color mode LabVIEW uses the monochrome icon for printing unless you have a color printer Use the Edit menu to cut copy and paste images from and to the icon When you select a portion of the icon and paste an image LabVIEW resizes the image to fit into the selection area You also can drag a graphic from anywhere in your file system and drop it in the upper right corner of the front National Instruments Corporation 2 5 LabVIEW Introduction Course Manual Lesson2 Modular Programming panel or block diagram LabVIEW converts the graphic to a 32 x 32 pixel icon Use the Copy from option on the right side of the Icon Editor dialog box to copy from a color icon to a black and white icon and vice versa After you select a Copy from option click the OK button to complete the change Kp Note If you do not draw a complete border around a VI icon the icon background appears transparent When you select the icon on the block diagram a selection marquee appears around each individual graphic element in the icon Use the tools on the left side of the Icon Editor dialog box to create t
173. for VIs have white backgrounds and icons for functions have pale yellow backgrounds By default most functions and VIs on the block diagram appear as icons that are not expandable unlike Express VIs Express VIs Use Express VIs for common measurement tasks Express VIs are nodes that require minimal wiring because you configure them with dialog boxes You can save the configuration of an Express VI as a subVI Refer to Chapter 5 Building the Block Diagram of the LabVIEW User Manual for more information about creating subVIs from Express VIs Vis When you place a VI on the block diagram LabVIEW considers the VI to be a subVI When you double click a subVI its front panel and block diagram appear rather than a dialog box in which you can configure options The front panel includes controls and indicators The block diagram includes wires front panel icons functions possibly subVIs and other LabVIEW objects The upper right corner of the front panel and block diagram displays the icon for the VI This is the icon that appears when you place the VI on the block diagram You can create a VI to use as a subVI Refer to Lesson 2 Modular Programming of this manual for more information about creating VIs and configuring them as subVIs Functions Functions are the fundamental operating elements of LabVIEW Functions do not have front panels or block diagrams but do have connector panes Double clicking a function only selects th
174. generated Kp Note Once an Express VI has been converted to a subVI it cannot be converted back LabVIEW Introduction Course Manual 10 10 ni com Lesson 10 Instrument Control Exercise 10 2 Using the Instrument I O Assistant Objective To build a VI that uses the Instrument 1 0 Assistant to communicate with a GPIB interface Complete the following steps to build a VI that acquires data from the NI Instrument Simulator Front Panel 1 Open a blank VI 2 The following front panel will result from building the block diagram ID String National Instruments GPIB and Serial Device Simulator Rew B 1 voltage 4 84 Block Diagram 3 Display and build the following block diagram Instrument Io Assistant error out t voltage ID String a Place the Instrument I O Assistant Express VI located on the are imal Functions Input palette on the block diagram Complete the following steps to configure the Express VI in the Instrument I O Assistant dialog box 1 Select devsim from the Select an instrument pull down menu and select VISA Code Generation from the Code generation type pull down menu 2 Click the Add Step button Click Query and Parse to write and read from the Instrument Simulator 3 Type IDN as the command select n as the Termination character and click the Run this step button If no error warning appears in the lower half of the dialog box this step has successfully completed
175. gisters before the loop starts a b Place the Compound Arithmetic function located on the E Functions Arithmetic amp Comparison Express Numeric palette on the block diagram This function returns the sum of the current temperature and the two previous temperature readings Use the Positioning tool to resize the function to have three left terminals National Instruments Corporation 6 9 LabVIEW Introduction Course Manual Lesson6 Plotting Data E gt c Place the Divide function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram This function returns the average of the last three temperature readings nr d Right click the y terminal of the Divide function select Create Constant type 3 and press the lt Enter gt key 7 Save the VI Run the VI 8 Run the VI During each iteration of the While Loop the Thermometer VI takes one temperature measurement The VI adds this value to the last two measurements stored in the left terminals of the shift register The VI divides the result by three to find the average of the three measurements the current measurement plus the previous two The VI displays the average on the waveform chart Notice that the VI initializes the shift register with a temperature measurement Block Diagram 9 Modify the block diagram as shown in the following illustration Compound Arithmetic Temperature History Wait Until Next ms Multiple
176. graph Front Panel l Temperature Chart l l 2 00 4 00 Time sec a b National Instruments Corporation Open a blank VI and build the front panel 6 00 a o Temperature raph Temp Fitted Mean z 0z l l 2 00 10 00 Set the point style of the waveform chart plot to a small x Hide the plot legend of the waveform chart Change the label of the waveform chart to Temperature Chart Change the label of the waveform graph to Temperature Graph Right click Temperature Chart select X Scale Formatting from the shortcut menu and change AX to 0 25 and Digits of Precision to 2 The data for Temperature Graph will be formatted on the block diagram Use the Positioning tool to resize the plot legend of the waveform graph Change the name of Plot 0 to Temp and Plot 1 to Fitted Set the point style of the waveform graph Temp plot to a small square Do not create the Mean Max and Min indicators yet They will be created from the block diagram 6 21 LabVIEW Introduction Course Manual Lesson6 Plotting Data Block Diagram 2 Build the following block diagram im T T E iaaa ofa aE Anas Hean LabVIEW Introduction Course Manual Array Max amp Min Temperature Chart Wait Until Neck ms Multiple mH Temperature Graph J Build Array General Bundle Polynomial Fit vi Place the Thermometer VI on the block diagram Select Functions All Functions Select a
177. graph Y Array Resulting Graph 1D Single Flot WOT Single Flat 2D Mult iplot WOT Cwaveform Data Type includes timing info Others default to 0 for x and 1 for ax Combine timing information using a bundle node sg Waveform Graph Y array See the example Waveform Graph vi 3 Save the VI as Graph Waveform Array vi inthe C Exercises LabVIEW Basics I directory National Instruments Corporation 6 17 LabVIEW Introduction Course Manual Lesson6 Plotting Data Run the VI 4 Display the front panel and run the VI The VI plots the auto indexed waveform array on the waveform graph 5 Enter the index of any element in the Waveform Array index display to view the value of that element If you enter a number greater than the array size of 100 the display dims 6 Use the Positioning tool to resize Waveform Array to view more than one element The indicator displays elements in ascending index order beginning with the index you entered Block Diagram In this block diagram you use the default value of the initial x and Ax value for the waveform In cases where the initial x and Ax value are a specific value use the Bundle function to specify an initial x and Ax value for a waveform array 7 Modify the block diagram as shown in the following figure waveform Array Functions Cluster palette on the block diagram This function assembles the plot elements into a single cluster The elements include the init
178. hanges to the OFF position and changes back to ON after the conditional terminal reads the value 16 Save the VI You will use this VI in Exercise 6 2 End of Exercise 6 1 LabVIEW Introduction Course Manual 6 8 ni com Lesson6 Plotting Data Exercise 6 2 Temperature Running Average VI Objective To use shift registers to perform a running average Complete the following steps to modify the Temperature Monitor VI to average the last three temperature measurements and display the average on a waveform chart Front Panel Open the Temperature Monitor VI that you built in Exercise 6 1 2 Select File Save As and rename the VI Temperature Running Average vi inthe C Exercises LabVIEW Basics I directory Block Diagram 3 Display the block diagram 4 Right click the right or left border of the While Loop and select Add Shift Register from the shortcut menu to create a shift register 5 Right click the left terminal of the shift register and select Add Element from the shortcut menu to add an element to the shift register 6 Modify the block diagram as follows Compound Arithmetic Temperature history Wait Until West ms Multiple millisecond multiple A ME aa a Press the lt Ctrl gt key while you click the Thermometer VI and drag Temp j i it outside the While Loop to create a copy of the subVI The Thermometer VI returns one temperature measurement from the temperature sensor and initializes the left shift re
179. hannel Rename existing File One column only Use next available file name Empty time column O 4ppend to File O overwrite File Delimiter Tab Save to series of files multiple Files Settings comma File Description SO This VI creates a 1vm file which you can open in a spreadsheet application The following figure shows an example of the spreadsheet created by the previous configuration of the Write LabVIEW Measurement File Express VI O 0 385055 1 0 23516 2 0 985184 3 0 177093 al 0 935915 Refer to Lesson 9 Data Acquisition and Waveforms of this manual for more information about the Write LabVIEW Measurement File and Read LabVIEW Measurement File Express VIs National Instruments Corporation 8 25 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O Exercise 8 5 Temperature Logger VI Objective To save data to a file in a form that a spreadsheet or a word processor can access Complete the following steps to build a VI that saves the time and current temperature to a data file Block Diagram 1 Open the Temperature Control VI which you built in Exercise 7 2 and Save it as Temperature Logger viinthecC Exercises LabVIEW Basics I directory You do not need to modify the front panel 2 Open and modify the block diagram as shown in the following example Resize the While Loop to add space at the top for the file I O operations prompt Enter Fi
180. haracter offset and converts the data to a 2D single precision array of numbers Click here for more help Figure 1 11 Detailed Context Helo Window A Click the Lock Context Help button to lock the current contents of the Context Help window When the contents are locked moving the cursor over another object does not change the contents of the window To unlock the window click the button again You also can access this option from the Help menu If a corresponding LabVIEW Help topic exists for an object the Context Help window describes a blue Click here for more help link appears in the Context Help window Also the More Help button shown at left is enabled Click the link or the button to display the LabVIEW Help for more information about the object LabVIEW Help You can access the LabVIEW Help either by clicking the More Help button in the Context Help window selecting Help VI Function amp How To Help or clicking the blue Click here for more help link in the Context Help window The LabVIEW Help contains detailed descriptions of most palettes menus tools VIs and functions The LabVIEW Help also includes step by step instructions for using LabVIEW features The LabVIEW Help includes links to the following resources e LabVIEW Bookshelf which includes PDF versions of all the LabVIEW manuals and Application Notes e Technical support resources on the National Instruments Web site such as the NI Develo
181. he Simple Error Handler VI located on the Functions All Functions Time amp Dialog palette on the block diagram This function checks the error cluster and displays a dialog box if an error Occurs f Complete the block diagram as shown in the previous figure 3 Save the VI as File Writer vi inthe C Exercises LabVIEW Basics I directory Run the VI 4 Change the values of the front panel controls and run the VI An Enter Filename dialog box appears 5 Type demofile txt and click the Save or OK button to save the file The VI writes the String to Write Numeric to Write and Unit to Write values to the file 6 Close the VI End of Exercise 8 3 LabVIEW Introduction Course Manual 8 20 ni com Exercise 8 4 Lesson 8 Strings and File 1 0 File Reader VI Objective To build a VI that reads data from a file Complete the following steps to build a VI that reads the file created in Exercise 8 3 and displays the information in a string indicator Front Panel l Block Diagram Open a blank VI and build the following front panel using the file path control located on the Controls Text Controls palette and a string indicator located on the Controls Text Indicators palette File Path E C Xexerciges l Basics I4demoftile tet String Read from File The measurement ig 12 4500 Volts 2 Build the following block diagram FILE eas f R National Instruments Corporation prompt Selec
182. he column elements as shown in the following example LabVIEW Introduction Course Manual 4 4 ni com Lesson4 Arrays Using Auto Indexing to Set the For Loop Count If you enable auto indexing on an array wired to a For Loop input terminal LabVIEW sets the count terminal to the array size so you do not need to wire the count terminal In the following example the For Loop executes a number of times equal to the number of elements in the array Normally if the count terminal of the For Loop is not wired the run arrow is broken However in this case the run arrow is not broken i Auto Index Input vi Block Diagram Seles File Edit Operate Tools Browse Window Help mE bale 22 Pet topictonrone JR If you enable auto indexing for more than one tunnel or if you wire the count terminal the count changes to the smaller of the two For example if you wire an array with 10 elements to a For Loop input tunnel and you set the count terminal to 15 the loop executes only 10 times National Instruments Corporation 4 5 LabVIEW Introduction Course Manual Lesson4 Arrays C Array Functions O Use the Array functions located on the Functions All Functions Array palette to create and manipulate arrays The more commonly used array functions include the following e Array Size Returns the number of elements in each dimension of an array If the array is n dimensional the size output is an array of n elements F
183. he icon design in the editing area The normal size image of the icon appears in the appropriate box to the right of the editing area The following tasks can be performed with these tools Use the Pencil tool to draw and erase pixel by pixel Use the Line tool to draw straight lines To draw horizontal vertical and diagonal lines press the lt Shift gt key while you use this tool to drag the Cursor Use the Color Copy tool to copy the foreground color from an element in the icon Use the Fill tool to fill an outlined area with the foreground color Use the Rectangle tool to draw a rectangular border in the foreground color Double click this tool to frame the icon in the foreground color Use the Filled Rectangle tool to draw a rectangle with a foreground color frame and filled with the background color Double click this tool to frame the icon in the foreground color and fill it with the background color a Use the Select tool to select an area of the icon to cut copy move or make other changes Double click this tool and press the lt Delete gt key to delete the entire icon Use the Text tool to enter text into the icon Double click this tool to select a different font Windows The Small Fonts option works well in icons Use the Foreground Background tool to display the current foreground and background colors Click each rectangle to display a color palette from which you can select new colors LabVIEW Introduct
184. hird dimension a scale similar to a color ramp control defines the range and mappings of values to colors The following illustration shows the elements of an intensity graph LabVIEW Introduction Course Manual 6 26 ni com Lesson6 Plotting Data Intensity Graph apnyjduiy u a cc mu T D LL 0 00 0 00 Frequency th ay aoo o00 Amplitude FEE 1 Y scale 3 Scale Legend 5 Graph Palette 2 X scale 4 Cursor Legend 6 Z scale Color Ramp Use the Operating or Positioning tools to right click the marker next to the color ramp select Marker Color from the shortcut menu to change the color associated with a marker and select the color you want from the color picker that appears To add markers to a color ramp right click the color ramp and select Add Marker from the shortcut menu To change the value of an arbitrary marker on a color ramp use the Operating tool to drag the marker to the value you want or use the Labeling tool to highlight the text of the marker and enter a new value National Instruments Corporation 6 27 LabVIEW Introduction Course Manual Lesson6 Plotting Data Exercise 6 6 Intensity Graph Example VI Optional Objective To use an intensity graph In this exercise you use a VI that displays a wave interference pattern on an intensity graph You also use the VI to plot a 2D array of data on the graph Front Panel 1 Open and run the Intensity Graph Example VI located in the C Exercises Lab
185. ht click the Start Subset and of Elements controls and select Representation I32 from the shortcut menu Do not change the values of the front panel controls 4 9 LabVIEW Introduction Course Manual Lesson4 Arrays Block Diagram 2 Build the following block diagram Run the VI 5 Random Array Final Array Array Subset Subset Array Scaling Factor a Place the Random Number 0 1 function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram This function generates a random number between 0 and 1 b Place the For Loop located on the Functions All Functions Structures palette on the block diagram The loop accumulates an array of 10 random numbers at the output tunnel Create a constant of 10 for the count terminal c Place the Multiply function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram In this exercise this function multiplies Random Array by Scaling Factor and returns Final Array d Place the Array Subset function located on the Functions All Functions Array palette on the block diagram This function returns a portion of an array starting at Start Subset and containing of Elements elements Save the VI as Array Exercise vi in the C Exercises LabVIEW Basics I directory Display the front panel change the values of the controls and run the VI a few times The For Loop runs f
186. ial x value 20 the Ax value 0 5 and the y array of waveform data a Place the Bundle function located on the Functions All b Create two numeric constants for the initial x value and Ax value c Label the Ax constant by typing Dx Use the Labeling tool to select the D and select the Symbol font from the Text Settings pull down menu on the toolbar D converts to the delta symbol A d Wire the block diagram as shown in the previous figure 8 Save the VI LabVIEW Introduction Course Manual 6 18 ni com Lesson6 Plotting Data Run the VI 9 Display the front panel and run the VI The graph displays the same 100 points of data with a starting value of 20 and a Ax of 0 5 for each point on the x axis In a timed test this graph would correspond to 50 seconds worth of data starting at 20 seconds Ky Note Change the initial x and Ax values in only one location either the Bundle function or in the Waveform Graph Properties dialog box 10 If time permits complete the optional steps Otherwise close the VI Optional 11 Right click the waveform graph and select Visible Items Graph Palette from the shortcut menu to display the graph palette Click the Zoom button to see the data on the graph in more detail 12 Right click the graph and select Visible Items Scale Legend from the shortcut menu to display the scale legend 13 Return to the block diagram Create a multiple plot waveform graph by building a 2D
187. ic C JAVA and most other text based programming languages follow a control flow model of program execution In control flow the sequential order of program elements determines the execution order of a program For a dataflow programming example consider a block diagram that adds two numbers and then subtracts 50 0 from the result of the addition In this case the block diagram executes from left to right not because the objects are placed in that order but because the Subtract function cannot execute until the Add function finishes executing and passes the data to the Subtract function Remember that a node executes only when data are available at all of its input terminals and it supplies data to its output terminals only when it finishes execution Number 1 EET E gt gt Result Number 2 DELH In the following example consider which code segment would execute first the Add Random Number or Divide function You cannot know because inputs to the Add and Divide functions are available at the same time and the Random Number function has no inputs In a situation where one code segment must execute before another and no data dependency exists between the functions use other programming methods such as error clusters to force the order of execution Refer to the Error Handling section of Lesson 5 Clusters of this manual for more information about error clusters Number 1 Result 1 National Instruments Corp
188. ifferent modes to scroll data as shown in the following front panel Right click the chart and select Advanced Update Mode from the shortcut menu Select Strip Chart Scope Chart or Sweep Chart The default mode is Strip Chart Strip Chart Scope Chart Sweep Chart trip Chart f art Sweep Chart A strip chart shows running data continuously scrolling from left to right across the chart A scope chart shows one item of data such as a pulse or wave scrolling partway across the chart from left to the right A sweep chart is similar to an EKG display A sweep chart works similarly to a scope except it shows the older data on the right and the newer data on the left separated by a vertical line The scope chart and sweep chart have retracing displays similar to an oscilloscope Because there is less overhead in LabVIEW Introduction Course Manual 6 2 ni com Lesson6 Plotting Data retracing a plot the scope chart and the sweep chart display plots significantly faster than the strip chart Wiring Charts You can wire a scalar output directly to a waveform chart The data type in the following waveform chart terminal matches the input data type Waveform charts can display multiple plots Bundle multiple plots together using the Bundle function located on the Cluster palette In the following block diagram the Bundle function bundles the outputs of the three VIs to plot on the
189. ight click an open space on the block diagram to display the Functions palette Use the Search button on the Controls and Functions palettes to search for controls VIs and functions All LabVIEW objects and empty space on the front panel and block diagram have associated shortcut menus which you access by right clicking an object the front panel or the block diagram Use the Help menu to display the Context Help window and the LabVIEW Help which describes most palettes menus tools VIs functions and features Select Help Search the LabVIEW Bookshelf to display the LabVIEW Bookshelf which you can use to search PDF versions of all the LabVIEW manuals and Application Notes You build the front panel with controls and indicators which are the interactive input and output terminals of the VI respectively Control terminals have a thicker border than indicator terminals To change a control to an indicator or to change an indicator to a control right click the object and select Change to Indicator or Change to Control from the shortcut menu The block diagram is composed of nodes terminals and wires 1 57 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW Tips amp Tricks The broken Run button appears on the toolbar to indicate the VI is broken Click the broken Run button to display the Error list window which lists all the errors Use execution highlighting single stepping probes and breakpo
190. ign in MAX instead of the instrument descriptor Mac OS Edit the visaconf ini file to assign a VISA alias UNIX Use the visacon utility LabVIEW Introduction Course Manual 10 14 ni com Lesson 10 Instrument Control If you choose not to use the Instrument I O Assistant to automatically generate code for you you can still write a VI to communicate with the instrument The most commonly used VISA communication functions are the VISA Write and VISA Read functions Most instruments require you to send information in the form of a command or query before you can read information back from the instrument Therefore the VISA Write function is usually followed by a VISA Read function National Instruments Corporation 10 15 LabVIEW Introduction Course Manual Lesson 10 Instrument Control Exercise 10 3 Programming with VISA Objective To build a VI that reads and writes information from the NI Instrument Simulator using VISA functions Complete the following steps to build a VI that uses VISA calls to acquire data from the NI Instrument Simulator 1 Make sure the Instrument Simulator is powered on and connected to the GPIB Interface Front Panel 2 Open a blank VI The following front panel will result from building the block diagram YISA resource name byte count Mo of bytes bo read From the instrument write buffer read buffer Command to write to the instrument Data to read from
191. ile function finishes execution it passes the refnum and error cluster to the Close File function which closes the file The Simple Error National Instruments Corporation 8 17 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O Handler VI examines the error cluster and displays a dialog box if an error occurred If an error occurs in one node subsequent nodes do not execute and the VI passes the error cluster to the Simple Error Handler VI LabVIEW Introduction Course Manual 8 18 ni com Lesson 8 Strings and File I O Exercise 8 3 File Writer VI Objective To write data to a file Complete the following steps to build a VI that concatenates a message string a numeric value and a unit string to a file In Exercise 8 4 you will build a VI that reads the file and displays its contents Front Panel 1 Open a blank VI and build the following front panel String to write File Fath The measurement ig E C exerciges LV q Basics dermotile tst Numeric to Write 12 45 Unit to rite ots a Place a path indicator located on the Controls Text Indicators palette on the front panel This indicator displays the path for the data file you create b Right click the String to Write control and select Visible Items Scrollbar from the shortcut menu to display a scrollbar Block Diagram 2 Build the following block diagram File Path prompt Write File close File Simple Error Handler vi Functio
192. iliarize yourself with the LabVIEW graphical programming environment and the basic LabVIEW features you use to build data acquisition and instrument control applications To view a PDF version of the manual select Help Search the LabVIEW Bookshelf in LabVIEW In the LabVIEW Bookshelf that appears click the Getting Started with LabVIEW link You Will Learn What LabVIEW and virtual instruments are About the LabVIEW environment including windows menus and tools About the LabVIEW front panel About the LabVIEW block diagram About dataflow programming wD About the LabVIEW documentation resources Q TIJA Debugging techniques National Instruments Corporation 1 1 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW A LabVIEW LabVIEW programs are called virtual instruments or VIs because their appearance and operation imitate physical instruments such as oscilloscopes and multimeters LabVIEW contains a comprehensive set of tools for acquiring analyzing displaying and storing data as well as tools to help you troubleshoot your code LabVIEW VIs contain three components the front panel the block diagram and the icon and connector pane This lesson describes the front panel and the block diagram refer to Lesson 2 Modular Programming of this manual for more information about the icon and connector pane In LabVIEW you build a user interface or front panel with controls and indi
193. imilar to the following figure Result Preview Sawtooth Frequency Hz Phase ideg 10 35 Amplitude 1 Add noise Moise type oO OrFsek Duty cycle o Amplitude Uniform White Moise Moise amplitude Seed number 0 1 Timing Samples per second Hz 1000 Ein Time Stamps i Relative to start of measurement Absolute date and time i Simulate acquisition timing Reset Signal Number of samples f Run as Fast as possible Reset phase seed and time stamps Use continuous generation fioo WW Automatic T Integer number of cycles Signal Name Actual number of samples W Use signal type name 100 10 3 4 Signal name Actual Frequency Sawtooth OK Cancel Help Click the OK button to apply the current configuration and close the Configure Simulate Signal dialog box 1 30 ni com a Simulate Signal i Sawkooth I T l l S eee Lesson1 Introduction to LabVIEW Move the cursor over the down arrows at the bottom of the Simulate Signal Express VI When a double headed arrow appears shown at left click and drag the border of the Express VI until the Amplitude input appears Notice how you expanded the Simulate Signal Express VI to display a new input Because the Amplitude input appears on the block diagram you can configure the amplitude of the sawtooth wave on the block diagram In the previous figure notice how Amp
194. in the C Exercises LabVIEW Basics I directory Build a VI that simulates the roll of a die with possible values 1 through 6 and records the number of times that the die rolls each value The input is the number of times to roll the die and the outputs include the number of times the die falls on each possible value Use only one shift register Save the VI as Die Roller vi inthe C Exercises LabVIEW Basics I directory 4 12 ni com Lesson4 Arrays 4 6 Build a VI that generates a 1D array and then multiplies pairs of elements together starting with elements 0 and 1 and returns the nee resulting array For example the input array with values 1 23 10 5 7 11 results in the output array 23 50 77 mK Tip Use the Decimate 1D Array function located on the Functions All Functions Array palette Save the VI as Array Pair Multiplier vi inthe C Exercises LabVIEW Basics I directory National Instruments Corporation 4 13 LabVIEW Introduction Course Manual Lesson4 Arrays Notes LabVIEW Introduction Course Manual 4 14 ni com Lesson 5 Clusters This lesson describes how to use clusters to group data elements of mixed types You Will Learn A About clusters B How to use the Cluster functions C About error clusters National Instruments Corporation 5 1 LabVIEW Introduction Course Manual Lesson5 Clusters A Clusters Clusters group data elements of mixed types such as a bundle of wires as in
195. in the palette Many applications that do not require advanced timing and synchronization can be performed by using the DAQ Assistant Express VI This course describes the use of the DAQ Assistant Express VI to perform data acquisition For more information on using all the features of NI DAQm x refer to the NI DA Qmx Help or attend the LabVIEW Data Acquisition and Signal Conditioning course The DAQ Assistant Express VI allows you to easily configure the data acquisition device When you place the DAQ Assistant Express VI on the block diagram a dialog box appears where you configure a local task to perform a specific measurement function Creating a local task allows you to specify the exact type of measurement to take NI DAQ DAO Assistant Select the measurement type for your task Back Hest C Cancel ly National Instruments Corporation 9 11 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms After you create a task the information for the local task 1s stored in the DAQ Assistant Express VI You can reconfigure the DAQ Assistant Express VI by double clicking the VI and creating a new task LabVIEW Introduction Course Manual 9 12 ni com Lesson9 Data Acquisition and Waveforms C Analog Input Task Timing Use analog input to perform analog to digital A D conversions The available analog input measurement types for a task are voltage temperature strain current resistance or
196. inals that correspond to the controls and indicators of that VI similar to the parameter list of a function call in text based programming languages The connector pane defines the inputs and outputs you can wire to the VI so you can use it as a subVI A connector pane receives data at its input terminals and passes the data to the block diagram code through the front panel controls and receives the results at its output terminals from the front panel indicators As you create VIs you might find that you perform a certain operation frequently Consider using subVIs or loops to perform that operation repetitively For example the following block diagram contains two identical operations LabVIEW Introduction Course Manual 2 2 ni com Lesson2 Modular Programming Compound Arithmetic i Multiply DAQ Assistant p Multiply Add DAQ Assistant pe E gt You can create a subVI that performs that operation and call the sub VI twice The following example calls the Temperature VI as a sub VI twice on its block diagram and functions the same as the previous block diagram You also can reuse the subVI in other VIs Refer to Lesson 3 Repetition and Loops for more information about using loops to combine common operations Compound Refer to the LabVIEW Basics II Development Course Manual for more information about application development National Instruments Corporation 2 3 LabVIEW Introduction Course Manual Lesson2 Mod
197. indow required connections are bold recommended connections are plain text and optional connections are dimmed or do not appear Figure 1 10 shows an example Context Help window I gt Context Help Format 5 SF File path dialog if ernpty number oF rows fall 14 mark after read chars transpose more y eee i EOF Read From Spreadsheet File vi Reads a specified number of lines or rows From a numeric text File beginning at a specified character offset and converts the data to a 2D single precision array of numbers Click here for more help Figure 1 10 Context Help Window Click the Hide Optional Terminals and Full Path button located on the lower left corner of the Context Help window to display the optional terminals of a connector pane and to display the full path to a VI Optional terminals are shown by wire stubs informing you that other connections exist The detailed mode displays all terminals as shown in Figure 1 11 LabVIEW Introduction Course Manual 1 42 ni com Lesson1 Introduction to LabVIEW If Context Help Format 5 3f new File path Mok A Path i File path dialog if empty all rows number oF rows fall 14 Ht First row start of read offset chars i mark after read chars 1 max charactersfrow ino lim bee EOF transpose ino F i delimiter Tab Read From Spreadsheet File vi Reads a specified number of lines or rows From a numeric text File beginning at a specified c
198. ing through all directories specified by the VI Search Path You can edit the VI Search Path by selecting Tools Options and selecting Paths from the top pull down menu The Searching section lists directories or VIs as LabVIEW searches through them You can have LabVIEW ignore a subVI by clicking the Ignore SubVI button or you can click the Browse button to search for the missing subVI Saving Vis Select Save Save As Save All or Save with Options from the File menu to save VIs as individual files or group several VIs together and save them in a VI library VI library files end with the extension 11b National Instruments recommends that you save VIs as individual files organized in directories especially if multiple developers are working on the same project LabVIEW uses the native file dialog boxes so they act similar to other applications on the computer You can disable this feature by selecting Tools Options and selecting Miscellaneous from the top pull down menu If you disable native file dialogs LabVIEW uses its own LabVIEW Introduction Course Manual 1 6 ni com Lesson 1 Introduction to LabVIEW platform independent file dialog boxes with some convenient features such as providing a list of recent paths and reducing the steps necessary to save VIs in VI libraries Moving Vis Across Platforms You can transfer VIs from one platform to another such as from Mac OS to Windows LabVIEW automatically translates and recompile
199. ingle step through the VI and its subVI National Instruments Corporation a Click the Step Into button to start single stepping b When the Debug Exercise Sub VI blinks click the Step Into button Notice the run button on the subVI 1 55 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW f Display the Debug Exercise Main VI block diagram by clicking it A green glyph shown at left appears on the subVI icon on the Debug Exercise Main VI block diagram indicating that the sub VI is running Display the Debug Exercise Sub VI block diagram by clicking it Click the Step Out button twice to finish single stepping through the subVI block diagram The Debug Exercise Main VI block diagram is active Click the Step Out button to stop single stepping 10 Use a probe to check intermediate values on a wire as a VI runs el a Use the Probe tool shown at left to click any wire A window similar to the following window appears if 1 Probe 1 Probe 0 0000E 0 LabVIEW numbers the Probe window automatically and displays the same number in a glyph on the wire you clicked Single step through the VI again The Probe window displays data passed along the wire 11 Place breakpoints on the block diagram to pause execution at that location a Use the Breakpoint tool shown at left to click nodes or wires Place a breakpoint on the block diagram to pause execution aft
200. ints to debug VIs by animating the flow of data through the block diagram Operating Frequently used menu options have equivalent keyboard shortcuts For example to save a VI you can select File Save or press the lt Ctrl S gt keys Common keyboard shortcuts include the following lt Ctrl R gt Runs a VI lt Ctrl E gt Toggles between the front panel and block diagram lt Ctrl H gt Toggles display of the Context Help window lt Ctrl B gt Removes all broken wires lt Ctrl F gt Finds VIs globals functions text or other objects loaded in memory or in a specified list of VIs To increment or decrement numeric controls faster use the Operating or Labeling tools to place the cursor in the control and press the lt Shift gt key while pressing the up or down arrow keys You can disable the debugging tools to reduce memory requirements and to increase performance slightly Select File VI Properties select Execution from the top pull down menu and remove the checkmark from the Allow Debugging checkbox Wiring LabVIEW Introduction Course Manual Click the Show Context Help Window button on the toolbar to display the Context Help window Use the Context Help window to determine which terminals are required Required terminals are bold recommended connections are plain text and optional connections are dimmed Press the spacebar to toggle the wire direction To move objects one pixel press the a
201. ion Course Manual 2 6 ni com Lesson2 Modular Programming Use the options on the right side of the editing area to perform the following tasks e Show Terminals Displays the terminal pattern of the connector pane e OK Saves the drawing as the icon and returns to the front panel e Cancel Returns to the front panel without saving any changes The menu bar in the Icon Editor dialog box contains more editing options such as Undo Redo Cut Copy Paste and Clear Setting up the Connector Pane To use a VI as a subVI you need to build a connector pane shown at left The connector pane is a set of terminals that corresponds to the controls and indicators of that VI similar to the parameter list of a function call in text based programming languages The connector pane defines the inputs and outputs you can wire to the VI so you can use it as a subVI Define connections by assigning a front panel control or indicator to each of the connector pane terminals To define a connector pane right click the icon in the upper right corner of the front panel window and select Show Connector from the shortcut menu The connector pane replaces the icon Each rectangle on the connector pane represents a terminal Use the rectangles to assign inputs and outputs The number of terminals LabVIEW displays on the connector pane depends on the number of controls and indicators on the front panel The following front panel has four controls and one indic
202. ions to control the front panel objects The block diagram contains this graphical source code Front panel objects appear as terminals on the block diagram Block diagram objects include terminals subVIs functions constants structures and wires which transfer data among other block diagram objects The VI in Figure 1 9 shows several primary block diagram objects nodes terminals and wires I gt add sub i Front Panel I gt add amp sub yvi Block Diagram melho 12 ene 1 Nodes 2 Indicator Terminals 3 Wires 4 Control Terminals Figure 1 9 Example of a Block Diagram and Corresponding Front Panel Functions Palette The Functions palette is available only on the block diagram The Functions palette contains the VIs and functions you use to build the block diagram Select Window Show Functions Palette or right click the block diagram workspace to display the Functions palette Tack down the Functions palette by clicking the thumbtack on the top left corner of the palette By default the Functions palette starts in the Express view Express Vis Vis and Functions LabVIEW uses colored icons to distinguish between Express VIs VIs and functions on the block diagram By default icons for Express VIs appear on the block diagram as expandable nodes with icons surrounded by a blue National Instruments Corporation 1 21 LabVIEW Introduction Course Manual Lesson 1 Nodes Introduction to LabVIEW field Icons
203. isplays the attributes of the device such as the system resources that are being used by the device 9 7 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms B Note You might have a different device installed and some of the options shown might be different Click the Show Help Hide Help button in the top right corner of MAX to hide the online help and show the DAQ device information 3 The Device Routes tab provides detailed information about the internal signals that can be routed to other destinations on the device This is a powerful resource that gives you a visual representation of the signals that are available to provide timing and synchronization with components that are on the device and other external devices PCI 6074E Devi Measurement amp Automation Explorer File Edit wiew Tools Help ES Properties Self Test Test Panels y Show Help E My System This panel shows the routes that can be eee Direct Route Data Neighborhood made within this device Hover over a cell SENET indirect Route Through Subsys EJ Devices and Interfaces to see what subsystem is used g Y Traditional NI DAQ Devices E PCI 6024E Device 1 PSEE PEI System 0 Unidentified NI Dacms Devices BW PCI 6024E Devi GPIBO PCI GPIB y Ports Serial amp Parallel Dev1 CtrOOuk IVT Instruments Dev ChrOGate 4 Scales F Fl Historical Data Software VI Logger Tasks oa Us
204. it button 15 Seta VISA alias for the NI Instrument Simulator so you can use the alias instead of having to remember the primary address a While Instrument is selected in MAX click the VISA Properties button to display the Properties dialog box b Type devsimin the VISA Alias field and click the OK button You will use this alias throughout this lesson 16 Select File Exit to exit MAX End of Exercise 10 1 LabVIEW Introduction Course Manual 10 8 ni com Lesson 10 Instrument Control C Using the Instrument I 0 Assistant The Instrument I O Assistant located on the Functions Input and Functions All Functions Instrument I O palettes is a LabVIEW Express VI which you can use to communicate with message based instruments and graphically parse the response For example you can communicate with an instrument that uses a serial Ethernet or GPIB interface Use the Instrument I O Assistant when an instrument driver is not available The Instrument I O Assistant organizes instrument communication into ordered steps To use Instrument I O Assistant you place steps into a sequence As you add steps to the sequence they appear in the Step Sequence window Use the view associated with a step to configure instrument I O To launch the Instrument I O Assistant place the Instrument I O Assistant Express VI on the block diagram The Instrument I O Assistant configuration dialog box appears If it does not appear double click the In
205. l This operation does not require any buffering or hardware timing For example if you need to generate a known voltage to stimulate a device a single update would be an appropriate task National Instruments Corporation 9 23 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms Generate n Samples One way to generate multiple samples for one or more channels is to generate single samples in a repetitive manner However generating a single data sample on one or more channels over and over is inefficient and time consuming Moreover you do not have accurate control over the time between each sample or channel Instead you can use hardware timing which uses a buffer in computer memory to generate samples more efficiently You can use software timing or hardware timing to control when a signal is generated With software timing the rate at which the samples are generated is determined by the software and operating system instead of by the measurement device With hardware timing a TTL signal such as a clock on the device controls the rate of generation A hardware clock can run much faster than a software loop A hardware clock is also more accurate than a software loop Ky Note Some devices do not support hardware timing Consult the device documentation if you are unsure if the device supports hardware timing Task Triggering Programmatically you need to include the timing function specifying the sam
206. lays the current voltage output Display and examine the block diagram National Instruments Corporation The Wait Until Next ms Multiple function located on the Functions All Functions Time amp Dialog palette causes the For Loop to execute every 500 ms The Select VI located on the Functions Arithmetic amp Comparison Express Comparison palette checks if the loop is in its last iteration If the loop is in its last iteration then the DAQ device outputs O volts This is a good technique to reset the output voltage to a known level It is always a good idea to reset the output voltage to something that won t damage a device that is connected to the DAQ device 9 25 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms 4 Modify the block diagram as shown in the following figure Place the DAQ Assistant Express VI located on the Functions Input palette in the For Loop Complete the following steps to configure this Express VI to generate an analog output voltage Select Analog Output Voltage for the measurement to make b Select Dev1 ao0 for the physical channel and click the Finish button c Inthe Analog Output Voltage Task Configuration dialog box that appears configure the Task Timing to Generate 1 Sample Change the output range minimum to 0 and maximum to 10 d Click the OK button to close the Analog Output Voltage Task Configuration dialog box This saves the settings sp
207. le Name Function fopen 0 create or replace sec TE End of Line Scag aos Build Text Bundle Temperature History Warning Greater Select High value Wait Until Next Lo Tick Multiple a Place the Open Create Replace File VI located on the Functions on All Functions File I O palette on the block diagram Right click the prompt input select Create Constant from the shortcut menu and type Enter File Name in the constant Right click the function input select Create Constant from the shortcut menu and click the constant with the Operating tool to select create or replace LabVIEW Introduction Course Manual 8 26 ni com la LEC JLEC Ti m E E bie e National Instruments Corporation Lesson 8 Strings and File 1 0 b Place the Get Date Time String function located on the Functions All Functions Time amp Dialog palette on the block diagram This function returns the time in string format when the temperature measurement was taken Right click the want seconds input select Create Constant from the shortcut menu and click the constant with the Operating tool to change the constant from FALSE to TRUE The TRUE Boolean constant sets the function to include seconds in the string Place the Build Text Express VI located on the Functions Output palette on the block diagram This Express VI converts the inputs to one string The Configure Build Text dialog box appears
208. le by Name function located on the Functions All Functions Cluster palette on the block diagram This function reads the status output from the error cluster gt b Place the Not function and the And function located on the Functions Arithmetic amp Comparison Express Boolean palette on the block diagram These functions set the conditional terminal to continue while Power is TRUE and no error occurs 11 Save and run the VI 12 Test the error handling by deleting the refnum wire between the Write File function and the left border of the While Loop Right click the refnum input of Write File and select Create Constant 13 Run the VI again The VI should wait for a path then stop immediately with an error If error handling was not included in this VI the VI would not report the error until the user stopped the VI 14 If time permits complete the challenge steps Otherwise close the VI Do not save changes Challenge 15 Replace the Build Text Express VI and the Write File function with the Format Into File function 16 Run the VI 17 Close the VI Do not save changes End of Exercise 8 5 National Instruments Corporation 8 29 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O Exercise 8 6 Temperature Application VI Objective Apply what you have learned so far in this course structures shift registers waveform charts arrays graphs file 1 0 and so on Challenge 1 Build a
209. lgary 403 274 9391 Canada Montreal 514 288 5722 Canada Ottawa 613 233 5949 Canada Qu bec 514 694 8521 Canada Toronto 905 785 0085 Canada Vancouver 514 685 7530 China 86 21 6555 7838 Czech Republic 420 2 2423 5774 Denmark 45 45 76 26 00 Finland 385 0 9 725 725 11 France 33 0 1 48 14 24 24 Germany 49 0 89 741 31 30 Greece 30 2 10 42 96 427 India 91 80 51190000 Israel 972 0 3 6393737 Italy 39 02 413091 Japan 81 3 5472 2970 Korea 82 02 3451 3400 Malaysia 603 9131 0918 Mexico 001 800 010 0793 Netherlands 31 0 348 433 466 New Zealand 1800 300 800 Norway 47 0 66 90 76 60 Poland 48 0 22 3390 150 Portugal 351 210 311 210 Russia 7 095 238 7139 Singapore 65 6226 5886 Slovenia 386 3 425 4200 South Africa 27 0 11 805 8197 Spain 34 91 640 0085 Sweden 46 0 8 587 895 00 Switzerland 41 56 200 51 51 Taiwan 886 2 2528 7227 Thailand 662 992 7519 United Kingdom 44 0 1635 523545 Contents Student Guide AADU TNS Mian all nenna aa ra miauveansaaceoceet 1X B What You Need to Get Started aicnisscvsiosinicebsnasdieiosveatesn daca tinctalibandvoueseeitelesnct its xi C Tnstaline De Course SOM W ane rasie A AE xii D Co rse Goalsand Non Goalg seisine a a aaa eee danse xiii EC ourse Convent ON aa E dei sncaue X1V Lesson 1 Introduction to LabVIEW ive EaD VIE W rand se terse E E 1 2 Bs edb V MEW Enyironme ihoss N dlneeleh die Wee ean teed 1 3 Co PROMI PING latices lode S E asa datetaeaseaas eel va E E E T 1 18 D Blo
210. libration information updates in the Calibration tab Part B Testing the DAQ Device Components 6 Click the Self Test button to test the device This tests the system resources assigned to the device The device should pass the test because it is already configured 7 Click the Test Panels button to test the individual functions of the DAQ device such as analog input and output The Test Panels dialog box appears a Use the Analog Input tab to test the various analog input channels on the DAQ device Channel Dev1 ai0 is connected to the temperature sensor on the DAQ Signal Accessory Click the Start button to acquire data from analog input channel 0 Place your finger on the sensor to see the voltage rise You also can move the Noise switch to On on the DAQ Signal Accessory to see the signal change in this tab When you are finished click the Stop button National Instruments Corporation 9 9 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms 9 b Click the Analog Output tab to set up a single voltage or sine wave on one of the DAQ device analog output channels Change the Output Mode to Sinewave Generation and click the Start Sine Generator button LabVIEW generates a continuous sine wave on analog output channel 0 c On the external DAQ Signal Accessory box wire Analog Out Ch0 to Analog In Chl d Click the Analog Input tab and change the channel to Dev1 ail Click the Start button to
211. litude is an option in the Configure Simulate Signal dialog box When inputs such as Amplitude appear on the block diagram and in the configuration dialog box you can configure the inputs in either location Wiring Objects on the Block Diagram To use the knob control to change the amplitude of the signal you must connect the two objects on the block diagram Complete the following steps to wire the knob to the Amplitude input on the Simulate Signal Express VI l Move the cursor over the Knob terminal shown at left until the Positioning tool appears Notice how the cursor becomes an arrow or the Positioning tool shown at left Use the Positioning tool to select position and resize objects Click the Knob terminal to select it then drag the terminal to the left of the Simulate Signal Express VI Make sure the Knob terminal is inside the loop shown at left The terminals are representations of front panel controls and indicators Terminals are entry and exit ports that exchange information between the front panel and block diagram Deselect the Knob terminal by clicking a blank space on the block diagram Move the cursor over the arrow of the Knob terminal shown at left Notice how the cursor becomes a wire spool or the Wiring tool shown at left Use the Wiring tool to wire objects together on the block diagram Kp Note The cursor does not switch to another tool while an object is selected Simulate Signal
212. lt Meta gt key Linux press the lt Alt gt key Mac OS Press lt Return gt to perform the same action as pressing the lt Enter gt key Italic text denotes variables emphasis a cross reference or an introduction to a key concept This font also denotes text that is a placeholder for a word or value that you must supply Text in this font denotes text or characters that you should enter from the keyboard sections of code programming examples and syntax examples This font is also used for the proper names of disk drives paths directories programs subprograms subroutines device names functions operations variables filenames and extensions and code excerpts Text in this font denotes the messages and responses that the computer automatically prints to the screen This font also emphasizes lines of code that are different from the other examples LabVIEW Introduction Course Manual XIV ni com Student Guide Platform Text in this font denotes a specific platform and indicates that the text following it applies only to that platform right click Mac OS Press lt Command gt click to perform the same action as a right click National Instruments Corporation XV LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW This lesson introduces the basics of LabVIEW Use the Getting Started with LabVIEW manual to get started with LabVIEW quickly Use the Getting Started with LabVIEW manual to fam
213. mmands data format e Software drivers available LabVIEW Introduction Course Manual 10 2 ni com Lesson 10 Instrument Control B GPIB Communication and Configuration GPIB Addressing The ANSI TEEE Standard 488 1 1987 also known as General Purpose Interface Bus GPIB describes a standard interface for communication between instruments and controllers from various vendors such as scanners and film recorders It contains information about electrical mechanical and functional specifications GPIB is a digital 8 bit parallel communication interface with data transfer rates of 1 Mbyte s and higher using a three wire handshake The bus supports one System Controller usually a computer and up to 14 additional instruments The ANSI TEFE Standard 488 2 1992 extends IEEE 488 1 by defining a bus communication protocol a common set of data codes and formats and a generic set of common device commands GPIB instruments offer test and manufacturing engineers the widest selection of vendors and instruments for general purpose to specialized vertical market test applications GPIB instruments have traditionally been used as stand alone benchtop instruments where measurements are taken by hand The GPIB is a 24 conductor parallel bus that consists of eight data lines five bus management lines ATN EOI IFC REN and SRQ three handshake lines and eight ground lines The GPIB uses a byte serial asynchronous data transfer scheme This mea
214. mpression Express VI Customizing the Front Panel In a previous exercise you added controls and indicators to the front panel using the Controls palette You also can add controls and indicators from the block diagram Complete the following steps to create controls and indicators l National Instruments Corporation Right click the Mean output in the Sample Compression Express VI and select Create Numeric Indicator from the shortcut menu to create a numeric indicator Right click the Mean output of the Sample Compression Express VI and select Insert Input Output from the shortcut menu to insert the Enable input Right click the Enable input and select Create Control from the shortcut menu to create the Enable switch Right click the wire linking the Sine output in the Simulate Signal Express VI to the Signals input in the Signal Compression Express VI and select Create Graph Indicator from the shortcut menu Notice that you can create controls and indicators from the block diagram When you create controls and indicators using this method LabVIEW automatically creates terminals that are labeled and formatted correctly Using the Wiring tool wire the Mean output in the Sample Compression Express VI to the Sine terminal Notice that the Merge Signals function appears 1 47 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW 6 Arrange the objects on the block diagram so that they appear similar
215. n _ create or replace on Openi Create Replace File vi String bo Write Libek Number to Write Create String vi nerh mie rrri Unik to Write Label National Instruments Corporation 8 19 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O a Place the Create String VI from Exercise 8 1 on the block diagram Select Functions All Functions Select a VI and navigate to C Exercises LabVIEW Basics I Create String vi This subVI concatenates the three input strings to one combined String EJE BE Mi b Place the Open Create Replace File VI located on the Functions on All Functions File I O palette on the block diagram This VI displays a dialog box to open or create a file Right click the prompt input select Create Constant from the shortcut menu and type Enter Filename in the constant When the VI runs a file navigation dialog box appears with Enter Filename as the title of the window Right click the function input select Create Constant from the shortcut menu and click the constant with the Operating tool to select create or replace FILE c Place the Write File function located on the Functions All A Functions File I O palette on the block diagram This function writes the concatenated strings to the file CLOSE d Place the Close File function located on the Functions All oe Functions File I O palette on the block diagram This function closes the file e Place t
216. nd MARK is a negative voltage and SPACE is positive The previous illustration shows how the idealized signal looks on an oscilloscope The following is the truth table for RS 232 Signal gt 3 V 0 Signal lt 3 V 1 The output signal level usually swings between 12 V and 12 V The dead area between 3 V and 3 V is designed to absorb line noise A start bit signals the beginning of each character frame It is a transition from negative MARK to positive SPACE voltage Its duration in seconds is the reciprocal of the baud rate If the instrument is transmitting at 9 600 baud the duration of the start bit and each subsequent bit is about 0 104 ms The entire character frame of eleven bits would be transmitted in about 1 146 ms Data bits are transmitted upside down and backwards That is inverted logic is used and the order of transmission is from least significant bit LSB to most significant bit MSB To interpret the data bits in a character frame you must read from right to left and read 1 for negative voltage and O for positive voltage This yields 1101101 binary or 6D hex An ASCII conversion table shows that this 1s the letter m An optional parity bit follows the data bits in the character frame The parity bit if present also follows inverted logic 1 for negative voltage and Q for positive voltage This bit is included as a simple means of error handling You specify ahead of time whether the parity of th
217. nd Functions File 1 0 Vis File I O operations pass data to and from files Use the File I O VIs and functions located on the Functions All Functions File I O palette to handle all aspects of file I O including the following e Opening and closing data files e Reading data from and writing data to files e Reading from and writing to spreadsheet formatted files e Moving and renaming files and directories e Changing file characteristics e Creating modifying and reading configuration files The File I O palette is divided into four types of operations high level low level advanced and express High Level File 1 0 Vis Use the high level File I O VIs located on the top row of the Functions All Functions File I O palette to perform common I O operations Refer to the High Level File I O VIs section of this lesson for more information about the high level File I O VIs You can save time and programming effort by using the high level VIs to write to and read from files The high level VIs perform read or write operations in addition to opening and closing the file If an error occurs the high level VIs display a dialog box that describes the error You can choose to halt execution or to continue However because high level VIs encapsulate the entire file operation into one VI they are difficult to customize to any use other than the one intended Use low level VIs for more specific tasks Low Level and Advanced File 1 0 Vis
218. nd Serial Device Simulator o H Traditional NI DAG Devices c MI DAQmx Devices GPIBO PCI GPIE 2 a Instrument HPX PXI System Unidentified a Ports Serial amp Parallel a Scales 2 H Software ce IWI Drivers roe Remote Systems E Attributes The Remote Systems section in the Configuration pane allows you to view and configure remote systems such as RT Series PXI Controllers Configure the objects listed in MAX by right clicking each item and selecting an option from the shortcut menu LabVIEW Introduction Course Manual 10 6 ni com Lesson 10 Instrument Control Exercise 10 1 GPIB Configuration with MAX Windows Only Objective To use MAX to examine the GPIB interface settings detect instruments and communicate with an instrument 1 Power off the NI Instrument Simulator and configure it to communicate through GPIB by setting the following left bank of switches on the side of the box MODE 2 Power on the NI Instrument Simulator and verify that both the Power and Ready LEDs are lit 3 Launch MAX by either double clicking the icon on the desktop or by selecting Tools Measurement amp Automation Explorer in LabVIEW 4 Expand the Devices and Interfaces section to display the installed interfaces If a GPIB interface is listed the NI 488 2 software is correctly loaded on the computer 5 Select the GPIB interface and click the Properties button on the toolbar to display the Properties
219. ndex of 0 You also can use the Index Array function to extract a row or column of a 2D array to create a subarray of the original To do so wire a 2D array to the input of the function Two index terminals are available The top index terminal indicates the row and the second terminal indicates the column You can wire inputs to both index terminals to index a single element or you can wire only one terminal to extract a row or column of data For example wire the following array to the input of the function The Index Array function returns the following array for an index row of 0 AERE 4 7 LabVIEW Introduction Course Manual Lesson4 Arrays D Polymorphism The Numeric functions located on the Functions Express Numeric and Functions All Functions Numeric palettes are polymorphic This means that the inputs to these functions can be different data structures such as scalar values and arrays For example you can use the Add function to add a scalar value to an array or to add two arrays together If you wire a scalar value of 2 and the following array to the Add function The function adds the scalar value to each element of the array and returns the following array If you wire the previous two arrays to the Add function the function adds each element of one array to the corresponding element of the other array and returns the following array Wire two arrays of different sizes to the Add function such as the pr
220. ng a cluster constant on the Cluster palette placing it on the block diagram and dragging a constant into the cluster shell If you have a cluster control or indicator on the front panel and you want to create a cluster constant containing the same elements on the block diagram you can either drag that cluster from the front panel to the block diagram or right click the cluster on the front panel and select Create Constant from the shortcut menu LabVIEW Introduction Course Manual 5 2 ni com Lesson5 Clusters Cluster Order Cluster elements have a logical order unrelated to their position in the shell The first object you place in the cluster is element 0 the second is element 1 and so on If you delete an element the order adjusts automatically The cluster order determines the order in which the elements appear as terminals on the Bundle and Unbundle functions on the block diagram You can view and modify the cluster order by right clicking the cluster border and selecting Reorder Controls In Cluster from the shortcut menu The toolbar and cluster change as shown in the following example al 2 pe Cluster Wi Fille Edit woerste Tools Browse Window Help OK Click to set to Cluster 1 Confirm Button 3 Cluster Order Cursor 5 New Order 2 Cancel Button 4 Current Order The white box on each element shows its current place in the cluster order The black box shows the new place in the order for an element To set the o
221. nge of 20 to 32 instead of 70 to 90 6 Save the VI as Temperature Monitor vi in the C Exercises LabVIEW Basics I directory Run the VI 7 Display the front panel by clicking it or by selecting Window Show Front Panel 8 Use the Operating tool to click the vertical toggle switch and turn it to the ON position National Instruments Corporation 6 5 LabVIEW Introduction Course Manual Lesson6 Plotting Data 9 Run the VI The subdiagram within the While Loop border executes until the specified condition is TRUE For example while the switch is on TRUE the Thermometer VI takes and returns a new measurement and displays it on the waveform chart 10 Click the vertical toggle switch to stop the acquisition The condition is FALSE and the loop stops executing Front Panel 11 Format and customize the x and y scales of the waveform chart a Right click the chart and select Properties from the shortcut menu to display the Chart Properties dialog box b Click the Format and Precision tab Select Deg F Y axis in the top pull down menu Set the Digits of precision to 1 c Click the Plots tab and select different styles for the y axis as shown in the following dialog box i Chart Properties Temperature History Appearance Format and Precision Plots Scales Documentation anane gt D 8 o G Oo a o E Ure Cobr FT Y scale Deg F Y axis Ww Point Fill Color ee meled Ka iy d Select the Scales tab
222. ns that whole bytes are sequentially handshaked across the bus at a speed that the slowest participant in the transfer determines Because the unit of data on the GPIB is a byte the messages transferred are frequently encoded as ASCII character strings All GPIB devices and interfaces must have a unique GPIB address between 0 and 30 Address 0 is normally assigned to the GPIB interface The instruments on the GPIB can use addresses through 30 GPIB devices can be talkers listeners or controllers A talker sends out data messages Listeners receive data messages The controller usually a computer manages the flow of information on the bus It defines the communication links and sends GPIB commands to devices The GPIB VIs automatically handle the addressing and most other bus management functions National Instruments Corporation 10 3 LabVIEW Introduction Course Manual Lesson 10 Instrument Control Data Transfer Termination You can terminate a GPIB data transfer in the following three ways Restrictions The GPIB includes a hardware line EOD that can be asserted with the last data byte This is the preferred method Place a specific end of string EOS character at the end of the data string itself Some instruments use this method instead of or in addition to the EOI line assertion The listener counts the bytes handshaked and stops reading when the listener reaches a byte count limit This method is often used as a default
223. nt digits to Digits of precision b Type 0 in the Digits of precision text box and click the OK button 4 Repeat step 3 to set the precision for Current Number and of iterations indicators LabVIEW Introduction Course Manual 3 6 ni com Block Diagram Lesson3 Repetition and Loops 5 Build the following block diagram Round To Nearest Current Number Number to Match Increment of iterations 1 0000 00 National Instruments Corporation Place the Random Number 0 1 function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram This function produces a random number between 0 and 1 Place the Multiply function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram This function multiplies the random number by 10 000 to produce a random number between 0 and 10 000 Right click the y terminal of the Multiply function select Create Constant from the shortcut menu type 10000 and press the lt Enter gt key to create a numeric constant Place the Round To Nearest function located on the Functions Arithmetic amp Comparison Express Numeric palette on the block diagram This function rounds the random number to the nearest integer Place the Not Equal function located on the Functions Arithmetic amp Comparison Express Comparison palette on the block diagram This function compares the random number with
224. nuously on the front panel Front Panel 1 Select File New then select Template Frameworks Single Loop Application to open the Single Loop Application template VI 2 Build the following front panel VISA Resource Name waveform Chart Yolts DC 4 p em 10 0 f Min Voltage ie i SJ Max Voltage 3 96 4 0 Time Use the following guidelines to help you construct the front panel a Place a VISA resource name control located on the Controls All Controls I O palette on the front panel b Set the x axis scale of the waveform chart to show incremental values LabVIEW Introduction Course Manual 10 22 ni com Block Diagram Lesson 10 Instrument Control 3 Build the following block diagram YISA Resource Mame E MI DEYSIM Multimeter Configuration wi MI DEYSIM Initialize wi DEVSIM d Measure DEYSIH e Farle Closg National Instruments Corporation MI DEW SIM Measure DE Voltage vi Simple Error Handler vi HI GEVSIM Close vi Waveform Chart Max Voltage Min Voltage Time Delay Create two shift registers by right clicking the right or left border of the loop and selecting Add Shift Register from the shortcut menu Place the NI DEVSIM Initialize VI located on the Functions Input Instrument Drivers NI Device Simulator palette on the block diagram This VI opens communication between LabVIEW and the NI Instrument Simulator Right click the ID
225. o an instrument you must know the resource name or instrument descriptor A resource 1s an instrument or interface and the instrument descriptor is the exact name and location of a resource in the following format Interface Type board index Address INSTR Optional parameters are shown in square brackets For example GPIB 2 INSTR is the instrument descriptor for a GPIB instrument at address 2 LabVIEW Introduction Course Manual 10 20 ni com Lesson 10 Instrument Control The VISA resource name control located on the Controls All Controls I O palette is similar to the DAQ channel name control but it is specifically used for instrument control Refer to the VISA section of this lesson for more information about VISA You can use MAX to determine what resources and instrument addresses are available as you did in Exercise 10 1 when you assigned a VISA alias of devsim to the NI Instrument Simulator The alias makes it easier to communicate with instruments because you no longer need to memorize which interface and address each instrument uses You can use the alias in the VISA resource name control instead of the instrument descriptor For example you can type devsim instead of GPIB 2 INSTR VISA Sessions After you initialize an instrument the Initialize VI returns a VISA session number The VISA session 1s a connection or link to a resource such as the instrument You do not need to display this value However ea
226. o indexing in While Loops Polymorphism is the ability of a function to adjust to input data of different data structures 4 11 LabVIEW Introduction Course Manual Lesson4 Arrays Additional Exercises 4 2 Build a VI that reverses the order of an array that contains 100 random numbers For example array 0 becomes array 99 array 1 becomes array 98 and so on W Tip Use the Reverse 1D Array function located on the Functions All Functions Array palette to reverse the array order Challenge 4 4 4 5 LabVIEW Introduction Course Manual Save the VI as Reverse Random Array vi in the C Exercises LabVIEW Basics I directory Build a VI that accumulates an array of temperature values using the Thermometer VI which you built in Exercise 2 2 Set the array size with a control on the front panel Initialize an array using the Initialize Array function of the same size where all the values are equal to 10 Add the two arrays calculate the size of the final array and extract the middle value from the final array Display the Temperature Array Initialized Array Final Array and Mid Value Save the VI as Find Mid Value vi in the C Exercises LabVIEW Basics I directory Build a VI that generates a 2D array of three rows by 10 columns that contains random numbers After generating the array index each row and plot each row on its own graph The front panel should contain three graphs Save the VI as Extract 2D Array vi
227. object resides Shortcut Menus The most often used menu is the object shortcut menu All LabVIEW objects and empty space on the front panel and block diagram have associated shortcut menus Use the shortcut menu items to change the look or behavior of front panel and block diagram objects To access the shortcut menu right click the object front panel or block diagram The shortcut menu for a meter is shown in Figure 1 6 Visible Items Find Terminal Caption Change to Contral Unit Label Digital Display Description and Tip Create Replace Data Operations Advanced Representation Data Range Format amp Precision Add Needle Scale Text Labels Properties Figure 1 6 Meter Shortcut Menu LabVIEW Introduction Course Manual 1 16 ni com Lesson1 Introduction to LabVIEW Property Dialog Boxes Front panel objects also have property dialog boxes that you can use to change the look or behavior of front panel objects Right click a front panel object and select Properties from the shortcut menu to access the property dialog box for an object Figure 1 7 shows the property dialog box for the meter in Figure 1 6 The options available on the property dialog box for an object are similar to the options available on the shortcut menu for that object f Knob Properties Meter Appearance Data Range Scale Format and Precision Text Labels aje Label Caption I Visible Visible Enabl
228. obtain the current status of the instrument or the status of pending operations An example of an action VI is Acquire Single Shot An example of a status VI is Query Transfer Pending e Data Transfers data to or from the instrument such as reading a measured waveform from the instrument or downloading a waveform to the instrument e Utility Performs a wide variety of functions such as reset self test error query and revision query e Close Terminates the communication channel to the instrument and deallocates the resources for that instrument All National Instruments instrument drivers are required to implement the following functions initialize close reset self test revision query error query and error message Application Examples LabVIEW also includes application example VIs that show how to use the component VIs to perform common tasks Typically this includes configuring triggering and returning measurements from an instrument An application example VI does not initialize or close the instrument driver These VIs are not intended to be a soft front panel for the instrument but rather to demonstrate some instrument driver capabilities and guide you in developing your own VI Inputs and Outputs of Instrument Driver VIs Just as all instrument drivers share a common VI hierarchy they also share common inputs and outputs Resource Name or Instrument Descriptor When you initialize the communication channel t
229. ocated on the Controls Buttons amp Switches palette and a horizontal fill slide located on the Controls Numeric Controls palette in the cluster d Create the Modified Cluster by duplicating the first cluster and relabeling it Right click the shell of Modified Cluster and select Change to Indicator from the shortcut menu e Copy Modified Cluster and relabel it to create Small Cluster Remove the second toggle switch and horizontal fill slide indicators Relabel the numeric indicator to Slide value Resize the cluster as shown in the previous front panel LabVIEW Introduction Course Manual 5 8 ni com Lesson5 Clusters 2 Verify the cluster order of Cluster and Small Cluster Modified Cluster should have the same order as Cluster a Right click the boundary of each cluster and select Reorder Controls in Cluster from the shortcut menu b Confirm the following cluster orders Block Diagram 3 Build the following block diagram Unbundle Cluster EL Bundle Small Cluster i Boolean 1 Boolean 1 ae By Mame pew ee j Era ai gt Tumer L EE a Place the Unbundle function located on the Functions All Functions Cluster palette on the block diagram This function disassembles Cluster Use the Positioning tool to resize this function to four output terminals or wire the input cluster to resize the function automatically a b Place the Bundle function located on the Functions All Functions Cluster pal
230. oduction Course Manual Lesson 3 Repetition and Loops For example the For Loop count terminal is a 32 bit signed integer If you wire a double precision floating point numeric to the count terminal LabVIEW converts the numeric to a 32 bit signed integer A coercion dot appears on the count terminal of the first For Loop as shown in the following illustration double precision Floating Ea l point numeric value 32 bit signed integer Coercion Dot If you wire two different numeric data types to a numeric function that expects the inputs to be the same data type LabVIEW converts one of the terminals to the same representation as the other terminal LabVIEW chooses the representation that uses more bits If the number of bits is the same LabVIEW chooses unsigned over signed In the following example a 32 bit signed integer 132 and a double precision floating point numeric value DBL are wired to the Divide function The 32 bit signed integer is coerced since it uses fewer bits than the double precision floating point numeric value Integer Output EEFT A T Double E To change the representation of a numeric object right click the object and select Representation from the shortcut menu Select the data type that best represents the data When LabVIEW converts double precision floating point numeric values to integers 1t rounds to the nearest integer LabVIEW rounds x 5 to the nearest even integer For exampl
231. ol Data Format Data Source Binary Simulated 979 Jas CII J sr Wavetorn String Waveform Flot CURVE 4 3749 09054E1 a 0 8429E1 7 1068 6 6331 7 0970 7 7300 7 9161 7 E677 7 3702 7 3012 7 4918 7 5704 7 5936 7 52617 4620 7 4556 7 4901 7 5197 7 5203 7 50267 4892 7 4901 7 4993 7 5051 4 9754 0 905561 0 942961 7 1071 6 6335 7 0970 7 7303 791657 6680 7 3705 73015 7438 7 5707 75939 7 5264 aaa 7 4623 7 4559 74904 100 120 140 75197 7 5206 7 5029 H of bytes in string Amplitude Data Format specifies an ASCII waveform or a binary waveform Data Source specifies whether the data is simulated or read from the NI Instrument Simulator through the GPIB Block Diagram 4 Display and examine the following block diagram E aj iis Acquire and convert the binary waveform string into an array oF i p J Waveform String Extract binary waveform string and convert it to an array of numbers rere ror rarer a ene enema eee eennne Acquire and convert the ASCII waveform string into an array of numbers es al F SSeS ees sb EDDIE 7 LabVIEW Introduction Course Manual 10 38 ni com Lesson 10 Instrument Control The String Subset function located on the Functions All Functions String palette returns a substring of 128 elements starting from the fifth byte of the binary waveform string excluding the header and trailer bytes The String to Byte Array function located on the Function
232. ol palette on the block diagram Wire the Analysis control to the selector terminal Click the decrement or increment button to select the TRUE case gt b Place two Greater functions located on the Functions Arithmetic amp Comparison Express Comparison palette on the block diagram This function returns TRUE if the temperature exceeds High Limit Otherwise the function returns FALSE c Place the Select function located on the Functions Arithmetic amp Comparison Express Comparison palette on the block diagram This function returns the greater of the two input values d Wire the TRUE case as shown e Click the decrement or increment button to select the FALSE case 5 Complete the FALSE case of the Case Structure shown in the following example 99999 Hy a Right click the tunnel that connects to the Warning Indicator and select Create Constant Use the operating tool to change the boolean to a FALSE National Instruments Corporation 7 11 LabVIEW Introduction Course Manual Lesson Making Decisions ina VI b Right click the tunnel that connects to the High Value indicator and select Create Constant Enter 99999 for the value of the constant 6 Save the VI You will use this VI later in the course Run the VI 7 Display the front panel type 80 in High Limit and run the VI If ANALYSIS is off the VI displays a dimmed warning light and a value of 99999 for the High Value If ANALYSIS is
233. on the VI turns on the Warning LED when the temperature is above High Limit and displays the current High Value 8 Close the VI End of Exercise 7 2 LabVIEW Introduction Course Manual 7 12 ni com Lesson 7 Making Decisions in a VI C Formula Node Use the Formula Node to perform mathematical operations in the LabVIEW environment For additional functionality you can link to the mathematics application MATLAB Formula Node The Formula Node is a convenient text based node you can use to perform mathematical operations on the block diagram Formula Nodes are useful for equations that have many variables of are otherwise complicated and for using existing text based code You can copy and paste the existing text based code into a Formula Node rather than recreating it graphically on the block diagram Create the input and output terminals of the Formula Node by right clicking the border of the node and selecting Add Input or Add Output from the shortcut menu then enter the variable for the input or output Type the equation in the structure Each equation statement must terminate with a semicolon Formula Nodes also can be used for decision making The following block diagram shows two different ways of using an if then statement in a Formula Node The two structures produce the same result Formula Node wo xo O sort ec 99999 Square Root Value Formula Node Floato t w iffx gt 0 yvSsqrtlxy else y 999
234. on dialog box This saves all the settings specified for the task in the DAQ Assistant Express VI 3 Savethe Vlas Simple Event Counting viinthecC Exercises LabVIEW Basics I directory National Instruments Corporation 9 29 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms 9 On the DAQ Signal Accessory wire the A output of the quadrature encoder to the SOURCE input of counter 0 Run the VI Rotate the quadrature encoder knob on the DAQ Signal Accessory Notice that the Number of Events indicator increments as you rotate the knob The quadrature encoder knob produces pulses as you rotate the knob The counter counts these pulses Stop the VI Double click the DAQ Assistant Express VI and change the Count Direction pull down menu to Externally Controlled Click the OK button to close the configuration dialog box The DAQ Signal Accessory internally connects phase B of the quadrature encoder to the Up Down line for counter 0 This can be used to determine the direction the knob has turned Run the VI Rotate the quadrature encoder knob on the DAQ Signal Accessory Notice that the Number of Events indicator decrements when you rotate the knob clockwise and increments when you rotate the knob counterclockwise Save and close the VI End of Exercise 9 6 LabVIEW Introduction Course Manual 9 30 ni com Lesson9 Data Acquisition and Waveforms G Digital 1 0 Measuring and generating digital
235. onfigure Build Text dialog box appears The following dialog box shows the Express VI configured to accept one input voltage and change it to a fractional number with a precision of 4 The input concatenates on the end of the string Voltage is A space has been added to the end of the Voltage is String Configure Build Text Build Text Text with Yariables in Percents ovariable name Voltage is tovolkagep Configure Yariables Variable Variable Properties Format Text Format Fractional number 12 345 s Number Minimum Field width Boolean Use minimum Field width T Justification Padding Left Using spaces Right Using zeros Precision Use specified precision 4 Sample Number Sample result 12 35 B 12 3450 This configuration produces the following block diagram A probe has been added to view the value of the output string The Build Text Express VI concatenates the Beginning Text input in this case the voltage value at the end of the configured text F I 3 LEC b LALEC Build Text Resul 2 Result Voltage is 1 2800 National Instruments Corporation 8 5 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O Converting Strings to Numeric Values with the Scan From String Function The Scan From String function converts a string containing valid numeric characters such as 0 9 e E and period to a numeric value This function scans the input string and
236. onfigure the appearance and behavior of a VI You also can right click the VI icon on the front panel or block diagram and select VI Properties from the shortcut menu You cannot access the VI Properties dialog box while a VI is running Refer to the LabVIEW Basics II Development Course Manual for more information about configuring the behavior of VIs Use the Category pull down menu at the top of the VI Properties dialog box to select from several different option categories including the following e General Displays the current path where a VI is saved its revision number revision history and any changes made since the VI was last saved You also can use this page to edit the icon or the size of the alignment grid for the VI e Documentation Use this page to add a description of the VI and link to a help file topic Refer to Exercise 2 2 for more information about documenting VIs e Security vUse this page to lock or password protect a VI e Window Appearance Use this page to configure various window settings e Window Size Use this page to set the size of the window e Execution Use this page to configure how a VI runs For example you can configure a VI to run immediately when it opens or to pause when called as a subVI e Editor Options Use this page to set the size of the alignment grid for the current VI and to change the style of control or indicator Lab VIEW creates when you right click a terminal and sele
237. or 10 iterations Each iteration generates a random number and stores it at the output tunnel Random Array displays an array of 10 random numbers The VI multiplies each value in Random Array by Scaling Factor to create Final Array The VI takes a subset of Final Array starting at Start Subset for of Elements and displays the subset in Subset Array Close the VI End of Exercise 4 1 LabVIEW Introduction Course Manual 4 10 ni com Lesson4 Arrays Summary Tips and Tricks National Instruments Corporation Arrays group data elements of the same type You can build arrays of numeric Boolean path string waveform and cluster data types The array index is zero based which means it is in the range 0 ton 1 where n is the number of elements in the array You must insert an object in the array shell before you use the array on the block diagram Otherwise the array terminal appears black with an empty bracket To create an array control or indicator select an array on the Controls Array amp Cluster palette place it on the front panel and drag a control or indicator into the array shell If you wire an array to a For Loop or While Loop input tunnel you can read and process every element in that array by enabling auto indexing Use the Array functions located on the Functions All Functions Array palette to create and manipulate arrays By default LabVIEW enables auto indexing in For Loops and disables aut
238. or example the Array Size function returns a size of 3 for the following array e Initialize Array cCreates an n dimensional array in which every element is initialized to the value of element Resize the function to increase the number of dimensions of the output array For example the Initialize Array function returns the following array for an element of 4 a dimension size of 3 and one dimension size terminal e Array Subset Returns a portion of an array starting at index and containing length elements For example if you use the previous array as the input the Array Subset function returns the following array for an index of 2 and a length of 3 e Build Array Concatenates multiple arrays or appends elements to an n dimensional array Resize the function to increase the number of elements in the output array For example if you concatenate the two previous arrays the Build Array function returns the following array To concatenate the inputs into a longer array of the same dimension as shown in the following array right click the function node and select Concatenate Inputs from the shortcut menu to create the following array LabVIEW Introduction Course Manual 4 6 ni com H at O National Instruments Corporation Lesson4 Arrays Index Array Returns the element or sub array of n dimension array at index For example if you use the previous array as the input the Index Array function returns 2 for an i
239. or to display the result of the operation Add Subtract Divide or Multiply that the VI performs on the two numbers Use a slide control to specify the operation to perform Save the VI as Calculator vi inthe C Exercises LabVIEW Basics I directory 7 6 Modify the Square Root VI which you built in Exercise 7 1 so the VI performs all calculations and condition checking using the Formula Node Select File Save As to save the VI as Square Root 2 vi inthe C Exercises LabVIEW Basics I directory 7 7 Builda VI that has two inputs Threshold and Input Array and one Challenge output Output Array Output Array contains values from Input Array that are greater than Threshold Save the VI as Array Over Threshold vi in the C Exercises LabVIEW Basics I directory Create another VI that generates an array of random numbers between O and 1 and uses the Array Over Threshold VI to output an array with the values greater than 0 5 Save the VI as Using Array Over Threshold vi in the C Exercises LabVIEW Basics I directory National Instruments Corporation 7 17 LabVIEW Introduction Course Manual Lesson Making Decisions ina VI Notes LabVIEW Introduction Course Manual 7 18 ni com Lesson 8 Strings and File 1 0 A string 1s a sequence of displayable or non displayable ASCII characters Stings provide a platform independent format for information and data File I O operations pass data to and from files You Will Learn
240. oration 1 39 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW Exercise 1 2 Express Filter VI Objective Explore the data flow of an example VI Complete the following steps to use the NI Example Finder to search for an example VI that generates a sine wave with a frequency of 10 Hz and an amplitude of 10 volts with white noise of 1 volts of amplitude and applies a filter 1 Select Help Find Examples to open the NI Example Finder 2 Click the Search tab and type filter in the Type in the word s to search for text box Notice that this word choice reflects what you want this Express VI to do filter a signal Select filter to display the example VIs that include filter in the title 4 Find the example VI called Express Filter vi and double click to open it 5 Open the block diagram of the VI shown in the following figure Tone Simulated amplitude Measurements k Amplitude Simulate Signal Sine with Uniform peje b Amplitude t Noise amplitude E l Simulated Signal i 3 ae 1 ee ee ee ee eee eee 1 1 1 1 oo do tered Signal Filter Filtered Signal sees psssssssseessseeenrerre re eerEEreree r gi do lt tered Amplitude Tone Measurements2 j Filtered Frequenc Amplitude e T E LabVIEW Introduction Course Manual 1 40 ni com Lesson1 Introduction to LabVIEW A 6 Click the Highlight Exec
241. ou cannot edit the front panel or block diagram while the VI runs 5 Click the STOP button shown at left to stop the VI Kp Note Although the Abort Execution button looks like a stop button the Abort Execution button does not always properly close the VI National Instruments recommends stopping your VIs using the STOP button on the front panel Use the Abort Execution button only when errors prevent you from terminating the application using the STOP button LabVIEW Introduction Course Manual 1 32 ni com Lesson1 Introduction to LabVIEW Modifying the Signal Complete the following steps to add scaling to the signal and display the results in the graph on the front panel 1 On the block diagram use the Positioning tool to double click the wire that connects the Simulate Signal Express VI to the Waveform Graph terminal shown at left Simulate Signal z Sal bouche earns Amplitude 2 Press the lt Delete gt key to delete this wire If the Functions palette is not visible on the block diagram select Window Show Functions Palette to display it Sa eee ree 4 Select the Scaling and Mapping Express VI shown at left on the Arithmetic amp Comparison palette and place it on the block diagram Scale amp Map inside the loop between the Simulate Signal Express VI and the Waveform Graph terminal If there is no room between the Express VI and the terminal move the Waveform Graph terminal to the right Notice
242. ou use to view the probed data For example if you are viewing numeric data you can choose to see that data in a chart within the probe To create a custom probe right click a wire and select Custom Probe New from the shortcut menu Breakpoints Use the Breakpoint tool shown at left to place a breakpoint on a VI node or wire on the block diagram and pause execution at that location When you set a breakpoint on a wire execution pauses after data pass through the wire Place a breakpoint on the block diagram workspace to pause execution after all nodes on the block diagram execute When a VI pauses at a breakpoint LabVIEW brings the block diagram to the front and uses a marquee to highlight the node or wire that contains the breakpoint LabVIEW highlights breakpoints with red borders for nodes and block diagrams and red bullets for wires When you move the cursor over an existing breakpoint the black area of the Breakpoint tool cursor appears white Use the Breakpoint tool to click an existing breakpoint to remove it National Instruments Corporation 1 53 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW Exercise 1 4 Debug Exercise Main VI Objective To practice debugging techniques Complete the following steps to load a broken VI and correct the error Use single stepping and execution highlighting to step through the VI Front Panel 1 Select File Open and navigate to C Exercises LabVIEW Basics I
243. ount terminal an input terminal shown at left indicates how many times to repeat the subdiagram E The iteration terminal an output terminal shown at left contains the number of completed iterations The iteration count always starts at zero During the first iteration the iteration terminal returns 0 The For Loop differs from the While Loop in that the For Loop executes a set number of times A While Loop stops executing the subdiagram only if the value at the conditional terminal exists The following For Loop generates a random number every second for 60 seconds and displays the random numbers in a numeric indicator Random Number 0 1 Random Number Indicator National Instruments Corporation 3 9 LabVIEW Introduction Course Manual Lesson3 Repetition and Loops Wait Functions The Wait Until Next ms Multiple function shown at left monitors a millisecond counter and waits until the millisecond counter reaches a multiple of the amount you specify Use this function to synchronize activities Place this function within a loop to control the loop execution rate The Wait Until Next ms Multiple function waits until the internal computer timer is at the multiple specified It is possible that the first loop period might be short as shown in the following illustration Pre loop Code Loop Code VI Begins Pre loop Code 1st Loop 2nd Loop 3rd Loop Iteration Iteration Iteration Begins Begins Begins 1st Loop 2nd
244. owsed for and selected a template from this dialog box use the pull down menu of the Browse button to select a template to reopen it Front panel preview Displays the front panel for the VI template you selected in the Create new list Block diagram preview Displays the block diagram for the VI template you selected in the Create new list Description Displays a description of the template you selected in the Create new list if the template includes a description 1 5 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW Opening an Existing VI You load a VI into memory by selecting File Open In the Choose the VI to open dialog box that appears navigate to the VI you want to open The VIs you edit in this course are located in the C Exercises LabVIEW Basics I directory As the VI loads a status dialog box similar to the following example might appear le 5 E Frequency Response wi Loading z Loaded Ci Program Files Mational Instruments LabyiEW 6examplestapps freqresp lb Cerna Tek Fa S010 vi Searching Program Files Mational Instruments LabviIew 01yvilib Daq leasyia lib Ignore SubwI Browse Stop The Loading section lists the subVIs of the VI as they are loaded into memory Number Loaded is the number of subVIs loaded into memory so far You can cancel the load at any time by clicking the Stop button If LabVIEW cannot immediately locate a subVI it begins search
245. p appears with the name of the terminal In addition the terminal blinks in the Context Help window and on the icon to help you verify that you are wiring to the correct terminal LabVIEW Introduction Course Manual 1 26 ni com Lesson1 Introduction to LabVIEW Exercise 1 1 Acquiring a Signal VI Objective Explore the LabVIEW environment by creating a VI that generates a signal and displays it on the front panel In the following exercise you will build a VI that generates a signal and displays that signal in a graph LabVIEW provides templates containing information from which you can build a VI These templates help you get started with LabVIEW Complete the following steps to create a VI that generates a signal and displays it on the front panel 1 Launch LabVIEW 2 Inthe LabVIEW dialog box that appears shown in the following figure click the New button to display the New dialog box El LabVIEW File Edit Tools Help NATIONAL INSTRUMENTS New Open Configure T LabVIEW el 3 Select VI from Template Tutorial Getting Started Generate and Display in the Create new list This template VI generates and displays a signal Notice that previews of the template VI appear in the Front panel preview and the Block diagram preview sections The following figure shows the New dialog box and the Generate and Display template VI National Instruments Corporation 1 27 LabVIEW Introduction Course Manual
246. p from the palette then use the cursor to drag a selection rectangle around the section of the block diagram you want to repeat When you release the mouse button a While Loop boundary encloses the section you Selected Add block diagram objects to the While Loop by dragging and dropping them inside the While Loop W Tip The While Loop always executes at least once The While Loop executes the subdiagram until the conditional terminal an input terminal receives a specific Boolean value The default behavior and appearance of the conditional terminal is Stop If True shown at left When a conditional terminal is Stop If True the While Loop executes its subdiagram until the conditional terminal receives a TRUE value E The iteration terminal an output terminal shown at left contains the number of completed iterations The iteration count always starts at zero During the first iteration the iteration terminal returns 0 In the following block diagram the While Loop executes until the subVI output is greater than or equal to 10 00 and the Enable control is TRUE The And function returns TRUE only if both inputs are TRUE Otherwise it returns FALSE LabVIEW Introduction Course Manual 3 2 ni com Lesson3 Repetition and Loops In the previous example there is an increased probability of an infinite loop Generally the desired behavior is to have one condition met to stop the loop rather than requiring both conditions to be met
247. parison Express Numeric palette to the left of the Add function Type 32 0 in the constant Use the Wiring tool shown at left to wire the icons as shown in the following block diagram LabVIEW Introduction Course Manual e To wire from one terminal to another use the Wiring tool to click the first terminal move the tool to the second terminal and click the second terminal You can start wiring at either terminal e You can bend a wire by clicking to tack down the wire and moving the cursor in a perpendicular direction Press the spacebar to toggle the wire direction 2 10 ni com Lesson2 Modular Programming e To identify terminals on the nodes right click the Multiply and Add functions and select Visible Items Terminals from the shortcut menu to display the connector pane on the block diagram Return to the icons after wiring by right clicking the functions and selecting Visible Items Terminals from the shortcut menu to remove the checkmark e When you move the Wiring tool over a terminal the terminal area blinks indicating that clicking will connect the wire to that terminal and a tip strip appears displaying the name of the terminal If the Context Help window is open the terminal area also blinks in the Context Help window e To cancel a wire you started press the lt Esc gt key right click or click the terminal where you started the wire 11 Display the front panel by clicking it or by selecting Window
248. pening VIs configuring data acquisition devices and finding helpful information National Instruments Corporation Click the New button to create anew VI Click the arrow on the New button to choose to open a blank VI or to open the New dialog box Click the Open button to open an existing VI Click the arrow on the Open button to open recent files Click the Configure button to configure your data acquisition devices Click the arrow on the Configure button to configure LabVIEW Click the Help button to launch LabVIEW Help Click the arrow on the Help button for other Help options including the NI Example Finder 1 3 LabVIEW Introduction Course Manual Lesson1 Introduction to LabVIEW Creating and Saving a VI When you click the New button in the LabVIEW dialog box the New dialog box appears You also can select File New to display this dialog box When you select a template in the Create new list previews of the VI appear in the Front panel preview and the Block diagram preview sections and a description of the template appears in the Description section Figure 1 2 shows the New dialog box and the SubVI with Error Handling VI template Front panel preview Description Use this template to build a VI to use as a al subI ee Data Acquisition with NI DAQmx vi l g Frameworks a Dialog Base Package eur Dialog Using Events Single Loop Application SubwI with Error Handling i Top Level Application Using Events
249. per Zone the KnowledgeBase and the Product Manuals Library National Instruments Corporation 1 43 LabVIEW Introduction Course Manual Lesson Introduction to LabVIEW NI Example Finder The New dialog box contains many LabVIEW template VIs that you can use to start building VIs However these template VIs are only a subset of the hundreds of example VIs included with LabVIEW You can modify any example VI to fit an application or you can copy and paste from an example into a VI that you create In addition to the example VIs that ship with LabVIEW you also can access hundreds of example VIs on the NI Developer Zone at ni com zone To search all examples using LabVIEW VIs use the NI Example Finder The NI Example Finder is the gateway to all installed examples and the examples located on the NI Developer Zone To launch the NI Example Finder select Help Find Examples from the front panel or block diagram menu bar You also can launch the NI Example Finder by clicking the arrow on the Open button on the LabVIEW dialog box and selecting Examples from the shortcut menu LabVIEW Introduction Course Manual 1 44 ni com Lesson1 Introduction to LabVIEW Exercise 1 3 Reduce Samples VI Objective Use the LabVIEW documentation resources to build a VI that generates a signal reduces the number of samples in the signal and displays the resulting data in a table on the front panel In the following exercises you will open a blank V
250. ph Palette 8 Scale Legend 11 Label 3 Grid Mark 6 Cursor Mover 9 X scale The graphs located on the Controls Graph Indicators palette include the waveform graph and XY graph The waveform graph plots only single valued functions as in y f x with points evenly distributed along the x axis such as acquired time varying waveforms XY graphs display any set of points evenly sampled or not Resize the plot legend to display multiple plots Use multiple plots to save space on the front panel and to make comparisons between plots XY and waveform graphs automatically adapt to multiple plots Single Plot Waveform Graphs The waveform graph accepts a single array of values and interprets the data as points on the graph and increments the x index by one starting at x 0 The graph also accepts a cluster of an initial x value a Ax and an array of y data Refer to the Waveform Graph VI in the NI Example Finder for examples of the data types that single plot waveform graphs accept LabVIEW Introduction Course Manual 6 14 ni com Lesson6 Plotting Data Multiplot Waveform Graphs A multiplot waveform graph accepts a 2D array of values where each row of the array is a single plot The graph interprets the data as points on the graph and increments the x index by one starting at x 0 Wire a 2D array data type to the graph right click the graph and select Transpose Array from the shortcut menu to handle each column of the array as a plot Ref
251. ple rate and the sample mode finite As with other functions you can generate multiple samples for a single channel or multiple channels Use Generate n Samples if you want to generate a finite time varying signal such as an AC sine wave Generate Continuously Continuous generation is similar to Generate n Samples except that an event must occur to stop the generation If you want to continuously generate signals such as generating a non finite AC sine wave set the timing mode to continuous When a device controlled by NI DAQmx does something it performs an action Two very common actions are producing a sample and starting a generation Every NI DAQm x action needs a stimulus or cause When the stimulus occurs the action is performed Causes for actions are called triggers The start trigger starts the generation The reference trigger 1s not supported for analog output tasks LabVIEW Introduction Course Manual 9 24 ni com Lesson9 Data Acquisition and Waveforms Exercise 9 5 Voltage Output VI Objective To output an analog voltage using a DAQ device Complete the following steps to finish a VI that outputs voltage from 0 to 9 5 V in 0 5 V steps l Front Panel Block Diagram Connect Analog Out CHO to Analog In CH1 on the DAQ Signal Accessory Open the Voltage Output VI located in the C Exercises LabVIEW Basics I directory The following front panel 1s already built Voltage Output n Voltage Output disp
252. ps in the Instrument I O Assistant dialog box that appears to configure the Express VI 1 2 3 4 Choose COM1 or COM2 depending on the connection port of the NI Instrument Simulator from the Select an instrument pull down menu Click the Add Step button and click Write In the command field type IDN and select n as the Termination character Click the Add Step button and click Read and Parse Click the Add Step button and click Read and Parse again Kp Note The Instrument Simulator returns the byte size of the response the termination character the response then another termination character Therefore after IDN is sent to the instrument the response must be read twice LabVIEW Introduction Course Manual 5 6 7 3 9 Click the Run button not the Run this step button The Run button runs the entire sequence Return to the first Read and Parse step Click the Auto parse button The value returned is the size in bytes of the query response Rename Token to String Length in the Token name text box Select the second Read and Parse step 10 Click the Auto parse button The value returned is the identification string of the NI Instrument Simulator 10 32 ni com Lesson 10 Instrument Control 11 Rename Token to String in the Token name text box The configuration window should be similar to the following figure ibe Instrument 1 0 Assistant aple a Add
253. r purchasing the LabVIEW Basics I Introduction course kit You can begin developing an application soon after you complete the exercises in this manual This course manual and the accompanying software are used in the three day hands on LabVIEW Basics I Introduction course You can apply the full purchase of this course kit toward the corresponding course registration fee if you register within 90 days of purchasing the kit Visit ni com training for online course schedules syllabi training centers and class registration National Instruments Corporation vii LabVIEW Introduction Course Manual Student Guide The LabVIEW Basics I Introduction course is part of a series of courses designed to build your proficiency with LabVIEW and help you prepare for exams to become an NI Certified LabVIEW Developer and NI Certified LabVIEW Architect The following illustration shows the courses that are part of the LabVIEW training series Refer to ni com training for more information about NI Certification LabVIEW Series Certified LabVIEW Developer Exam Certified LabVIEW Architect Exam Certification Track LabVIEW Experience LabVIEW LabVIEW LabVIEW Advanced LabVIEW Advanced Basics Basics II Performance Application g Introduction Development and Communication Development Data Acquisition and Signal Conditioning LabVIEW Instrument Control Machine Vision and Image Processing Motion Control
254. r that occurs when a VI runs by suspending execution highlighting the subVI or function where the error occurred and displaying a dialog box You can choose other error handling methods For example if an I O VI on the block diagram times out you might not want the entire application to stop You also might want the VI to retry for a certain period of time In LabVIEW you can make these error handling decisions on the block diagram of the VI VIs and functions return errors in one of two ways with numeric error codes or with an error cluster Typically functions use numeric error codes and VIs use an error cluster usually with error inputs and outputs Error handling in LabVIEW follows the dataflow model Just as data flow through a VI so can error information Wire the error information from the beginning of the VI to the end Include an error handler VI at the end of the VI to determine if the VI ran without errors Use the error in and error out clusters in each VI you use or build to pass error information through the VI As the VI runs LabVIEW tests for errors at each execution node If LabVIEW does not find any errors the node executes normally If LabVIEW detects an error the node passes the error to the next node without executing The next node does the same thing and so on Use the LabVIEW Introduction Course Manual 5 12 ni com Lesson5 Clusters Simple Error Handler VI shown in the following example to handle the e
255. r to the NI Example Finder available by selecting Help Find Examples for example VIs you can use and incorporate into VIs you create xiii LabVIEW Introduction Course Manual Student Guide E Course Conventions 3 i bao lt Ctrl gt lt Enter gt italic monospace monospace bold The following conventions appear in this course manual The symbol leads you through nested menu items and dialog box options to a final action The sequence File Page Setup Options directs you to pull down the File menu select the Page Setup item and select Options from the last dialog box This icon denotes a tip which alerts you to advisory information This icon denotes a note which alerts you to important information This icon denotes a caution which advises you of precautions to take to avoid injury data loss or a system crash This icon indicates that an exercise requires a plug in GPIB interface or DAQ device Bold text denotes items that you must select or click in the software such as menu items and dialog box options Bold text also denotes parameter names controls and buttons on the front panel dialog boxes sections of dialog boxes menu names and palette names The terminology for this course is written primarily for the Windows platform For keyboard shortcuts that instruct you to press the lt Ctrl gt key press the following keys for other platforms Mac OS press the lt Command gt key Sun press the
256. ram a set number of times You create loops by using the cursor to drag a selection rectangle around the section of the block diagram you want to repeat or by dragging and dropping block diagram objects inside the loop The Wait Until Next ms Multiple function makes sure that each iteration occurs at certain intervals Use this function to add timing to loops The Wait ms function waits a set amount of time Coercion dots appear where LabVIEW coerces a numeric representation of one terminal to match the numeric representation of another terminal Use shift registers on For Loops and While Loops to transfer values from one loop iteration to the next Create a shift register by right clicking the left or right border of a loop and selecting Add Shift Register from the shortcut menu To configure a shift register to carry over values to the next iteration right click the left terminal and select Add Element from the shortcut menu The Feedback Node stores data when the loop completes an iteration sends that value to the next iteration of the loop and transfers any data type Use the Feedback Node to avoid unnecessarily long wires 3 21 LabVIEW Introduction Course Manual Lesson3 Repetition and Loops Notes LabVIEW Introduction Course Manual 3 22 ni com Lesson 4 Arrays This lesson describes how to use arrays to group data elements of the same type You Will Learn A About arrays B How to create arrays with
257. rder of a cluster element type the new order number in the Click to set to text box and click the element The cluster order of the element changes and the cluster order of other elements adjusts Save the changes by clicking the Confirm button on the toolbar Revert to the original order by clicking the Cancel button Corresponding elements determined by the cluster order must have compatible data types For example in one cluster element 0 is a numeric control and element 1 is a string control In a second cluster element 0 is a numeric indicator and element is a string indicator The cluster control correctly wires to the cluster indicator National Instruments Corporation 5 3 LabVIEW Introduction Course Manual Lesson5 Clusters However if you change the cluster order of the indicator so the string is element 0 and the numeric is element 1 the wire from the cluster control to the cluster indicator appears broken indicating that the data types do not match LabVIEW Introduction Course Manual 5 4 ni com Lesson5 Clusters B Cluster Functions Use the Cluster functions located on the Functions All Functions Cluster palette to create and manipulate clusters Use the Bundle and Bundle by Name functions to assemble and manipulate clusters and use the Unbundle and Unbundle by Name functions to disassemble clusters You also can create the Bundle Bundle by Name Unbundle and Unbundle by Name functions by right clicking
258. resize a node on the block diagram 1 Move the Positioning tool over the node Resizing handles appear at the top and bottom of the node 2 Move the cursor over a resizing handle to change the cursor to the resizing cursor 3 Use the resizing cursor to drag the border of the node down to display additional terminals 4 Release the mouse button To cancel a resizing operation drag the node border past the block diagram window before you release the mouse button The following figure shows the Basic Function Generator VI as a resized expandable node signal out Se E National Instruments Corporation 1 23 LabVIEW Introduction Course Manual Lesson 1 yi Introduction to LabVIEW Note If you display a subVI or Express VI as an expandable node you cannot display the terminals for that node and you cannot enable database access for that node Terminals Wires Fi Front panel objects appear as terminals on the block diagram The terminals represent the data type of the control or indicator You can configure front panel controls or indicators to appear as icon or data type terminals on the block diagram By default front panel objects appear as icon terminals For example a knob icon terminal shown at left represents a knob on the front panel The DBL at the bottom of the terminal represents a data type of double precision floating point numeric To display a terminal as a data type on the block diagram right
259. riate case subdiagram based on the current item in the enumerated control In the previous block diagram if Enum is add the VI adds the numeric values If Enum is subtract the VI subtracts the numeric values LabVIEW Introduction Course Manual 7 6 ni com Lesson 7 Making Decisions ina VI Error Case Structure The following example is an error cluster Case structure When you wire an error cluster to the selector terminal of a Case structure the case selector label displays two cases Error and No Error and the border of the Case structure changes color red for Error and green for No Error The Case structure executes the appropriate case subdiagram based on the error State When an error cluster is wired to the selection terminal the Case structure recognizes only the status Boolean of the cluster National Instruments Corporation LabVIEW Introduction Course Manual Lesson Making Decisions ina VI Exercise 7 1 Square Root VI Objective To use the Case structure in a VI Complete the following steps to build a VI that checks whether a number is positive If the number is positive the VI calculates the square root of the number Otherwise the VI returns an error message Front Panel 1 Open a blank VI and build the following front panel Block Diagram Square Root Value areater Or Equal To 0 E Number a Place the Case structure located on the Functions Execution Control palette on the block
260. ric array is a little more complex You must convert the string to an integer array You can do this by using the String To Byte Array function located on the Functions All Functions String String Array Path Conversion palette You must LabVIEW Introduction Course Manual 10 34 ni com Lesson 10 Instrument Control remove all header and trailer information from the string before you can convert it to an array Otherwise this information also is converted Binary Waveform String without ALE Us Numeric Array header or trailer Binary Waveforms Encoded as 2 Byte Integers If each point in the binary waveform string is encoded as a 2 byte integer it is easier and much faster to use the Type Cast function located on the Functions All Functions Advanced Data Manipulation palette Refer to the LabVIEW Basics II Development Course Manual for more information about type casting For example consider a GPIB oscilloscope that transfers waveform data in binary notation The waveform is composed of 1 024 data points Each data point is a 2 byte signed integer Therefore the entire waveform is composed of 2 048 bytes In the following example the waveform has a 4 byte header DATA and a 2 byte trailer a carriage return followed by a linefeed 4 byte header 2 byte trailer carriage return line feed DATA KHB1 gt LB1 gt HB2 gt LB2 HB1024 LB1024 gt CR LF 2 bytes representing the first data point
261. right clicking the right border and selecting Add Output from the shortcut menu Enter y and a respectively in the boxes that appear You must create output terminals for temporary variables like a Kp Note When you create an input or output terminal you must use a variable name that exactly matches the one in the equation Variable names are case sensitive LabVIEW Introduction Course Manual 14 Lesson Making Decisions ina VI d Type the following equations in the Formula Node where is the exponentiation operator Refer to the LabVIEW Help for more information about syntax for the Formula Node a tanh x cos x yY St ate aay e Complete the block diagram as shown 2 Save the Vlas Formula Node Exercise viinthecC Exercises Run the VI LabVIEW Basics I directory Display the front panel and run the VI The graph displays the plot of the equation y f x f x where f x tanh x cos x During each iteration the VI divides the iteration terminal value by 15 0 The quotient is wired to the Formula Node which calculates the function value The VI plots the array as a graph 4 Close the VI End of Exercise 7 3 National Instruments Corporation 7 15 LabVIEW Introduction Course Manual Lesson Making Decisions ina VI Summary Tips and Tricks LabVIEW Introduction Course Manual The Select function selects between two inputs dependent on a third Boolean input A Case structure has
262. rom the Show Menu Bar and Show Toolbar When Running checkboxes d Click the OK button twice 12 Save and close all VIs 13 Open the Temperature System VI again The VI runs automatically when you open it Click the buttons on the front panel or use the keyboard shortcuts 14 Stop and close all VIs End of Exercise 11 2 LabVIEW Introduction Course Manual 11 12 ni com Lesson 11 Customizing VIS D Editing VI Properties Sometimes you can select VI properties that make it difficult to edit a VI For example you might select the Run When Opened option and disable the menu bar and toolbar If you set the VI to close and exit LabVIEW after it runs you cannot stop the VI and edit it without it closing and exiting LabVIEW This VI would be very difficult to edit Kp Note To exit LabVIEW you can use the Quit LabVIEW function located on the Functions All Functions A pplication Control palette This function aborts all running VIs and ends the current session of LabVIEW The function has one input If it is wired the end of the LabVIEW session occurs only if that input is TRUE If the input is not wired the end of the session occurs when the node executes Before you change VI properties save a backup of the VI to a new location by selecting File Save with Options to avoid situations like the previous examples Select the Development Distribution option to save the VI to a new location along with its entire hierarchy You also c
263. rporation 9 17 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms Exercise 9 3 Measurement Averaging VI Objective To reduce noise in analog measurements by averaging Run the Voltmeter VI that you completed in Exercise 9 2 2 Introduce noise into the temperature measurement by changing the Temp Sensor Noise switch on the DAQ Signal Accessory to the ON position The measurements begin to fluctuate with noise spikes Block Diagram 3 Stop the VI and display the block diagram Modify the block diagram to calculate the average of 100 measurements p Assistant ct La Statistics C deta m Signals voltage Collected Signals CEET be Friet Mean rbeRDEL Unbundle By Name Roche status ee 4 Place the Collector Express VI located on the Functions Signal Manipulation palette on the block diagram This Express VI creates an internal buffer to store the individual points When the maximum number of input points is collected the Express VI discards the oldest points and adds the newest points In the Configure Collector dialog box that appears set the Maximum number of samples to 100 Click the OK button to close the dialog box 5 Place the Statistics Express VI located on the Functions Analysis palette on the block diagram In the Configure Statistics dialog box that appears place a checkmark in the Arithmetic Mean checkbox to perform averaging on the collected data Click the OK button
264. rror at the end of the execution flow The Simple Error Handler VI is located on the Functions All Functions Time amp Dialog palette Wire the error cluster to the error in input eror code no eror 0 eror source tupe of dialog UE meg 1 P H source Out eror in no error m BOT CL Message Error Clusters The error clusters located on the Functions All Functions Array amp Cluster palette include the components of information shown in the following example error in no error error out error in no error error out code e status is a Boolean value that reports TRUE if an error occurred Most VIs functions and structures that accept Boolean data also recognize this parameter For example you can wire an error cluster to the Boolean inputs of the Stop Quit LabVIEW or Select functions If an error occurs the error cluster passes a TRUE value to the function e code is a 32 bit signed integer that identifies the error numerically A non zero error code coupled with a status of FALSE signals a warning rather than a fatal error e source is a string that identifies where the error occurred Use the error cluster controls and indicators to create error inputs and outputs in subVIs Explain Error When an error occurs right click within the cluster border and select Explain Error from the shortcut menu to open the Explain Error dialog box The Explain Error dialog box contains information abou
265. rrow keys To move objects several pixels press the lt Shift gt key while you press the arrow keys To cancel a wire you started press the lt Esc gt key right click or click the terminal where you started the wire Use the tip strips that appear as you move the Wiring tool over terminals Display the connector pane by right clicking the node and selecting Visible Items Terminals from the shortcut menu 1 58 ni com Lesson1 Introduction to LabVIEW e You can bend a wire by clicking to tack the wire down and moving the cursor in a perpendicular direction To tack down a wire and break it double click 1 Tack Down a Wire by 2 Tack and Break the Wire by Clicking Double clicking Editing e Use the following shortcuts to create constants controls and indicators Right click a function terminal and select Create Constant Create Control or Create Indicator from the shortcut menu Drag controls and indicators from the front panel to the block diagram to create a constant Drag constants from the block diagram to the front panel to create a control e To duplicate an object press the lt Ctrl gt key while using the Positioning tool to click and drag a selection e To restrict an object s direction of movement horizontally or vertically use the Positioning tool to select the object and press the lt Shift gt key while you move the object e To keep an object proportional to its original size as
266. rse Manual Lesson6 Plotting Data Exercise 6 5 Graph Circle VI Objective To plot data using an XY Graph Complete the following steps to build a VI that plots a circle using independent x and y arrays Front Panel 1 Open a blank VI and build the following front panel ey Circle Graph Circle a Place an XY Graph located on the Controls Graph Indicators palette on the front panel b Label the graph XY Circle Graph c Change Plot 0 to Circle in the plot legend d Right click the plot in the plot legend select Point Style from the shortcut menu and select the small square e Change the scale labels and ranges as shown in the previous figure Block Diagram 2 Build the following block diagram LabVIEW Introduction Course Manual 6 24 ni com Lesson6 Plotting Data a Place the Sine amp Cosine function located on the Functions Arithmetic amp Comparison Express Numeric Express Trigonometric palette on the block diagram This function builds an array of points that represents one cycle of a sine wave and a cosine wave b Place the Bundle function located on the Functions All Functions Cluster palette on the block diagram This function assembles the sine array and the cosine array to plot the sine array against the cosine array to produce a circle c Place the Pi Multiplied by 2 constant located on the Functions Arithmetic amp Comparison Express Numeric Express Numeric Constants p
267. s All Functions String String Array Path Conversion palette converts the binary string to an array of unsigned integers The String Length function located on the Functions All Functions String palette returns the number of characters in the waveform string The Extract Numbers VI located in the Exercises directory extracts numbers from the ASCII waveform string and places them in an array Non numeric characters such as commas separate numbers in the string The VISA Write and VISA Read functions located on the Functions All Functions Instrument I O VISA palette query the NI Instrument Simulator for a square wave in either ASCII or 1 byte binary format The Simple Error Handler VI located on the Functions All Functions Time amp Dialog palette reports any errors 5 Display the front panel and run the VI The TRUE case acquires and converts the binary waveform string to an array of numeric values The FALSE case acquires and converts the ASCII waveform string to an array of numeric values 6 Set Data Format to ASCII and run the VI The ASCII waveform string displays the VI converts the values to a numeric array and displays the string length and numeric array 7 Set Data Format to Binary and run the VI again The binary waveform string and string length display the VI converts the string to a numeric array and displays it in the graph Kp Note The binary waveform is similar to the ASCII waveform
268. s You also can add and delete objects Remember you can undo recent edits by selecting Edit Undo or pressing the lt Ctrl Z gt keys 6 Experiment with other properties of the knob by using the Knob Properties dialog box For example try changing the colors for the Marker Text Color by clicking the color box located on the Scale tab 7 Click the Cancel button to avoid applying the changes you made while experimenting If you want to keep the changes you made click the OK button LabVIEW Introduction Course Manual 1 36 ni com Lesson 1 Introduction to LabVIEW Customizing the Waveform Graph The waveform graph indicator displays the two signals To indicate which plotis the scaled signal and which is the simulated signal you customize the plots Complete the following steps to customize the appearance of an indicator on the front panel l Move the cursor over the top of the plot legend on the waveform graph Notice that while there are two plots on the graph the plot legend displays only one plot When a double headed arrow appears shown in the following figure click and drag the border of the plot legend until the second plot name appears t Sawtooth Scaled a 40 0 a 20 0 10 0 0 0 SC 70 05 30 0 40 0 I I I I I O 0E 0 2 0E 2 4 0E 2 6 0E 2 amp 0E 1 0E 1 Time 1 g 2 a rel Right click the waveform graph and select Properties from th
269. s Graph Palette from the shortcut menu to display the graph palette as shown in the following illustration You can place the graph palette anywhere on the front panel LabVIEW Introduction Course Manual 6 12 ni com Lesson6 Plotting Data 1 Cursor Movement Tool 3 Panning Tool 2 Zoom Button 4 Zoom Pull down Menu Use the Zoom button on the graph palette to zoom in or out of sections of the chart or the whole chart Use the Panning tool to pick up the plot and move it around on the display Use the Cursor Movement tool to move the cursor on the graph 18 Run the VI While the VI runs use the buttons in the scale legend and graph palette to modify the waveform chart Kp Note If you modify the axis labels the display might become larger than the maximum size that the VI can correctly present 19 Use the Operating tool to click the Power switch and stop the VI 20 Save and close the VI End of Exercise 6 2 National Instruments Corporation 6 13 LabVIEW Introduction Course Manual Lesson6 Plotting Data B Waveform and XY Graphs VIs with graphs usually collect the data in an array and then plot the data to the graph The following illustration shows the elements of a graph 11 waveform Graph Plot 0 mae 1 y cale name l 20 40 x scale name scaenam e y Jy scaename name y scalename Yt 1 Plot Legend 4 Mini grid Mark 7 Cursor Legend 10 Y scale 2 Cursor Graph Only 5 Gra
270. s aliases and tags to channels or measurements configured in Devices and Interfaces e Devices and Interfaces Use this section to configure resources and other physical properties of devices and interfaces and to view attributes of one or multiple devices such as serial numbers e IVI Instruments Use this section to name an IVI virtual instrument modify its properties and swap IVI instruments e Scales Use this section to set up simple operations to perform on data such as scaling the temperature reading from the DAQ Signal Accessory from volts to degrees Celsius e Historical Data Use this section to access databases and logged data National Instruments Corporation 10 5 LabVIEW Introduction Course Manual Lesson 10 Instrument Control e Software Use this section to determine which National Instruments drivers and application software are installed and their version numbers e VI Logger Tasks Use this section to create modify run and view VI Logger tasks The following example shows a GPIB interface in MAX after clicking the Scan For Instruments button on the toolbar GPIBO PCI GPIB Measurement amp Automation Explorer Of s File Edit View Tools Help Configuration a A Ef Properties aA Scan For Instruments Se NI Spy Eh GPIB Analyzer yp Show Help S My System i Data Neighborhood E SPIE Interface Number O Aa Devices and Interfaces Instrumento Primary Address 2 National Instruments GPIB a
271. s 5 2 B CIUSter Func OMS e a E alent 5 5 C OE CIS UC 10 ee E E E E E E 5 12 Lesson 6 Plotting Data Ars NV AV COTM CATS u E sestiih 6 2 B Wav ommi ana XY Gira assis ettrseb hyde sacra A O 6 14 C Miensii Plots Opt Oat isis sec sesinsacewcsanveatatiehseercaendaasaonreenctayasaiase mez EEA 6 26 Lesson Making Decisions ina VI A Making Decisions with the Select FUNCTION 2 0 0 ceecsseecceecceaeeeeeeeeeceeeeeeaeeenees 7 2 B OAS SS UU CBU Satria a a Ds oes alice chee N daw gael c aguante ede dd eased 7 3 Formula Node siossisoaitianisitionteenite aia ien A 7 13 Lesson 8 Strings and File 1 0 PR SUMING eo ae nea ia past ete cepa dle ie ude soe eagle candies eausaDeaaaeaadan 8 2 B SUG PUM CHONG ssss crdeticetvanssuain a a da aa staamhesecnusyudeaaatbent uh 8 4 Ce Tile TO Nis And Fn O 05 seat at patncte ist etae ata nitacets ies hddn eee a rien 8 10 D veh viel Fle OWS erer 8 12 E Low Level Pile VO V1 and Func ons ccisoctets los sustedonte net et ieedeiecisavisaedeadaedowke 8 16 F Formatting Spreadsheet Strings w ngbe tte eoeeietinivne esate eonite essere 8 23 Lesson 9 Data Acquisition and Waveforms A Overview and Conf guration ecesna a E E oie 9 2 B Data Acgusitonin LabVIEW xaerscisecceceiiieri ne E E E G 9 11 Eo PATIO PUE eaea a a a a a inte 9 13 D DTO o E a a a ne 9 19 E Anio OUMU ensa E 9 23 E COUME S rai a a ned iescaeatdnuminastadt ne 9 28 G DENO a R E E E A T a 9 31 LabVIEW Introduction Course Manual IV ni com
272. s preparation for the class O O O O O Course Training facility quality O O O O O Training equipment quality O O O O O Was the hardware set up correctly O Yes O No The course length was O Toolong O Justright O Too short The detail of topics covered in the course was O Toomuch O Justright O Not enough The course material was clear and easy to follow O Yes O No O Sometimes Did the course cover material as advertised OO Yes O No I had the skills or knowledge I needed to attend this course O Yes O No Ifno howcould you have been better prepared for the course What were the strong points of the course What topics would you add to the course What part s of the course need to be condensed or removed What needs to be added to the course to make it better How did you benefit from taking this course Are there others at your company who have training needs Please list Do you have other training needs that we could assist you with How did you hear about this course O NI Web site O NI Sales Representative O Mailing O Co worker O Other
273. s the VIs on the new platform Because VIs are files you can use any file transfer method or utility to move VIs between platforms You can port VIs over networks using FTP Z or XModem protocols or similar utilities Such network transfers eliminate the need for additional file translation software If you port VIs using magnetic media such as floppy disks or a moveable external hard drive you need a generic file transfer utility program such as the following e Windows MacDisk and TransferPro transfer Mac OS files to the PC format and vice versa e Mac 0S DOS Mounter MacLink and Apple File Exchange convert PC files to the Mac OS format and vice versa e Sun PC File System PCFS converts PC files to the Sun format and vice versa Kp Note Certain operating system specific VIs are not portable between platforms such as DDE Dynamic Data Exchange VIs ActiveX VIs and AppleEvents Refer to the Porting and Localizing LabVIEW VIs Application Note available by selecting Help Search the LabVIEW Bookshelf for more information about porting VIs Menus The menus at the top of a VI window contain items common to other applications such as Open Save Copy and Paste and other items specific to LabVIEW Some menu items also list shortcut key combinations Mac OS The menus appear at the top of the screen Windows and UNIX The menus display only the most recently used items by default Click the arrows at the bottom of
274. se Manual Lesson3 Repetition and Loops Stacked Shift Registers To create a stacked shift register right click the left terminal and select Add Element from the shortcut menu Stacked shift registers let you access data from previous loop iterations Stacked shift registers remember values from previous iterations and carry those values to the next iterations Stacked shift registers can only occur on the left side of the loop because the right terminal only transfers the data generated from the current iteration to the next iteration If you add two more elements to the left terminal values from the last three iterations carry over to the next iteration with the most recent iteration value stored in the top shift register The second terminal stores the data passed to it from the previous iteration and the bottom terminal stores data from two iterations ago Feedback Nodes E The Feedback Node shown at left appears automatically in a For Loop or While Loop if you wire the output of a sub VI function or group of sub VIs and functions to the input of that same VI function or group Like a shift register the Feedback Node stores data when the loop completes an iteration sends that value to the next iteration of the loop and transfers any data type Use the Feedback Node to avoid unnecessarily long wires in loops The Feedback Node arrow indicates in which direction the data flows along the wire LabVIEW Introduction Cour
275. se Manual 3 16 ni com Lesson3 Repetition and Loops You also can select the Feedback Node on the Structures palette and place it inside a For Loop or While Loop If you place the Feedback Node on the wire before you branch the wire that connects the data to the tunnel the Feedback Node passes each value to the tunnel If you place the Feedback Node on the wire after you branch the wire that connects data to the tunnel the Feedback Node passes each value back to the input of the VI or function and then passes the last value to the tunnel Exercise 3 3 contains an example of this behavior National Instruments Corporation 3 17 LabVIEW Introduction Course Manual Lesson3 Repetition and Loops Exercise 3 3 Accessing Previous Data Objective To observe the use of shift registers and feedback nodes to hold data from previous iterations of a For Loop Front Panel 1 Open the Feedback VI located in the C Exercises LabVIEW Basics I directory The following front panel is already built Feedback After This VI demonstrates two methods of using the fr Feedback Mode The First method places the Feedback Node after the Feedba ETa indicator has read kthe numerical Function D The second method places the Feedback Node before the indicator reads the numerical Function Block Diagram 2 Display the following block diagram and make sure both the front panel and block diagram are visible If necessary close or move the Tools and
276. se Manual 7 2 ni com Lesson 7 Making Decisions ina VI B Case Structures A Case structure shown at left has two or more subdiagrams or cases Only one subdiagram is visible at a time and the structure executes only one case at a time An input value determines which subdiagram executes The Case structure is similar to case statements or i f then else statements in text based programming languages a True F The case selector identifier at the top of the Case structure shown at left contains the case selector identifier in the center and decrement and increment buttons on each side Use the decrement and increment buttons to scroll through the available cases FA Wire an input value or selector to the selector terminal shown at left to determine which case executes You must wire an integer Boolean value string or enumerated type value to the selector terminal You can position the selector terminal anywhere on the left border of the Case structure If you wire a Boolean to the selector terminal the structure has a TRUE case and a FALSE case If you wire an integer string or enumerated type value to the selector terminal the structure can have up to 23 1 cases You can specify a default case for the Case structure You must specify a default case to handle out of range values or explicitly list every possible input value For example if you specified cases for 1 2 and 3 but you get an input of 4 the Ca
277. se structure executes the default case Right click the Case structure border to add duplicate remove or rearrange cases and to select a default case Selecting a Case The following block diagram is an example of the Thermometer VI that uses a Case structure instead of the Select function It is shown with the True case foremost in the Case structure DAQ Assistant data National Instruments Corporation 7 3 LabVIEW Introduction Course Manual Lesson Making Decisions ina VI To select a case type the value in the case selector identifier or use the Labeling tool to edit the values as shown in the following block diagram al kas baa i 7 False DAQ Assistant Temperature SSS SSS Temp Scale Once you have selected another case that case appears foremost as shown in the following block diagram n a ae DAQ Assistant Temperature Temp Scale If you enter a selector value that is not the same type as the object wired to the selector terminal the value appears red to indicate that you must delete or edit the value before the structure can execute and the VI will not run Also because of the possible round off error inherent in floating point arithmetic you cannot use floating point numeric values as case selector values If you wire a floating point value to the case LabVIEW rounds the value to the nearest even integer If you type a floating point value in the case selector the v
278. sets it to 9 600 baud 8 data bits odd parity one stop bit and XON XOFF software handshaking Then the VISA Write function sends the command The VISA Read function reads back up to 200 bytes into the read buffer and the Simple Error Handler VI checks the error condition National Instruments Corporation 10 29 LabVIEW Introduction Course Manual Lesson 10 Instrument Control YISA resource name write buffer byte count read buffer ASRLZHINSTR 200 baud rate 9600 YISA Configure Simple Error Serial Port YISA Writ YISA Read YISA CI i data bits lgh z Sa pa O56 Handler vi cea ee aS parity Odd i i stop bits Flow control Ji Note The VIs and functions located on the Functions All Functions Instrument I O Serial palette are also used for parallel port communication You specify the VISA resource name as being one of the LPT ports For example you can use MAX to determine that LPT1 has a VISA resource name of ASRL10 INSTR LabVIEW Introduction Course Manual 10 30 ni com Lesson 10 Instrument Control Exercise 10 5 Serial Write amp Read VI Objective To build a VI that communicates with an RS 232 device Complete the following steps to use the Instrument I O Assistant to build a VI that communicates with the NI Instrument Simulator NI Instrument Simulator 1 Power off the NI Instrument Simulator and configure it to communicate through the serial port by setting the following switches on the side o
279. sponds to the controls and indicators of that VI Define connections by assigning a front panel control or indicator to each of the connector pane terminals Create custom icons to replace the default icon by double clicking the icon in the upper right corner of the front panel to open the Icon Editor In the Icon Editor dialog box double click the Text tool to select a different font You can designate which inputs and outputs are required recommended and optional to prevent users from forgetting to wire subVI connections Right click a terminal in the connector pane and select This Connection Is from the shortcut menu Document a VI by selecting File VI Properties and selecting Documentation from the Category pull down menu When you move the cursor over a VI icon the Context Help window displays this description and indicates which terminals are required recommended or optional Add descriptions and tip strips to controls and indicators by right clicking them and selecting Description and Tip from the shortcut menu When you move the cursor over controls and indicators the Context Help window displays this description Convert a section of a VI into a subVI by using the Positioning tool to select the section of the block diagram you want to reuse and selecting Edit Create SubVI 2 22 ni com Lesson2 Modular Programming Notes National Instruments Corporation 2 23 LabVIEW Introduction Course Manual Lesson2 Modular
280. sson6 Plotting Data temperature data The Ax value of 0 25 is required so that the VI plots the temperature array points every 0 25 seconds on the waveform graph h Place the Build Array function located on the Functions All Functions Array palette on the block diagram This function creates an array of clusters from the temperature cluster and the best fit cluster i Complete the block diagram as shown 3 Save the VI as Temperature Analysis vi in the C Exercises LabVIEW Basics I directory Run the VI 4 Display the front panel and run the VI The graph displays both the temperature data and best fit curve of the temperature waveform 5 Try different values for the polynomial order constant on the block diagram and run the VI again 6 Change the appearance of the plots by modifying the plot styles and fill styles a Right click the Temp plot display in the plot legend and select Common Plots Scatter Plot from the shortcut menu the top middle option b Right click the Fitted plot display in the plot legend select Bar Plots from the shortcut menu and select the second option in the middle row The waveform graph should appear similar to the following front panel Temp Graph Temp 30 0 Fitted oo oo oo oan T oo o o o l l I ir mi T mi z T l 40 6 0 Time 3 7 Save and close the VI End of Exercise 6 4 National Instruments Corporation 6 23 LabVIEW Introduction Cou
281. stration If the Boolean control wired to the selector terminal is TRUE the VI adds the numeric values Otherwise the VI subtracts the numeric values Integer Case Structure The following example is an integer Case structure Integer is a text ring control located on the Controls Text Controls palette that associates numeric values with text items If the text ring control wired to the selector terminal is 0 add the VI adds the numeric values If the value is 1 subtract the VI subtracts the numeric values If the text ring control is any other value than 0 add or 1 subtract the VI adds the numeric values because that is the default case National Instruments Corporation 7 5 LabVIEW Introduction Course Manual Lesson Making Decisions ina VI String Case Structure The following example is a string Case structure 5 add Default If String is add the VI adds the numeric values If String is subtract the VI subtracts the numeric values Enumerated Case Structure The following example is an enumerated Case structure An enumerated control gives users a list of items from which to select The data type of an enumerated control includes information about the numeric values and string labels in the control When you wire an enumerated control to the selector terminal of a Case structure the case selector displays a case for each item in the enumerated control The Case structure executes the approp
282. strument I O Assistant icon Complete the following steps to configure the Instrument I O Assistant 1 Select an instrument Instruments that have been configured in MAX appear in the Select an instrument pull down menu 2 Choose a Code generation type VISA code generation allows for more flexibility and modularity than GPIB code generation 3 Select from the following communication steps using the Add Step button e Query and Parse Sends a query to the instrument such as IDN and parses the returned string This step combines the Write command and Read and Parse command e Write Sends a command to the instrument e Read and Parse Reads and parses data from the instrument 4 After adding the desired number of steps click the Run button to test the sequence of communication that you have configured for the Express VI 5 Click the OK button to exit the Instrument I O Assistant configuration dialog box LabVIEW adds input and output terminals to the Instrument I O Assistant Express VI on the block diagram that correspond to the data you will receive from the instrument National Instruments Corporation 10 9 LabVIEW Introduction Course Manual Lesson 10 Instrument Control To view the code generated by the Instrument I O Assistant right click the Instrument I O Assistant icon and select Open Front Panel from the shortcut menu This converts the Express VI to a subVI Switch to the block diagram to see the code
283. t e To edit a VI with properties that make the VI difficult to edit Break one of its subVIs The VI opens in edit mode because it cannot run with a broken subVI Ifthe VI has no subVIs place it on the block diagram of a new VI e The simplest method for adding VIs and controls to the Controls and Functions palettes is to save them in the user 1ib directory e To create or edit a custom palette view select Tools Advanced Edit Palette Views e Change to an icon or text only palette view by selecting from the Format pull down menu National Instruments Corporation 11 17 LabVIEW Introduction Course Manual Lesson11 Customizing VIs Notes LabVIEW Introduction Course Manual 11 18 ni com Appendix A This appendix contains additional information about LabVIEW A Additional Information This section describes how you can receive more information regarding LabVIEW instrument drivers and other topics related to this course National Instruments Technical Support Options The best way to get technical support and other information about LabVIEW test and measurement instrumentation and other National Instruments products and services is the NI Web site at ni com The support page for the National Instruments Web site contains links to application notes the support KnowledgeBase hundreds of examples and troubleshooting wizards for all topics discussed in this course and more Another excellent pla
284. t Ctrl N gt keys to open a blank VI Create the following front panel Temp Scale Temperature degt 100 o J deg F a0 TE 402 ans E Place a thermometer located on the Controls Numeric Indicators palette on the front panel Type Temperature in the label and press the lt Enter gt key or click the Enter button on the toolbar shown at left Right click the thermometer and select Visible Items Digital Display from the shortcut menu to show the digital display for the thermometer Place a vertical toggle switch control located on the Controls Buttons amp Switches palette on the front panel Type Temp Scale in the label and press the lt Enter gt key or click the Enter button 2 16 ni com Lesson2 Modular Programming f Use the Labeling tool shown at left to place a free label deg C next to the TRUE position of the switch If you are using automatic tool selection double click the blank area of the front panel to begin typing a free label g Place a free label deg F next to the FALSE position of the switch User Documentation 3 Document the VI so a description appears in the Context Help window when you move the cursor over the VI icon a Select File VI Properties to display the VI Properties dialog box b Select Documentation from the Category pull down menu c Type the following description for the VI in the VI description text box This VI measures temperature using the
285. t file name Read File Close File Simple Error Handler vi Function Open Create Replace File vi String Read from File a Place the Open Create Replace File VI located on the Functions All Functions File I O palette on the block diagram This VI displays a dialog box that you use to open or create a file Right click the prompt input select Create Constant from the shortcut menu and type Select Filename in the constant Right click the function input select Create Constant from the shortcut menu and click the constant with the Operating tool to select open b Place the Read File function located on the Functions All Functions File I O palette on the block diagram This function reads count bytes of data from the file starting at the beginning of the file 8 21 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O CLOSE c Place the Close File function located on the Functions All aa Functions File I O palette on the block diagram This function closes the file d Place the Simple Error Handler VI located on the Functions All Functions Time amp Dialog palette on the block diagram This VI checks the error cluster and displays a dialog box if an error occurs e Complete the block diagram as shown in the previous figure 3 Save the VI as File Reader vi in the C Exercises LabVIEW Basics I directory Run the VI 4 Display the front panel and use the Operating tool to click the Brows
286. t on the block diagram of another VI There is no limit on the number of layers in the hierarchy Using modular programming helps you manage changes and debug the block diagram quickly A VI within another VI is called a subVI A subVI corresponds to a subroutine in text based programming languages When you double click a subVI a front panel and block diagram appear rather than a dialog box in which you can configure options The front panel includes controls and indicators that might look familiar The block diagram includes wires front panel icons functions possibly subVIs and other LabVIEW objects that also might look familiar The upper right corner of the front panel and block diagram displays the icon for the VI This icon is the same as the icon that appears when you place the VI on the block diagram icon and Connector Pane After you build a front panel and block diagram build the icon and the connector pane so you can use the VI as a subVI Every VI displays an icon such as the one shown at left in the upper right corner of the front panel and block diagram windows An icon is a graphical representation of a VI It can contain text images or a combination of both If you use a VI as a subVI the icon identifies the subVI on the block diagram of the VI You can double click the icon to customize or edit it You also need to build a connector pane shown at left to use the VI as a subVI The connector pane is a set of term
287. t the error The shortcut menu includes an Explain Warning option if the VI contains warnings but no errors You also can access the Explain Error dialog box from the Help Explain Error menu National Instruments Corporation 5 13 LabVIEW Introduction Course Manual Lesson5 Clusters Using While Loops for Error Handling You can wire an error cluster to the conditional terminal of a While Loop to stop the iteration of the While Loop When you wire the error cluster to the conditional terminal only the TRUE or FALSE value of the status parameter of the error cluster is passed to the terminal When an error occurs the While Loop stops error in no error When an error cluster 1s wired to the conditional terminal the shortcut menu items Stop if True and Continue if True change to Stop on Error and Continue while Error LabVIEW Introduction Course Manual 5 14 ni com Lesson5 Clusters Summary Tips and Tricks National Instruments Corporation Clusters group data elements of mixed types A cluster cannot contain a mixture of controls and indicators If a front panel contains more than 28 controls and indicators that you want to use programmatically group some of them into a cluster and assign the cluster to a terminal on the connector pane to eliminate clutter on the block diagram To create a cluster control or indicator select a cluster on the Functions All Functions Array amp Cluster palette place it on the
288. ta flows along these wires The block diagram should appear similar to the following figure Generate and Display Acquiring a Signal yvi Block Diagram ojx Ele Edt operate Tools Browse Window Hee _ m h LS Scaling and Simulate Signal Mapping ol Select File Save to save this VI Displaying Two Signals on the Graph To compare the signal generated by the Simulate Signal Express VI and the signal modified by the Scaling and Mapping Express VI on the same graph use the Merge Signals function Complete the following steps to display two signals on the same graph l 2 LabVIEW Introduction Course Manual Move the cursor over the arrow on the Sawtooth output of the Simulate Signal Express VI Using the Wiring tool wire the Sawtooth output to the Waveform Graph terminal The Merge Signals function shown at left appears where the two wires connect This function takes the two separate signals and combines them so that both can be displayed on the same graph The block diagram should appear similar to the following figure 1 34 ni com Lesson1 Introduction to LabVIEW I gt Generate and Display Acquiring a Signal vi Block Diagram ol x Bile Edit Operate Tools Browse Window Help _ N 2 mE hele aes sed ah SY Scaling and Simulate Signal Mapping Sawtooth rg 3 Select File Save to save this VI You also can press the lt Ctrl S gt keys to save
289. te shown in Figure 1 5 is available only on the block diagram The Functions palette contains the VIs and functions you use to build the block diagram Refer to the Block Diagram section of this lesson for more information about using the Functions palette on the block diagram The VIs and functions located on the Functions palette depend on the palette view currently selected The VIs and functions are located on subpalettes based on the types of VIs and functions lind ie Functions asane pa i User m a Exec z M Sig Manip All Functions Figure 1 5 Functions Palette LabVIEW Introduction Course Manual 1 14 ni com Lesson1 Introduction to LabVIEW Changing Palette Views Use the Options button on the Controls or Functions palette toolbar to change to another palette view or format hare Click the Options button shown at left on the Controls or Functions palette toolbar to display the Controls Functions Palettes page of the Options dialog box Select a palette view from the Palette View pull down menu Select a format from the Format pull down menu such as Standard All Icons All Text or Icons and Text Click the OK button The Controls and Functions palettes change to the palette view and format you selected Searching for Controls Vis and Functions Use the following navigation buttons on the Controls and Functions palettes to navigate and search for controls VIs and functions National Ins
290. termination method because the transfer stops on the logical OR of EOI EOS if used in conjunction with the byte count Thus you typically set the byte count to equal or exceed the expected number of bytes to be read To achieve the high data transfer rate that the GPIB was designed for you must limit the number of devices on the bus and the physical distance between devices The following restrictions are typical A maximum separation of 4 m between any two devices and an average separation of 2 m over the entire bus A maximum total cable length of 20 m A maximum of 15 devices connected to each bus with at least two thirds powered on For high speed operation the following restrictions apply All devices in the system must be powered on Cable lengths must be as short as possible with up to a maximum of 15 m of cable for each system There must be at least one equivalent device load per meter of cable If you want to exceed these limitations you can use a bus extender to increase the cable length or a bus expander to increase the number of device loads You can order bus extenders and expanders from National Instruments ny Note Refer to the National Instruments GPIB support Web site at ni com support gpibsupp htm for more information about GPIB LabVIEW Introduction Course Manual 10 4 ni com Lesson 10 Instrument Control Software Architecture The software architecture for GPIB instrument control using LabVI
291. that the Configure Scaling and Mapping dialog box automatically opens when you place the Express VI on the block diagram 5 Define the value of the scaling factor by entering 10 in the Slope m text box The Configure Scaling and Mapping dialog box should appear similar to the following figure If Configure Scaling and Mapping Scaling and 4 Scaling or Mapping Type Normalize Lowest peak Highest peak D 1 ie Linear m b Slope im Y intercept b fio 0 amp Logarithmic dB reference 1 Interpolated Define Table OK Cancel Help 6 Click the OK button to apply the current configuration and close the Configure Scaling and Mapping dialog box National Instruments Corporation 1 33 LabVIEW Introduction Course Manual Lesson1 Introduction to LabVIEW a i D F k a r Scaling and Simulate Signal Mapping SawtestF cay caled Sena O 10 Move the cursor over the arrow on the Sawtooth output of the Simulate Signal Express VI When the Wiring tool appears click the arrow and then click the arrow on the Signals input of the Scaling and Mapping Express VI shown at left to wire the two objects together Using the Wiring tool wire the Scaled Signals output of the Scaling and Mapping Express VI to the Waveform Graph terminal Notice the wires connecting the Express VIs and terminals The arrows on the Express VIs and terminals indicate the direction that the da
292. the front panel when called e Dialog The VI functions as a dialog box in the operating system so the user cannot interact with other LabVIEW windows while this VI window is open This option does not prevent you from bringing windows of other applications to the front UNIX You cannot make a window stay in front of all other windows Dialog style windows stay on top have no menu bar scrollbars or toolbar allow the user to close the window but not resize it allow run time shortcut menus and show the front panel when called Also if a Boolean parameter on the front panel is associated with the lt Enter gt or lt Return gt key LabVIEW highlights the parameter with a dark border e Default Same window style used in the LabVIEW development environment e Custom Custom window style e Customize Displays the Customize Window Appearance dialog box National Instruments Corporation 11 3 LabVIEW Introduction Course Manual Lesson11 Customizing VIs Window Size In the VI Properties dialog box select Window Size from the Category pull down menu to customize the window size for VIs This page includes the following components LabVIEW Introduction Course Manual Minimum Panel Size Sets the minimum size of the front panel If you allow the user to resize the window on the Window Appearance page the user cannot resize the front panel smaller than the width and height you set on this page Size the front panel to
293. the block diagram This function returns either the Fahrenheit FALSE or Celsius TRUE temperature value depending on the value of Temp Scale 2 18 ni com Lesson2 Modular Programming Use the Positioning tool to place the icons as shown in the previous block diagram and use the Wiring tool to wire them together W Tip To display terminals for a node right click the icon and select Visible Items Terminals from the shortcut menu Front Panel 12 Display the front panel by clicking it or by selecting Window Show Front Panel 13 Click the Run Continuously button shown at left to run the VI continuously 14 Put your finger on the temperature sensor and notice the temperature increase 15 Click the Run Continuously button again to stop the VI This allows the VI to finish the current run of the VI icon and Connector Pane 16 Create an icon so you can use the Thermometer VI as a subVI The following icon is an example If necessary create a simpler icon to save time Icon Editor File Edit Help Copy From Black amp white 16 Colors 256 Colors Show Terminals a Right click the icon in the upper right corner of the front panel and select Edit Icon from the shortcut menu The Icon Editor dialog box appears a b Double click the Select tool shown at left on the left side of the i Icon Editor dialog box to select the default icon Press the lt Delete gt key to remove the default icon C d
294. the entry Do not use the lt Enter gt key on the main keyboard because in this case it adds the return character to the search expression 8 8 ni com Lesson 8 Strings and File I O d Place the Scan From String function located on the Functions All Functions String palette on the block diagram This function converts the string after the colon to a numeric value e Complete the block diagram as shown in the previous figure icon amp Connector Pane 3 Run the VI 6 Display the front panel and create an icon and connector pane so you can use this VI as a subVI later in this course Refer to Lesson 2 Modular Programming for more information about creating icons and connector panes Header Combined String Number String Length Trailer Number Out String 2 Offset Past Match Save the VI as Create String vi in the C Exercises LabVIEW Basics I directory You will use this VI later in the course Change the values of the front panel controls and run the VI The VI concatenates Header Number and Trailer into Combined String and displays the string length The VI also searches String 2 for a colon converts the string following the colon to Number Out and displays the index of the first character after the colon in Offset Past Match Save and close the VI End of Exercise 8 1 National Instruments Corporation 8 9 LabVIEW Introduction Course Manual Lesson 8 Strings and File I O C File 1 0 Vis a
295. the filename For example home testdata test1 dat is the pathname to a file named test1 dat in the testdata directory in the home directory Filenames and pathnames are case sensitive Consists of the volume name the name of the disk a colon colon separated folder names and the filename For example Hard Disk testdata test1 dat is the pathname to a file named test1 dat in a folder named testdata on a disk named Hard Disk The following block diagram shows how to write string data to a file while programmatically wiring the filename and pathname If the file already exists it is replaced otherwise a new file is created Openi Create Replace File vi DC bestdabaitest1 dat 4h create or replace The Open Create Replace File VI opens the file test1 dat The VI also generates a refnum and an error cluster When you open a file device or network connection LabVIEW creates a refnum associated with that file device or network connection All Operations you perform on open files devices or network connections use refnums to identify each object The error cluster and refnum pass in sequence from one node to the next Because a node cannot execute until it receives all its inputs passing these two parameters forces the nodes to run in order and creates a data dependency The Open Create Replace File VI passes the refnum and error cluster to the Write File function which writes the data to disk When the Write F
296. the instrument Block Diagram 3 Build the following block diagram write buffer byte count VISA resource NAME YISA Open YISA Read YISA Close Simple Error Handler vi Lick a Place the VISA Open function located on the Functions All Functions Instrument I O VISA VISA Advanced palette on the block diagram This function opens a VISA session with an instrument Right click the VISA resource name input and select Create Control from the shortcut menu LabVIEW Introduction Course Manual 10 16 ni com de Lesson 10 Instrument Control b Place the VISA Write function located on the Functions All Functions Instrument I O VISA palette on the block diagram This function writes a string to the instrument Right click the write buffer input and select Create Control from the shortcut menu c Place the VISA Read function located on the Functions All Functions Instrument I O VISA palette on the block diagram This function reads data from the instrument Right click the byte count input and select Create Control from the shortcut menu Right click the read buffer output and select Create Indicator from the shortcut menu d Place the VISA Close function located on the Functions All Functions Instrument I O VISA VISA Advanced palette on the block diagram This function closes the session with the instrument and releases any system resources that were used e Place the Simple Error Handler VI loc
297. the reduced signal If the Enable switch is off the graph does not display the reduced signal 7 Click the STOP button to stop the VI Using a Table to Display Data Complete the following steps to display a collection of mean values in a table on the front panel 1 On the front panel select the Express Table indicator on the Controls Text Indicators palette and place it on the front panel to the right of the waveform graph 2 Display the block diagram Notice that the Table terminal appears wired to the Build Table Express VI automatically 3 Ifthe Build Table Express VI and the Table terminal are not selected i EF already click an open space on the block diagram to the left of the Build puidTable FEE Table Express VI and the Table terminal Drag the cursor diagonally until the selection rectangle encloses the Build Table Express VI and the Table terminal shown at left A moving dashed outline called a marquee highlights the Build Table Express VI the Table terminal and the wire joining the two 4 Drag the objects into the While Loop to the right of the Mean terminal Notice that the While Loop automatically resizes to enclose the Build Table Express VI and the Table terminal 5 Using the Wiring tool wire the Mean terminal of the Sample Compression Express VI to the Signals input of the Build Table Express VI LabVIEW Introduction Course Manual 1 50 ni com Lesson1 Introduction to LabVIEW
298. the width and height of the entire screen Automatically resizes the front panel window to fit the screen when you run the VI The VI does not retain a record of its original size and location so it stays in the new location if you switch back to edit mode Maintain proportions of window for different monitor resolutions Resizes the VI so it takes up approximately the same amount of screen space when opened on a computer with a different monitor resolution For example if you develop a VI on a computer with a monitor resolution of 1 024 x 768 you might want to run the VI ona computer with a monitor resolution of 800 x 600 Use this control in conjunction with scaling one or all the objects on the front panel Scale all objects on front panel as the window resizes Automatically resizes all front panel objects with respect to and in proportion to the size of the front panel window Text does not resize because the font sizes are fixed Use this option when you allow the user to resize the front panel window 11 4 ni com Lesson 11 Customizing VIS B Opening SubVI Front Panels when a VI Runs A single front panel sometimes 1s too restrictive to present numerous options or displays To solve this problem organize VIs so the top most VI presents high level options and subVIs present related options W Tip You also can use tab controls to make the front panel more usable Single Instance Every Instance When LabVIEW calls a su
299. tions Palettes Optional You can customize the Controls and Functions palettes to add VIs and controls to the palettes hide VIs and functions or rearrange the built in palettes to make the VIs and functions you use frequently more accessible Adding Vis and Controls to the User Library and the Instrument Library The simplest method for adding VIs and controls to the Controls and Functions palettes is to save them in the labview user 1ib directory When you restart LabVIEW the Functions Express User Libraries and Controls Express User Controls palettes contain subpalettes for each directory VI library 11b or menu mnu file in the labview user lib directory and icons for each file in the Llabview user 1lib directory After you add files to or remove files from specific directories LabVIEW automatically updates the palettes when you restart LabVIEW The Functions All Functions Instrument I O palette corresponds to the labview instr 1ib directory Save instrument drivers in this directory to add them to the Functions palette When you add VIs or controls to the Controls and Functions palettes using this method you cannot set the name of each subpalette or the exact location of the VIs or controls on the palettes Creating and Editing Custom Palette Views To control the name of each subpalette and the exact location of the VIs and controls you add to the Controls and Functions palettes you must create a custom palette view
300. tions and the Array functions to format the data and to combine the strings Then write the data to a file Format Into File Use the Format Into File function to format string numeric path and Boolean data as text and write the text to a file Often you can use this function instead of separately formatting the string with the Format Into String function or Build Text Express VI and writing the resulting string with the Write Characters To File VI or Write File function Use the Format Into File function to determine the order in which the data appears in the text file However you cannot use this function to append data to a file or overwrite existing data in a file For these operations use the Format Into String function with the Write File function You can wire a refnum or path to the input file terminal of the Format Into File function or you can leave this input unwired for a dialog box to prompt you for the filename In the following block diagram the Open Create Replace File VI opens a file and the For Loop executes five times The Format Into File function converts the iteration count and the random number to strings and places the tab and end of line characters in the correct positions to create two columns and one row in spreadsheet format After the loop completes five iterations the file closes and the VI checks the error condition National Instruments Corporation 8 23 LabVIEW Introduction Course Manual Lesson 8 S
301. to File Writes a character string to a new byte stream file or appends the string to an existing file The VI opens or creates the file before writing to it and closes it afterwards Read Characters From File Reads a specified number of characters from a byte stream file beginning at start of read offset The VI opens the file before reading from it and closes it afterwards Read Lines From File Reads a specified number of lines from a text or binary file beginning at a specified character offset The VI opens the file before reading from it and closes it afterwards Binary File VIs These VIs read from and write to binary files Data can be integers or single precision numbers 8 12 ni com Lesson 8 Strings and File 1 0 Exercise 8 2 Spreadsheet Example VI Objective To save a 2D array ina text file so a spreadsheet application can access the file and to display numeric data in a table Complete the following steps to examine a VI that saves numeric arrays to a file in a format you can access with a spreadsheet Front Panel 1 Open the Spreadsheet Example VI located in the C Exercises LabVIEW Basics I directory The following front panel is already built DE Waveform Graph Cosine 1 0 0 5 l o3 o l aou q oeo 60 80 100 120 140 Run the VI 2 Run the VI The VI generates a 2D array of 128 rows x 3 columns The first column contains data for a sine waveform the second column contains data for a noise
302. to close the dialog box 6 Select File Save As to save the VI as Measurement Averaging vi in the C Exercises LabVIEW Basics I directory 7 Display the front panel and run the VI Notice that the noise spikes are reduced when the Temp Sensor Noise switch is turned on 8 Stop and close the VI End of Exercise 9 3 LabVIEW Introduction Course Manual 9 18 ni com Lesson9 Data Acquisition and Waveforms D Data Logging It is often necessary to permanently store data acquired from the DAQ device Remember the following important considerations when planning to store data to a file e Not all data logging applications use LabVIEW to process and analyze the stored data Consider which applications will need to read the data e The data storage format defines which applications can read the file Since LabVIEW contains standard file operation functions that exist in other languages the programmer has complete control over the data logging process LabVIEW includes the ability to create a LabVIEW measurement file an ASCII text file that can be read by a spreadsheet or a text editor The LabVIEW measurement file is easy to create in LabVIEW and easy to read in LabVIEW or other applications The Write LabVIEW Measurement File Express VI located on the Functions Output palette writes signals to a LabVIEW measurement file When you place this Express VI on the block diagram a configuration dialog box appears where you can specify
303. tool selection Press the lt Shift Tab gt keys or click the Automatic Tool Selection button to enable automatic tool selection again You also can manually select a tool on the Tools palette to disable automatic tool selection Press the lt Tab gt or lt Shift Tab gt keys or click the Automatic Tool Selection button on the Tools palette to enable automatic tool selection again If automatic tool selection is disabled you can press the spacebar to switch to the next most useful tool Use the Operating tool shown at left to change the values of a control or select the text within a control The Operating tool changes to the icon shown at left when it moves over a text control such as a numeric or string control Use the Positioning tool shown at left to select move or resize objects The Positioning tool changes to resizing handles when it moves over the edge of a resizable object Use the Labeling tool shown at left to edit text and create free labels The Labeling tool changes to the following icon when you create free labels Use the Wiring tool shown at left to wire objects together on the block diagram Use the Object Shortcut Menu tool shown at left to access an object shortcut menu with the left mouse button Use the Scrolling tool shown at left to scroll through windows without using scrollbars Use the Breakpoint tool shown at left to set breakpoints on VIs functions nodes wires and structures to pause ex
304. trings and File I O Tab Constant Enter Filename Random Number 0 1 al a Function fopen 0 open or create Y Open Create Replace File vi i End of Line Constant This VI creates the following text file where an arrow indicates a tab and a paragraph symbol q indicates an end of line character 0 gt 0 7981419 150 6593649 2 70 5814094 330 52643379 4 gt 0 1710629 You can open the previous text file in a spreadsheet application to display the following spreadsheet Write LabVIEW Measurement File In the following block diagram the Write LabVIEW Measurement File Express VI includes the open write close and error handling functions It also handles formatting the string with either a tab or comma delimiter The Merge Signals function combines the iteration count and the random number into the dynamic data type Write LabyIE yy Measurement File Random Number 0 1 LabVIEW Introduction Course Manual 8 24 ni com Lesson 8 Strings and File I O The following dialog box shows the configuration for the Write LabVIEW Measurement File Express VI Configure Write LabVIEW Measurement File Write LabVIEW Measurement File File name Ci Exercises data lm A Action Segment Headers Save to one file One header per segment 4sk user bo choose File O One header only Ask only once No headers Ask each iteration Yalue Columns If a file already exists O One column per c
305. truments Corporation Up to Owning Palette Navigates up one level in the palette hierarchy Search Changes the palette to search mode In search mode you can perform text based searches to locate controls VIs or functions on the palettes For example if you want to find the Random Number function click the Search button on the Functions palette toolbar and start typing Random Number in the text box at the top of the palette LabVIEW lists all matching items that either start with or contain the text you typed You can click one of the search results and drag it to the block diagram as shown in the following example lind ie Functions i Arem 2 andom Periodic Random Moise PtEyPt wi 2 Periodic Random Noise Waveform yvi lt lt Vaveform Generation gt gt Periodic Random Noise Waveform vi lt lt Waveform Generation gt gt Periodic Random Noise vi Random Number 0 1 lt lt Express Numeric gt gt Random Number 0 1 Numeric gt Cl Simulate Arbitrary Signal C Simulate Signal lt lt Wayveform Generation gt gt OI Simulate Signal lt lt Waveform Generation C Simulate Signal lt lt Inpuk gt gt O Simulate Signal lt lt Signal nalysis gt gt Options 1 15 LabVIEW Introduction Course Manual Lesson1 Introduction to LabVIEW Double click the search result to highlight its location on the palette You then can click the Up to Owning Palette button to view the hierarchy of where the
306. ts National Instruments Corporation Create new Displays templates you can use to start building VIs and other LabVIEW documents Select from the following templates and click the OK button to start building a VI or other LabVIEW document Blank VI Opens a blank front panel and blank block diagram VI from Template Opens a front panel and block diagram with components you need to build different types of VIs e DAQ Opens a front panel and a block diagram with the components you need to measure or generate signals using the DAQ Assistant Express VI and NI DAQmx e Frameworks Opens a front panel and block diagram with the components and settings you need to build VIs that include a specific type of functionality e Instrument I O Opens a front panel and block diagram with the components you need to communicate with an external instrument attached to the computer through a port such as a serial or GPIB enabled device e Simulated Opens a front panel and block diagram with the components you need to simulate acquiring data from a device e Tutorial Getting Started Opens a front panel and block diagram with the components you need to build the VIs for the exercises in the Getting Started manual Other Document Types Opens the tools you use to build other LabVIEW objects Browse for Template Displays the Browse dialog box so you can navigate to a VI control or template If you previously have br
307. two or more subdiagrams or cases Only one subdiagram is visible at a time and the structure executes only one case at a time If the case selector terminal is a Boolean value the structure has a TRUE case and a FALSE case If the selector terminal is an integer string or enumerated type value the structure can have up to 23 1 cases Inputs are available to all subdiagrams of a Case structure but subdiagrams do not need to use each input If at least one output tunnel is not defined all output tunnels on the structure appear as white squares When creating a subVI from a Case structure wire the error input to the selector terminal and place all subVI code within the No Error case to prevent the subVI from executing if it receives an error Formula Nodes are useful for equations that have many variables or are otherwise complicated and for using existing text based code Each equation statement must terminate with a semicolon 7 16 ni com Lesson 7 Making Decisions ina VI Additional Exercises 7 4 Build a VI that uses the Formula Node to calculate the following equations yy xX x4 5 Yo mx b Use only one Formula Node for both equations and use a semicolon after each equation in the node Save the VI as Eqguations vi in the C Exercises LabVIEW Basics I directory 7 5 Build a VI that functions like a calculator On the front panel use numeric controls to input two numbers and a numeric indicat
308. u want to use and then add it to the block diagram l 10 Modifying the Signal If the Context Help window is not visible press the lt Ctrl H gt keys to open the Context Help window You also can press the Show Context Help Window button shown at left to open the Context Help window Select the Input palette on the Functions palette and move the cursor over the Express VIs on the Input palette Notice that the Context Help window displays information about the function of each Express VI From the information provided in the Context Help window find the Express VI that can simulate a sine wave signal Select the Express VI and place it on the block diagram The Configure Simulate Signal dialog box appears Idle the cursor over the various options in the Configure Simulate Signal dialog box such as Frequency Hz Amplitude and Samples per second Hz Read the information that appears in the Context Help window Configure the Simulate Signal Express VI to generate a sine wave with a frequency of 10 7 and amplitude of 2 Notice how the signal displayed in the Result Preview window changes to reflect the configured sine wave Close the Configure Simulate Signal dialog box by clicking the OK button Move the cursor over the Simulate Signal Express VI and read the information that appears in the Context Help window Notice that the Context Help window now displays the configuration of the Simulate Signal Express VI
309. uction Course Manual 9 36 ni com Lesson 10 Instrument Control This lesson describes how you can use LabVIEW to control and acquire data from external GPIB and serial port instruments Use instrument drivers along with the Instrument I O Assistant to perform instrument I O You Will Learn About instrument control About GPIB communication and configuration How to use the Instrument I O Assistant About VISA About LabVIEW instrument drivers How to use instrument driver VIs About serial communication ay Gy io ie ae Oh es About waveform transfers Optional National Instruments Corporation 10 1 LabVIEW Introduction Course Manual Lesson 10 Instrument Control A Instrument Control Overview You are not limited to the type of instrument that you control if you choose industry standard control technologies You can use instruments from many different categories including serial GPIB VXI PXI computer based instruments Ethernet SCSI CAMAC and parallel port devices This lesson describes the two most common instrument communication methods GPIB and serial port communication You must consider the following issues with PC control of instrumentation e Type of connector pinouts on the instrument e Cables needed null modem number of pins male female e Electrical properties involved signal levels grounding cable length restrictions e Communication protocols used ASCII commands binary co
310. udes step by step instructions for correcting the error Click the Show Error button or double click the error description to highlight the area on the block diagram that contains the error Use the Error list window to fix each error Select File Save to save the VI 5 Display the front panel by clicking it or by selecting Window Show Front Panel Run the VI Click the Run button to run the VI several times Select Window Show Block Diagram to display the block diagram 8 Animate the flow of data through the block diagram a Click the Highlight Execution button shown at left on the toolbar to enable execution highlighting Click the Step Into button shown at left to start single stepping Execution highlighting shows the movement of data on the block diagram from one node to another using bubbles that move along the wires Nodes blink to indicate they are ready to execute Click the Step Over button shown at left after each node to step through the entire block diagram Each time you click the Step Over button the current node executes and pauses at the next node Data appear on the front panel as you step through the VI The VI generates a random number and multiplies it by 10 0 The subVI adds 100 0 and takes the square root of the result When a blinking border surrounds the entire block diagram click the Step Out button shown at left to stop single stepping through the Debug Exercise Main VI 9 S
311. ugh the block diagram Click the button again to disable execution highlighting Click the Step Into button shown at left to open a node and pause When you click the Step Into button again it executes the first action and pauses at the next action of the subVI or structure You also can press the lt Ctrl gt and down arrow keys Single stepping through a VI steps through the VI node by node Each node blinks to denote when it is ready to execute By stepping into the node you are ready to single step inside the node Click the Step Over button shown at left to execute a node and pause at the next node You also can press the lt Ctrl gt and right arrow keys By stepping over the node you execute the node without single stepping through the node Click the Step Out button shown at left to finish executing the current node and pause When the VI finishes executing the Step Out button becomes dimmed You also can press the lt Ctrl gt and up arrow keys By stepping out National Instruments Corporation 1 11 LabVIEW Introduction Course Manual Lesson1 Introduction to LabVIEW Palettes ii Note of a node you complete single stepping through the node and go to the next node The Warning button shown at left appears if a VI includes a warning and you placed a checkmark in the Show Warnings checkbox in the Error List window A warning indicates there is a potential problem with the block diagram but it does not stop the
312. ular Programming The following pseudo code and block diagrams demonstrate the analogy between subVIs and subroutines Function Code Calling Program Code function average inl in2 out average pointl point 2 inl in2 2 0 pointavg LabVIEW Introduction Course Manual 2 4 ni com Lesson2 Modular Programming B Icons and Connector Panes After you build a VI front panel and block diagram build the icon and the connector pane so you can use the VI as a subVI Creating an Icon i Every VI displays an icon shown at left in the upper right corner of the front panel and block diagram windows An icon is a graphical representation of a VI It can contain text images or a combination of both If you use a VI as asubVI the icon identifies the subVI on the block diagram of the VI The default icon contains a number that indicates how many new VIs you have opened since launching LabVIEW Create custom icons to replace the default icon by right clicking the icon in the upper right corner of the front panel or block diagram and selecting Edit Icon from the shortcut menu or double clicking the icon in the upper right corner of the front panel You also can edit icons by selecting File VI Properties selecting General from the Category pull down menu and clicking the Edit Icon button Use the tools on the left side of the Icon Editor dialog box to create the icon design in the editing area The normal size image o
313. ulates a temperature measurement every 500 ms and plots it on a strip chart The Display and Log Temp VI simulates a temperature measurement every 500 ms plots it on a strip chart and logs it to a file The Display Logged Temp VI opens a file that you select reads the logged data and displays them on a graph Configure each subVI to display its front panel when called a Right click the subVI and select Sub VI Node Setup from the shortcut menu b Place checkmarks in the Show Front Panel when called and Close afterwards if originally closed checkboxes c Click OK to close the Sub VI Node Setup dialog box d Repeat steps a through c for the remaining two subVIs Save the VI Display the front panel and run the VI Click each button and press the corresponding keyboard shortcuts The three subVIs return to the Temperature System VI front panel when you press the lt Enter gt key Try pressing the lt Enter gt key to do so Stop the VI Configure the Temperature System VI to run automatically when you open the VI a Select File VI Properties b Select Execution from the Category pull down menu c Place a checkmark in the Run When Opened checkbox 11 11 LabVIEW Introduction Course Manual Lesson11 Customizing VIs 11 Configure the VI so the menu bar and toolbar are not visible while the VI runs Select Window Appearance from the Category pull down menu Click the Customize button c Remove the checkmarks f
314. uments Corporation xi LabVIEW Introduction Course Manual Student Guide C Installing the Course Software Complete the following steps to install the course software Windows 1 Copy the contents of the nidevsinm directory to the labview instr lib directory After you start LabVIEW the NI DevSim instrument driver is located on the Functions Input Instrument Drivers palette 2 Copy the Exercises directory to the top level of the C directory Copy the Solutions directory to the top level of the C directory LabVIEW Introduction Course Manual xii ni com Student Guide D Course Goals and Non Goals This course prepares you to do the following Understand front panels block diagrams icons and connector panes Use the programming structures and data types that exist in LabVIEW Use various editing and debugging techniques Create and save VIs so you can use them as subVIs Display and log data Create applications that use plug in DAQ devices Create applications that use serial port and GPIB instruments This course does not describe any of the following National Instruments Corporation Every built in VI function or object refer to the LabVIEW Help for more information about LabVIEW features not described in this course Analog to digital A D theory Operation of the serial port Operation of the GPIB bus Developing an instrument driver Developing a complete application for any student in the class refe
315. umeric control LabVIEW highlights the text so you can edit it If the control is Boolean press the spacebar or the lt Enter gt key to change its value You also can assign keyboard shortcuts to controls so users can navigate the front panel by pressing other keys Right click the control and select Advanced Key Navigation from the shortcut menu to display the Key Navigation dialog box Kp Note The Advanced Key Navigation shortcut menu item is dimmed for indicators because you cannot enter data in an indicator Select the shortcut key you want to assign to the control in the Key Assignment section The front panel control names that appear in the Current Assignments listbox correspond to the owned labels of those controls To prevent users from accessing a control by pressing the lt Tab gt key while the VI runs place a checkmark in the Skip this control when tabbing checkbox National Instruments Corporation 11 9 LabVIEW Introduction Course Manual Lesson11 Customizing VIs Exercise 11 2 Temperature System VI Objective To set keyboard shortcuts for front panel controls and display a subVI front panel when a VI runs Complete the following steps to build a temperature monitoring system you can use to view three different tests on request Front Panel l Open the Temperature System VI located in the C Exercises LabVIEW Basics I directory The following front panel is already built The front panel contains fo
316. ur Boolean buttons The mechanical action of the first three buttons is Latch When Pressed This setting changes the control value when you click it and retains the new value until the VI reads it once At this point the control reverts to its default value even if you keep pressing the mouse button This action is similar to a circuit breaker and is useful for stopping While Loops or for getting the VI to perform an action only once each time you set the control The mechanical action of the STOP button is Latch When Released This setting changes the control value only after you release the mouse button within the graphical boundary of the control When the VI reads it once the control reverts to the old value This action guarantees at least one new value This action is similar to dialog box buttons and system buttons Right click a control and select Advanced Key Navigation from the shortcut menu to display the Key Navigation dialog box In the Key Assignment section assign the shortcut key shown in the previous figure 4 Repeat steps 2 and 3 for each control LabVIEW Introduction Course Manual 11 10 ni com Block Diagram 5 10 National Instruments Corporation Lesson11 Customizing VIS Examine the following block diagram which is already built meg E All False Cases dre Empty BE Display Temp vi f Wait Lintil Mest ms Errr Lit on al Wiii Display and Log Temp vi A G The Display Temp VI sim
317. users VISA is the VXIplug amp play I O software language that is the basis for the software standardization efforts of the VXIplug amp play Systems Alliance VISA by itself does not provide instrumentation programming capability It is a high level API that calls in low level drivers VISA can control VXI GPIB serial or computer based instruments and makes the appropriate driver calls depending on the type of instrument used When debugging VISA problems remember this hierarchy An apparent VISA problem could be an installation problem with one of the drivers that VISA calls In LabVIEW VISA is a single library of functions you use to communicate with GPIB serial VXI and computer based instruments You do not need to use separate I O palettes to program an instrument For example some National Instruments Corporation 10 13 LabVIEW Introduction Course Manual Lesson 10 Instrument Control instruments give you a choice for the type of interface If the LabVIEW instrument driver were written with functions on the Functions All Functions Instrument I O GPIB palette those instrument driver VIs would not work for the instrument with the serial port interface VISA solves this problem by providing a single set of functions that work for any type of interface Therefore all LabVIEW instrument drivers use VISA as the I O language VISA Programming Terminology The functions you can use with a resource are operations The resour
318. ution button shown at left on the toolbar to slow down the execution of the program so you can observe the execution order on the block diagram 7 Click the Run button Observe the block diagram Notice the flow of data on the block diagram For example notice that the Tone Measurements2 Express VI cannot output data until it receives data from Filter 9 Close the VI when finished Do not save changes End of Exercise 1 2 National Instruments Corporation 1 41 LabVIEW Introduction Course Manual Lesson1 Introduction to LabVIEW F LabVIEW Documentation Resources Use the Context Help window the LabVIEW Help and the NI Example Finder to help you build and edit VIs Refer to the LabVIEW Help and manuals for more information about LabVIEW Context Help Window The Context Help window displays basic information about LabVIEW objects when you move the cursor over each object The Context Help window is visible by default To toggle display of the Context Help window select Help Show Context Help press the lt Ctrl H gt keys or click the Show Context Help Window button shown at left on the toolbar When you move the cursor over front panel and block diagram objects the Context Help window displays the icon for subVIs functions constants controls and indicators with wires attached to each terminal When you move the cursor over dialog box options the Context Help window displays descriptions of those options In the w
319. ve the VI as Cluster Exercise vi inthe C Exercises LabVIEW Basics I directory Display the front panel and run the VI Enter different values in Cluster and run the VI again Notice how values entered in Cluster affect the Modified Cluster and Small Cluster indicators Is this the behavior you expected Try changing the cluster order of Modified Cluster Run the VI How did the changed order affect the behavior Close the VI Do not save changes End of Exercise 5 1 5 10 ni com Exercise 5 2 Lesson5 Clusters Cluster Scaling VI Optional Objective To build a VI that uses polymorphism with clusters Front Panel Block Diagram Complete the following steps to build a VI that scales values stored in a cluster where each cluster element has a different scale factor Assume that the voltages were measured from transducers that measure the pressure flow rate and temperature The VI then scales these values to get the actual values present in the system 1 Open the Cluster Scaling VI located in the C Exercises LabVIEW Basics I directory The front panel is already built 2 Change the controls as shown in the following front panel Raw Data Scaled Data p Y temperature temperature deg C flow rate liters sec pressure N m 2 500 7 7 400 40000 60000 V flow rate ang NO l E ta s0000 E woi 200 100 100000 ie 3 Build the following block diagram Make sure you apply the correct scale fa
320. ver some high level File I O VIs designed for common file I O operations perform all four steps Although these VIs are not always as efficient as the low level functions you might find them easier to use Use the high level File I O VIs located on the top row of the File I O palette to perform common I O operations such as writing to or reading from the following types of data Characters to or from text files Lines from text files 1D or 2D arrays of single precision numeric values to or from spreadsheet text files 1D or 2D arrays of single precision numeric values or signed 16 bit integers to or from binary files High level File I O VIs include the following LabVIEW Introduction Course Manual Write to Spreadsheet File Converts a 2D or 1D array of single precision numbers to a text string and writes the string to a new byte stream file or appends the string to an existing file You also can transpose the data The VI opens or creates the file before writing to it and closes it afterwards You can use this VI to create a text file readable by most spreadsheet applications Read From Spreadsheet File Reads a specified number of lines or rows from a numeric text file beginning at a specified character offset and converts the data to a 2D single precision array of numbers The VI opens the file before reading from it and closes it afterwards You can use this VI to read a spreadsheet file saved in text format Write Characters
321. w Show Block Diagram LabVIEW Introduction Course Manual 1 28 ni com Lesson 1 Introduction to LabVIEW 7 On the front panel toolbar click the Run button shown at left Notice that a sine wave appears on the graph 8 Stop the VI by clicking the STOP button shown at left on the front panel Adding a Control to the Front Panel Controls on the front panel simulate the input devices on a physical instrument and supply data to the block diagram of the VI Many physical instruments have knobs you can turn to change an input value Complete the following steps to add a knob control to the front panel W Tip Throughout these exercises you can undo recent edits by selecting Edit Undo or pressing the lt Ctrl Z gt keys 1 Ifthe Controls palette is not visible on the front panel select Window Show Controls Palette to display it 2 Move the cursor over the icons on the Controls palette to locate the Numeric Controls palette Notice that when you move the cursor over icons on the Controls palette the name of that subpalette appears in the gray space above all the icons on the palette When you idle the cursor over any icon on any palette the full name of the subpalette control or indicator appears 3 Click the Numeric Controls icon to access the Numeric Controls palette 4 Select the knob control on the Numeric Controls palette and place it on the front panel to the left of the waveform graph You will use this knob in a
322. ware such as LabVIEW LabWindows CVI and Measurement Studio or open ADEs that support calling dynamic link libraries DLLs through ANSI C interfaces Using NI application software greatly reduces National Instruments Corporation 9 3 LabVIEW Introduction Course Manual Lesson9 Data Acquisition and Waveforms development time for data acquisition and control applications regardless of which programming environment you use e LabVIEW supports data acquisition with the LabVIEW DAQ VIs a series of VIs for programming with NI measurement devices e For C developers LabWindows CVI is a fully integrated ANSI C environment that provides the LabWindows CVI Data Acquisition library for programming NI measurement devices e Measurement Studio development tools are for designing your test and measurement software in Microsoft Visual Studio NET Measurement Studio includes tools for Visual C Visual Basic NET and Visual C NET DAQ Hardware Configuration You must complete several steps before you can use the Data Acquisition VIs The devices are configured for the computers in this class Windows The Windows Configuration Manager keeps track of all the hardware installed in the computer including National Instruments DAQ devices If you have a Plug amp Play PnP device such as an E Series MIO device the Windows Configuration Manager automatically detects and configures the device If you have a non PnP device or legacy
323. waveform chart The waveform chart terminal changes to match the output of the Bundle function To add more plots use the Positioning tool to resize the Bundle function National Instruments Corporation 6 3 LabVIEW Introduction Course Manual Lesson6 Plotting Data Exercise 6 1 Temperature Monitor VI Objective To use a While Loop and a waveform chart to acquire and display data Front Panel Block Diagram LabVIEW Introduction Course Manual Complete the following steps to build a VI that measures temperature and displays it on a waveform chart Open a blank VI and build the following front panel Temperature History 8 10 12 14 16 18 20 Time sec Place the vertical toggle switch located on the Controls Buttons amp Switches palette on the front panel Label this switch Power You use the switch to stop the acquisition Place a waveform chart located on the Controls Graph Indicators palette on the front panel Label the chart Temperature History The waveform chart displays the temperature in real time The waveform chart legend labels the plot Plot 0 Use the Labeling tool to triple click Plot 0 in the chart legend and change the label to Temp The temperature sensor measures room temperature Use the Labeling tool to double click 10 0 in the y axis and type 90 to rescale the chart Leave the x axis in its default state Change 10 0 in the y axis to 70 Label the y axis Temp
324. xercises 10 7 Open the Voltage Monitor VI which you built in Exercise 10 4 Modify the block diagram so that the data are written to a spreadsheet file named voltage txt in the following format i es Ee a A 1 Start Date 6 8 00 Start Time 1 26 PM Max Voltage 9 151000 Min Voltage 0 354010 Data 6 965 9 067 0 354 Select File Save As to save the VI as Voltage Data to File vi in the C Exercises LabVIEW Basics I directory National Instruments Corporation 10 41 LabVIEW Introduction Course Manual Lesson 10 Instrument Control Notes LabVIEW Introduction Course Manual 10 42 ni com Lesson 11 Customizing Vis This lesson describes how to configure the appearance and behavior of VIs and the LabVIEW environment You Will Learn How to configure the appearance of the front panel How to open subVI front panels when a VI runs How to use and assign keyboard shortcuts How to edit VIs with custom VI properties moa Ww gt How to customize palette views Optional National Instruments Corporation 11 1 LabVIEW Introduction Course Manual Lesson11 Customizing VIs A Configuring the Appearance of Front Panels After you build a VI you can configure the appearance of the front panel so users can more easily operate the VI For example you can hide the menu bar and scrollbars to create VIs that look and behave like standard dialog boxes for each platform Select File VI Properties to c
325. y negative with respect to ground to be a logical 1 whereas the RS 422 receiver senses which line is more negative than the other This makes RS 422 more immune to noise and interference and more versatile over longer distances The Macintosh serial ports follow RS 422 which can be converted to RS 423 by proper wiring of an external cable RS 423 can then communicate with most RS 232 devices over distances of 15 m or so National Instruments Corporation 10 27 LabVIEW Introduction Course Manual Lesson 10 Instrument Control RS 232 Cabling Devices that use serial cables for their communication are split into two categories These are DCE and DTE DCE are devices such as a modem TA adapter plotter and so on while DTE is a computer or terminal RS 232 serial ports come in two sizes the D Type 25 pin connector and the D Type 9 pin connector Both of these connectors are male on the back of the PC Thus you require a female connector on the device The following table shows the pin connections for the 9 pin and 25 pin D Type connectors Output Output Output Input The DB 9 connector is occasionally found on smaller RS 232 lab equipment It is compact yet has enough pins for the core set of serial pins with one pin extra ny Note The DB 9 pin numbers for transmit and receive 3 and 2 are opposite of those on the DB 25 connector 2 and 3 Be careful of this difference when you are determining if a device is DTE or DCE
326. you resize it press the lt Shift gt key while you drag the resizing handles or circles e To resize an object as you place it on the front panel press the lt Ctrl gt key while you click to place the object and drag the resizing handles or circles e To replace nodes right click the node and select Replace from the shortcut menu e To display the block diagram of a subVI from the calling VI press the lt Ctrl gt key and use the Operating or Positioning tool to double click the subVI on the block diagram e To display the front panel of a subVI from the calling VI use the Operating or Positioning tool to double click the subVI on the block diagram You also can select Browse This VI s SubVIs National Instruments Corporation 1 59 LabVIEW Introduction Course Manual Lesson 1 Introduction to LabVIEW After you type a label press the lt Enter gt key to end text entry To add items quickly to ring controls and Case structures press the lt Shift Enter gt keys after each item Pressing lt Shift Enter gt accepts the item and positions the cursor to add the next item Refer to Lesson 7 Making Decisions in a VI of this manual for more information about Case structures To copy the color of one object and transfer it to a second object without using a color picker use the Color Copy tool to click the object whose color you want to copy Use the Coloring tool to click the object to which you want to apply the color You

Download Pdf Manuals

image

Related Search

Related Contents

Guide d`installation des serveurs SPARC Enterprise T5140  Introduction to YS1000 Series - YS1000 Series Single Loop Controller  JEUDI 21 AVRIL 2011  M2G V2.2 User Manual  Descargue  Étiquette  Téléchargez le catalogue  MANUAL DE INSTRUÇÕES  ROLLER'S Uni-Press E ROLLER'S Uni-Press    

Copyright © All rights reserved.
Failed to retrieve file