G-Code (RS-274) Support

Supported G-Code Letters

The following G-code letters are supported by the language.

Letter

Meaning

E

Feedrate of Dependent Axes

F

Feedrate of Dominant Axes

G

General Function (G-code)

I

I Offset for G2/G3/G12/G13

J

J Offset for G2/G3/G12/G13

K

K Offset for G2/G3/G12/G13

M

Miscellaneous Function (M-code)

N

Line number/label (N-code)

P

Absolute Starting Angle for G2/G3/G12/G13

Q

Absolute Ending Angle for G2/G3/G12/G13

R

Radius for G2/G3/G12/G13

S

Spindle Speed

T

Tool Selection Function (T-code) for custom tool selection routines

More details about the G-code letters follow:

  • Each of these letters is supported by the G-code (RS-274) standard.
  • These letters are case-insensitive, so that both G1 and g1 mean the same thing.
  • Most of the remaining letters are allowed to be used as axis names (e.g., X, Y, and Z). See Axis Naming Conventions for more information.
  • Some additional letters (H and L) are part of the G-code (RS-274) standard but are unused in AeroScript. These letters are reserved for future use.

Many concepts in G-code are not whitespace-sensitive. Whitespace between G-code letters and their expressions is optional. For example, each of the following lines of G-code programming have the same meaning.

G1X10Y100
G1 X10 Y100
G 1 X 10 Y 100

If you specify two or more G-code commands on one AeroScript program line, the commands are usually executed in the order that follows:

  1. Modal G-code words (G17, G71, G90, and so on).
  2. F, E, S, and T commands, in that order (F100, T10, and so on).
  3. Spindle on or off (M3, M4, M5).
  4. Cutter compensation commands (G40, G41, G42, G43, G44, G143, G144, and G149).
  5. Motion mode commands (G0, G1, G2, and G3).
  6. Motion commands (x10, Y-10, and so on).
  7. Control M-codes (M0, M1, M2, M30, M47, and so on).

E Command

The E command is used to specify the feedrate for dependent axes when performing coordinated motion. Coordinated motion includes the following types of motion:

  • G1, MoveLinear()
  • G2, MoveCw()
  • G3, MoveCcw()
  • G12 and G13

An E command may be specified on its own program line, or it can be specified on the same program line as G-code motion.

// Specified on its own line
E100
 
// Specified as part of a move
G1 Y50 E100

An E command can either be specified with a constant value or with a numeric expression.

// Specified with a constant feedrate
E100
 
// Specified with a numeric expression feedrate
E($dependentSpeed)

The dependent feedrate is used for coordinated moves that contain only dependent axes. If a coordinated move contains only dominant axes, or a mixture of dominant and dependent axes, then the move will use the dominant feedrate (the F command).

F Command

The F command is used to specify the feedrate for dominant axes when performing coordinated motion. Coordinated motion includes the following types of motion:

  • G1, MoveLinear()
  • G2, MoveCw()
  • G3, MoveCcw()
  • G12 and G13

An F command may be specified on its own program line, or it can be specified on the same program line as G-code motion.

// Specified on its own line
F100

 
// Specified as part of a G-code move

G41 G1 X10 Y10 F100

An F command can either be specified with a constant value or with a numeric expression.

// Specified with a constant feedrate
F100

 
// Specified with a numeric expression feedrate
F($mySpeed * 0.1)

The dominant feedrate is used for coordinated moves that contain only dominant axes or a mixture of dominant and dependent axes. If a coordinated move contains only dependent axes, then the move will use the dependent feedrate (the E command).

G-Codes

G-codes are used to configure and perform various types of motion on the controller.

G-codes must be specified with a numeric integer constant. Preceding zeros are allowed to be used in the numeric value, making both of the following G-codes equivalent:

// The following G-codes are equivalent
G1 X10
G01 X10

Refer to the list of Supported G-codes for more information.

I/J/K Offsets

The I, J, and K offsets are only applicable with the G2, G3, G12, and G13 G-codes.

M-Codes

M-codes are used to perform miscellaneous functionality on the controller.

M-codes must be specified with a numeric integer constant. Preceding zeros are allowed to be used in the integer value. The following two M-codes are equivalent:

  • M2
  • M02

Refer to the list of Supported M-codes for more information.

N-Codes

N-codes are used to label a line or a block of G-code. N-codes are optional on G-code lines. If an N-code is specified on a program line that contains G-code concepts, then it must be specified before all other G-codes on the same line.

N-codes must be specified with a positive numeric integer constant. Preceding zeros are allowed to be used in the numeric value.

  • N01G1X10
  • N02G1X15
// N-codes can be used as an alternative to labels when used in G-code.
// Use a label to branch to a specific location in G-code

goto
myLabel
 
G1 Y1.3
G1 Y2.2
 
myLabel:
G1 Y3.5

 
// Use an N-code to branch to a specific location in G-code
goto
N03
 
N01G1X2.5
N02G1X3.3
N03G1X7.5

P Command

