General Command Overview

Preprocessor

Command

Description

#include

The #include directive inserts the contents of another file. The included file is referenced by its path. Typically, it is used to “import” commonly used code like e.g. libraries. Its behavior is similar to the C-Preprocessor.

Interpolations

Command

Description

Modal or Nonmodal

Default

G00

Interpolation mode: Linear.
Applying maximum velocity ignoring programmed velocity.
Reset by G01, G02, G03.

Modal.

Default.

G01

Interpolation mode: Linear.
Applying programmed velocity.
Reset by G00, G02, G03.

Modal.

No.

G02

Clockwise interpolation mode: Circular or helical.
Applying current velocity.
Reset by G00, G01, G03.

Modal.

No.

G03

Counterclockwise interpolation mode: Circular or helical.
Applying current velocity.
Reset by G00, G01, G02.

Modal.

No.

G303

With G303 an circular arc (CIP circle) can be programmed, that can be freely located in space.

 

No

G04

Defines a dwell time, i.e. suspends machining for a given duration.

Nonmodal.

No.

Workingplane Selection

Command

Description

Modal or Nonmodal

Default

G17

Selects XY-plane as workingplane.

Modal.

Default.

G18

Selects ZX-plane as workingplane.

Modal.

No.

G19

Selects YZ-plane as workingplane.

Modal.

No.

Delete Distance to go

Command

Description

Modal or Nonmodal

Default

G31

Delete distance to go.

Nonmodal.

No.

Deactivation and Activation of Tool Radius Compensation

Command

Description

Modal or Nonmodal

Default

G40

Deactivates Tool Radius Compensation (TRC). With/After a G40 command it is mandatory to program at least one geometry element.

Modal.

Default.

G41

Activates Tool Radius Compensation (TRC).
Left.

Modal.

No.

G42

Activates Tool Radius Compensation (TRC).
Right.

Modal.

No.

Set, Deactivate and Activate Zero-Offset-Shift Translations

Command

Description

Modal or Nonmodal

Default

G53

Deactivates any zero-offset-shift translation.

Modal.

Default.

G54..G57

Activates the zero-offset-shift associated with the given G-Code.
Activates the translation G58 and G59.

Modal.

No.

G58, G59

Sets the translation associated with the given G-Code.

Modal.

No.

Command

Description

zeroOffsetShiftSet(g:= USInt,
 x:= LReal,
y:= LReal,
z:= LReal)

Sets the translation for G-Code g where g must be one of the numbers 54, 55, 56 or 57.

Accurate Stop

Command

Description

Modal or Nonmodal

Default

G09

Accurate stop.

Nonmodal.

No.

G60

Accurate stop.

Modal.

No.

Set Unit for Length and Speed

Command

Description

Modal or Nonmodal

Default

G70

Sets the unit for lengths to inch.
Does not affect the unit for velocity.

Modal.

No.

G71

Sets the unit for lengths to millimeter.
Does not affect the unit for velocity.

Modal.

Default.

G700

Sets the unit for lengths to inch.
Also applies to the interpretation of velocity.

Modal.

No.

G710

Sets the unit for lengths to millimeter.
Also applies to the interpretation of velocity.

Modal.

Default.

Switch to Absolute or Relative Coordinates

Command

Description

Modal or Nonmodal

Default

G90

Switches to absolute programming.

Modal.

Default.

G91

Switches to incremental programming.

Modal.

No.

IJK

Command

Description

Modal or Nonmodal

Default

I<vx> J<vy> K<vz>

Center point is currentPoint + [vx,vy,vz].
Current length unit is used for vx,vy,vz.
I used by G4 defines a duration.

Modal.

Default: Center point is currentPoint + [0,0,0].
The IJK-parameters are optional.

M-Functions

Command

Description

M<v>

Triggers the M-function v.
The timing behavior depends on the definition of v in the development environment of TwinCAT.
There must not be more than one M-function of type handshake in a block.

M2

Predefined M-function.
Signals program end.

M30

Predefined M-function.
Signals program end.

Tool Orientation

Command

Description

Modal or Nonmodal

Default

P<v>

Switches tool orientation.

Modal.

No.

