SINUMERIK 840D sl: Auto-Reset Tool Sequence on Gantry Interrupt
When a cycle is interrupted on a SINUMERIK 840D sl controller mid-sequence (T1→T2→T3→T4) on a gantry-style machine, the default behavior is a REPOS-style resume from the last decoded block. Operators who need to discard the in-process workpiece and restart the sequence from a defined tool index require a deterministic ASUB-driven reset path. This reference covers the NC, PLC, and HMI Operate configuration that implements an auto-reset of the tool sequence and increments a reject counter, with explicit handling of the gantry axis pair so the reset cannot desynchronize the coupled axes.
1. Problem: Interrupt at T3, Resume vs. Reset
The reported scenario: a part-program runs T1 D1 → T2 D1 → T3 D1 → T4 D1 on a gantry machine. An NC STOP / alarm / safety stop fires while T3 is engaged. When the operator presses NC START again, the controller executes the configured REPOS mode (REPOSA, REPOSL, REPOSQ, or REPOSH) and re-runs the T3 work as rework on the same workpiece. The required behavior is to:
- Treat the interrupted workpiece as scrap.
- Restart the tool sequence from a defined index (typically T1) on a fresh part.
- Suppress REPOS for this class of interrupt.
2. Root Cause: Why REPOS Resumes T3
The 840D sl kernel preserves decoded block context across NC STOP and stores the REPOS offset in $AC_REPOS_PATH_MODE and the axis positions in $AA_REPOS_DELAY. On NC START, the interpreter branches to the saved block and re-executes any motion and auxiliary function still pending. Because T"name" or T<n> is decoded as a tool selection request and M6 is the tool change, the interpreter sees T3 as still due; the REPOS path simply completes that block set.
| Trigger | REPOS default | Effect on T3 | Auto-reset path |
|---|---|---|---|
| NC STOP + START | REPOSA / REPOSL | Re-executes T3 work | Operator menu or GUD check |
| Alarm class ALCmxh with RESET | Reset, no REPOS | Sequence cleared, scrap flag required | ASUB on PROG_EVENT |
| Safety stop (STOP E/F) | Safe stop, REPOS on ack | Drift dependent | Manual intervention mandatory |
| M00 / M01 | No REPOS | Resumes inline | Direct RESTART, no scrap |
The configured REPOS mode is read from machine data MD20150 $MC_GCODE_RESET_VALUES[2] for G-code group 2 (REPOS) at reset, and the active mode is stored in $AC_REPOS_PATH_MODE. The auto-reset path is implemented by setting MD20108 $MC_PROG_EVENT_MASK to call an ASUB on reset and a separate ASUB on NC START.
3. Auto-Reset Architecture
Three coordinated blocks deliver the behavior:
-
ASUB on RESET — declared via
MD20108bit pattern'H14'(PROG_EVENT_RESET) and'H81'(PROG_EVENT_START). The reset ASUB increments the reject counter and writes a GUD flag_GUD_REJECT_ACTIVE. -
ASUB on START — reads
_GUD_REJECT_ACTIVE, forces a tool sequence reset, and either (a) calls the main program from the first T block viaINIT(2, "_N_MPF_DIR\\_N_MAIN_MPF")+START(2), or (b) skips the in-progress tool and queues the next tool through the magazine. -
PLC interface — FC8 / standard tool manager handshake; user DB
DB9000holdsREJECT_FLAG,SCRAP_COUNT, andREPOS_DISABLE; FC9 starts the ASUB from the PLC side if needed.
4. NC-Side: Asynchronous Subprogram for Tool Sequence Reset
Create two ASUB files in the part-program directory, e.g. _N_ASUP_RESET_SPF and _N_ASUP_START_SPF. Define the GUD in _N_GUD_DEF:
DEF NCK INT _GUD_REJECT_ACTIVE = 0 ; 1 = scrap current part, restart
DEF NCK INT _GUD_RESET_TOOL_IDX = 1 ; restart from this T index
DEF NCK INT _GUD_SCRAP_COUNT = 0 ; local mirror of PLC reject counter
DEF NCK INT _GUD_LASTMACH = 0 ; last decoded T before interrupt
_N_ASUP_RESET_SPF (called by PROG_EVENT_RESET):
; ASUP_RESET_SPF — called automatically on NC RESET
; Increments scrap count and records the last active tool index
DEF INT _LV_TIDX = 0
IF $AC_ALARM_STAT == 0
; operator-initiated reset, do not scrap
GOTOF _END
ENDIF
; capture the tool that was active at the time of the stop
_LV_TIDX = $AC_TOOL_ACT[0] ; current tool of channel 1
_GUD_LASTMACH = _LV_TIDX
_GUD_REJECT_ACTIVE = 1
; increment scrap counter (special parts used for reject log)
SETPIECE(3) ; $AC_TOTAL_PARTS++
$AC_SPECIAL_PARTS = $AC_SPECIAL_PARTS + 1
_GUD_SCRAP_COUNT = _GUD_SCRAP_COUNT + 1
; signal PLC to disable REPOS for the next START
DO $A_DBW[0] = 1 ; user HMI signal: REJECT_REQ
_END:
M17
_N_ASUP_START_SPF (called by PROG_EVENT_START):
; ASUP_START_SPF — called automatically on NC START
IF _GUD_REJECT_ACTIVE == 0
GOTOF _NORM_START
ENDIF
; clear REPOS offset and disable auto REPOS for this cycle
$AC_REPOS_PATH_MODE = 0 ; clear pending REPOS
$AC_REPOS_DELAY = 0 ; no axis delay
$AA_REPOS_DELAY[X] = 0 ; clear per-axis
$AA_REPOS_DELAY[Y] = 0
; unload current tool, queue tool index from GUD
T0 ; clear spindle tool
M6
_GUD_REJECT_ACTIVE = 0 ; consume flag
; re-trigger the program from the start with the new tool index
INIT(2, "_N_MPF_DIR\\_N_MAIN_MPF", "/_N_MPF_DIR\\_N_MAIN_MPF")
START(2)
_NORM_START:
M17
$AC_REPOS_PATH_MODE = 0 from an ASUB on channel 1 is the supported method to suppress REPOS; it does not alter MD20150. The interpreter then treats the next decoded block as a fresh execution. For gantry axes, also verify $AA_LEAD_SP[X] and $AA_LEAD_SP[Y] are equal before clearing the REPOS, otherwise the ASUB will raise alarm "26017 Axis %1 not synchronized with gantry".Main program pattern that survives the reset:
; MAIN_MPF — tool sequence with reject-safe block structure
N10 G0 G54 X0 Y0 Z100
N20 T1 D1 M6
N30 S3000 M3
N40 WORK_BLOCK(1) ; part feature A
N50 T2 D1 M6
N60 WORK_BLOCK(2) ; part feature B
N70 T3 D1 M6
N80 WORK_BLOCK(3) ; part feature C <-- interrupt point
N90 T4 D1 M6
N100 WORK_BLOCK(4) ; part feature D
N110 M30
5. PLC-Side: FC8 / Standard Tool Manager Interface
The standard tool manager on SINUMERIK 840D sl uses the following exchange blocks. User data for the reject logic is held in DB9000:
| Block | Direction | Function |
|---|---|---|
| DB4 (TMMVTP) | NCK → PLC | Tool change request |
| DB5 (TMMCPC) | PLC → NCK | Tool change completion ack |
| DB71 / DB72 | PLC → HMI | Magazine configuration mirror |
| DB9000 | PLC ↔ HMI | User: REJECT_FLAG, SCRAP_COUNT, REPOS_DIS |
| FC8 | PLC | Tool change coordination |
| FC9 | PLC | ASUB start (start ASUP with INT priority) |
| FC6 / FC7 | PLC | Magazine positioning / transfer |
SCL example for the reject handshake (FB 9000 "REJECT_HND") stored in DB9000:
FUNCTION_BLOCK FB9000
VAR
bReject : BOOL; // DB9000.DBX0.0
nScrap : DINT; // DB9000.DBD4
bRepDis : BOOL; // DB9000.DBX8.0 "REPOS disable"
nTime : TIME;
END_VAR
BEGIN
// rising edge of PLC-side reject request from NCK
IF "dbNcToPlc".reject_req AND NOT bReject THEN
bReject := TRUE;
nScrap := nScrap + 1;
bRepDis := TRUE;
// log to operator via HMI message line
"HMI_MSG_BUFF".msg[0] := 1;
"HMI_MSG_BUFF".id[0] := 4701; // 4701 = reject event
"HMI_MSG_BUFF".text[0] := 'SCRAP PART TOOL=';
"HMI_MSG_BUFF".text[0] := CONCAT("HMI_MSG_BUFF".text[0],
DWORD_TO_STRING("dbNcToPlc".last_tool_idx));
END_IF;
// clear after start
IF "dbPlcToNck".channel_1_start_ack AND bReject THEN
bReject := FALSE;
bRepDis := FALSE;
END_IF;
END_FUNCTION_BLOCK
The PLC drives the REPOS path via DB32000.DBX0.6 (REPOS offset active) and the ASUB trigger via DB32000.DBB4 (ASUB interface). For alarm-driven ASUBs, set MD11602 $MN_ASUP_START_MASK accordingly and MD20194 $MC_PROG_EVENT_RESTART_BITS to allow PROG_EVENT at NC STOP.
6. Rejecting the Workpiece: Counters and Marking
The Siemens part-counter system uses SETPIECE() and the $AC_*PARTS family. For reject accounting, the canonical approach is:
| Counter | NC variable | PI / SETPIECE | Usage |
|---|---|---|---|
| Actual parts | $AC_ACTUAL_PARTS | SETPIECE(1) | Counter incremented on M30/M02 |
| Required parts | $AC_REQUIRED_PARTS | SETPIECE(2) | Target / lot size |
| Total parts (NCK) | $AC_TOTAL_PARTS | SETPIECE(3) | Total parts since last reset |
| Special parts | $AC_SPECIAL_PARTS | — | Parts that consumed a tool |
| User scrap (DB9000) | DB9000.DBD4 | — | Reject count (user-defined) |
To mark a workpiece as reject:
; increment the NC-side scrap book-keeping
SETPIECE(3) ; $AC_TOTAL_PARTS++
$AC_SPECIAL_PARTS = $AC_SPECIAL_PARTS + 1
$AC_REQUIRED_PARTS = $AC_REQUIRED_PARTS - 0 ; not decremented
; user scrap counter is mirrored in PLC
SBC(64) ; set user bit, e.g. for HMI
; or write directly
DO $A_DBD[0] = $A_DBD[0] + 1 ; user-side reject counter
For traceability, write the tool index and timestamp to a user log DB on each reject:
DEF NCK INT _GUD_LAST_TIDX = 0
DEF NCK REAL _GUD_LAST_TIME = 0
_GUD_LAST_TIDX = $AC_TOOL_ACT[0]
_GUD_LAST_TIME = $AC_TIMER[0] / 1000.0 ; seconds
M17
7. Gantry Synchronization Across the Reset
A gantry axis pair (typically two mechanically-coupled drives, e.g. X1 = master, X2 = slave) is defined by:
-
MD37100 $MA_GANTRY_AXIS_TYPE[n]— 0 = none, 1 = leading, 2 = following -
MD37110 $MA_GANTRY_POS_TOL_LONG[n]— monitoring tolerance (mm), default 0.5 -
MD37120 $MA_GANTRY_POS_TOL_REF[n]— reference tolerance, default 0.05 -
MD37130 $MA_GANTRY_BREAK_UP_DELAY[n]— break-up delay in seconds -
MD37140 $MA_GANTRY_BREAK_UP_COND[n]— break-up condition (e.g. follow-up, error)
On NC RESET, alarm 26017 ("Axis %1 gantry not synchronized") can fire if the slave axis position differs from the master beyond GANTRY_POS_TOL_LONG. The ASUB must zero the REPOS offset on the master and slave before any motion, and the gantry must be re-synchronized with GANTRY_ACTIVATE or by leaving reset state if the leading axis is referenced.
; ASUB gantry-safe sequence
IF $AA_LEAD_SP[X] <> X_AXIS_NAME OR $AA_LEAD_SP[X2] <> X_AXIS_NAME THEN
; gantry broken up — re-join before continuing
$AA_LEAD_SP[X2] = X_AXIS_NAME
$AA_LEAD_OFF[X2] = 0
ENDIF
; clear REPOS on both
$AA_REPOS_DELAY[X] = 0
$AA_REPOS_DELAY[X2] = 0
For machines with active gantry during tool change, leave MD37130 GANTRY_BREAK_UP_DELAY at the default 0.0 s; never re-synchronize the gantry inside the ASUB if the machine builder has not explicitly allowed it, because re-sync on a tilted gantry can crash the mechanical coupling.
8. Machine Data and Setting Data Configuration
| MD / SD | Name | Recommended | Notes |
|---|---|---|---|
| MD20108 $MC_PROG_EVENT_MASK | Event mask for PROG_EVENT | 'H95' (RESET + START + END + _N_FILE_) | Enables ASUB hooks |
| MD20194 $MC_PROG_EVENT_RESTART_BITS | Restart allowed bits | 'H1F' | Allow PROG_EVENT at NC STOP |
| MD11602 $MN_ASUP_START_MASK | ASUP start mask | 'H1F' | Permit PLC FC9 + interrupt |
| MD11604 $MN_ASUP_START_PRIO_LEVEL | ASUP priority | 5 | Higher than main program |
| MD20150 $MC_GCODE_RESET_VALUES[2] | REPOS group default | 2 (REPOSA) | Reset, but cleared by ASUB |
| MD20270 $MC_CUTTING_EDGE_DEFAULT | Default D number | 1 | For T0 → T1 transitions |
| MD20310 $MC_TOOL_MANAGEMENT_MASK | Tool manager | 'H2F' | Enables FC8 path |
| SD42900 $SC_MIRROR_TOOL_LENGTH | Mirror tool length | 0 | Standard |
| SD42100 $SC_DRY_RUN_MASK | Dry-run mask | 0 | Disable during reset |
For details refer to the Siemens Industry Online Support entry for the SINUMERIK 840D sl list manual, function manual "Tool Management", and the programming manual "Basics". Search for the SINUMERIK 840D sl documentation set on the Siemens support portal.
9. HMI Operate: Operator Interface and Acknowledgment
Display the scrap count and the last reject on the HMI Operate operator screen. Use the user-variable display that calls DB9000.DBD4 for the counter, and the alarm log shows the event with a classification of 4701. In Operate's config (System CFG → operator screen), add the following read-only fields:
-
/Plc/DB9000.DBD4— scrap count (DINT) -
/Plc/DB9000.DBD8— last tool index rejected (DINT) -
/Plc/DB9000.DBD12— last reject timestamp in NCK ticks (DINT)
For the operator to manually trigger the auto-reset (without waiting for an alarm), add an MC-Code or HMI softkey that sets DB32000.DBX0.7 (channel-specific "delete distance to go") and DB9000.DBX0.0 (REJECT_FLAG), then a separate "RESET + START" prompt. The MC-Code can be issued as an M-function in the part program:
; Manual reject (operator M-code entry)
M97 ; custom M for reject
; — defined via MD10715 $MN_M_NO_FCT_CYCLE[1] = 97
; — calls _CYC97, which sets DB9000.DBX0.0 and triggers PROG_EVENT
Use MD10715 to bind M97 to a custom cycle, e.g. _CYC97_SPF:
; _CYC97_SPF — operator reject
RPF _GUD_REJECT_ACTIVE = 1
SBC(64)
M17
10. Step-by-Step Commissioning Procedure
- Back up the machine. Archive the current NCK, PLC, and CF card image with HMI Operate → Commissioning → Backup before any change.
-
Create GUD definitions in
_N_GUD_DEFand load via HMI Operate → Commissioning → NC → GUD. Re-initialize the NCK to apply. -
Author the ASUBs
_N_ASUP_RESET_SPFand_N_ASUP_START_SPFin the manufacturer area (NCKMADV_DIRorMPF_DIR). Use manufacturer area, not user area, to prevent end-user edits. - Configure PROG_EVENT machine data (Section 8). Always set values in NCK reset state; reload with NCK reset.
- Add DB9000 in the PLC project (TIA Portal or STEP 7 classic) and instantiate FB9000 in OB1 cyclic.
- Verify FC8 / FC9 in the PLC. Confirm that the tool manager handshake bits in DB4/DB5 cycle through (NCK → PLC → NCK).
- Compile and load the PLC project. Watch the PLC diagnostic buffer for any cross-reference errors.
-
Test in dry-run: set
SD42100 $SC_DRY_RUN_MASK = 1, run a known part-program, and trigger an NC STOP at T3. Confirm ASUB fires, scrap counter increments, REPOS does not resume. - Test in a real cut: same sequence, with a test block (no actual cut) on a sacrificial workpiece. Verify the gantry remains synchronized, the tool returns to the magazine correctly, and the next part starts at T1.
-
Alarm-class filter: configure
MD11600 $MN_CONTOURHANDLER_CONFIGto only fire the reset ASUB for ALC REWORK alarms. Other alarms (e.g. axis, drive) must not invoke the reset.
11. Verification Tests and Acceptance Criteria
| Test ID | Action | Expected result | Pass criteria |
|---|---|---|---|
| V-01 | NC STOP during T3 motion | REPOS cleared, scrap +1, restart at T1 | $AC_ACTUAL_PARTS unchanged, DB9000.DBD4 +1, DB9000.DBX8.0 TRUE |
| V-02 | Alarm 26017 during T3 | Alarm is not auto-rejected; manual intervention | ASUB does NOT fire on 26017; operator must acknowledge |
| V-03 | Operator M97 mid-cycle | Sequence restarts from T1 on the next START | $AC_TOOL_ACT = 1 after START |
| V-04 | Power outage during T3 (PSU fail) | Boot up, NCK reset, ASUB_RESET_SPF not called | $AC_ALARM_STAT cleared; no scrap increment |
| V-05 | Gantry desync at T3 (slave overruns) | Alarm 26017, ASUB rejected | MD37110 monitoring fires; operator handles separately |
| V-06 | Tool life expiry at T3 | Tool life protection substitutes sister tool | $AC_TOTAL_PARTS unchanged, scrap not incremented |
Read the counters from HMI Operate: Diagnostics → NC/PLC Variables → /Plc/DB9000.DBD4 and /NCK/System/_GUD_SCRAP_COUNT — they must match.
12. Troubleshooting Matrix
| Symptom | Likely cause | Action |
|---|---|---|
| ASUB does not fire on RESET | PROG_EVENT_MASK not set | Verify MD20108, reset NCK, re-archive |
| ASUB fires but REPOS still resumes | $AC_REPOS_PATH_MODE not cleared | Add $AC_REPOS_PATH_MODE = 0 in ASUB on START |
| Scrap counter does not increment | SETPIECE(3) called outside M30/M02 path | Use direct $AC_TOTAL_PARTS++ or GUD |
| DB9000 not visible in HMI | DB not assigned to read-only field | Re-add in HMI Operate operator screen config |
| Gantry alarm 26017 after auto-reset | Slave position drifted during interrupt | Operator-driven re-reference; do not auto-reset on 26017 |
| T0 not executed (spindle stays with T3) | MD20270 $MC_CUTTING_EDGE_DEFAULT not set | Set to 1; verify with $AC_TOOL_ACT |
| FC8 returns error 0x80F1 | Tool manager not initialized in PLC | Initialize DB4 / DB5 at NCK run-up; check OB100 |
| ASUB called twice in a row | PROG_EVENT_MASK has duplicate bits | Recompute mask; H14 + H81 is the canonical pair |
| ASUB calls wrong program | Init syntax / path | Use INIT(2, "_N_MPF_DIR\\_N_MAIN_MPF") with absolute path |
| Alarm 8076 "Program %1 not in memory" | Part program not in CF card | Reload part program; check Setup/Active file system |
13. Operational and Safety Notes
MD11600 $MN_CONTOURHANDLER_CONFIG to limit the ASUB to process-class alarms only (e.g. operator pause, M00, E-stop class C with confirmed ack)._N_ASUP_RESET_SPF, _N_ASUP_START_SPF, and GUD definitions in the manufacturer area (NCKMADV_DIR, password-protected) so the customer cannot accidentally delete them. The main part program stays in the user area.$TC_MOP1 or tool wear $TC_MOP3; the in-progress tool has consumed life. Mark the part as scrap and the tool state as $TC_TP1[tn] = 7 (used-up) only when the tool's life is exceeded — never as a side-effect of the auto-reset.For tool life monitoring (TLO), set MD18080 $MN_MM_TOOL_MANAGEMENT_MASK to enable life monitor and use $AC_SPECIAL_PARTS as the increment target when the part consumed a tool. The user scrap counter (DB9000) is the audit-trail for parts that did not consume a tool life unit, only REJECT_HND.
For machines that load a part into the work area only after the tool change, the auto-reset may also need to call a part-load macro. Add a GUD-driven decision:
IF _GUD_REJECT_ACTIVE == 1
CALL _CYC_PART_LOAD ; load a new blank
_GUD_REJECT_ACTIVE = 0
ENDIF
14. Cross-References and Standards
For the underlying tool-change interface and PROG_EVENT semantics, the relevant Siemens documentation is the SINUMERIK 840D sl list manual (LH1) and the function manual "Tool Management" (FBMA), both distributed through the Siemens Industry Online Support. The IEC 61131-3 standard covers the PLC side of the PLC basic program; ISO 6983 (G-code) covers the NC syntax for M-functions, T-codes, and modal behavior referenced above.
FAQ
How do I auto-reset the tool sequence on a SINUMERIK 840D sl after an interrupt at T3?
Set MD20108 $MC_PROG_EVENT_MASK to 'H95' so PROG_EVENT fires on RESET and START. Author _N_ASUP_RESET_SPF to mark the part as scrap and _N_ASUP_START_SPF to clear $AC_REPOS_PATH_MODE, execute T0 M6, then INIT(2)/START(2) to re-run the main program from T1.
How do I mark the interrupted workpiece as scrap and increment a reject counter?
In the reset ASUB call SETPIECE(3) to bump $AC_TOTAL_PARTS, increment $AC_SPECIAL_PARTS by 1, and write to DB9000.DBD4 (user scrap counter). Mirror $AC_TOOL_ACT into a GUD for traceability and display the value on the HMI Operate operator screen.
Why does the controller REPOS-resume on T3 instead of restarting from T1?
REPOS is enabled by MD20150 and stored in $AC_REPOS_PATH_MODE; on NC START the interpreter completes the interrupted block set, re-executing T3. Set $AC_REPOS_PATH_MODE = 0 and $AA_REPOS_DELAY on every axis of the channel from the START ASUB, then issue T0 M6 before the main program restart.
What is the correct way to handle the gantry pair during a tool-sequence reset?
Verify the gantry is synchronized ($AA_LEAD_SP slave = master name). Clear $AA_REPOS_DELAY on both leading and following axes. Do not break up the gantry inside the ASUB; let the gantry remain coupled and only re-reference if the controller raises alarm 26017 after the ASUB returns.
Can I keep the auto-reset from firing on safety or drive alarms?
Yes. Filter the ASUB trigger by alarm class: configure MD11600 $MN_CONTOURHANDLER_CONFIG and MD20194 $MC_PROG_EVENT_RESTART_BITS to limit the reset ASUB to process-class alarms only. Safety STOP A–F and drive alarms must never trigger the auto-reset path; they require controlled operator-driven recovery.
Which Siemens block should I use to send a tool change to the PLC?
Use the standard PLC basic program blocks: DB4/DB5 for the tool manager handshake, FC8 for tool change coordination, FC9 to start an ASUB from the PLC, and FC6/FC7 for magazine positioning. Custom logic for the reject path lives in FB9000 with data in DB9000.