Freelance 2013 look-up table logic(ASTM table for density calculations)
I need to make a logic in freelance for calculating the Absolute density(density@15) of Oil
I have two inputs with me i.e. ambient density and ambient temperature. Also we have look-up table (ASTM) table for refrence. from where we can see the corresponding density at 15 Deg C. The product is flowing inside a pipeline and the I am getting two inputs from a mass flow meter.
Can anybody guide how we can make logic for this.
As far as I understand You need a function that returns a value based on two inputs, right? Then You should simply use ST programming - maybe even in a User Function Block if You will need multiple instances of this code.
You initialize a two dimentional ARRAY with Your data from this excel sheet (this can take some time when doing manualy, so I would suggest cutting all descriptive data from that excel and saving it as a CSV file, from which You should very easily copy the whole data array). Then You return the value from row and column based on the input values. That's all.
If You need more accurate value, then you should simply make a linearization between two nearest values and return this as a output.
See Freelance Engineering - IEC 61131-3 Programming manual (section 8 Structural Text) for more info on ST editor and ARRAYS.
Hope this helps,
Also you can use 'if then else' and 'for loops' in ST language, But for that you need to analyse data available in excel sheet and derive some formula. e.g. while observing tab A in attached excel sheet for row 3 if you subtract column values from C to B, D to C difference is 1 upto column J ( up to temp value 708.0 for row 1) then difference is incremented by 1.1 and then same difference 1.0 continues. So starting from 690.8 keep value incremented using for loop and exit with if then else.
So Logic will be complex but need not need to feed data manually. Or check if customer is having any formula for density calculation then your life will be easy implementing this.