Changing Simotion C240 Gear Ratio On-the-Fly Without Abort Alarms

David Krause12 min read
Motion ControlSiemensTutorial / How-to
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

Changing Simotion C240 Gear Ratio On-the-Fly Without Abort Alarms

Continuous-process machines (printing presses, film lines, slitters, winders, paper machines, and similar web/conveyor systems) require the gearing ratio between a master axis and a slave axis to be changed while the slave is already coupled and running. On the SIMOTION C240 PN controller, re-triggering the basic Gear on command with a new ratio while a gearing relationship is already active raises a gear aborted technology alarm and the slave axis is decelerated to a stop by the default error reaction. The system has to either run a new synchronization (phasing) sequence or stay in a permanent couple through an indirection layer that hides the ratio change behind a master-setpoint switch.

This reference documents the field-proven pattern that solves the problem: a virtual master axis layer plus the _setMaster (or MCC Change master setpoint) command, optionally combined with _setGearOffset to absorb any residual position error. ST and MCC examples are shown, parameters and alarm codes are mapped, and the commissioning checks that prove a clean on-the-fly ratio swap are listed step-by-step.

Applies to: SIMOTION C240 PN (6AU1240-1AA00-0AA0 and 6AU1240-1AB00-0AA0), firmware V4.4 / V4.5 / V5.1, programmed with SIMOTION SCOUT TIA V5.2 SP1 or later. Most steps also apply to SIMOTION D4x5 and SIMOTION P320 with the same firmware line.

1. Why Re-Triggering "Gear on" Fails

When the slave axis enters synchronous operation through the technology object command Gear on (MCC) or _gearingOn(...) (system function), the controller goes through the synchronous-operation state machine: STOPPING -> SYNCHRONIZING -> SYNCHRONOUS. The state transition from SYNCHRONOUS back into SYNCHRONIZING is only legal through a clean disengage (Gearing off / _gearingOff) or through the gearing-blending command. Calling Gear on a second time without an explicit disengage is rejected by the technology object with one of the following alarms:

Alarm Number Cause Default reaction
Synchronous operation aborted 20102 / 201802 (drive-side) Re-trigger of gear command while still coupled Axis stop, alarm latching
Command not allowed in current state 20005 Gear command issued in operating state SYNCHRONOUS without prior disengage Command rejected, no state change
Gear ratio invalid 201801 Ratio change requested with synchronization off, or ratio of 0 Command rejected
Following error outside window 20125 Offset cannot be absorbed in the configured synchronizing time Abort, alarm

Re-triggering therefore is not a valid method for live ratio updates. The next section shows the indirection architecture that the SIMOTION firmware does support natively.

2. Architecture: Virtual Master Axis Layer

The ratio is decoupled from the slave by inserting one or more virtual axes (technology object type TO_VirtualAxis) between the real master and the real slave. The real master follows virtual axis A with a fixed ratio; virtual axis A in turn follows virtual axis B; the real slave follows whichever virtual axis is currently selected as its master. By changing the selected master (with no slave stop, no resync) the effective ratio is swapped.

Real Master (Encoder / TO) VirtualAxis_A Ratio 1.000 VirtualAxis_B Ratio 1.000 Real Slave (Drive / TO) gear 1:1 (active) gear 1:1 (standby) _setMaster command

Both virtual axes run continuously (typically with the same velocity setpoint, setpointVelocity = masterVelocity). The slave can be "ganged" to either one of them at any time, and a switch between them is reported by the controller as a master change, not as a gear abort. With the slave following the virtual axis 1:1, all actual gear ratio change happens inside the virtual layer (real master → virtual axis ratio), which can be retuned live through _setMasterVelocity or by swapping its source between two real masters.

3. Function Blocks and MCC Commands

Item Type Purpose in this pattern
_setMaster (system function) ST / LAD / FBD Re-binds a slave TO to a different master TO at runtime. Valid in operating state SYNCHRONOUS when called with the same command id structure.
Change master setpoint MCC chart MCC equivalent of _setMaster; allows smooth or abrupt switch, and supports an additional velocity offset at the switch instant.
_setGearOffset ST system function Adds a position offset to the slave (or master) coordinate system; can be commanded for the current setpoint only, for future setpoints, or both. Used to absorb residual position mismatch after a ratio swap.
_setMasterVelocity ST system function Adds a velocity to a virtual master, on top of its current actual speed. With additive parameterization this is the cleanest live-ratio change inside the virtual layer: slaveVelocity = realMasterVelocity * ratioBase + deltaVelocity.
Gearing on (MCC) MCC command Engages the slave with its currently configured master. Called once at process start. Should not be re-called to change the ratio.
_gearingOff ST system function Disengages gearing. Only needed for full decoupling; not required for ratio swap.
The classic Simotion help on _setGearOffset states: "Moves the coordination system of the slave or master by a specified offset. Can be done for the current command only, for future commands only, or for current and future commands." Choose current and future when absorbing an error caused by a sudden master change, otherwise the offset is consumed by the next interpolator cycle.

4. Configuration in SCOUT TIA

