Triggering SINUMERIK 840D Servo Trace via Part Program

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

Overview

The SINUMERIK 840D and 840D sl controllers expose a high-speed Servo Trace function used to capture NC setpoint/actual-value signals, drive signals, and PLC variables during a defined motion event. The trace is normally armed and started from the HMI (Diagnostics > Trace for HMI Advanced, or Diagnostics > Trace / Servo Trace under SINUMERIK Operate). For automated commissioning, acceptance tests, or repeatable diagnostic routines, the operator typically wants the trace to start sampling exactly when the part program reaches a known motion block — not when the user manually clicks the start button.

Siemens provides two write-only system variables that allow the part program to fire the trace trigger:

  • $AA_SCTRACE[Ax] — axis-specific software trigger for traces configured in HMI Advanced (840D / 840D sl classic HMI).
  • $AN_SLTRACE — axis-independent global software trigger for traces configured in SINUMERIK Operate on 840D sl.

This reference documents the complete procedure for configuring a servo trace that fires from a part program: variable selection, trigger-condition setup, the part-program syntax, the mandatory manual arming step, and the limitations that apply on both HMI generations. The procedure is the one described in the Siemens support documentation SINUMERIK 840D sl SINUMERIK Operate — Support ID 109769186.

Mandatory manual step: Even when the trigger is fired from the part program, the trace session must first be armed by the operator via the HMI Start button. The dialog line then changes to "...waiting for trigger". The NC command only releases a previously armed trace; it cannot launch a new session unattended. There is no API to bypass this on standard 840D / 840D sl controllers.

Prerequisites

Before writing the part-program trigger, confirm the following on the controller and the HMI:

  1. Controller generation: Identify whether the machine runs the legacy 840D with HMI Advanced, or the 840D sl with SINUMERIK Operate. The trigger variable differs between the two.
  2. Operator access level: Access to Diagnostics > Trace requires manufacturer or service password on most installations. Coordinate with the machine OEM if the menu is greyed out.
  3. Trace channel licence: At least one trace channel must be available. The default configuration provides two servo-trace channels; additional channels may require licence options depending on the software version.
  4. Axis identification: Determine the machine axis name (e.g. X1, Y2, SP1) of every axis you intend to trace. The $AA_SCTRACE trigger is indexed by machine axis, not by channel axis name.
  5. NCK access rights: Writing to $AA_SCTRACE / $AN_SLTRACE from the part program requires standard NCK write access. Protected programs (e.g. _N_MPF_DIR/_N_CMA_DIR) may need to be unlocked first.
  6. Trace storage path: Confirm that the CF card / NCK file system has space for the trace buffer. Long recordings at high sampling rates (31.25 µs) consume several MB per channel.

Trace System Variables — Reference Table

Variable HMI platform Index Scope Value to write Effect
$AA_SCTRACE[Ax] HMI Advanced (840D / 840D sl) Machine axis name (e.g. X1) Axis-specific — must match the first trace variable's axis 1 or TRUE Fires the trace trigger on the axis named in the index
$AN_SLTRACE SINUMERIK Operate (840D sl) None — scalar variable Axis-independent (global NC trigger) 1 Fires the trace trigger for any configured servo-trace session on the NCU
$AA_SCTRACE (read) Both Axis Status readback — Returns the current trace state of the axis (used in NC programs for diagnostics)
Variable scope warning: If a single trace records signals from multiple axes (e.g. position setpoint of X1 and actual current of Y2), the $AA_SCTRACE trigger must reference the machine axis name of the first trace variable. There is no separate variable per additional axis.

Step-by-Step: Configure the Trace in the HMI

1. Open the Trace dialog

From the HMI main menu:

  • HMI Advanced: Diagnostics > Trace > Servo Trace (or Commissioning > Trace on older 840D software).
  • SINUMERIK Operate: Menu Select > Diagnostics > Trace > Servo Trace.

The trace dialog displays the Trace Settings (PLC, NC, Servo) window where start condition, stop condition, recording duration, sampling time, and channel assignments are configured. Reference: SINUMERIK 840D sl SINUMERIK Operate — Support ID 109769186.

2. Add at least one trace variable

Click Add variable and select the signal you want to capture. Typical choices during commissioning include:

  • Position setpoint of axis X1
  • Position actual value of axis X1
  • Velocity setpoint of axis SP1 (spindle)
  • Torque-limiting current setpoint of axis Z1

Each additional Add variable click adds another channel. The first variable defines the axis the trigger is bound to (see warning above).

3. Configure the trigger condition

In the Trigger condition section, set:

Parameter Recommended value for part-program trigger
Trigger mode Trigger from part program (HMI Advanced) / Trigger from NC program (SINUMERIK Operate)
Trigger source variable First trace variable's axis — automatically populated
Pre-trigger samples 10–50 % of total record length
Sampling time 1 ms for commissioning, 0.5 ms for high-dynamic axes
Record length 4096 samples (default) — increase to 8192 for long motions

