Overview: What the S7 Clock Memory Byte Is
The Siemens SIMATIC S7 clock memory (German: Taktmerker) is a reserved byte in the CPU's bit-addressable memory area whose eight bits toggle between 0 and 1 at fixed, software-defined frequencies. The ON state and OFF state of every bit are equal in duration, which is the meaning of the documented pulse-pause ratio of 1:1: each bit spends 50% of its period in logic 1 and 50% in logic 0.
The clock memory is generated by the CPU's operating system at the start of every OB1 cycle (priority class 1) and is therefore deterministic with respect to the user program scan. The byte is updated independent of program execution time, so the period you read in the manual is the period you measure at the contact in your ladder logic.
Clock memory is available on every current S7 platform (S7-300/400, S7-1200, S7-1500, and the ET 200S CPU). On the S7-200 the equivalent feature is the Special Memory (SM) bits in the SMB area (e.g., SM0.5 with a 1 s period), and on the LOGO! logic module the function blocks provide equivalent flashing relays.
The 1:1 Pulse-Pause Ratio, Formally Defined
A pulse-pause ratio of 1:1 means that for any given bit n of the clock byte, the time the bit is at logical 1 (pulse) equals the time the bit is at logical 0 (pause). If the period is T seconds, the duty cycle is:
Duty = tON / T = tOFF / T = 0.5
For Bit 7 of the byte, the period is 2.0 s. Therefore the bit is ON for 1.0 s, OFF for 1.0 s, ON for 1.0 s, OFF for 1.0 s, and so on. The same logic applies to every other bit. The ratio is independent of the OB1 cycle time; the operating system toggles the bit when the elapsed time reaches T/2, regardless of whether the user program has just executed or not.
Bit-to-Frequency Assignment Table
The following table is the canonical assignment from the STEP 7 / TIA Portal online help. The byte is treated as a single register; the bits are independent of each other.
| Bit of Clock Memory Byte | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Period Duration (s) | 2.0 | 1.6 | 1.0 | 0.8 | 0.5 | 0.4 | 0.2 | 0.1 |
| Frequency (Hz) | 0.5 | 0.625 | 1.0 | 1.25 | 2.0 | 2.5 | 5.0 | 10.0 |
| tON = tOFF (s) | 1.000 | 0.800 | 0.500 | 0.400 | 0.250 | 0.200 | 0.100 | 0.050 |
| Duty Cycle (%) | 50 | 50 | 50 | 50 | 50 | 50 | 50 | 50 |
All eight frequencies are derived from a single time base by successive division by two (with a single odd divisor for bit 6). The exact internal implementation is firmware-specific, but the documented periods are guaranteed by Siemens for every supported CPU firmware version.
How to Configure the Clock Memory in STEP 7 (Classic)
In STEP 7 V5.x and SIMATIC Manager, the clock memory byte is configured at the CPU properties:
- Open the S7 Program folder and right-click the CPU (e.g., CPU 315-2 PN/DP).
- Select Object Properties.
- Open the Cycle/Clock Memory tab.
- Tick the Clock memory checkbox.
- Enter the byte address (commonly MB0, MB10, or MB100; any free M-byte is valid).
- Click OK and download the hardware configuration to the CPU.
The byte must not overlap with any other used M-byte, with the process-image partition used by the program, or with retentive data that you intend to preserve across a STOP→RUN transition. Clock memory is non-retentive; its state is undefined until the OB1 cycle resumes.
How to Configure the Clock Memory in TIA Portal (S7-1200 and S7-1500)
- In the project tree, expand the S7 device and double-click Device configuration.
- Select the CPU in the device view.
- In the inspector window, open Properties > System and clock memory (S7-1500) or Properties > Cycle (S7-1200).
- Tick Enable clock memory byte.
- Enter the Clock memory byte address (default often MB0; Siemens recommends an address in the range MB10–MB199 for S7-1500 to avoid overlap with optimized data and system bytes).
- Compile and download the hardware configuration.
Cross-Reference: Same Feature, Different Platforms
| Platform | Configuration Location | Default/Free Selection | Equivalent Special Memory |
|---|---|---|---|
| S7-300/400 (STEP 7 V5.x) | CPU Properties > Cycle/Clock Memory | Free selection of MB | n/a |
| S7-1200 (TIA Portal) | Device config > Properties > System and clock memory | Free selection, default MB0 | SM0.5 (1 s period) |
| S7-1500 (TIA Portal) | Device config > Properties > System and clock memory | Free selection | n/a |
| S7-200 (Micro/WIN) | Wizard > Configure Timed Interrupts (limited use) | n/a | SM0.0 always-ON, SM0.5 1 s clock, SMB34/SMB35 time-base interrupts |
| LOGO! (LOGO!Soft Comfort) | Function block (e.g., Wiping relay) | Free selection | Asynchronous pulse generator |
Typical Use Cases
The clock memory byte is intended for low-bandwidth periodic events where the exact phase relationship to OB1 is unimportant. Common applications include:
- Flashing beacons and indicator lamps (Bit 5 at 1.0 s is the canonical 1-second flasher).
- Heartbeat / life-bit monitoring: ladder code monitors one bit and raises an HMI alarm if it stops toggling for more than twice the period.
- Stochastic sampling: sample an analog value every 0.1 s (Bit 0) to capture fast temperature or pressure transients without engaging the full PID controller.
- Long-period clocks for operators (Bit 7 at 2.0 s) used as a cadence for machine status display.
- Watchdog reset for sub-systems that require a periodic handshake.
- Triggering periodic jobs in OB35 / cyclic interrupts when you do not want to configure a dedicated OB35 interval.
Example: LAD snippet that flashes Q0.0 at 1 Hz
Network 1:
M 5.0 Q 0.0
|--|/|----------( )--|
(clock bit 5 = 1.0 s period)
Because the duty cycle is exactly 50%, the contact M5.0 closes for 1 s and opens for 1 s, producing a 1 Hz square wave on the output.
Example: SCL block that toggles a 2 Hz heartbeat for an HMI tag
IF "Clock_Memory_Byte".%X3 THEN // Bit 3 = 2 Hz
"HMI_Heartbeat_OK" := TRUE;
ELSE
"HMI_Heartbeat_OK" := FALSE;
END_IF;
The Restart Phase-Offset Problem (Critical Edge Case)
Engineers frequently try to use clock memory as a free timer replacement by counting edges. The field report surfaces an important limitation: the phase of every clock bit is undefined at STOP→RUN.
Concretely, if you wire Bit 5 (1.0 s period) to a counter, the first edge after restart can arrive anywhere from 0 ms to 1000 ms after the CPU enters RUN, depending on what phase the OS scheduler was in at the moment of the transition. Over many restarts the average error is half the period (0.5 s for Bit 5), and the worst case is a full period (1.0 s).
This is acceptable for indicator lamps and watchdog handshakes but is not acceptable for any measurement where you need an absolute time reference (e.g., "measure temperature every 60 seconds exactly"). Use a true cyclic interrupt OB instead:
| Requirement | Use Clock Memory | Use Cyclic OB |
|---|---|---|
| Flashing beacon, cadence OK | Yes | Overkill |
| Periodic edge counter | Yes if 0.5*T error acceptable | Better |
| Time-of-day scheduling | No | Yes (OB10 + TOD) |
| Long-period > 2.0 s | No (not available) | Yes (OB35 / OB30 series) |
| Sub-100 ms sampling | No (Bit 0 = 100 ms minimum) | Yes (OB30 at 5 ms supported on S7-1500) |
| Retentive counter across power off | No | Yes with retentive CTU |
Sample-ST Code: Edge-Counting with Restart Correction
If you must use clock memory for an edge counter, correct for the phase offset on startup. The following SCL block in an S7-1500 waits for the first 0→1 transition of Bit 5 and then re-syncs a 1-second IEC timer.
REGION EdgeCounter
// Detect rising edge of clock bit 5 (1 Hz)
IF "Clock_Byte".%X5 AND NOT "Edge_Memory" THEN
"Edge_Count" := "Edge_Count" + 1;
// First rising edge after RUN: start a 1 s IEC timer to lock phase
IF NOT "Phase_Locked" THEN
"Phase_Locked" := TRUE;
"Phase_Timer" (IN := TRUE, PT := T#1S);
END_IF;
END_IF;
"Edge_Memory" := "Clock_Byte".%X5;
// Phase-locked IEC timer replaces free-running counter
IF "Phase_Timer".Q THEN
"Phase_Timer" (IN := FALSE);
"Locked_Pulse" := NOT "Locked_Pulse";
END_IF;
END_REGION
This pattern eliminates the 0–1 s startup error because the IEC timer is started from the first observed clock edge; all subsequent pulses are aligned to that phase.
Interactions with Process Image, Retain, and Optimized Access
- Process image (PII / PIQ): Clock memory is updated by the OS at the start of OB1. Bits reside in the bit memory (M) area and are visible to all program blocks without explicit PI loading.
- Retain attribute: Clock memory is implicitly non-retentive. The retain setting on the M-byte is ignored for the clock byte. Do not mark the clock byte as retentive.
- Optimized block access (S7-1500): You cannot declare M as a fully optimized area. Access the clock byte through a global DB with standard (non-optimized) access, or address MB<n> directly via the absolute name.
- HMI polling: HMI tags pointed at the clock byte generate high HMI traffic because every poll sees the bit toggling. Limit the polled area to non-toggling bits, or use a heartbeat tag derived in the PLC code (e.g., an M-bit that mirrors clock bit 5).
Verification Procedure
- Download the hardware configuration with the clock byte enabled.
- Open an online watch table in STEP 7 / TIA Portal and add the clock byte as a binary display.
- Force the CPU to RUN if not already running.
- Confirm Bit 5 toggles every 1.0 s ±10 ms (the tolerance is bounded by the OB1 cycle).
- Measure Bits 0 (0.1 s) and Bit 7 (2.0 s) for the bookends.
- Trigger a STOP→RUN transition and observe Bit 5: it must resume toggling, but the next edge may arrive up to 1.0 s after RUN.
- Verify that no other code is writing to MB<n> — a stray MOVE or SET coil anywhere will break the toggling.
Troubleshooting Matrix
| Symptom | Likely Cause | Corrective Action |
|---|---|---|
| Clock byte never toggles | Clock memory not enabled in CPU properties, or wrong byte number downloaded | Re-open Device configuration > System and clock memory and verify the checkbox and address |
| Clock byte toggles for a few seconds then freezes | User program is writing to the M-byte (e.g., L / T instruction, SET/reset coil) | Search the project for any access to MB<n> and remove it |
| Period is wrong (e.g., 2 s instead of 1 s) | Wrong bit being monitored | Recount: Bit 7 = 2.0 s, Bit 5 = 1.0 s, Bit 0 = 0.1 s |
| Toggling visible only after CPU restart | Configuration not downloaded (only compiled) | Right-click device > Download to device > Hardware configuration |
| S7-1500 byte is unreadable in optimized DB | Optimized block access hides MB addresses | Create a standard-access DB and declare an M-area tag, or address MB<n> absolutely |
| Counter drift in long-running count | Phase-offset at restart propagated into a CTU | Replace free-running counter with phase-locked IEC timer; see SCL example above |
| Clock byte overlaps with retentive data | Byte address collides with retain-tagged area | Move the clock byte to a free M area; ensure non-overlap with the retain bit memory range |
Field-Commissioning Checklist
- Clock memory enabled in CPU properties and downloaded.
- Clock byte address documented and unique to clock function (no overlap).
- Watch table confirms Bit 5 toggles at 1 Hz, Bit 0 at 10 Hz, Bit 7 at 0.5 Hz.
- Program code does not write to the byte.
- No optimized-block conflicts on S7-1500.
- HMI tags are limited to relevant bits to avoid wasted bandwidth.
- Counter-based applications either accept the ±0.5 T phase error or use a phase-locked IEC timer.
- Restart behavior observed and documented in the project functional specification.
Related Functions Worth Knowing
- Time-of-day interrupts (OB10): for absolute scheduling, e.g., "run report at 23:59 every Sunday".
- Cyclic interrupts (OB30–OB38): for high-priority periodic tasks; selectable phase and period from 1 ms to 60 s depending on CPU.
- Hardware timer DI / DO modules: for high-frequency counters independent of the OB1 scan.
- PWM / PTO outputs: for variable duty cycle and pulse-train applications (NOT 1:1 ratio).
- IEC timers (TP, TON, TOF, TONR): for general timing inside user program blocks.
What does "pulse-pause ratio of 1:1" actually mean in an S7 clock byte?
It means each clock bit is in the ON (logic 1) state for exactly half of its period and in the OFF state for the other half. For Bit 5 with a 1.0 s period, the bit is ON for 0.5 s and OFF for 0.5 s, producing a 1 Hz square wave with a 50% duty cycle.
What frequencies does the S7 clock memory byte provide?
Eight frequencies, one per bit: Bit 7 = 0.5 Hz (2.0 s), Bit 6 = 0.625 Hz (1.6 s), Bit 5 = 1 Hz (1.0 s), Bit 4 = 1.25 Hz (0.8 s), Bit 3 = 2 Hz (0.5 s), Bit 2 = 2.5 Hz (0.4 s), Bit 1 = 5 Hz (0.2 s), Bit 0 = 10 Hz (0.1 s). All eight are independent and toggle simultaneously.
How do I enable the clock memory byte in TIA Portal?
Open Device configuration, select the CPU, go to Properties > System and clock memory, tick Enable clock memory byte, set the address (commonly MB0 or MB10), compile, and download the hardware configuration to the CPU. The byte is updated by the operating system as soon as the CPU enters RUN.
Why does my counter drift by up to one second after every CPU restart?
The phase of every clock bit is undefined when the CPU transitions STOP to RUN, so the first rising edge after restart can arrive up to one full period (1.0 s for Bit 5) later. Average error is half the period. This is intrinsic to clock memory; use a cyclic interrupt OB or a phase-locked IEC timer if you need absolute timing.
Can I use the clock memory as a PWM output?
No. Clock memory is a fixed 1:1 ratio that cannot be changed at runtime. For variable duty cycle use the PWM output on an S7-1500 SB or onboard DQ module; for pulse trains use PTO. Both are configured in Device configuration and have their own set of parameters independent of the clock memory byte.