S7-1200 MC_Home Mode 3 Position Drift: Flying Saw Troubleshooting

David Krause15 min read
S7-1200SiemensTroubleshooting
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

1. Problem Overview

Engineers building a flying saw on a SIMATIC S7-1200 CPU 1212C with a PTO/PWM-controlled or PROFIdrive-coupled servo frequently report a cumulative positional drift that appears only after a few dozen or a few hundred cut cycles. The motion sequence looks like this:

  1. MC_MoveVelocity synchronises the saw carriage to the material feed and triggers the cut at the calculated trigger point.
  2. After the cut is acknowledged, the application issues MC_Home in Mode 3 (active homing to a reference cam/sensor) with a Position input of 0.0.
  3. The drive finds the reference cam, decelerates, sets the actual position to the configured home coordinate, and the PLC drops the homing Execute bit.
  4. On the next cycle, the carriage no longer lines up with the reference sensor - the visual "home offset" appears to walk away from the cam over time.

Because Mode 3 physically re-references the axis to a fixed cam, the encoder-derived actual position is force-overwritten to the home coordinate on every cycle. A real world drift of the encoder reading therefore cannot be the root cause. The drift is always caused by one of three logical families:

  • The homing job never actually completes (it is aborted or superseded).
  • The homing job completes, but a second job overwrites the position before the cut geometry is re-established.
  • The application is writing a non-zero Position value, adding a software offset, or mishandling the Execute edge in a way that the documented block behaviour of MC_Home Mode 3 does not match.
Engineering rule: MC_Home in Mode 3 is the only motion control instruction that physically re-references the axis. If the axis truly completed Mode 3, the actual position is reset every cycle and there is no encoder value to "accumulate". An apparent drift means homing was not what the program believed it was.

2. Reference System Architecture

The architecture assumed in this article is the canonical low-cost S7-1200 flying-saw stack:

Component Typical Selection Notes
CPU 6ES7212-1AE40-0XB0 (CPU 1212C DC/DC/DC) or 6ES7212-1BE40-0XB0 (DC/DC/Rly) Firmware V4.2 - V4.6 recommended for axis TO V6/V7 features
Technology object TO_ServoAxis (PTO), TO_PositioningAxis, TO_SynchronousAxis Configured in TIA Portal V15.1 - V18
Servo drive SINAMICS V60 (PTO pulse train), V90 (PROFIdrive telegram 3), S110/S120 with PROFIdrive V60 uses pulse + direction, V90 uses PROFINET/PROFIBUS
Reference cam 24 V PNP proximity switch on a digital input Wired to a configured digital input of the axis TO
HMI/Programming TIA Portal V16/V17/V18, HMI for online monitoring Online monitor of instance DB is mandatory for diagnosis

The PLC open blocks used in the application are part of the MC library shipped with TIA Portal and are documented in the S7-1200 Motion Control V6 function manual (Siemens Support, 109751049).

3. How MC_Home Mode 3 Actually Works

The behaviour of the S7-1200 axis MC_Home instruction in Mode 3 is defined in the TIA Portal help and in the S7-1200 Motion Control manual. The simplified sequence is:

  1. On a rising edge of Execute, the axis accelerates from its current actual velocity to the configured approach velocity and moves in the configured approach direction.
  2. When the reference cam is detected, the axis decelerates and (if configured) runs a reducing velocity profile in the opposite direction to find the cam edge with controlled accuracy.
  3. Once the cam edge is reached, the axis stops and the actual position is set to the home position coordinate defined in the axis configuration (this is not the Position input on the block - that input is only used in Modes 0 and 1).
  4. Output Done is set for one cycle; output Busy falls; CommandAborted or Error is raised on failure.

Three block inputs matter for Mode 3:

Input Mode 3 Relevance Common Mistake
Execute Edge-triggered. Homing starts on a 0→1 transition. Holding Execute high continuously, or toggling it mid-motion, causes the block to either start a new homing attempt or to be aborted by the next job.
Position Not used in Mode 3. The home coordinate is taken from the axis technology object (parameter Home position). Passing a non-zero Position to Mode 3 has no effect. Engineers who think it shifts the home will observe the axis returning to the same physical location every cycle - looking like a fixed offset, not a drift.
Mode 3 = active homing to reference cam + zero mark (or cam + reversal, depending on configuration). Using Mode 0/1 by accident. Mode 0 sets the actual position to the Position input without any physical movement - a single PLC scan later, the next MC_MoveAbsolute with a relative offset will appear to walk the home point.
Critical: The Position input of MC_Home is greyed out or documented as "reserved" for Mode 3 in the TIA Portal help. If your code passes a value, the comment that says "home position 0.0" is misleading and should be removed.

4. Symptom: Position Walks After 70 - 250 Cycles

The 70-250 cycle window reported in the original case is a strong fingerprint. The encoder, drive, and mechanical axis are not slowly degrading; the trigger is programmatic:

  • After 70-250 successful homing attempts, some internal counter, edge, or memory flag in the application logic flips state. Common candidates:
    • 16-bit wrap of a "cycle counter" used to gate homing.
    • A flip-flop ladder that only re-arms every N cycles (e.g. the user thought they were homing every cycle, but they were homing every other cycle, and the alternate path skipped the cam check).
    • A watch-dog / fault latch that suppresses the homing Execute when the previous cut exceeded a tolerance window.
  • The PLC internal task cycle (typically 1 - 10 ms in the OB1 cycle) is missing a homing Execute edge because the input or the request tag is updated faster than the OB is dispatched.
  • The drive is in a follow-up state (e.g. SS1, STOP2, or fault) and the PLC issues MC_Home without first re-issuing MC_Power.Enable = TRUE; the job is queued, fails, and a subsequent MC_MoveVelocity starts with the encoder at its last true position.

Hence the visual signature: a flat, repeatable, accurate cut for tens to hundreds of cycles followed by an accumulating offset that grows at exactly the rate of the missed homings.

5. Root Cause Matrix

Use this matrix to map the symptom to the most likely category of fault. The first three rows cover 90 % of S7-1200 flying-saw drift cases seen in the field.

# Root Cause Diagnostic Indicator Fix
1 MC_Home Execute is not reset between cycles; a new motion job (e.g. MC_MoveVelocity or MC_MoveAbsolute) aborts the homing before it finishes. Instance DB shows Busy=FALSE, CommandAborted=TRUE, AbortID=16#8001 (job aborted) after most cycles where the offset grew. Wrap the Execute in a single-cycle pulse (rising-edge M-bit or use the MC_Home.Done to drop it). Block any other motion command until Done is seen.
2 User code is actually running Mode 0 or Mode 1, not Mode 3. The PLC "re-homes" the axis purely in software by overwriting the actual position. Encoder error then accumulates in the next sync window. Inspect the input wire to MC_Home.Mode. A common bug is wiring a tag that is re-assigned elsewhere. Hard-code Mode := 3 as a constant; do not pass it through a data block variable that other code can change.
3 MC_Power was toggled off (drive STO / SS1) and the application issues MC_Home before MC_Power.Status = TRUE. Homing is rejected; subsequent moves use the stale actual position. Sequence trace shows MC_Power.Status falling and rising around the failed cycle. Add a gate: homing is only allowed when MC_Power.Status = TRUE and MC_Home.Busy = FALSE.
4 Approach direction is wrong, the cam is missed, and the drive times out (Error=TRUE, ErrorID=16#800D "Homing error - homing cam not found"). Trace ErrorID; check that the cam is wired to the configured digital input and that Permit auto reverse at hardware limit switch is enabled in the axis configuration. Correct Approach direction; if the cam is on the far side of the travel range, enable Permit auto reverse at HW limit and verify the Reduction velocity profile.
5 Encoder increments per motor revolution or gearbox ratio is mis-scaled. The error appears to "accumulate" when in fact the position unit is wrong by a small factor. Issue one full mechanical revolution under MC_MoveAbsolute 360° and compare commanded vs. measured. Ratio mismatch shows as 1 - 3 % systematic offset. Recompute the Mechanics tab in the axis configuration: load revolutions, motor revolutions, leadscrew pitch.
6 PROFIdrive telegram 3 mismatch: MC_Home is issued against a SINAMICS drive that has the wrong telegram selected (e.g. telegram 1 instead of 3). Homing is silently ignored. Drive parameter p0922 does not match the TIA Portal telegram configuration. Set p0922 = 3 on the drive and cycle power.
7 Mechanical: the reference cam bracket is loose, or the proximity switch has a 1 - 2 mm dead-band that the axis is sampling differently under thermal expansion. Visual inspection of the cam. Encoder-derived drift correlates with ambient temperature. Mechanically fix the cam; consider a second confirmation cam.
8 Application is calling MC_Home but the drive was never absolute-referenced after a power cycle. The axis is in "homed but not referenced" state and the active homing succeeds without a real cam detection (depending on drive firmware). Drive parameter r2684.11 ("Homing valid") toggles on power cycle. Force a power-on active homing sequence on every CPU restart.

6. Diagnostic Procedure

Follow this sequence in order. Stop the line safely and run the saw in manual jog with TIA Portal online attached to the CPU.

  1. Pin the homing tag to a watch table. Add the MC_Home instance DB tags to a watch table: Execute, Busy, Done, CommandAborted, Error, ErrorID, Mode, Position.
  2. Single-step 300 cycles. Run the line at slow speed and increment a counter. Every cycle, screenshot or log the homing output states. Look for the first cycle where Done is replaced by CommandAborted=TRUE or Error=TRUE.
  3. Capture ErrorID and AbortID. Typical S7-1200 motion error IDs (per the Motion Control V6 manual):
    • 16#8001 – Job aborted by another job.
    • 16#800D – Homing error (cam not found / overrun).
    • 16#8012 – Encoder error / telegram failure.
    • 16#801C – Drive not enabled (MC_Power off).
  4. Confirm the cam is seen by the drive. In the drive's parameter list (V90 / S120), monitor r2526.0 (status of homing cam) and the digital input status word. The cam must transition 0→1 during the homing run.
  5. Plot actual position vs. cycle number. The plot must be a flat line at the home coordinate (with a single saw-tooth swing during the cut). Any linear slope proves that one of the homing jobs did not reset the position.
Safety: The flying saw moves a blade. Lock out the cut signal and use MC_MoveJog in manual mode with the blade retracted. Never diagnose motion faults with the blade engaged.

7. Step-by-Step Correction

Apply the corrections in the order listed. Each is independent and can be verified before moving to the next.

7.1 Make MC_Home.Execute a one-shot pulse

The classic S7-1200 homing pattern uses a positive edge on Execute and drops it after Done:

// FB "FlyingSawControl"
// Tags
VAR
  bReqHome   : BOOL;          // request from cycle sequencer
  bHomeStart : BOOL;          // one-shot pulse
  bHomeBusy  : BOOL;
  bHomeDone  : BOOL;
  bHomeErr   : BOOL;
  wHomeErrID : WORD;
END_VAR

// Edge generation
bHomeStart := bReqHome AND NOT bHomeBusy;

// Call
"MC_Home_DB"(Execute := bHomeStart,
             Position := 0.0,
             Mode     := 3,
             Busy     => bHomeBusy,
             Done     => bHomeDone,
             Error    => bHomeErr,
             ErrorID  => wHomeErrID);

// Self-reset: drop the request as soon as homing starts
IF bHomeBusy THEN
   bReqHome := FALSE;
END_IF;

7.2 Block other motion commands during homing

If MC_MoveVelocity or MC_MoveAbsolute is called while MC_Home is busy, the homing is aborted. Add a state machine gate:

CASE iState OF
  0: // Idle
     IF bSeq_CutDone AND NOT bHomeBusy THEN
        bReqHome := TRUE;
        iState   := 10;
     END_IF;
  10: // Homing in progress
     IF bHomeDone THEN
        bReqHome := FALSE;
        iState   := 0;       // ready for next cut
     ELSIF bHomeErr THEN
        // fault handling, latched
        bFault := TRUE;
     END_IF;
END_CASE;

7.3 Ensure MC_Power is healthy before homing

Insert a guard so that homing is only allowed when the drive is in "Operation Enabled":

bPowerOK := "MC_Power_DB".Status AND NOT "MC_Power_DB".Error;
bReqHome := bReqHome AND bPowerOK;

7.4 Pin Mode to a constant

Hard-code Mode := 3 at the call site. Do not route it through a DB that other FBs (especially a recipe block) can modify. Add a comment: "Mode 3 = active homing to reference cam; home coordinate from axis TO".

7.5 Verify the cam and digital input

Open the axis technology object in TIA Portal, go to Hardware, and check:

  • Selected digital input matches the physical wiring.
  • Input filter (in the CPU properties) is < 0.5 ms so the cam edge is sampled reliably at the configured approach velocity.
  • Cam is within the axis travel range; Permit auto reverse at hardware limit switch is enabled if the cam is beyond the start position.

7.6 Confirm telegram and scaling on PROFIdrive

For SINAMICS V90 PROFINET, set p0922 = 3 and verify:

Drive Parameter Value Meaning
p0922 3 Standard telegram 3 (positioning, 5/9 PZD)
p29000 1 Select basic positioner mode
p29002[0] 0 Setpoint via PROFINET
p2543 10 Position tracking tolerance

Cycle power after a parameter change. The drive will need a new absolute reference; issue an active homing once before resuming production.

8. Verification Tests

Run the following regression before re-qualifying the line for production.

  1. 1000-cycle homing test, no cut. Jog the axis to mid-travel, issue MC_Home Mode 3, monitor Done, repeat 1000 times. Pass criterion: Done = TRUE on every cycle, actual position returns to the same value within 1 encoder increment.
  2. 1000-cycle cut test, full speed. Run the production cut sequence. Plot the position at the trigger point. Pass criterion: standard deviation of the trigger position < 0.05 mm (or the tolerance required by the cut length).
  3. Power-cycle resilience test. Power off the CPU, power back on, run a homing cycle, run a cut. Pass criterion: first cut is on target.
  4. Forced abort test. While MC_Home is busy, issue a MC_Stop. Pass criterion: Error = TRUE with ErrorID = 16#8001 (job aborted) and the axis stops without jerk or overshoot.

9. Best Practices for Flying Saw on S7-1200

  • Use a synchronous axis (TO_SynchronousAxis) for the saw carriage and a virtual leading axis (TO_ExternalEncoder or a counter-based virtual axis) for the material. The MC_GearIn / MC_CamIn commands handle the synchronization; reserve MC_Home for setup only.
  • Home once at power-up, not every cycle. The original post mentions homing after every cut. That is unnecessary wear on the brake and on the reference cam. A clean implementation homes on the first motion enable, then uses MC_MoveAbsolute for the return stroke.
  • Use MC_MoveAbsolute to the home coordinate rather than re-homing. The axis can be moved to Home position directly if it is already referenced. This avoids the cam and is faster.
  • Watch the MC_Home Execute tag with a rising-edge detector (R_TRIG) in every code path. A held Execute does not re-trigger homing; it just keeps the job queued.
  • Keep the homing Position input at 0.0 in Mode 3 for code clarity, but also document in the comment that the value is unused in Mode 3.
  • Latch ErrorID in a fault log so that the support engineer can see the history when the next line call comes in at 3 a.m.
  • Validate the encoder on every power-up by issuing a slow jog in both directions; if the actual position changes proportionally, the encoder is healthy.

10. Related Axis Parameters and Their Failure Modes

Parameter (Axis TO) Default Recommended Failure Mode If Wrong
Approach velocity 100 LU/min 20 % of max feed velocity Too high: cam missed; too low: cycle time penalty
Reduction velocity 50 LU/min 5 % of approach velocity Too high: overshoot at cam edge; too low: vibration
Permit auto reverse at HW limit FALSE TRUE if cam is past home FALSE: axis stops at the limit, homing times out
Home position offset 0.0 Equal to the desired home coordinate in LU Wrong value: axis stops at the wrong physical location
Encoder increments per revolution 1024 Match the encoder nameplate Wrong: systematic scaling error in position
Gear ratio (load / motor) 1:1 Match the mechanics Wrong: position appears to drift mechanically
Leadscrew pitch (mm/rev) 1.0 Match the real screw Wrong: linear position off by a constant factor

For the canonical S7-1200 motion configuration procedure, see the Siemens S7-1200 Motion Control V6 function manual and the S7-1200 Easy Speed Control application example. For SINAMICS V90 telegram configuration, see the SINAMICS V90 PN Function Manual.

11. FAQ

Why does the S7-1200 flying saw drift only after 70-250 cycles and not on the first run?

Because the drift is not mechanical; it is the symptom of a homing job that occasionally aborts. As soon as one cycle fails to complete Mode 3, the actual position is no longer re-zeroed. Each subsequent failed homing adds a small offset equal to the cam-to-cut travel, producing the visible "walk" that you observe after a few dozen cycles.

Does the Position input on MC_Home matter in Mode 3?

No. In Mode 3 the actual position is set to the Home position parameter of the axis technology object after the cam is detected. The Position input on the block is only used in Modes 0 (absolute set) and 1 (relative set). Set it to 0.0 for readability but understand that it has no effect on Mode 3.

Which MC_Home error ID means "cam not found"?

16#800D on the S7-1200 motion control block. Verify the approach direction in the axis TO, enable Permit auto reverse at hardware limit switch if the cam is on the far side of the travel range, and confirm the digital input wiring matches the configuration.

Can I home only once at power-up instead of every cycle?

Yes, and it is the recommended pattern. Call MC_Home Mode 3 once when MC_Power.Status becomes TRUE after a CPU start. Use MC_MoveAbsolute with the home coordinate for the return stroke between cuts. Reserve MC_Home for loss-of-reference recovery.

Why does the drive ignore MC_Home issued right after a power cycle?

On a power cycle the SINAMICS drive loses its absolute encoder reference. The first motion command after power-up must be an active homing, and MC_Power must already report Status = TRUE when the homing is started. If homing is queued before MC_Power.Status rises, the job is rejected with ErrorID = 16#801C (drive not enabled).

What is the difference between MC_Home Mode 0 and Mode 3 for a flying saw?

Mode 0 sets the actual position to the Position input value without any physical movement. Mode 3 moves the axis to a reference cam and only then sets the actual position. Use Mode 0 only when the axis is mechanically at the home coordinate and you want to re-anchor the coordinate. For the first reference after power-up, use Mode 3.

Back to blog