Understanding PIB Addressing in Siemens S7-300 and S7-400 PLCs

David Krause20 min read
S7-300SiemensTechnical Reference
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

Understanding PIB Addressing in Siemens S7-300 and S7-400 PLCs

The mnemonic PIB stands for Peripheral Input Byte, and the numeric suffix (for example, the 1 in PIB1) is the byte address assigned to a physical I/O slot in the hardware configuration. The address is not arbitrary; it is the slot offset produced by STEP 7 HWConfig for the analog or digital module that occupies the corresponding position in the rack. This article explains the address model behind the P prefix, the difference between peripheral access and image-table access, and the engineering rules for reading analog channels with PIW and the FC105 SCALE block.

Conventions used in this article: IB = Input Byte (process image), PIB = Peripheral Input Byte, IW = Input Word, PIW = Peripheral Input Word, QB = Output Byte, PQB = Peripheral Output Byte, PQW = Peripheral Output Word, MB = Bit Memory / Merker Byte.

1. The Siemens S7 Address Model: Process Image vs. Peripheral I/O

The S7-300 and S7-400 CPUs expose two distinct read paths to physical I/O:

  1. Process image (I and Q areas) — a memory mirror of the input and output modules that the CPU refreshes once per OB1 scan at a deterministic point in the cycle. The user program reads IB0, IW4, QB12, etc. The values are stable for the duration of OB1 execution and represent a snapshot of the I/O at scan start.
  2. Peripheral I/O (PI and PQ areas) — a direct, non-buffered path to the module's hardware register. Accessing PIB0 or PIW256 triggers an immediate read on the backplane bus every time the instruction is executed. There is no scan-stable buffer.

The P prefix is the mnemonic marker for the peripheral area. The full address family is summarized below.

Mnemonic Width Direction Source Update Mechanism
IB / IW / ID Byte / Word / DWord Input Process image input table (PAE) Refreshed once per scan by OB1
QB / QW / QD Byte / Word / DWord Output Process image output table (PAA) Flushed to modules once per scan
PIB / PIW / PID Byte / Word / DWord Input Peripheral input area (direct read) Immediate read on every access
PQB / PQW / PQD Byte / Word / DWord Output Peripheral output area (direct write) Immediate write on every access
MB / MW / MD Byte / Word / DWord Bit memory (Merker) CPU-internal RAM Read/write, no I/O coupling

The numeric suffix on every address is the byte offset within the chosen area. PIB1 therefore means: byte 1 of the peripheral input area. PIW256 means: word at byte offset 256, i.e. bytes 256 and 257, of the peripheral input area (words are little-endian, low byte at the lower address).

2. Why Two Address Spaces? The Engineering Rationale

The process image exists to give a deterministic, race-free view of all inputs at the moment logic decisions are made. The peripheral area exists for cases where the snapshot semantics are wrong:

  • Analog modules with slow update rates. The S7-300 analog input modules (SM331, SM332, SM334) update their conversion registers only every few milliseconds to tens of milliseconds depending on the configured integration time. Forcing the user to read PIW directly lets the application pick up the most recent conversion at the exact moment it is needed.
  • Time-critical interrupts (OB40, OB82). In hardware interrupts, the process image may not be current; peripheral access is the only way to read the true state of the line that triggered the interrupt.
  • Modules that physically sit outside the configured process image partition. By default, HWConfig assigns the lower addresses to the process image. The upper area of the address space is reserved for peripheral-only modules; accessing them with IB is impossible because no image entry exists.

3. Default Address Ranges in S7-300 and S7-400

STEP 7 HWConfig partitions the I/O address space as follows by default. These limits are configurable in the CPU properties dialog and must be verified against the actual project, but the defaults shown are the values seen in the majority of installed systems.

