Scaling Siemens S7-300 4-20mA Flow Input with FC105

David Krause14 min read
S7-300SiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Scaling Siemens S7-300 4-20mA Flow Input with FC105

Field commissioning a 0–9 m³/hr flow transmitter into a Siemens S7-300 CPU over a 4–20 mA analog input is one of the most common first-touch tasks for a process automation engineer. The plant signals all run, the HMI shows the loop is alive, but the engineering-unit value on the screen does not match the operator's handheld reference. The fault almost always traces to one of three places: a misconfigured analog input range in the SIMATIC hardware configuration, a 2-wire vs 4-wire wiring mismatch, or a scaling block (typically FC105 "SCALE") wired with the wrong LO_LIM and HI_LIM. This reference walks through the underlying signal-to-integer mapping, the module-level range selection, the FC105 call structure, and the verification checks you run at the panel before handing the loop back to operations.

Signal identity: A 4–20 mA current loop is live-zero: 4 mA = 0 % of range, 20 mA = 100 % of range. Anything below 4 mA (down to 0/1.185 mA on Siemens S7-300 SM 331 modules in 4-wire mode) is a wire-break or under-range fault, not a valid process value.

Prerequisites

  • SIMATIC Manager Step 7 V5.5 (or TIA Portal V13+ with S7-300 — refer to SIMATIC S7-300 S7-300 Module Data Manual).
  • CPU 31x with a free analog input slot.
  • SM 331 analog input module (e.g., 6ES7 331-7KF02-0AB0, 8 AI, 12-bit resolution or 6ES7 331-1KF01-0AB0).
  • Flow transmitter with isolated 4–20 mA output and a known calibration range (here 0–9 m³/hr).
  • STEP 7 standard library block FC105 from the "TI-S7 Converting Blocks" library, or the equivalent SCL function SCALE.
  • Wiring tools, calibrated 4–20 mA source (e.g., Beamex MC6 or WIKA CPH6000), and a 24 VDC supply for the loop.

Analog Input Signal-to-Integer Mapping

The S7-300 SM 331 analog input module digitises a current input into a 16-bit integer. The mapping depends entirely on the range you selected in HW Config for that channel:

Input range selected in HW Config Engineering unit (current) Integer at input (PIW) Notes
0 – 20 mA (unipolar) 0 mA 0 0 % lower limit
0 – 20 mA (unipolar) 20 mA 27648 100 % upper limit
0 – 20 mA (unipolar) Overflow 32767 Diagnostic flag set
4 – 20 mA (unipolar) 4 mA 0 Live zero
4 – 20 mA (unipolar) 20 mA 27648 Nominal full scale
4 – 20 mA (unipolar) < 3.6 mA -1 (dec) Under-range, wire-break (with diagnostic enabled)
4 – 20 mA (unipolar) > 22.8 mA 32767 Over-range
±20 mA (bipolar) -20 mA -27648 Full negative scale
±20 mA (bipolar) 0 mA 0 Midpoint

For a 4–20 mA flow loop the answer to the engineer's two commissioning questions becomes deterministic:

Process value Loop current PIW integer FC105 output (LO_LIM=0, HI_LIM=9.0)
0 m³/hr 4 mA 0 0.0 (REAL)
4.5 m³/hr 12 mA 13824 4.5 (REAL)
9 m³/hr 20 mA 27648 9.0 (REAL)
Wire-break 0 mA -1 (dec) / 0x8001 -3.38E-04 (or error flag set)

Direct answer to the questions in the source thread:

  • Q1: Flow = 0 m³/hr → current = 4 mA, PIW 288 = 0 (dec).
  • Q2: Flow = 9 m³/hr → current = 20 mA, PIW 288 = 27648 (dec).

The engineer's assumption in the original post is therefore correct only if the channel in HW Config is set to 4–20 mA (unipolar). If the channel is set to 0–20 mA by mistake, the transmitter's 4 mA live-zero will read as approximately 5529 dec (4/20 × 27648) and FC105 will incorrectly scale that to ~1.8 m³/hr for a true zero flow. That is the single most common commissioning defect in this class of problem.