4.1 Axis topology

  1. Create the real master TO (TO_ExternalEncoder or TO_SpeedAxis, depending on whether the master is a measured encoder or a drive-setpoint axis).
  2. Create two virtual axes, e.g. VirtAxis_RatioA and VirtAxis_RatioB (type TO_VirtualAxis). Both default length unit = 1 LU, default modulo = 360000000 LU.
  3. Create the real slave TO (e.g. Axis_Winder, type TO_SpeedAxis or TO_PositioningAxis).
  4. Configure a following axis interconnection (Axis → Following axis) for each virtual axis, with the real master as leading and the virtual as following. Ratio 1.0; synchronous operation enabled; same cycle clock (e.g. 1 ms IPO, 1 ms position-control cycle).

4.2 Synchronous-operation parameters on the slave TO

Parameter Value (typical) Note
Type of gearing Synchronous with absolute following Prevents position drift across gear swaps.
Gear ratio numerator/denominator 1 / 1 Slave follows the selected virtual master 1:1. The actual ratio lives in the virtual layer.
Synchronizing time 0.5 s Only used at first engage; subsequent master changes are immediate.
Max following error (gearing) 1.0 LU Tighter than the positioning window so a swap is observable in trace.
Position tolerance for synchronization 0.05 LU Required so that a re-synchronize after abort completes fast.

5. MCC Implementation

The MCC chart runs once at process start to engage the gearing, and exposes two Boolean inputs bUseRatioA and bUseRatioB plus one floating-point fRatio for the active ratio that the virtual master applies.

  1. Init: enable real master, then enable VirtAxis_RatioA and VirtAxis_RatioB; set both virtual axes to follow the real master (configure in SCOUT, do not command in MCC).
  2. Engage slave: Gearing on command on Axis_Winder with master = VirtAxis_RatioA.
  3. Live ratio change: on rising edge of bUseRatioA issue Change master setpoint with new master = VirtAxis_RatioA; on rising edge of bUseRatioB issue the same with VirtAxis_RatioB. Set the command parameter Smoothness = 1 (smooth cross-fade over 250 ms typical) to avoid a velocity step in the slave.
  4. Compensate residual offset: after the master-change commandId returns DONE, call Set master offset (or _setGearOffset in a coupled ST block) with the actual position difference between the previously followed and the newly followed virtual axis. Apply scope = "current and future".

6. Structured Text Implementation

The same logic expressed as an ST function block. Place it in the unit assigned to the IPO task (typically 1 ms) so the master change is serviced in the same cycle as the trigger.

FUNCTION_BLOCK RatioSwapAxis
VAR_INPUT
    bUseRatioA  : BOOL;          // TRUE = follow VirtAxis_RatioA
    bUseRatioB  : BOOL;          // TRUE = follow VirtAxis_RatioB
END_VAR
VAR
    sAxis       : AXIS_REF;      // slave TO reference (Axis_Winder)
    sVirtA      : AXIS_REF;      // VirtAxis_RatioA
    sVirtB      : AXIS_REF;      // VirtAxis_RatioB
    rt          : R_TRIG;
    rtB         : R_TRIG;
    cmdRet      : COMMAND_RET_VAL; // system return type
    offsetLU    : LREAL;
END_VAR

// Detect a falling edge of the previous selection: this is the
// change-of-master event
rt(CLK := bUseRatioA);
rtB(CLK := bUseRatioB);

IF rt.Q AND sAxis.State = AXIS_STATE_SYNCHRONOUS THEN
    // Bind slave to virtual axis A in the same cycle as the trigger
    _setMaster(slave := sAxis, master := sVirtA,
               commandId := GET_COMMAND_ID(),
               mergeMode := MERGE_MODE_IMMEDIATELY,
               nextCommand := CMD_NO_NEXT);
END_IF;

IF rtB.Q AND sAxis.State = AXIS_STATE_SYNCHRONOUS THEN
    _setMaster(slave := sAxis, master := sVirtB,
               commandId := GET_COMMAND_ID(),
               mergeMode := MERGE_MODE_IMMEDIATELY,
               nextCommand := CMD_NO_NEXT);
END_IF;

// After a successful master change, absorb the residual position gap
// by issuing a master-side offset. Read it from the previously
// followed virtual axis position minus the new one.
IF cmdRet.commandIdState = COMMAND_ID_STATE_DONE THEN
    offsetLU := _getAxisActualPosition(sVirtA) -
                _getAxisActualPosition(sVirtB);
    _setGearOffset(master := sAxis,
                   offset := offsetLU,
                   offsetMode := GEAR_OFFSET_MODE_CURRENT_AND_FUTURE);
END_IF;
END_FUNCTION_BLOCK
Always read commandIdState from the return struct of the previous _setMaster call before launching a second one. Stacking two _setMaster invocations in the same IPO cycle drops the second one silently on firmware V4.4 and raises alarm 20005 on V4.5+.

