Problem Definition: Modulo Axis Long-Term Position Drift
A SINAMICS S210 application controlled by a SIMATIC S7-1500 uses a positioning axis configured as a modulo axis. The mechanical chain consists of:
- Servomotor SIMOTICS S-1FK2204-5AK00-0MA0 with absolute encoder AM22DQC G02 (22-bit single-turn, 4,194,304 inc/rev).
- Planetary gearbox with nominal reduction i = 14.57 (measured: 1705 motor revolutions per 117 load revolutions).
- Sprocket with 17 teeth on the load shaft.
- Chain with 130 teeth at pitch 19.05 mm (total chain length 130 × 19.05 = 2,476.5 mm).
- Modulo length set equal to the chain length (2,476.5 mm).
After several modulo cycles, the displayed axis position drifts away from the physical position. For indexing, gantry synchronization, or chain-driven transfer lines this drift causes loss of absolute reference to the work-piece, phase errors, and mandatory re-homing.
The root cause is documented in the SINAMICS S210 system documentation. Section 3.2.4 Long-term accuracy states:
"Long-term accuracy means that the technological position from the accumulated encoder increments can be exactly determined (without a rounding error) and are thus always accurate. The axis position indicated by the control always corresponds to the real position."
The condition for long-term stability is that the number of encoder increments corresponding to one modulo cycle is an exact integer. When the increments-per-cycle value is a non-terminating decimal, the controller rounds the conversion and a residual error accumulates with every wrap-around. The drift seed is small per cycle, but over thousands or millions of cycles the cumulative error is observable and, in safety-relevant applications, hazardous.
Mechanics of Modulo Axis Long-Term Stability
A modulo axis positions cyclically within a defined length L. When the actual position exceeds L it is wrapped back to 0. For the technology object (TO) to maintain a stable physical-to-logical mapping after every revolution, the encoder increment count corresponding to one modulo cycle must be a finite, exact integer.
If the increments per modulo cycle are non-integer (e.g. 467,422,054.802 inc/cycle), the controller rounds the result. Each wrap introduces a residual of the fractional part. After N cycles the drift is:
Driftinc = N × ( incround − inctrue )
The numerical traversing range of the S7-1500 modulo axis is bounded. The SINAMICS S210 Function Manual states:
"Modulo axes are accordingly stable at least as long as they do not exceed the numerical traversing range of 9.0E12 mm at 1000 increments per unit."
Re-stated in algebraic form, long-term stability requires:
Δsmodulo = Eres × ( Ngear / Dgear ) × (1 / Pload) × Lmodulo ∈ ℤ
where:
- Eres = encoder increments per motor revolution
- Ngear, Dgear = load gear numerator (motor side) and denominator (load side)
- Pload = load revolutions per length unit (e.g. sprocket teeth / chain pitch)
- Lmodulo = modulo length in user units
If any factor introduces a non-terminating decimal in the product, drift is unavoidable.
System Configuration Overview
The hardware components involved in the long-term stability calculation are summarised below.
| Component | Designation | Specification |
|---|---|---|
| Controller | SIMATIC S7-1500 | Firmware V2.5 or later (Technology Object V5.0+ feature set) |
| Servo drive | SINAMICS S210 | 6SL5 series, firmware V5.2+ (see SINAMICS S210 Function Manual) |
| Servomotor | SIMOTICS S-1FK2 1FK2204-5AK00-0MA0 | Frame size 28, 0.4 kW, 3,000 rpm, with absolute encoder AM22DQC G02 |
| Encoder | AM22DQC | 22-bit single-turn, DRIVE-CLiQ interface, 4,194,304 inc/rev |
| Gearbox | Planetary, vendor-supplied | Nominal i = 14.57, measured 1705 : 117 (irreducible) |
| Sprocket | 17 teeth on load shaft | Pitch 19.05 mm (ANSI #60 chain) |
| Chain | 130 teeth, pitch 19.05 mm | Total length 2,476.5 mm (modulo range) |
The encoder resolution is the foundation of every subsequent calculation. For the 1FK2204 with AM22DQC:
Eres = 222 = 4,194,304 inc/rev
DRIVE-CLiQ transports the position to the S210 and onward to the S7-1500 TO as a 32-bit value per DRIVE-CLiQ cycle (typically 125 µs).
Topology Diagram
Encoder Resolution and Incremental Math
A 22-bit encoder delivers 222 = 4,194,304 distinct positions per mechanical revolution. Inside the S7-1500 TO, this is multiplied by the load gear ratio to obtain a load position in length units (LU). For the gearbox in the example:
incload rev = Eres × Ngear / Dgear
= 4,194,304 × 1705 / 117
= 7,151,288,320 / 117
= 61,122,121.538461... inc/load rev
The decimal part (.538461...) is the drift seed on the gearbox side. Each load revolution the controller must round, introducing a residual of approximately 0.461538 increments per revolution (≈ 0.46 mm at 1 inc/mm).
The chain-driven mechanism compounds the issue. The sprocket is fixed to the load shaft. The chain wraps around the sprocket. For one full chain traversal (one modulo cycle), the sprocket must rotate:
Rsprocket = Nchain / Nsprocket = 130 / 17 = 7.6470588235...
And the motor must complete:
Rmotor = 7.6470588235 × 1705 / 117 = 111.43795... revolutions
Encoder increments per modulo cycle:
incmodulo = 4,194,304 × 111.43795... = 467,422,054.8025...
The fractional part 0.8025 increments per cycle is the modulo-side drift seed. After 1,000 cycles the loss is 802.5 increments (≈ 0.19 mm). After 1,000,000 cycles it is 802,500 increments (≈ 191 mm). This is the mathematical explanation of the observed long-term drift.
Calculating Increments per Modulo Cycle
Use the following six-step procedure to evaluate long-term stability for any SINAMICS S210 axis.
- Determine encoder resolution. Eres = 2bits (single-turn) where bits = 22 for AM22DQC, 20 for AM20DQC, 24 for AM24DQC.
- Determine the load gear ratio as an irreducible fraction. Read the gearbox nameplate; measure if possible by rotating the load shaft a known number of revolutions and counting motor revolutions. Verify GCD(Ngear, Dgear) = 1.
In the example: 1705 : 117. 1705 = 5 × 11 × 31, 117 = 9 × 13, GCD = 1 — the ratio is irreducible.
- Identify the chain/sprocket mechanics. Sprocket revolutions per modulo cycle: Rsprocket = Nchain / Nsprocket.
- Compute total motor revolutions per modulo cycle. Rmotor = (Nchain / Nsprocket) × (Ngear / Dgear).
- Compute increments per modulo cycle. incmodulo = Eres × Rmotor.
- Test for integer-valued result. If int(incmodulo) = round(incmodulo), the axis is long-term stable. Otherwise, drift is unavoidable.
Worked example with the user's data:
E_res = 4,194,304
N_gear = 1705
D_gear = 117
N_chain = 130
N_sprocket = 17
R_motor = (130 / 17) × (1705 / 117)
= (130 × 1705) / (17 × 117)
= 221,650 / 1,989
= 111.43795...
inc_modulo = 4,194,304 × 111.43795...
= 467,422,054.8025...
fractional part = 0.8025 → DRIFT, no long-term stability
Boundary Conditions for Modulo Axes
The Siemens support document 61055938 Boundary conditions for mechanics settings for modulo axes (long-term stability) states:
"Long-term stability ensures that the positions measured by the encoder and the internal representation of the actual values are always synchronous. This enables the user to rely on the position value of the axis at all times."
The mathematical condition for long-term stability derived from this reference is that the conversion from encoder increments to the technological length unit modulo L must be a bijective integer mapping. The boundary conditions are:
| Condition | Formulation | Violation Effect |
|---|---|---|
| Integer increments per modulo cycle | Eres × Ngear / Dgear × (1 / Pload) × Lmodulo ∈ ℤ | Per-cycle rounding error; drift accumulates |
| Load gear fraction in lowest terms | GCD(Ngear, Dgear) = 1 | Hidden simplification in TO changes effective ratio |
| No floating-point scaling inside the TO | Use integer-type numerator/denominator only | Compiler-dependent rounding |
| Maximum numerical range | 9.0 × 1012 mm at 1,000 inc/mm (Δs counter) | Internal overflow → mandatory re-home |
For the worked example, the chain pitch 19.05 mm = 0.75 in is the ANSI #60 chain standard. The pitch value is exact in decimal form (rational 381/20), but the 130/17 sprocket ratio is not a rational number with terminating binary representation. The non-integer quotient is the source of all drift.
Configuration in TIA Portal Technology Object
The mechanics configuration is performed in the technology object (TO) under Configuration > Mechanics. The critical parameters for this system are:
TO_PositioningAxis_1.Mechanics:
LoadGear.Numerator := 1705 // motor revolutions
LoadGear.Denominator := 117 // load revolutions
Modulo.Length := 2476.5 // mm
Modulo.Enable := TRUE
PositionUnits := mm
Two more parameters are critical for stable operation:
TO_PositioningAxis_1.Homing:
HomingMode := 5 // passive homing to reference cam
HomePosition := 0.0
TO_PositioningAxis_1.PositionLimits:
MinPosition := 0.0
MaxPosition := 2476.5 // identical to Modulo.Length
Verify in the TO commissioning view that the calculated load position and the actual mechanical position agree to within one encoder increment. If the actual position drifts after several modulo cycles, the chain mechanics or load gear has a non-integer ratio. Open the S210 commissioning in TIA Portal (Startdrive) and use the trace function to record r0479 (position actual value, encoder 1) over multiple revolutions; a return to the start of the modulo range without drift is the acceptance criterion.
For high-resolution applications where the ratio is fixed by mechanics, the S210 provides the parameter p408[0] (encoder increments) configurable in Startdrive under Encoder > Configuration > Resolution. Default is 222 for AM22DQC. Adjusting this value changes the per-revolution increment count and can be used to align the mechanics with an integer mapping — but it also changes the absolute resolution of every positioning command, so it should be used only with a full understanding of the consequences.
Solutions for Achieving Long-Term Stability
Five practical approaches are available, listed in order of preference.
Solution 1 — Match chain length to integer sprocket revolutions. Change the chain so the number of chain teeth is an integer multiple of the sprocket teeth. This makes the sprocket-revs-per-modulo an integer.
| Chain Teeth | Sprocket Revs per Modulo | Modulo Length (mm) | Notes |
|---|---|---|---|
| 119 = 7 × 17 | 7 (exact) | 2266.95 | Smallest viable whole-multiple |
| 136 = 8 × 17 | 8 (exact) | 2590.80 | Longer stroke, fewer wraps per shift |
| 153 = 9 × 17 | 9 (exact) | 2914.65 | — |
| 170 = 10 × 17 | 10 (exact) | 3238.50 | — |
However, this alone does not solve the long-term drift because the combined motor-revs-per-modulo still contains the non-integer gearbox ratio 14.57. With 119 teeth and 7 sprocket revolutions per modulo:
incmodulo = 4,194,304 × 7 × 14.572649... = 427,953,720.6...
Still not integer. Solution 1 removes the sprocket-side non-integer factor but leaves the gearbox factor in place.
Solution 2 — Combine gearbox and chain mechanics into a single load gear fraction.
Combined_ratio = (N_gear × N_chain) / (D_gear × N_sprocket)
= (1705 × 130) / (117 × 17)
= 221,650 / 1,989
GCD(221650, 1989) = 13 (1989 = 3^2 × 13 × 17; 221650 = 2 × 5^2 × 11 × 13 × 31)
Reduced ratio = 17,050 / 153
LoadGear.Numerator := 17050
LoadGear.Denominator := 153
Modulo.Length := 2476.5 // mm, unchanged
Resulting increments per modulo:
incmodulo = 4,194,304 × 17,050 / 153 = 71,512,883,200 / 153 = 467,404,465.359...
Still non-integer. The 222 = 4,194,304 factor (pure power of 2) cannot be cancelled by the 153 = 9 × 17 denominator, so this solution also leaves a residual of 0.359 inc/cycle.
Solution 3 — Configure the S210 encoder resolution (p408) to align with the mechanics. Choose p408 such that Eres × 17,050 / 153 is integer. The smallest Eres satisfying the condition is Eres = 153 × k for integer k; the value must also be ≤ 222 = 4,194,304. k = 27,413 gives Eres = 4,194,189. This is within range, but the resulting position resolution is no longer binary-aligned, and Startdrive must be used to set p408. Reserved for advanced users.
Solution 4 — Adjust the length unit to make increments per LU integer. TIA Portal allows free selection of the length unit (LU). Choosing an LU such that exactly 1 LU corresponds to a rational sub-multiple of the chain pitch can convert a non-integer ratio into an integer one. For chain pitch 19.05 mm and 1 LU = 0.05 mm, the controller maps 381 LU per chain pitch. Re-compute:
incmodulo = 4,194,304 × 17,050 / 153 × 0.05/19.05 = integer?
With careful LU selection (e.g. 1 LU = 0.762 mm such that 25 LU = 1 chain pitch), the integer condition can sometimes be met without changing the mechanics. This solution requires iterative evaluation per application.
Solution 5 — Periodically re-home and accept the residual drift. This is the fallback. If the application tolerates bounded drift and a homing reference is available, call MC_Home periodically with Mode := 5 (passive homing to a reference cam) or Mode := 7 (set home position directly) when the chain crosses a known reference mark. The bounded drift per cycle is:
Driftper cycle = ( incmodulo − round(incmodulo) ) / incmodulo × Lmodulo
For the worked example (Solution 2 case): 0.359 / 467,404,465 × 2476.5 = 1.9 µm per cycle. A re-home every 10,000 cycles limits drift to 19 mm; every 1,000 cycles to 1.9 mm; every 100 cycles to 0.19 mm.
Recommended hybrid approach for this application. Implement Solution 2 (combined load gear 17,050 : 153) together with Solution 5 (periodic passive re-home on a cam at 0 mm of the chain). The combined load gear reduces the per-cycle drift to 1.9 µm, and a re-home once per hour at 1 Hz cycle rate holds the maximum accumulated drift under 6.8 mm. This is acceptable for most transfer-line applications and is a pure software fix — no mechanical rework is required.
Verification and Acceptance Test
After configuration, perform the following tests in the TIA Portal commissioning environment.
Test 1 — Static repeatability.
- Run the axis to position 0 (modulo start).
- Read
TO_PositioningAxis_1.PositioningState.ActualPosition. - Move +10 full modulo cycles using
MC_MoveRelative. - Read
ActualPosition. It should equal the original value ± 1 increment. - Repeat 10 times and compare the standard deviation of the readings.
Test 2 — Long-duration drift.
- Record
ActualPositionat a known mechanical reference (e.g. proximity switch cam). - Run 100,000 modulo cycles at the operational speed.
- Re-read
ActualPositionat the same mechanical reference. - The deviation is the long-term drift. Acceptance criterion: |Δpos| ≤ 1 increment of Modulo.Length = 0.00059 mm (with 1 inc = 2,476.5 / 4,194,304 × 111.44 ≈ 0.00059 mm).
Test 3 — Increments-per-cycle check. Use the S7-1500 trace to record ActualPosition at the moment the modulo counter wraps. Confirm the wrap is from Lmodulo to 0 without any sub-integer offset.
Test 4 — S210 trace. In Startdrive, trace r0479[0] (position actual value, encoder 1) over multiple revolutions. Confirm the position value returns to the start of the modulo range without drift. Cross-check with the TO's ActualPosition at the same moment.
Troubleshooting Matrix
| Symptom | Probable Cause | Diagnostic Step | Corrective Action |
|---|---|---|---|
| Position drifts over multiple modulo cycles | Non-integer increments per modulo | Compute incmodulo = Eres × (N_chain/N_sprocket) × (N_gear/D_gear) | Apply Solutions 2 and 5 (combined load gear + periodic re-home) |
| Drift present even with integer gear ratio | Sprocket teeth count error or wrong pitch | Measure pitch with caliper; verify tooth count visually | Use exact measured pitch; update Modulo.Length |
| Drift accumulates slowly (sub-µm per cycle) | Floating-point precision in TO scaling | Use higher resolution LU; verify GCD(N,D) = 1 | Use LREAL in any custom scaling function |
| Position resets to 0 unexpectedly | Modulo range mismatch with mechanical stroke | Compare Modulo.Length to physical chain length | Set Modulo.Length = N_chain × pitch |
| Encoder alarm F3x117 or A33405 on S210 | Encoder initialization error | Check DRIVE-CLiQ connection, cable shielding | Re-seat connector; check S210 firmware matches motor encoder type |
| Homing required after each restart | AM22DQC is single-turn, not multi-turn | Confirm encoder type on motor nameplate | Use AM22DQI (multi-turn) or re-home on each power-up |
| S210 reports position following error F07452 | Mechanical binding, incorrect Kv factor | Check Kv in TO configuration; verify mechanical free movement | Adjust Kv (position loop gain) within S210 commissioning limits |
| Trace shows oscillation around setpoint | Kv too high or low-pass filter missing | Review p1460, p1462 in Startdrive | Tune position controller per S210 commissioning manual |
The AM22DQC encoder is single-turn (22-bit, 4,194,304 positions per motor shaft revolution). At power-up the controller does not know the absolute shaft position; the axis must perform an active homing sequence on every power-up. If the application requires absolute position retention across power cycles, the encoder must be upgraded to the multi-turn variant AM22DQI (22-bit + 12-bit revolutions, 4,194,304 × 4,096 total positions) when ordering the 1FK2 motor. The DRIVE-CLiQ interface and the S210 wiring remain identical.
Numerical Worked Example — Quantifying the Drift
Given the system as described in the problem statement:
E_res = 2^22 = 4,194,304 inc/rev
N_gear = 1705
D_gear = 117
N_chain = 130
N_sprocket = 17
pitch = 19.05 mm
L_modulo = 130 × 19.05 = 2,476.5 mm
Total motor revolutions per modulo cycle:
Rmotor = (130 × 1705) / (17 × 117) = 221,650 / 1,989 ≈ 111.43795
Increments per modulo cycle:
incmodulo = 4,194,304 × 221,650 / 1,989 = 929,802,265,600 / 1,989 ≈ 467,422,054.8025
Fractional part = 0.8025 inc/cycle (drift seed).
Drift as a function of cycle count:
| Cycles | Drift (increments) | Drift (mm) |
|---|---|---|
| 1,000 | 802.5 | 4.25 |
| 10,000 | 8,025 | 42.5 |
| 100,000 | 80,250 | 425 |
| 1,000,000 | 802,500 | 4,252 |
Conversion uses the ratio inc/mm = 467,422,054.8 / 2,476.5 ≈ 188,742 inc/mm. At a 1 Hz cycle rate, drift exceeds 1 m within 235,000 seconds (~65 hours) of continuous operation. This is the observed long-term instability. Without configuration changes, the position is fundamentally not bit-exact, and drift is a mathematical certainty, not a measurement artefact.
Related Considerations
For applications where the modulo axis participates in a synchronous operation (e.g. camming, gearing, or cross-coupled master/slave), the same long-term condition applies to the gantry or synchronous axis. The LoadGear of the synchronous axis must be evaluated against the encoder resolution of the master axis. Cross-coupling two axes that are individually long-term stable does not necessarily yield a long-term stable relative position — both must be evaluated together.
For non-Siemens controllers, the same mathematical condition applies. The Beckhoff Information System reference for the TC2 MC2 library states that modulo positions are wrapped at the start value if the deviation is less than one increment in the target direction. This is functionally equivalent to the Siemens S7-1500 behaviour, but the Beckhoff implementation uses different rounding semantics for the modulo wrap. When migrating a modulo axis between vendors, re-evaluate the long-term stability condition against the new controller's encoder resolution and scaling rules.
FAQ
What causes long-term position drift in a S7-1500 modulo axis with SINAMICS S210?
Drift occurs when the number of encoder increments per modulo cycle is not an integer. The controller rounds to the nearest integer, and the residual error accumulates every cycle. Typical causes are non-integer gear ratios (e.g. i = 14.57), sprocket/chain teeth ratios that share no common factor, or floating-point conversions in the technology object scaling.
How do I calculate if my axis is long-term stable?
Compute inc_per_modulo = EncoderResolution × (chain_teeth / sprocket_teeth) × (gear_numerator / gear_denominator). If the result is a pure integer, the axis is long-term stable for the given modulo length. For a SIMOTICS 1FK2 with AM22DQC encoder, the resolution is 4,194,304 increments per motor revolution.
If I change the chain to a whole multiple of the sprocket teeth (e.g. 119 = 7 × 17), will long-term stability be achieved?
No. Making the chain length an integer multiple of the sprocket teeth eliminates the sprocket-side non-integer factor (sprocket_revs_per_modulo becomes exactly 7), but the combined motor-revs-per-modulo still contains the non-integer gearbox ratio 14.57. The result is still a non-integer increments-per-cycle value. To achieve true long-term stability, the combined ratio (gearbox × sprocket × chain) must yield an integer when multiplied by the encoder resolution.
Why does the AM22DQC encoder not retain absolute position after power-off?
The AM22DQC is a 22-bit single-turn absolute encoder. It knows the shaft position within one revolution, but not the number of revolutions since power-up. The SINAMICS S210 therefore requires an active homing sequence on each power-up. For absolute position retention, specify the multi-turn variant AM22DQI (22-bit + 12-bit revolutions) when ordering the 1FK2 motor.
What is the maximum numerical traversing range of a S7-1500 modulo axis?
According to the SINAMICS S210 Function Manual Section 3.2.4, the maximum numerical traversing range is 9.0 × 10^12 mm at 1,000 increments per mm. Exceeding this range produces an overflow of the internal position counter. For a 2.4765 m modulo length, the theoretical maximum cycle count before overflow is 3.6 × 10^12 cycles — effectively unreachable in practical applications.
Can I rely on periodic re-homing instead of solving the long-term stability equation?
Yes, if the application tolerates bounded drift and a homing reference (proximity switch, cam, or absolute marker) is available. With a combined load gear of 17,050 : 153 the per-cycle drift is 1.9 µm. A re-home once per hour at 1 Hz cycle rate caps the drift at 6.8 mm. For tighter budgets, re-home more frequently or apply the integer-resolution technique (Solution 3) using the S210 parameter p408.