IMDHMIControls LibraryShop main store

How-to

Scale an SM 1231 4-20 mA input with NORM_X and SCALE_X

Controllers and I/O Published 6 min read By IMDHMI controls team

Short answer

Chain NORM_X with MIN = 0 and MAX = 27648 into SCALE_X with MIN = -50.0 and MAX = 250.0, then compare the REAL temperature with 120.0 to drive the output. First force 4 mA and 20 mA and confirm the raw counts sit near 0 and 27648; a count near 5530 at the low end means the channel is still set to 0-20 mA.

On this page
  1. What NORM_X and SCALE_X each do
  2. Verify the raw endpoints before trusting the constants
  3. Program the chain, the trip and the mask
  4. Worked example: the transmitter midpoint at 12 mA and the trip count
  5. Bench test that proves the scaling
  6. Questions asked

Wire the transmitter into one channel of the SM 1231 AI 4x13 bit (6ES7231-4HD32-0XB0) on your 1214 CPU, set that channel to 4-20 mA in the device configuration, and do the rest in the program with two conversion instructions in series. NORM_X turns the raw count, across its 0 to 27648 count span, into a REAL from 0.0 to 1.0; SCALE_X maps that REAL onto -50.0 to 250.0 °C. You then compare the scaled temperature with 120 °C and drive the digital output from that comparison. One check decides whether those constants are honest: force the loop to both endpoints and read the raw counts before you trust a single line of the scaling.

What NORM_X and SCALE_X each do #

NORM_X (Normalize) returns a dimensionless REAL from OUT = (VALUE - MIN) / (MAX - MIN): it gives 0.0 when VALUE equals MIN and 1.0 when VALUE equals MAX. Feed it the raw Int directly; MIN and MAX take the same integer type as VALUE, and the output is a Real either way.

SCALE_X (Scale) is the inverse mapping, OUT = VALUE × (MAX - MIN) + MIN. With the normalized REAL at VALUE and the temperature endpoints at MIN and MAX, it returns the temperature as a Real. Both are standard conversion instructions — select the block in the network and press F1 for the vendor's own description — and the raw limits come from the S7-1200 analog data-word convention: the nominal span of a current range fills the word from zero up to a fixed full-scale count, and why the data word tops at 27648 explains where that number comes from.

One rule before any of this: the value arriving at NORM_X must be the channel count itself. If an older rung already offsets or scales it, keep one conversion, never both.

Verify the raw endpoints before trusting the constants #

The two blocks are trivial; the constants are where scaling goes wrong. Check the channel in this order:

  1. In the device configuration, the channel's measuring range must be the current range with a 4 mA live zero, not the zero-based one. Nothing in the wiring tells you which one is active.
  2. Force the loop to 4 mA, with the transmitter's own adjustment or a calibrator, and monitor the raw tag online. A count within a few counts of zero confirms the nominal mapping, and you can use the constants in this article as written.
  3. A count near 5530 instead is the signature of the zero-based current range: 27648 × 4 / 20 = 5529.6 is where that current lands on the wider scale. Correct the measuring range rather than scaling around it. Only if the configuration cannot be downloaded, on a machine you are not allowed to touch, enter the measured endpoint counts as MIN and MAX of NORM_X; the math then works on the real endpoints.
  4. Force the loop to the top of its range and expect the full-scale count. A materially different value is a loop problem — transmitter supply, loop loading, a shunt someone left in circuit — and calibrating software around it hides the fault.
  5. An unconnected channel does not read zero; it parks at the overflow value, as covered in why an SM 1231 AI8 reads 32767 on unwired channels, so run these checks with the loop powered.

Program the chain, the trip and the mask #

Declare the working tags first. The names below are mine; the instruction names and pin names are the documented ones.

// Block interface, illustrative tags with initial values
TempRaw   : Int;    // raw channel count, initial value 0
TempNorm  : Real;   // normalized value, initial value 0.0
TempC     : Real;   // scaled temperature in °C, initial value 0.0
TempHigh  : Bool;   // trip result, initial value FALSE
WireBreak : Bool;   // overflow mask, initial value FALSE

The logic, in SCL:

#TempNorm  := NORM_X(MIN := 0, VALUE := #TempRaw, MAX := 27648);
#TempC     := SCALE_X(MIN := -50.0, VALUE := #TempNorm, MAX := 250.0);
#WireBreak := #TempRaw > 32511;                 // documented overflow band
#TempHigh  := (#TempC >= 120.0) OR #WireBreak;  // trip, fails to alarm

In order:

  1. NORM_X takes the raw count at VALUE with the verified raw endpoints at MIN and MAX.
  2. SCALE_X takes the normalized REAL at VALUE with the temperature endpoints at MIN and MAX.
  3. The trip compares the scaled temperature with the setpoint in °C — the worked example below shows why you compare the temperature and never a derived count.
  4. Counts from 32512 to 32767 are the documented overflow band for this range, so a count above 32511 means a broken loop: OR it into the trip so the alarm fails on, and raise a maintenance bit with it.
  5. If the output chatters while the process holds at the setpoint, add hysteresis rather than a wider comparison:
IF #WireBreak THEN
    #TempHigh := TRUE;        // broken loop: fail to alarm
ELSIF #TempC >= 120.0 THEN
    #TempHigh := TRUE;        // on at the trip
ELSIF #TempC <= 118.0 THEN
    #TempHigh := FALSE;       // off 2 °C lower
END_IF;

Begin with 2 °C of hysteresis on a loop like this one: it is under 1 % of the temperature span, and it silences the relay chatter you would otherwise get whenever the process sits at the trip. Widen it only if the output still switches too often for the load it drives.

