Creating First Project using LabVIEW Programming

Hello everyone! I hope you all will be fine. Today, I am going to elaborate that how to create your First Project using NI LabVIEW Programming. This software is very easy to use in comparison to the other software. You do not have to write the complete source code for the desired output, like in other software e.g. Arduino, MATLAB, Dev C++, Eclipse etc. instead you have to just implement your logic using Field Programmable Gate Array (FPGA) blocks. The program is designed with the help of the FPGA blocks, is usually known as “Virtual Instruments”. Normally we used to call it as VI’s. We create in “Block Diagram” window as described in our previous tutorial on Introduction to LabView. If you haven't read that tutorial then I owuld suggest you to read that one first because I have given a detailed introduction to LabView software and today's we are gonna have the same introduction but about LabView Programming. So, today we are gonna design our first project using LabView Programming and you will see how easy it is in LabView Programming. If you ask me then when I was a beginner on LabView Programming then it seems to me the most difficult programming Language but now I can say that LabView Programming is the most easiest and flexible one. Labview has a great online support, yu should also have a look at this online LabView Community because its very extensive and has great projects and tutorials. Here I am going to guide all of you, about creating your first program using NI LabVIEW Programming.

Creating First Project using LabVIEW Programming

  • First of all create a new project as we have done in our previous tutorial Introduction to LabView.
  • Now once you created the project you will have two windows in front of you named as Front Panel and Block Diagram.
  • I will start the very first step by simple adding two parameters in our Block Diagram.
  • So, open your “Block Diagram” window and go to Functions-> Programming-> Numeric.
  • By doing this, you can see the following window on your screen:
  • Select the very first block named as “Add”, its an addition operator in LabView Programming.
  • Drag and place it on the “Block Diagram” window.
  • You can see that it has two input terminals (x and y) and only a single output terminal (x+y) which shows that this block gives only one result by manipulating the two different parameters simultaneously.
  • Inputs are known as “Controls” and outputs are known as "indicators".
  • Since we want to manipulate the two parameters by changing them according to our requirement so we will make the input terminals as “Control”.
  • Place the cursor on one of the input terminal and right click it.
  • Go to the Create-> Control as shown in the figure below:
  • By pressing the “Control” option, one input of this block can be controlled manually by you.
  • Similarly, perform the same procedure on the second input terminal.
  • The figure shows both of the manually controlled inputs:
  • Now we have to observe the output of the block, which is now manipulating the two input parameters.
  • Place the cursor on the output terminal of the block and make a click on it.
  • Now, go to Create-> Indicator because we have to display the output.
  • The figure below shows a bit detail:
  • Press the “Indicator” option and you will get an indicator on your output pin.
  • You can see that output has also been created now as show in the figure below:
  • Now our first project using LabView programming is completed in the “Block Diagram” window.
  • Since we have create our project with the help of FPGA blocks.
  • So, what we have to do is to observe the output of the designed algorithm.
  • So now, we need to go to the “Front Panel” which helps us to show the output of the program as described in detail in our previous tutorial Introduction to LabView.
  • Open the “Front Panel” window and it will be something like the image shown below:
 
  • On the left side of the “Add” block there are two inputs  represented by as “x” and “y”.
  • And on the right side there is a single output represented by “x+y” to perform the addition operation.
  • Now adjust the both of the input parameters to obtain the desired output according to the adjusted parameters.
  • Here I have adjusted “x” input by assigning it with a value “2”.
  • And I have adjusted “y” input by assigning it with a value “5”.
  • You can see both of the adjusted inputs in the figure below:

How to Run LabView Simulation ???

  • You have to see the output of the program according to the adjusted parameter
  • Go to the “Run” button on the top left corner of the “Front Panel” window, and just run the program
  • The figure shown below will explain a bit about both of the above two steps
  • You can see the output of the program has been successfully obtained according to the adjusted input parameters.
  • So that is how you can perform the simple addition of the two parameters in LabVIEW.
  • You can also use the all of the other operators in the Functions-> Programming-> Numeric similarly to perform different operations for the different input parameters according to your own requirements.

For Loop using LabView Programming

  • In previous part, you can see that as you compile (run) your program it shows the desired output and then terminates.
  • That means if you have to change input parameters then you have to run your program again as well.
  • Now I am going to explain you that what to do with this program, if you want that this should run for a number of iterations.
  • There is “For Loop” option which helps us to run our designed algorithm for number of iterations we want.
  • You can select the “For Loop” by following the below procedure:
  • Select the “For Loop”, drag and place it in the “Block Diagram”.
  • It will look like the figure shown below:
  • You can see that there is a “N” symbol on the top left corner of the “For Loop”.
  • Basically the symbol “N” shows the number of iterations for which we want to run our program.
  • Go to the input terminal of the symbol “N” and click on it.
  • Now, go to Create Constant as shown below:
  • So, set the number of iterations according to the requirement.
  • Here, I am going to set the iterations value to 5 as shown in below figure:
  • Now place the designed algorithm inside the “For Loop” to run the program five times in this case as shown in the figure below:
  • Now your program will run for five iterations.

