Explainer
Why PLC I/O mapping into a data block cuts commissioning time
Short answer
Copy each input word into a data block in the first networks of the scan and copy a separate command block out to the outputs in the last networks. Logic then references the mapped bits, so an inverted contact or a channel moved to a spare terminal is a one-network change in one block. That is where the commissioning time goes.

On this page
- What is I/O mapping in a PLC program?
- Why does mapping inputs and outputs cut commissioning time?
- How do you copy the input words into a data block on an S7-1200?
- How do you write the mapped outputs back to the physical channels?
- Where in the scan cycle do the mapping networks run?
- What changes when a contact is NC instead of NO?
- When is direct addressing the better choice?
- Questions asked
Copy every input word into a data block in the first networks of the scan and copy a separate command block back out to the physical outputs in the last networks. The logic in between never names a physical address, so a limit switch that turns out NC instead of NO, or an input channel that dies and moves to a spare terminal, is a one-network change in one block instead of a hunt through every rung that uses the signal. On an S7-1200 the whole pattern is a handful of MOVE boxes plus one exception network per inverted bit, and it is the first structural thing to add when commissioning edits keep landing in the wrong places.
What is I/O mapping in a PLC program? #
I/O mapping is two copy routines at the edges of the scan: the first copies the physical input words into a data block before any logic runs, and the last copies a separate command block out to the physical output words after the logic finishes. The logic between them never names a physical address. Where a rung used to test I 0.2 it tests the corresponding bit of the mapped word, DB1.DBX0.2, and the physical address appears in exactly one place in the whole project: the mapping block. That single point of contact is the entire mechanism.
Keep one distinction clear. The device configuration screen where each channel is assigned its start address is also called an I/O map in some engineering tools; that one assigns addresses. This mapping is the program-level copy of those addresses into memory the logic owns. Addresses are still decided in the hardware configuration; mapping decides what the logic is allowed to reference.
The copies are ordinary MOVE instructions, and their documented behavior matters here: a move writes the value to a new address and leaves the source unchanged. The raw input word therefore stays readable for diagnostics after it has been mapped, which you want the day a sensor and its mapped bit disagree.
Why does mapping inputs and outputs cut commissioning time? #
Every change to a signal's address or contact convention lands in one network instead of one edit per reference, and commissioning is mostly exactly those changes: inversions, moved channels, temporary bypasses. The saving is arithmetic, not opinion, so work an example.
Take a machine on a CPU 1214 DC/DC/DC with all 14 onboard inputs in use and an average of four references per signal: 14 x 4 = 56 contact references across the program. During commissioning, three limit switches turn out NC where the program assumed NO, and one input channel fails and is moved to a spare terminal.
Without mapping, each fix is an edit at every reference: three inversions at four references each plus one channel move at four references is 3 x 4 + 1 x 4 = 12 + 4 = 16 edits, each to be found, changed and cross-checked across the program. With mapping, the same session is three exception networks plus one source-address edit = 4 edits, all in one block. At an assumed five minutes per verified edit, that is 16 x 5 = 80 minutes against 4 x 5 = 20 minutes, and the mapped version leaves a signal list behind as a document. The minutes are illustrative; the edit counts are the point.
The scattered edits carry a second cost: a missed one passes commissioning and waits in the rarely exercised path, which converts a commissioning edit into a shutdown call months later.
How do you copy the input words into a data block on an S7-1200? #
Put one MOVE box per input word in the first networks of the main program, source IW 0 and destination DB1.DBW0, and create the data block with standard access so those absolute word addresses resolve. The onboard inputs of a CPU 1214 DC/DC/DC occupy I 0.0 through I 1.5, so one word copy of IW 0 captures all 14 of them, with bits 1.6 and 1.7 left at zero. Each expansion module or signal board contributes its own word at its configured address.
Network 1 input mapping, first networks of the main program
IW 0 -> DB1.DBW0
IW 2 -> DB1.DBW2
The block must have standard, non-optimized access for DB1.DBW0 to mean anything: an optimized block has no fixed layout, so absolute addressing into it does not resolve. The alternative is an optimized block used only through its declared variable names; both work, and the only wrong choice is switching later.
Name the mapped bits. The addressing documentation for PLC tags allows either the absolute address or the symbolic name, and a rung that reads a symbolic name survives every address change the mapping block absorbs. Logic that used to test I 0.2 now tests DB1.DBX0.2, under a name.
How do you write the mapped outputs back to the physical channels? #
Give the outputs their own command block: the logic writes DB2 only, and the last networks of the main program copy DB2.DBW0 to QW 0 and DB2.DBW2 to QW 2, so each physical output word has exactly one writer.
Network N output mapping, last networks of the main program
DB2.DBW0 -> QW 0
DB2.DBW2 -> QW 2
The command block earns its keep the same way the input image does. A failed output channel moves by editing one destination address, and a maintenance mode that must drop outputs can zero the command words in one place instead of hunting coils. If a SCADA client or HMI writes outputs, point those writes at the command block, never the physical word, so the end-of-scan copy stays the only writer; what a direct write to the output registers actually does is covered in can a Modbus write change PLC outputs?.
One line stays uncrossed: an output that implements a safety function is never part of this scheme. It is hardwired or driven by the safety program, and a bypass bit in a mapping block does not get to defeat it; the handover on the safety side is covered in mapping standard PLC tags into a safety program.
The stability serves the visualization too: displays read the input image and commands write the command block, so a channel move never touches a screen connection.
Where in the scan cycle do the mapping networks run? #
Input mapping runs in the first networks and output mapping in the last networks of the main program, and because the operating system refreshes the input process image before that program executes, the pattern adds no extra scan of latency. The scan order does the work: inputs are read into the process image, the main program executes with the copy-in first and the copy-out last, and the process image is written to the terminals. The logic sees exactly the input freshness it always had, and a mapped output reaches its terminal in the same scan it was computed.
The cost is a few word copies per scan, negligible against a cycle measured in milliseconds, but check it once anyway: the CPU enforces a maximum cycle time and raises a time error when the cycle exceeds it, and the current cycle time is shown in the CPU diagnostics. Confirm the number after adding the mapping networks, then stop thinking about it.
What changes when a contact is NC instead of NO? #
One exception network placed after the word copy: drive that mapped bit from a normally-closed contact instead of taking the copied bit, and leave every rung that references the signal untouched. Order is everything; the exception must follow the copy, or the copy overwrites the corrected bit on every scan.
Adopt one convention per machine: the mapped bit is 1 when the physical condition the machine calls true (extended, closed, part present) is present. The electrician's NO-versus-NC choice then stays in the field, and the mapping absorbs it without the logic knowing.
Check the failure state, not just the active state. Under that convention, a broken wire on an NC loop reads 0, the same as de-actuated. If the machine must alarm on a broken wire for a particular loop, add a fault rung on the raw input rather than inventing a different inversion, and prove it on first power-up by lifting the wire at the terminal and watching the mapped bit.
When is direct addressing the better choice? #
Only a signal used exactly once and wired to a terminal that will never move is better off direct; from the second reference onward, the one-time mapping copy is cheaper than any later edit. The decisions, per case:
- Map every input and output on any machine you will commission and hand over. A single-reference signal costs one copy network either way, so the uniform scheme costs nothing extra and produces one signal list per machine.
- Keep direct addressing for a signal referenced exactly once on a fixed terminal, such as a handshake bit to one device, and note the exception on the signal list so the next engineer knows it was deliberate.
- Never mix styles on one signal. A signal referenced through both the physical address and the mapped bit is worse than either scheme alone, because an inversion at the boundary silently splits the program into two disagreeing views.
A failed channel has a third rescue worth knowing: swapping addresses in the device configuration re-points the channel without touching code. That path does nothing for a wrong contact convention or a controlled bypass, and it leaves the program disagreeing with the drawings unless the drawings change too. The mapping edit covers all three cases and keeps the hardware configuration as-built.
Questions asked
Can I copy the input image as one array instead of word by word?
Yes. Declare the mapped image as an array of words in the data block and use MOVE_BLK, the documented block move, to copy several words in one instruction. If an interrupt routine can fire mid-copy and read the array, use UMOVE_BLK instead, the uninterruptible variant, so the interrupt never sees a half-updated image. Word-by-word MOVE boxes stay easier to read in ladder up to a dozen words; past that the array pays for itself.
Should the mapping live in a function block or straight in the main program?
Either works; put it where the addresses are easiest to audit. On a single-CPU machine, two small routines called from the first and last networks of the main program are the simplest to read. A function block earns its place when the same subsystem repeats, say three identical stations: one mapping block type, one instance per station, each instance holding its own mapped image. Either way the logic sits between the copy-in and copy-out calls, never beside them.
Does the same pattern apply to analog inputs?
Yes, and it pays twice. Copy each analog input word into the mapped image at the top of the scan, then scale from that copy: the raw counts stay available for calibration, the conversion to engineering units happens once at the boundary instead of in every consumer, and swapping a channel means editing one source address. Consumers reference the scaled value, never the channel, under the same discipline as the digital bits.
Does mapping cover PROFINET remote I/O on the same CPU?
Yes. Remote IO device inputs arrive in the process image at the address range the device configuration assigns them, so the mapping block copies those words exactly like onboard words, in the same first networks. When a remote channel fails, edit the source address in the mapping block the same way; nothing downstream changes, and the data block layout the screens read stays put.


