Create a simple program using NI LabVIEW

The first program that my mentor told me to develop here at NI was a simple calculator that could perform basic mathematical operations. This was basically done to help the new interns get an idea of the LabVIEW environment and its various feature. Developing programs in LV is kind of different from the traditional methods of writing lines of code and compiling them. LV makes use of an interactive graphical method to develop complex software. You basically just drag and drop blocks that perform some specific functions and connect them together through wires to get the desired output.

Now there may be a lot of tutorials and VIs (programs in LV are saved with a *.vi extension and are known as Virtual Instruments) on the internet that will let you do this. But I am sure that the calculator that I am going to show you is different from them. At least I was not able to find any similar program on the internet.

So lets begin!

The first thing I did was to create a while loop with a nested event structure. All the button clicks an the inputs that user enters are handled by this event structure. I went for a simple minimalist interface with the following components on the screen:-

  1. A numeric control that the is used for taking the input from the user.
  2. A numeric indicator that displays the result.
  3. A string indicator that displays the sequence of operations.
  4. Seven buttons for performing basic mathematical operations.
  5. An Enter button to perform calculations.
  6. A Refresh button to clear the previous operations.
  7. An Exit button that will end the program.

To perform the operations I used a case structure. All the operation buttons were connected to a ‘build array’ function which was further connected to ‘Boolean array to number’ function which finally connected to the Case Selector. In this way I could control the case structure with Boolean selector variables. Below is an image which shows what I mean.

caseStruc

To implement the Refresh button I simply used a select operation which took the output of  the Refresh button as the selection criterion (s). Its implementation is shown below.

Refresh

This means that whenever I pressed the Refresh button, zeros were taken as input and the output window would show 0. Also I used a similar way for displaying the Sequence of Operations. The only difference was that since it was a String indicator, it had to select between the space character and the output from a concatenate string which basically kept on appending each successive operation into the present string. I used shift registers to keep a track of the previous values.

Also I used a shift register to insert my result back into the case structure as the second operand. The bottom-most yellow wire in the last image is actually coming from a shift register in the left. Here is the image to bring some clarity

shift

This is pretty much all there is to the operations part.

Next I decided to add nice touch to my calculator by adding a custom wallpaper. To do this you right click on the front panel scroll bar and select the Properties option. Then in the background tab you can select a custom image as your wallpaper.

 

This got over quite fast. So to explore even more features I decided to create a standalone application that could run without first starting LV in your system. Now this part requires that you have LV Run Time Engine on your system.

To do this select ‘Build Application (EXE) from VI’ option under the Tools menu. Now I could go on telling you step by step on how to do this but luckily I found a great video on how to do this on You Tube. Here is the link to it:

By the end of this video you can easily create a working standalone application.

Here is the final image of how my calculator turned out to be,

Final

 

And here is the block Diagram image,

block

I also made use of some custom buttons for my Exit button which I downloaded from ni.com (https://decibel.ni.com/content/docs/DOC-16709). You can look around on the internet for some more options and features.

You can access and download my program from https://decibel.ni.com/content/docs/DOC-38860

Stay tuned for more…

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s