Original coordinates <ORIGIN>
The <ORIGIN> command specifies the coordinate system of the subsequent NC code.
Actually there are two modes of the Origin command.
In the first mode the Origin command is used to activate one of the predefined workpiece coordinate systems (G54-G59). The mode is indicated by the <CLD> (<CLD.PPFun>) parameter set to zero. The number of the coordinate system being activated is specified in the <CLD> (<CLD.N>) parameter.
In the second mode the Origin command is used to define a transformation of the workpiece coordinate system (Sinumeric TRANS, ROT, Heidenhain CYCLE7, CYCLE19, PLANE, Fanuc G52, G68 etc). The mode is indicated by the <CLD> (<CLD.PPFun>) parameter set to <PPFun(1079)>. The transformation is defined by shift along the XYZ axes (CLD, CLD, CLD) and rotation around the same axes (CLD, CLD, CLD).
ORIGIN X x, Y y, Z z, PPFUN f, N n, A a, B b, C c
Parameters available through the Cmd operator
Some controls require definition of local coordinate systems by spatial angles while the other controls support definition of local coordinate systems only by real machine angles. The ORIGIN command includes all the needed information for the both definition methods. The Cmd.Ptr["MCS"] and the Cmd.Ptr["WCS"] properties contain spatial angles (A, B, C) of the LCS, while the Cmd.Ptr["Axes"] array contain the corresponding coordinates of machine rotary axes. The main advantage of the Cmd.Ptr["Axes"] property is that it defines the LCS unambiguously while for the Cmd.Ptr["WCS"] there are commonly two possible solutions. For the controls requiring spatial angles for the LCS definition the machine angles can be used to resolve ambiguous cases. (See an example below).
Note: spatial angles are specified relative to the local coordinate system being active at the moment of definition of the ORIGIN command.
In case a control supports both methods of LCS definition, you can specify the desired output format of the ORIGIN command in SprutCAM in the Control parameters settings. In the postprocessor the desired output format is available in the Cmd.Int["IsSpatial"] property of the ORIGIN command.
Some controls support various positioning modes of the ORIGIN command. SprutCAM offers the following LCS positioning modes.
Cmd.Int["PositioningMode"]=STAY. The origin command does not move the machine axes.
Cmd.Int["PositioningMode"]=TURN. The origin command rotates the machine axes in such a way the tool axis direction becomes aligned with the Z axis of the local coordinate system
Cmd.Int["PositioningMode"]=MOVE. The origin command rotates the machine axes to align the tool axis with the Z axis of the local coordinate system and moves the linear axes in such a way the tool tip position stays the same relative to the workpiece
The controls define a local coordinate system relative to some reference workpiece coordinate system (G54). Depending on the control used you should use either the MCS matrix or the WCS matrix to define a LCS.
Modern controls know about the machine kinematics. On those controls the workpiece coordinate system is rotated together with the rotary table. So on those controls you can define a local coordinate system relative to the rotating workpiece coordinate system. In this case you are happy to use the WCS matrix.
Old controls know nothing about the machine kinematics and can not rotate the workpiece coordinate system together with the rotary table. For those controls you should use the MCS matrix to define a LCS transformation.
At the following figures you can see the difference between the reference coordinate systems for the MCS, and the WCS matrices. Using the WCS matrix is preferable as the WCS matrix is not dependent on the workpiece setup, while the MCS is heavily dependent on it.
SprutCAM Local CS settings.
In SprutCAM the settings of the ORIGIN command are specified in the Machine configuration file.
<SCType ID="MachineName" type="AbstractMachine">
The options are also available from the GUI in the Control Parameters section of the Machine parameters .
Code samples of the <ORIGIN> command:
if Cmd.Int["OriginType"]=0 then begin !G54-G59
Output "G" + Cmd.Str["CSNumber"]
end else begin !G52 X Y Z
X = Cmd.Flt["MCS.OriginPoint.X"]
Y = Cmd.Flt["MCS.OriginPoint.Y"]
Z = Cmd.Flt["MCS.OriginPoint.Z"]
Output "G52 X" + Str(X) + " Y" + Str(Y) + " Z" + Str(Z)
if CLD=0 then begin ! Select standart LCS (G54-G59)
! Do nothing for Heidenhain
end else if CLD=1079 then begin ! Transform LCS
Output "CYCL DEF 7.0 DATUM SHIFT"
Output "CYCL DEF 7.1 X" + Str(Cmd.Flt["WCS.OriginPoint.X"])
Output "CYCL DEF 7.2 Y" + Str(Cmd.Flt["WCS.OriginPoint.Y"])
Output "CYCL DEF 7.3 Z" + Str(Cmd.Flt["WCS.OriginPoint.Z"])
if (abs(Cmd.Flt["WCS.RotAngles.A"])>0.0001) or
Output "CYCL DEF 19.0 WORKING PLANE"
if Cmd.Int["IsSpatial"]>0 then begin ! Spatial coordinates
Output "CYCL DEF 19.1 A" + str(Cmd.Flt["WCS.RotAngles.A"]) +
" B" + str(Cmd.Flt["WCS.RotAngles.B"]) +
" C" + str(Cmd.Flt["WCS.RotAngles.C"])
end else begin ! Machine axes
OutStr$ = "CYCL DEF 19.1"
if Cmd.Ptr["Axes(AxisBPos)"]<>0 then begin
OutStr$ = OutStr$ + " B" + str(Cmd.Flt["Axes(AxisBPos).Value"])
if Cmd.Ptr["Axes(AxisCPos)"]<>0 then begin
OutStr$ = OutStr$ + " C" + str(Cmd.Flt["Axes(AxisCPos).Value"])