rjafri05
Hi Experts,

I want to scale the analog values, for example in my case 65535 - 0 to 100% - 0%. I have a GUI/HMI where user can enter the percentage of tank to be filled and then the pump should run until the analog level sensor signals to stop the pump.

Can any one of you guide me how this can be achieved on OpenPLC?

Best regards,
Syed Raza
Reply 0 0
thiagoralves
This is not a PLC issue, but a math issue. You solve this with a simple "rule of three". By definition: rule of three >> the method of finding the fourth term in a proportion when three terms are given. / a mathematical rule asserting that the value of one unknown quantity in a proportion is found by multiplying the denominator of each ratio by the numerator of the other. (Dictionary.com)

So if you want to scale it, here is the math:
65535  =======> 100 (%)
x    =======> User Input (%)

Now we just cross-multiply to get the formula:
65535 * User Input = 100*x
x = (65535 * User Input) / 100

So, for example, if the user input is 50%, then on the formula:
x = (65535 * 50) / 100
x = 32767

Or, if the user input is 32%, then on the formula:
x = (65535 * 32) / 100
x = 20971
Reply 0 0
bobert0670
So I just joined and I was looking for a Function as well.  Most PLC's have built in scaling FB's  for instance in Allen Bradley word its a scale with parameters block.  You se tthe Input Max, Input Min, Output max, and Output min and set the output.  Inside the FB it does the math to convert the values. I was just about to start writing a FB for the OpenPLC community.
Reply 0 0
thiagoralves
If you write a block like that, add it to the “Custom Blocks” section on this forum
Reply 0 0
bobert0670
of course
Reply 0 0
Reply