If you leave the trigger mode on Threshold or Edge, the part-program command has no effect. The trace will still run, but it will start on the signal threshold, not on the NC command.

4. Arm the trace

Press the HMI Start button. The dialog line should change to ...waiting for trigger (HMI Advanced) or Waiting for trigger (SINUMERIK Operate). At this point the trace is armed but idle.

Single-shot limitation: After the trigger fires and the trace completes, the session ends. To record again you must press Start a second time. There is no way to start the trace permanently without a user action on standard 840D / 840D sl.

Part-Program Syntax — HMI Advanced

For traces armed in HMI Advanced, the part program must set the axis-specific trigger variable before the motion block you want to record:

; =========================================================
; Sample: trigger servo trace on X1 from HMI Advanced
; =========================================================
G90 G94 G500                       ; absolute, feed/min, modal reset

; --- arm the trace trigger on machine axis X1 ----------
$AA_SCTRACE[X1] = 1                ; (or TRUE)

; --- force the NC to accept the trigger immediately ----
NEWCONF                            ; re-evaluate settable frames/commands

; --- start of the motion to be recorded ----------------
G90 G00 X=STARTPOS                 ; rapid to the start position
G01 X=ENDPOS F1000                 ; linear motion — the trace fires here
...

The write to $AA_SCTRACE[X1] is processed in the IPO cycle. Placing the assignment on its own line above the motion block ensures the trigger is latched before the geometry command starts executing. Without the isolated line, the controller may collapse the assignment with the next motion block and miss the latching window.

Variant: writing TRUE

The numeric value 1 and the boolean literal TRUE are equivalent. Use whichever is consistent with the rest of the part program. Some legacy 840D controllers (NC software earlier than SW 5) only accept the integer form — verify on the target build.

Part-Program Syntax — SINUMERIK Operate

On 840D sl running SINUMERIK Operate, the trace trigger is global. Replace the axis-indexed command with the scalar variable:

; =========================================================
; Sample: trigger servo trace from SINUMERIK Operate
; =========================================================
G90 G94 G500

$AN_SLTRACE = 1                    ; global NC trigger, axis-independent

NEWCONF

G90 G00 X=STARTPOS
G01 X=ENDPOS F1000
...

If the same part program must run on both HMI Advanced and Operate installations (e.g. a portable commissioning routine), keep both lines and comment out the one that does not apply:

$AA_SCTRACE[X1] = 1                ; trigger for trace at HMI Advanced
;$AN_SLTRACE = 1                   ; trigger for trace at SINUMERIK Operate
NEWCONF

Verification Procedure

After running the part program with the trace armed, confirm the recording was captured:

  1. The HMI dialog line returns from Waiting for trigger to Trace finished (or Recording while the buffer is being read back).
  2. The trace graph populates with at least one full record. If the buffer is empty, the trigger did not fire — jump to the troubleshooting matrix below.
  3. Inspect the recorded signals against the known motion. The position setpoint should match the programmed path within the servo lag tolerance; large discrepancies indicate a mechanical, drive, or parameterisation issue.
  4. Save the trace (File > Save) with a meaningful name (e.g. X1_rapid_2024-05-22.trc) so the capture can be referenced in the commissioning report.
  5. If a second recording is needed, press Start again and re-run the program.

Limitations and Workarounds

Limitation Detail Workaround
Mandatory manual arming The trace cannot start from a cold NC state — the operator must press Start once per session. Build a commissioning macro: an HMI Run MyScreens or a PLC-driven HMI script can click Start programmatically on supported versions. Standard HMI does not expose this.
Single trace session per arming After the trigger fires and the record completes, the trace is finished. Re-arm before each motion. For high-rate automated testing, integrate the Start press into a PLC sequence with operator confirmation.
Trigger bound to first variable's axis If the trace mixes variables from X1 and Y2, only $AA_SCTRACE[X1] fires. Always start the variable list with the axis that matters most for triggering. Put other axes' variables at the end.
Trigger mode reset on session end If the trace dialog is closed and reopened, trigger mode may revert to threshold. Always re-verify Trigger from part program is selected after each HMI restart.
NCK access rights on protected programs Protected cycles may refuse $AA_SCTRACE writes. Copy the cycle to a non-protected directory (_N_CUS_DIR) before adding the trigger command, or place the trigger in the calling main program (MPF).

Troubleshooting Matrix

Symptom Likely root cause Corrective action
Dialog line stays at Waiting for trigger after NC-Start Trigger variable not written, or wrong axis name used Verify $AA_SCTRACE[X1] uses the machine axis name (X1), not the channel name (X). Check $AA_SCTRACE readback in a subsequent block.
Dialog line stays at Waiting for trigger even though variable is written Trigger mode is not from part program; trace is waiting for a threshold that never arrives Re-open Trace Settings and confirm Trigger from part program / Trigger from NC program is selected.
Trace fires immediately when Start is pressed Trigger mode is set to Immediate or threshold is already exceeded at arming time Switch to Trigger from part program; idle the axis below threshold before arming.
Trace fires but graph is empty Pre-trigger set to 0 % and trigger variable set after the IPO scan that latches it Add a 5–10 % pre-trigger and place the trigger command several IPO cycles before the motion block (use NEWCONF or a dummy G04 F0.1 dwell).
Trigger fires only every other program run The trace session was not re-armed between runs Press Start again before each NC-Start. There is no way to make the trace auto-rearm.
Access denied alarm when writing $AA_SCTRACE NCK write protection on the program directory or insufficient access level Move program to _N_CUS_DIR or _N_MPF_DIR; confirm operator/service password is active.
$AN_SLTRACE accepted but trace never fires (Operate) Trace was configured in HMI Advanced mode, not Operate — Operate traces use $AN_SLTRACE, HMI Advanced traces use $AA_SCTRACE Confirm the HMI generation and use the matching variable. Re-create the trace in the correct HMI if necessary.

Performance and Timing Notes

  • IPO latching latency: The trigger is evaluated once per IPO cycle (default 4 ms; can be 2 ms on high-performance machines). Place the assignment at least one IPO cycle before the motion block you want to record.
  • Sampling time alignment: Trace sampling times of 0.5 ms, 1 ms, 2 ms, 4 ms, 8 ms, 16 ms, 32 ms, 64 ms, 128 ms, 256 ms, 512 ms, 1024 ms are exposed in the dialog. For a 4 ms IPO the shortest sensible sampling is 1 ms; anything below the IPO clock will produce interpolated data.
  • Record length: 4096 samples at 1 ms gives 4.096 s of capture — adequate for a single linear move with settling. Increase to 8192 samples (8.192 s) when capturing spindle acceleration or interpolating-axis settling tails.
  • Multiple triggers in one program: If you need to capture two distinct motion segments in a single NC-Start, you must re-arm the trace between segments. The trigger command can be issued twice, but only the first firing will produce a record; subsequent firings are ignored until the trace is restarted from the HMI.

Related System Variables for Diagnostics

Variable Meaning
$AA_SCTRACE[Ax] Trace trigger state for axis Ax (write fires, read returns state)
$AN_SLTRACE Global trace trigger for SINUMERIK Operate
$AC_TRACE Channel-related trace state (read only)
$NC_USER_DATA_* Optional user-defined data that can be added as a trace variable to correlate part-program state with the recorded signals

These variables can be displayed in the same trace session, allowing the engineer to correlate "what the part program did" with "what the axes actually did" in a single recording.

Integration with Commissioning Workflows

For repeatable acceptance tests, embed the trigger in a dedicated commissioning program that loops over the test points:

; =========================================================
; Commissioning loop: trace each of three test positions
; Requires the operator to press "Start" on the HMI
; before each NC-Start.
; =========================================================
G90 G94 G500

DEF INT _IDX
FOR _IDX = 0 TO 2

  ; --- operator arms the trace here ----------------------
  ; MSG "Arm trace, then press NC-Start"
  ; wait for operator confirmation if your HMI supports it

  $AA_SCTRACE[X1] = 1
  NEWCONF

  G90 G00 X=10 + (_IDX * 50)
  G01 X=20 + (_IDX * 50) F2000
  G04 F0.5

  ; --- second iteration: re-arm required ----------------
  ; MSG "Trace finished. Re-arm and press NC-Start"

ENDFOR
M30
Operator protocol: Print a clear message to the HMI bar between iterations instructing the operator to re-arm the trace. Without this, the second and third captures will not record.

FAQ

Which trigger variable do I use on SINUMERIK 840D sl with SINUMERIK Operate?

Use $AN_SLTRACE = 1. It is a scalar, axis-independent global NC trigger fired from the part program. The axis-indexed $AA_SCTRACE[Ax] is reserved for traces configured in HMI Advanced.

Can the trace start completely unattended from the part program?

No. On standard 840D and 840D sl controllers the operator must press the HMI Start button once per session to arm the trace. The part-program command only releases the armed trigger; it cannot start a fresh trace session without the manual arming step.

The trace graph is empty even though the dialog left the "waiting for trigger" state. What went wrong?

The most common causes are (a) the trigger was set to Immediate or a threshold instead of from part program, (b) the trigger variable was written after the IPO scan that latches it, so add a dwell or NEWCONF before the motion block, or (c) the trace was not re-armed between runs.

Which machine axis name do I use in $AA_SCTRACE[Ax]?

The machine axis name (e.g. X1, Z1, SP1) as shown in Axis configuration, not the channel axis name (X, Z, S). Using the channel name produces no trigger and no alarm.

Where can I find the official Siemens documentation for this procedure?

The procedure is documented in SINUMERIK 840D sl SINUMERIK Operate — Support ID 109769186 and the SINUMERIK 840D sl Programming Manual (basics and advanced) under the Diagnostics > Trace section.

Back to blog