Hardware Configuration in SIMATIC Manager

  1. Open SIMATIC Manager → HW Config and double-click the SM 331 module.
  2. For the slot used by the flow meter (e.g., Slot 4 → Channel 0, address PIW 288), select 4DMU (4-wire transducer, 4–20 mA) or R-4L (4-wire, 4–20 mA) from the "Measuring range" dropdown. The exact label depends on the module order number; refer to the S7-300 Module Data Manual, section 4.5 "Measuring ranges of the SM 331".
  3. Disable "Bipolar" — 4–20 mA is unipolar, so the integer range 0–27648 is correct. Bipolar would expose the negative half of the ADC (-27648 to 27648) and is only needed for ±10 V, ±5 V, or ±20 mA ranges.
  4. Enable "Diagnostics" on the channel if you want the CPU to enter OB82 on wire-break and surface the channel status word PII bit diagnostics.
  5. Save and compile. Verify the start address. With a 6ES7 331-7KF02-0AB0 and the module placed in slot 4, the default starting input word is PIW 288 (slot 4 × 32 = 128, plus channel 0 byte offset 0; for 8-AI modules the offset is 32 bytes per slot).
Address check: Open the module's "Addresses" tab in HW Config and confirm "I Address" before any FC105 call. If a different slot is used the start address changes. PIW 288 is correct for slot 4 of a standard 6ES7 331-7KF02-0AB0 mounted after a CPU 314, but always re-verify at the module door with the door label printed by HW Config.

Two-Wire vs Four-Wire Transmitter Wiring

A flow meter is typically a 4-wire device: two wires carry the mains or 24 VDC loop power to the transmitter's internal electronics, and two separate wires carry the 4–20 mA signal back to the PLC. A 2-wire (loop-powered) transmitter instead draws its supply current from the same pair that carries the signal.

Topology Transmitter terminals SM 331 connection HW Config measurement type
4-wire (most flow meters) V+ / V− for power; I+ / I− for signal I+ → channel input, I− → Mana (common) 4DMU / 4-wire
2-wire (loop-powered) Two terminals only Channel input provides 24 V on the I+ terminal 2DMU / 2-wire

On SM 331 modules there is a measuring-range module (a small DIL-pack in a socket on the side of the analog card) that physically changes the input front-end. The label on the module door indicates which position (A, B, C, D) corresponds to which range. Mismatching the measuring-range module position with the HW Config range is the second most common cause of a "the HMI shows wrong value" complaint and the most common cause of an unexpectedly low reading — the module simply does not route the current to the right ADC channel front-end.

FC105 "SCALE" Function Block

FC105 converts the 16-bit integer at the input IN into a floating-point engineering value at the output OUT, using the bipolar/unipolar flag, the lower limit LO_LIM, and the upper limit HI_LIM:

OUT = [ ((IN - K1) / (K2 - K1)) * (HI_LIM - LO_LIM) ] + LO_LIM

Where K1 and K2 are the integer limits for the selected range:

BIPOLAR = FALSE (unipolar) K1 K2
0 – 20 mA or 0 – 10 V 0 27648
4 – 20 mA or 1 – 5 V 0 27648
BIPOLAR = TRUE (bipolar) K1 K2
±20 mA or ±10 V -27648 +27648
±5 V -27648 +27648

The call interface in STEP 7 STL or LAD:

// STL
  CALL  FC105
       IN    := PIW288              // 16-bit raw input word
       HI_LIM:= 9.000000e+00        // Engineering full scale (m3/hr)
       LO_LIM:= 0.000000e+00        // Engineering zero (m3/hr)
       BIPOLAR:= FALSE              // 4-20 mA is unipolar
       RET_VAL:= MW200              // Error return code (0 = no error)
       OUT   := MD204               // Scaled REAL flow value (m3/hr)
// LAD (FBD equivalent)
|   IN    :  PIW288        
|   HI_LIM:  9.0          
|   LO_LIM:  0.0          
|   BIPOLAR: FALSE        
|   RET_VAL: MW200        
|   OUT   :  MD204 = "Flow_ProcessValue"  

RET_VAL returns a negative integer on error. The most common values are -32500 through -32504 for invalid parameter combinations, and 0 for a healthy conversion. Connect RET_VAL to a status word and display the value on the HMI alarm page to give maintenance visibility into a bad FC105 call.

Alternative: FC106 "UNSCALE" for Output (4–20 mA Command)

If the same flow value is also sent out as a 4–20 mA control signal (e.g., to a positioner or chart recorder), use FC106 "UNSCALE" with the same LO_LIM/HI_LIM and the same unipolar flag. FC106 performs the inverse operation: OUT = [(IN - LO_LIM)/(HI_LIM - LO_LIM)] × (K2 - K1) + K1. If you change FC105 limits, change FC106 limits in the same download to keep the loop coherent.

