Fixing SMC_ERROR.SMC_DI_HWLIMITS_EXCEEDED in CODESYS SoftMotion

Claire Rousseau14 min read
Motion ControlSchneider ElectricTroubleshooting
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

Problem Overview

The SMC_ERROR.SMC_DI_HWLIMITS_EXCEEDED flag is raised by the CODESYS SoftMotion axis object whenever the motion controller detects that a hardware travel-limit digital input (positive or negative end-stop) is in the active state at the moment the drive is enabled, or that the polarity of the configured input does not match the physical wiring of the sensor. When this bit is set in the axis error word, the axis is forced into the ErrorStop state, the drive is commanded to disable power through the CiA 402 state machine (typically transitioning from Operation Enabled / state 9 to Switch On Disabled / state 7, often via a Quick Stop / state 11), and every subsequent motion command is rejected until the cause is cleared and the error is acknowledged.

The error surfaces through the SMC_ReadAxisError function block, the Axis.Status.Error variable, and most commonly appears on an HMI as a banner string, in the PLC log buffer, or as an alarm imported from the SoftMotion error catalog. Per the official Schneider Electric Machine Expert SoftMotion SMC_ERROR reference, the SMC_ERROR enumeration groups drive-side and controller-side fault flags under a single DWORD, allowing the application to mask individual bits and react programmatically.

Error Enumeration Context

The SMC_ERROR structure used by CODESYS SoftMotion (SM3_Basic and SM3_CNC libraries) is a bitfield that partitions faults into logical categories. SMC_DI_HWLIMITS_EXCEEDED sits in the drive I/O supervision group, alongside sibling flags that often appear together when a limit input is misconfigured or unreachable.

Bit Group Typical Flag Meaning
Drive I/O supervision SMC_DI_HWLIMITS_EXCEEDED Negative or positive hardware limit input is active while drive is enabled
Drive I/O supervision SMC_DI_LIMITS_NOT_VALID Axis configured for limits but DI mapping is missing or invalid
Drive I/O supervision SMC_DI_LIMITS_DISABLED Limit inputs intentionally masked by the application (0x60FE bits)
Drive communication SMC_DRIVE_ERROR Vendor-specific drive fault latched
Encoder feedback SMC_ENCODER_ERROR Encoder feedback invalid, missing, or out of range
Following error SMC_FOLLOWING_ERROR Position lag exceeded configured threshold
State machine SMC_STATE_ERROR Command issued while axis is in an invalid state
Note: The exact numeric value and bit position of SMC_DI_HWLIMITS_EXCEEDED within the DWORD varies between SM3_Basic library revisions (3.5.x, 4.x, 4.12.x). Always decode the error by symbolic name rather than by numeric comparison, and reference the library version installed in your project.

Root Cause Categories

In field experience, SMC_ERROR.SMC_DI_HWLIMITS_EXCEEDED traces to one of four root causes, ranked by frequency:

  1. PDO mapping mismatch: The EtherCAT slave (drive) publishes the digital input status word (typically CiA 402 object 0x60FD) but the CODESYS project either does not map it to the SoftMotion axis object, or maps it to a different PDO index than the axis expects. This is the most common cause immediately after a project download, drive replacement, or library upgrade.
  2. Drive input polarity: The drive is configured to interpret the limit-switch input as normally-open (NO) when the physical sensor is wired as normally-closed (NC), or vice versa. Many drives default to NC for safety, so wiring a PNP NO sensor without reconfiguring the drive produces a permanent "limit hit" signal.
  3. Sensor wiring or ground fault: The proximity switch or mechanical limit contact shares a return path with a noisy load, the cable is broken, or the 24 V supply to the sensor is missing, holding the input in the "limit active" state even when the sensor is clear.
  4. Encoder or scaling change: After replacing the motor or encoder (for example, swapping a 20-bit encoder for an equivalent model with a different resolution), the axis scaling parameters no longer match the physical motion range. SoftMotion can propagate the resulting mismatch into the limit-exceeded flag if limit input supervision is enabled.

PDO Mapping Verification Procedure

The first verification step is to confirm that the drive's digital input status word is reachable from the SoftMotion axis. The standard CiA 402 object is 0x60FD "Digital inputs", a 32-bit field in which bit 0 reflects the negative limit switch state and bit 1 reflects the positive limit switch state as observed by the drive.

Procedure:

  1. In the CODESYS device tree, expand the EtherCAT slave (drive) and inspect the PDO mapping. Confirm that the chosen TPDO includes 0x60FD with the correct mapping entry.
  2. Open the drive's configuration editor in CODESYS and verify that the digital input mapping for the limit switch points to the correct physical input (DI1, DI2, DI3, etc.).
  3. Force-update the device (right-click the slave → "Force update of device") so the axis object picks up the current mapping.
  4. In the axis object, navigate to the limit-switch mapping and confirm the symbolic name resolves to the correct PDO bit. If the axis was created from a template that assumed a different drive family, the mapping may be blank or pointed at an unmapped object.
  5. Add the axis variable to a watch list and read 0x60FD in the drive's online diagnostics. Compare bit 0 and bit 1 against the physical sensor status; if a bit is asserted while the sensor is clear (and vice versa), the polarity is wrong.
CiA 402 Object Name Bit 0 (Neg. Limit) Bit 1 (Pos. Limit)
0x60FD Digital inputs 1 = negative limit active 1 = positive limit active
0x60FE Digital outputs 1 = disable neg. limit 1 = disable pos. limit
0x605A Quick stop option code Defines reaction when limit hit (drive-dependent)
0x6041 Status word Bit 11 = internal limit active; bit 13 = following error
Safety warning: Hardware limit switches are part of the machine safety chain and must not be bypassed to clear this error. If a temporary override is required during commissioning, use the SoftMotion axis object's limit mask (via 0x60FE bit manipulation where supported) and clearly mark the system as not production-ready.

Drive Input Polarity and Logic Level

Most modern servo drives allow the logic level of each digital input to be inverted. In the Schneider Electric Lexium and Altivar drive families, this is exposed in the drive's I/O configuration as "DI active level" or "DI invert". The default is typically active low because the safety convention is NC contacts that open (high impedance) on limit hit, which the drive interprets as active.

If the axis was developed using simulated drives or a template that assumed a normally-open sensor, the drive may be configured for active high. A real NC sensor then produces a constant limit-active signal. Conversely, a NO sensor wired to a drive configured for NC will hold the input in the "clear" state but fail to stop the axis mechanically if the software limit is disabled.

Sensor Wiring Recommended Drive Logic Level Effect When Misconfigured
NC contact (mechanical) Active low (default) Permanent limit-exceeded error; axis will not enable
NO contact (mechanical) Active high Limit ignored during runtime; safety hazard
PNP proximity switch (sourcing) Active high (sink input) PNP output goes high on target; drive sees "no limit" if drive expects low
NPN proximity switch (sinking) Active low (source input) NPN output pulls low on target; drive sees "limit hit" if drive expects high

Procedure to correct:

  1. Identify the sensor type from the machine drawing (NC/NO, PNP/NPN).
  2. Connect to the drive's commissioning tool (Machine Expert Motion, ctrlX Drive Engineering, Lexium CT, or vendor-specific tool) and locate the DI configuration menu.
  3. Set the active level to match the sensor, save to the drive, and cycle power if required by the firmware.
  4. Re-trigger the axis enable and confirm SMC_DI_HWLIMITS_EXCEEDED is no longer raised.

Hardware Limit Switch Wiring

Beyond the drive's logic level, the physical wiring must be verified. Common problems include:

  • 24 V common missing: A PNP sensor requires both 24 V supply and a return path. If the 24 V return is shared with a contactor coil that produces back-EMF, the input may chatter and intermittently assert the limit bit.
  • Cable shield not terminated: Long cable runs near VFD output cables inject noise into the DI line and produce false limit events.
  • Sensor damaged: End-of-travel stops see mechanical impact; the proximity switch may be bent or its target plate misaligned.
  • Cross-wired channels: Positive and negative limits reversed at the terminal block produce the error only on enable, because the controller sees both inputs in unexpected states.
Wire / Terminal Expected Signal Test Method
Brown (24 V supply) +24 VDC ±10% Measure with multimeter at sensor terminals
Blue (0 V return) 0 VDC (field ground) Verify referenced to drive 0 V, not chassis
Black (signal) PNP: +24 V on detect, NPN: 0 V on detect Toggle target by hand; observe drive DI status
Shield Drain wire to PE at cabinet entry only Verify single-point termination

Axis Initialization and Reset Sequence

