S7-1500 TO_ExternalEncoder: Configure Absolute Encoder Position

David Krause16 min read
Motion ControlSiemensTroubleshooting
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 Description

When commissioning a SIMATIC S7-1500 CPU with a TM PosInput 2 module and a TO_ExternalEncoder technology object, the actual position read by the user program does not survive a power cycle of the PLC even though the connected encoder is an absolute device. The diagnostics view of the TM PosInput module shows a correct, updated absolute position immediately after restart, but the application DB exposes a value that resets to 0.0 on every STOP-to-RUN transition. This breaks applications that rely on a retained absolute position, such as rotary tables, hoists, or tracking systems where the mechanical reference cannot be re-acquired cheaply after every PLC restart.

Observed Symptom Pattern

  • Encoder hardware reports a valid absolute value (for example 4000 increments) in the TM PosInput diagnostics.
  • Mechanically rotating the encoder while the PLC is powered off produces the expected change in the diagnostic view once the PLC powers back up.
  • The user program's Actual position tag in the TO_ExternalEncoder instance DB starts at 0.0 after every restart.
  • Calling MC_Home with mode 7 (Absolute encoder adjustment) overwrites the position to 0.0 instead of adopting the absolute value from the encoder.
  • Attempting to change the relevant configuration parameter in the technology object online produces no effect; the parameter appears greyed out or unavailable.
Important: The encoder hardware is not at fault. The TM PosInput correctly forwards the absolute position. The technology object configuration simply has not been told that the encoder is absolute.

Affected Hardware and Software

Component Identification Notes
CPU SIMATIC S7-1516-3 PN/DP Firmware V2.5 or higher recommended for full TO_ExternalEncoder with absolute encoders
Position input module SIMATIC TM PosInput 2, 6ES7 551-1AB00-0AB0 Supports SSI, sin/cos, and PROFIdrive-compatible absolute encoders via telegram 83
Technology object TO_ExternalEncoder in TIA Portal Operating mode Positioning, modulo enabled
Encoder telegram PROFIdrive telegram 83 Gx_XIST1 in PZD 1+2, Gx_XIST2 in PZD 3+4
Fine resolution Gx_XIST1 = 0 bit, Gx_XIST2 = 12 bit Configured in the encoder properties under Fine resolution
Engineering framework TIA Portal V15.1 or higher (typical baseline) Earlier versions may not expose all configuration options

Understanding the Data Flow

Before applying the fix, it helps to understand how encoder data flows from the physical device to the application program.

  1. Encoder hardware: The physical encoder maintains its absolute position internally. Single-turn resolution is the number of increments within one mechanical revolution. Multi-turn resolution adds additional bits for the number of full revolutions. Common resolutions are 13-bit single-turn (8192 increments per revolution) and 25-bit multi-turn (33 million revolutions).
  2. TM PosInput 2 module: The module reads the encoder data over its native protocol (SSI, sin/cos with EnDat, or pure PROFIdrive) and translates it into the standard PROFIdrive telegram 83 format. The module does not lose the absolute information; it simply packs the position into Gx_XIST1 and the fine resolution into Gx_XIST2.
  3. PROFINET/PROFIBUS: Telegram 83 travels from the TM PosInput 2 to the CPU via PROFINET IO or PROFIBUS DP. The full 32-bit position plus 12-bit fine resolution is delivered each cycle.
  4. TO_ExternalEncoder: The technology object receives the telegram data. If the object is configured for absolute operation, it stores the position as a true absolute value and updates the user-visible Actual position tag accordingly. If not, it treats Gx_XIST1 as a relative counter and resets the position on every STOP-to-RUN transition.
  5. Application program: The user program reads the Actual position tag from the technology object's instance DB and uses it for control decisions.

Root Cause Analysis

The TM PosInput 2 correctly reads the absolute position from the encoder and publishes it to the technology object through PROFIdrive telegram 83. The technology object, however, treats the encoder as a non-absolute source unless its configuration explicitly marks it as absolute. In non-absolute mode, the technology object treats the incoming Gx_XIST1 as a relative counter and clears the position reference to zero on every CPU restart and every STOP-to-RUN transition.