CPU Family Process Image Input (I) Process Image Output (Q) Peripheral Input (PI) starts at Peripheral Output (PQ) starts at
S7-300 (most CPUs, e.g. 314, 315, 317) IB 0 … IB 127 QB 0 … QB 127 PIB 128 PQB 128
S7-400 (e.g. 412, 414, 416, 417) IB 0 … IB 255 QB 0 … QB 255 PIB 256 PQB 256
S7-400H / high-end IB 0 … IB 511 QB 0 … QB 511 PIB 512 PQB 512
Field tip: Open HWConfig, double-click the CPU, and inspect the Cycle / Clock Memory tab (S7-300) or the Cycle tab (S7-400). The fields "Size of the process image input area" and "Size of the process image output area" show the actual configured boundary. Anything above that boundary is reachable only through PIx / PQx addressing.

For an S7-300 with the default 128-byte image, the first valid peripheral input byte is PIB128, and an analog module slotted in the first free slot is typically assigned PIW256, PIW258, … (word-aligned, even address). For an S7-400, the boundary is PIB256, with analog modules usually starting at PIW512.

4. The "xxx" in PIBxxx: What the Number Really Means

The numeric suffix is the logical I/O address in the STEP 7 project, not a physical slot number, not a channel number, and not a sequential counter. It is generated by HWConfig and follows these rules:

  1. STEP 7 scans the configured racks (0, 1, 2, … for S7-300; up to 18 for S7-400) in slot order, starting with slot 4 (slots 1–3 are reserved for the CPU, IM, and PS).
  2. For each module it reads the number of input and output bytes declared in the GSD or module description.
  3. It assigns addresses starting at the configured process image boundary, incrementing by the module's I/O size, and aligns words on even byte addresses.
  4. The address is written to the project as the module's "logical address." The same address is downloaded to the CPU's system data and burned into the module's diagnostic table.

Therefore, in a typical S7-300 layout with default settings:

  • Slot 4: SM321 DI32 × 24 V DC → IB 0 … IB 3 (process image)
  • Slot 5: SM321 DI32 × 24 V DC → IB 4 … IB 7 (process image)
  • Slot 6: SM331 AI8 × 12 bit → PIW 256 … PIW 270 (peripheral only, 8 channels × 2 bytes)
  • Slot 7: SM332 AO4 × 12 bit → PQW 272 … PQW 278 (peripheral only)

Channel 0 of the analog card is PIW256, channel 1 is PIW258, channel 2 is PIW260, and so on. To inspect the actual mapping in your project, right-click the module in HWConfig and select Monitor/Modify, or open the System Data blocks (SDB) in the offline project view.

5. PIB vs. IB: Update Semantics in Detail

The behavioural difference between PIB and IB is not merely a matter of address range. The two read paths execute differently inside the CPU:

Property IB (Process Image) PIB (Peripheral)
CPU cycle position of read All reads within one OB1 pass return the value loaded at scan start. Each L PIB… instruction triggers a new backplane read at the moment of execution.
Bus load Low — the I/O is read once per cycle. Higher — N reads per cycle if N instructions touch the area.
Consistency with module timing Snapshot — ignores mid-scan changes. Latest — may capture transitions that occurred during the scan.
Use in OB40 / OB82 May be stale. Mandatory for true interrupt-time state.
Read latency One scan maximum. Bus cycle latency, typically < 1 ms for local racks.
Failure mode Returns 0 (or last good value if configured) on module failure. Returns 0 and sets the BR/OV bit on a bus error.

6. Reading PIB1: A Practical Example

The forum example MOVE PIB1 to IB1 is technically legal but architecturally questionable. The correct interpretation and the recommended patterns are as follows.

6.1 Why the original example is unusual

PIB1 in the default S7-300 layout lies inside the process image area, so it refers to the same physical byte as IB1. The two read paths will return identical values during the OB1 scan; the only difference is that PIB1 performs a fresh backplane read at the moment the MOVE executes, while IB1 returns the cached value. Because the cache is refreshed at the start of OB1, the two are functionally interchangeable inside OB1 itself.

The MOVE from PIB1 to IB1 will succeed, but it will be overwritten at the next OB1 start when the CPU refreshes the image from the module. The write is therefore wasted unless the program disables the process image update (S7-400 only, see section 10).

