Results 1 to 9 of 9

Thread: custom g or m codes with mach ???

  1. #1
    Gold Member dertsap's Avatar
    Join Date
    Oct 2005
    Location
    canada
    Posts
    3,880
    Downloads
    0
    Uploads
    0

    custom g or m codes with mach ???

    I've created a functioning custom macro to use for the rotary axis , this is something that I've used on professional machines with great success . I have a macro sub routine that calculates xyz g52 work shifts for any new angle positions based on calculations from the center of rotation to the actual xyz zero positions of the part at A zero, which is to say that I only need to pick up one single work shift from the A axis zero point and the machine calculates the rest for any given angle of rotation , so it gives me a g52 shift for xyz , anyhow it appears that with a few mods it will work well with mach .
    now to get to my question , is it possible in mach to create a custom g or m code , I'd rather edit in a simple g code than to add a sub routine call for every rotation , point is to minimize the amount of editing that i need to do to the program and to build the routine into mach rather than it always be at the bottom of the program
    this way my program will look like this before the rotation

    #1=45.(rotation variable)
    g555(*********custom g code with the calculations)
    g52x#2y#3z#4
    g0 a#1
    x***y***

    rather than it looking like this

    #1= 90.
    m98 P8989 (does the calculations in the sub routine which is at the bottom of the program)
    G52 X#2 Y#3 Z#4
    g0 a#1
    x***y***

    its always necessary to have the variables in the program header but it would be nice to hide the calculations in the custom g or m code




    .
    A poet knows no boundary yet he is bound to the boundaries of ones own mind !! ........
    http://microcarve.microcarve.biz/


  2. #2
    hub
    hub is offline
    Registered
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    435
    Downloads
    0
    Uploads
    0
    I don't know for sure, but I would say no. It's not possible to add a custom g or m code. I think they are hard coded into the software. 99.99%sure..
    http://www.cnczone.com/forums/cnc_wood_router_project_log/125895-my_diy_cnc_cnc2011_%3B.html


  3. #3
    Gold Member dertsap's Avatar
    Join Date
    Oct 2005
    Location
    canada
    Posts
    3,880
    Downloads
    0
    Uploads
    0
    i kinda figured so , I cant find any info on it , so if its not possible then its a bit of an inconvenience but not the end of the world , it would be a nice option to have
    A poet knows no boundary yet he is bound to the boundaries of ones own mind !! ........
    http://microcarve.microcarve.biz/


  4. #4
    Community Moderator Al_The_Man's Avatar
    Join Date
    Dec 2003
    Location
    Canada
    Posts
    18,965
    Downloads
    0
    Uploads
    0
    Mach describes 'Customizable M codes through VB script'.
    M codes are usually for external control (PLC like) feature.
    But I get the impression that Mach does not use a FIN signal feature, IOW wait until a M code complete signal if needed.
    I have not done that much with Mach so I could be wrong.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design (Skype Avail).

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


  • #5
    Gold Member dertsap's Avatar
    Join Date
    Oct 2005
    Location
    canada
    Posts
    3,880
    Downloads
    0
    Uploads
    0
    i agree that m codes are normally used for external control but hope that i can make something work , this tends to be more for my twisted curiosity and convenience than necessity .
    I've played a bit in the macro folder for mach 3 and it seems that i can take the code from the m3 macro , and create a new m code m9797 which runs the same code as the m3 and it works , so hopefully with a bit more research I'll figure out how to (if i can) do my calculations within the m code , then have the calculated variables input into the local variables in mach .
    its a nice day , I'm going fishing so it will go on the back burner
    A poet knows no boundary yet he is bound to the boundaries of ones own mind !! ........
    http://microcarve.microcarve.biz/


  • #6
    Gold Member dertsap's Avatar
    Join Date
    Oct 2005
    Location
    canada
    Posts
    3,880
    Downloads
    0
    Uploads
    0
    got it , its simply a matter of putting SetVar(1, 9.) into the new M9797.M1S file that i created in the macro folder
    1 is the variable to modify and 9 is the value to set
    so now as a test with an m9797 before g0g90 x#1 , then x will travel 9"
    so with it being able to do that then what i want to do will be pretty much a breeze .
    Last edited by dertsap; 09-13-2011 at 01:45 AM.
    A poet knows no boundary yet he is bound to the boundaries of ones own mind !! ........
    http://microcarve.microcarve.biz/


  • #7
    Gold Member dertsap's Avatar
    Join Date
    Oct 2005
    Location
    canada
    Posts
    3,880
    Downloads
    0
    Uploads
    0
    ok so the basics of this macro is coming together , the calculations are done but need to be modified some for mach to understand what i'm telling it to do , I'm trying to minimize the amount of code that i need to edit into my programs so the g52 shift will be within the custom m code , this way I'll only need to edit in the m code after every rotation , A axis rotations will no longer need to be a variable number in the program as i had it before because i can get the dro value within the macro after the A axis rotation (if if any of this makes sense to anyone) , now for the trouble that I'm having in order to complete this task , i need to edit the m1 and m30 so that i can cancel the g52 shift by adding g52x0y0z0 .
    where is the coding for the m30 and m1 , these m codes are not in the macro folder and i can't seem to find them anywhere ? is it possible to modify these two m codes ?

    so far the custom header will look similar to this


    %
    O8000
    #1= 1.025 (Y DEV from center of rotation at A0)
    #2= -0.529 (ZDEV from center of rotation at A0)
    #3= 0 (ANGLE )
    #4= -2.525 (SHIFT FROM TOOLPROBE T0 part Z0 AT A0)

    g0g90 x blah y whatever A0
    m9797
    g43 blah
    blah
    a90.
    m9797(custom m code after rotation which trigs g52 shift based from g54 position and all variables)
    g0x@$y^@
    ;
    ;
    ;
    .
    Last edited by dertsap; 11-13-2011 at 02:41 AM.
    A poet knows no boundary yet he is bound to the boundaries of ones own mind !! ........
    http://microcarve.microcarve.biz/


  • #8
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Twp, MI....USA
    Posts
    22,306
    Downloads
    0
    Uploads
    0
    No, those two are hard coded.

    What I'd do is make two custom M codes and have them tag along with M1 and M30, say M901 and M930.

    Have your post put them in your code something like this.

    M1
    M901
    ....
    ....
    ....
    ....
    M930
    M30

    So, after your M1 stop, the M901 can do what you want to do with M1.

    Then at the end of your code, the M930 can do what you need before the M30 rewinds to the beginning.

    I missed this thread earlier. let me know if you get stuck, and I'll try to help if I can.
    Gerry

    Mach3 2010 Screenset
    http://home.comcast.net/~cncwoodworker/2010.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)


  • #9
    Gold Member dertsap's Avatar
    Join Date
    Oct 2005
    Location
    canada
    Posts
    3,880
    Downloads
    0
    Uploads
    0
    thanks Ger
    That's what I sort of figured I'd have to do , what I think I'll do is create a couple m codes to replace the m1 and m30 ,
    this way a couple of simple program edits will suffice and I should be able to modify my post to do it for me .
    So far I've got all the basics down and will finish it at some point soon , right now much of my focus is on completing my mill conversion , and today getting some fish smoked
    A poet knows no boundary yet he is bound to the boundaries of ones own mind !! ........
    http://microcarve.microcarve.biz/


  • Similar Threads

    1. Dyna 4M macros and custom G codes
      By dave design in forum Dyna Mechtronics
      Replies: 1
      Last Post: 10-28-2010, 09:46 PM
    2. Replies: 2
      Last Post: 04-06-2010, 09:46 PM
    3. Replies: 5
      Last Post: 03-22-2010, 10:13 AM
    4. help using custom M codes and M-FIN on haas
      By josh591 in forum Haas Mills
      Replies: 6
      Last Post: 09-30-2008, 01:14 PM
    5. Custom G codes in Custom G codes
      By stevo1 in forum Fanuc
      Replies: 7
      Last Post: 09-09-2008, 03:32 PM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.