Siemens S7-300 Scaling 4-20mA to 0-2.5V with FC105 and FC106

David Krause12 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

1. Problem Overview

Many field instruments deliver a current-loop signal of 4-20 mA as the live-zero industrial standard, but some downstream devices (solenoid pilots, small valve positioners, low-energy controllers, lab instruments) accept only a narrow voltage input of 0-2.5 V DC. The challenge is that the available Siemens S7-300 analog output modules do not offer a 0-2.5 V range — they ship with 0-10 V, +/-10 V, 1-5 V, or 4-20 mA ranges only. Programming the PLC to scale the 4-20 mA reading and then command a 0-2.5 V level on a 0-10 V output stage is therefore the standard approach, but it carries an important over-voltage risk: a programming fault, an out-of-range input, or a defaulted output can drive the channel to 10 V and destroy the 2.5 V instrument.

This reference shows how to implement the scaling chain with FC105 (SCALE) and FC106 (UNSCALE) from the SIMATIC Standard Library, how to clamp the output to 2.5 V in software, and what alternative hardware (signal isolators and converters) is available when the application cannot tolerate any over-voltage exposure.

2. Prerequisites

  • Siemens SIMATIC S7-300 CPU (e.g. CPU 315-2 PN/DP, 6ES7315-2EH14-0AB0) with STEP 7 V5.5 or TIA Portal V16+
  • SM 331 analog input module configured for 4-wire current, 4-20 mA. Typical part: 6ES7331-1KF02-0AB0 (8 AI, 13-bit) or 6ES7331-7NF10-0AB0 (8 AI, 16-bit, suitable for HART)
  • SM 332 analog output module configured for 0-10 V. Typical part: 6ES7332-5HD01-0AB0 (4 AO, 12-bit) or 6ES7332-8TF01-0AB0 (8 AO, 16-bit, HART)
  • FC105 SCALE and FC106 UNSCALE from the Standard Library > TI-S7 Converting Blocks (STEP 7 V5.5) or the equivalent IEC functions SCALE_X and NORM_X in TIA Portal
  • Wiring hardware: 24 V DC supply, shielded twisted-pair cable, terminal blocks, and the 0-2.5 V instrument data sheet confirming its absolute maximum input voltage

3. Analog Signal Ranges and Normalized Integer Values

Every S7-300 analog channel returns a signed 16-bit integer. The S7 convention maps the configured range to -27648 ... +27648 for bipolar ranges and 0 ... +27648 for unipolar ranges. The relationships for the two ranges used in this application are:

Configured range Engineering low (raw) Engineering high (raw) Notes
4-20 mA input 0 (at 4 mA, live zero) 27648 (at 20 mA) Wire break / open circuit drives the value to 32767 or 0 depending on diagnostics configuration
0-10 V output 0 (at 0 V) 27648 (at 10 V) Default bipolar default of +/-10 V must be reconfigured to 0-10 V in HW Config or device configuration
0-2.5 V target (instr.) 0 (at 0 V) 6912 (at 2.5 V) Calculated as 27648 * (2.5 / 10) = 6912.0
Live-zero principle: 4 mA is not zero. A reading of 0 raw units therefore means either a true 4 mA signal OR a wire break on an AI channel configured for 4-20 mA with diagnostics enabled. Treat a value below 0 as a fault condition, not a valid measurement.

4. Configuring the Analog Modules in HW Config

  1. Open SIMATIC Manager > HW Config (STEP 7) or Device Configuration (TIA Portal).
  2. Insert the SM 331 in the slot next to the CPU. Double-click the module and set Measuring range = 4DMU (4-wire transmitter, 4-20 mA) for each used channel. Enable Diagnostics if wire-break detection is required.
  3. Insert the SM 332 and set Output type = Voltage, Output range = 0..10 V for each used channel. Disable current output mode.
  4. Compile and download the hardware configuration. The new ranges are only active after a STOP -> RUN transition on the CPU.

