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[4]> (<CLD.PPFun>) parameter set to zero. The number of the coordinate system being activated is specified in the <CLD[5]> (<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[4]> (<CLD.PPFun>) parameter set to <PPFun(1079)>. The transformation is defined by shift along the XYZ axes (CLD[1], CLD[2], CLD[3]) and rotation around the same axes (CLD[6], CLD[7], CLD[8]).

Command:

ORIGIN X x, Y y, Z z, PPFUN f, N n, A a, B b, C c

Parameters:


Parameter

CLD array

Description

x,

y,

z

CLD[1]

CLD[2]

CLD[3]

CLD.X

CLD.Y

CLD.Z

Offsets of local system along X, Y and Z axes respectively.

f

CLD[4]

CLD.PPFun

Mode of coordinate system definition:

0 – command specifies one of standard systems;

PPFun(1079) – local coordinate system transformation.

n

CLD[5]

CLD.N

The number of chosen standard coordinate system: 54 (G54), 55 (G55), 59 (G59) and so on.

a

CLD[6]

CLD.A

Angles of rotation around X, Y and Z axes respectively. The sequence of rotations around the axes (notation of Euler angles) may vary and is defined in the settings of the machine scheme.

b

CLD[7]

CLD.B

c

CLD[8]

CLD.C


Parameters available through the Cmd operator


TCLDOrigin: ComplexType

The command of coordinate system definition

OriginType: Integer

Cmd.Int["OriginType"] - Type of coordinate system definition command:0 (SelectStandardLCS) - standard workpiece coordinate system selection command (G54-G59),

1 (TransformLCS) - local coordinate system transformation command.

CSNumber: Integer

Cmd.Int["CSNumber"] - The number of the standard workpiece coordinate system: 54 (G54), 55 (G55), 59 (G59) and so on.

MCS: ComplexType

Cmd.Ptr["MCS"] - Parameters of the new coordinate system

OriginPoint: ComplexType

Cmd.Ptr["MCS.OriginPoint"] - The shift of the original point of the coordinate system

X: Double

Cmd.Flt["MCS.OriginPoint.X"] - offset in X

Y: Double

Cmd.Flt["MCS.OriginPoint.Y"] - offset in Y

Z: Double

Cmd.Flt["MCS.OriginPoint.Z"] - offset in Z

RotAngles: ComplexType

Cmd.Ptr["MCS.RotAngles"] - The angles of rotation of the coordinate system along the axes (in degrees). The sequence of rotations around the axes (notation of Euler angles) may vary and is defined in the settings of the machine scheme.

A: Double

Cmd.Flt["MCS.RotAngles.A"] - angle of rotation around the X axis

B: Double

Cmd.Flt["MCS.RotAngles.B"] - angle of rotation around the Y axis

C: Double

Cmd.Flt["MCS.RotAngles.C"] - angle of rotation around the Z axis

WCS: ComplexType

Cmd.Ptr["WCS"] - Parameters of the new coordinate system. The parameters that defines the transformation on the new coordinate system in relation to the mobile workpiece coordinate system. It includes the geometrical (spatial) coordinates.

OriginPoint: ComplexType

Cmd.Ptr["WCS.OriginPoint"] - Shift of coordinate system origin

X: Double

Cmd.Flt["WCS.OriginPoint.X"] - offset in X

Y: Double

Cmd.Flt["WCS.OriginPoint.Y"] - offset in Y

Z: Double

Cmd.Flt["WCS.OriginPoint.Z"] - offset in Z

RotAngles: ComplexType

Cmd.Ptr["WCS.RotAngles"] - The angles of rotation of the coordinate system along the axes (in degrees). The sequence of rotations around the axes (notation of Euler angles) may vary and is defined in the settings of the machine scheme.

A: Double

Cmd.Flt["WCS.RotAngles.A"] - angle of rotation around the X axis

B: Double

Cmd.Flt["WCS.RotAngles.B"] - angle of rotation around the Y axis

C: Double

Cmd.Flt["WCS.RotAngles.C"] - angle of rotation around the Z axis

Axes: Array, Key="AxisID"

Cmd.Ptr["Axes"] - Array of the "Axes" records. Defines the positions of the real (machine) axes that corresponds to the defined coordinate system. Origin command can contain positions for the few axes.

Axis: ComplexType

Cmd.Ptr["Axes"].Item[Index] или Cmd.Ptr["Axes(<AxisName>)"] - The item of the Axes array. It contains the position of a machine axis. Access for the array item is available by the index of by the key field. Here <AxisName> - value of the key field that must be equal to value of field <AxisID>.

AxisID: String

Cmd.Str["Axes(<AxisName>).AxisID"] - Identifier of machine axis for that the position is defined. It is described in the machine schema.

Value: Double

Cmd.Flt["Axes(<AxisName>).Value"] - Axis position.

IsSpatial: Integer

Cmd.Int["IsSpatial"] - parameter, that defines the priority what is main or geometrical coordinates (A,B,C) or machine axes. Two values is possible: 0 - machine axes defined by Axes array has the priority.1 - geometrical coordinates defined by the MCS and WCS have the priority.

PositioningMode: Integer

Cmd.Int["PositioningMode"] - parameter that defines or this command generate the real motions of the machine axes or defines the local coordinate system inside CNC without any motions.Three value are possible:0 - STAY - transformation does not generate the real machine motions. ,

1 - TURN - transformation moves the machine rotary axes only.,

2 - MOVE transformation moves all necessary axes to save the same tool tip position in the new coordinate system.


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. T he origin command does not move the machine axes .

Cmd.Int["PositioningMode"]=TURN. T he 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. T he 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.

images/download/attachments/95446828/CSTypes.png

SprutCAM Local CS settings.

In SprutCAM the settings of the ORIGIN command are specified in the Machine configuration file.

<SCType ID="MachineName" type="AbstractMachine">

...

<ControlData>

...

<LocalCS>

<IsSpatial DefaultValue="True"/>

<PositioningMode DefaultValue="Stay"/>

</LocalCS>

...

</ControlData>

...

<SCType>

The options are also available from the GUI in the Control Parameters section of the Machine parameters .

images/download/attachments/95446828/LocalCSInspector.png

Code samples of the <ORIGIN> command:

program Origin

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)

end

end

program Origin

if CLD[4]=0 then begin ! Select standart LCS (G54-G59)

! Do nothing for Heidenhain

end else if CLD[4]=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

(abs(Cmd.Flt["WCS.RotAngles.B"])>0.0001) or

(abs(Cmd.Flt["WCS.RotAngles.C"])>0.0001)

then begin

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"])

end

if Cmd.Ptr["Axes(AxisCPos)"]<>0 then begin

OutStr$ = OutStr$ + " C" + str(Cmd.Flt["Axes(AxisCPos).Value"])

end

Output OutStr$

end

end

end

end

See also:

Technology commands description