6.2 The legitimate use case for storing PIB to a memory location

Storing a peripheral read into a merker (M), DB, or input (I) byte is justified when the program needs a frozen snapshot of a transient value, for example:

  • Capturing a peak value from an analog input that the module no longer holds in its conversion register.
  • Reading a counter or frequency value from a fast FM350 module and writing it to a DB for a recipe archive.
  • Logging a digital event within a hardware interrupt (OB40) where the process image update for the partition owning that module is not guaranteed.

6.3 Recommended STL snippet (STEP 7 v5.x)

// Read PIW 256 (analog channel 0) and store the raw value in DB100.DBD0
L     PIW 256
T     DB100.DBD 0

// Alternative with explicit byte swap if the module is bipolar and
// the high/low byte need ordering correction:
L     PIW 256
CAW                       // reverse byte order inside the accumulator
T     DB100.DBD 0

6.4 Recommended SCL snippet (STEP 7 v5.x or TIA Portal)

// SCL function block fragment
#rawValue  := WORD_TO_INT("PIW256");    // 0..27648 or +/-27648
#scaledEng := SCALE_DB.IN  := INT_TO_REAL(#rawValue);
#scaledEng := SCALE_DB.OUT;            // engineering unit output

7. Raw Analog Value Representation in S7-300 / S7-400

The S7-300 analog modules (SM331, SM332, SM334) and the S7-400 analog modules (SM431, SM432) represent each channel value as a 16-bit signed integer with a fixed full-scale range. The nominal value ranges are:

Signal Type Raw Integer Range (hex) Raw Integer Range (dec) Engineering Equivalent
Unipolar voltage 0…10 V 0x0000 … 0x6C00 0 … 27648 0 % … 100 %
Unipolar current 0…20 mA 0x0000 … 0x6C00 0 … 27648 0 % … 100 %
Unipolar current 4…20 mA 0x0000 … 0x6C00 0 … 27648 0 % … 100 %, with 4 mA = 0
Bipolar voltage ±10 V 0x9400 … 0x6C00 (0x9400 = −27648) −27648 … +27648 −100 % … +100 %
Bipolar current ±20 mA 0x9400 … 0x6C00 −27648 … +27648 −100 % … +100 %
Overflow tag 0x7FFF 32767 Over-range, fault in module or wiring
Underflow tag 0x8000 −32768 Under-range, wire break, open input
Source-clarification note: The field report mentions a raw range of "0…27468 or ±27468". The well-established Siemens value across the S7-300/400 analog module family is 27648 / ±27648; the "27468" figure in the source appears to be a transcription error and has been corrected to the documented value in the table above. Always verify against the specific module data sheet, because some specialty modules (RTD, thermocouple) use different resolutions and the S7-1500 generation has migrated to 0…27648 as well with extended ranges up to ±32511 for diagnostics.

The S7-300/400 SM331 manual also defines the integration time vs. noise rejection trade-off: a 60 Hz integration time setting yields the highest noise rejection at the cost of channel update latency (~50 ms per active channel when 8 channels are enabled). For fast loops, switch to 50 Hz (or 20 ms) at the expense of noise immunity. The relevant module data and wiring rules are documented in the SIMATIC S7-300 S7-300 Module Data manual on Siemens Industry Online Support.

8. Scaling with FC105 SCALE and FC106 UNSCALE

The TI-S7 Converting Blocks library (formerly shipped with STEP 7 as the "Standard Library / TI-S7 Converting Blocks") provides two essential blocks:

  • FC105 SCALE — converts a raw integer to a real engineering value.
  • FC106 UNSCALE — inverse, converts a real engineering value to a raw integer for writing to PQW.

8.1 FC105 SCALE interface

