587,997 active members*
1,898 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > G-Code Programing > New to variables need help with this one.
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Posts
    8

    New to variables need help with this one.

    Hi I am trying to create a g code program with variables. I am very new to this and wanted to try to create a custom drill program. I'm sure it is wrong but wanted to post it here so people could see and help me fix it. I didn't include a G65 macro call but just variable assignments and an attempt at a loop. I'm trying to drill .5 deep at a certain speed/feed, remain in hole (dwell), then continue drilling hole hole at another speed/feed. I want to be able to do this to multiple holes like a canned cycle. Here's my attempted code...**The G91 X1 is to move 1 inch to next hole location**


    %
    O0001(HOLE DRILL LOOP)
    #1=-.5
    #2=-1.0
    #3=1000
    #4=2000
    #5=.25

    G20
    G0 G17 G40 G49 G80 G90
    T1 M6
    G0 G90 G54 X0. Y0. S1000 M3
    G43 H01 S#3 M8
    G1 Z#1 F3 G04 P.05
    G1 Z#2 S#4 F4
    G1 Z#5 F30
    G91 X1
    G90
    WHILE[Z EQ.25]DO1
    G1 Z#1 F3 P1.5
    G1 Z#2 S#4 F4
    G1 Z#5 F30
    G91 X1
    G90
    END1

  2. #2
    Join Date
    Aug 2009
    Posts
    684
    G43 H.25 is the first thing that jumps out at me. The Hn should refer to the table position of a tool length offset stored in your tool offset table, eg H1 for tool 1

    To use this cycle in a modal fashion would require calling it with g66 along with the relevant address codes and arguments for each variable. The program would then be recalled at each subsequent position.

  3. #3
    Join Date
    Mar 2009
    Posts
    8
    Quote Originally Posted by christinandavid View Post
    G43 H.25 is the first thing that jumps out at me. The Hn should refer to the table position of a tool length offset stored in your tool offset table, eg H1 for tool 1

    To use this cycle in a modal fashion would require calling it with g66 along with the relevant address codes and arguments for each variable. The program would then be recalled at each subsequent position.
    Ok, I have a book so I can assign the right variables with arguments. This is very helpful. I fixed the H value. Now I see what the G66 modal means. Thanks

  4. #4
    Join Date
    Aug 2009
    Posts
    684

    Cool

    Not sure what your while loop is for but you need to replace z eq.25 with a valid macro statement. Ie z must be replaced with a macro/system variable.

    DP

  5. #5
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by avirostick View Post
    Hi I am trying to create a g code program with variables. I am very new to this and wanted to try to create a custom drill program. I'm sure it is wrong but wanted to post it here so people could see and help me fix it. I didn't include a G65 macro call but just variable assignments and an attempt at a loop. I'm trying to drill .5 deep at a certain speed/feed, remain in hole (dwell), then continue drilling hole hole at another speed/feed. I want to be able to do this to multiple holes like a canned cycle. Here's my attempted code...**The G91 X1 is to move 1 inch to next hole location**


    %
    O0001(HOLE DRILL LOOP)
    #1=-.5
    #2=-1.0
    #3=1000
    #4=2000
    #5=.25

    G20
    G0 G17 G40 G49 G80 G90
    T1 M6
    G0 G90 G54 X0. Y0. S1000 M3
    G43 H01 S#3 M8
    G1 Z#1 F3 G04 P.05
    G1 Z#2 S#4 F4
    G1 Z#5 F30
    G91 X1
    G90
    WHILE[Z EQ.25]DO1
    G1 Z#1 F3 P1.5
    G1 Z#2 S#4 F4
    G1 Z#5 F30
    G91 X1
    G90
    END1
    As David stated, the Z in the WHILE block has to be a valid Macro variable, but further to this, the logic must be such that the variable can change so as to control the LOOP. Without this logic, the LOOP becomes endless without escape.

    As your code includes an incremental X move, you would probably want to control the number of times the control moves the tool to a new X position and executed the drill in code. The way in which you have constructed your Macro Program is not the way I, and I'm sure David, would have done so, but to give you an idea of how to control the LOOP, I'll use your code in the example.

    #6 = 1 (INITIALIZE A COUNTER OUTSIDE OF THE LOOP)
    #7 = 6 (SET THE NUMBER OF ITERATION OF THE LOOP)

    WHILE[#6 LE #7]DO1
    G1 Z#1 F3 P1.5
    G1 Z#2 S#4 F4
    G1 Z#5 F30
    G91 X1
    #6 = #6 + 1 (INCREMENT THE COUNTER BY 1)
    G90
    END1

    When #6 takes on the value 7 in the above example, control will exit from the LOOP.

    Regards,

    Bill

Similar Threads

  1. Global variables
    By Normsthename in forum Solidworks
    Replies: 3
    Last Post: 03-18-2011, 07:21 PM
  2. System Variables???
    By springer82 in forum NCPlot G-Code editor / backplotter
    Replies: 3
    Last Post: 03-12-2011, 07:39 PM
  3. Variables
    By kz1000 in forum Mach Wizards, Macros, & Addons
    Replies: 1
    Last Post: 12-18-2009, 12:04 AM
  4. looking for system variables
    By chunkymonkey in forum Mori Seiki lathes
    Replies: 3
    Last Post: 10-26-2009, 09:27 PM
  5. Variables 500 to 531
    By viorel26 in forum Fanuc
    Replies: 0
    Last Post: 09-30-2007, 08:30 AM

Posting Permissions

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