Overview
The Siemens S7-1200 programmable logic controller uses a uniform Byte.Bit addressing scheme across its memory areas. Inputs, outputs, and bit memory (M) all begin at byte 0, bit 0 and grow upward as the project requires. The question every migration engineer asks is: how far can I address %M before the CPU rejects the symbol? The answer is not a fixed address, it is a CPU-dependent property published in the Siemens datasheet and the ST 70 catalog.
For the S7-1200 family the bit memory area is compact: most CPUs cap the M area at 4 KB or 8 KB. The S7-1500 family expands this headroom to 16 KB on the 1511-1PN and beyond on the larger 1513/1515/1516/1517/1518 CPUs. Knowing the exact upper bound of the M area is required before assigning DB-internal flags, scratch words, edge-detection helpers, or HMI handshaking tags, because a TIA Portal compile error "Address is not within the process image or the address area of the block" is the only feedback the engineer receives when an %M address is out of range.
This reference consolidates the published M memory sizes for every current S7-1200 CPU, the S7-1500 entry-level CPU, the official Siemens documentation paths, and the practical workarounds used in field programs that exceed the on-board bit memory.
S7-1200 Memory Architecture and the Role of M
The S7-1200 splits its load memory, work memory, and retentive memory across three physical areas. Bit memory (M) sits inside the work memory image, behaves like a global scratchpad, and is cleared on every CPU restart unless the byte is declared retentive in the PLC properties dialog of TIA Portal. M memory is not backed by the process image, so reads and writes access the work memory directly without the OB1 update cycle that governs %I and %Q.
| Area | Prefix | Typical Use | Retentive Option |
|---|---|---|---|
| Process image of inputs | %I / %IB / %IW / %ID | Sensor states at OB1 boundary | No (mirrored from inputs) |
| Process image of outputs | %Q / %QB / %QW / %QD | Actuator commands at OB1 boundary | No (mirrored to outputs) |
| Bit memory | %M / %MB / %MW / %MD | Flags, edge bits, interlock words | Yes (selective byte ranges) |
| Data blocks | %DB | Structured application data | Yes (whole block or elements) |
| Timers / Counters | %T / %C | IEC timers and counters | Yes (IEC_Timer instances can be retentive) |
The numbering of %I, %Q, and %M is byte-aligned and bit-indexed. The first 8 inputs occupy %I0.0 through %I0.7, the next 8 sit in %I1.0 through %I1.7, and so on. The same logic applies to %Q and %M. When an engineer writes %M100.7 in TIA Portal, the compiler translates that to byte 100 (offset 100 * 8 = bit address 800) and bit 7, the highest bit of that byte.
Byte.Bit Addressing Format Explained
Siemens uses the IEC 61131-3 % prefix followed by the area letter and a Byte.Bit index. The S7-1200 accepts the following variants in TIA Portal:
-
%M0.0– single bit, the very first flag bit -
%MB0– entire byte of bit memory (8 bits) -
%MW0– word (16 bits), aligned on byte boundary -
%MD0– double word (32 bits), aligned on byte boundary -
MW2– the S7-1200 also accepts the legacy prefix-less form in LAD/FBD/STL
The bit index runs from 0 to 7. The byte index starts at 0 and rises to (size_in_bytes - 1). For an S7-1211C with 4096 bytes of bit memory, the valid range is therefore %M0.0 through %M4095.7. For an S7-1214C with 8192 bytes, the range extends to %M8191.7. Writing to %M4096.0 on a 1211C causes a TIA Portal offline compile error, or, if the address is forced at runtime, an access error that stops the CPU with SF (system fault) LED lit and a diagnostic buffer entry referencing the offending OB.
M Memory Size by S7-1200 CPU Model
The published bit memory sizes for the current S7-1200 generation are summarized in the table below. All values are taken from the Siemens SIMATIC S7-1200 programmable controller system manual and the ST 70 catalog. Verify against the manual revision for your firmware version, because Siemens has revised some figures between firmware V3 and V4.x.
| CPU Model | Order Number (MLFB) | Firmware | Bit Memory (M) | Range |
|---|---|---|---|---|
| CPU 1211C DC/DC/DC | 6ES7211-1AE40-0XB0 | V4.x | 4096 bytes (4 KB) | %M0.0 – %M4095.7 |
| CPU 1211C AC/DC/RLY | 6ES7211-1BE40-0XB0 | V4.x | 4096 bytes (4 KB) | %M0.0 – %M4095.7 |
| CPU 1212C DC/DC/DC | 6ES7212-1AE40-0XB0 | V4.x | 4096 bytes (4 KB) | %M0.0 – %M4095.7 |
| CPU 1212C AC/DC/RLY | 6ES7212-1BE40-0XB0 | V4.x | 4096 bytes (4 KB) | %M0.0 – %M4095.7 |
| CPU 1214C DC/DC/DC | 6ES7214-1AG40-0XB0 | V4.x | 8192 bytes (8 KB) | %M0.0 – %M8191.7 |
| CPU 1214C AC/DC/RLY | 6ES7214-1BG40-0XB0 | V4.x | 8192 bytes (8 KB) | %M0.0 – %M8191.7 |
| CPU 1215C DC/DC/DC | 6ES7215-1AG40-0XB0 | V4.x | 8192 bytes (8 KB) | %M0.0 – %M8191.7 |
| CPU 1215C AC/DC/RLY | 6ES7215-1BG40-0XB0 | V4.x | 8192 bytes (8 KB) | %M0.0 – %M8191.7 |
| CPU 1217C DC/DC/DC | 6ES7217-1AG40-0XB0 | V4.x | 8192 bytes (8 KB) | %M0.0 – %M8191.7 |
| CPU 1212C (compact, older) | 6ES7212-1AD30-0XB0 | V3.x | 4096 bytes (4 KB) | %M0.0 – %M4095.7 |
| CPU 1214C (older) | 6ES7214-1AD30-0XB0 | V3.x | 8192 bytes (8 KB) | %M0.0 – %M8191.7 |
Two patterns are visible: the 1211C and 1212C share the 4 KB M area, while the 1214C, 1215C, and 1217C all carry 8 KB. The 1217C is a high-speed application controller with 125 ns bit execution, but it does not increase bit memory above 8 KB. If a project needs more than 8 KB of M, the solution is not to look for a larger S7-1200; it is to step up to the S7-1500 family or, more often, to refactor the program to use a global data block (DB) with optimized access.
S7-1500 Comparison: Why the M Area Grows
The S7-1500 family inherits the same Byte.Bit syntax but expands the M area because the work memory of the 1500-series CPUs is several times larger. The published figures for the entry-level S7-1500 CPUs are:
| CPU Model | Order Number | Bit Memory (M) | Range |
|---|---|---|---|
| CPU 1511-1 PN | 6ES7511-1AK02-0AB0 | 16 KB (16384 bytes) | %M0.0 – %M16383.7 |
| CPU 1511F-1 PN | 6ES7511-1FK02-0AB0 | 16 KB (16384 bytes) | %M0.0 – %M16383.7 |
| CPU 1512C-1 PN | 6ES7512-1CK00-0AB0 | 16 KB (16384 bytes) | %M0.0 – %M16383.7 |
| CPU 1513-1 PN | 6ES7513-1AL02-0AB0 | 32 KB (32768 bytes) | %M0.0 – %M32767.7 |
| CPU 1515-2 PN | 6ES7515-2AM02-0AB0 | 64 KB (65536 bytes) | %M0.0 – %M65535.7 |
| CPU 1516-3 PN/DP | 6ES7516-3AN02-0AB0 | 128 KB (131072 bytes) | %M0.0 – %M131071.7 |
| CPU 1517-3 PN/DP | 6ES7517-3AP00-0AB0 | 256 KB (262144 bytes) | %M0.0 – %M262143.7 |
| CPU 1518-4 PN/DP MFP | 6ES7518-4AP00-0AB0 | 512 KB (524288 bytes) | %M0.0 – %M524287.7 |
The S7-1500 also introduces optimized data blocks as the default storage, which is why many programs that previously consumed large M areas in the S7-300/400 era now allocate their scratch tags in a global DB. The S7-1500's M area is still useful for short-term flags, mode bits, and first-scan logic, but the engineering recommendation is to use a structured DB for any tag that carries a process meaning (recipe values, machine state, HMI handshaking). The 1511-1 PN's 16 KB M area comfortably covers migration from a 1214C 8 KB area with room to spare.
Locating the M Memory Limit in Official Documentation
Siemens publishes the bit memory size in two places that engineers should consult before commissioning.
- SIMATIC S7-1200 Programmable Controller System Manual – the chapter Technical Specifications lists the bit memory area in the Memory areas subsection of each CPU's data sheet. The manual is shipped as a PDF with the TIA Portal installation and is available on the Siemens Industry Online Support portal.
- ST 70 Catalog – the SIMATIC product catalog (ST 70) is the master catalog and lists every S7-1200 and S7-1500 CPU with the headline figures for work memory, bit memory, counters, and timers.
To find the exact M area for any Siemens PLC online:
- Open Siemens Industry Online Support.
- Search for the order number, e.g.
6ES7214-1AG40-0XB0. - Open the product page, then select the Technical data tab.
- Look for the row labeled Bit memory; the value is given in bytes (4 096, 8 192, 16 384, ...).
- Convert bytes to bits by multiplying by 8, then subtract 1 from the bit number to get the upper bound (e.g. 8 192 bytes × 8 = 65 536 bits, the highest addressable bit is bit 65 535 of byte 8 191, written
%M8191.7).
Migration from LOGO! to S7-1200: M Memory Mapping
Engineers moving from Siemens LOGO! to the S7-1200 often carry over a habit of naming every tag in a flat namespace. LOGO! does not expose a traditional M area, but its flag blocks (M8, M16, M25, ...) serve a similar role. On the LOGO! 8 the flag bytes are mapped into a subset of the LOGO!'s variable memory. The S7-1200 then becomes the first platform where the engineer has to make a conscious decision: do I put this in %M, or do I put it in a DB?
| LOGO! Concept | S7-1200 Equivalent | Notes |
|---|---|---|
| Flag block M8 / M16 / M25 | %MB0, %MB1, %MB2 | Byte-wide flag, equivalent semantics |
| Flag block M32 | %MD8 (32-bit signed) | Use a double-word when LOGO! block expects DWord |
| Shift register bits S1.1 – S1.8 | %M10.0 – %M10.7 | Map the 8 bits to a single byte in M |
| Edge detection (P/N) | %M20.0, %M20.1, … | One bit per edge in a flag byte |
| LOGO! Softkey / cursor key state | %M30.0 – %M30.3 | Reserve a dedicated byte for the four keys |
A practical layout convention for an S7-1212C migrating a 200-line LOGO! program:
-
%MB0–%MB31: machine mode bits (auto / manual / setup / fault reset / start / stop / ack) -
%MB32–%MB63: edge memory (rising / falling flags, one byte per signal, 32 signals supported) -
%MW64–%MW127: HMI handshaking (command word, status word, setpoint, actual value) -
%MB128–%MB255: free scratch for FB instance data; replace with DB if project grows
This plan uses only 256 bytes of the available 4 096, leaving the rest for unexpected growth. The S7-1214C and 1215C provide 8 192 bytes, which means the same plan can be extended fourfold without renumbering.
Programming Best Practices for M Memory
Bit memory is fast, byte-aligned, and easy to address from LAD/FBD. It is also the first area to become disorganized on a long-running project. The following rules prevent the M area from degenerating into a tag swamp.
-
Reserve a header byte for first scan and warm restart. %M0.0 is the natural choice for FirstScan (S7-1200 also exposes a system bit
%S0.0for the same purpose). %M0.1 can be WarmRestart, %M0.2 ColdRestart. - Group related flags into a named byte or word. Mode bits live in %MB1, edge bits in %MB2, interlock bits in %MB3. This compresses cross-references and lets the HMI display the byte as a binary status word.
- Declare retentive ranges explicitly. In the CPU properties under Retentive memory → Bit memory, enter the byte count to retain. The remaining non-retentive flags reset to 0 on every restart. Typical retentive range: %MB0 – %MB63 for mode and counter latches.
-
Use MW or MD instead of building words out of bits. A
%MW10is a 16-bit signed integer. TIA Portal will not infer the sign, so declare the variable in a tag table asWordorIntbefore use. - Cross-reference every M before commissioning. Right-click the project tree, choose Cross-references → Show all, then filter by area M. Stale flags from removed code blocks can waste MB of memory and confuse the next maintainer.
- Plan for migration to a global DB. When the program exceeds ~50% of the M area, refactor: create a global DB named MachineData, move tags there, and let the M area shrink to a thin band of fast boolean flags.
Verification and Diagnostics
The most reliable way to confirm the M area boundary in a live project is to query the PLC's online diagnostics. TIA Portal exposes the M area as a watchable memory range, and the S7-1200 web server can render a portion of the M area as a custom web page.
- Online & Diagnostics → Memory → Bit memory: shows the configured size in bytes and the retentive byte count.
-
Watch table: create a watch table with tag
%MW0and a forced value. If the watch table goes online and displays the value, the address is valid; if the table reports "Invalid address", the byte is outside the work memory. -
Diagnostic buffer: an out-of-range M access during a forced write or a programming error generates event ID
0x35FE(or a similar operand-range diagnostic), visible in Online & Diagnostics → Diagnostics & Buffer. - System LEDs: a persistent SF LED (red) after a forced M access above the CPU limit indicates the CPU has stopped. Acknowledge the error with STOP → RUN after clearing the offending force table.
When to Outgrow M: Data Block Patterns
The S7-1200 and S7-1500 do not enforce a hard cap on the M area beyond the published byte count, but the engineering community has converged on a few refactor patterns.
| Symptom | Refactor | Benefit |
|---|---|---|
| HMI polls 50+ M tags individually | Move to a global DB, expose as a single UDT | Single PUT/GET frame, faster HMI polling |
| M used as a recipe table | Move recipe to a DB and use RecipeView HMI controls | Persistent storage, export/import to USB |
| M used for motion setpoints | Move to a TO (Technology Object) data block | Type-safe access, motion library functions |
| M used for safety interlocks | Move to F-runtime group DB (F-CPU only) | Safety certification preserved |
| M declared retentive in large blocks | Move to a DB with optimized access and set the DB as retentive | Fine-grained retention, faster download |
The refactor decision is rarely about memory size; it is about data shape. M is a flat array of bytes. A DB is a typed structure. Once the project carries structured data (machine state, recipes, axes, alarms), the DB wins on readability, on HMI integration, and on long-term maintenance cost.
Troubleshooting Matrix
| Symptom | Likely Cause | Resolution |
|---|---|---|
| TIA Portal compile error: "Address is not within the address area" | %M byte is above the CPU's published bit memory size | Reduce the byte index, change the CPU, or move the tag to a DB |
| CPU goes to STOP with SF LED after download | Forced %M address outside the work memory | Open the force table, delete the offending entry, perform STOP->RUN |
| Flag value visible online but resets after power cycle | Byte is in the non-retentive range | Open PLC properties → Retentive memory → Bit memory, extend the retentive range to cover the byte |
| Cross-reference shows M tags but no source | Tag was renamed or its block deleted; compiler left the reference in the M area | Run Program cleanup in the project tree, recompile, re-download |
| Watch table shows "Invalid address" for a known M byte | The CPU was changed but the project was not recompiled | Right-click the device → Compile → Software (rebuild all), then download |
| HMI shows M tags as question marks | HMI project points to an M area larger than the S7-1200 publishes | Edit the HMI tag list, lower the byte index, or remap the tag to a DB |
Related Memory Areas Worth Knowing
The M area is one of five global memory spaces in the S7-1200. The other four are sometimes mistaken for M and should be understood before allocating tags.
- %L (Local / Temp) – per-block scratch, lives only during the block call, cannot be retentive. Use for math intermediates and loop counters.
- %DB (Data Block) – typed structured memory, the preferred location for any tag that carries process meaning. Optimized access on the S7-1200/1500 makes DB faster than M for word and double-word reads.
- %I / %Q (Process image) – peripheral I/O mirrored to RAM at the OB1 boundary. Avoid using %M as a roundabout way to read inputs; the process image is always faster and consistent.
-
%S (System memory) – read-only bits managed by the CPU, e.g.
%S0.0FirstScan,%S0.1DiagnosticBufferOverflow,%S0.7ClockFault. Cannot be written.
FAQ
What is the highest valid M address on an S7-1214C?
The S7-1214C (firmware V4.x, order number 6ES7214-1AG40-0XB0) has 8 192 bytes of bit memory, so the highest valid address is %M8191.7. TIA Portal rejects any %M byte above 8 191 at compile time.
What is the highest valid M address on an S7-1211C or S7-1212C?
Both the 1211C and 1212C have 4 096 bytes of bit memory. The valid range is %M0.0 through %M4095.7. Going above 4 095 causes a compile error or, on a force, an access stop.
Does the S7-1500 have more M memory than the S7-1200?
Yes. The S7-1511-1 PN ships with 16 384 bytes (range %M0.0 to %M16383.7). Larger S7-1500 CPUs scale up to 512 KB on the 1518-4 PN/DP MFP. The exact figure for any 1500 CPU is published in the ST 70 catalog entry.
Where can I find the M memory size for my exact CPU?
Look up the order number (MLFB) on the Siemens Industry Online Support portal at support.industry.siemens.com, then open the product page's Technical data tab. The bit memory size is listed in bytes. Cross-check with the SIMATIC ST 70 catalog PDF for the current product generation.
Can I make M memory retentive across power cycles?
Yes. Open the device properties of the CPU in TIA Portal, navigate to Retentive memory, and enter the number of M bytes to retain starting at %MB0. The chosen range is preserved through STOP/RUN, power loss, and warm restarts. Bytes outside the range reset to zero on every restart.