After correcting the root cause, the axis must be re-initialized and the error must be acknowledged before motion can resume. The standard SoftMotion sequence is:

  1. Call SMC_ReadAxisError to confirm the error word is clear of SMC_DI_HWLIMITS_EXCEEDED. The error may need to be cleared at the drive first if the drive latched its own fault.
  2. Issue SMC_ResetAxisError (or set Axis.bReset = TRUE for one cycle) to acknowledge the SoftMotion error and force the axis out of ErrorStop.
  3. Call SMC_Power or drive the CiA 402 state machine through Shutdown (state 6) → Switch On (state 3) → Operation Enabled (state 9). Verify the drive's status word (0x6041) shows bit state-x.2 = 1, state-x.1 = 1, state-x.0 = 1, and state-x.3 = 0 (no fault).
  4. If the error persists after the reset, read the drive-side error word (0x603F) and consult the drive manual. Common latched codes include F702 (limit switch) on Lexium drives and F799 (hardware limit) on Altivar drives.
// Typical reset sequence (Structured Text)
IF Axis.Status.Error THEN
    fbReadErr(Axis := Axis, Error => dwErr);
    IF (dwErr AND SMC_DI_HWLIMITS_EXCEEDED) <> 0 THEN
        // Optional: log structured alarm with timestamp
        bClearLimits := TRUE;
        fbReset(Axis := Axis, Execute := TRUE);
    END_IF;
END_IF;

// Drive-side check
IF Axis.Com.StatusWord.%X3 = 1 THEN
    // Bit 3 = fault; do not enable power until cleared
    nDriveErrCode := Axis.Drv.ErrorCode;
END_IF;
Note: Some SoftMotion versions retain SMC_DI_HWLIMITS_EXCEEDED until a full controller restart if the underlying drive error is not cleared first. Verify the drive fault queue is empty (object 0x603F = 0) before resetting the SoftMotion axis.

SoftMotion Axis State Machine

Understanding the SoftMotion state machine is essential to interpret the error. The state transitions are governed by PLCopen function blocks such as SMC_Power, SMC_Reset, SMC_Home, and SMC_Stop. SMC_DI_HWLIMITS_EXCEEDED forces the transition from Standstill, Moving, Homing, or Stopping directly into ErrorStop. The axis remains in ErrorStop until SMC_ResetAxisError succeeds.

SoftMotion State Trigger to Enter Trigger to Leave
Disabled Initial state after download / restart SMC_Power with no errors
Standstill Power applied, no motion active Motion command or SMC_Home
Homing SMC_Home executed Homing complete or aborted
Moving Motion command accepted Target reached or SMC_Stop
Stopping SMC_Stop issued Stop complete → Standstill
ErrorStop Any axis error (including limit) SMC_ResetAxisError + cause cleared

Verification Checklist

After applying the fix, run the following checks before returning the machine to production:

  • Axis enables without raising SMC_DI_HWLIMITS_EXCEEDED in the error word.
  • Manual jog in both positive and negative directions crosses the limit sensor; the axis stops with a Quick Stop (or category 1 stop, depending on configuration), the drive reports a limit-active status, and the SoftMotion axis transitions to ErrorStop with the expected flag.
  • Homing sequence completes; the referencing sensor is registered without the limit flag prematurely asserting.
  • Drive error queue is empty (0x603F = 0).
  • PLC log shows no recurring SMC_ERROR.SMC_DI_HWLIMITS_EXCEEDED entries across a full production cycle.
  • HMI alarm banner displays the expected state during a test-induced fault and clears when acknowledged.
  • Safety relay or hard-wired E-stop chain still functions (limit switches often share wiring with the safety category stop circuit).

Related SoftMotion Errors

If the same root cause is present but the controller reacts differently, you may see one of the following sibling errors. Use the table to confirm you are addressing the correct flag:

Error Flag Typical Trigger Differentiation
SMC_DI_HWLIMITS_EXCEEDED Limit switch asserted while drive is enabled Occurs on enable; usually wiring or polarity
SMC_DI_LIMITS_NOT_VALID Axis object has no mapping for limit inputs Occurs on project download; configuration issue
SMC_HW_ERROR Generic hardware fault from drive Often paired with vendor-specific code
SMC_FOLLOWING_ERROR Position lag exceeded threshold Occurs during motion, not at enable
SMC_POSITION_ERROR Software end-stop exceeded Occurs when commanded position passes configured soft limits
SMC_ENCODER_ERROR Encoder feedback invalid Often paired with comms loss or scaling mismatch

Platform-Specific Notes

Schneider Electric Machine Expert Motion / EcoStruxure

