Siemens 840D: Troubleshooting a Stuck Part Counter

David Krause2 min read
Other TopicSiemensTroubleshooting
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

A Siemens 840D engraving routine increments R600 and passes it to PRINT, but the observed sequence stops progressing after 1, 2, 3, 4 and repeatedly engraves 4. The evidence supports an R-parameter collision as the primary hypothesis: another routine may overwrite R600. Replace the shared R parameter with a dedicated, clearly named integer and then verify its lifetime across the required production cycle.

Identify the Counter Failure

The original counter consists of two operations:

R600=R600+1
PRINT("2007-KW30-"<<R600,0.4,4,0,0,-30,0.01,0.01,2)

Because the displayed or engraved value reaches 4 and then remains at 4, the increment statement exists and initially executes. The available evidence does not prove whether execution later skips the statement or whether another routine restores or overwrites R600. Treat both as checks, with shared-parameter overwrite as the stated hypothesis.

Separate the Counter from Shared R Parameters

Declare a dedicated integer at the beginning of the program. An integer matches a whole-number part count and avoids using R600, which may also be accessed elsewhere.

DEF INT WERKSTUECKNUMMER=0

WERKSTUECKNUMMER=WERKSTUECKNUMMER+1
PRINT("2007-KW30-"<<WERKSTUECKNUMMER,0.4,4,0,0,-30,0.01,0.01,2)

A REAL declaration is also shown in the evidence, but it is unnecessary when the counter advances only by whole units. If numbering must start at a different value, initialize the variable to one less than the first number to engrave because the increment occurs before PRINT.

Verify Execution and Variable Lifetime

  1. Run consecutive engraving operations and confirm that WERKSTUECKNUMMER changes before each PRINT call.
  2. Check whether any called routine writes the original R600. A write confirms that the shared R parameter was unsuitable for this counter.
  3. Restart or re-enter the subprogram and observe whether WERKSTUECKNUMMER returns to its initialized value. The evidence does not establish whether this declaration persists across separate program invocations.

If the counter resets when the program is re-entered, the local declaration solves the overwrite problem only within one execution. Continuous numbering across separate runs then requires a persistent storage method supported by the specific machine configuration; that mechanism is not identified in the available evidence.

Apply the Correct Decision

Requirement Supported action Verification
Count within one uninterrupted execution Use DEF INT WERKSTUECKNUMMER=0, increment it, and print it Confirm the value advances beyond 4
Avoid interference from other routines Stop using R600 for the part number Monitor both variables around called routines
Continue after program re-entry First determine whether the declared variable retains its value Re-enter the program and inspect the next engraved number

FAQ

Why does my Siemens 840D part counter stop at 4?

The stated hypothesis is that another routine overwrites R600. Confirm this by monitoring R600 before and after called routines and by testing a dedicated variable.

Should a Siemens 840D part counter use INT or REAL?

Use INT when the part number advances in whole units. Declare DEF INT WERKSTUECKNUMMER=0, increment it, and pass it to PRINT.

Will DEF INT WERKSTUECKNUMMER retain its value after restart?

The evidence does not establish persistence across program re-entry or restart. Test that boundary directly; if the value resets, use a persistent storage method supported by the machine configuration.

Back to blog