5. FC105 SCALE - Reading the 4-20 mA Input

FC105 converts a raw integer into a floating-point engineering value using a linear interpolation between a low and high physical limit.

5.1 Function Interface

Parameter Declaration Type Description
IN INPUT INT Raw value from PIW xxx (0..27648)
HI_LIM INPUT REAL Engineering value at raw = 27648
LO_LIM INPUT REAL Engineering value at raw = 0 (corresponds to 4 mA)
BIPOLAR INPUT BOOL FALSE for unipolar 0..27648
RET_VAL OUTPUT WORD FC error code (W#16#0000 = OK)
OUT OUTPUT REAL Scaled engineering value (REAL)

5.2 FC105 Call Example (STL / LAD)

// STL
CALL  FC   105
     IN     := IW    288        // SM331 channel 0, 4-20 mA
     HI_LIM := 100.0            // Process full scale, e.g. 100.0 % or 100.0 degC
     LO_LIM := 0.0              // Process zero, corresponds to 4 mA
     BIPOLAR:= FALSE
     RET_VAL:= MW    100        // FC105 status word
     OUT    := MD    104        // Engineering value as REAL

When the loop current is 4 mA, OUT = 0.0. When the loop current is 20 mA, OUT = 100.0. Values between are linearly interpolated.

6. FC106 UNSCALE - Driving the 0-10 V Output

FC106 is the inverse of FC105. It takes an engineering REAL value and converts it back into the raw integer (0..27648) that the analog output channel expects.

6.1 Function Interface

Parameter Declaration Type Description
IN INPUT REAL Engineering value to write to the output
HI_LIM INPUT REAL Engineering value for raw = 27648 (10 V)
LO_LIM INPUT REAL Engineering value for raw = 0 (0 V)
BIPOLAR INPUT BOOL FALSE for unipolar
RET_VAL OUTPUT WORD FC error code
OUT OUTPUT INT Raw value 0..27648 to load into PQW yyy

6.2 FC106 Call Example

// STL
CALL  FC   106
     IN     := MD    120        // Desired engineering value (e.g. 0..100.0)
     HI_LIM := 100.0
     LO_LIM := 0.0
     BIPOLAR:= FALSE
     RET_VAL:= MW    124
     OUT    := MW    126        // Move to PQW 288 in OB1

7. The Two-Step Scaling: 4-20 mA to 0-2.5 V

The complete chain has two stages. The first stage converts the incoming 4-20 mA signal into a real-world engineering value (0.0 to 100.0 in the example). The second stage converts the desired 0-2.5 V output into the raw integer the SM 332 expects on a 0-10 V range.

7.1 Stage A - Read & Scale Input (FC105)

With HI_LIM = 100.0 and LO_LIM = 0.0, the FC105 output MD104 ranges from 0.0 (4 mA) to 100.0 (20 mA).

7.2 Stage B - Reinterpret Engineering Range to 0-2.5 V (FC106)

Because the physical output stage is 0-10 V, the value written to the SM 332 must be limited so that the resulting voltage never exceeds 2.5 V. Using the same 0.0-100.0 engineering scale, the FC106 limits are again 0.0 and 100.0, but the integer written to the AO is clamped in software to a maximum of 6912 (= 27648 * 0.25).

Engineering value (IN to FC106) FC106 OUT (raw) Resulting voltage on 0-10 V stage Within 0-2.5 V limit?
0.0 (4 mA) 0 0.000 V Yes
25.0 6912 2.500 V Yes (limit)
50.0 13824 5.000 V No - software clamp required
75.0 20736 7.500 V No - software clamp required
100.0 (20 mA) 27648 10.000 V No - software clamp required

8. Software Clamping - Mandatory Protection for the 2.5 V Instrument

Critical safety requirement: If FC106 is fed the full 0.0-100.0 range and the SM 332 is configured for 0-10 V, the maximum output is 10 V. The 0-2.5 V instrument will be destroyed. Clamp the FC106 OUT or the engineering value before the FC106 call.

8.1 Clamp the Engineering Value (Preferred)

// STL - Clamp the user request to 0.0 .. 25.0 so 25.0 = 2.5 V
      L     MD    104            // FC105 output 0.0..100.0
      LIMIT (                      // FC251 or manual
      )
      // or manual clamp
      L     25.0
      >R
      JC    _CLMP
      TAK
      L     0.0
      <R
      JC    _CLMP
      JU    _OK
_CLMP: L     25.0
      T     MD    120            // FC106 input (max = 25.0 -> 2.5 V)
_OK:  NOP   0

8.2 Clamp the Raw Integer After FC106

// STL - Clamp the FC106 result to 0..6912
      L     MW    126            // FC106 OUT
      L     6912
      >I
      JC    _CLMP2
      L     0
      <I
      JC    _CLMP2
      JU    _OK2
_CLMP2: L     6912
_OK2:  T     PQW  288            // Drive SM332 channel 0

Clamp the engineering value (method 8.1) when the loop also drives other actuators; clamp the raw integer (method 8.2) when only this single AO needs the limit.

9. Wire-Break and Fault Reaction

On the SM 331 configured for 4-20 mA with diagnostics enabled, a wire break sets the channel value to 0 (or 32767 for some variants). Both will read as 0 mA, i.e. as a "0 %" value through FC105, which is indistinguishable from a true 4 mA reading. To detect a real wire break:

  1. Enable Group diagnostics on the SM 331.
  2. In OB82 (diagnostic interrupt), evaluate the channel status bytes from the local data to identify the failing input.
  3. Force the FC106 input to 0.0 and raise a maintenance alarm when a wire break is active, so the operator knows the reading is invalid rather than low.

10. Hardware Alternative - Signal Isolators and Converters

When the application cannot accept any risk of an over-voltage event (e.g. explosion-proof field equipment, expensive sensors, validated process), it is better to convert the signal at the field marshalling cabinet using a dedicated signal conditioner. A 4-20 mA input / 0-2.5 V output isolator provides:

  • Galvanic isolation between the PLC and the field device (typically 1.5 kV or 2.5 kV test voltage)
  • A hard-wired 0-2.5 V output range — the PLC no longer needs to overshoot a 0-10 V stage to reach 2.5 V
  • Open-circuit and short-circuit detection on the current loop side

Examples of devices that can be sourced for this conversion include:

  • ABB CC-U range of universal signal converters — supports 0-20 mA / 4-20 mA inputs and configurable 0-2.5 V / 0-5 V / 0-10 V outputs with 2.5 V internal drop and three-way isolation. See the ABB CC-U analog signal converter datasheet (PDF) for specifications and ordering data.
  • WAGO 857-402 or similar JUMPFLEX signal conditioners with DIP-switch selectable 0-2.5 V output
  • Phoenix Contact MINI Analog Pro or MACX MCR — configurable output ranges including 0-2.5 V
  • Automation Direct signal isolators such as the 4-20 mA to 0-20 Hz frequency signal isolated converter family, with variant codes (V1-V4 etc.) used to select input and output ranges; the 0-2.5 V output code is typically V4.

When a hardware isolator is used, the PLC AO is no longer the bottleneck. The SM 332 can be reconfigured to 0-10 V (or to 4-20 mA) and the isolator handles the 0-2.5 V conversion. The FC106 chain then becomes a simple engineering-scale-to-0-10 V drive with no software clamp required.

11. Verification and Commissioning Steps

  1. Disconnect the 0-2.5 V instrument and connect a precision DMM (4-1/2 digit or better) to the AO terminals.
  2. In the STEP 7 watch table, force the FC106 input to 0.0, 12.5, and 25.0. Verify the analog output reads 0.000 V, 1.250 V, and 2.500 V respectively.
  3. Force the FC106 input to 100.0. Verify the AO reads 2.500 V and NOT 10.0 V. If it reads 10.0 V the software clamp is missing — STOP and re-check the limit code.
  4. Restore the FC106 input to follow the FC105 output (process mode). Apply a calibrated 4 mA, 12 mA, and 20 mA source to the SM 331 and confirm the corresponding AO voltages are 0.0 V, 1.25 V, and 2.5 V respectively.
  5. Pull the current loop wire from the SM 331 terminal. Confirm the diagnostic OB82 fires and that the FC106 input is forced to 0.0 (or that the system raises a maintenance alarm).
  6. Power-cycle the CPU. Confirm the FC106 output powers up to 0.0 V, not to a default mid-scale or last-value that could exceed 2.5 V on the 0-10 V stage.
  7. Only after all the above checks pass, connect the 0-2.5 V instrument and re-verify the full-scale output.

12. Common Pitfalls and Troubleshooting Matrix

Symptom Likely cause Corrective action
Output saturates at 10 V on power-up FC106 input follows the last value, hardware configured 0-10 V Initialize FC106 input to 0.0 in OB100 (warm restart) and verify the software clamp
Output reads 2.5 V at 4 mA input FC105 limits are reversed (LO_LIM = 100.0, HI_LIM = 0.0) Swap the LO_LIM and HI_LIM parameters in the FC105 call
Output reads correctly at 0 V and 2.5 V but is non-linear in between Current loop has excessive resistance or the SM 331 is configured for 0-20 mA instead of 4-20 mA Re-check the SM 331 measuring range; measure loop voltage at the transmitter terminals (should be > 11 V for a 4-20 mA loop)
RET_VAL = W#16#0008 HI_LIM = LO_LIM in FC105 or FC106 Ensure the two limit values differ by at least 0.0001
Output jitters by 1-2 LSB No integration on the AI or no smoothing on the FC105 output Add a first-order lag (e.g. FC15 or manual exponential filter) on MD104, or enable integration in the SM 331
Output oscillates when connected to the instrument Instrument input is referenced to a different ground potential than the PLC Install a signal isolator, or verify single-point grounding of the 0 V reference between the PLC and the instrument

What raw value should the SM 332 output to produce exactly 2.5 V on a 0-10 V range?

Use 6912. The relationship is OUT = 27648 x (V_out / 10). For 2.5 V: OUT = 27648 x 0.25 = 6912. Drive PQW 288 with 6912 and the SM 332 will produce 2.500 V on a calibrated channel.

Can the S7-300 SM 332 be hardware-configured directly for 0-2.5 V?

No. The 0-10 V hardware range is the lowest unipolar voltage range on the SM 332. Use 0-10 V configuration in HW Config and limit the output to 2.5 V in the PLC program, or add an external 4-20 mA / 0-2.5 V signal isolator such as the ABB CC-U.

Is FC105 still the recommended function in TIA Portal?

FC105 and FC106 are the STEP 7 V5 / SIMATIC Manager functions. In TIA Portal V16+ the equivalent IEC blocks are SCALE_X and NORM_X from the "Convert" group. The scaling math and limits are identical; only the parameter names and types differ.

How do I detect a wire break on a 4-20 mA loop?

Enable group diagnostics on the SM 331, and evaluate the diagnostic interrupt in OB82. The local data of OB82 contains the channel status. A wire break typically sets the channel value to 0 or to 7FFFh, which the FC105 will read as a "low" engineering value; combine this with the diagnostic flag to avoid interpreting it as a valid 4 mA reading.

What happens if I configure the SM 332 for 1-5 V instead of 0-10 V?

On a 1-5 V stage, raw 0 corresponds to 1 V (not 0 V) and raw 27648 still corresponds to 5 V. The relationship becomes V_out = 1 + (OUT / 27648) x 4. A clamped 2.5 V output would require OUT = 10368. For a 0-2.5 V-only instrument this is unsafe because the lowest output is 1 V, which may exceed the instrument's 0-2.5 V range on the low end. Always use 0-10 V configuration when the load must start at 0 V.

Back to blog