How to Make a Simple Calculator in LabVIEW™ Lita Wilch TECM 2700.022 4/28/2013 2 How to Make a Simple Calculator in LabVIEW™ Table of Contents iii Table of Contents Table of Contents ...................................................................................................................... iii Introduction ................................................................................................................................v Manual Overview ....................................................................................................................v Supplies ...................................................................................................................................v Supply Cost .............................................................................................................................v Opening the LabVIEW™ Main Menu .........................................................................................3 Opening a Blank VI ....................................................................................................................7 Option 1: Opening the VI using the Main Menu ......................................................................7 Option 2: Opening the VI using the Create Project Menu .........................................................8 Adding Function to the Block Diagram ..................................................................................... 13 Adding Numeric Controls to the Front Panel ......................................................................... 13 Adding Numeric Indicators to the Front Panel ....................................................................... 15 Renaming the Numeric Controls and Indicators......................................................................... 19 Renaming the Numeric Controls ............................................................................................ 19 Renaming the Numeric Indicators .......................................................................................... 20 Adding Functions to the Block Diagram .................................................................................... 23 Adding the Add Function to the Block Diagram .................................................................... 23 Adding the Subtract Function to the Block Diagram .............................................................. 26 .............................................................................................................................................. 26 Adding the Multiply Function to the Block Diagram ............................................................. 27 Adding the Divide Function the Block Diagram .................................................................... 28 Connecting the Controls in the Block Diagram .......................................................................... 31 Connecting the X Numeric Control to the Functions .............................................................. 31 Connecting the Y Numeric Control to the Functions .............................................................. 33 Connecting the Functions to the Numeric Indicators .............................................................. 35 How Everything Connects: A Visual Overview ..................................................................... 37 ................................................................................................................................................. 37 Using the Simple Calculator in the Front Panel ......................................................................... 40 Glossary .................................................................................................................................... 45 iv How to Make a Simple Calculator in LabVIEW™ Index ......................................................................................................................................... 47 Introduction v Introduction So you are heading into the electrical engineering program at your college and one of the professors you talk to mentions that one of the programs you will work with is LabVIEW™ (Laboratory Virtual Instrumentation Engineering Workbench). This manual will help you to gain some experience with this program as you make this simple calculator in LabVIEW™. Manual Overview After reading this manual you will know how to: Open LabVIEW™ Open a VI (Virtual Instrument) in LabVIEW™ Locate Numeric Controls in the front panel Locate Numeric Indicators in the front panel Rename the Numeric Controls Rename the Numeric Indicators Locate the Add Function in the block diagram Locate the Subtract Function in the block diagram Locate the Divide Function in the block diagram Locate the Multiply Function in the block diagram Connect the controls, indicators, and functions together in the block diagram Run the simple calculator using the front panel I will not explain how to purchase or how to download LabVIEW™. I will not explain any buttons on the front panel and block diagram that have no use for completing this project. I will not explain how to open LabVIEW™ with Apple® computers. I will also not include the cost of a computer or laptop because the price will vary depending on the user’s needs. Supplies Before you start to make this simple calculator in LabVIEW™ make sure you have the following supplies: LabVIEW™ software LabVIEW™ license Computer After you have all the supplies, you will have everything you need to make this simple calculator in LabVIEW™. Supply Cost The basic LabVIEW™ Student Edition program costs approximately $21. Take notice of arrows surrounded by an oval to the right of buttons or other items. They point out things that you must use or should take note of. Words that are bolded and colored yellow can be found in the glossary on page 45. vi How to Make a Simple Calculator in LabVIEW™ Opening the LabVIEW™ Main Menu 2 How to Make a Simple Calculator in LabVIEW™ Opening the LabVIEW™ Main Menu Opening the LabVIEW™ Main Menu 1. Find the Start button in the bottom left-hand corner of your screen 2. Click the Start button once to open the search box 3. Type the LabVIEW™ program name without the ™ into the search box 4. Find the LabVIEW™ option in the list 3 4 How to Make a Simple Calculator in LabVIEW™ 5. Left-click the LabVIEW™ option twice, this will open the initialization screen and then the main menu for LabVIEW™ Opening a Blank VI \ 6 How to Make a Simple Calculator in LabVIEW™ Opening a Blank VI Opening a Blank VI Option 1: Opening the VI using the Main Menu 1. Find the blank VI option on the main menu 2. Left-click the blank VI option twice, this will open a new front panel and block diagram 7 8 How to Make a Simple Calculator in LabVIEW™ Option 2: Opening the VI using the Create Project Menu 1. Find the Create Project button on the main menu 2. Left-click the create project button once, this will take you to the project menu 3. Find the Blank VI option on the Create Project menu Opening a Blank VI 4. Left-click the blank VI option once and then then left-click the Finish button at the bottom to open a blank VI 9 10 How to Make a Simple Calculator in LabVIEW™ 11 Adding Numeric Controls and Indicators to the Front Panel 12 How to Make a Simple Calculator in LabVIEW™ Adding Numeric Controls and Indicators to the Front Panel Adding Function to the Block Diagram Adding Numeric Controls to the Front Panel 1. Right-click the front panel once, this will open the Controls palette 2. Find the Numeric Controls button in the Numeric Control sub-palette 3. Place your cursor over the Numeric Controls button to open the Numeric Controls subpalette 13 How to Make a Simple Calculator in LabVIEW™ 14 4. Find the Numeric Control in the Numeric Control sub-palette 5. Left-click the Numeric Control once and then place the Numeric Control where you would like it on the front panel 6. Repeat steps 1-5 to add another Numeric Control to the front panel 7. Save your current progress Adding Numeric Controls and Indicators to the Front Panel Adding Numeric Indicators to the Front Panel 1. Right-click the front panel to reopen the Control palette . 2. Find the Numeric Indicator button 3. Place your cursor over the Numeric Indicator button, this will open the Numeric Indicators sub-palette 4. Find the Numeric Indicator in the open sub-palette 15 How to Make a Simple Calculator in LabVIEW™ 16 5. Left-click the Numeric Indicator once and then place the Numeric Indicator where you would like it on the front panel 6. Repeat steps 1-6 to add three more Numeric Indicators to the front panel 7. Save your current progress Renaming the Numeric Controls and Indicators 18 How to Make a Simple Calculator in LabVIEW™ Renaming the Numeric Controls and Indicators Renaming the Numeric Controls and Indicators Renaming the Numeric Controls 1. Find the word numeric above the first Numeric Control 2. Double-click numeric to gain access to the text box 3. Type X into the highlighted text box 4. Repeat steps 1-2 for the second Numeric Control 5. Type Y into the second Numeric Control text box 6. Save your current progress 19 How to Make a Simple Calculator in LabVIEW™ 20 Renaming the Numeric Indicators 1. Find the word numeric above a Numeric Indicator 2. Double-click numeric to rename the Numeric Indicator 3. Type X + Y into the highlighted text box. This indicator will who the sum of X and Y 4. Repeat steps 1-2 for the second Numeric Indicator 5. Type X – Y into the text box. This indicator will show the difference of X and Y 6. Repeat steps 1-2 for the third Numeric Indicator 7. Type X * Y into the text box. This indicator will show the product of X and Y 8. Repeat steps 1-2 for the third Numeric Indicator 9. Type X/Y into the text box. This indicator will show the quotient of X and Y 10. Save your current progress Adding Functions in the Block Diagram 22 How to Make a Simple Calculator in LabVIEW™ Adding Function in the Block Diagram Adding Functions to the Block Diagram Adding the Add Function to the Block Diagram 1. Right-click the block diagram once, this will open the Functions palette 2. Find the Arithmetic and Comparisons button in the Functions palette 3. Place your cursor over the Arithmetic and Comparisons buttons, this will open the Arithmetic and Comparison sub-palette 4. Find the Numeric button in the Arithmetic and Comparison sub-palette 23 24 How to Make a Simple Calculator in LabVIEW™ 5. Place your cursor over the Numeric button, this will open the Express Numeric subpalette 6. Find the Add Function in the Express Numeric sub-palette Adding Function in the Block Diagram 7. Left-click the Add Function once and place it between the Numeric Controls and Numeric Indicators 8. Save your current progress 25 How to Make a Simple Calculator in LabVIEW™ 26 Adding the Subtract Function to the Block Diagram 1. Repeat steps 1-5 from the Adding the Add Function part of the this chapter 2. Find the Subtract Function in the Express Numeric sub-palette 3. Left-click the Subtract Function once and place it between the Numeric Controls and Numeric Indicators 4. Save your current progress Adding Function in the Block Diagram Adding the Multiply Function to the Block Diagram 1. Repeat 1-5 from the Adding the Add Function part of this chapter 2. Find the Multiply Function in the Express Numeric sub-palette 3. Left-click the Multiply Function once and place it between the Numeric Controls and Numeric Indicators 4. Save your current progress 27 How to Make a Simple Calculator in LabVIEW™ 28 Adding the Divide Function the Block Diagram 1. Repeat 1-5 from the Adding the Add Function part of this chapter 2. Find the Divide Function in the Express Numeric sub-palette 3. Left-click the Divide Function once and place it between the Numeric Controls and Numeric Indicators 4. Save your current progress Connecting the Controls in the Block Diagram 30 How to Make a Simple Calculator in LabVIEW™ Connecting the Controls in the Block Diagram 31 Connecting the Controls in the Block Diagram Connecting the X Numeric Control to the Functions 1. Connect the X Numeric Control to the Add Function 2. Connect the Subtract Function to the wire between the X Numeric Control and the Add Function How to Make a Simple Calculator in LabVIEW™ 32 3. Connect the Multiply Function to the wire between the X Numeric Indicator and the Subtract Function 4. Connect the Divide Function to the wire connected to the Multiply Function 5. Save your current progress Connecting the Controls in the Block Diagram Connecting the Y Numeric Control to the Functions 1. Connect the Y Numeric Control to the Divide Function 2. Connect the Multiply Function to the wire between the Y Numeric Indicator and the Divide Function 33 How to Make a Simple Calculator in LabVIEW™ 34 3. Connect the Subtract Function to the wire connected to the Multiply Function 4. Connect the Add Function to the wire connected to the Subtract Function 5. Save your current progress Connecting the Controls in the Block Diagram Connecting the Functions to the Numeric Indicators 1. Connect the Add Function to the indicator X + Y 2. Connect the Subtract Function to the indicator X – Y 35 How to Make a Simple Calculator in LabVIEW™ 36 3. Connect the Multiply Function to the indicator X * Y 4. Connect the Divide Function to the indicator X / Y 5. Save your current progress 6. You have now finished making your first program in LabVIEW™ Connecting the Controls in the Block Diagram How Everything Connects: A Visual Overview The red line shows how the X Numeric Control connects to each function and each indicator The blue line shows how the Y Numeric Control connects to each function and each indicator 37 38 How to Make a Simple Calculator in LabVIEW™ Using the Simple Calculator in the Front Panel 40 How to Make a Simple Calculator in LabVIEW™ Using the Simple Calculator in the Front Panel 1. Use your simple calculator by pressing the run continuously button at the top 2. The grid lines will go away when you press the run continuously button and you will get a screen like this: Using the Simple Calculator in the Front Panel 3. Enter numbers you would like to see added, subtracted, divided ,and multiplied into the X and Y boxes 4. The answers to the two numbers entered will show in the indicators to the right 41 42 How to Make a Simple Calculator in LabVIEW™ 5. Press the abort execution button at the top to stop the program Using the Simple Calculator in the Front Panel 43 44 How to Make a Simple Calculator in LabVIEW™ Glossary Glossary Add Function – allows the values entered to added together Block Diagram – used to add functions for any program made Divide Function – allows the values entered to be divided Front Panel – used to add user functions for programs made Multiply Function - allows the values entered to be multiplied Numeric Control – allows values to be entered into the program by a user Numeric Indicator – shows the outputs of the program Subtract Function – allows the values entered to be subtracted VI ( Virtual Instrument) – consists of the front panel and block diagram Wire – word used to describe the line that connects functions, indicators, and controls in the block diagram 45 46 How to Make a Simple Calculator in LabVIEW™ Index 47 Index Add Function, 23, 24, 25, 26, 27, 28, 31, 34, 35, 45 Block Diagram, v, 7, 23, 45 Divide function, 28, 32 Front Panel, v, 7, 13, 14, 15, 16, 45 Multiply Function, 27, 32, 33, 36, 45 Numeric Control, 13, 14, 19, 31, 33, 37, 45 Numeric Indicator, 15, 16, 20, 32, 45 Subtract Function, 26, 31, 32, 34, 35, 45 VI, v, 7, 8, 9, 45 Wire, 31, 32, 33, 34 Lita Wilch Style Sheet for How to Make a Simple Calculator in LabVIEW™ Page Elements Page size 11 ½ "x 8" Margins 1" Layout Manual Spacing Single spacing and double spacing for text Visual aids Screenshots Headings Left-hanging Type Elements Typeface Size Style Color Text Elements Capitalization Numbers Lists Punctuation Style Handbook Times New Roman for text Arial for headings 12 point for text 16 point for headings 14 point for subheadings 36 point for fly page headings Regular text Black for major headings Blue for minor headings Yellow for indexed words All brand names Spell out numbers 1-99 Bulleted lists use black circle bullet Numbered lists will have a period after the number No period after sentences in a list Items in a series use comma before last item Technical Communications for Readers and Writers by Brenda R. Sims