IMDHMIControls LibraryShop main store

Troubleshooting

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

Controllers and I/O Published 7 min read

Short answer

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.

On this page
  1. Decode the raw count first
  2. Meter the loop at the terminal
  3. Walk the return path and channel setup
  4. Split sensor from module with a loop calibrator
  5. Fix the scaling with fixed endpoints
  6. Verify end to end
  7. Questions asked

A current loop is linear by construction: the transmitter is a current source, the module's input chain is linear across its rated span, and nothing between them bends the transfer function. So when the raw word on your SM 1231 swings between 10 and 30246 counts while the scaled value only matches at 60 mm and 160 mm, the loop current is not what the sensor's LCD says it is. On this module, 27648 counts is the top of the loop's measuring range, and 30246 decodes to 21.50 mA: over-range fault current, not full scale. Work the fault in this order: decode the count, meter the loop at the terminal, split sensor from module with a calibrator, then anchor the scaling to 0 and 27648.

Decode the raw count first #

A channel configured for this loop maps its range linearly onto the process-image word: 4 mA is 0 counts, 20 mA is 27648 counts, and the slope is 27648 / 16 mA = 1728 counts per mA. That is the documented full-scale range for current inputs on the SM 1231 8-channel module (6ES7231-4HF32-0XB0; Siemens support entry 109759862). Above it the word keeps reporting: counts from 27649 to 32511 are the over-range band, 32767 is overflow, negative counts are under-range, and a fully broken loop drives the channel to its limit value while it raises a channel diagnostic.

Convert any count back to current with:

I [mA] = 4 + 16 x (raw / 27648)

Decode your two observed extremes:

  • 30246 counts: 4 + 16 x (30246 / 27648) = 4 + 16 x 1.094 = 21.50 mA
  • 10 counts: 4 + 16 x (10 / 27648) = 4.01 mA

21.50 mA cannot be a distance. Two explanations fit it: the sensor really drove past full scale, which this sensor class does for lost-target, out-of-window and signal-quality states, or the module mangled a healthy current because the channel type or its reference is wrong. The meter check next separates them. Either way, 30246 is not an endpoint to teach into scaling.

Loop current Expected count Meaning
Below 4 mA Negative, under-range Loop open or sensor under-driving
4.000 mA 0 Bottom of the measuring range
10.4 mA at a 100 mm target 11059 Working point inside the window
12.000 mA 13824 Mid-scale
Full scale 27648 Top of the measuring range
21.500 mA 30246 Over-range: fault or out-of-window current
Past the over-range band 32767 Overflow value or broken loop

Meter the loop at the terminal #

Break the loop at the module terminal, put a multimeter in series in DC mA mode, and hold a target at three known distances. For a taught 60 to 160 mm window the transfer function is fixed arithmetic: 16 mA spread over 100 mm is 0.16 mA per mm.

I [mA] = 4 + 0.16 x (d_mm - 60)

  • 100 mm: 4 + 0.16 x 40 = 10.4 mA
  • 110 mm: 4 + 0.16 x 50 = 12.0 mA
  • 160 mm: 4 + 0.16 x 100 = the top of the range, 27648 counts

One safety note: inhibit whatever acts on this distance before you open the loop, because a swinging analog value can command machine motion while your hands are at the terminals.

Decision: if the meter tracks those currents within the sensor's stated linearity, the sensor and its window are sound and the fault is downstream, in wiring, channel configuration or the module. If the meter reads 21.5 mA while the LCD shows a normal distance, the sensor is signalling a fault state; re-teach the window through its menu, which offers manual teach-in of the 4 mA and 20 mA endpoints. No PLC change repairs that.

Remember the display trap: the LCD shows distance regardless of the taught analog window, so screen and current disagree by design whenever the window is not what you assumed.

Walk the return path and channel setup #

Your hookup, sensor signal to the channel's + terminal and supply 0 V to the channel's - terminal, is the standard 3-wire arrangement, with one requirement: the module's M and the sensor's 0 V must be the same node. A 3-wire sensor returns its supply current and its signal current through the shared 0 V conductor, so every crimp in that path is part of your measurement. Work this list with the sensor viewing a fixed target:

  • 24 VDC on the module's own L+ and M terminals. The analog section runs on its own supply, and an unpowered module returns arbitrary counts, not zero.
  • One 0 V bond. Measure DC volts between the sensor's 0 V terminal and the module's M: expect millivolts. A reading approaching 1 V is conductor drop or two unbonded supplies, and the loop current is finding a return path you did not design.
  • Channel type Current, the matching current range, in the module's device configuration. A channel left in a voltage range presents a high input impedance, the sensor runs out of compliance voltage, and the count pins high.
  • Shield landed at the cabinet end only. Landing both ends makes the shield a current path and the count wanders at low frequency.
  • Integration time set against the local mains frequency, with moderate smoothing. That removes ripple; it never removes an offset or a wrong slope.

Then watch the raw word for a minute on a static target. A healthy channel holds within a handful of counts; a swing of hundreds of counts on an unchanged target is a return-path fault, exactly the 10-to-30246 pattern, and no scaling constant survives it.

Split sensor from module with a loop calibrator #

This test cuts the loop in half. Disconnect the sensor signal wire, connect a loop calibrator in source mode to the channel's + and - terminals, and step it while watching the process-image word:

Injected current Expected count If it fails
4.000 mA 0 Offset error, or the wrong range selected
8.000 mA 6912 Linearity deviation
12.000 mA 13824 Gain error if the ends match but mid-scale is off
16.000 mA 20736 Linearity deviation
Full scale 27648 Far above 27648 means voltage mode or a defective channel

