Home > Forum > IEC 61131 Programming (LogicLab) > Make a value scale
- This topic has 7 replies, 4 participants and was last updated 5 years, 11 months ago da Sergio Bertana.
-
AuthorPost
-
July 23, 2012 at 9: 55 am #35251Sergio BertanaAdministrator Forum
Many customers ask us how to scale a value, this is necessary for example in the case of acquisition of 4-20 mA current sensors. As the current value acquired by the 4-20 mA sensor varies, a corresponding acquired quantity value corresponds.
The function ValueScale (Manual extract), allows the input of the acquired current value defining 4 mA as minimum value and 20 mA as maximum value. It will be enough to define the range of the value of the quantity to be acquired, the function will perform the conversion from the value of the acquired current to the engineering value of the quantity to be acquired.
In the simple FBD program I am attaching screenshot, the acquisition of a temperature sensor in 4-20 mA is performed, the minimum temperature value is -50 ° C and the maximum 150 ° C. As you can see from the screenshot at 6 mA the temperature value acquired corresponds to -30 ° C.
November 19, 2013 at 2: 42 pm #37901oscar_stbParticipantIs it possible to use this function if I have to acquire voltage values that are not linear? Let me explain: voltage value 1V engineering value 1, voltage value 2V engineering value 1,5. In case which function block to use?
November 19, 2013 at 2: 51 pm #37902oscar_stbParticipantI think I found it: Linearize?
November 19, 2013 at 5: 14 pm #37903Sergio BertanaAdministrator ForumIt is just the function lINEARIZE (Manual extract) that you need. As you can see from the manual you have to supply the function with the addresses of two arrays of REAL variables.
VInReference, Array with input values to be linearized (In your case 1.0, 2.0, etc.).
VOutReference, Array with linearized output values (In your case 1.0, 1.5, etc.).The function searches the array VinReference of the value immediately higher than the input value by linearly interpolating between the found value and the previous one, calculating the output value based on the two values present in the same positions of the array VOutReference. Naturally the output value will be much more precise the more points you have tabulated in the two arrays.
October 4, 2017 at 9: 08 am #39983AuthorlessIdleI wanted to ask for information on the Linearize function, is it possible to use a csv file instead of the two arrays in order to calibrate the sensor without having to switch off the system?
I looked for a solution on the forum, I found this discussion e this discussion, but unfortunately I could not change them for my purpose.
October 4, 2017 at 9: 16 am #39984Sergio BertanaAdministrator ForumThe function lINEARIZE calculates the output value based on the input value based on two arrays VInReference and VOutReference, the two arrays must be evaluated when the function is executed. So to read the values from a CSV file you have to read the file and transfer the values into the two arrays. I believe that based on the two topics you mentioned you can already have an idea of how to do it.
But if the need is to dynamically change the values in the arrays, it is sufficient to simply declare the arrays as RETAIN and with Debug LogicLab to modify the values.
If you define the RETAIN arrays every time you load the program their value is reset to the value of init. If you want the values set by debug to remain, just allocate the arrays in the buffer memory area (From DB100.2048 onwards). In this topic information on the use of retentive memory.
April 4, 2018 at 8: 18 pm #40064FleaParticipantOn the Logiclab 2.5 version I can't find the scaling function in the eLLabUtyLib_C040 library ... where can I find it?
April 5, 2018 at 5: 32 am #40065Sergio BertanaAdministrator ForumThe latest versions of the various LogicLab libraries are available in the download area of the bookshelf page on our website. Download the library you are interested in and then import from the library (Topic) the object you need (In your case the ValueScale function). What is strange is that in the library eLLabUtyLib_C040 the function is present, you are sure you have selected the functions (Screenshot) when do you import?
-
AuthorPost
- You must be logged in to reply to this topic.