Step-by-Step Commissioning Procedure

  1. Document loop name and range. Confirm the tag number, the flow meter's calibrated range (0–9 m³/hr), and the input channel number on the SM 331. Update the loop drawing, the HMI tag list, and the cause-and-effect matrix.
  2. Verify the wire-break / open-circuit indication. With the transmitter disconnected, the channel value should read either 0 (range 4–20 mA, open circuit < 3.6 mA) or the diagnostic under-range value. In OB82, confirm the channel's diagnostic bit is set in the relevant SFC59 / SFC51 status read.
  3. Apply a 4.000 mA reference from a calibrator. In the online → Monitor/Modify window of PIW 288, confirm PIW 288 reads 0 dec (±2 dec). If it reads > 20 dec, the channel is set to 0–20 mA; fix in HW Config.
  4. Apply a 12.000 mA reference. PIW 288 should read 13824 ± 4 dec. If it reads 9216 dec, the channel is set to 0–10 V or 0–20 mA, again HW Config is wrong.
  5. Apply a 20.000 mA reference. PIW 288 should read 27648 ± 4 dec.
  6. Connect the live transmitter and read the FC105 output. With flow stopped (transmitter should hold 4 mA, PIW 288 = 0), FC105 output (MD204) should be 0.0. If it is non-zero with no flow, the transmitter may be biased or the loop has a voltage drop that is being compensated. A small bias (e.g., 0.02 m³/hr) at zero is acceptable if the meter's datasheet documents a turndown or zero offset.
  7. Drive a known flow. Open a manual valve to a setpoint and compare FC105 output to a portable clamp-on ultrasonic flow meter. The two should agree within 2 % of the full scale. If not, the meter's K-factor, totaliser, or zero trim is wrong; that is a transmitter problem, not a PLC problem.
  8. Verify HMI display. The HMI tag connected to MD204 should refresh in engineering units. If the HMI shows a scaled-down value (e.g., 0.018 m³/hr instead of 1.8 m³/hr) it is almost always a decimal-point configuration in the HMI tag editor, not a PLC scaling issue.

Verification Matrix

Test point Apply Expected PIW 288 (dec) Expected MD204 (REAL) Pass criteria
Live zero 4.000 mA from calibrator 0 0.0 PIW within ±2 of 0; MD = 0.0 ± 0.01
Mid scale 12.000 mA from calibrator 13824 4.5 PIW within ±4 of 13824; MD = 4.5 ± 0.02
Full scale 20.000 mA from calibrator 27648 9.0 PIW within ±4 of 27648; MD = 9.0 ± 0.02
Under-range 3.500 mA -1 (0x8001) FC105 limits to 0.0; OB82 fires if diagnostics enabled CPU enters OB82, PII bit set, alarm logged
Over-range 22.000 mA 32767 Clamped at 9.0; OB82 fires if diagnostics enabled Over-range alarm raised
Wire-break Loop open, 0 mA -1 0.0; OB82 with wire-break bit HMI shows 0.0 with wire-break alarm icon

Troubleshooting Common Defects

Symptom on HMI Likely cause Diagnostic step Fix
Always 0 m³/hr, no alarms Loop open; transmitter not powered Measure 24 VDC at transmitter terminals; measure loop current with clamp meter Repair field wiring; verify transmitter supply fuse
Always 9 m³/hr PIW address wrong; channel wired to a different terminal Disconnect signal; if PIW still 27648 the wire is on the wrong terminal or the channel is seeing 24 V Move wire to correct channel; check for voltage on the signal pair
Reads 1/5 of actual Channel set to 0–20 mA in HW Config Apply 4 mA; PIW reads ~5529 instead of 0 Reconfigure channel to 4–20 mA in HW Config and re-download
Reads 1/10 of actual Channel set to 0–10 V in HW Config Apply 4 mA into 500 Ω shunt: should read 2 V, not 0.4 V Change to 4–20 mA range; or add shunt if voltage output exists
Reads negative at zero BIPOLAR = TRUE in FC105 Online monitor FC105: BIPOLAR = TRUE Change FC105 input BIPOLAR to FALSE
Reads correct at zero, wrong span HI_LIM and LO_LIM swapped, or wrong scale on HMI Apply 20 mA; HMI should show full scale, not zero Correct FC105 HI_LIM/LO_LIM or HMI tag decimal scaling
Reads jumps wildly, then settles Electrical noise on long cable run Check for VFDs nearby, check shield grounding Use shielded twisted pair, ground shield at PLC end only, separate from 400 V power in its own conduit
Reads -32768 Channel fault or open input Module diagnostic LEDs lit, OB82 firing Check wiring, check that measuring-range module position matches HW Config
Measuring-range module reminder: The small 4-position DIL pack on the side of the SM 331 sets the hardware input type (voltage/current, 2-wire/4-wire, range). If the physical position does not match the setting in HW Config, the ADC will be expecting a different signal and your readings will be wrong by a factor of 2, 4, or 5 — or the input will be pegged at zero. Always re-seat the module and verify the door-label printout after a hardware change.

