When a CNC file compiled with SMC_CNC_REF drives the axes to X=0 Y=0 before the first programmed point, the interpreter is missing its start position: the value in the CNC properties is only read in OutQueue compile mode. Initialize SMC_NCInterpreter.piStartPosition from the forward-kinematic transformation output before every file start and verify from a position away from the origin, such as X=100 Y=50.
You start a CNC file and the axes drive to X=0 Y=0 before the first programmed point runs. The cause is the file's compile mode, and the fix lives in the IEC application, not in the CNC settings. The start position entered in the CNC properties is only read when the file is compiled in OutQueue mode. With SMC_CNC_REF, the interpreter takes its start position from the piStartPosition input of SMC_NCInterpreter, and when nothing is supplied there the path begins at the origin, so the machine travels to X=0 Y=0 first. The fix is to initialize piStartPosition from the output of your machine's forward-kinematic transformation before every file start. This page covers which mode reads which value, the symptoms to sort, the checks, the wiring, and a verification with numbers you choose.
Which compile mode reads the start position
The rule is short. The start position in the CNC properties belongs to the OutQueue compile mode. Compile the file with SMC_CNC_REF and the interpreter reads only SMC_NCInterpreter.piStartPosition in the IEC application. SMC_NCInterpreter carries that input for this purpose, and the value it expects is the machine's current position, which the forward-kinematic transformation computes from the measured axis positions.
| Compile mode | Start position source |
|---|---|
| OutQueue | The value entered in the CNC properties |
| SMC_CNC_REF | SMC_NCInterpreter.piStartPosition, initialized from the forward-kinematic transformation |
The move to X=0 Y=0 is what the interpreter does in SMC_CNC_REF mode when no start position reaches it. A correct value in the properties field makes no difference, and that is a familiar shape: the same pattern as a control application config setting that is ignored, where the value is right but the running mode never consults it. So confirm the compile mode first, in the settings where the CNC file is compiled. An OutQueue file takes its start from the properties field as it is, and no application change belongs there.
Symptoms and what each points to
- Axes reach X=0 Y=0 before the first programmed point. The path was built from the origin because no start position reached piStartPosition.
- A correct start position in the CNC properties has no effect. The file runs in SMC_CNC_REF mode, which reads only piStartPosition.
- The move returns after every restart or download. piStartPosition was written once, or not written before this particular file start.
- The first element in simulation starts at the workspace corner. The path begins at X=0 Y=0 there too, so an approach you never programmed precedes your first move on screen and on the machine.
Checks before you change the application
- Compile mode. Open the settings where the CNC file is compiled and confirm the mode. If it is OutQueue, set the start position in the CNC properties and stop there; the interpreter reads that field in this mode.
- Forward transformation block. Name the block that implements the forward kinematic transformation configured on your machine. On a two-axis gantry that block is SMC_TRAFOF_Gantry2; a different axis configuration uses a different forward block, so take the name from the configured kinematics.
- Current wiring. Find where piStartPosition gets its value in the application. If nothing drives it, the interpreter starts from the origin, and the move you are seeing is that gap.
The fix: initialize piStartPosition from the kinematics
- In the IEC application, take the output of the forward-kinematic transformation block and initialize SMC_NCInterpreter.piStartPosition with it. On the two-axis gantry case, that block is SMC_TRAFOF_Gantry2.
- Write the value before every start of execution, with the write ordered ahead of the interpreter's first call for the file. In a project with more than one task, the PLC execution order across task layers decides whether the write lands in time.
- Leave the start position field in the CNC properties in place for the files you compile as OutQueue. That field is the correct source in that mode.
Recommendation: for any CNC file compiled with SMC_CNC_REF, initialize SMC_NCInterpreter.piStartPosition from the machine's forward-kinematic transformation output before each execution start, and keep the CNC-properties start position for OutQueue files. Run the first verification with the axes parked away from the origin, at X=100 Y=50 in a metric program, so a missing start position cannot hide at zero distance.
Example: the table sits at X=100 Y=50 and the file still opens at the origin
Inputs. The axes stand at X=100 Y=50, the position chosen for the verification, in a metric program, so distances are in millimetres. The start position supplied to the interpreter: none, so the path begins at X=0 Y=0. The rule: the approach distance is the straight line from the current position to the path start, sqrt(dx² + dy²).
Arithmetic. dx = 100 mm, dy = 50 mm. Distance = sqrt(100² + 50²) mm = sqrt(10000 + 2500) mm = sqrt(12500) mm = 111.8 mm.
Result. With piStartPosition unsupplied, the axes travel 111.8 mm to X=0 Y=0 before the first programmed point executes. With piStartPosition initialized to X=100 Y=50, the path start is where the axes already stand, so the approach is 0 mm and the file's first programmed move is the first motion the machine makes.
Decision. Start the file from X=100 Y=50 and watch the first motion. Any travel toward X=0 Y=0 means piStartPosition did not receive the transformation output before the interpreter started, so recheck the compile mode and the write order. No travel toward the origin means the start position chain is correct. That 111.8 mm approach crosses the work area, so clear part, clamps and tooling from the path and run the first verification at reduced feed override.
Questions
Why does the move to X=0 Y=0 come back after a controller restart?
piStartPosition is an application input, and after a restart or a new download it holds nothing until your code writes it again. An initialization that runs once at startup covers the first file start only. Move the write so it executes before every execution start, then repeat the verification from X=100 Y=50. If the axes still reach the origin first, the write is landing after the interpreter's first call.
Does the fix require changes to the CNC file itself?
No. The file, its programmed coordinates and its feeds stay exactly as they are. The change is on the application side, where the forward-kinematic output is connected to SMC_NCInterpreter.piStartPosition so the interpreter begins the path from the machine's real position. Files you compile as OutQueue keep using the start position field in the CNC properties, and that field is the correct source there.
Why verify from X=100 Y=50 instead of the origin?
At the origin the fault is invisible: the axes are already at X=0 Y=0, so a missing start position produces no measurable motion. From 100 mm in X and 50 mm in Y, a missing piStartPosition produces a 111.8 mm approach to the origin before the file starts, a movement you can see and measure. The same test run with the input correctly supplied produces no approach at all.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.