When the project is deployed via Machine Expert (formerly SoMachine), the axis object is generated from the device editor. If you replace the drive variant (for example, switching from a Lexium 32 to a Lexium 28, or from a 20-bit encoder motor to a 24-bit equivalent), the axis template regenerates and may assign new DI mappings. After any drive swap, force-update the device and re-verify the limit input mapping before downloading to the controller. Refer to the Machine Expert SoftMotion SMC_ERROR reference for the canonical flag names and library revision notes.

Bosch Rexroth ctrlX Drive / ctrlX Data Layer

On ctrlX platforms running CODESYS SoftMotion (for example, library 4.12.0.0 with SoftMotion Adaption 1.16.0) and ctrlX drive firmware 3.14, the axis object is exposed via the drive's parameter set. Limit-switch mapping is configured under the axis "Inputs" tab in ctrlX Drive Engineering, and the SoftMotion axis picks up the mapping through the EtherCAT PDO assignment. Confirm the drive firmware release notes cover the SoftMotion version in use; mismatched firmware and SoftMotion libraries occasionally latch SMC_DI_HWLIMITS_EXCEEDED that can only be cleared with a full controller reboot or project re-download.

Preventive Measures

To avoid recurrence, integrate the following checks into your commissioning workflow:

  • Add a startup self-test that reads 0x60FD on every axis before enabling power and verifies both limit bits are clear. If either is asserted at start-up, abort the enable sequence and raise a structured alarm.
  • Store the drive's DI active-level setting as part of the machine's parameter recipe, so a drive replacement does not silently revert to the wrong polarity.
  • Log axis error transitions with the timestamp of the drive-side fault queue snapshot to speed up post-mortem analysis.
  • On every project download, verify that the axis template's DI mapping still resolves to a live PDO entry. CODESYS will allow a download with an unmapped limit input if the axis is configured but the PDO is disabled, only failing at runtime.
  • Keep the SoftMotion library version consistent across the engineering team; mixed library versions on different machines can produce identical-looking but differently-behaving errors.

FAQ

What does SMC_ERROR.SMC_DI_HWLIMITS_EXCEEDED mean?

It means the CODESYS SoftMotion axis detected that a hardware travel-limit digital input (positive or negative end-stop) is in the active state at the moment the drive is being enabled, or that the configured polarity does not match the physical wiring. The axis is forced into ErrorStop and rejects motion commands until the cause is cleared and the error is acknowledged via SMC_ResetAxisError.

Why does the error appear even though no limit switch is touched?

The most common cause is a polarity or wiring mismatch: the drive is configured for normally-open logic but the sensor is wired as normally-closed, or vice versa. Verify the drive's DI active-level setting against the sensor type (PNP/NPN, NC/NO) and confirm the 24 V supply to the sensor is stable. Cross-wired positive/negative channels and missing 24 V return paths produce the same symptom.

How do I clear SMC_DI_HWLIMITS_EXCEEDED without rebooting the controller?

Fix the underlying cause first (correct the PDO mapping, polarity, or wiring), then drive the CiA 402 state machine back to Operation Enabled. Call SMC_ResetAxisError or pulse Axis.bReset for one cycle. If the drive latched its own fault, clear the drive error queue (object 0x603F) before resetting the SoftMotion axis; otherwise the error will reappear immediately.

Which CiA 402 object reports the hardware limit state?

Object 0x60FD "Digital inputs" carries the limit state: bit 0 reflects the negative limit switch and bit 1 reflects the positive limit switch as observed by the drive. Object 0x60FE "Digital outputs" allows the controller to mask each limit input individually via its bit 0 (disable negative) and bit 1 (disable positive). Use 0x6041 status word bit 11 to detect "internal limit active" at the drive level.

Can SMC_DI_HWLIMITS_EXCEEDED be disabled during commissioning?

SoftMotion allows the application to mask limit inputs through 0x60FE bit manipulation or through the axis configuration, but hardware limit switches are a safety-of-machine requirement and must never be permanently disabled. Use a temporary mask only during commissioning, mark the system clearly as not production-ready, and re-enable the limits before handover. The mask should be removed automatically as part of any production-mode startup sequence.

Does a motor or encoder swap affect this error?

Yes. Changing the encoder resolution (for example, from a 20-bit to a 24-bit encoder) or the mechanical gear ratio alters the axis scaling, and the controller may compute that the axis is past a configured software end-stop, propagating into the limit-supervision logic. After any hardware swap, re-run the axis scaling wizard, re-verify PDO mapping for 0x60FD, and confirm the new drive firmware supports the SoftMotion library version in use.

Back to blog