S7-200 Periodic Pulse Output: Timer Setup and PWM Methods

David Krause18 min read
S7-200SiemensTutorial / How-to
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

1. Problem Definition and Functional Requirements

The classic S7-200 periodic-pulse problem is small enough to be ignored in textbooks and large enough to expose a number of platform-specific gotchas. The functional specification is: a CPU in the SIMATIC S7-200 family must issue a fixed 4-second output pulse repeatedly. The repetition period is selected by two binary inputs (four possible periods), and a third binary input acts as a master inhibit. The pulse must be repeatable, deterministic, and survive the inevitable edge case where the inhibit arrives mid-pulse.

Decoupling the requirement into primitives gives the engineer a checklist before any code is written:

  • Pulse width: 4.000 s, fixed, no modulation required.
  • Pulse repetition period: 1 of 4 values, selected by inputs I_x and I_y.
  • Master inhibit: I_z = 0 freezes the output and prevents a new pulse from starting. I_z = 1 allows the cycle to run.
  • Behavior at inhibit-true mid-pulse: the specification should explicitly state whether the active 4 s pulse is allowed to complete or must be truncated. Both behaviors are easy to implement; the difference is whether the reset path of the pulse timer is gated by I_z.
  • Behavior when period-select inputs change while running: the implementation must decide between immediate update (re-loads the period) and update-on-next-cycle (the change takes effect after the current period expires).
Lock these five items down in writing before writing a single rung. The S7-200 timer and PWM subsystems are deterministic but unforgiving, and re-architecting ladder logic after the panel is wired is a costly exercise.

2. S7-200 Hardware Platform Selection

The S7-200 label covers two distinct hardware generations. Choosing the correct CPU determines which instruction set, time bases, and PWM channels are available.

CPU Generation User program Data memory Onboard PWM outputs Notes
CPU 212 21x 1 KB 512 bytes None Entry level, no PWM.
CPU 214 21x 2 KB 2 KB None Lacks PWM; timer-based only.
CPU 215 21x 4 KB 2.5 KB None Adds PROFIBUS-DP slave.
CPU 221 22x 2 KB 2 KB 2 (Q0.0, Q0.1) Replacement for 212.
CPU 222 22x 2 KB 2 KB 2 (Q0.0, Q0.1) Adds signal-board support.
CPU 224 22x 4 KB 5 KB 2 (Q0.0, Q0.1) Typical machine-control CPU.
CPU 224XP 22x 6 KB 10 KB 2 + 1 high-speed Adds 100 kHz HSC and Q0.3/Q0.5.
CPU 226 22x 6 KB 10 KB 2 (Q0.0, Q0.1) 40-point, dual port.

The 22x generation is recommended for any new machine. The 21x series has been obsolete for over a decade and a half and is no longer supported with firmware updates or new STEP 7 Micro/WIN project files. Field-replacement must use the 22x or the modern S7-200 SMART (which uses a different instruction set and is not binary-compatible).

If the panel label says "S7-200" and the part number begins with 6ES7 212-, 214-, or 215-, treat it as legacy hardware. Plan the timer/PWM logic against the 22x system manual even if you must ship a 214 on this build.

3. Timer Fundamentals on the S7-200

Unlike a Siemens S5 or S7-300/400, the S7-200 does not let the programmer pick a time base per timer. The time base is fixed by the timer number, not by a parameter. Engineers who learned ladder on the S5 consistently trip over this.

Timer type Numbers Resolution Maximum preset Maximum interval
TON / TOF (1 ms) T32, T96 1 ms 32 767 32.767 s
TONR (1 ms) T0, T64 1 ms 32 767 32.767 s
TON / TOF (10 ms) T33–T36, T97–T100 10 ms 32 767 327.67 s
TONR (10 ms) T1–T4, T65–T68 10 ms 32 767 327.67 s
TON / TOF (100 ms) T37–T63, T101–T255 100 ms 32 767 3 276.7 s
TONR (100 ms) T5–T31, T69–T95 100 ms 32 767 3 276.7 s

Key constraints that drive the implementation:

  • The PT (preset) value of a timer is a 16-bit signed integer. The maximum value is 32 767, which combined with the resolution gives the maximum interval per row above.
  • The PT input is normally a constant, but the S7-200 permits a variable PT connected to a VW (variable word) or MW (marker word). This is the only practical way to change the period from inputs at runtime.
  • The ET (elapsed time) is updated by the scan cycle. On a 1 ms resolution timer, the actual bit transition is decoded inside the CPU and reflected in the next scan, so a 4 s pulse driven by a T37 (100 ms) has a worst-case 100 ms jitter relative to the requested edge.
  • A self-resetting timer (a TON whose enable contact is its own NC bit) introduces additional rules. The section on self-resetting timers below covers them in detail because they are the single most common source of subtle bug reports on the S7-200.

4. Method A — Standard Timer with Variable PT

This is the method that maps most cleanly onto the question: a TON with a variable PT selected by two binary inputs, plus a master inhibit. It works on every CPU from the 214 onward.

4.1 Memory map

Symbol Address Width Purpose
I_period_A I0.0 1 bit Period select, LSB.
I_period_B I0.1 1 bit Period select, MSB.
I_inhibit I0.2 1 bit 1 = enabled, 0 = inhibit.
VW_period VW200 16 bit Holds the current PT in 100 ms units.
T_pulse T37 100 ms 4 s pulse timer (PT=40).
T_period T38 100 ms Repetition period timer (PT=variable).
M_run M0.0 1 bit Latched "cycle running" flag.
Q_pulse Q0.0 1 bit Pulse output.

4.2 Period-preset table

Two inputs give four codes. Pick four real periods that suit the application, multiply by 10 to get 100 ms counts, and load them into four VW constants. The example uses 10 s, 30 s, 60 s, 120 s.

I_period_B I_period_A Period (s) VW constant (× 100 ms)
0 0 10 100
0 1 30 300
1 0 60 600
1 1 120 1 200

4.3 Network-by-network ladder

Write this in STEP 7 Micro/WIN V4.0 SP9 or later. Micro/WIN stores projects as .mwp and exports to .awl for offline review.

  1. Network 1 — period select via four MOV_W instructions. Use I0.0 and I0.1 as contacts in series for each branch, then a MOVW of the constant into VW200. The four branches load 100, 300, 600, or 1200 depending on the input code. Leave the rung un-conditional so the period is updated on every scan; the variable will simply be rewritten with the same value if the inputs do not change.
  2. Network 2 — master inhibit and run latch. SET M0.0 on the rising edge of I0.2 (use EU, edge-up). RESET M0.0 on the falling edge of I0.2 (use ED, edge-down). This gives a clean enable flag rather than tracking a level.
  3. Network 3 — pulse timer T37. IN = M0.0 AND NOT Q0.0 (the latter prevents re-trigger while a pulse is already in progress). PT = 40 (4 s × 10 ticks). When T37 reaches 4 s, it sets Q0.0 directly through its own contact if you drive Q0.0 from T37's bit, or, more cleanly, with a SET/RESET on Q0.0 gated by the T37 contact.
  4. Network 4 — period timer T38. IN = M0.0. PT = VW200. When T38 done, it resets M0.0 and Q0.0. On the next scan, M0.0 is re-asserted by the edge of I0.2 (which is still high) and the cycle restarts.

4.4 The self-resetting timer caveat

When a TON's enable contact is the timer's own NC contact, the S7-200 update mechanism in firmware versions prior to REL_22 deviates from the IEC 61131-3 model by one scan: the bit transition is latched at the start of the next scan, not at the moment the elapsed time crosses the preset. Three rules avoid the bug:

  1. Do not place a 1 ms timer (T32, T96, T0, T64) in a self-resetting path. Use a 10 ms or 100 ms timer so the bit-decoding latency is at most one tick of the resolution you are counting.
  2. Use a separate DONE bit (a marker or Q output) and reset the timer explicitly from that bit in the next network, rather than relying on a NC contact on the timer bit to break the IN path.
  3. Verify on the bench with a stopwatch that the actual pulse width matches PT × resolution to within one resolution tick. If you see 4.1 s when you asked for 4.0 s, the timer is in self-reset mode and you have the firmware-bug variant.

5. Method B — PWM Output Subsystem

The S7-200's PWM output is a hardware peripheral, not a ladder construct. It runs in the background and continues to produce the configured waveform regardless of scan time, which makes it the correct choice for any pulse output that must be jitter-free or that runs faster than 100 ms.

5.1 PWM specification

Parameter Range Resolution
Cycle time (microsecond mode) 250 – 65 535 µs 1 µs
Cycle time (millisecond mode) 2 – 65 535 ms 1 ms
Pulse width (microsecond mode) 0 – 65 535 µs 1 µs
Pulse width (millisecond mode) 0 – 65 535 ms 1 ms
Duty cycle 100 % pulse width = cycle time
Duty cycle 0 % pulse width = 0
Minimum functional cycle 2 time units (failsafe default)

On a CPU 224, the two PWM channels are Q0.0 (PWM0) and Q0.1 (PWM1). On a CPU 224XP, the high-speed PWM on Q0.3 is configured by the same PLS instruction but accepts PTO mode as well.

5.2 Configuring PWM0 with the PLS instruction

PWM is set up by writing a control byte (SMB67 for PWM0, SMB77 for PWM1) and then loading cycle and pulse-width words (SMW68 / SMW70) before issuing PLS. The control byte selects microsecond vs millisecond mode, whether the time base is updated, and whether the output runs continuously or for a fixed pulse count.

Network 1 — one-shot initialization on first scan
      SM0.1                MOVB   16#C1, SMB67   // 1100 0001: enable PWM0, ms mode, continuous
      |                    MOVW   +1000, SMW68   // 1 s cycle
      |                    MOVW   +4000, SMW70   // 4 s pulse width (40 % duty)
      |                    PLS    0              // write configuration to PWM0

Network 2 — inhibit via PWM enable bit in SMB67
      I_inhibit (I0.2)      MOVB   16#C1, SMB67   // bit 7 = 1, PWM0 active
      |                     PLS    0
      NOT I_inhibit         MOVB   16#41, SMB67   // bit 7 = 0, PWM0 gated off
      |                     PLS    0

Setting bit 7 of SMB67 to 0 freezes the waveform at its current level. Setting it to 1 resumes the waveform from the last cycle edge. The transition is not glitch-free; if a deterministic phase relationship to the inhibit input is required, gate the Q0.0 output with an external relay or use the inhibit to load a 0-pulse-width value (output held low) instead of disabling PWM0 entirely.

5.3 Variable period with PWM

Because the cycle and pulse-width words are writable at any time, a period-select network identical to the one in Method A can load SMW68 (cycle) and SMW70 (pulse width) from a lookup, then re-issue PLS to apply. The change takes effect at the next cycle boundary, so the new period is phase-coherent rather than abrupt.

If the period selection inputs can change more than once per cycle, debounce them with a TON of 50 ms and write to SMW68 only when the debounced selector value is stable. Otherwise a noisy selector input will produce a continuously-shifting cycle time and the load will read as a varying-frequency output on a scope.

6. SMO and SMB Special Memory Bits for Pulse Generation

The S7-200 exposes a number of fixed-frequency clock bits that can simplify the period-select logic or drive a base timebase. The relevant bits for pulse work are:

Bit Period Duty Typical use
SM0.4 60 s 50 % (30 s on / 30 s off) Slow heartbeat, 1-minute flag.
SM0.5 1 s 50 % (0.5 s on / 0.5 s off) 1 s blink.
SM0.6 2 s (off) Single-cycle pulse, scan on, next scan off Edge source.
SM0.7 2 s (on) Single-cycle pulse, scan off, next scan on Edge source.

SM0.5 in combination with a counter gives a 4 s pulse without any explicit TON: count four rising edges, set the output, count four more, reset. The counter is the CTU with C0..C255. Preset the counter to 4, the 1 s clock gives the resolution, and the output is a clean 4 s pulse on every fourth second.

7. Inhibit Logic and Edge-Case Behaviour

The question of what happens when the inhibit arrives mid-pulse is the only place this application can have a hidden trap. There are three valid behaviours, each with a different implementation:

Behaviour Implementation Use case
Hard abort — output drops the moment inhibit goes false. Reset Q0.0 on NOT I_inhibit; do not gate the reset on T37 done. Safety stop, no retrigger until inhibit is removed and re-asserted.
Complete-then-freeze — current 4 s pulse runs to completion, no new pulse starts. Gate M0.0 with I_inhibit; do not touch Q0.0 while T37 is timing. Process calls for a minimum cycle length even on operator abort.
Complete-then-recover — current 4 s pulse runs to completion, then normal cycle resumes. Use a rising-edge detector on I_inhibit falling to latch a "skip one cycle" flag; the next T38 done clears the flag. Semi-automatic press cycle.

Document the chosen behaviour in the I/O list. Field commissioning goes wrong most often when the customer and the integrator have different mental models of the abort case.

8. State-Machine View

For documentation and for HMI display, a four-state machine captures every transition cleanly:

IDLE inhibit = 0 ARMED inhibit = 1, Q=0 PULSE Q=1, T37 timing WAIT Q=0, T38 timing inhibit↑ T38 done T37 done T38 done inhibit↓ (hard abort)

The diagram is a documentation aid only; the ladder logic does not need an explicit state register on a CPU 224, where the M0.x and timer bits serve the same role.

9. STEP 7 Micro/WIN Project Setup

  1. Launch STEP 7 Micro/WIN. Confirm the project is set to the correct CPU type under CPU > Type. The wrong CPU type is the most common reason for an apparently correct program to refuse to download.
  2. Open Tools > Options > STL/Micro/WIN and enable instruction tree view; the PLS, TON, CTU, and MOVW blocks are all in the Instructions tree.
  3. Use the Symbol Table to assign every address (I0.0, M0.0, T37, VW200) a meaningful name. The project becomes searchable and the cross-reference (Ctrl+F3) jumps directly to the rung.
  4. Compile with Ctrl+B. A clean compile with zero errors is required before download. Warnings about duplicate coil assignments or unreachable rungs are a hint that the timer and inhibit logic have a race condition.
  5. Download with the PC/PPI cable (RS-485) or, on 22x CPUs, an Ethernet CP 243-1 module if installed. Set the PPI address to 2 (the S7-200 default) and the baud to 9.6 kbps for legacy 21x or 187.5 kbps for 22x.
  6. Switch to Online > Monitor (Ctrl+M). Watch T37, T38, VW200, and Q0.0 in real time. Trigger the inputs from the Status Chart to validate the full matrix.

10. Verification and Commissioning Procedure

Step Action Pass criterion
1 Force inhibit high; select period = 10 s. Q0.0 cycles on for 4.0 s ± 100 ms, off for 6.0 s ± 100 ms.
2 Switch to period = 120 s without disturbing inhibit. New period takes effect on next cycle; no glitches on Q0.0.
3 Force inhibit low while Q0.0 is high. Output behaviour matches the documented abort case.
4 Force inhibit low while Q0.0 is low. No new pulse starts while inhibit is low.
5 Re-assert inhibit. Pulse cycle resumes within one scan of the rising edge.
6 Toggle period inputs while cycle is running. Cycle continues with previous period; new period applies on next cycle (or per spec).
7 Power-cycle the CPU. On restart, SM0.1 fires once, period is reloaded, inhibit starts low (or as configured), no spurious output pulses.

For a PWM-based implementation, repeat steps 1–7 with a 100 MHz oscilloscope on Q0.0. Verify that the cycle time matches the loaded value within ±1 µs and that the pulse width is exactly 4 s within the configured resolution.

11. Troubleshooting Matrix

Symptom Likely cause Fix
No output at all. Wrong CPU type selected in Micro/WIN; program does not run. Re-select the CPU under CPU > Type, recompile, re-download.
Output stuck high. SET on Q0.0 with no corresponding RESET, or T37 done bit cannot clear because IN is held by the timer bit itself. Add explicit RESET rung; check self-resetting pattern.
Pulse width is 4.1 s instead of 4.0 s. Self-resetting timer firmware quirk. Switch to 10 ms or 100 ms timer; use external DONE bit for reset.
Period selector does nothing. VW200 not reloaded; or PLC value out of range. Check that all four MOVW branches use unique enable contacts; status-chart monitor VW200.
PWM channel does not start. SMB67 control byte not written; PLS issued before SMB67. Reorder: write SMB67, write SMW68, write SMW70, then PLS.
PWM period jitters. Selector input bouncing; SMB67/77 rewritten inside scan. Debounce inputs; rewrite the control byte and PLS only on edge of selector change.
Inhibit ignored on a 21x CPU. PWM not available; only timer-based output. Move to timer-based Method A; consider CPU 224 upgrade.
Output pulse continues after inhibit goes low. Inhibit is gating the enable but not the reset path. Add NOT I_inhibit to the Q0.0 reset rung; behaviour is now "hard abort".

12. Migration to S7-200 SMART and S7-1200

If the machine is being re-engineered rather than maintained, two paths exist:

  • S7-200 SMART (CPU SR20 / ST40 / SR60): drop-in replacement for 22x projects. The S7-200 SMART keeps the same instruction set but uses STEP 7 Micro/WIN SMART, adds Ethernet, and supports the same PWM and PTO/PWM peripherals on Q0.0 and Q0.1. The migration tool in Micro/WIN SMART imports the .mwp file and flags incompatible instructions.
  • S7-1200 (CPU 1211C through 1215C): a new project in TIA Portal. The 4 s pulse with variable period collapses into one or two IEC timers with a wider resolution (1 ms default) and the PWM is configured in the device configuration rather than via SMB control bytes.

For brand-new design work, do not start on the S7-200. The platform is in mature maintenance, the documentation set is frozen, and the engineering community is shrinking. Start on the S7-1200 or S7-1500 and treat any S7-200 work as a sustaining-engineering task.

13. Field-Notes Caveats

  • The 21x CPU does not have an EEPROM for the program; battery-backed RAM is the only persistence. If the battery dies, the program is lost and the CPU starts in a stopped state. The 22x has an integrated EEPROM and survives a dead battery.
  • The PPI cable's RS-485 transceiver is 5 V tolerant on the S7-200 side but not on every laptop. Use a USB/PPI or USB/MPI cable with isolation; the un-isolated variant is a known cause of laptop RS-232 port failures.
  • Micro/WIN V4.0 SP9 is the last version that supports the 21x series. If you are on SP5 or earlier and a customer is on a 215, update to SP9 before doing more than a status-chart read.
  • Wiring a relay or solenoid to Q0.0 without a snubber diode across the coil will inject 50–200 V transients on every pulse edge. The 22x outputs are not optoisolated, and repeated transients have been known to damage the high-side driver. Always add a 1N4007 (DC) or MOV (AC) across the coil.

What is the simplest way to get a 4 s pulse on an S7-200?

Use a 100 ms timer T37 with PT = 40 (4.0 s). IN = enable, OUT drives Q0.0. The T37 bit is high for exactly 4.0 s ± 100 ms from the moment IN transitions high. On the 22x CPUs you can use a PWM output on Q0.0 instead for jitter-free hardware timing.

How do I change the period at runtime from two inputs?

Use four MOVW instructions, each gated by a different combination of the two input bits, to write one of four preset constants into VW200. Then connect VW200 to the PT input of a 100 ms period timer. The constant must be the desired seconds × 10 (so 10 s = 100, 30 s = 300, 60 s = 600, 120 s = 1200). Document the four values in the I/O list.

Why is my self-resetting pulse timer off by one tick?

The S7-200 firmware updates a timer's bit on the next scan, not at the exact moment the elapsed time crosses the preset. When a TON drives its own IN contact through an NC branch, the one-tick latency is repeated on every cycle, which shows up as a pulse that is one resolution unit longer than PT × resolution. The fix is to use a 10 ms or 100 ms timer (where one tick is 10–100 ms, not 1 ms) and to reset the timer from an explicit DONE bit rather than from its own NC contact.

Which S7-200 CPUs have PWM outputs?

All 22x CPUs (221, 222, 224, 224XP, 226) have two PWM channels on Q0.0 and Q0.1. The 224XP adds a high-speed PWM on Q0.3. The older 21x series (212, 214, 215) has no PWM and must use timer-based logic. Configure PWM with the PLS instruction after writing SMB67 (PWM0) or SMB77 (PWM1) and the cycle/width words SMW68/SMW70.

Can the inhibit input abort a 4 s pulse in progress?

It depends on how the reset is wired. If the inhibit also resets Q0.0 directly, the pulse is truncated the moment the inhibit goes low. If the inhibit only gates the enable, the current pulse runs to its 4 s completion and no new pulse starts. Both are valid; choose one and document it explicitly so the customer's expectations match the integrator's implementation.

What is the difference between the S7-200 and the S7-200 SMART?

The S7-200 SMART is a newer platform designed as a drop-in replacement for the 22x series with built-in Ethernet, the same PWM/PTO peripherals, and a refreshed programming tool (STEP 7 Micro/WIN SMART). It is not binary compatible with the original S7-200: project files must be imported through the migration wizard. For new design work use the S7-1200 or S7-1500 instead, as the S7-200 family is in mature maintenance with no new development.

Back to blog