Cross-Reference to Other Siemens Platforms

The same scaling approach works on:

  • S7-200 / SMART 200: Use library routine Scale_I_to_R in the SIWAREX or the Modbus scaling library; same integer limits 0–27648 and 4–20 mA mapping.
  • S7-1200 / S7-1500: In TIA Portal, use the SCALE instruction in the "Scaling and conversion" palette or the built-in SCALE / NORM_X / SCALE_X trio. The integer range remains 0–27648 (S7-1200) or 0–27648 (S7-1500) for unipolar current.
  • ET 200SP / ET 200MP: The AI 4xI 2-/4-wire ST module (6ES7 134-6TD00-0CA1) supports 4–20 mA directly with the same 0–27648 mapping. The newer AI 4xI 2-wire (6ES7 134-6HD00-0CA1) returns 0–27648 scaled to a channel value in the user-program range and additionally supports 0–10 V, ±10 V, 0–5 V, and ±5 V.

Where the underlying flow physics can affect scaling (gas vs liquid, Reynolds-number dependence, fluid-property compensation), see the independent research on flow-pattern scaling at The scaling behavior of flow patterns. In particular, optimum sensor-feature dimensions for transitional flow patterns occur at intermediate channel sizes; the implication for a 4–20 mA scaling engineer is that the meter's published calibration curve is valid only inside the documented Reynolds-number window, and any change in fluid viscosity or temperature should be re-trimmed at the transmitter rather than compensated in the PLC.

Safety and EMC Considerations

  • Intrinsic safety (Ex): If the flow meter is in a hazardous area, use a barrier or isolator in front of the SM 331 channel (e.g., Pepperl+Fuchs KCD2-SCD-Ex1 or Phoenix Contact MACX MCR-EX-SL). The SM 331 itself is not IS-rated.
  • Shield and ground: Belden 8761 or equivalent shielded twisted pair, 24 AWG minimum, with the shield bonded to the cabinet ground bar at the PLC end only. Avoid running the signal cable in the same conduit as 400 V motor feeds or VFD output cables; maintain 200 mm separation or use a dedicated cable tray.
  • Over-voltage: On field cable runs longer than 50 m in electrically noisy plants, fit a 3-conductor gas discharge tube / TVS surge protector at the marshalling panel (e.g., DEHN BVT KKS).
  • Loop power: For 2-wire transmitters, ensure the SM 331's 24 V sensor supply can provide the transmitter's required loop current; some SM 331 variants are limited to 25 mA per channel.

FAQ

What integer does an SM 331 read at 4 mA and 20 mA on a 4–20 mA channel?

With "4–20 mA" selected in HW Config, the SM 331 returns 0 dec at 4 mA and 27648 dec at 20 mA. Values between 0 and 27648 are linearly interpolated. Under-range returns -1 dec (0x8001) and over-range returns 32767 dec (0x7FFF).

Do I need to write scaling math if I have FC105?

No. FC105 ("SCALE") takes the raw integer, the bipolar flag, and the LO_LIM/HI_LIM engineering values, and produces a REAL at OUT. Connect PIW 288 to IN, set HI_LIM=9.0 and LO_LIM=0.0 for a 0–9 m³/hr flow meter, set BIPOLAR=FALSE, and the OUT value is the engineering flow in m³/hr. Monitor RET_VAL and alarm on any non-zero negative return code.

Why is my HMI value wrong by exactly a factor of 5?

The SM 331 channel is most likely configured for 0–20 mA instead of 4–20 mA. The 4 mA live-zero then appears as 5529 dec (4/20 × 27648) and FC105 scales it to 1.8 m³/hr instead of 0. Open HW Config, change the channel to 4DMU / 4-wire / 4–20 mA, re-download, and re-verify.

Can I use FC105 with a bipolar integer even though 4–20 mA is unipolar?

It is technically possible but not recommended. With BIPOLAR=TRUE, FC105 expects a range of -27648 to +27648. At 4 mA the input is 0, so FC105 would compute (0 - (-27648))/(27648 - (-27648)) = 0.5 and scale that to 4.5 m³/hr for a true zero flow — a 50 % error at zero. Always set BIPOLAR=FALSE for live-zero 4–20 mA loops.

What is the difference between FC105 and FC106?

FC105 ("SCALE") converts a 16-bit integer to a REAL engineering value (input scaling). FC106 ("UNSCALE") converts a REAL engineering value to a 16-bit integer (output scaling) and is typically used to drive a 4–20 mA analog output. Use the same LO_LIM and HI_LIM on both, and the same bipolar flag, to keep the loop coherent.

Back to blog