How to read a G-Code File

How to read a G-Code File

Things go wrong all the time.  It is the nature of this industry that parts and tools will be broken.  One of the most fundamental skills required, is being able to read a G-Code file and make sure your machine is being the correct instructions.

 

Format of a file

Header

The start of the file features a heap of useful information.

  1. What version of software you are using
  2. What Post Processor
  3. Time and Date
  4. Document Name/description
  5. Which Setup you are using; and,

It's followed by a ranges table.  This gives you a high level indication of how big your part is.  

It is important to check the Z height here, to validate that you have setup your part correctly and you are not going crash your tooling into the part, or worse, into your machine.

The Tools Table lets you know which tool is used in the program, its unique ID, description, and some geometry. 

It is always best practice to make sure your tool numbers line up with what is installed in Gladius.

Content

The central section of the code is where all the tool paths are listed.   The most important codes to know, are:

  • M5 - Spindle Stop
  • M6 - Spindle Tool Change, Tool number must be defined first.  i.e T1 M6
  • M3 - Spindle On, Clockwise,  Spindle speed must be defined afterwards.  i.e M3 S5000
  • M4 - Spindle On, Counter Clockwise
  • G54 - Work Coordinate System 1.  We can go from G54.0 to G59.9 for individual work setups.
  • G0 - Traverse Move (Linear)
  • G1 - Cutting Move (Linear)
  • G2 - Cutting Move (Arc, Clockwise)
  • G3 - Cutting Move (Arc, Counter Clockwise)
  • G90 - Absolute Movement Mode
  • G91 - Relative Movement Mode

Movements are given in a logical string of commands.

[type of movement] [which axis] [position to move to] [feed rate to move at]

For example:

G90 ; absolute positioning

G0 X10 Y10 Z-10 F5000 ; Linear Traverse movement, Go to Co-ordinates X10 Y10 Z-10, and move at a rate of 5000mm/min

 

Footer

The footer holds the code for finishing off the program.

  • M400 - pauses communication to the machine to clear the stack of instructions held the buffer.
  • M5 - Stop Spindle

To find more information on what G-Codes are supported with Swordfish, have a look at the Marlin Firmware Supported GCode list.

https://marlinfw.org/meta/gcode/