While Loop using LabView Programming

  • If you want that your program should have continue to run until you terminate then it is also possible.
  • While Loop” option will be helpful for us in such a condition.
  • Here I will tell you how to select the “While Loop” in this software. It is quite similar to the selection of the “For Loop” described in previous section.
  • Go to Functions-> Programming-> Structures-> While Loop as shown in below figure:
  • Select the “While Loop” drag and place it on the “Block Diagram” window.
  • Now, place the designed algorithm inside the “While Loop” like shown below:
  • You can see there the “Run” button is not in a normal condition which shows that there is some problem with the program.
  • It is due to the fact because we have not yet defined the terminating condition of the program.
  • Now, go to the “Front Panel” window and right click on it.
  • Go to Controls-> Modern-> Boolean-> Stop Button as shown in the figure below:
  • Connect the “Stop Button” with the red dot surrounded with the green boundary at the bottom right corner of the “While Loop” as shown in the figure below:
  • Now you can see that the “Run” button is now again in normal state which shows that the everything is going fine with the program.
  • Now, run the program and it will continue to run until you press the “Stop Button” in the “Front Panel” window.
  • Running Program is shown in the figure below:
  • You can change the input according to the requirements and you can see output  immediately and you do not have to run the program again and again for the different inputs
  • If you press the stop button you can see that the program terminates only then
That's all from this tutorial. I hope you enjoyed that and it will help you in learning Labview Programming. If you face any sort of problem then you can ask us without feeling any kind of hesitation. I will explain the further details of NI LabVIEW in the later tutorials. Take care till then :)

Introduction to LabVIEW

Hello everyone. I hope you all will be absolutely fine. Today, I am going to share an Introduction to LabView. LabView is a really exciting software and recently I have worked on many LabView Project so I thought to start this new set of series in which I am gonna explain all about LabView from beginners level to Pro Level. So, today I am gonna upload the first tutorial in this LabVIEW series so that's why I have named it Introduction to LabView and I hope you are gonna like this tutorial. :)

LabVIEW basically stands for “Laboratory Virtual Instrument Engineering Workbench”. This software is designed by the National Instruments (NI) for the control and design of the projects. You can use it for simulation purposes, can also interface hardware with LabVIEW, data acquisition is another big benefit of LabView. Moreover we can also design automation and robotics projects in LabVIEW. Before designing such projects, let's first have a look at the Introduction to LabVIEW:

Introduction to LabVIEW

  • So, let's get started with Introduction to LabView and first of all what you need to do is to open the NI LabVIEW 2015 software.
  • A small window will open up as shown in the below figure:
  • So, this newly opened LabView window will have two portions “left bar” and “right bar”.
  • If you want to design new project then you have to click on the button “Create Project”.
  • If you want to open the project which already exists then press “Open Existing” button.
Opening New VI in LabView
  • Go to the “File” menu of the software as show in the figure below
  • Click on “New VI” or you can press the short code Ctrl+N. to open up new VI in LabView.
  • So, now when you click on this NewVI then you will see that two windows will open up.
  • One of them is known as “Front Panel” and second is known as “Block Diagram”.
  • Both windows and their functionalities are explained in detail below:
Block Diagram
  • Here is the screen shot of the “Block Diagram” so when we are having the Introduction to LabVIEW then we must discuss these windows in detail. :)
  • This window is named as Block Diagram because we design our LabVIEW Block Diagram in this window.
  • It's more of a back end programming section.
  • So suppose you are designing some simulation in LabView then what features you want in your simulation depends on your code in the Block Diagram.
Front Panel
  • Here's the screen shot of “Front Panel” of LabVIEW.
  • It's also known as GUI of LabVIEW.
  • In this Front Panel of LabView, we design the presentable output.
  • For example, you are working on some simulation and you have to display some sensors' values then they are gonna be displayed in this Front Panel.
So, both of these windows are equally important and works simultaneously with each other. So, if you change anything in Front Panel then its counter part in Block Diagram will also change. So, let's have a look at How to align these two windows in LabVIEW.
Windows Alignment in LabView
  • Now we know that if we are gonna work on some LabView simulation then we have to deal with two windows and in the above section of Introduction to LabView, we have discussed both of these windows.
  • Now the problem is when we are working on two windows simultaneously then we need both of them to be rite in front of us.
  • In order to do so, press “Ctrl+T” and both of your windows will be rite in front of you.
  • It will help you to align both the windows, the “Front Panel” and the “Block Diagram”.
  • The aligned windows are shown below and you can see the are looking nice comparatively.
  • If “Front Panel is there on you screen and “Block Diagram” window is not on the screen, then just pres “Ctrl+E”.
  • You can see “Block Diagram” also appears automatically on the screen.
  • You can perform it for the vice versa purpose as well.