There are three compounding causes that, together, produce the symptom:

  1. Technology object configuration: The Operating mode parameter of the TO_ExternalEncoder is not set to support absolute evaluation of the connected encoder.
  2. PROFIdrive interpretation: The associated telegram data is interpreted as incremental, so Gx_XIST1 is treated as a relative counter rather than an absolute position.
  3. Online edit limitation: The configuration change cannot be performed online. Configuration data of technology objects in TIA Portal is only applied when the project is recompiled and downloaded. This is why the parameter appears unavailable when attempted from the online view.

Why MC_Home Mode 7 Cannot Rescue a Misconfigured Encoder

Calling MC_Home with mode 7 (Absolute encoder adjustment) writes a home position offset based on the current position value returned by the technology object. If the technology object has already cleared the absolute reference on restart, the offset is computed against 0.0 and the home position snaps to 0.0 as well. Homing cannot rescue a configuration that has been told to ignore the encoder's absolute capability. The encoder evaluation flag must be set first; only then will MC_Home mode 7 behave as documented.

Prerequisites

  • Installed TIA Portal project containing the S7-1500 station, the TM PosInput 2, and the TO_ExternalEncoder.
  • Project consistent and successfully downloaded at least once prior to the fix.
  • CPU accessible from the engineering station via PROFINET or PROFIBUS.
  • User rights to edit the technology object configuration in the project.
  • Encoder manufacturer datasheet available, with single-turn resolution, multi-turn range, and protocol (SSI or PROFIdrive) documented.
  • Online backup of the current project for rollback if the new configuration produces unexpected results.

Encoder Selection in TIA Portal

When you add a TM PosInput 2 module to the device configuration, TIA Portal offers a list of supported encoders and protocols. The selection determines the default telegram and the default fine resolution.

Encoder Type Typical Telegram Default Fine Resolution Notes
SSI absolute encoder 83 0 bit XIST1, 12 bit XIST2 Most common selection for SSI encoders
EnDat 2.1 absolute encoder 83 0 bit XIST1, 12 bit XIST2 EnDat provides additional diagnostic data
PROFIdrive absolute encoder 83 or 86 Configurable Telegram 86 adds additional status words
Incremental encoder with homing 81 0 bit For incremental encoders; needs homing routine

If the encoder is not in the list, the User-defined entry allows manual configuration of telegram and fine resolution. Always cross-check the manual configuration against the encoder datasheet; mismatched fine resolution is one of the most common causes of position jumps in the commissioning phase.

Solution: Configure the TO_ExternalEncoder for Absolute Operation Offline

The configuration changes must be made offline, then compiled, then downloaded. Online-only modifications to technology object configuration data are silently rejected by TIA Portal, which is why the parameter appears unavailable when changed from the online view. This is a feature, not a bug: the technology object configuration is part of the project source of truth and must be reproduced from the offline project at every download.

Step-by-Step Procedure

  1. Open the project in TIA Portal and switch to the project tree.
  2. Navigate to Technology Objects > TO_ExternalEncoder_1 > Configuration.
  3. Open the Hardware interface section and select the encoder channel assigned to the TM PosInput 2.
  4. In the Encoder configuration page, set the encoder operating mode to support absolute position evaluation. For an SSI or PROFIdrive absolute encoder, this is typically the Absolute encoder parameter or the Encoder type selector in the configuration dialog.
  5. Switch to the Position parameters section and enable absolute value handling so that the technology object reads the encoder's absolute position on every restart instead of treating the counter as relative.
  6. If the application uses a circular range, leave Modulo enabled. Verify the modulo range matches the encoder's single-turn or multi-turn range to avoid wrap-around jumps in the displayed position.
  7. Under Fine resolution, confirm the values Gx_XIST1 = 0 bit and Gx_XIST2 = 12 bit match the encoder datasheet. The 12-bit fine resolution means the technology object can resolve the position to 1/4096 of one encoder increment.
  8. Confirm the encoder's direction setting (positive or negative count direction) matches the mechanical setup.
  9. Save the project.
  10. Right-click the S7-1500 station and select Compile > Hardware and Software (rebuild all).
  11. Download the compiled configuration to the CPU. The CPU may briefly transition to STOP during download; this is expected for configuration data.
  12. After download, switch the CPU to RUN and observe the technology object diagnostics.
