No announcement yet.

Understanding G code and M code

  • Filter
  • Time
  • Show
Clear All
new posts

    Understanding G code and M code

    I'm hoping someone can help clear up some confusion for me?

    I understand that G code is generated by the slicing software and that certain code can be added to the slicer, ie footer and headers, however, within my printer configuration files that I browse to via the Duet web interface (I'm using the Duet V0.8.5) there are M and G codes there.

    Do the G codes belong there? (I originally copied and pasted the configuration a couple of years back now and it's worked reasonably well with a few "quirks") I have edited these settings a little to make improvements to my machine, but I'm now wondering if having these G codes written here as well as through the slicer is causing some confusion?

    From what I can establish, the G code is generated by the slicer for the job in hand and the M code is information the printer needs to move?

    Any enlightenment would be appreciated

    There is a listing what G and M codes do if you do a web search for 3d printer G codes there are also similar codes for CNC machines . The GM codes you see in your firmware are for things like homing the axes turning heater and steppers off when print is done these are not generated by slicer as such. I would not alter those directly let the settings you change adjust those. But it is good reading to find what different G and M codes do so you could correctly make changes in G code file if you wanted.


      G-code originated from the CNC machining industry. 3D printing adopted G-code but needed additional functionality beyond X, Y, Z and tool change control. M-code was introduced to handle these extensions without impacting G-code. Your printer will respond to both types of code during operation.

      Slicers have evolved to include some features that we once had to manually code into start and ending G-code. Cura can even perform a priming wipe at the start of the print if configured correctly.

      The advantage of manually crafting start and end G-code is that you can optimise your printer's start and finish actions to suit your personal needs. You can, for example, start heating the bed while the nozzle is travelling towards the bed at the start of the print to save some time or move the bed and nozzle to a position of your choice at completion of printing.

      You can determine what the slicer can do for you and, if convenient, remove any duplicated actions from your start and end G-code for efficiency purposes.


        Apologies for not replying sooner.
        Thank you both, I think I'm going to have a play and see what happens, you don't learn unless you make a few mistakes along the way.


        Sign Up


        To post a reply to this thread you must be a member. Registration is fast, simple and absolutely free. Please join our community today!