<< Click to Display Table of Contents > 

USC-3 Manual > G-Code (CNC) > Supported G-Code Commands

Supported G-Code Commands
Previous pageReturn to chapter overviewNext page

Before the G-Code commands can be interpreted by the USC-3 card there are several settings which have to be defined before a *.cnc file can be converted to a *.unf file successfully. The SCAPS definitions commands are global field settings, pen settings and special settings. They can be defined in a global default definition file and/or within each *.cnc job file as file settings. If required code is not defined in the global G-Code settings it has to be used in every job file. At the beginning of each conversion the global settings will be read at first and then the *.cnc job file. If definition commands are used in both files the values of the job file will be taken. It is not allowed to define the same function within the global G-Code file AND in the *.cnc file. There are two ways of defining a comment within a *.CNC file. Using ';' is defining a comment which ends with the current line. Within this comment any character can be used. '(' is defining the beginning of a comment whereas ')' is defining its end. Nested comments with '(' and ')' are invalid. This comment has to end before the end of the current line. The end of a line is indicated by <LF>. The decimal separator for floating values is '.'.

Please note that the G-Code interpreter will not check if the defined coordinates does match with the defined field size!
Please note that not all available G-Code commands are interpreted into entities by SAMLight. For example, G0 commands are ignored during import to SAMLight.

 

Program code

Global commands

Definition commands

Field settings [g]

Pen settings [g]

Special settings [g], [o]

General commands

Variables [o]

Entity commands [o]

Jump and mark commands

Motion commands [o]

GOTOF and CALL commands [o]

Output and Input commands [o]

Functions code [g], [o]

[g]: These commands can be outsourced in the global G‑Code settings.
[o]: These commands are optional, not required.

Table 36: G-Code command structure of a *.cnc job file

 

Program code: Within this program code everything but the definitions of functions is defined. The program code starts automatically at the beginning of the *.cnc file and ends with the command 'M2'.

 

Global Commands: These parameters are defined according DIN 66025 and ISO 6983. They have to be defined within each *.cnc file.

 

G17

Defines XY plane as working area.

This define is valid until it is overwritten within the code.

 

G70 or G71

Defines the position unit.

G70 sets inch as unit, G71 sets mm as unit.
This define is valid until it is overwritten within the code.

 

G90 or G91

Use absolute or relative position values.

G90 sets absolute values, G91 sets relative values.
This define is valid until it is overwritten within the code.

 

M2

End of program.

This command ends the program and starts the optional function definition code.

 

Definition commands: Defines the scanner and pen settings. The definition commands start and end with the $SC_DEFINES command. They can be defined in the global settings of the USC-3 card or within the *.cnc file.

 

$SC_DEFINES = x

Defines the beginning and the end of the definition command block within the *.cnc file.

Value

Function

1

Begin of definitions

0

End of definitions

All definition commands has to be within the begin and the end of the definitions.

 

$SC_LASERPORT = x

Defines the laser port for YAG laser.

Value

Function

2

8 bit digital laser port (LP_0 - LP-7)

3

DAC A

4

DAC B

Please define the laser port even if you have already set it in sc_setup.exe.

 


Field settings:

 

$SC_FIELDXMIN = x

$SC_FIELDXMAX = x

$SC_FIELDYMIN = x

$SC_FIELDYMAX = x

Defines the field size.

Unit: mm

These four commands defines the borders of the XY field size.

 

$SC_FIELDXGAIN = x
$SC_FIELDYGAIN = x

Defines the X and Y gain of the scanner field.

Factor range: [0; 2]

The default value of this define is 1.

 

$SC_FIELDXOFFSET = x
$SC_FIELDYOFFSET = x

Defines the X and Y offset of the scanner field.

Unit: mm

The default value of this define is 0.

 

$SC_FIELDAXISSTATE = x

Defines the arrangement of the axes X, Y and Z.

Value

Function

0

Neutral

1

Inverts the X-axis

2

Inverts the Y-axis

4

Flips the X and Y axes

8

Inverts the Z-axis

The default value of this define is 0. The combination of this flags is the sum of the values. The value for <Flags> for a inverted X-axis and X-Y flip would be 1+4=5.

 


Pen settings:

 

SC_TOOL_LOAD[#]

Starts the definition of a pen number #.

Range: [1; 1024]

Starts the definition of the pen settings. The definition has to end with SC_TOOL_SAVE[#]. The pen must be chosen with SC_TOOL_LOAD[#] in the general commands.

Please note that in SAMLight only up to 256 pens can be imported.

Pens > 256 will be mapped to pen 1.

 

$SC_LASERPOWER = x

Defines the laser power of the pen.

Unit: % [0; 100]

Modulates the LaserA signal (PWM) for CO2 laser or sets the laser port for YAG laser. The laser port for YAG lasers has to be defined with $SC_LASERPORT.

 

$SC_FREQUENCY = x

Defines the frequency of the pen.

Unit: kHz

Modulates the LaserA signal.

 

$SC_YAGPULSELENGTH = x

Defines the pulse length (YAG only)

Unit: µs

Modulates the LaserA signal of a YAG laser.

 

$SC_STDBYPERIOD = x

Defines the standby half period of the pen.

Unit: µs

Modulates the LaserA signal in standby for CO2 or YAG laser.
Freq. = 1 / ( 2 * $SC_STDBYPERIOD )

 

$SC_STDBYPULSEWIDTH = x

Defines the standby pulse width of the pen.

Unit: µs

Modulates the LaserA signal in standby for CO2 or YAG laser.

 

$SC_JUMPSPEED = x

Defines the jump speed of the pen.

Unit: mm/s

Is used for general commands G0.

 

$SC_MARKSPEED = x

Defines the mark speed of the pen.

Unit: mm/s

Is used for general commands G1, G2 and G3.

 

$SC_JUMPDELAY = x

Defines the jump delay of the pen.

Unit: µs

This scanner delay is executed after a jump (general command G0).
Jump delay too short -> After a jump a oscillation will be visible at the start of a mark vector.

Jump delay too long -> No problem, just increasing mark time.

 

$SC_MARKDELAY = x

Defines the mark delay of the pen.

Unit: µs

This scanner delay is executed after a marking procedure (general commands G1, G2 and G3).

Mark delay too short -> The last part of a vector is turned towards the direction of the jump vector.

Mark delay too long -> No problem, just increasing mark time.

 

$SC_POLYDELAY = x

Defines the poly delay of the pen.

Unit: µs

This scanner delay is executed during a marking procedure (general commands G2 and G3) of a polyline.

Poly delay too short -> The corners of the polyline are rounded off.

Poly delay too long -> Burn-in effects at the corners.

 

$SC_LASERONDELAY = x

Defines the laser on delay of the pen.

Unit: µs

The time the controller card waits from the beginning of the output of the first scanner micro step before it switches on the laser with the command SC_TOOL[1] (for general commands G1, G2 and G3). The laser on delay can have a negative value too. If so the Scanner moves to the start position of the vector and waits for LASERONDELAY µs. This is the time the laser needs to start up. When the laser is ready then the scanner will begin moving.
LaserOn delay too short -> Burn-in effects at the beginning of a mark vector.

LaserOn delay too long -> The first part of a vector is not marked.

 

$SC_LASEROFFDELAY = x

Defines the laser off delay of the pen.

Unit: µs

The time the controller card waits from the beginning of the output of the last scanner micro step before it switches off the laser with the command SC_TOOL[0] (general commands G1, G2 and G3).

LaserOff delay too short -> The last part of a vector is not marked.

LaserOff delay too long -> Burn-in effects at the end of a mark vector.

Important delay rules:

LaserOn < LaserOff < LaserOn + Mark

 

SC_TOOL_SAVE[#]

Ends the definition of a pen number #.

Range [1; 255]

The definition has to start with SC_TOOL_LOAD[#].

 


Special settings (optional):

 

$SC_ARCSTEPMODE = x

Enables the dynamic segment number mode for arcs, ellipses and circles.

Value for x

Function

0

disabled

1

enabled

If this mode is enabled the number of arc segments can be defined with SC_ARCSTEPVALUE manually. This is affecting the general commands G2 and G3. The software will create 1 sampling point per mm vector length if the arcstepmode is disabled.

 

$SC_MOFCHAN = x

Defines the marking on the fly channel.

Value for x

Function

0

Sets channel 0 of the USC-3 card (37 pin connector) as MOTF encoder input signal.

1

Sets channel 1 of the USC-3 card (40 pin extension connector) as MOTF encoder input signal..

This command is necessary for marking on the fly applications only.

 

General commands: Defines variables and supported entity , jump, mark, laser, motion, GOTOF and CALL commands for each *.cnc file. Make sure you have already set the global and definition commands before you are using the general commands. The commands G0, G1, G2, G3 and G4 are defined according DIN 66025 and ISO 6983.

 


Variables: There are 2 types of variables: freely definable variables (DVAR) and 2 pre-defined variables.
Free variables can be defined at any place within the general code. They need to be defined before they are used the first time and the values are valid until they are changed within the program code.

 

DVAR $<VariableName> = x

Defines a floating point variable with the name <name> and the value x.

<VariableName> is not case-sensitive. Multiple variables can be used.

 

$<VariableName>

Addresses a floating point variable with the name <name>.

<VariableName> has to be defined with the DVAR command before it can be addressed.

 

SC_CUSTOM_VALUE[0][X]

SC_CUSTOM_VALUE[1][Y]

Use 2 pre-defined variables.

The USC-3 card can work with 2 pre-defined variables.These 2 variables are 32-bit integer values and can be used to store a value.  

The first variable is addressed by SC_CUSTOM_VALUE[0][X], the second one by SC_CUSTOM_VALUE[1][Y]. X and Y stand for the values the user can store.

The values of these 2 variables can be get (not set) with the FCI command CVAL (CVAL 0 and CVAL 1).

 


Entity commands (optional): If no entity command is used everything will be marked once (loopcount = 1).

 

$SC_LOOPCOUNT = x

Defines a loop count for an entity.

The loopcount is executed on the next entity which is generated with SC_START_ENTITY and SC_END_ENTITY and is valid until it is overwritten within the code. The default value for this define is 1.

 

$SC_ARCSTEPVALUE

Defines number of circle segments.

If the SC_ARCSTEPMODE has been enabled this value defines the number of segments a circle will have. This is affecting the general commands G2 and G3.

 

SC_START_ENTITY

Defines a start marker for an entity.

The corresponding end marker of an entity is SC_END_ENTITY. The commands which are given inside SC_START_ENTITY and SC_END_ENTITY will be repeated as often as defined in SC_LOOPCOUNT.

 

SC_END_ENTITY

Defines an end marker for an entity.

The corresponding start marker of an entity is SC_START_ENTITY. The commands which are given inside SC_START_ENTITY and SC_END_ENTITY will be repeated as often as defined in SC_LOOPCOUNT.

 


Jump and mark commands:

 

SC_TOOL_LOAD[#]

Loads Pen number # in the range [1, 1024].

Sets a pen which must be set up with SC_TOOL_LOAD[#] in the definition commands.

 

SC_TOOL[#]

Switch the laser on or off.

Value for #

Function

0

Laser off

1

Laser on

Make sure you have set a pen with SC_TOOL_LOAD before you switch on the laser. This command will use the laser delays which are defined in the pen settings.

 

$SC_DACA = x

$SC_DACB = x

Defines the laser power for DAC A / DAC B.

Unit: bits

Sets analog signal of DAC A / DAC B as laser port. The value range is 0 - 4095. The voltage corresponds to the value which was set in sc_setup.exe and stored to the USC-3 card. Possible maximum output voltages are 2.5, 5.0 and 10.0 volts.

 

$SC_LP = x

Defines the laser power for 8 bit laserport.

Unit: bits

Sets 8 bit signal of the laser port (LP_0 to LP_7) of the USC-3 card. The value range is 0 - 255.

 

G0 X Y Z

Performs a scanner jump.

Unit: mm (inch)

The scanner will jump to the position (X, Y, Z). X, Y and Z are floating point values. The coordinates depend on the global commands G90 (absolute values) or G91 (relative values). The unit depends on the global commands G70 (inch) or G71 (mm). Make sure you have set a pen with SC_TOOL_LOAD before you use this command. The value for Z is optional.

 

G1 X Y Z

Performs a linear scanner move.

Unit: mm (inch)

The scanner will move to the position (X, Y, Z). X, Y and Z are floating point values. The coordinates depend on the global commands G90 (absolute values) or G91 (relative values). The unit depends on the global commands G70 (inch) or G71 (mm). Make sure you have set a pen with SC_TOOL_LOAD before you use this command. The value for Z is optional.

 

G2 X Y i j

Performs a clockwise arc scanner move.

Unit: mm (inch)

The scanner will draw an arc clockwise.

The start point of the circle is the previous position (Xprev, Yprev).

The circle center point is (Xprev+i, Yprev+j).

The end point is (X,Y) and must be valid point on the circle.

X, Y, i and j are floating point values. The unit depends on the global commands G70 (inch) or G71 (mm). Make sure you have set a pen with SC_TOOL_LOAD before you use this command.

 

G2 X Y R

Performs a clockwise arc scanner move.

Unit: mm (inch)

The scanner will draw an arc smaller than 180° clockwise.

The start point of the circle is the previous position (Xprev, Yprev).

The end point is (X,Y) and must be valid point on the circle.

The radius (R) defines the bending of the arc.

X, Y and R are floating point values. The unit depends on the global commands G70 (inch) or G71 (mm). Make sure you have set a pen with SC_TOOL_LOAD before you use this command.

 

G3 X Y i j

Performs an anti clockwise arc scanner move.

Unit: mm (inch)

The scanner will draw an arc anti clockwise.

The start point of the circle is the previous position (Xprev, Yprev).

The circle center point is (Xprev+i, Yprev+j).

The end point is (X,Y) and must be valid point on the circle.

X, Y, i and j are floating point values. The unit depends on the global commands G70 (inch) or G71 (mm). Make sure you have set a pen with SC_TOOL_LOAD before you use this command.

 

G3 X Y R

Performs an anti clockwise arc scanner move.

Unit: mm (inch)

The scanner will draw an arc smaller than 180° anti clockwise.

The start point of the circle is the previous position (Xprev, Yprev).

The end point is (X,Y) and must be valid point on the circle.

The radius (R) defines the bending of the arc.

X, Y and R are floating point values. The unit depends on the global commands G70 (inch) or G71 (mm). Make sure you have set a pen with SC_TOOL_LOAD before you use this command.

 

G4 Px

Waits at current position.

Unit: s

The scanner waits at the current position for x seconds where x is a floating point value. Make sure you have set a pen with SC_TOOL_LOAD before you use this command. This can be used in drill mode.

 

SC_DEFOCUS_BIT

Set the defocus of the z axis

Unit: bit

This command set the defocus of the z axis.

 

$SC_MOFFACTOR0 = x

$SC_MOFFACTOR1 = x

Defines marking on the fly factor.

Unit: mm / count

This command is necessary for marking on the fly applications only. x is a floating point value for the MOTF factor which is used to calculate the compensation based on the counts of the encoder into mm.

$SC_MOFFACTOR0 defines the MOTF factor of channel 0, $SC_MOFFACTOR1 defines the MOTF factor of channel 1. The channel for the encoder input signal has to be selected with the command $SC_MOFCHAN first.

 

SC_MOFON[#]

Activates the marking on the fly compensation.

Value for #

Function

0

Compensation in x direction.

1

Compensation in y direction.

Make sure you have defines the input channel for the encoder signals with $SC_MOFCHAN and defined the marking on the fly factor with $SC_MOFFACTOR0 or $SC_MOFFACTOR1 first.

 

SC_MOFOFF

Deactivates the marking on the fly compensation.

This command deactivates the MOTF compensation.

 

SC_SETMOFOFFSET[x]

Defines Marking on the fly offset entity.

Unit: mm

x is a floating point value for a distance in mm. This entity will generate an internal trigger pulse after the corresponding distance in mm has been reached. The distance is calculated based on the count of the encoder signal and the defined value for the MOTF factor. Refer to SC_MOFON.

 

SC_CLEARANDWAITTRIGGERMOF

Wait for MOTF trigger.

This command pauses the job execution until an internal trigger signal has been received.

 

This internal trigger can be generated with an SC_SETMOFOFFSET entity.

 

SC_CLEARANDWAITTRIGGER

Wait for trigger.

This command pauses job execution until an external trigger signal is received at Opto_In_0 (rising edge).

 

 

 


Motion commands (optional, only available for stepper type 14 of the USC-3):

Please note that motion commands are always based on mm. The global command G70 (use inch as unit) will be ignored for all CGL commands.

 

SC_CMD['GCL M46']

Enables stepper execution.

No GCL commands will work without enabling the stepper execution first. If a movement was stopped with the GCL M0 command the stepper execution is automatically disabled and has to be enabled with GCL M46 again before another GCL command can be used.

 

SC_CMD['GCL M0']

Disables stepper execution and aborts moves.

If a motion is executed it can be aborted with this command. After this command no motion command will be executed before the stepper was enabled with GCL M46 again.

 

SC_CMD['GCL G90']

Switch to absolute mode.

In absolute mode GCL G1 move commands are interpreted as absolute values in mm (default). This define is valid until it is overwritten within the code.

 

SC_CMD['GCL G91']

Switch to relative mode.

In relative mode GCL G1 move commands are interpreted relative to previous position in mm. This define is valid until it is overwritten within the code.

 

SC_CMD['GCL F?']

Defines movement speed.

Unit: mm/s

The value for ? is a floating point value. This speed is taken for GCL G1 and is valid until it is overwritten within the code.

 

SC_CMD['GCL G1#?']

Defines movement.

Unit: mm

Addressed axis move to position ?. The value for ? is a floating point value.

# corresponds to the axis identifier (X, Y, Z, A, B, C). X is always the first axis like defined with 'axis=0' in sc_motion_stepper_settings.txt. Multiple axis can be combined for example like G1X1Y2.5Z0. Using the same speed the X-, Y- and Z-axis can move interpolated so that they reach the final position of the movement at the same time.

 

SC_CMD['GCL G28#1']

Starts homing procedure.

Homes axis defines with identifier # (X, Y, Z, A, B, C). X is always the first axis like defined with 'axis=0' in sc_motion_stepper_settings.txt. The homing procedure is defined in the same file. Only one axis at a time can be homed.

 


GOTOF (labels) and CALL (function) commands (optional):

 

<LabelName>:

Defines jump label.

<LabelName> is a string (not case sensitive) and defines a jump label which can be addressed with the GOTOF command. The label can be anywhere within the general command code. Each label has to be unique and can not be overwritten within the code. Multiple labels can be used.

 

GOTOF <LabelName>

Jumps to a label.

<LabelName> is a jump label which has to be defines somewhere in the general command code.

 

CALL <FunctionName>

Calls a function.

<FunctionName> has to be defined in the function code of the *.cnc file (after the program code) with a DFS command. If the CALL command is used the corresponding function will be copied at the place where the CALL command is called.

 


Output and Input commands (optional):

 

SC_SetOutput[Bit][State]

 

Set the output [bit].

SC_SetOutput sets a single output bit to the defined state.
 

 

 

Example: SC_SetOutput[7][1] activates Digi_Out_0.

 

SC_SetOutput_MV[Mask][State]

 

Set outputs using a [mask].

SC_SetOutput_MV sets multiple outputs to the defined states.
 


 

 

 


 


 

Example: SC_SetOutput_MV[48][48] activates Opto_Out_4 and activates Opto_Out_5.

 

SC_WaitForInput[Bit][State]

 

Wait for the input [bit].

SC_WaitForInput pauses job execution until a single input is in the defined state.

 


 


 

Example: SC_WaitForInput[6][1] waits for Opto_In_5 to be active.

 

SC_WaitForInput_MV[Mask][State]

Wait for inputs using a [mask].

SC_WaitForInput_MV pauses job execution until multiple inputs are in the defined states.

 

waits for multiple inputs to be in the defined states.
 


 


 

 

 


 

Example: SC_WaitForInput_MV[48][48] waits Opto_In_4 to be active and Opto_In_5 to be active.

 

Functions code (optional):  Behind the program code definitions of functions can be defined. The functions code starts after the command 'M2' and ends with the last line of the *.cnc file.

 

DFS<FunctionName>

Begins the definition of a function.


<FunctionName> is a string (not case sensitive) and defines a function which can be addressed with the CALL command. The function has to be coded within the function code outside the program code. Each function name has to be unique and can not be overwritten within the code. Multiple functions can be used.

 

ENDDFS

Ends the definition of a function.


Marks the end of a function.