Parameter I/O Type Meaning
IN INPUT INT Raw input value (e.g. from PIW)
HI_LIM INPUT REAL Engineering value at raw 27648 (e.g. 100.0)
LO_LIM INPUT REAL Engineering value at raw 0 (e.g. 0.0)
BIPOLAR INPUT BOOL 1 = bipolar (±27648), 0 = unipolar (0…27648)
OUT OUTPUT REAL Scaled engineering value
RET_VAL OUTPUT WORD W#16#0000 on success; see error code table below

8.2 FC105 RET_VAL error codes

RET_VAL Cause Recommended Action
W#16#0000 No error Use OUT
W#16#0007 HI_LIM = LO_LIM (division by zero) Check scaling limits, ensure HI_LIM > LO_LIM for unipolar
W#16#0008 LO_LIM > HI_LIM Swap the limits or verify the inverted scale (e.g. 4…20 mA → 100…0 %)
W#16#0009 Raw value below LO_LIM engineering range (output clipped) Inspect wiring and module configuration; check for wire break (0x8000)

8.3 Example call in STL

// Convert PIW 256 (0..27648) to 0.0..100.0 percent
CALL  FC   105
     IN       := MW100                 // loaded elsewhere from PIW 256
     HI_LIM   := 1.000000e+002
     LO_LIM   := 0.000000e+000
     BIPOLAR  := FALSE
     RET_VAL  := MW110                 // check for W#16#0007..0009
     OUT      := MD120                 // scaled real, e.g. 47.3 (percent)

8.4 Worked scaling formula

For unipolar signals the math is a straight linear interpolation:

OUT = ((IN - 0) × (HI_LIM - LO_LIM)) / 27648 + LO_LIM

For bipolar signals the math centres on zero:

OUT = (IN × (HI_LIM - LO_LIM)) / 27648 + (HI_LIM + LO_LIM) / 2

For inverted scales (e.g. 4…20 mA → 100…0 %, as used in some valve positioners) set LO_LIM = 100.0 and HI_LIM = 0.0. FC105 automatically detects the inverted limits and returns the correct inverted output.

9. Process Image Partitioning (TP / PIP)

For S7-400 (and S7-300 CPUs that support it, such as 317 and 319), the process image can be subdivided into up to 31 partitions, each assignable to a specific OB. This is configured in HWConfig on the module properties under Addresses / Process Image. The relevant OBs are:

Partition Owner OB Trigger Typical Use
OB1 Cyclic scan Default process image partition
OB10…OB17 Time-of-day interrupt Refresh slow I/O at a fixed schedule
OB40 Hardware interrupt Force update of inputs associated with a fast event
OB55…OB57 Status / update / manufacturer interrupts DPRAM and DP-V1 diagnostics

When a module is assigned to partition TP n, the CPU updates the corresponding IB/QB bytes only when the owning OB is entered. Outside that OB, the user program should use PIB / PQB for an immediate read/write, otherwise it sees stale data.

10. Disabling Process Image Updates on S7-400

For certain deterministic applications, the S7-400 CPU allows the process image update to be disabled in the scan cycle. The relevant SFC is SFC 26 UPDAT_PI (input) and SFC 27 UPDAT_PO (output), which refresh selected process image partitions under program control. The calling pattern is:

CALL  SFC 26
     PART     := 0                     // partition 0 (OB1 portion)
     RET_VAL  := MW200                 // W#16#0000 on success
     FLADDR   := MW202                 // first byte that failed (if any)

When the automatic scan-end update is disabled in the CPU properties (Cycle / Update Process Image cyclically unchecked), the program becomes fully responsible for invoking SFC 26 / SFC 27 at the desired points. This is the proper way to avoid the "PIB1 value overwritten by next OB1 image refresh" issue raised in the field report.

11. Programming Patterns and Best Practices

11.1 Use PIW for analog, IB for digital (when stable)

Default rule: digital input modules participate in the process image, so use I addresses. Analog modules are always accessed via PIW because their conversion registers are not mirrored in the process image by default. Counting modules (FM350) likewise use PIW for the count register.

11.2 Do not move PIB into IB inside OB1

