584,837 active members*
5,485 visitors online*
Register for free
Login
Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2005
    Posts
    24

    More free macros

    These are some macros I wrote. Use and modify however you like just be careful and toolpath them before running.
    I tried to put comments everywhere to help follow the flow.
    PI R ROUND

  2. #2
    Join Date
    Feb 2006
    Posts
    1792

    Re: More free macros

    I have copied one line from one of your macros

    "IF[#117GE#3]AND[#131EQ0]THENG91G01Y[#117/2]"

    It is not correct.

  3. #3
    Join Date
    Sep 2005
    Posts
    24

    Re: More free macros

    Thank you. I'll check that out.
    PI R ROUND

  4. #4
    Join Date
    Feb 2006
    Posts
    338

    Re: More free macros

    Quote Originally Posted by sinha_nsit View Post
    "IF[#117GE#3]AND[#131EQ0]THENG91G01Y[#117/2]"

    It is not correct.
    Use of 'AND' / 'OR' in an IF statement may be disabled by a parameter setting. Something like 'allowing logical statements to be used everywhere'
    Mazak machines do NOT allow IF THEN (only IF GOTO)
    I have only used IF THEN to assign macro values, so can't say about calling G-codes with it.
    With those possible exceptions the code looks fine.

  5. #5
    Join Date
    Feb 2006
    Posts
    1792

    Re: More free macros

    With IF THEN, NC statements are not allowed; only macro statements are allowed.
    And, outer bracket with the IF condition is needed.
    Referring to Fanuc.

  6. #6
    Join Date
    Feb 2006
    Posts
    1792

    Re: More free macros

    Copied from this book:

    The term “NC statement” has been used without formally defining
    it. It is a program block involving at least one NC address, such as G,
    M, F, S, T, X, Y, and Z, except codes for calling a macro program (such
    as G65, G66, etc.) On the other hand, a macro statement simply assigns
    a value to a variable (#i = <some value or an arithmetic expression>),
    or jumps to a specified block number (GOTO_ and IF_GOTO_), or
    uses a conditional statement (IF_THEN_, WHILE_DO_, and END_),
    or calls a macro program. To put it simply, a macro statement does not
    directly cause physical machine movement, whereas an NC statement
    directly controls the machine movement. An NC statement may or
    may not use macro variables/functions.

  7. #7
    Join Date
    Sep 2005
    Posts
    24

    Re: More free macros

    Here is an alternative version of the macro in question. I did away with the IF/THEN and NC statement on one line and broke it up on separate lines.I also found some redundant settings and deleted them. It ran through simulation ok but then again so did the other version.


    %
    O1000(MAIN)
    G65P8030X-5.Y1.Z0C.25F20.D.5I2.95J1.K5.
    M30


    O8030(RECTANGLE POCKET MACRO)
    (VIC MOORE 8/08/2017)
    (XYZ #24 #25 #26 ARE ABS START POSITION/LOWER LEFT CORNER)
    (CAN BE PLACED ANYWHERE ON X AND Y AND Z)
    (INCR. DEPTH WILL BE DIVIDED EQUALLY BY K #6)
    (PLUNGE FEED IS 1/4 OF CUT FEED)
    (RETURN TO START FEED IS DOUBLE CUT FEED)
    (FEED TO SURFACE IS DOUBLE THE CUT FEED)
    (CALL EX. G65P8030X-5.Y1.Z0C.25F20.D.5I2.5J3.26K5.)
    (*************************************)
    (C #3 IS CUTTER DIA)
    (F #9 IS FEED IN IPM OR IPR - SET G94/G95 BEFOREHAND)
    (D #7 IS INCR DEPTH OF POCKET)
    (I #4 IS LENGTH OF RECTANGLE FOR X)
    (J #5 IS LENGTH OF RECTANGLE FOR Y)
    (K #6 IS NUMBER OF ROUGH CUTS)
    (X #24 IS ABS LOWER LEFT CORNER OF POCKET)
    (Y #25 IS ABS LOWER LEFT CORNER OF POCKET)
    (Z #26 IS ABS PART SURFACE TO START CUT)

    (PRESETS)
    #3=ABS[#3] (C IS SET POSITIVE ONLY)
    #8=ABS[#8] (E IS SET POSITIVE ONLY)
    #9=ABS[#9] (F IS SET POSITIVE ONLY)
    #6=ABS[#6] (K IS SET POSITIVE ONLY)
    #6=FUP[#6] (K IS ROUNDED UP TO WHOLE #)
    #7=ABS[#7] (D IS SET POSITIVE ONLY)
    #7=-#7 (D IS NOW FORCED NEGATIVE)
    #100=ABS[#3/2] (CUTTER RADIUS)
    #101=[#3*.65] (65 PERCENT STEPOVER)
    #120=[#7/#6] (DEPTH OF CUT CALCULATION)

    (**** ERROR CHECKING *****)
    IF[#3EQ#0]THEN#3000=1(CUTTER C MISSING)
    IF[#4EQ#0]THEN#3000=1(X LENGTH -I- MISSING)
    IF[#5EQ#0]THEN#3000=1(Y LENGTH -J- MISSING)
    IF[#6EQ#0]THEN#3000=1(NUMBER/CUTS -K- MISSING)
    IF[#7EQ#0]THEN#3000=1(DEPTH -D- MISSING)
    IF[#9EQ#0]THEN#3000=1(FEED RATE -F- MISSING)
    IF[#3GEABS[#5]]OR[#3GEABS[#4]]THEN#3000=1(CUTTER IS TOO BIG)

    (**** CHECKING WHICH AXIS IS THE SHORTER ONE ***************)
    IF[#4GE#5]THEN#102=FUP[[[#5/2]-#100]/#101](IF Y IS SHORT SIDE CALC CUTS IN Y)
    (#102 IS NUMBER OF CUTS FOR SHORT Y SIDE)
    IF[#4GE#5]THEN#131=0 (SET TO ZERO IF Y IS SHORTSIDE)
    IF[#5GT#4]THEN#102=FUP[[[#4/2]-#100]/#101](IF X IS SHORT SIDE CALC CUTS IN X)(!!!)
    (#102 IS NUMBER OF CUTS FOR SHORT X SIDE)
    IF[#4LT#5]THEN#131=1 (SET TO 1 IF X IS SHORTSIDE)
    (************************************************* ********)

    (*** PRESETS ***)
    G90G0Z[#26+.1](CLEAR Z)
    X[#24+#100]Y[#25+#100] (RAPID TO START POINT + 1/2 CUTTER)
    G01Z#26F[#9*2] (FEED TO SURFACE Z)
    #110=0(SET LOOP COUNTER)
    #105=0 (STEPOVER INITIAL SETTING)
    (************************************************* ******)

    (*** MAIN LOOP 1 ***)
    #130=0 (LOOP COUNTER TO CALL CUTTING LOOP)
    WHILE[#130LT#6]DO1 (DO UNTIL NUMBER OF CUTS IS DONE)
    G90G01X[#24+#100]Y[#25+#100]F[#9*2] (GO TO START POSITION)
    G91G01Z#120F[#9/4] (FEED DOWN PRE-CALCULATED AMOUNT)

    (*** LAYER CUTTING LOOP 2 ***)
    WHILE[#110LT#102]DO2(#102 IS CALCULATED # OF CUTS BASED ON SHORT SIDE)
    #115=#5002 (GET CURRENT Y POSITION)
    G91X[[#4-#3]-#105]F#9(CUT LENGTH - CUTTER - STEPOVER)
    #118=#5001 (GET X FOR CENTER CUT AFTER LOOP)
    Y[[#5-#3]-#105](CUT WIDTH - CUTTER - STEPOVER)
    #116=#5002 (GET NEW Y POSITION)
    X-[[#4-#3]-#105](CUT LENGTH - CUTTER - STEPOVER)
    #119=#5001(GET NEW X AXIS)
    Y-[[#5-#3]-#105](CUT WIDTH - CUTTER - STEPOVER)
    #117=[#116-#115] (DIFFERENCE IN Y POSITIONS)
    #121=[#118-#119] (DIFFERENCE IN X POSITIONS)
    IF[#110EQ[#102-1]]GOTO10 (SKIP INWARD MOVE IF ON LAST CUT)
    X#101Y#101(SCOOT INWARD FOR NEXT CUT)
    N10 #110=[#110+1] (INDEX COUNTER BY ONE)
    #105=[#101*2](NOW THROW STEPOVER INTO CALC TILL DONE)
    IF[#110GE2]THEN#105=[#105*#110](ADD STEPOVER BASED ON LOOP COUNT)
    END2

    #105=0(RESET STEPOVER INITIAL SETTING FOR ANOTHER GO AROUND)
    #110=0(RESET LAYER LOOP COUNT FOR ANOTHER GO AROUND)
    IF[#117GE#3]AND[#131EQ0]GOTO20
    N20G91G01Y[#117/2] (IF ISLAND - CUT X MIDDLE)

    IF[#117GE#3]AND[#131EQ0]GOTO30
    GOTO35(SKIP OVER IF ABOVE EQUATION IF FALSE)
    N30G01G90X#118 (IF ISLAND - CUT X MIDDLE)

    N35IF[#121GE#3]AND[#131EQ1]GOTO40
    GOTO45(SKIP OVER IF ABOVE EQUATION IF FALSE)
    N40G91G01X-[#121/2] (IF ISLAND - CUT Y MIDDLE)

    N45IF[#121GE#3]AND[#131EQ1]GOTO50
    GOTO55(SKIP OVER IF ABOVE EQUATION IF FALSE)
    N50G01G90Y#116 (IF ISLAND - CUT Y MIDDLE)

    N55G90G01X[#24+#100]Y[#25+#100]F[#9*2] (BACK TO START POSITION)
    #130=[#130+1] (MAIN LOOP 1 INDEX +1)
    END1
    (END OF MAIN LOOP)
    G90G0Z[#26+1.]
    M99
    %
    PI R ROUND

  8. #8
    Join Date
    Feb 2006
    Posts
    1792

    Re: More free macros

    Third-party simulation software is generally not 100% perfect. NC Guide has to be used.

  9. #9
    Join Date
    Sep 2005
    Posts
    24

    Re: More free macros

    I recently needed to cut windows in a 4" tube x 1/4" thick with an end mill and as it wore, I would have to change depth in program to an unused portion of the mill. I decided to use the #3901 counter to see if it was odd or even to vary the depth after each run to get even wear all along the end mill.
    This is the original test program to prove concept, not the actual program I used.

    %
    O03013 (VARIABLE DEPTH BASED ON #3901 COUNTER)
    (HAAS VF1 VERIFIED TO WORK)
    (VIC MOORE 2/27/2018)
    (NOTE - M99 DOES NOT INCR #3901 ON OUR MACHINE)
    (2 DEPTHS BASED ON ODD OR EVEN COUNT)
    IF [ #3901 MOD 2 EQ 0 ] THEN #500= -0.1 (IF EVEN COUNT)
    IF [ #3901 MOD 2 NE 0 ] THEN #500= -0.2 (IF ODD COUNT)
    G28
    T1 M06
    G90 G00 G54 X3. Y0
    G43 Z5. H01 S500 M03
    G00 Z0
    G01 Z#500 F20.
    G04 P5000
    G00 Z2.
    G28
    M30
    %
    PI R ROUND

  10. #10
    Join Date
    Sep 2005
    Posts
    24

    Re: More free macros

    Regarding sinha_nsit:
    I still forgot to add outer brackets or delete inner brackets on the IF/AND lines. Have you edited to work on NC GUIDE?
    Thanks for the heads up.
    PI R ROUND

  11. #11
    Join Date
    Feb 2006
    Posts
    1792

    Re: More free macros

    I just talked about the usual syntax.

    G28 on Fanuc requires an argument.

  12. #12
    Join Date
    Sep 2005
    Posts
    24

    Re: More free macros

    Yes I am aware of that. The program you are talking about with the G28 is for a HAAS VF1. You can always edit to make FANUC friendly. That program was for example of using MOD.
    PI R ROUND

  13. #13
    Join Date
    Sep 2005
    Posts
    24

    Re: More free macros

    Here is a macro for engine turning/jeweling on a flat plate.I made it so almost everything is adjustable. I have simulated it and the concept works but may need editing for your machine.
    Attached Files Attached Files
    PI R ROUND

Similar Threads

  1. MACROS
    By gtrrpa in forum Mori Seiki lathes
    Replies: 4
    Last Post: 11-17-2011, 07:57 PM
  2. Free 3d Mechanical Cad Tool, Did anybody try the free 3D CAD too CoCreate is offerin
    By hansge31 in forum Mechanical Calculations/Engineering Design
    Replies: 1
    Last Post: 06-20-2007, 08:13 PM
  3. Free Doors--Free Cabinet Door Software
    By 1BigPig in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 1
    Last Post: 06-07-2007, 07:36 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
  •