Description of Block Diagram Window
  • Block diagram is a window in which we can create our logic by using different blocks.
  • NI LabVIEW basically supports Field Programmable Gate Array Language (FPGA).
  • We have to select different blocks according to the requirement ad they are known as FPGA blocks.
  • Press “Right Click” on the “Front Panel” a new “Function” tab opens as shown below:
  • From this “Function Tab” you can select different blocks to create your logic according to the requirements
  • The detail about few of the blocks and functions is given below.
Numeric Toolbox in LabVIEW
  • Go to the Functions-> Programming-> Numeric and you will get all your numeric tools there.
  • You can see, the following window on your screen
  • You can see different alphanumeric blocks (operators) like addition, subtraction etc. in the above figure
  • Using these operators you can perform different mathematical operations
Graphics in NI LabVIEW
  • Graphics tool is another amazing tool in this software and I think we should discuss them in this Introduction to LabView.
  • Go to Functions-> Programming-> Graphics & Sounds and you will get all your graphics tools in there.
  • You can see a window on your screen as shown below:
  • You can make three dimensional picture and plot three dimensional graphs as well.
Comparator in LabView
  • Go to Functions-> Programming-> Comparison and there's a big list of comparator waiting for you there.
  • You can see a window on the screen as shown below
  • These blocks are used for the comparison of two or more than two operators.
  • These blocks are used in the projects where there are some restrictions i.e. if temperature exceeds the threshold, fire alarm or buzzer turns into “ON” state then.
Loops in LabView
  • Go to Functions-> Programming-> Structures and here lie the most important functions of LabView programming.
  • The below window will appear on the screen:
 
  • If you want to run your created logic for different no of iterations, these loops will be helpful.
  • You have to just set the number of iterations and your program will according to the adjusted number of iterations.
Timing Toolbox in LabVIEW
  • Go to the Functions-> Programming-> Timing and you will find all the timing blocks in there.
  • You can see the following window on the screen:
 
  • If you want that your program should run with some delay.
  • These timing clock bocks will be helpful.
  • Usually their values are in milliseconds but you can adjust them accordingly by setting their properties.
Driver Support in NI LabVIEW
  • One of the amazing functions of the NI LabVIEW is that, it supports the external device drivers.
  • The device which we want to use and interface with the NI LabVIEW, we have to just install the driver of that device.
  • After the successful installation you can see that device in "Functions" Palette.
  • For example, go to the Functions-> Programming at the end of the window you can see the installed drivers or toolkits.
  • I have installed Arduino interface for NI LabVIEW 2015.
  • The figure below describes all of the above steps.
NI LabVIEW Supported Devices
Here's the list of most commonly used NI LabVIEW devices:
  1. compactRIO.
  2. myRIO (Re-configureable Input Output Device).
  3. sbRIO (Single Board Reconfigureable Input Output Device).
  4. Arduino.
  5. Raspberry PI.
  • NI LabVIEW suppors different devices.
  • You have to just install the drivers or toolkit of these devices.
  • After successful installation you will be able to use these devices.
Description of Front Panel
  • Press “Right Click” on the “Front Panel” window
  • You can see the output of your designed algorithm on the “Front Panel” window.
  • We can make our output’s look more and more beautiful.
  • For this purpose NI LabVIEW provides us with the “Decorations” section.
  • Go to the Controls-> Modern-> Decorations and the following window will be appeared on your screen.
 
  • These blocks are helpful while giving the better external look to the Front Panel.
  • Now go to the Controls-> Modern-> Boolean and you will have a look at the Boolean Buttons which are different in shapes and sizes.
  • You can see a new window on the screen as shown in below figure:
  • Round LED, Square LED are used for some indication purposes.
  • You can use a “Stop” button to terminate the program.
  • You can use radio buttons for “checking” and un-checking purposes.
Graphical Visual Display
  • Graphical Visual display is also a good function in NI LabVIEW.
  • You can display your output on different graphs.
  • Go to Controls-> Modern-> Graph and all the graphical Visual Displays open up.
  • The figure shown below will be appeared on the screen.
  • Select the graph you want and display your output on a particular graph.
  • 3D graphs is a very good option for the good looking output.
Searching Desired Blocks
  • Press “Right Click” in the front panel
  • Go to the “Search” option as shown in the figure below
  • Press the “Search” option
  • You can see following window on the screen
  • Type the name of the block you want to find.
  • Sometimes the “simple search” method takes a lot of time in finding the desired blocks.
  • So, I prefer to use the quick search method.
  • So, you should use “Quick Search” method, it will be helpful in time saving perspective.
  • Go to the “Front Panel” and press “Ctrl+Space Bar”.
  • You can see a new window on the screen.
  • You can see the window in the figure below.
  • For example, I want to search the “Simulate Signal” block.
  • So, I typed “Simulate Signal” in the search bar.
  • The desired blocks are appeared as shown in the figure below.
So, that's all form today's tutorial on Introduction to LabView. I hope that it will be helpful for all of you. I have tried my level best to share in detail, my knowledge on Introduction to LabVIEW, with all of guys. I'll share further knowledge about this software soon, till then take care :)

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir