Problem Details
A plant engineer commissioning a SANMOTION SH1603 two-phase bipolar stepper motor on a Siemens S7-1200 CPU 1212DC/DC/DC (firmware V4.x) using TIA Portal V10.5 cannot push the on-board pulse output above 1 kHz. The stepper driver requires a 24 V DC pulse-and-direction command stream of 0 Hz to 10 kHz. With the standard CTRL_PWM instruction the engineer measures a hard ceiling near 1 kHz regardless of the cycle-time parameter entered in the PWM configuration dialog. A second subsystem, a Keyence SR-610 barcode reader connected through an N-R2 RS-232C module, must also be integrated on the same PLC program.
The engineer attempted to follow Siemens Entry ID 38391227 but the example project supplied was created for TIA Portal V11 (Step 7 Basic V11) and would not import cleanly into the V10.5 SP2 environment available on the engineering workstation. The local search was performed against the legacy URL support.automation.siemens.com, which has since been redirected to support.industry.siemens.com.
Root Cause
The S7-1200 PWM function is being used where PTO (Pulse Train Output) is the correct technology. CTRL_PWM is a variable duty-cycle block intended for slow process control (heating elements, proportional valves, LED dimming). Its internal minimum pulse width (the smallest ON time the output hardware can resolve) is enforced by the configuration dialog and by the output-stage timing. When the requested cycle time forces the ON time below this minimum, the firmware holds the previous valid value and the apparent maximum frequency collapses to 1/(2 × t_min_pulse).
For the standard CPU 1212C outputs running the default PWM profile, this minimum pulse width is approximately 1 ms, which limits usable PWM to roughly 500 Hz at 50% duty and to 1 kHz absolute at very small duty cycles once you account for the half-period resolution step. That is exactly the symptom reported.
For stepper pulse-and-direction control the correct primitive is CTRL_PTO, which is a high-speed hardware counter engine that uses the output hardware in PTO mode (also referred to as FM (Frequency Modulation) in older Siemens documentation). PTO bypasses the PWM minimum-pulse-width enforcement and exposes a frequency range of 0.5 Hz to 100 kHz on the CPU 1212C on-board outputs, with separate pulse-count and integrated ramp parameters.
CPU 1212C DC/DC/DC Hardware Reference
All output specifications below are taken from the SIMATIC S7-1200 manual collection hosted on TIA Siemens Cloud – CPU 1212C technical specifications and the System Manual entry S7-1200 Programmable Controller (109741593).
| Parameter | Value |
|---|---|
| Order number (DC/DC/DC) | 6ES7212-1AE40-0XB0 (Firmware V4.x) |
| On-board digital outputs | 6 transistor outputs (sourcing), Q0.0 to Q0.5 |
| Output voltage range | 20.4 V DC to 28.8 V DC |
| Rated output current per channel | 0.5 A continuous |
| Inrush current | 5 A for 100 ms |
| Leakage current (off) | ≤ 10 µA |
| High-speed outputs (PTO/PWM capable) | Q0.0, Q0.1, Q0.2, Q0.3, Q0.4, Q0.5 |
| PTO max frequency (on-board) | 100 kHz |
| PWM max frequency (on-board) | 100 kHz (limited by minimum pulse width) |
| Minimum PTO pulse width | 5 µs |
| Signal board SB 1223 high-speed I/O | 200 kHz (PTO), 200 kHz (PWM) |
| Max PTO pulse count | 2,147,483,647 (32-bit signed) |
The CPU 1212DC/DC/DC variant is the transistor-output model. The relay-output variant (DC/DC/RLY) cannot be used for PTO/PWM because the electromechanical relay cannot switch at the required rates. Confirm the part number suffix is -1AE40- or -1BE40- before proceeding.
PWM vs PTO on the S7-1200
| Feature | CTRL_PWM (PWM) | CTRL_PTO (PTO) |
|---|---|---|
| Intended use | Variable duty cycle (heat, light, valve) | Stepper / servo pulse-and-direction |
| Frequency range | 1 Hz to 100 kHz hardware, but t_min_pulse limits effective ceiling | 0.5 Hz to 100 kHz on-board |
| Effective ceiling at default min pulse | ~1 kHz | 100 kHz (no minimum-pulse-width cap) |
| Output type | Single fixed output | Pulse output + direction output |
| Pulse count control | None (continuous modulation) | Up to 2,147,483,647 pulses per run |
| Acceleration/deceleration ramp | None | Integrated, configurable in steps/s² |
| Hardware counter | Not used | Uses HSC channel of selected output |
| Direction output | User must allocate separately | Allocated automatically when configured |
| Jerk-limited profile | No | Yes (PTO profile table) |
Solution: Migrate from CTRL_PWM to CTRL_PTO
The fix is to delete the PWM configuration on the output channel and reconfigure the same physical output as a PTO. Both functions live on the same hardware channel of the CPU 1212C, so no wiring changes are required; only the device configuration and the program logic change.
Prerequisites
- SIMATIC S7-1200 CPU 1212DC/DC/DC, firmware V3.0 or later (V4.x recommended for full feature set). Firmware can be verified in Online & Diagnostics → Module Information → Firmware.
- STEP 7 Basic V10.5 SP2 (or migrate the project to V13/V14/V15/V16/V17 to access newer PTO features; the program logic described is portable across versions).
- SANMOTION SH1603 bipolar stepper with compatible 24 V DC pulse-and-direction driver (e.g., Sanmotion Q series, Oriental Motor CVD, or equivalent).
- 24 V DC logic supply with adequate inrush margin. CPU 1212C draws 1.0 A typical from the 24 V DC sensor supply; the driver electronics typically require an additional 0.5 A to 2 A.
- TIA Portal project with the CPU 1212C added to the device tree and the standard PLC tags created.
Step-by-Step Configuration in TIA Portal V10.5
- Open the device configuration of the CPU 1212C. In the project tree, expand PLC_1 → Device configuration.
- Select the high-speed output channel. Click on the digital output DQa you intend to use (Q0.0 is the canonical PTO0 channel on the CPU 1212C). Q0.1 becomes the direction output automatically.
- Open the Properties pane for the channel. Navigate to Properties → Outputs → Pulse generator (PTO/PWM).
- Switch from PWM to PTO. Set the mode selection to PTO (Pulse Train Output). The dialog expands to reveal the PTO0 sub-properties.
- Configure PTO0 pulse output. Set Pulse output = DQa (Q0.0). Set Direction output = DQb (Q0.1).
- Set the high-speed counter resource. TIA assigns HSC 1 to PTO0 by default. Confirm this is not conflicting with another HSC; if it is, choose HSC 2 (PTO1) or HSC 3 (PTO2).
- Confirm the I/O filter on the direction output. Set the direction output filter to Off or 0.1 µs; never leave the 6.4 ms default filter in place, otherwise the direction changeover will lag the pulse and the motor will stall at high speeds.
- Compile and download the hardware configuration. The output channel is now reserved for PTO and cannot be written with a normal Q-assignment.
- Insert the CTRL_PTO instruction in the OB1 (or OB35 cyclic interrupt at 10 ms). Drag Instructions → Motion Control → Pulse → CTRL_PTO into the network.
- Wire the CTRL_PTO inputs. Connect the parameters as shown in the table below.
CTRL_PTO Interface Wiring
| Parameter | Direction | Data type | Wiring |
|---|---|---|---|
| EN | Input | BOOL | Connect to logic enable |
| PTO | Input | INT | Constant 0 (= PTO0, hardware channel Q0.0) |
| ENABLE | Input | BOOL | TRUE to permit pulse generation |
| BUSY | Output | BOOL | TRUE while ramp or pulses are active |
| ERROR | Output | BOOL | TRUE on configuration error |
| STATUS | Output | WORD | Diagnostic word (see table) |
| FREQ | Input | DINT | Target frequency in Hz (1 to 100000) |
| NUM_PULSES | Input | DINT | Pulse count, 0 = continuous, >0 = finite run |
| DIR | Input | BOOL | Direction (0/1) |
| RAMP_TYPE | Input | BOOL | 0 = linear, 1 = S-curve |
| ACCEL | Input | DINT | Acceleration in pulses/s² |
| DECEL | Input | DINT | Deceleration in pulses/s² |
Sample Ladder Snippet
Network 1: PTO0 Enable and Speed Command
| M10.0 M10.1 DB1.DBX0.0 DB1.DBD4
--| |-----------| |------------( )-----------| |
| RUN EN_OK CTRL_PTO_DB
|
| DB1.DBD4 = target frequency in Hz (DINT)
| DB1.DBD8 = pulse count (0 = continuous)
| DB1.DBX12.0 = direction bit
Network 2: Set frequency from integer tag
| M10.2
--|/|-----------[MOVE EN]
| IN := MW20 // scaled 0–10000 Hz
| OUT := DB1.DBD4
Mapping the 0–10 kHz Speed Reference
The driver accepts a pulse frequency between 0 Hz and 10 kHz. To run the stepper at its rated speed you should derive the target frequency from a per-second count of step pulses required to advance one revolution. If the SH1603 is set to 1000 step/rev (full step, no microstep), then 10 kHz equals 600 RPM. If the driver is set to 8000 step/rev (typical 1/8 microstep), then 10 kHz equals 75 RPM. The PLC program should:
- Convert the HMI RPM command to Hz by
Hz = RPM × steps_per_rev / 60. - Clamp the result to 0 Hz to 10000 Hz (or 100000 Hz if the mechanical envelope allows).
- Pass the clamped value to the FREQ input of CTRL_PTO.
- Use NUM_PULSES = 0 for continuous run, or pre-compute the pulse count for indexed moves.
SANMOTION SH1603 Wiring
The SH1603 is a 1.8° two-phase bipolar stepper motor from Sanyo Denki's SANMOTION series. Its datasheet specifies a holding torque of approximately 0.95 N·m and a rated phase current of 1.5 A. Pair it with a 24 V DC pulse-and-direction driver such as the Sanmotion Q Step driver or a comparable Oriental Motor, AMC, or Leadshine unit. Verify the driver's opto-isolator input current (typically 5 mA to 15 mA) is within the S7-1200 output rating (0.5 A continuous per channel).
| CPU 1212C terminal | Function | Driver terminal (typical) |
|---|---|---|
| Q0.0 (DQa.0) | Pulse output + | PULSE+ (opto-isolator anode) |
| Q0.1 (DQa.1) | Direction output + | DIR+ (opto-isolator anode) |
| 1M | Common for Q0.0–Q0.5 | PULSE- and DIR- (return to opto emitter) |
| 24 V DC sensor supply L+ | Driver internal supply, if required | VCC terminal of driver |
Keyence SR-610 Barcode Reader Integration
The Keyence SR-610 is a 1D/2D industrial barcode reader. The N-R2 module is the RS-232C communication option, providing DB-9-style serial at 9600 to 115200 baud. The SR-610 supports two trigger modes, and the difference between them is the root of the integrator's follow-up question.
| Trigger mode | Activation | Latency | Wiring | |
|---|---|---|---|---|
| When to use | ||||
| Command trigger | Host PLC sends an ASCII command (e.g., LON) over RS-232C |
~30–80 ms (round-trip protocol) | None beyond RS-232C lines | Multi-drop networks, when the trigger source is a PLC tag |
| Hardware (hard) trigger | A 24 V input on the SR-610 N-R2 module is driven high | Sub-millisecond | Requires a free digital output of the PLC | Conveyor lines where a photo-eye or PLC flag must trigger the read |
For a high-throughput packaging line the hard trigger is preferred because it removes the serial round-trip latency. For a slower automation cell the command trigger is faster to integrate because no additional wiring or PLC output is required. In the global program the trigger source can be unified by a single boolean tag Trigger_SR610:
- If hard trigger is wired: route
Trigger_SR610to a free DQ output wired to the N-R2 trigger terminal. - If command trigger is used: when
Trigger_SR610 := TRUE, transmitLON\r\nover the RS-232C port using the S7-1200Send_P2Pinstruction on the CM 1241 RS-232C module (not on the on-board port of the CPU 1212C, which is RS-485 only).
S7-1200 RS-232C Send/Receive Wiring with CM 1241
| CM 1241 terminal | Keyence N-R2 DB-9 pin | Signal |
|---|---|---|
| TXD (pin 3 on D-sub) | RXD (pin 2) | PLC transmit → reader receive |
| RXD (pin 2 on D-sub) | TXD (pin 3) | PLC receive ← reader transmit |
| GND (pin 5) | GND (pin 5) | Common ground |
| RTS/CTS | Not used | Leave floating unless hardware flow control is enabled |
Commissioning Verification
- Online watch table on the PTO output. Force ENABLE = TRUE, FREQ = 10000, NUM_PULSES = 0. Force the same and observe BUSY go TRUE.
- Scope on Q0.0 and Q0.1. Confirm a 24 V pulse train at the commanded frequency (within ±1% due to HSC quantization). Confirm Q0.1 (direction) is stable and not chattering; any chatter means the I/O filter on the direction output is set too high.
- Stepper response. Command a slow 100 Hz for one rotation, then 1 kHz, 5 kHz, and finally 10 kHz. The motor must run smoothly without stalling or audible cogging at each step.
- Direction reversal. Toggle DIR. The motor must reverse within one pulse. If it stalls during reversal, increase the deceleration ramp in the CTRL_PTO ACCEL/DECEL parameters.
- Stop behaviour. Drop ENABLE to FALSE. The output must stop within one pulse cycle. The Q0.0 line must return to 0 V within 100 µs.
-
Barcode trigger round-trip. Send
LON, wait for theRDYreply, present a known-good code, and verify the decoded string is returned within 200 ms.
Troubleshooting Matrix
| Symptom | Likely cause | Corrective action |
|---|---|---|
| Output stuck at 1 kHz, no higher | PWM block still in use, minimum pulse width enforced | Reconfigure the channel as PTO and use CTRL_PTO |
| PTO BUSY stays FALSE | CTRL_PTO not enabled, or output not configured as PTO | Verify PTO selection in device configuration; recompile hardware |
| PTO ERROR = TRUE, STATUS = 16#8001 | PTO already running from another instance | Disengage CTRL_PTO from both instances and re-issue |
| STATUS = 16#8002 | Direction output filter set too high | Set filter to 0.1 µs in device configuration |
| STATUS = 16#8003 | FREQ out of range | Clamp FREQ to 0..100000 before passing to CTRL_PTO |
| STATUS = 16#8004 | NUM_PULSES invalid (negative or unsupported value) | Use 0 for continuous; positive integer for finite run |
| STATUS = 16#8005 | HSC resource conflict | Reassign HSC 1/2/3 to non-overlapping channels |
| Motor stalls above 5 kHz | Driver opto input current insufficient, or supply droop | Verify 24 V rail under load; reduce microstep ratio to lower pulse rate needed for same RPM |
| Motor stutters at direction change | Ramp too aggressive | Increase ACCEL/DECEL to a value matching the load inertia |
| Keyence SR-610 does not reply | RS-232C/485 mismatch, wrong port | Verify CM 1241 RS-232C module installed; do not connect N-R2 to CPU on-board port |
| Barcode reads only intermittently | Trigger latency with command trigger | Switch to hardware trigger; wire a PLC output directly to N-R2 trigger input |
| Q0.0 oscillates but motor does not turn | Direction output inverted or opto supply missing | Swap PULSE+ / PULSE-, or verify 24 V on driver VCC |
Frequently Asked Questions
Why is my S7-1200 PWM output limited to 1 kHz when the manual says 100 kHz?
The CTRL_PWM instruction enforces a minimum pulse width of approximately 1 ms in the default configuration. With a 50% duty cycle this caps the effective maximum frequency at 500 Hz; at very low duty cycles the absolute ceiling reaches 1 kHz. Use CTRL_PTO for any motor pulse-train requirement above 1 kHz.
Can I keep using PWM and just change a parameter to raise the ceiling?
No. The minimum pulse width is a hardware-level constraint of the CPU output stage, not a software parameter that can be defeated. For pulse-and-direction stepper control the correct primitive is CTRL_PTO, which routes through the high-speed counter engine and bypasses the PWM minimum-pulse-width enforcement.
What is the maximum PTO frequency on the CPU 1212DC/DC/DC?
100 kHz on the on-board outputs Q0.0 to Q0.5. A signal board SB 1223 (200 kHz) can raise this to 200 kHz. Pulse count per run is limited to 2,147,483,647 (32-bit signed) and the direction output has a configurable filter that should be set to 0.1 µs for high-speed operation.
Do I need a CM 1241 module for the Keyence SR-610?
Yes. The CPU 1212DC/DC/DC on-board port 0 is RS-485 only and will be damaged if connected directly to the SR-610 N-R2 RS-232C module. Install a CM 1241 RS-232C module (6ES7241-1AH32-0XB0) and wire TXD/RXD/GND per the N-R2 DB-9 pinout. Configure the port at 9600,8,N,1 to match the SR-610 default.
Which Keyence SR-610 trigger mode is faster?
Hardware (hard) trigger is faster because it bypasses the RS-232C round-trip latency. Command trigger incurs 30–80 ms of protocol overhead per trigger. For high-throughput conveyors, hard trigger is preferred; for slow cells where wiring a trigger line is impractical, command trigger is faster to integrate.