584,866 active members*
5,142 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > G-Code Programing > Can i add G Code for some custom features
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2021
    Posts
    24

    Can i add G Code for some custom features

    I'm learning G Code and I was able to setup my first CNC structure and move axis, its basically not a CNC machine but I'm taking advantage of it and building a machine with robotic movements.

    I have some Relays, and MOSFETs on my Arduino (or could be Arduino Mega) board is there some way that through G Code commands I can turn on/off some of them? or read switch state? or do some action in response to a trigger?

    I know, I have some options like using resources for spindle, coolant etc.

    But I have greater hardware needs to turn on/off and get input like switches is there some options something like custom G Code or some extra of additional commands those can be used for different scenarios like input/output.

  2. #2
    Join Date
    Dec 2013
    Posts
    5717

    Re: Can i add G Code for some custom features

    Coolant On/Off is normally done with a M7 (On) and M9 (Off). There are many other M codes for these types of functions.

    G code https://en.wikipedia.org/wiki/G-code
    Jim Dawson
    Sandy, Oregon, USA

  3. #3
    Join Date
    Mar 2021
    Posts
    24

    Re: Can i add G Code for some custom features

    Thanks, but my question is how can i run other than those existing commands, like custom commands (other than spindle, coolant)

  4. #4
    Join Date
    Nov 2013
    Posts
    4282

    Re: Can i add G Code for some custom features

    Hi,

    how can i run other than those existing commands, like custom commands (other than spindle, coolant)
    I don't think you can. Gcodes are defined and conform, fairly closely, to a standard. Most CNC software programs allow you to write your own macros, Mnnn,Mxxx, etc.
    A macro can be called from an ordinary Gcode job by calling its name, M104, for instance.

    Whether GRBL has the ability to accept custom Mcodes I don't know, but Mach4 (and Mach3 if you want to go back in time) certainly do allow custom Mcodes and provide
    the software language and constructs to do it.

    Craig

  5. #5
    Join Date
    Dec 2003
    Posts
    24216

    Re: Can i add G Code for some custom features

    Quote Originally Posted by sairfan1 View Post

    But I have greater hardware needs to turn on/off and get input like switches is there some options something like custom G Code or some extra of additional commands those can be used for different scenarios like input/output.
    The G codes are usually the responsibility of the motion controller, and are generally specific to the machine, the general machine (M) functions are done with the customisable controller, specific for the purpose.
    It depends alot what controller you have in mind as to how they would be implemented.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  6. #6
    Join Date
    Mar 2021
    Posts
    24

    Re: Can i add G Code for some custom features

    As currently I'm choosing hardware I have no issue to select some hardware for it, I already have Arduino Mega and Uno for test
    I'm using GBRL but i can also use Marlin and also thinking to check Smoothie for this.

    But before buying those things i was to be sure if they will work good

  7. #7
    Join Date
    Nov 2013
    Posts
    4282

    Re: Can i add G Code for some custom features

    Hi,
    can you write your own macros in GRBL or Smoothie dialects? If the software does not accommodate custom Mcodes then
    it hardly matters whether the hardware would work....if you cant craft your own Mcodes.

    Craig

Similar Threads

  1. DIY ATC add on for 6040 or custom made??
    By WoodLover in forum DIY CNC Router Table Machines
    Replies: 2
    Last Post: 09-06-2020, 01:27 PM
  2. Replies: 14
    Last Post: 06-14-2016, 03:25 PM
  3. How do we add a torch on off code
    By mwpeters49 in forum SheetCam
    Replies: 0
    Last Post: 10-07-2011, 12:41 AM
  4. add comments in G code?
    By webcruiser8 in forum G-Code Programing
    Replies: 4
    Last Post: 10-03-2006, 07:07 PM
  5. How to add comments to G-code
    By Xterrian in forum G-Code Programing
    Replies: 2
    Last Post: 10-15-2005, 07:46 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •