FUNCTION_BLOCK SCALE

Upon the occurrence of an event at the REQ input, an instance of this Function Block type converts an unscaled INT input value in the range {MIN..MAX} to a corresponding scaled UINT value in the range {0..100} percent according to the Java™ statement below, and then issues an event at the CNF output.

try{OUT.value
    = Math.max(0,Math.min(100,100*(IN.value-MIN.value)/(MAX.value-MIN.value)));
   }
catch(ArithmeticException ex){OUT.value = 0;}