It is wasteful and confusing. The next OB1 pass will overwrite your IB1 with the live input. Use an M or a DB byte if you need a frozen snapshot.

11.3 Group adjacent PIW reads

To minimise backplane bus traffic, read an entire 16-byte analog block with a single L PIW per channel rather than scattering reads. If a module supports 8 channels starting at PIW256, the eight reads are PIW256 … PIW270. Avoid reading the same channel twice in OB1 unless the logic demands it.

11.4 Handle 0x7FFF / 0x8000 diagnostics

Always check the raw value for the overflow tag 0x7FFF (32767) and the wire-break tag 0x8000 (-32768) before scaling. A raw of 32767 in a 4…20 mA loop usually means an open input or a shorted cable. FC105 will scale these to LO_LIM or HI_LIM and set the appropriate clipping flag, but your logic should still log the event and raise a process alarm.

11.5 Verify the address in HWConfig before commissioning

STEP 7 will allow you to type any address in the editor, but the CPU will return an I/O access error (SF LED + diagnostic buffer entry) if the address is not configured. Use PLC → Monitor/Modify → Monitor to verify the address space online before downloading the program.

12. Troubleshooting Matrix

Symptom Likely Cause Diagnostic Step Fix
Reading PIW always returns 0 Module not configured or wrong slot HWConfig: verify the module's logical address and the slot number Re-assign the module, re-download HWConfig
SF LED on, diagnostic buffer shows "Peripheral I/O error" Module removed, faulty, or backplane issue Replace the module with a known-good one Replace module; check connector pin-out
Raw value stuck at 0x7FFF (32767) Over-range, broken wire, misconfigured range Check wiring, check HWConfig measurement range Repair wiring, change measurement type to match sensor
Raw value stuck at 0x8000 (-32768) Wire break on 4…20 mA loop or TC open Measure loop current with a multimeter Repair cable, check terminal screws
Value oscillates wildly in OB1 EMI or wrong integration time Switch SM331 to 60 Hz integration Apply shielded cable, increase integration time
FC105 returns W#16#0007 HI_LIM = LO_LIM (division by zero) Inspect scaling limits in the call Re-enter valid LO_LIM < HI_LIM
FC105 returns W#16#0008 LO_LIM > HI_LIM (intentional or not) Check scale direction For inverted scale, leave as-is; for normal scale, swap
Output stays at last value after field signal change Reading IB instead of PIB for an analog channel outside the image Inspect the symbol table for the address prefix Change to PIW / L PIW 256
Process image updates do not run OB1 image disabled in CPU properties Check CPU > Properties > Cycle tab Re-enable automatic update or call SFC 26 / SFC 27
Symbolic access fails for PIW Symbol declared in wrong address area Verify symbol "PIW256" or use absolute address Declare symbolic name in address "PIW 256"

13. Reference: Equivalent Addresses Across Siemens Families

Function S7-300/400 (STEP 7 v5.x) S7-1200/1500 (TIA Portal)
Peripheral input byte PIB <addr> %IB<addr> with attribute Direct I/O access in the PLC tag table, or :%IB<addr> in SCL
Peripheral input word PIW <addr> :%IW<addr> or process image tag in the I/O area
Peripheral output word PQW <addr> :%QW<addr>
Immediate read instruction Direct L PIW 256 Use direct I/O access slice in the tag table, or :%IW256 in SCL
Process image update control SFC 26 / SFC 27 Automatic; cannot be disabled at the cycle level in S7-1500

On S7-1500 the P prefix is replaced by an explicit "Direct I/O Access" attribute on the PLC tag. Under the hood the backplane behaviour is the same: the read is performed on the bus at the moment of access, bypassing the process image update. For migration of S7-300/400 code, swap PIW256 for %IW256 in the S7-1500 tag and mark the tag as "direct" in the tag table.