Worked example: the transmitter midpoint at 12 mA and the trip count #

Inputs, with where each comes from:

  • Transmitter range: 4 mA = -50 °C and 20 mA = 250 °C, from the transmitter's data for this application.
  • Raw span: 0 to 27648 counts, confirmed at both endpoints in the check above.
  • Trip point: 120 °C, the process requirement.
  • Test current: 12 mA, the middle of the loop.

The rule, in words: the temperature equals the lower endpoint plus the normalized fraction times the temperature span, and the normalized fraction is the count divided by the full-scale count.

The arithmetic:

  • Temperature span: 250 - (-50) = 300 °C
  • Counts at the test current: 27648 × (12 - 4) / 16 = 13824
  • Normalized value: (13824 - 0) / (27648 - 0) = 0.5
  • Temperature: -50 + 0.5 × 300 = 100 °C
  • Trip fraction: (120 - (-50)) / 300 = 170 / 300 = 0.5666667
  • Trip count: 0.5666667 × 27648 = 15667.2

Result: at the test current the program shows 100.0 °C with the output FALSE, and the output goes TRUE when the raw count passes 15667 — which the program expresses as the REAL comparison at the trip temperature.

Decision: keep that comparison on the scaled temperature, not on the derived count; the count moves the day an endpoint moves, and it hides the setpoint from the next technician. If the process can hold at the trip, the hysteresis decides the output: TRUE at the trip and above, FALSE 2 °C lower, unchanged in between — about 184 counts of raw hysteresis, 0.7 % of the span.

Bench test that proves the scaling #

Download, then drive the loop with a calibrator and watch the four tags online:

Loop current Expected raw count TempNorm TempC Output
4 mA 0, within a few counts 0.0 -50.0 °C FALSE
12 mA 13824 0.5 100.0 °C FALSE
just above the trip about 15667 0.5667 120.0 °C TRUE
20 mA 27648 1.0 250.0 °C TRUE

Ramp slowly through the trip instead of stepping: TempC must cross the setpoint and the output must change on the same evaluation. Then open the loop — the count jumps to the overflow value and the mask drives the trip, which is the last thing worth proving before you hand the machine over.

If the scaled REAL shows a long decimal tail on the panel, trim the display format rather than rounding the tag; the steps for fixing the decimal display of a NORM_X and SCALE_X result apply the same way to this chain.

Questions asked

My channel reads about 5530 counts at 4 mA instead of zero. Can I scale around that?

Yes, as a fallback. Put the measured endpoint counts into NORM_X: MIN equal to the count at the transmitter's low end and MAX equal to the count at its high end, and the scaling stays correct. You give up resolution, because the usable span shrinks to about 22118 counts, and the configuration no longer matches the loop drawings, so correcting the measuring range in the device configuration remains the better fix.

How do I stop a broken wire from reading as a valid high temperature?

Counts from 32512 to 32767 are the documented overflow band for this current range, and an unwired channel parks at the top of it. Fed through the chain, that count lands near 306 °C, above the trip, and looks like a genuine over-temperature. Add one comparison: when the raw count exceeds 32511, set a wire-break fault and drive the trip TRUE, because fail-alarm is the safe direction for over-temperature, and display the fault so the operator sees a broken loop rather than a hot process.

Can I use NORM_X and SCALE_X in ladder, or are they SCL only?

Both are conversion instructions available in LAD, FBD and SCL, so the ladder version is the same call. Drop in the NORM_X box, wire the raw tag to VALUE, type the verified raw endpoints at MIN and MAX, then feed its output to VALUE of the SCALE_X box with the temperature endpoints. The SCL lines in this article are the compact form of exactly those two boxes.

Why does mid-loop current not read half of the transmitter's top temperature?

Because the scale runs from minus 50 to 250 °C, not from zero. Mid-loop current sits halfway between the endpoints, so it reads the average of the two endpoints: (-50 + 250) / 2 = 100 °C. A reading of 150 °C there would mean the lower endpoint was typed as 50 instead of -50, the classic sign slip on a negative MIN.

Keep reading

  • Troubleshooting

    Troubleshooting non-linear 4-20 mA readings on an S7-1200 analog input

    A 4-20 mA loop is linear by construction, so counts swinging between 10 and 30246 mean the current at the terminal is not what the sensor LCD shows. On the SM 1231, 27648 counts is the top of the 4-20 mA range and 30246 decodes to 21.5 mA over-range fault current. Check the loop with a series meter, split sensor from module with a calibrator, and anchor NORM_X to 0 and 27648.

    Controllers and I/O

  • Troubleshooting

    Why an S7-1200 analog input shows 32767 on wire break

    With no transmitter connected, a 4-20 mA channel on an S7-1200 SM 1231 analog input carries less than 1.185 mA, and the module substitutes 32767 (hex 0x7FFF) in the input word instead of zero. The same word reports overflow above 22.81 mA, so measure the channel current to decide which fault you have. Below the wire-break threshold, repair the loop; above the overflow threshold, fix the over-current source.

    Controllers and I/O

  • Explainer

    S7-1200 analog input full scale: why the data word tops at 27648

    An S7-1200 analog input reports its rated range as the data word 0 to 27648 for current and -27648 to +27648 for voltage, per the analog value representation table in the S7-1200 system manual. The word keeps counting to 32511 before saturating, and the 25 to 50 °C figure on thermocouple modules is the internal cold-junction sensor, not the measurement range.

    Controllers and I/O