Image of spindle with G-code software
Image of Polaris Cartesian G-code

CNC G-Code Software Overview

G-code is the most widely used programing language in the world for programming CNC machine tools. It provides instructions to a motion controller by way of a programming file to move the toolpath of a CNC machine tool in three dimensions using lines, arcs and splines. A powerful extension to G-code software is the Paramacro language, which adds variable names, program flow control and a comprehensive list of math functions.

Polaris has been developing and refining its G-code language and computational engine since 1996. Many machine types are supported, including: mills, lathes, routers and waterjets, single-point diamond turning machines, precision laser machines, and robotic dispensing and welding machines. Polaris G-code has a wide breadth, it is complete in its offering, and it has been tested over decades.

3, 5 and 9-Axes G-code

Standard 9-Axis G-code is offered for controlling the XYZ-ABC-UVW motors of a machine tool. The XYZ commands move the three linear stage axes, the ABC commands move the three rotational axes, and the UVW commands move actuators that are parallel to the XY and Z axes. Usually XYZ represent the linear stage, the ABC axes represent the rotational gimbal and UVW represent fast, short stroke motors such as laser Galvo scanner motors.

Cartesian G-code™ is Polaris Motion’s new and novel G-code programming mode and it is now available when ordering a Polaris UniverseOne™ motion control system. G-code is specified in a Cartesian reference in the part coordinate system. The G-code software commands are specified with commands XYZ-PxPyPz, where XYZ are the 3D position of the tool tip and PxPyPz are the roll, pitch and yaw angles of the tool tip. Some advantages of Cartesian G-code include:

  • Simple tool path description
  • Greater choice of CAM solutions
  • Easier machine tool calibration
  • Easier to use serial and parallel robots in precision CNC applications
  • Tool center point control (TCP) is inherent

G-Code Commands

Polaris G-code uses EIA-RS274D as a basis. Fundamental Polaris G-code commands include G00 rapid traverse, G01 linear interpolation, G02/G03 clockwise and counter-clockwise circular interpolation, and G05 position-velocity-time (PVT) spline interpolation.

A sample of other G-code commands include plane selection, inch/mm programming modes, cutter compensation, tool-length compensation, work coordinate system selection, spindle control, and constant surface speed mode.

M-Code Commands

M-codes cover miscellaneous machine functions. Some Polaris M-codes include: spindle selection, coolant control, control of pulsed and continuous wave (CW) lasers, controls for infinite field of view (IFOV), laser wobble and laser optic lens calibration.

Executing G-Code Software

G-code programs may be executed in three ways: manual data input (MDI) mode, step mode, or continuous mode. In manual data input (MDI) mode, the user enters one G-code command at a time and watches the machine move. In step mode a program is executed one line at a time as the user issues steps. In continuous mode the G-code program runs from beginning to end without human intervention. Some limitations are imposed using the first two modes due to the continual stopping and starting of the motion axes.

G-Code Work Coordinate Systems

Multiple work coordinate systems are supported with Polaris G-code. Multiple identical parts can be made using the same G-code. Work coordinates can have linear or rotational offsets.

Tool Change, Tool Probing & Workpiece Probing

Polaris G-code supports the creation of custom tool change, tool probing and workpiece probing algorithms using the Polaris software programming API.

Feed-Rate Override

Feed-rate override enables real-time modification of the tool path speed based on an operator input such as a handwheel. Feed-rate override is available in the G-code programming API.

Wobble Control

Wobble is powerful feature that is executed using an M-code. It super-imposes a repeating, high-speed pattern onto a toolpath. It’s especially useful for laser cutting and welding applications. Four patterns are available including line, circle, figure eight and infinity. The wobble amplitude and frequency can be specified.

Precision Wobble Control

Cutter Compensation with G-Code

In creating a G-code file, the diameter of an end-mill may be specified in a CAM program. The G-code that results depends on that diameter. However, during actual machining operations, that particular tool diameter may not be available. Instead of re-running the CAM program again, the operator can specify an alternate tool diameter using the cutter compensation feature. As the tool wears an operator can specify a new diameter without re-running the CAM software.

Paramacro Programming

Paramacro programming is a full featured tool path programming language which overloads the G01 linear interpolation function. The Paramacro language has program flow control using IF, WHILE and GOSUB structures; and it has arithmetic and logical operators, and trigonometric functions. Using Paramacro programming, complex parts can be made using a compact program.

See our Technology in Action

Sign up for an interactive presentation by a Polaris expert!