Problem Summary
A SIMATIC S7-300 CPU 315-2 PN/DP (article number 6ES7315-2EH14-0AB0) is being read in TIA Portal V17 with the IEC operand syntax %DW286:P to fetch a 4-20 mA pressure signal wired to channel 0 of an SM331 AI8x12 module (6ES7331-7KF02-0AB0). The tag is permanently locked at -32768 (0x8000 hex) regardless of the current produced by a bench simulator. That single value is the universal SIMATIC S7-300 signature for "underrange / wire break / no signal" and the symptom masks three independent root causes that converge on the same failure mode:
- The
:Pslice access qualifier is an S7-1200 / S7-1500 feature and is not implemented on S7-300/S7-400 CPUs. On S7-300 the equivalent is thePIW(Peripheral Input Word) prefix. - The default process image of inputs (PII) on the S7-300 is 128 bytes. The configured slot of the SM331 begins at
IW272, which is outside the default PII, so the value the application reads is the power-on default0x8000rather than a live conversion. - The measuring range module (DIP switch) on the back of the SM331 is set to position D (RTD / resistance) while a 2-wire 4-20 mA transducer is connected. The hardware decoder therefore routes the input through the resistance front-end; any current applied is reported as underrange.
0x8000 for no apparent reason, first check the on-module SF LED, the 24 V sensor supply, the measuring range module position, and the channel configuration in HW Config before suspecting wiring. The diagnostic tree in Section 11 walks the sequence.Affected Hardware and Software
| Component | Article Number | Firmware / Version | Relevance |
|---|---|---|---|
| CPU 315-2 PN/DP | 6ES7315-2EH14-0AB0 | V3.3 (or higher) | Process image boundaries, operand syntax |
| SM331 AI8x12 (8 AI, 12-bit) | 6ES7331-7KF02-0AB0 | All firmware revisions | Measuring range module positions, channel groups |
| Front connector | 6ES7392-1AM00-0AA0 (20-pin) or 6ES7392-1BM01-0AA0 (40-pin) | — | Wiring for 2-wire 4-20 mA |
| TIA Portal | STEP 7 V17 | V17.0 + Update 3 or higher | HW Config, OB1 process image sizing |
| Transducer | Pressure sensor, 2-wire, 4-20 mA | — | Loop-powered by module's Vs+ |
What -32768 (0x8000) Actually Means on S7-300 Analog Inputs
The SM331 12-bit ADC quantises the input according to the configured range. A 4-20 mA channel has the following nominal mapping and fault states:
| Input condition | Raw word (decimal) | Raw word (hex) | Engineering meaning |
|---|---|---|---|
| I < 1.185 mA or open circuit | -32768 | 0x8000 | Underrange / wire break |
| 1.185 mA ≤ I < 4 mA | 0 | 0x0000 | Downscale (live, intentional) |
| 4 mA (lower nominal) | 0 | 0x0000 | Live, LRV |
| 20 mA (upper nominal) | 27648 | 0x6C00 | Live, URV |
| 20 mA < I ≤ 22.96 mA | 27649 – 32512 | 0x6C01 – 0x7F00 | Overrange (live) |
| I > 22.96 mA | 32767 | 0x7FFF | Overflow (live) |
A reading of 0x8000 after the module is configured and the channel is enabled is therefore always an indication that the analog front-end is not seeing a valid current, or that the module has lost its 24 V supply and the peripheral access is reading the safe-state default.
Why %DW286:P Does Not Work on S7-300
The IEC 61131-3 absolute operand %prefixDWaddress refers to the input double-word (32-bit) at the given byte offset. The trailing :P is the slice qualifier "process image direct" (also called peripheral access in TIA Portal). It tells the controller to read the input directly from the I/O backplane at the start of the current OB, instead of the value previously copied into the process image of inputs.
On S7-1200 (firmware ≥ V2.0) and S7-1500, this slice qualifier is fully supported. On S7-300 and S7-400 the corresponding functionality is exposed by a different operand prefix:
| Family | Process image access | Direct peripheral access |
|---|---|---|
| S7-1200 / S7-1500 | %IW286 |
%IW286:P (slice qualifier) |
| S7-300 / S7-400 |
IW 286 (or %IW286 in IEC view) |
PIW 286 (no :P) |
The STEP 7 compiler will reject %DW286:P on an S7-300 CPU with "Address type not supported in this CPU". If the operand slips through (for example, by being entered as a literal in a watch table or by an FB written on an S7-1500 and pasted into an S7-300 project), the read returns the power-on default 0x8000 — which is exactly the symptom reported.
:P" in the imported code. The compiler will accept the operand on the S7-1500 side and silently misbehave on the S7-300 side. Use a global find/replace that converts %DWn:P → PIDn, %IWn:P → PIWn, etc.Process Image Architecture on the S7-300
The S7-300 copies peripheral inputs into a 128-byte (default) RAM area at the start of OB1. The CPU then executes the application using the "PII" snapshot. Outputs are written back to the PIO at the end of OB1. The mechanism is designed to give the application a deterministic view of inputs and to bound OB execution time by avoiding backplane accesses inside the cycle.
Key boundaries for the CPU 315-2 PN/DP:
| Process image size (input) | Highest input word reachable in PII | Highest input byte |
|---|---|---|
| 128 bytes (default) | IW 126 |
IB 127 |
| 256 bytes | IW 254 |
IB 255 |
| 512 bytes | IW 510 |
IB 511 |
| 1024 bytes (max for 6ES7315-2EH14) | IW 1022 |
IB 1023 |
Peripheral input words above the configured PII size can only be read with the PIW prefix; the IEC %IW view does not exist beyond the configured boundary. If the SM331 is configured at IW272 with the default 128-byte PII, the value IW272 from the process image is stuck at the power-on default 0x8000, and PIW272 returns the live conversion.
Primary Fix — Replace %DW286:P with PIW 286
The simplest, lowest-risk change is to read the peripheral input word directly. PIW 286 returns the live conversion regardless of PII size and works on every S7-300/400 CPU ever shipped.
STL (classic STEP 7)
// Pressure input on SM331 at slot 3, channel 0, address 286
L PIW 286 // Direct peripheral input word (live)
T MW 100 // Copy to flag word for further use
NOP 0
SCL (TIA Portal V17)
// Read live peripheral input word and convert to INT
iRawPressure := WORD_TO_INT("PIW_286");
// Detect underflow / wire break
IF iRawPressure = -32768 THEN // 0x8000
bWireBreak := TRUE;
rPressure := 0.0;
ELSIF iRawPressure = 32767 THEN // 0x7FFF
bOverflow := TRUE;
rPressure := 0.0;
ELSE
bWireBreak := FALSE;
bOverflow := FALSE;
END_IF;
LAD
The equivalent LAD implementation is a single move box: MOVE PIW286 → MW100. Combine it with a comparator for the value 0x8000 in a separate network if you need a wire-break flag.
PIW and not PEW? Siemens has used both prefixes in its German and English manuals (PEW = "Peripherie-Eingangswort"). The English-language help in TIA Portal V17 normalises the operand to PIW; PEW is accepted as a synonym but is not auto-completed in the editor.Secondary Fix — Extend the Process Image of Inputs
If the project architecture requires process-image reads (e.g. to feed OB1 consistent bits or for alarm generation), extend the PII in TIA Portal V17 so it covers the SM331 slot:
- In the project tree, open Devices & networks and double-click the CPU icon (6ES7315-2EH14-0AB0).
- Select the Properties tab, then Cycle / clock memory.
- Under Process image increase "Size of process image of inputs" to a value strictly greater than the highest IW byte used. For
IW272(byte 543) set the size to 1024 bytes (the maximum supported by the 6ES7315-2EH14). - Download the HW configuration. TIA Portal V17 will request a STOP-to-RUN transition.
- Replace
%DW286:Pwith%IW286in every user block.
Hardware Configuration — Set the Measuring Range Module Correctly
The SM331 6ES7331-7KF02-0AB0 has four measuring range modules on the back/side of the module, one per pair of channels (group 0 = channels 0-1, group 1 = 2-3, group 2 = 4-5, group 3 = 6-7). Each module is a small 4-position DIP switch labelled A, B, C, D. The switch position is the hardware decoder for the analog front-end — it must match the type of sensor wired to the channel pair, regardless of what the TIA Portal software says.
| Position | Front-end function | Typical use |
|---|---|---|
| A | Voltage (all ranges: ±80 mV to ±10 V, 0-10 V, 1-5 V) | Voltmeter, ±10 V signal, 0-10 V signal |
| B | Current, 4-wire (0-20 mA, 4-20 mA, ±20 mA) | 4-wire transmitter with external 24 V loop supply |
| C | Current, 2-wire (4-20 mA) | 2-wire loop-powered transmitter fed by the module's Vs+ |
| D | Resistance / RTD (PT100, PT1000, NI100, 0-600 Ω) | RTD probe, resistance measurement |
For a 2-wire 4-20 mA pressure transducer, the measuring range module for the channel pair must be set to C. Always re-verify the position with the module unplugged; the white plastic cam on the side of the front connector also serves as the switch lever.
Wiring a 2-Wire 4-20 mA Transducer to SM331 6ES7331-7KF02-0AB0
For a 2-wire transmitter the module supplies the 24 V loop voltage through the same terminals that read the current. On the 6ES7331-7KF02-0AB0, with a 40-pin front connector, channel 0 is wired as follows:
| Terminal | Signal | Connection |
|---|---|---|
| 1 | M0− (Ch0−) | Transmitter signal− (the same conductor is also the return of the 24 V loop) |
| 2 | M0+ (Ch0+) | Transmitter signal+ (24 V loop is fed through this terminal by the module's internal Vs+ jumper) |
| 35 / 36 / 37 / 38 | Vs+ (24 V sensor supply, internally jumpered to Ch0+ for the "C" position) | Not wired externally — the module bridges Vs+ to the channel |
| 39 | L+ (module 24 V supply) | 24 V DC from the backplane / power supply |
| 40 | M (24 V supply return) | Ground |
If you are using a 20-pin front connector, the terminal numbers for the 2-wire wiring differ (refer to the SM331 manual for your specific pinout). The principle is the same: Ch+ provides the loop supply, Ch− returns the current.
TIA Portal V17 Channel Configuration
Software configuration must agree with the hardware. For the 6ES7331-7KF02-0AB0, channel 0 must be set to current, 4-20 mA, single-ended, with diagnostic interrupts enabled if you want wire-break indication in the diagnostic buffer.
- In Devices & networks, double-click the SM331 icon in the rack.
- Switch to the Properties > Inputs tab.
- Select Channel 0 in the channel overview. Tick "Enable channel".
- Set Measurement type = Current.
- Set Current range = 4..20 mA.
- Under Diagnostics, enable Wire break. The module will then set the diagnostic interrupt when the current drops below 1.185 mA, and the SF LED lights up.
- Under Trigger, set the interrupt priority high enough that it pre-empts OB1 but does not steal from your fast OB (e.g. priority 16).
- Compile and download the HW Config.
If the software is set to "Voltage" while the switch is on "C", the module is internally consistent (it does not validate the switch), but the analog front-end will source / sink current through a 1 MΩ voltage divider and produce a meaningless value. The hardware switch is always the ground truth.
Hardware Diagnostics — LED and 24 V Supply Check
The SM331 6ES7331-7KF02-0AB0 has three LEDs per module: SF (group error), BF (bus fault on the backplane, only on the Profibus variant), and the channel-specific indicators integrated into the front connector. A red SF LED is the most important early indicator of misconfiguration:
| LED | State | Meaning | Action |
|---|---|---|---|
| SF | off | No diagnostic | Continue; check other causes |
| SF | red, slow flash | Configuration error (DIP / SW mismatch) | Compare measuring range module with HW Config |
| SF | red, fast flash | Wire break / overrange on at least one channel | Check Vs+ supply, sensor wiring |
| SF | red, on steady | Module fault (internal diagnostics) | Power-cycle the rack, replace module |
| 24 V module power | off | No L+ at terminal 39 | Re-verify the backplane 24 V rail |
Always measure the 24 V at terminal 39/40 of the front connector with the connector unplugged from the module. A floating ground (L+ present, M open) will let the green LEDs flicker as the module re-boots every 100 ms.
Scaling 4-20 mA to Engineering Units
The raw integer must be linearised to engineering units (e.g. bar, °C, %) before it is useful. The S7-300 in TIA Portal V17 supports the SCL 1.0 instructions NORM_X and SCALE_X from the standard library; for classic STEP 7 use the legacy blocks FC105 (FC_SCALE) and FC106 (FC_UNSCALE).
Using NORM_X / SCALE_X in SCL
FUNCTION "FC_PressureScaling" : Real
VAR_INPUT
iRawWord : INT; // 0..27648 for 4..20 mA
rMinEng : REAL; // 0.0 bar at 4 mA
rMaxEng : REAL; // 10.0 bar at 20 mA
END_VAR
VAR
rNorm : REAL;
END_VAR
BEGIN
IF iRawWord = 16#8000 OR iRawWord = 16#7FFF THEN
// Underflow / overflow -> return safe value
"FC_PressureScaling" := 0.0;
RETURN;
END_IF;
rNorm := NORM_X(MIN := 0.0,
VALUE := INT_TO_REAL(iRawWord),
MAX := 27648.0);
"FC_PressureScaling" := SCALE_X(MIN := rMinEng,
VALUE := rNorm,
MAX := rMaxEng);
END_FUNCTION
Using FC105 in classic STL
// FC105 inputs:
// IN -> PIW286 (INT)
// HI_LIM -> 10.0 (REAL, engineering max)
// LO_LIM -> 0.0 (REAL, engineering min)
// BIPOLAR -> FALSE (0 = unipolar, 1 = bipolar)
// FC105 output:
// OUT -> MD100 (REAL, engineering value)
CALL FC105
IN := PIW286
HI_LIM := 1.000000e+001
LO_LIM := 0.000000e+000
BIPOLAR:= FALSE
RET_VAL:= MW200
OUT := MD100
NOP 0
For 4-20 mA the engineering range and the raw range are always 0 to 27648, and the slope is positive. If the sensor is reverse-acting (20 mA = 0 bar) swap HI_LIM and LO_LIM and let FC105 handle the inversion automatically.
Troubleshooting Matrix
| Symptom | Most likely cause | Check | Fix |
|---|---|---|---|
| 0x8000, SF LED off, switch in D | Wrong measuring range module | Set to C for 2-wire 4-20 mA | Move DIP switch to C |
| 0x8000, SF LED slow flash | SW / DIP mismatch | Compare HW Config with switch | Re-align switch and SW |
| 0x8000, SF LED fast flash | Wire break / no Vs+ | Measure 24 V at terminal 39/40 | Repair 24 V supply |
| 0x8000, no SF LED, 24 V OK, switch OK | Process image out-of-range + wrong operand | Check PII size, use PIW286 | Use PIW286 or extend PII |
| 0x0000, 4 mA applied | Downscale (live) | Normal for 4 mA | No action |
| 0x6C00, 12 mA applied | Live, mid-scale | Verify scaling | No action |
| 0x7FFF, > 22.96 mA applied | Overflow (live) | Check transducer range | Replace transducer or attenuate |
| Value stuck at 0, switch in A | Voltage mode but loop-powered transmitter | Move switch to C | Move switch to C |
| Value is half-scale regardless of input | Group mix-up (CH0/CH1 share a switch) | Check channel pair wiring | Move transmitter to the correct terminal |
Verification and Commissioning Steps
- Open TIA Portal V17, connect to the CPU 315-2 PN/DP, and go online.
- In the project tree, open Watch and force tables and add a new table. Insert
"PIW_286"(the symbolic name of the peripheral input word — TIA auto-creates the symbol for the configured slot). - Apply 4 mA with the bench simulator. The watch table should show
0and the SF LED should be off (no underrange, live downscale). - Apply 12 mA. The watch table should show
13824(50 % of 27648). The SF LED should be off. - Apply 20 mA. The watch table should show
27648. The SF LED should be off. - Reduce the current to 0 mA (open the loop). The watch table should show
-32768(0x8000) and the SF LED should start fast-flashing if the diagnostic interrupt is enabled. - In Online & diagnostics > Diagnostic buffer, confirm the events are recorded as expected.
- Force the raw word in the watch table, then call your scaling FC. Verify the engineering value matches.
PIW286 writes a forced value into the input; the I/O module still sees the physical signal, so once you remove the force the live value returns.Related Edge Cases
Process image size and the OB update rules
On the S7-300, the process image is refreshed automatically by OB1 (and the configured update OBs, if any). If you read PIW286 from inside OB1, you read the live value. If you read it from an OB that is not on the update list (e.g. OB40 hardware interrupt), the process image of inputs is also updated automatically by the S7-300 firmware when the OB is called, so PIW286 is safe. Avoid reading PIW286 inside cyclic OB35 if you do not need the live value — use IW286 and rely on the OB1 update to keep the value consistent.
4-wire transmitter on the same module
If you later add a 4-wire transmitter to a free channel group, set the DIP switch to position B, supply the transmitter with 24 V from a separate rail, and configure the channel in TIA Portal as "Current 4-wire 4..20 mA". Mixing 2-wire and 4-wire transmitters on the same channel pair is impossible because the pair shares one DIP switch.
Module diagnostic in the diagnostic buffer
With the wire-break diagnostic enabled, an open circuit on channel 0 generates event W#16#5301 in the diagnostic buffer. The application can read the diagnostic data via SFC 51 ("RDSYSST") with index 0x00B1 / 0x0131. See the S7-300 system manual, chapter "Diagnostics of the SM331".
Cross-platform portability
If you later port the program to an S7-1500, the PIW prefix is no longer needed; the %IW286:P slice qualifier is the modern equivalent. The peripheral address space is also larger, so the slot can be moved closer to the start of the process image automatically.
Frequently Asked Questions
Why does %DW286:P compile on my S7-1500 project but not on the S7-300?
The :P slice qualifier is part of the S7-1200/1500 absolute address model only. On S7-300/400, the compiler reports "Address type not supported on this CPU". Replace %DW286:P with PID 286 (or PIW 286 if you only need the 16-bit word) to get a direct peripheral read.
My SM331 input is always -32768 even though I can see the 24 V at the front connector — what is wrong?
Check the measuring range module (DIP switch) on the side of the front connector. For a 2-wire 4-20 mA transmitter the switch must be on position C. Position D (resistance / RTD) presents the loop current as an open circuit, producing the 0x8000 underflow value without illuminating the SF LED.
What is the maximum process image of inputs for a 6ES7315-2EH14-0AB0?
The CPU supports up to 1024 input bytes and 1024 output bytes, configured in the CPU properties under Cycle / clock memory > Process image. Anything beyond that must be read with the PIW prefix.
Can I read PIW286 from any OB?
Yes. The S7-300 refreshes the process image at the start of OB1 and at the start of any OB listed in the update list (typically OB40 and OB82). Reading PIW286 always returns the live value, regardless of the OB context, so it is safe inside any OB, including high-priority hardware interrupts.
Is FC105 (SCALE) still supported in TIA Portal V17 on the S7-300?
Yes, but only inside classic blocks compiled with STEP 7 V5.x semantics. In SCL for S7-300 in TIA V17 use the modern NORM_X and SCALE_X instructions. Both produce the same linear result; SCALE_X handles bipolar mode and overflow reporting natively.