Problem Statement
A SIMATIC S7-1200 CPU 1217C DC/DC/DC (Siemens order number 6ES7217-1AG40-0XB0 and successor variants) drives a three-axis stepper machine in PTO (Pulse Train Output) mode through the on-board high-speed outputs. Only the negative (lower) hardware limit switch is wired; the positive limit is intentionally left free. The inductive, latching limit switch delivers 24 V DC when the axis has reached the mechanical stop and holds the level high (with typical residual voltage of 0.4 V DC in the released state) until the carriage has travelled back out of the switch window.
Field symptom: the commissioning tool bundled with TIA Portal — accessed from Project tree > Technology objects > <TO_Axis> > Commissioning — permits the operator to jog the axis past the wired endstop without triggering a stop or error message. The input LED assigned to %I0.5 lights the moment the cam enters the sensor, confirming the field wiring and 24 V DC sourcing. Triggering the lock/unlock combination inside the commissioning dialog forces the axis object to report "Lower HW limit switch reached" — but only after that forced reinitialisation. The same input transition is ignored in real time during MC_MoveJog, MC_MoveAbsolute and MC_MoveRelative motion jobs.
The signal is wired directly onto the CPU (not onto a SM digital input module), so it is on one of the on-board interrupt-capable inputs, which are required inputs for hardware limit switches per Siemens documentation.
CPU 1217C Hardware Architecture Overview
The CPU 1217C variants (firmware V4.x through the current V4.7 line, plus the V4.6 SIMATIC CPUs) expose 10 digital on-board inputs (Ia.0 through Ib.5), 6 of which are interrupt-capable and can also serve as HSC, PTO position-reference, or HW-limit channels. The exact mapping for DC/DC/DC versions is:
| Input | Interrupt-capable | HSC | Typical PTO assignment | Notes |
|---|---|---|---|---|
| %I0.0 | Yes | HSC1 | PTO 1 (axis 0) pulse A / dir | 12 / 24 V DC, 5 mA typ., 30 V DC max |
| %I0.1 | Yes | HSC2 | PTO 1 (axis 0) pulse B / dir inverse | Same electrical envelope |
| %I0.2 | Yes | HSC3 | PTO 2 (axis 1) pulse A | — |
| %I0.3 | Yes | HSC4 | PTO 2 (axis 1) pulse B | — |
| %I0.4 | Yes | HSC5 | PTO 3 (axis 2) pulse A | — |
| %I0.5 | Yes | HSC6 | PTO 3 (axis 2) pulse B | Commonly used for HW limit on axis 2 |
| %I0.6 .. %I0.7 | No | — | General-purpose | Cannot drive interrupts for limit switches |
| %I1.0 .. %I1.5 | No | — | General-purpose | Same — not interrupt-capable |
This table is the critical first check: if the limit switch is wired to %I0.6–%I1.5, the firmware will not honour it as a hardware limit switch no matter how the project configuration looks. Because the reported wiring uses %I0.5, the channel is interrupt-capable, ruling out one of the common root causes. The interrupt-capable inputs can be configured as rising-edge, falling-edge, or both-edge triggering and are the only channels that the Motion Control firmware watches for HW-limit transitions.
Motion Control Fundamentals — PTO Operation on the S7-1200
The S7-1200 Motion Control firmware implements the PLCopen motion profiles (single-axis blocks MC_MoveAbsolute, MC_MoveRelative, MC_MoveJog, MC_Halt, MC_Stop and the multi-axis MC_CamIn/MC_GearIn) on top of the PTO generator. For each PTO axis the firmware allocates:
- One or two digital outputs as the pulse train (single pulse + direction, or CW/CCW pulse pair).
- Optional discrete outputs for the drive enable (DRV_ENABLE) and ready (DRV_READY) handshake.
- Optional HW limit switch inputs on channels that the firmware polls at the PTO tick rate (typically every 1 ms, depending on the configured sampling).
- Optional SW limit switch positions (low and high) stored in the technology object.
- Optional homing inputs (home switch, homing marker).
The Siemens documentation makes the limit-switch monitoring contract explicit: "Hardware limit switches must be connected to interrupt-capable inputs of the CPU". Until that contract is honoured and the configuration is committed to the target, the firmware does not poll the input — even though the LED on the front of the CPU may be lit whenever the input field voltage rises above the threshold.
Hardware Limit Switch Activation Rules
According to the Siemens S7-1200 Motion Control documentation, three independent rules must be satisfied before the firmware will react to a HW limit transition during a running motion job:
- The input selected in the axis configuration must map to a physically interrupt-capable CPU input. TIA Portal will not refuse the assignment if you choose %I0.7, but runtime will silently disable monitoring and the axis object compiles without the active flag.
- The "Enable HW limit switches" checkbox must be ticked in the technology object under Configuration > Extended parameters > Hardware limit switches. Until that box is selected, the entire HW-limit mechanism is dormant, regardless of the input selection.
- The polarity / "Type of HW limit switch" must match the real wiring. Two options exist: Active high (NO contact) and Active low (NC contact). The selection toggles the firmware's interpretation of the input edge. If the inductive switch is wired as a PNP source (24 V on activation) and the configuration declares the switch as NC, the firmware will expect the line to fall to 0 V on trigger and will therefore ignore the rising edge that the LED confirms.
The Siemens "Configuring HW limit switches" manual page describes this dialog and the required selections in detail: tick the "Enable HW limit switches" checkbox, then select the type (active high / active low) and assign the input address in %I memory. Until those three steps are committed and the project is downloaded to the CPU, the runtime will treat the axis as if no HW limit switch existed.
Root Cause Analysis
Three root causes explain the reported behaviour. Each is testable from inside TIA Portal without rewiring the panel:
| ID | Likely root cause | Symptom signature | How to confirm | Resolution |
|---|---|---|---|---|
| R1 | "Enable HW limit switches" checkbox is unticked in the axis configuration | LED on %I0.5 lights when the cam engages; commissioning dialog reports the error only after lock/unlock (which forces a re-init) | Open Project tree > Technology objects > Axis > Configuration > Extended parameters > Hardware limit switches. The checkbox state is the ground truth. | Tick the box, save the project, perform a full hardware download |
| R2 | "Type of HW limit switch" set to NC (active low) while the inductive sensor is PNP (active high) | LED confirms 24 V; firmware never asserts the limit event | From the same dialog check "Type". Activate the limit in commissioning while watching Monitor & force; the bit TO.Axis.StatusWord.HWLimitSwitchMin must change. |
Switch type to "Active high" (PNP NO) to match the wiring |
| R3 | Active technology object does not match the running axis — configuration was edited on the wrong TO instance, or the build was downloaded to PLC but the hardware configuration was not | LED works; commissioning dialog shows wrong axis, or no error even with enable=HIGH | Compare Online > Diagnostics > Technology objects; verify each axis's active configuration matches the offline configuration | Perform Online > Download to device > Hardware and software (complete) — not "Software only" |
The lock/unlock sequence inside the commissioning dialog re-evaluates all configuration parameters on reinitialisation. That is why the error message "Lower HW limit switch reached" appears immediately after the unlock, but never during a continuous jog. The unlock forces the TO's configuration block to reload from the work memory image — a behaviour that masks any mismatch between the live axis and the project configuration during normal motion.
Step-by-Step Resolution Procedure
The procedure below assumes TIA Portal V18 or later and a CPU 1217C with firmware V4.4 or above. Step order is significant: a partial download will not propagate the Motion Control configuration changes.
- Open the project offline and navigate to Project tree > Technology objects > <Axis_1>. Right-click and select Properties.
- Select Configuration > Extended parameters > Hardware limit switches.
- Tick the checkbox Enable HW limit switches.
- Set the input address for the negative HW limit switch (lower): enter
%I0.5in the address field, or select it via the IO drop-down if address syntax is disabled in the project. - Set the Type of HW limit switch to Active high (PNP, normally open). With inductive latching sensors wired as PNP sourcing, this matches the field voltage of 24 V on trip.
- Leave the positive (upper) HW limit switch input disabled by leaving the checkbox unchecked for that row. Leave SW limit switches configured to a position range that envelops the working travel.
- Confirm that the assigned input is listed as interrupt-capable in the CPU's Properties > Digital inputs tab. %I0.5 on the CPU 1217C is interrupt-capable by default; if the project shows a missing assignment, review the device configuration and ensure the SM/CP slot is not occupying the interrupt vector.
- Compile the project (Project > Compile > Software (rebuild all)). Address any "no interrupt-capable input available" warnings.
- Connect to the CPU. From the menu bar: Online > Download and reset PLC program — accept the prompt to overwrite the runtime configuration. This step is the one the original post initially missed; it forces a complete download of the hardware configuration.
- Right-click on the CPU device in the project tree and choose Download to device > Hardware configuration. Confirm that the transfer status reads Successful (Differences found).
- Reboot the CPU if the download dialog recommends it. Some firmware revisions require a STOP-RUN transition to activate new Motion Control parameters; older revisions (V4.0–V4.1) require a power-cycle.
- Re-enter the commissioning dialog for the axis. Verify that the two limit LEDs in the dialog reflect the field state of %I0.5 in real time (no lock/unlock required).
- Jog the axis toward the endstop with the commissioning tool. Confirm an immediate stop with no overtravel into the mechanical stop, and confirm the diagnostic buffer entry reads "Reaching the negative HW limit switch caused axis stop" with MotionControl technology object ID listed.
Commissioning Tool Behaviour Reference
The commissioning dialog has its own reinitialisation semantics, different from the runtime motion job path. Understanding the distinction prevents future misdiagnoses:
| Action in commissioning | Effective runtime effect |
|---|---|
| Toggling the "Enabled" checkbox ON | Activates the axis and applies the currently loaded configuration. Does not re-read the offline project; uses whatever is in the work memory. |
| Lock / Unlock | Lock halts the axis; unlock re-enables it and reloads the technology object parameters from the most recently downloaded hardware configuration. This is why the user observed the correct error immediately after unlock. |
| Clicking "Set" on a position | Writes to the position setpoint; does not re-evaluate HW limit configuration. |
| Clicking "MC Reset" or invoking MC_Reset | Forces the TO into a known initial state and reloads the HW limit configuration parameters. |
Operationally, the simplest confirmation that the configuration matches the firmware is to disconnect the live online connection, perform a full compile, and then issue a fresh STOP-RUN transition on the CPU. After the transition the commissioning tool should reflect %I0.5's real-time state without the lock/unlock workaround.
Recommended Hardware Setup for Inductive Latching Sensors
Because the limit switches in this application are latching inductive sensors, two design rules apply beyond the firmware configuration:
- Debounce / filter width: the input filter for interrupt-capable inputs on the CPU 1217C is configurable from 0.1 ms up to 20 ms via Properties > Digital inputs > Input filter. Set it to the default of 6.4 ms for typical mechanical switches; only lower it (down to 0.1 ms) if the axis velocity demands it and the cable run is short and shielded.
- Polarity protection: route the sensor 24 V DC through the same 24 V DC supply that feeds the CPU's sensor supply Vs (terminals 1M / 2M on the CPU). Cross-grounding different supplies creates differential noise that can falsely retrigger the limit switch edge on high-current PWM loads such as stepper drivers.
Verification Procedure
- With the axis enabled and idle, observe the limit switch indicator on the commissioning dialog. Manually drive the sensor with a screwdriver or test block. The indicator must toggle within 20 ms.
- Place the axis 50 mm outside the limit zone, command MC_MoveAbsolute with a target position 100 mm into the limit zone.
- Confirm that motion stops within 0–2 ms of the cam entering the sensor (subject to the configured ramp-down / jerk limit). The TO error state should flip to
16#8001("Limit switch reached") and the diagnostic buffer should contain the event. - Run MC_Reset from the user program to clear the error, then jog away from the sensor in the positive direction and confirm that motion resumes normally.
- Disconnect power to the sensor only (simulate wire break). Confirm that the CPU firmware reports the limit as tripped within the input filter time + one scan. (For a sensor wired active high with NC logic the wire break will trip the limit, as expected.)
Troubleshooting Matrix
| Observed behaviour | Most likely root cause ID | Action |
|---|---|---|
| LED on %I0.5 lights on activation, but PLC never stops motion | R1 (checkbox) or R2 (polarity mismatch) | Open the axis configuration dialog; tick the enable box and verify the active-high setting |
| Error appears only after lock/unlock sequence in commissioning | R1 or R3 (incomplete download) | Perform full hardware + software download; power-cycle the CPU |
| LED lights only when sensor is released, not when activated | Wiring inversion (sensor wired PNP vs NPN, or NC vs NO) | Verify sensor type on the device datasheet; re-wire to PNP sourcing so that the sensor applies 24 V on trip |
| Configuration dialog refuses the address %I0.5 | %I0.5 already used by HSC6 or by another configured function | Move the limit switch to another free interrupt-capable channel, or release %I0.5 from its HSC assignment |
| Multiple instances of the same technology object downloaded; runtime picks the wrong one | R3 — wrong axis active in commissioning | Use online diagnostics to identify the active axis ID; remove duplicate instances |
| After configuration changes, error "Technology object not ready" at restart | R3 — incomplete hardware download | Compile → Stop CPU → Download hardware configuration → Run |
Configuration Snippet — User Program Side Enforcement
For belt-and-braces protection in addition to the firmware-level monitoring, embed a cyclic check in the user program that disables the drive enable output the moment the limit becomes true. This will not replace the firmware's native reaction but provides redundancy for diagnostics logging:
// SCL — IEC 61131-3 Structured Text
IF "Axis_1".Status.HWLimitSwitchMin OR
"Axis_1".Status.SWLimitMinReached OR
"Axis_1".Status.Error THEN
"Drive_Enable_1" := FALSE; // De-energise drive ENABLE
"MC_Reset_DB".Execute := FALSE;
END_IF;
// After clearing the cause:
IF NOT "Axis_1".Status.HWLimitSwitchMin
AND NOT "Axis_1".Status.SWLimitMinReached
AND "Axis_1".Status.Standstill THEN
"Drive_Enable_1" := TRUE;
"MC_Reset_DB".Execute := TRUE;
END_IF;
The same pattern can be wired in ladder or FBD; the semantic intent — that drive enable is interlocked with both HW and SW limits — is the same.
Field Commissioning Notes
Three field tips specific to the CPU 1217C + PTO + inductive HW-limit combination:
- If the project is migrated from a different S7-1200 firmware (V4.0, V4.1, V4.2), the technology object databases (file format .xml in Project > Project folder > IM) sometimes retain obsolete HW-limit entries. After migration, delete the technology object and recreate it. This eliminates "phantom" configuration that survives a partial download.
- If the project was first commissioned with the CPU in RUN mode and downloads happen online only, force a STOP-RUN transition after each configuration change. The S7-1200 firmware caches Motion Control parameters until the next STOP-RUN transition on legacy V4.x CPUs.
- When using a stepper driver with optocoupled inputs, the driver provides 24 V DC sourcing from its own supply rail. The sensor 24 V must come from the CPU's Vs rail to guarantee a common reference — otherwise the limit input floats relative to the CPU input threshold.
FAQ
Why does the S7-1200 only react to the hardware limit switch after I lock and unlock the axis in commissioning?
The lock/unlock sequence forces the technology object to reload its configuration from the work memory image. If the HW limit switch was not enabled (checkbox unticked) or its polarity mismatched (active low vs PNP NO), the firmware only re-evaluates those configuration bits after that re-init. Without lock/unlock, the axis continues with the previous (broken) configuration and ignores the input.
Does the hardware limit switch have to be wired to an interrupt-capable CPU input?
Yes. Siemens documentation explicitly states that HW limit switches must be connected to interrupt-capable inputs of the CPU. On the CPU 1217C these are %I0.0 through %I0.5; %I0.6, %I0.7 and %I1.0–%I1.5 are not interrupt-capable and cannot serve as HW limit switch inputs.
Which is the correct "Type of HW limit switch" setting for a PNP inductive sensor?
Select Active high (also called "normally open" / PNP NO). The firmware then interprets a rising edge on the input — i.e., the 24 V DC level your inductive sensor applies when tripped — as the limit event. If you choose "active low" the firmware waits for the line to fall, which never happens for that sensor family.
After editing the technology object, do I need a STOP-RUN cycle or just an online download?
On legacy CPU 1217C firmware (V4.0–V4.4) you must perform a STOP-RUN transition after every Motion Control configuration change because the firmware caches the parameters. On V4.5 and later an online download of the complete hardware configuration is sufficient, but a power-cycle is the safest field practice. The original poster's scenario — commissioning only after lock/unlock — is a classic symptom of a partial download being accepted without a STOP-RUN cycle.
Can the S7-1200 hardware limit switch fulfil a Cat. 3 / PL d safety function?
No. The PLC-level HW limit switch is a process-level monitoring function, not a category-rated safety function. For Cat. 3 / PL d or higher you must use a separate, hardwired, dual-channel safety relay or a SIMATIC F-CPU (e.g., CPU 1214FC or CPU 1515F) with the limit switch duplicated into a fail-safe input module. The PLC-level switch can remain in place as a process-level overshoot protection.