14. Field-Commissioning Checklist

  1. Open HWConfig, double-click the CPU, and record the configured "Size of the process image" limits.
  2. List every analog module and write down the logical PIW and PQW addresses from the module properties dialog.
  3. In Monitor/Modify, watch PIW values to confirm a live signal is present at the module terminals (multiply by engineering factor for sanity: e.g. 4…20 mA at 10 V should read about 13824 for 50 % of range).
  4. Verify the diagnostic buffer is clean (no "Peripheral I/O error" entries).
  5. Test the FC105/FC106 scaling path with a known input signal (e.g. calibrator at 12.000 mA, expect 50 % of range).
  6. Document the address map in the project documentation so that the next engineer does not have to repeat the analysis.
Safety reminder: Analog input channels in safety-related applications (SM331F, SM336F) must be handled by an F-runtime group in the F-CPU. The PIW address can be used inside the F-block provided the value is consumed within the F-runtime group and is processed by a fail-safe block. Direct peripheral access from a standard OB1 outside the F-system is not permitted for safety signals.

15. Summary

The number after PIB is the byte address within the peripheral input area, generated by STEP 7 HWConfig and downloaded to the CPU as part of the system data. The P prefix is the marker for direct, immediate I/O access that bypasses the process image. The two address spaces (image and peripheral) co-exist because they serve different engineering goals: deterministic snapshot semantics for digital logic, low-latency direct access for analog and interrupt-driven reading. Understanding where the boundary between them sits in the configured CPU — typically PIB128 on S7-300 and PIB256 on S7-400 — and verifying the assignment in HWConfig is the first step to writing correct, maintainable STEP 7 code. Use PIW for analog channels, scale with FC105 into engineering units, and always check the raw value for the 0x7FFF overflow and 0x8000 wire-break diagnostic tags before trusting the scaled result.

Frequently Asked Questions

What does the "1" in PIB1 represent?

The "1" is the byte address of the peripheral input, not a channel number or a counter. It is the logical address assigned by STEP 7 HWConfig to the module that occupies the corresponding slot in the rack. For analog channels the word equivalent — e.g. PIW256 for the first channel of a typical SM331 — is what the program normally uses.

Can I move PIB1 into IB1 inside OB1?

Technically yes, but it serves no useful purpose on the default S7-300 layout because PIB1 and IB1 refer to the same physical byte and the process image refresh at OB1 start will overwrite your IB1 immediately. Use a merker byte (MB) or a DB byte if you need to preserve a snapshot, or disable the cyclic image update on an S7-400 and use SFC 26 to control refresh timing.

Why does my analog read always return 0x7FFF (32767)?

0x7FFF is the S7-300/400 overflow / fault tag. It means the analog module detected a value above its configured range, an open input (for 4…20 mA loops), or a hardware fault. Check the wiring with a multimeter, verify the HWConfig measurement range matches the sensor type, and inspect the diagnostic buffer for the specific channel error.

What is the difference between PIW256 and IW256?

On the default S7-400, IW256 does not exist because it lies above the process image boundary (which ends at IB 255). PIW256 is the only valid way to read that address. On the default S7-300, addresses above 127 are similarly only reachable as PIW. Always use PIW for analog channels to ensure the code is portable across CPU families.

How do I scale a raw PIW value to engineering units?

Use FC105 SCALE from the TI-S7 Converting Blocks library. Pass the raw value to IN, set HI_LIM and LO_LIM to the engineering range (e.g. 100.0 and 0.0 for percent), and set BIPOLAR = FALSE for 0…27648 unipolar or TRUE for ±27648 bipolar. The block returns the scaled REAL in OUT and a status word in RET_VAL; W#16#0000 means success, W#16#0007 means HI_LIM equals LO_LIM, W#16#0008 means the limits are inverted.

Does PIB exist on S7-1200 and S7-1500?

Not with the PIB mnemonic. The S7-1200/1500 platform uses the percent syntax with the direct I/O access attribute (e.g. %IW256 with the "Direct I/O access" bit set in the PLC tag table, or :%IW256 in SCL). The backplane behaviour is identical — the read happens immediately on every access, bypassing the process image.

Back to blog