0:06
Good morning everyone, thank you for joining us on this webinar on Tank Volume Calculation Function Blocks.
0:12
It’s a relatively shorter one than others, it’s about 10 minutes presentation but if you do have any questions you can put them in and we’ll get to them at the end.
0:20
Hello and welcome to today’s webinar. Today we will look at Tank Volume Calculation Function Blocks.
0:27
Let’s look at our agenda for today.
0:30
First we will do a quick review of user-defined function blocks, Then we will look at the tank volume function blocks that we will be using today.
0:39
We will look at options for cylindrical tanks, oval tanks and capsule tanks.
0:44
We will also discuss the maths behind these function blocks.
0:48
There will be demonstrations throughout and we will finish with the Q &A session.
0:53
User defined function blocks or UDFBs are sections of code that are modularized in a callable function similar to subroutines.
1:02
However, UDFBs are much more powerful than subroutines because they allow you to have multiple instances of a user-defined function block throughout the same program.
1:12
Whether you create your own function blocks or you import ones that have been made by someone else into your project, user-defined function blocks are an excellent way to efficiently solve a variety of application issues.
1:25
UDFBs require that you use variable-based logic.
1:28
This can be either variable-based advanced ladder, which the function blocks we will be demonstrating today use, or you can also use the seascape IEC options.
1:39
Why are we creating these user-defined function blocks for the calculation of tank volume?
1:44
It is a common task in automation to be able to effectively measure the level in a tank and then calculate the volume.
1:51
However, based on the geometry of some tanks, this can be challenging and can involve a lot of maths to make the conversions or calculations required.
2:01
So importing these user-defined function blocks that are well tested into your project can save you a lot of time and effort.
2:09
Here are the six different tank geometries that we have created user-defined function blocks for.
2:14
These are horizontal and vertical cylinder tanks, horizontal and vertical oval tanks, and horizontal and vertical capsule tanks.
2:23
Now we will look at some of the maths behind these function blocks.
2:27
We will start with the horizontal cylinder tank, which is what we will focus on for our demonstration today.
2:33
The main value we need to get is from calculating the volume of a cylinder section.
2:38
So let’s say we have a cylinder lying on its side and we cut it in half horizontally.
2:43
This cross section would represent the level of the liquid in the tank.
2:48
There is a lot of trigonometry involved in calculating the volume of this.
2:52
However, our UDF-B will help us calculate this instead.
2:56
The calculations for the volume of a vertical cylinder tank are a lot easier.
3:01
Here we would just need to get the circular area of the tank using pi r-squared, and then multiply that value by the fill height.
3:08
But once again, this is done for us through the user-defined function block.
3:12
The calculations for a horizontal oval tank are very similar to a horizontal cylinder tank.
3:19
Once again, we can treat this as a horizontal cylinder cut in half, but this time with a rectangular section in the middle.
3:26
So we can combine the techniques of a rectangular tank and a cylindrical tank to make these calculations.
3:33
A vertical oval tank is similar to this, except for this we will have to make different calculations depending on where the liquid level is.
3:41
whether it is in the lower half cylinder section of the tank, the middle rectangular section, or the upper half cylinder section, but this is done by our function block.
3:52
Then we have UDFBs for capsule tanks.
3:55
We can treat this horizontal capsule as a cylinder with a half a sphere at each end, and get the volume of each of these shapes.
4:03
Finally, we have a vertical capsule tank.
4:05
This is similar to our calculations for a vertical oval tank, as we have different calculations involved depending on where the level of the liquid in the tank is.
4:16
Next, we will look at how you can use these UDFBs in your projects.
4:20
You first need to import the UDFB file into your project.
4:24
You can add an instance or multiple instances of that function block into your logic.
4:29
As you assign each instance or add each instance to your program, you will assign variables to it.
4:36
Each function block has both input and output variables.
4:40
All of the input variables, except for one, are in a floating point format, and the values you get from the output variables will be gallons, liters, and percentage filled.
4:50
So regardless of whether you choose to use imperial or metric type volume measurements in your project, or if you are just looking for the percentage that the tank is filled, you will still get all three of these outputs from each of the user-defined function blocks.
5:05
Now we will look at how we can use these user-defined function blocks we’ve created in Cscape. We will start with a fresh program for this demonstration, but this is optional.
5:15
You can also import your UDFBs into an existing program.
5:19
The only requirement is that you need use Variable Based Advanced Ladder or IEC.
5:25
These specific UDFBs we have created are for Variable Based Advanced Ladder, so we will select Variable Based Advanced Ladder here.
5:34
We are using Variable Based Advanced Ladder because one of the requirements for user defined function blocks is that you have a variable based language and register based advanced ladder is not variable based. We will select OK and we have created a brand new program.
5:51
Next, we will go to Logic Modules, right-click and select Import Logic Module.
5:57
Then we will navigate to the folder containing our UDFB files by searching for any.cpu files.
6:04
To import a function block, we will select the horizontal cylinder Tank UDFB, for example, and select Open, and it will appear under UDFB Modules.
6:15
We will note that we can have multiple instances of these function blocks in our program if want. We are currently looking at the logic inside of this UDF-B. We will close this tab.
6:27
If we want to add this function block to our program, we first need to add it to an existing rung of logic. For now, we will use the always-on contact.
6:37
Then we will go to our project toolbox and under UDF-Bs we can find all the function blocks we have imported into our program.
6:45
we will select our horizontal cylinder function block and drag it onto our rung.
6:50
It is important to note that we have to name every instance of this function block that we will use.
6:56
For example, we will call this Tank1Volume.
7:00
We are only naming the instance of this particular UDF-B, which will then show up in our variable list.
7:06
Now that this instance of this function block has been created, we next need to fill in the variables for all of the inputs and outputs.
7:14
These UDFBs we have created mostly use real variables for the diameter, the length, and the height, as well as the gallons, leasures, and percentage fields.
7:24
The only exception to this is the units underscore M input, which is a Boolean.
7:30
So if this variable is on, we will be using metric units or meters for our linear dimensions.
7:36
If it’s off, we will instead be using imperial units or feet.
7:40
Regardless of whether we use feet or meters, we will still get values for the gallons, leashes and percentage filled.
7:48
For example, we will create a variable to assign to the diameter called tank1Diameter.
7:54
We will assign this as a real variable and set the user group to retained variable.
8:00
We would then repeat this for the rest of our variables.
8:03
We can also just type the values in instead.
8:06
We don’t need to have variables assigned to all of these inputs.
8:09
For example, if the length of the tank is always 10 meters, we could enter 10 here.
8:15
The fill height has to be a variable, as it is getting input from the sensor.
8:20
Also, if we know we will always be using feet for our measurements, then we can assign our units variable as always off.
8:28
This is a Boolean variable, so this is now always set to zero.
8:32
So we can go through and assign each of the variables in turn, or for the values that have to be variables, such as the diameter and length, we can simply type these in as constants.
8:43
So this is how we set up our user-defined function block for our program.
8:47
Now we will close this project and show you our demo program for tank volume, which uses all six of our UDFBs.
8:55
These have all been imported into our project and can be seen under UDFP modules.
9:00
If we look at our main logic, we can see we are calling each function block turn, and each one can be called by a push button on the touchscreen of our OCS.
9:10
In our graphics editor, we can see that on each of the screens, we have added a diagram of the tank, along with the data that can be typed in and the results from the function block outputs for gallons, liters and fill percentage.
9:24
Now let’s look at our bench setup for this demonstration.
9:27
On our OCS, we are currently looking at our horizontal cylinder tank screen.
9:31
We have set our values to be in feet for the demonstration, so we have set the tank diameter as 3 feet and the length of the tank as 6 feet.
9:41
We have also set the fill level as 1, but usually you would have sensor connected here.
9:46
If we press the calculate button, we get our calculations for our gallons, liters and fill percentage.
9:52
We have the same setup for all three types of tanks.
9:56
Let’s look at our screen for our horizontal capsule tank.
9:59
Once again, we have our diameter of 3 feet, our length of 6 feet, and our fill level of 1.
10:06
We will press the calculate button again, and once again we get values for our gallons, liters, and fill percentage.
10:13
That concludes our webinar for today.
10:15
Thank you so much for listening, and the Q &A session will begin shortly.
10:30
Okay, so following up from that we have run to Cscape 10 again with the Project Navigator into Alarm Handling, Recipes and WebMi Plus.
10:42
So that’ll take us up for the next month’s worth of webinars. I’m not seeing any questions in as yet and that’s kind of straightforward.
10:52
If you do have any questions after you can email.
10:56Okay, thank you all very much and I and I’ll see you next week