I think you will have to build this function by your self. I would try to use the FB LIN_TRAFO from the Util lib.
Create a 2D array (table with 2 column) with sensor values and depending volume values.
Set the min values of the input and output of the lin_trafo fb with the values from the array index next below the actual sensor value.
Set the max input/output values of the lin_trafo fb to the values from the array index next above the actual sensor value.
So your tank will be divided into several linear volume parts. Good luck!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If the relationship between level and volume is amenable to it, one thing you can do is to use software that can perform a regression to get a a formula that approximates volume as a function of the level (Excel graphs can do that). Then, instead of a lookup table, you just perform a direct calculation. It makes for more concise code.
Obviously, you need a different formula for each tank geometry, but the same is true with lookup tables (or at least their content).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Can you please help me to have volume of Non linear tank from 4-20mA ?
Is there any tabular options in ladder logic>?
Hello,
I hope you are doing well. Here is a similar discussion topic posted in Forge that I think can help you: https://forge.codesys.com/forge/talk/Engineering/thread/aa5f2f9294/.
I hope this helps!
Regards,
Shawn
I think you will have to build this function by your self. I would try to use the FB LIN_TRAFO from the Util lib.
Create a 2D array (table with 2 column) with sensor values and depending volume values.
Set the min values of the input and output of the lin_trafo fb with the values from the array index next below the actual sensor value.
Set the max input/output values of the lin_trafo fb to the values from the array index next above the actual sensor value.
So your tank will be divided into several linear volume parts. Good luck!
If the relationship between level and volume is amenable to it, one thing you can do is to use software that can perform a regression to get a a formula that approximates volume as a function of the level (Excel graphs can do that). Then, instead of a lookup table, you just perform a direct calculation. It makes for more concise code.
Obviously, you need a different formula for each tank geometry, but the same is true with lookup tables (or at least their content).