Set Block Number

Command

Description

N<v>

Block number.

Set Radius

Command

Description

Modal or Nonmodal

Default

U<v>

Sets the radius within the context of G02 or G03 to |v|.

Modal.

No.

Set Cartesian Coordinate

Command

Description

X<v>

Sets the X-coordinate of the next point to v.
Uses current length unit for v.

Y<v>

Sets the Y-coordinate of the next point to v.
Uses current length unit for v.

Z<v>

Sets the Z-coordinate of the next point to v.
Uses current length unit for v.

Auxiliary Axes

Command

Description

Modal or Nonmodal

Default

Q<i>=<v>

Sets label for auxiliary axis.

Modal.

No.

Set Orientation Angle

Command

Description

Modal or Nonmodal

Default

A<v>

Sets the A-angle of the next orientation to v.
Uses current length unit for v.

Nonmodal, but may influence succeeding blocks.

No.

B<v>

Sets the B-angle of the next orientation to v.
Uses current length unit for v.

Nonmodal, but may influence succeeding blocks.

No.

C<v>

Sets the C-angle of the next orientation to v.
Uses current length unit for v.

Nonmodal, but may influence succeeding blocks.

No.

Control Structures

Command

Description

IF-THEN-ELSIF-ELSE

Conditional statement.

CASE OF

Conditional statement.

FOR

Counter-controlled loop.

WHILE

Head-controlled loop.

REPEAT

Foot-controlled loop.

EXIT

Leaving a loop.

Jump statement

Command

Description

LABEL-GOTO

Jump statement.

Trigonometric

Command

Description

SIN(x)

Returns the sine of x; x in radians.

COS(x)

Returns the cosine of x; x in radians.

TAN(x)

Returns the tangent of x; x in radians.

ASIN(x)

Returns the arc sine of x; x in radians.

ACOS(x)

Returns the arc cosine of x; x in radians.

ATAN(x)

Returns the arc tangent of x; x in radians.

ATAN2(y, x)

Returns the arc tangent of y/x; y/x in radians.

Arithmetic

Command

Description

ABS(x)

Returns the absolute value of x.

SQRT(x)

Returns the square root of x.

LN(x)

Returns the natural logarithm of x.

LOG(x)

Returns the decimal logarithm of x.

EXP(x)

Returns e raised to the power of x.

ADD(x1, x2, …)

Returns the sum of all parameters.

MUL(x1, x2, …)

Returns the product of all parameters.

SUB(x, y)

Returns the difference x-y.

DIV(x, y)

Returns the quotient x/y.

MOD(x, y)

Returns the remainder of the integer division x/y.

EXPT(x, y)

Returns x raised to the power of y.

Arithmetic Parameters

Command

Description

rSet(index := LINT, value := LREAL)

Assigns an R-parameter value.

rGet(index := LINT)

Extracts an R-parameter value.

Bit Shift and Bit Rotation

Command

Description

SHL(x, y)

Returns the bitstring x shifted left by y bits.

SHR(x, y)

Returns the bitstring x shifted right by y bits.

ROL(x, y)

Returns the bitstring x rotated left by y bits.

ROR(x, y)

Returns the bitstring x rotated right by y bits.

Logical Operations

Command

Description

AND(x1, x2, …)

Returns the bitwise Logical And of all parameters.

OR(x1, y2, …)

Returns the bitwise Logical Or of all parameters.

XOR(x1, x2, …)

Returns the bitwise Logical Exclusive Or of all parameters.

NOT(x)

Returns the bitwise complement of x.

Selection (Conditional Expressions)

Command

Description

SEL(cond, x1, x2)

Returns x1 if cond is FALSE, and x2 otherwise.

MUX(select, x0, x1, …, xN)

Returns x<select>.

Min, Max and Limit

Command

Description

MAX(x1, x2, …)

Returns the maximum of all parameters.

MIN(x1, x2, …)

Returns the minimum of all parameters.

LIMIT(min, in, max)

Returns in if it lies in the interval [min,max]. Otherwise, the violated bound (min or max) is returned.

Comparison

Command

Description

GT(x, y)

Returns TRUE if x is larger than y.

GE(x, y)

Returns TRUE if x is not smaller than y.

EQ(x, y)

Returns TRUE if x and y are equal.

LE(x, y)

Returns TRUE if x is not larger than y.

LT(x, y)

Returns TRUE if x is smaller than y.

NE(x, y)

Returns TRUE if x and y are not equal.

Strings and Messages

Command

Description

toString(<arg0>, …, <argN>): STRING

Converts and concatenates the given arguments to one string.

msg(str:= String[81])

Sends the given message to the message list of TwinCAT.

Transformations

Command

Description

transRotX(angle:= LReal)
transRotY(angle:= LReal)
transRotZ(angle:= LReal)

Rotation around the respective axis by the given angle in the user-defined angle unit.

transRotA(x:= LReal,
y:= LReal,
 z:= LReal,
angle:= LReal)

Rotate around vector [x,y,z] by the given angle.

transMirrorX()
transMirrorY()
transMirrorZ()

Mirror with respect to the X-direction, Y-direction or Z-direction relative to the origin of the current PCS.

transScale(factor:= LReal)

Scales the coordinate system by the factor in the X-dimension, Y-dimension and Z-dimension.

transScaleAxis(axisNo := axisIndex, factor := value)

Scales the selected path axis (axisNo) by the factor.

transTranslate(x:= LReal,
 y:= LReal,
z:= LReal)

Translate by vector [x,y,z].

transPop()

Pops a transformation from the stack of transformations.

transDepth(): UInt

Yields the depth of the stack of transformations, i.e. the number of active transformations.

transRestore(depth:= UInt)

Reduces the stack of transformations to the given depth.

Movement

Command

Description

moveCircle3d(cx:= LReal,
cy:= LReal,
 cz:= LReal,
 nx:= LReal,
 ny:= LReal,
 nz:= LReal,
 angle:= LReal,
 height:= LReal)

Move circular by rotating around the center cx,cy,cz and the normal vector nx,ny,nz by the given angle. If height is nonzero, a helix is described. The rotation is performed according to the right hand rule.

Centerpoint Correction

Command

Description

centerpointCorrectionSet(on:= bool)

Activates the centerpoint correction for circles. Used for circles that are defined by centerpoint programming.

centerpointCorrectionLimitSet(limit:= LReal)

Sets the precision limit for the centerpoint of circles.

Tools

Command

Description

toolParamSet(tidx:= USInt,
col:= USInt,
 val:= LReal)

Set a parameter of the tool tidx (1..255) to val. The parameter is identified by col (0..15).

toolParam(tidx:= USInt,
 col:= USInt): LReal

Yields the given tool parameter.

toolSet(index:= USInt,
 nr:= Int,
 tooltype:= ToolType,
 length:= LReal,
 radius:= LReal,
 lengthAdd:= LReal,
 radiusAdd:= LReal,
 offsetX:= LReal,
 offsetY:= LReal,
 offsetZ:= LReal)

Set all parameters of a tool.

ToolType

Enumeration of tool types.

Tool Radius Compensation

Command

Description

trcApproachDepartSet(approachRadius:= LReal,
 approachAngle:= LReal,
 departRadius:= LReal,
 departAngle:= LReal)

Configures the approach and depart behavior to use an arc of given radius and angle.

trcOffsetSet(offset:= LReal)

Configures the amount of segment extension that is used to close gaps.

trcLimitSet(offset:= LReal)

Configures the lookahead that is used for collision elimination.

trcParam(): TrcParamType

Returns the current configuration as a structure value.

trcParamSet(param:= TrcParamType)

Configures the tool radius compensation. Summarizes trcApproachDepartSet, trcOffsetSet and trcLimitSet.

TrcParamType

Structure containing all configuration parameters of the tool radius compensation.

collisionElimination(nx:= LReal,
ny:= LReal,
 nz:= LReal,
 limit:= ULInt)

Activates collision elimination with respect to the plane of the normal vector nx, ny, nz.

collisionEliminationFlush()

To ignore conflicts between the path preceding the call and the path succeeding the call.

Command

Description

Modal or Nonmodal

Default

G40

Deactivates Tool Radius Compensation (TRC).