Expect each point inside the module's accuracy class and all five on a straight line. If injection is linear while the sensor was not, the sensor or its window owns the fault. If injection itself is non-linear, move the wires to a spare channel and repeat before condemning the module.

Fix the scaling with fixed endpoints #

Endpoints are properties, not observations. NORM_X gets 0 and 27648 because they belong to the module's range; SCALE_X gets 60.0 and 160.0 because they belong to the taught window. The two-point teach matched at 60 mm and 160 mm only because the line was bent through whatever counts the loop happened to produce that day.

Illustrative SCL for one channel:

// Illustrative tags with initial values
"raw_ch0"     : Int  := 0;      // process-image word of the channel
"norm_ch0"    : Real := 0.0;
"dist_mm"     : Real := 0.0;
"range_fault" : Bool := FALSE;

"norm_ch0" := NORM_X(MIN := 0, VALUE := "raw_ch0", MAX := 27648);
"dist_mm"  := SCALE_X(MIN := 60.0, VALUE := "norm_ch0", MAX := 160.0);

IF ("raw_ch0" > 27648) OR ("raw_ch0" < 0) THEN
    "range_fault" := TRUE;   // hold last good distance, raise an alarm
END_IF;

NORM_X and SCALE_X are the documented instructions; the tag names are illustrative. Prove the chain from a watch table:

  • 0 normalizes to 0.0 and scales to 60.0 mm
  • 13824 normalizes to 0.5 and scales to 110.0 mm
  • 27648 normalizes to 1.0 and scales to 160.0 mm
  • 30246 extrapolates to 169.4 mm and sets the fault

That last line is the whole argument: 169.4 mm is a plausible-looking number made of pure fault current, and without the guard somebody eventually tunes the machine to it.

Verify end to end #

Restore the sensor and walk five targets; every row must hold across all three columns:

Target Meter Raw count Scaled value
60 mm 4.00 mA 0 60.0 mm
85 mm 8.00 mA 6912 85.0 mm
110 mm 12.00 mA 13824 110.0 mm
135 mm 16.00 mA 20736 135.0 mm
160 mm Full scale 27648 160.0 mm
Target removed Above full scale Above 27648 Fault alarm within one scan

Expect the largest deviation of the five points to stay inside the sum of the sensor's linearity spec and the module's accuracy spec. A residual that grows toward mid-scale points back to the injection test, not to the scaling blocks. On a new station, run this pass alongside a remote I/O commissioning checklist before handover.

Questions asked

Why did my readings match at 60 mm and 160 mm but not in between?

Because the two taught endpoints force the scaled value through the counts you captured that day, those two points match by construction and everything between inherits the loop's real error. With endpoints of 10 and 30246 counts, a true 110 mm signal of 13824 counts scales to 60 + (13824 - 10) / (30246 - 10) x 100 = 105.7 mm, a 4.3 mm error from the slope alone. Restore endpoints of 0 and 27648 and the same count reads 110.0 mm.

Will averaging or a longer filter time fix the flutter?

No. A longer integration time and smoothing remove ripple, and that is all they remove. A count that walks between 10 and 30246 on a static target is a wiring or reference fault, and filtering it produces a slower wrong number with the fault intact. Repair the return path and the 0 V bond first, confirm the channel is linear with a calibrator, then set filtering only against genuine process ripple.

Does the analog module need its own 24 V supply?

Yes. The SM 1231 needs 24 VDC on its own L+ and M terminals to run the analog electronics; the signal pair alone does not power the channel. A module without that supply returns arbitrary counts rather than zero, which looks exactly like a non-linear sensor. Put a meter on those terminals before touching the program; it is a two-minute check.

What does a broken loop read on a 4-20 mA channel?

Not a usable low value. A broken loop drives the channel to its limit value and raises a channel diagnostic, and counts below 0 or above 27648 mark under-range, over-range or overflow. Enable the channel diagnostics in the device configuration, alarm on any count outside 0 to 27648, and hold the last good distance when the alarm fires. A distance derived from fault current is worse than no reading at all.

How much is one millimetre in counts?

For a 60 to 160 mm window on a 4-20 mA channel, 27648 counts span 100 mm, so the channel delivers 276.48 counts per millimetre and 1728 counts per milliamp. Use the scale to judge what you see: a 5 mm offset is about 1382 counts, while 20 counts of noise is under a tenth of a millimetre. That comparison tells you at a glance whether a swing is mechanical, electrical or numerical.

Keep reading

  • How-to

    Remote I/O commissioning checklist for a modular station

    Commission a modular remote I/O station in this order: match the coupler's protocol and addressing to the controller interface, budget and verify station power, seat modules and connectors against the drawing, then prove cyclic data exchange and every field signal before enabling outputs. A loading web page and lit status LEDs prove the coupler is alive; only a value that changes at the controller proves valid I/O data.

    Controllers and I/O

  • Troubleshooting

    Connecting STARTER to a PROFIBUS drive through an S7-300

    Being online with the S7-300 does not put STARTER online with the drive. Confirm the drives are on PROFIBUS, make the drive's station address match the one the project expects, select the routed path through the S7-300 in STARTER, and save the new parameters to EEPROM with P0971 = 1.

    Industrial networks

  • Troubleshooting

    PLC-5 not visible in RSLinx after processor replacement

    A replacement PLC-5 stays invisible in RSLinx because the 1785-ENET sidecar answers the network on its own while the processor waits for an application that configures the Ethernet channel 3A. Leave the non-isolated serial port disconnected until the cable is checked, bring the processor up over serial DF1 or DH+, download the saved program, and the Ethernet path returns.

    PLC programming