1. Home
  2. PLC programming
  3. Scaling calculator

PLC scaling calculator

Convert between the signal on the wire, the raw value in the PLC and the value in engineering units, for 4 to 20 mA, 0 to 10 V and other analogue signals. Useful for programming and for loop checks on site.

MB AutomationSheet 16 of 17
Tool
Analogue scaling
Signals
mA, volts or your own
Raw values
Siemens, Beckhoff, custom
Cost
Free

Convert a value

Set the signal, the PLC and the range of the sensor, then type any one of the three values.

Check the raw range in your module manual. It can change with the module and its settings.

Result

Signal
12mA
PLC raw value
13824
Engineering value
50bar

50% of the range

Check the result against your module and sensor documents before you rely on it on a live machine.

Loop check points

Five points across the range, for checking a transmitter, the input card and the screen against each other.

PointSignal (mA)PLC rawValue (bar)
0%400
25%8691225
50%121382450
75%162073675
100%2027648100

PLC code for this scaling

The code follows the settings above. Add your own handling for signals that leave the range, such as a broken wire.

Siemens TIA Portal, SCL

// rawValue : Int;  norm, scaled : Real (bar)
#norm   := NORM_X(MIN := 0, VALUE := #rawValue, MAX := 27648);
#scaled := SCALE_X(MIN := 0.0, VALUE := #norm, MAX := 100.0);

Structured text, TwinCAT and CODESYS

// rawValue : INT;  scaled : REAL
VAR CONSTANT
    RAW_LO : REAL := 0.0;
    RAW_HI : REAL := 27648.0;
    EU_LO  : REAL := 0.0;   // bar
    EU_HI  : REAL := 100.0;   // bar
END_VAR

scaled := EU_LO + (INT_TO_REAL(rawValue) - RAW_LO)
          * (EU_HI - EU_LO) / (RAW_HI - RAW_LO);

Analogue scaling questions

What raw value is 12 mA on a Siemens S7-1500?
With a 4 to 20 mA input, 4 mA reads 0 and 20 mA reads 27648, so 12 mA is half way: 13824. With the input set to 0 to 20 mA, 12 mA is 60 percent of the range, about 16589.
How do I detect a broken wire on a 4 to 20 mA loop?
A healthy 4 to 20 mA transmitter does not drop near zero, so a very low current points to a fault. NAMUR NE43 treats 3.6 mA and below, or 21 mA and above, as a failure signal. Many input modules can also report a wire break as a diagnostic.
Why does my value read a little under or over the range?
Transmitters can move slightly outside 4 to 20 mA, and the input card keeps converting. Decide in the program what the machine should do when the value leaves the range you expect, instead of only limiting the number.
Where do I find the raw range of my module?
In the module or terminal manual, under the representation of analogue values. It can depend on the measuring range and on settings in the hardware configuration, so check it for the exact article number.

More questions and answers

Multi-axis servo panel with ESTUN servo drives, Schneider distribution and TeSys control

Need a hand with the PLC?

We program Siemens, Rockwell, Beckhoff, Schneider, Omron, Mitsubishi and ABB: new control systems, upgrades and fault finding.