Offline-only rule for technology objects: If the corresponding property page in the technology object is greyed out in the online view, the parameter belongs to the configuration data set of the technology object. Such parameters are loaded as part of the project and cannot be patched online. Always edit offline, recompile, and download.

Solution: Apply MC_Home Mode 7 in the User Program

Once the technology object is configured for absolute operation, MC_Home with mode 7 (Absolute encoder adjustment) performs an offset correction so the displayed actual position matches the configured home position. Unlike modes 0 to 6, mode 7 does not overwrite the encoder's mechanical reference; it only applies a software offset.

Structured Text Example


// Trigger absolute encoder adjustment
#instHome.Execute := TRUE;
#instHome.Mode := 7;               // Absolute encoder adjustment
#instHome.Position := 0.0;         // Target home position in user units
#instHome.Encoder := "TO_ExternalEncoder_1";
MC_Home_DB(#instHome);

// Wait for Done
IF #instHome.Done THEN
    #instHome.Execute := FALSE;
END_IF;

// Evaluate error
IF #instHome.Error THEN
    // Log ErrorID for diagnostics
    #diagErrorID := #instHome.ErrorID;
END_IF;

Conditions for a Successful Adjustment

  • The technology object must be enabled (MC_Power Status = TRUE).
  • The encoder must report a valid absolute value (check the technology object's StatusWord for the absolute-encoder bit).
  • The job must be triggered after the configuration download has been acknowledged and the CPU is in RUN.
  • If the home position is configured in the technology object as a non-zero value, either change the Position parameter in the MC_Home call to match, or set the home position in the technology object to 0.0 if the application requires a zero-referenced axis.

Interpretation of MC_Home Modes

Mode Name Behavior with Absolute Encoder
0 Direct homing absolute Overrides the mechanical reference with the supplied position. Not recommended for absolute encoders.
1 Direct homing relative Adds an offset to the current position.
2 Passive homing Waits for an external homing mark during motion.
3 Active homing Drives the axis to a homing mark.
5 Passive homing with reversal Like mode 2, but reverses on a missing mark.
6 Active homing with reversal Like mode 3, but reverses on a missing mark.
7 Absolute encoder adjustment Computes a software offset so the encoder's true absolute value aligns with the configured home position. Use this mode for absolute encoders.

Modulo Configuration Considerations

The modulo setting tells the technology object that the position is circular within a specified range. For a rotary encoder with 4096 increments per revolution, setting the modulo to 4096 user units produces a position display that wraps from 4095 back to 0 with no discontinuity. Mismatches between modulo range and encoder resolution cause unexpected behavior:

  • If modulo is smaller than the encoder's single-turn range, the position wraps mid-turn.
  • If modulo is larger than the encoder's single-turn range, the position accumulates over multiple turns and breaks the wrap-around semantics.
  • If modulo is set to 0 (off), the position accumulates over the encoder's full multi-turn range, which is appropriate for linear axes but rarely for rotary axes.

Verification Procedure

  1. Download the modified project to the CPU and let it transition to RUN.
  2. In the technology object diagnostics, confirm that the encoder is reported as absolute and that the Actual position value matches the encoder's mechanical position.
  3. Rotate the encoder to a known mechanical position (for example 4000 increments).
  4. Monitor the Actual position tag in the online watch table and confirm it follows the mechanical movement without jumps or oscillations.
  5. Switch the CPU to STOP, then back to RUN. Verify that the Actual position tag in the user program now retains the last known position instead of resetting to 0.0.
  6. Mechanically rotate the encoder by 90 degrees while the CPU is off, then power the CPU back on. The Actual position should reflect the new mechanical position immediately after restart.
  7. Execute MC_Home mode 7 once and verify that the absolute position is adopted as the configured home position without snapping to 0.0.
  8. Disconnect the encoder cable, re-connect, and verify the encoder value reappears correctly without a STOP-to-RUN transition.
  9. Cycle the CPU power three times in succession and confirm the position is retained across every cycle.

Troubleshooting Matrix

Observed Symptom Likely Cause Corrective Action
Actual position resets to 0.0 on every restart TO_ExternalEncoder not configured for absolute evaluation Edit the encoder configuration offline, compile, and download the project
Position jumps or oscillates when encoder rotates Fine resolution mismatch or incorrect sign evaluation Verify Gx_XIST1 and Gx_XIST2 resolution against encoder datasheet; check direction inversion setting
MC_Home mode 7 sets position to 0.0 instead of adopting absolute value Technology object still treats encoder as relative Apply the offline configuration fix described in this article before calling MC_Home
Configuration parameter greyed out online Parameter belongs to the configuration data set, not online-changeable Edit offline, recompile, download to CPU
Encoder value correct in TM PosInput diagnostics but wrong in TO_DB Different scaling or modulo range between module and TO Compare unit, modulo range, and fine resolution between the TM PosInput configuration and the TO_ExternalEncoder configuration
MC_Home returns error 16#8001 (job rejected) TO not enabled or no valid encoder signal Confirm MC_Power.Status, encoder cable wiring, and technology object StatusWord flags
Position wraps at unexpected values Modulo range too large or too small for the application Adjust modulo range to encoder's single-turn resolution or application requirement
Encoder counts in the wrong direction Direction inversion not set Toggle the Invert direction parameter in the encoder configuration and re-download
Multi-turn bits lost after power cycle Encoder battery backup missing or low Replace the encoder battery; verify battery monitoring wiring
Position display doubled compared to mechanical expectation Fine resolution applied twice or unit mismatch Verify encoder intrinsic fine resolution against configured Gx_XIST2; confirm unit setting matches between TM PosInput and TO

Reference: PROFIdrive Telegram 83 Layout

PZD Slot Name Meaning
PZD 1 (low word) Gx_XIST1 low Actual position value 1, low word
PZD 2 (high word) Gx_XIST1 high Actual position value 1, high word
PZD 3 (low word) Gx_XIST2 low Actual position value 2 (extended resolution), low word
PZD 4 (high word) Gx_XIST2 high Actual position value 2 (extended resolution), high word

Gx_XIST1 carries the absolute encoder position with the configured fine resolution of the lower bits stripped. Gx_XIST2 carries the additional fine-resolution bits, allowing the technology object to reconstruct the full position with sub-increment precision. With the 12-bit fine resolution specified in this application, the technology object resolves 4096 sub-increments per encoder increment.

Reference: Technology Object Status Word (TO_ExternalEncoder)

Bit Typical Symbolic Name Meaning
0 ActivationDone Technology object has been activated successfully
1 Error An error is pending; inspect ErrorID
2 ErrorAcknowledge Acknowledgement of an error in progress
3 UpdateDone Configuration data update completed
4 HomingDone Encoder has been homed successfully
5 AbsoluteEncoder Encoder is being treated as absolute
6 EncFault Encoder reports a hardware fault
7 Restored Retain data was successfully restored on restart
Bit names: The exact symbolic names of these bits vary slightly between TIA Portal versions. Always confirm by inspecting the technology object's instance DB in the project navigator. The meaning of each bit is consistent across versions.

Best Practices for Absolute Encoder Projects on S7-1500

  • Always edit technology object configuration data offline and download the compiled project. Do not rely on online parameter patching for technology objects; the configuration data set is only loaded at project download.
  • Cross-check the encoder's single-turn and multi-turn resolution against the configured modulo range. A mismatch produces silent wrap-around at unexpected angles and corrupts the position reference.
  • Use a Watch table with the technology object's StatusWord and ErrorID tags during commissioning. These tags surface issues before they propagate into the application logic.
  • Document the exact firmware version of the TM PosInput 2 module and the CPU. Different firmware versions change the available configuration options and the handling of multi-turn encoders.
  • Add a power-on initialization block that calls MC_Home mode 7 once after MC_Power reports ready. This guarantees the application sees a defined home reference on every cold start.
  • Never use MC_Home mode 0 (direct homing absolute) with an absolute encoder in production unless you deliberately want to override the mechanical reference. Mode 7 preserves the encoder's true absolute position while still providing the application's preferred zero reference.
  • For multi-turn encoders with battery-backed turn counters, include the battery voltage in your preventive maintenance schedule. A depleted battery silently breaks multi-turn capability while leaving single-turn operation intact.
  • Keep the encoder cable shield grounded at one end only. Splitting or floating the shield introduces noise that the technology object reports as intermittent EncFault flags.
  • When scaling user units, compute the conversion factor once and store it in a constant tag. Inline scaling arithmetic in the application obscures the relationship between encoder increments and user units.

Field-Proven Caveats

Several recurring failure modes show up in commissioning and can be diagnosed from the symptoms alone:

  • Mixing incremental and absolute configuration data: If the encoder itself is incremental but the technology object is set to absolute, the position drifts every power cycle. Always match the encoder's intrinsic type to the technology object setting.
  • Modulo mismatch with the encoder's mechanical range: An SSI encoder with 4096 increments per turn combined with a modulo range of 360000 user units produces wrap-around at unexpected mechanical angles. Either match the modulo range to the encoder's physical range or scale to the application's needs.
  • Fine resolution applied twice: If the encoder already provides its fine resolution in Gx_XIST1 and the technology object is configured with non-zero fine resolution, the position will appear doubled. Confirm the encoder's actual fine resolution before setting the technology object value.
  • Direction inversion triggered by cable swap: Swapping the A and B signals (or their digital equivalents) on the encoder cable inverts the count direction. Configure the inversion parameter correctly and verify by monitoring the count direction during a test rotation.
  • Configuration parameter silently ignored: A common symptom is that the engineer changes the absolute flag, sees the online view update, but the next power cycle resets the position. The change was never written to the offline project; it was a temporary online patch that the next STOP-to-RUN transition discarded.

Related Siemens Documentation

For deeper coverage of absolute encoder adjustment and the MC_Home instruction, refer to the following Siemens Industry Online Support entries:

FAQ

Why does the encoder value look correct in the TM PosInput diagnostics but reset to 0.0 in the TO_ExternalEncoder?

The TM PosInput reads the raw absolute position from the encoder and forwards it to the technology object through PROFIdrive telegram 83. The TO_ExternalEncoder, however, only treats that value as absolute when its configuration explicitly enables absolute evaluation. Until that flag is set and the project is recompiled and downloaded, the technology object clears the position on every STOP-to-RUN transition.

Can I change the absolute-encoder flag online, or must I always edit offline?

The flag is part of the technology object configuration data set, which is only applied at project download. Online-only edits appear greyed out or are silently rejected. Always edit offline, recompile the station, and download.

Which MC_Home mode should I use to retain the absolute encoder position?

Use mode 7 (Absolute encoder adjustment). It applies a software offset that aligns the encoder's true absolute value with the configured home position without overwriting the encoder's mechanical reference.

What does telegram 83 provide for an absolute encoder?

Telegram 83 is the PROFIdrive encoder telegram with two actual value words. Gx_XIST1 carries the absolute position without fine resolution; Gx_XIST2 carries the fine-resolution bits. With Gx_XIST2 set to 12 bit, the technology object reconstructs the full position with sub-increment precision of 1/4096.

How do I confirm that the absolute encoder flag is active after the project download?

Open the TO_ExternalEncoder online diagnostics and verify that the technology object reports the encoder as absolute. Then rotate the encoder mechanically while the CPU is off, then power on; the Actual position tag should reflect the new mechanical position immediately instead of resetting to 0.0.

Back to blog