The P command has different meanings depending upon the context in which it is specified. A P command cannot be specified on its own program, and must be specified on the same line as G2, G3, G12, or G13 G-code motion, or with the G4 G-code.

  • When specified along with the G4 G-code, the numeric value of the P command is used to specify the amount of time that the G4 command will delay execution of the task.

  • When specified with G2, G3, G12, or G13 G-code motion, the numeric value of the P command is used to specify the absolute starting angle for the G2 or G3 arc move.

In both usages, the numeric value specified as part of the P command can be a numeric constant or a numeric expression.

G4 P0.1
G4 P$dwellTime
G2 P108 Q-18 R1.5

Q Command

The Q command is used to specify the absolute ending angle for a G2, G3, G12, or G13 arc move. A Q command cannot be specified on its own line, and must be specified on the same line as G2, G3, G12, or G13 G-code motion.

The numeric value specified as part of a Q command can be a numeric constant or a numeric expression.

R Command

The R command is used to specify the radius in an arc move (G2, G3, G12, and G13 G-codes). The R command cannot be specified on its own line. When using G-codes, an R command can only be specified on the same line as a G2, G3, G12, or G13 G-code motion.

The numeric value specified as part of an R command can be a numeric constant or a numeric expression.

G2 X10 Y0 R5

S Command

The S command is used to define the speed of the spindle that is active on the current task.

T Command

Use the T command together with custom T-codes to make a user-defined tool selection routine in AeroScript.

IMPORTANT: If you want to use T commands in the Aerotech G-code dialect, you must define one custom T-code in an AeroScript program or library. If no custom T-code is defined or two or more custom T-codes are defined, a compiler error will occur.

For more information about how to use custom T-codes, see Custom T-Codes.

Supported G-codes

G-Code

Description

G0

Executes a rapid point-to-point positioning move on the specified axes.

G1

Executes a coordinated linear move on the specified axes.

G2

Executes a circular arc move in the clockwise direction on the specified axes in the first coordinate plane.

G3

Executes a circular arc move in the counterclockwise direction on the specified axes in the first coordinate plane.

G4

Suspends the execution of the task for the duration that you specify, in seconds.

G8

Causes the G-code motion that you specify on the same program line to immediately accelerate to the programmed feedrate.

G9

Causes the G-code motion command that you specify on the same program line to decelerate to zero velocity when the axes get to their target position.

G12

Executes a circular arc move in the clockwise direction on the specified axes in the second coordinate plane.

G13

Executes a circular arc move in the counterclockwise direction on the specified axes in the second coordinate plane.

G16

Configures the set of axes that are used for the first coordinate plane for G2 and G3 commands.

G17

Configures the task to use the first set of axes of the first coordinate system for G2 and G3 commands.

G18

Configures the task to use the second set of axes of the first coordinate system for G2 and G3 commands.

G19

Configures the task to use the third set of axes of the first coordinate system for G2 and G3 commands.

G26

Configures the set of axes that are used for the second coordinate plane for G12 and G13 commands.

G27

Configures the task to use the first set of axes of the first coordinate system for G12 and G13 commands.

G28

Configures the task to use the second set of axes of the second coordinate system for G12 and G13 commands.

G29

Configures the task to use the third set of axes of the second coordinate system for G12 and G13 commands.

G40

Deactivates Cutter Radius Compensation mode on the task.

G41

Activates Cutter Radius Compensation left mode on the task.

G42

Activates Cutter Radius Compensation right mode on the task.

G43

Specifies the radius that the task uses in Cutter Radius Compensation mode.

G44

Specifies the axes that comprise the X-Y or X-Y-Z plane when a cutter compensation mode is active on the task.

G60

Configures the task to use the acceleration duration that you specify for coordinated motion while operating in time-based ramping mode.

G61

Configures the task to use the deceleration duration that you specify for coordinated motion while operating in time-base ramping mode.

G63

Configures the task to operate with the sinusoidal acceleration and deceleration ramping type for coordinated motion.

G64

Configures the task to operate with the linear acceleration and deceleration ramping type for coordinated motion.

G65

Configures the task to use the acceleration rate that you specify for coordinated motion while operating in rate-based ramping mode.

G66

Configures the rate that the task uses to perform coordinated motion to decelerate dominant axes.

G67

Configures the task to use time-based ramping when accelerating and decelerating axes during coordinated motion.

G68

Configures the task to use rate-based ramping when accelerating and decelerating axes during coordinated motion.

G69

Configures the task to operate with the S-curve acceleration and deceleration ramping type for coordinated motion.

G70

Configures the task to treat distances and feedrates that you specify in G-code commands as being English units.

G71

Configures the task to treat distances and feedrates that you specify in G-code commands as being metric units.

G75

Configures the task to treat feedrates that you specify in G-code commands as being distance units per minute.

G76

Configures the task to treat feedrates that you specify in G-code commands as being distance units per second.

G82

Clears the program position offset on the specified axis. The program position will be restored to the current axis position.

G90

Configures the task to operate in the absolute target mode.

G91

Configures the task to operate in the incremental target mode.

G92

Sets the program position of the specified axes. All moves that specify an absolute target-position will be relative to the new program position.

G93

Configures the task for inverse time feedrate mode. Values specified to the F command are interpreted as the inverse amount of time that the controller should take to complete the distance specified in the move.

G94

Configures the task for normal feedrate mode. Values specified to the F command are interpreted as distance units per unit of time.

G95

Configures the task to interpret feedrates that you specify with the F command or the E command as units per spindle revolution.

G96

Configures the task to interpret the S command as the tangential speed, or the speed on the surface, of the spindle axis. You must specify surface speed and a radial axis to this command.

G97

Configures the task to interpret the S command in velocity units.

G98

Enables inverse dominance mode on the task.

G99

Disables inverse dominance mode on the task.

G100

Disables spindle shutdown mode on the task.

G101

Enables spindle shutdown mode on the task.

G108

Enables velocity blending mode on the task.

G109

Disables velocity blending mode on the task.

G114

Enables optional pause mode on the task.

G115

Disables optional pause mode on the task.

G118

Configures the center point coordinates that you specify to a coordinated arc motion command to be in absolute user units.

G120

Configures the task to disable the effects of manual feedrate override (MFO) and the feedhold state during asynchronous motion.

G121

Configures the task to enable the effects of manual feedrate override (MFO) and the feedhold state during asynchronous motion.

G143

Activates cutter offset compensation positive mode on the task.

G144

Activates cutter offset compensation negative mode on the task.

G149

Deactivates cutter offset compensation mode on the task.

G150

Disables part scaling mode on the task.

G151

Enables part scaling mode on the task.

G165

Configures the rate that the task uses to perform coordinated motion to accelerate dependent axes.

G166

Configures the rate that the task uses to perform coordinated motion to decelerate dependent axes.

G359

Sets the wait mode to wait the minimum amount of time between motion blocks.

G360

Sets the wait mode to wait for all motion to be done between motion blocks.

G361

Sets the wait mode to wait for all motion to be done and for all axes to be in position between motion blocks.

Supported M-codes

M-Code

Description

M0

Pauses the current task.

M1

Pauses the current task if the optional pause mode is active on the task, or does nothing if optional pause mode is not active.

M2

Stops the execution of the program on the current task.

M3

Starts motion in the clockwise direction on the spindle axis that is configured for the task. The command is complete after the spindle accelerates to the commanded speed.

M4

Starts motion in the counterclockwise direction on the spindle axis that is configured for the task. The command is complete after the spindle accelerates to the commanded speed.

M5

Causes the spindle axis that is configured for the task to decelerate to zero speed.

M30

Resets the execution of the AeroScript to the first executable line.

M47

Resets the execution of the AeroScript to the first executable line. Then it causes the controller to start execution of the program.

M48

Disables the use of manual feedrate override (MFO) controls.

M49

Enables the use of manual feedrate override (MFO) controls.

M50

Disables the use of manual spindle override (MSO) controls.

M51

Enables the use of manual spindle override (MSO) controls.

M103

Starts motion on the spindle axis that is configured for the task in the clockwise direction. The command does not wait for the spindle to accelerate to the commanded speed.

M104

Starts motion on the spindle axis that is configured for the task in the counterclockwise direction. The command does not wait for the spindle to accelerate to the commanded speed.

G-code Specification Rules

G-code and Exponential Notation

AeroScript has special rules when parsing G-code programs due to the existence of the E command in the G-code dialect, in addition to support for constant floating-point values that are specified with exponential notation, as well as the G-code dialect being whitespace-insensitive.

A floating-point value specified with exponential notation must be delimited on both its left and right sides in order to prevent conflicts with the E command in G-code programming. The following examples show how exponential notation and the E command are treated in various circumstances.

// E commands
E100E 100
 
// Exponential notation
$myVar
= 1e10
 
// Move with Y = 1, E command = 10

G1 Y1E10
 
// Move with Y = 1, E command = 10
G1 Y1 E10
 
// Move with Y = 1E10 (no E command)
G1 Y 1E10

 
// Move with Y = 1, E command = 10
G1 Y 1 E 10
 
// Exponential notation can be enforced by using delimiter characters
G1 Y(1E10)G1 Y=1E10

G-code and Hexadecimal Notation

In addition to the exceptions that were made for the E command and exponential notation, there are also exceptions when specifying hexadecimal literals in a G-code program.

A hexadecimal literal must be delimited on both its left and right sides in order to prevent conflicts with an axis called either X or x that is directly followed by an integer value in G-code. The following examples show how hexadecimal notation and G-code are treated in various circumstances.

// G-code
X10

 
// Hexadecimal notation
$myVar = 0x10
 
// Move with Y = 0, X = 10
G1 Y0X10

 
// Move with Y = 0, X = 10
G1 Y0 X10
 
// Move with Y = 0x10 (16, no move on X)
G1 Y 0X10
 
// Move with Y = 0, X = 10
G1 Y 0 X 10

 
// Hexadecimal notation can be enforced by using delimiter characters
G1 Y(0X10)
G1 Y=0X10

Related Topics 

G-Code Programming

G-Code Example Program

Tool Table Example Program