7. Verification and Acceptance Test

  1. Open the Trace tool in SCOUT, record the following signals on the slave TO for at least 3 s after the master change trigger: ActualPosition, SetpointPosition, VelocitySetpoint, FollowingError, OperatingState, and the new ActualMasterValue.
  2. Confirm that OperatingState stays at SYNCHRONOUS throughout the change (no transient SYNCHRONIZING, no STOPPING).
  3. Confirm FollowingError returns to within the configured tolerance (0.05 LU) within the configured synchronizing time.
  4. Confirm the alarm buffer is clean: no 20102, 201802, 20005 entries in the diagnostic buffer for the slave TO.
  5. Command a ratio change in both directions (A→B and B→A) and verify slave velocity changes by the expected factor with no axis stop.
  6. Force a forced _gearingOff from the user program; verify clean re-engage with the currently selected virtual master.

8. Edge Cases and Field-Proven Caveats

  • Modulo mismatch. If the two virtual axes have different modulo lengths, the slave's absolute position will jump by a multiple of the modulo at the switch. For winders, set the virtual axes to the same modulo as the slave (or to 0 = non-modulo) and use the gear-offset to absorb any phase error in linear units.
  • IPO clock mismatch. When the slave TO is in a different IPO clock than the master, the master change is delayed by one IPO tick. This is normal and is visible in the trace as a one-cycle delay on the velocity step.
  • Drive-side stop reactions. Even when the controller-side state stays SYNCHRONOUS, a SINAMICS drive that sees a velocity step larger than its p958 setpoint-off threshold may drop into follow-up mode. Verify the p958 / p959 SINAMICS parameters before commissioning.
  • Position-controlled slave. For TO_PositioningAxis slaves, the controller limits the velocity step at the master change to the value of Max acceleration (MCC dynamic limit). A jump from ratio 1.0 to 0.25 with a master running at 1500 rpm is fine; a jump from 0.05 to 1.0 is not, and the slave will take several hundred milliseconds to reach the new speed.
  • PROFIdrive telegram mismatch. The slave must have a SIEMENS telegram 1, 2, 3, 5, or 6 with the encoder word (Gn_XIST1/Gn_XIST2) enabled. Without that, the controller cannot read the actual position after the master change and the gearing will be aborted.
  • Use of _setMaster versus MCC. _setMaster takes effect in the same IPO cycle; the MCC Change master setpoint takes effect in the next IPO cycle because it goes through the command interpreter queue. For high-speed changes (sub-2 ms) prefer the ST system function.

9. Alarms and Diagnostics

Alarm Likely cause in this pattern Fix
20005 "Command not allowed in current state" _setMaster issued while slave is in STOPPING after a prior error Acknowledge errors, bring axis to STANDSTILL or SYNCHRONOUS first, then re-issue.
20125 "Following error outside window" Offset applied during a master change larger than the dynamic envelope Reduce offset step, increase Synchronizing time, or pre-warm the second virtual axis at the new ratio before switching.
F08501 (drive) "PROFIdrive sign-of-life failure" Master change coincided with a bus cycle drop Check PROFINET sync domain, raise Watchdog in the slave drive.
201801 "Gear ratio invalid" Ratio denominator = 0 in the slave TO configuration Re-enter the gear ratio with non-zero denominator; re-download to the C240.

10. Reference Documentation

When commissioning, keep these Siemens documents open alongside this procedure:

FAQ

Why does re-triggering "Gear on" on a SIMOTION C240 raise a "gear aborted" alarm while the axis is running?

The slave TO transitions to operating state SYNCHRONOUS on the first Gear on and rejects a second Gear on in that state. The controller raises alarm 20102 (controller-side) or 201802 (drive-side) and applies the configured alarm reaction, which by default is a controlled stop. Re-triggering is not a valid way to change ratios.

Can I change a gear ratio on a Simotion C240 without stopping the slave or resynchronizing?

Yes. Place a virtual master axis (TO_VirtualAxis) between the real master and the slave, have the slave follow that virtual axis 1:1, and change the actual ratio inside the virtual layer. The cleanest implementation uses _setMaster (ST) or the MCC command Change master setpoint to rebind the slave to a different virtual master at runtime, with _setGearOffset to absorb any residual position error.

What is the difference between _setMaster and the MCC command "Change master setpoint"?

Both rebind the slave TO to a different master TO. _setMaster takes effect in the same IPO cycle; the MCC command goes through the command interpreter queue and takes effect in the next IPO cycle. For sub-2 ms swaps use the ST system function. Both honor the same command-id lifecycle and both require that the slave TO is in operating state SYNCHRONOUS at the time of the call.

How do I remove a position step at the instant of the master change?

After the master change returns DONE, read the difference between the previously followed virtual axis position and the newly followed virtual axis position. Issue _setGearOffset with offsetMode = CURRENT_AND_FUTURE and that value. The slave TO redistributes the offset over the configured synchronizing time and the following error returns to the configured window without an axis stop.

What firmware version on the SIMOTION C240 is required for this pattern?

The pattern works on SIMOTION C240 PN firmware V4.4 and later. The behavior of stacked _setMaster invocations differs: V4.4 drops the second one silently, V4.5 and later raise alarm 20005. SCOUT TIA V5.2 SP1 or later is recommended for the editor and trace view of the relevant system variables.

Back to blog