Modal.

Default.

G41

Activates Tool Radius Compensation (TRC). Left.

Modal.

No.

G42

Activates Tool Radius Compensation (TRC). Right.

Modal.

No.

Synchronization

Command

Description

sync()

Synchronizes the interpreter with the associated NC-channel.

wait()

Waits for a GoAhead-signal from the PLC.

Query of Axes

Command

Description

queryAxes()

Set the MCS coordinates of the interpreter to the actual coordinates of the physical axes.

Current Point

Command

Description

frameGet(x:= LReal,
 y:= LReal,
z:= LReal,
a:= LReal,
 b:= LReal,
 c:= LReal)

Store the current frame of the PCS in x, y, z and a, b, c.

qAxisGet(q1:= LReal,
 q2:= LReal,
 q3:= LReal,
q4:= LReal,
 q5:= LReal)

Store the current values of Q-axes q1 to q5.

Suppression of G-Code Blocks

Command

Description

disableMask():= LWord

Yields the current value of the disable mask.

disableMaskSet(mask:= LWord)

Sets the internal disable mask to the given value.

Units

Command

Description

unitAngleSet(unitAngle:= UnitAngle)

Set the unit for angles to unitAngle.

UnitAngle

Enumeration of unit angles.

unitLengthSet(unitLength:= UnitLength)

Set the unit for lengths to unitLength.

UnitLength

Enumeration of unit lengths.

unitTimeSet(unitTime:= UnitTime)

Set the unit for time to unitTime.

UnitTime

Enumeration of unit times.

unitVelocitySet(unitLength:= UnitLength,
 unitTime:= UnitTime)

Set the unit for velocity to unitLength/unitTime.

Trigonometric (Unit Aware)

Command

Description

gSin(angle:= LReal)

Returns the sine of the given angle where the current angle unit is used to interpret the angle.

gCos(angle:= LReal)

Returns the cosine of the given angle where the current angle unit is used to interpret the angle.

gTan(angle:= LReal)

Returns the tangent of the given angle where the current angle unit is used to interpret the angle.

gASin(val:= LReal)

Returns the arc sine of val in the current angle unit.

gACos(val:= LReal)

Returns the arc cosine of val in the current angle unit.

gATan(val:= LReal)

Returns the arc tangent of val in the current angle unit.

gATan2(y:= LReal, x:= LReal)

Returns the arc tangent of y/x in the current angle unit.

Feed Mode

Command

Description

feedModeSet(feedMode:= FeedModeType)

Set the feed mode.

FeedModeType

Enumeration of feed mode types.

Feed Mode

Command

Description

feedInterpolationSet(feedInterpolation:= FeedInterpolationType)

Set feed interpolation.

FeedInterpolationType

Enumeration of feed interpolation types.

Streaming of Large G-Code Files

Command

Description

runFile(path:= string)

Executes the plain G-Code that is contained in the G-Code file given by path.

Vertex Smoothing

Command

Description

smoothingSet
(mainType:= SmoothingMainType,
 subType:= SmoothingSubType,
 value:= LReal)

Set the vertex smoothing behavior.

SmoothingMainType

Enumeration of smoothing main types.

SmoothingSubType

Enumeration of smoothing sub types.

autoAccurateStopSet

Automatic accurate stop.

Dynamic Override

Command

Description

dynOverrideSet(value:= LReal)

Set the dynamic override of axes to the given value.

Programming reference

Command

Description

programmingReferenceSet

As an alternative to G90/G91, programmingReferenceSet can be used to set the dimensions of the subsequent movement commands to absolute or relative.

programmingReferenceGet

The currently active dimension for the movement commands can be read out with programmingReferenceGet.

ReferenceType

Enumeration of reference types.

Center Point Reference of Circles

Command

Description

circleCenterReferenceSet(value:= ReferenceType)

Sets the center reference type for circles that are programmed by G02/G03.

ReferenceType

Enumeration of reference types.

Dynamics Set

Command

Description

axisDynamicsSet

Change in axis dynamics.

pathDynamicsSet

Change in path dynamics.

Spline Interpolation

Command

Description

transBSpline

Spline interpolation.