Problem Overview
A field engineer reports the following symptom on a Siemens S7-1200 CPU programmed with TIA Portal:
- Digital input
%I0.4(label "prise de force") is wired to a permanent 24 V signal and is verified HIGH by both the physical LED indicator and 99 % of the program logic. - In one specific network, monitoring the bit online shows
%I0.4 = 0, breaking the rung. - Inserting a memory bit (memento, e.g.
%M10.0) assigned to%I0.4in a previous network and using the flag instead of the input in the failing network restores correct behavior. - All High-Speed Counters (HSC) on the CPU are confirmed disabled.
This article walks through the engineering diagnostic path, the actual root-cause families, the diagnostic steps to prove them, and a robust software pattern that prevents recurrence.
Why a Single Network Can Read I0.4 as 0
The S7-1200 stores digital inputs in two distinct areas that the user program can address:
| Operand | Area | Update | Typical Use |
|---|---|---|---|
%Ix.y |
Process image input (PII) | Refreshed once per OB1 cycle at start of scan | Standard bit logic, contacts, comparisons |
%Ix.y:P |
Periphery (immediate I/O) | Direct read of physical input at the moment the instruction executes | HSC, time-critical captures, interrupt OBs |
The vast majority of user code reads %I0.4 from the PII. If the bit consistently reads 1 in those networks and only fails in one, the failure is not caused by a dead field wire, a missing 24 V supply, or a CPU hardware defect (those would corrupt the PII globally and the LED would also be off). The failure is one of the following four classes:
- Conditional overwrite of the process image in the same scan (very rare, only via explicit SFC/POKE instructions).
- HSC or PTO/PWM assignment of the input — when a function sub-module "owns" the terminal, certain TIA configurations can change the value the CPU writes back into the PII or the way the input is read.
- Input filter time-out / hardware interrupt mis-configuration at the input channel — a configured rising-edge hardware interrupt can consume the signal in the cycle it occurs.
-
Edge / one-shot timing artefact — the network in question evaluates on a one-cycle pulse that has just been consumed by another rung (e.g.
NEG/POSedge bit cleared by previous logic).
Step 1 — Verify the Failing Network Online
Open the affected FC/FB in TIA Portal, right-click the title bar and select Monitor On/Off. With the PLC in RUN, both %I0.4 and the surrounding tags must be visible at the same time. To compare the input against a memory copy side by side:
- Insert a parallel contact
%M10.0next to%I0.4in the failing network. - In a new network above, write:
%M10.0 := %I0.4;(FBD) or equivalent ladder rung with a simple--| |--( )--coil: A%I0.4, coil%M10.0. - Compile, download, go online, and observe both bits simultaneously for at least 60 seconds.
If the M bit is always 1 but the I bit momentarily shows 0, the input is being overwritten or read out of the PII at a different time than the M bit. If both go to 0, the issue is upstream (wiring, sensor, filter, or power supply).
Step 2 — Count the Number of 1→0 Transitions
Add a one-shot edge detector and a counter so you can quantify how often %I0.4 falls:
// FBD network - count falling edges of I0.4
%I0.4 %M20.0 %MW100
--+--|/|-----(P)-----------(ADD 1)-----------(==)--
| (NEG edge) (target=%MW100)
|
+--[ %MW100 < 32767 ]
Run for an hour. Three outcomes:
- Counter increments every scan → the input is genuinely toggling or being overwritten every cycle. Investigate the channel assignment, HSC, or PTO/PWM.
-
Counter increments only on power-up / STOP-RUN → the input was never reliably 1 at the moment the PII was sampled during the first scan. Add a power-on delay using
%S_BSY/ first-cycle flag. - Counter never increments → the input is always 1; the failing network has a logic error (NOT contact, edge bit consumed elsewhere, or operand typo).
Step 3 — Check Hardware Configuration of the Input
In the project tree, open Devices & Networks → [CPU] → Properties → Digital inputs → Channel 4 and verify the following parameters:
| Parameter | Recommended Value | Comment |
|---|---|---|
| Used as | DI (digital input) | Not HSC, not PTO, not motion input |
| Input filter | 0.1 ms to 1.0 ms | A 6.4 ms or 12.8 ms filter is fine for push-buttons but masks short pulses; 0.1 ms catches 1 kHz signals |
| Hardware interrupt (rising / falling) | Disabled (unless needed) | An enabled rising-edge interrupt can latch the bit for the OB and clear it before OB1 reads it, depending on priority |
| Input inversion | Disabled | Would flip logic in the PII without changing the LED state |
Default filter for a 1212C/1214C/1215C digital input is typically 6.4 ms. If the field signal is a relay contact bouncing shorter than that window, the PII will read 0 between bounces. This is the single most common cause of "the LED is on but the bit is off."
Step 4 — Disable All HSC and Motion Functions
The S7-1200 shares terminals between standard digital inputs, HSC, PTO, PWM, and motion control. The CPU firmware rev 4.x and higher allows several of these to coexist, but firmware rev 2.x is stricter. Verify:
- Open Device Configuration → CPU → Properties → Pulse generators (PTO/PWM): ensure the channel used by I0.4 is not assigned.
- Open High-Speed Counters (HSC): confirm none of HSC1..HSC6 reference the input. Even when "disabled" in user code, a configured channel in the device view can still claim the terminal.
- If you find an accidental assignment, unbind the channel, recompile, and re-download hardware configuration (not just the program block).
Step 5 — Use the Force Table to Validate the PII Path
The Force Table is a privileged tool — it overrides the PII from the field and is the only way to write to a physical input from TIA Portal.
- Open Project tree → [CPU] → Watch and force tables → Force table.
- Add row:
%I0.4→ Force value1. - Click Start force (the icon shows a padlock with a play symbol).
- Go online and check the failing network. If the bit now reads 1 inside the network, the issue is the physical input path; if it still reads 0, the issue is downstream of the PII read (i.e. the network is overwriting or masking the bit).
Step 6 — Use a Watch Table to Toggle a Memory Bit
Watch tables are non-privileged. They let you change %M bits but not %I bits:
- Open Watch and force tables → Watch table_1.
- Add row:
%M10.0with "Modify value" = 1. - Click Modify (or Modify with trigger for scan-controlled writes).
This is the technique to test the rest of the logic independently from the input. If toggling %M10.0 drives the downstream actuator correctly, the failing network is logically sound and the original problem lies in the input path. If it still does not work, the failing network has its own bug (operand typo, wrong edge bit, hidden network above clearing a tag).
The Memory-Bit Workaround Explained
The field engineer's fix is to introduce a buffer flag:
// Network 1 - buffer the input
%I0.4
--+--| |-----------( %M10.0 )-- // "memento" / memory bit
// Network N (failing) - use the flag instead
%M10.0
--+--| |-----------( %Q0.0 )-- // works reliably
Why this works even when the original symptom persists:
-
Decoupling of read timing.
%M10.0is written in the same scan and at the same PII refresh moment as every other input bit. If%I0.4is being corrupted by an interrupt OB that runs between the PII write and the user-code read of the failing network, theMbit is read after that interrupt completes, so it reflects the corrected value. -
Decoupling of edge consumption. If a previous network uses a rising-edge
(P)on%I0.4, the PII bit still shows 1 in the same scan (the edge marker is internal), but the user often mis-reads the edge flag and confuses it with the input state. Buffering removes the edge from the equation. -
Decoupling of group faults. On a 1215C, certain digital-input groups share a common ground. A high-impedance source can let the PII read a residual 0 only on the very first scan after STOP-RUN. A memory bit initialized with the first-cycle flag (
%S0.1via SFL/SFR) eliminates the artefact.
This pattern is also a best practice for signal conditioning: debounce, filter, and capture every field input once at the start of OB1, then use the conditioned flag everywhere else.
Alternative: Read the Periphery Directly
If the issue is proven to be in the PII itself, you can bypass the PII for that single input:
// Ladder - read periphery directly (immediate I/O access)
%I0.4:P %M10.0
--+--| |-------------( )-- // direct read at the moment of evaluation
The :P suffix forces the CPU to read the physical input on the same OB1 instruction, eliminating the PII from the equation. Use this only as a diagnostic step; the long-term fix should be a debounce/buffer network as in the previous section.
%Ix.y:P in a tight loop is slower than the PII because every read performs a backplane access. Use it on diagnostic or safety-relevant signals only.First-Cycle and Warm-Restart Considerations
On STOP→RUN, the S7-1200 default initializes all bit memories to 0 but leaves the PII at its last value. If your failing network uses %M10.0 directly, it will be 0 on the first scan, even if %I0.4 is already 1. Use a retentive tag, or initialize the flag with the first-cycle bit:
// First-cycle latch of I0.4
%S0.1 %I0.4 %M10.0
--+--| |------| |-----------(S)-- // set M10.0 on first cycle if I0.4 is high
Mark %M10.0 as retentive in the PLC tag table (column "Retain") so the value survives a power cycle if required by the process.
Diagnostic Checklist
| # | Check | How | Pass criterion |
|---|---|---|---|
| 1 | Field wiring is 24 V and stable | Multimeter at the CPU terminal | 23.0 V ≤ V ≤ 28.8 V DC |
| 2 | Input LED matches PII | Watch table on %I0.4
|
LED on ↔ bit = 1 |
| 3 | HSC/PTO not bound to channel | Device view → DI4 → "Used as" | "DI" (no function) |
| 4 | Input filter compatible with pulse width | Channel properties → filter | Filter ≤ 1/10 of shortest pulse |
| 5 | No hardware interrupt on the channel | Channel properties → interrupt | Both "None" or intentionally set |
| 6 | No edge bit consumed upstream | Cross-reference %I0.4
|
Only one (P)/(N) consumer |
| 7 | First-scan behaviour OK | Toggle STOP/RUN, observe bit | Bit stabilises within 1 scan after power-up |
| 8 | Force table writes are not active | Force table → all forces off | No red "F" icons in project tree |
Best-Pattern Reference: Input Conditioning Block
Wrap every field input in a small FC that returns a debounced, buffered flag. The pattern below is reusable across the program and removes the symptom class entirely:
FUNCTION_BLOCK FB_InputCondition
VAR_INPUT
iRaw : BOOL; // physical input %Ix.y
iFilter_ms : UINT; // debounce time, e.g. 10
iFirstScan : BOOL; // connect to %S0.1 in OB1
END_VAR
VAR_OUTPUT
qStable : BOOL; // debounced flag
qRising : BOOL; // one-cycle rising edge of qStable
END_VAR
VAR
tStart : TIME; // IEC timer start timestamp
tElapsed : TIME;
END_VAR
BEGIN
// Initialise on first scan
IF iFirstScan THEN
qStable := iRaw;
tStart := T#0ms;
END_IF;
// Restart the timer whenever the raw input changes
IF iRaw <> qStable THEN
tStart := TIME(); // system time
END_IF;
// Commit the new value only after filter has elapsed
tElapsed := TIME() - tStart;
IF tElapsed >= INT_TO_TIME(iFilter_ms) THEN
qRising := iRaw AND NOT qStable;
qStable := iRaw;
END_IF;
END_FUNCTION_BLOCK
Call this block in OB1 with iRaw := %I0.4, route qStable to the rest of the program, and the failing network becomes both deterministic and self-documenting.
Verification Procedure
- Apply the FB or the simple
%I0.4 → %M10.0buffer in a network above the failing one. - Replace all subsequent references to
%I0.4in user logic with%M10.0. - Compile, download hardware configuration, download software, and place the CPU in RUN.
- Monitor the failing network online and confirm the bit reads 1 in every scan for 5 minutes.
- Power-cycle the CPU three times. After each cycle, the bit must read 1 within the first two scans (cold-start, warm-restart, retentive-restart).
- Disable the buffer momentarily to confirm the original symptom returns; this proves the workaround, not a coincidence.
FAQ
Why does my S7-1200 input read 0 in one network but 1 in every other?
It is almost always a PII-timing artefact: a hardware interrupt, an HSC/PTO channel claim, an edge-bit consumption, or a first-cycle lag. Use the diagnostic checklist in this article to identify which, then either change the device configuration or use a memory-bit buffer.
Is the memory-bit ("memento") workaround safe for production code?
Yes, provided the buffer is initialized with the first-cycle flag, marked retentive if required, and the upstream input is monitored with a watch table during commissioning. Buffering is a recognised signal-conditioning pattern in TIA Portal.
How do I read the physical input directly without using the process image?
Append :P to the operand: %I0.4:P. The CPU performs an immediate backplane read at the moment the instruction executes. Use this only for diagnostics or time-critical signals because it is slower than a PII read.
My HSC is "disabled" in user code, but the input still behaves strangely. Why?
HSC channels are claimed at the device-configuration level, not in the program. Open Device Configuration → CPU → High-Speed Counters, unbind the channel, recompile, and re-download the hardware configuration. A simple program-level disable does not release the terminal.
Can I force an input from a Watch table instead of the Force table?
No. Watch tables can only write to %M, %DB, outputs and process data — never to physical inputs %I. To override an input, use Watch and force tables → Force table with caution, as the force remains active across STOP-RUN transitions.
What is the default input filter on a 1212C / 1214C / 1215C?
By default, the digital-input filter is 6.4 ms on S7-1200 CPUs. For signals shorter than 6.4 ms, change the filter to 0.1 ms in the channel properties of the device configuration.
Could a missing 0 V on the input group cause this?
On a 1215C, digital inputs are grouped (typically 4 or 8 per group) and share a common ground. A loose 0 V terminal on the group can make the PII read 0 intermittently on every input of that group while the LED — powered from the same source — still shows on.