Area and Volume Calculation in LabVIEW
Here I am going to elaborate you about the different formulas to calculate the area and volume of the different shapes e.g. circle, cylinder, square, triangle etc. I will focus to calculate the area and volume of two different shapes with the given radius. The basic formulas for the area and volume of the square or rectangle are given below.- Area = length × width
- Volume = length × width × height
- Area of circle = pr²
- Area of cylinder = 4pr²
- Volume of cylinder = (4/3)pr³
Youn can download a complete NI LabVIEW simulation here.
I am using above formulas to calculate these parameters using NI LabVIEW. I will make a very simple program in NI LabVIEW which will take radius as an input and calculates the area and volume of circle and cylinder after manipulating the given area. You can also select the maximum limit of the radius. When the radius approaches its maximum limit an LED will glow showing the notification reduce the radius. So, let's start with the NI LabVIEW to make this program for Area and Volume Calculation.Steps to Follow
- Go to the Front Panel and Right Click on it.
- Go to Controls-> Silver-> Numeric, you can see different numeric blocks here e.g. numeric control, numeric indicator etc.
- Choose the encircled block shown in the below.
- Select and place the encircled block on the Front Panel and change its name to Set the radius limit.
- Similarly select another Numeric Indicator and change its name to Radius.
- Now, go to Controls-> Silver-> Numeric-> Indicator, select this block and place it on the Front Panel.
- Copy this block and paste it two time on the Front Panel.
- Change their names to Area of Circle, Area of Cylinder and Volume of Cylinder respectively.
- The figure shown below describes all of the above steps.
- Set the radius limit block will help you to set the maximum value of the radius.
- You can enter the required radius the Radius block and the other three blocks will show the desired results depending upon the radius.
- Now go to Controls-> Silver-> Boolean, you can see different Boolean blocks here.
- Choose the encircled block as shown in the figure below.
- Select the encircled block and place it on the Front Panel.
- LED is used to show the indication when the radius reaches its maximum limit.
- Here is the screenshot of the updated Front Panel.
- Now, go to the Block Diagram window, here you can that the blocks are automatically placed there.
- Here is the screenshot of the Block Diagram window.
- Now, let's make the logic to find the area of the circle.
- Go to Functions-> Programming-> Numeric, you can see different numeric blocks here.
- Choose the encircled block as shown in the figure below.
- Select the Multiply block and place it on the Block Diagram window.
- Now go to Functions-> Programming-> Numeric-> Math Constants, you can see different types of numeric constants here.
- Choose the encircled math constant as shown in the figure below.
- Select the encircled Field Programmable Gate Array (FPGA) block and place it on the Block Diagram window.
- Now, make a simple logic to find the area of the circle by adjusting the radius.
- Algorithm is shown in the figure below.
- I have set the value the radius as 2 and run the program, you can see the area calculated by NI LabVIEW there.
- The calculated area with the given radius is shown in the figure below.
- Now, go to the Block Diagram window.
- Go to Functions-> Programming-> Comparison, you can see different comparison blocks here.
- Choose the encircled block as shown in the figure below.
- Now make a simple logic for the indication when the radius reaches its maximum limits.
- The logic for this particular purpose is shown in the figure below.
- Now, go to the Front Panel you can see, I have adjusted the maximum limit of the radius as 5, you can see when radius approaches its maximum limit LED shows indication.
- The above step is elaborated in the figure below.
- Now, put your cursor on the LED and right click on it.
- Go to the properties and make the changes shown in the figure below.
- Updated indication is shown in the figure below.
- Now, I will make an algorithm to find the area and volume of the cylinder according to the formulas written at the start of this tutorial.
- The virtual instrument (VI) for the desired algorithm is shown in the figure below.
- Now, go to the Functions-> Programming-> Structures, here you can see different structures blocks.
- Choose the encircled block only, as shown in the figure below.
- Select the For Loop and place it on the Block Diagram window.
- Place the whole program inside the For Loop as shown in the figure below.
- Now go Red button at the bottom of the For Loop and click on it.
- Go to Create-> Constant, and make a connection between them, it helps to terminate program.
- The updated Block Diagram window is shown in the figure below.
Adding Background Image
- Go to the scroll bar at right side of the Front Panel and right click on it.
- Go to the Properties-> Background, as shown in the figure below.
- Go to the background and here you can easily browse any image at the background image of your program.
- I have added the image shown in the figure below.
- You can see the area of circle, area and volume of cylinder for the adjusted value of Radius. So, the complete output is shown in above figure.
- In the below video, I have explained how to use this LabView VI: