586,102 active members*
2,620 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Fanuc > Toolchange macro to make multiple parts
Page 1 of 2 12
Results 1 to 20 of 27
  1. #1
    Join Date
    Feb 2010
    Posts
    69

    Toolchange macro to make multiple parts

    There is someone interested by a toolchange macro i created that loop each tool for mutiple parts. IE you set one variable at the program start for the part quantity for example #800=4 and the machine take the tool 1 and make all the operations on G54,G55,G56,G57 and also if you want G54 P1, G54 P2, etc. and then take the tool 2 and do all operations in reverse G57,G56,G55,G54...really usefull when you want to choose part QTY right on the floor.It also support the G5 P10000 (ai Nano HPCC) function that doesn't support macro calculation when activated. If interested reply and i will post all is needed to do it!

  2. #2
    Join Date
    Aug 2011
    Posts
    2517
    there is always interest in macros that do useful things. please post it here if you want to.

  3. #3
    Join Date
    Nov 2006
    Posts
    418
    I'd like to check it out as well!

  4. #4
    Join Date
    Feb 2010
    Posts
    69

    toolchange macro

    I finally posted it

    there's the macro

    O9000(TOOLCHANGE*MACRO)
    IF[#4113EQ98]THEN#10=1
    IF[#4EQ1]GOTO13(GO*BACK*TO*CURRENT*TC)
    IF[#5NE#0]GOTO6(WPC*UP)
    IF[#6NE#0]GOTO9(WPC*DOWN)
    IF[#10EQ1]GOTO14(SEND*TO*END*OF*PROGRAM)
    #3=#4114(SEQUENCE*N*FLAG)
    #11=#149/100
    #11=FIX[#11](CALC*TOOL)
    #12=[#149-[#11*100]](CALC*PRELOAD)
    IF[#11EQ0]THEN#11=#12(MANUAL*TC)
    IF[#11EQ#12]THEN#12=#0
    IF[#11EQ30]THEN#11=0(PROBE=T30*FOR*PRELOAD)
    IF[#11EQ#702]GOTO5(SAME*TOOL*SKIP)
    IF[#703EQ0]GOTO2(SKIP*ROTARY*PROTECT*IF*DISABLED)
    IF[#1EQ#0]GOTO1(MANUAL*TC*PROTECTION*WITH*ROTARY)
    IF[#7741EQ0]GOTO15(ALARM*IF*FACEPLATE*PROBING*NOT*DONE)
    IF[#5021+[#1-#5041]GT#7741]GOTO2(SKIP*IF*TC*IS*SAFE)
    IF[#5021+[#1-#5041]LE#7741]THEN#1=#5041-[#5021-#7741](ROTARY*TC*PROTECTION)
    G5P0
    M9
    G91G28Z0M19
    G90X#1
    GOTO2
    N1
    IF[#5021LE#7741]THEN#1=#5041-[#5021-#7741]
    G5P0
    M9
    G91G28Z0M19
    G90X#1
    N2
    IF[#3GE2]GOTO3
    IF[#4014NE54.1]THEN#801=#4014(SET*FIRST*WPC*G54-G59)
    IF[#4014EQ54.1]THEN#801=#4130(SET*FIRST*WPC*G54*P1-P48)
    N3
    IF[#5021+[#1-#5041]LE0]THEN#1=#0(X-*OT*CHECK)
    IF[#5021+[#1-#5041]GE60.7]THEN#1=#0(X+*OT*CHECK)
    IF[#5022+[#2-#5042]LE-30.]THEN#2=#0(Y-*OT*CHECK)
    IF[#5022+[#2-#5042]GE0]THEN#2=#0(Y+*OT*CHECK)
    #700=#4001(MOVE*TYPE*FLAG)
    #701=#4003(ABS*INC*FLAG)
    M46
    IF[#4120NE0]THENGOTO4(PROBE*SPINDLE*LOCK)
    S0M47
    N4
    G5P0
    M9
    G91G28Z0T#11M19
    G90X#1Y#2M6
    #702=#4120
    T#12
    #1=#0
    #2=#0
    N5
    G#700
    G#701N#3
    #1=#0
    #2=#0
    M1(OPTIONAL*STOP)
    (SET*WPC*MULTIPART*SECTION)
    IF[#800LE1]GOTO12(SKIP*SECTION*IF*ONE*PART)
    #7=#3/2(CHECK*IF*TC*NWORD*IS*ODD*OR*EVEN)
    #8=FIX[#7]
    #9=FUP[#7]
    IF[#8EQ#9]GOTO9(SEND*TO*WPC*DOWN*IF*ODD)
    N6(WPC*UP)
    #4=1
    IF[#5NE#0]THEN#5=#5+1
    IF[#5EQ#0]THEN#5=#801
    IF[#5LE48]GOTO7
    G#5
    GOTO8
    N7
    G54P#5
    N8
    IF[#5EQ[[#800-1]+#801]]THEN#5=#0
    IF[#5EQ#0]THEN#4=#0
    GOTO12
    N9(WPC*DOWN)
    #4=1
    IF[#6NE#0]THEN#6=#6-1
    IF[#6EQ#0]THEN#6=[[#800+#801]-1]
    IF[#6LE48]GOTO10
    G#6
    GOTO11
    N10
    G54P#6
    N11
    IF[#6EQ#801]THEN#6=#0
    IF[#6EQ#0]THEN#4=#0
    N12(RETURN*TO*PROGRAM)
    M99
    N13(GO*CURRENT*TC)
    IF[#800LE1]GOTO14
    M56
    #4=#0
    M99P#3
    N14(SEND*TO*END*OF*PROGRAM)
    #3=#3+1
    #10=#0
    #800=#0
    #801=#0
    M99P#3
    N15
    #3000=1(PROBE*ROTARY*FACEPLATE)
    M99
    (#1=TC*X*RAPID)
    (#2=TC*Y*RAPID)
    (#3=CURRENT*TOOL*NWORD)
    (#4=RETURN*TO*CURRENT*TC*FLAG)
    (#5=CURRENT*UP*WPC)
    (#6=CURRENT*DOWN*WPC)
    (#7=CURRENT*TOOL*SPLIT*TO*ROUND)
    (#8=ROUND*DOWN)
    (#9=ROUND*UP)
    (#10=END*OF*PROGRAM*FLAG)
    (#11=TWORD)
    (#12=CURRENT*PRELOAD)
    (#700=MOVE*TYPE*FLAG)
    (#701=ABS/INC*FLAG)
    (#702=CURRENT*TOOL)
    (#800=PART*QTY)
    (#801=FIRST*WPC)




    there's a sample program
    %
    O6001 (18-19)
    #800=1 (PART QUANTITY)
    G17 G20 G40 G54 G90 G98
    #1=-2.875
    #2=-1.25
    N1 T0610 (ENDMILL 3/8" CARBIDE 2FL.)
    M3 S10000
    G5 P10000
    G0 X-2.875 Y-1.25 M8
    G43 H6 Z-.175
    G1 Y.25 F75.
    G0 Z.5
    X2.875
    Z-.175
    G1 Y-1.25
    G0 Z.5
    X2.2813 Y-.5
    Z.1
    G1 Z-.275 F40.
    X2.2822
    G3 I-.001
    G1 X2.2813
    G0 Z.5
    X-2.2813
    Z.1
    G1 Z-.275
    X-2.2803
    G3 I-.001
    G1 X-2.2813
    G0 Z.5
    G5 P0
    #1=0
    #2=-.625
    N2 T1000 (DRILL 5/32")
    M3 S4890
    G0 X0 Y-.625 M8
    G43 H10 Z.5
    G81 X0 Y-.625 R.1 Z-.2719 F29.3
    G80
    M98 P9000
    N3 M9
    G53 X30. Y0 Z0 M19
    M30
    %

  5. #5
    Join Date
    Feb 2007
    Posts
    314
    I was thinking about something like that and i recently wrote my own. It works great for short program but with a 200 block program,that is not very long, the last tool takes almost 5 sec to loop. I have also written a macro that loop a defined number of program on a defined number of work offset. Search for a program is much more faster than search for a block number. But you have to separate each tool on a single prog.

    If any interest to see that, let me know

  6. #6
    Join Date
    Jul 2011
    Posts
    21
    I need to put the tool in the same packet from which was take it, for example if I take the T01 from packet # 1 finished work how can I write the program so that the tool T01 back to packet # 1

  7. #7
    Join Date
    Feb 2007
    Posts
    314
    I assume that you have a random tool changer. Why do you want to return the tool in a specific pocket? You can write a macro to track which tool is in a pocket and a reorder macro to return each tool in its initial pocket at the end of the program. But in involve a lot of useless tool change. Maybe if you explain what you really want to do and why you want to do this, with some details on your tool changer, we could find an efficient solution.

  8. #8
    Join Date
    Jul 2011
    Posts
    21
    Quote Originally Posted by samu View Post
    I assume that you have a random tool changer. Why do you want to return the tool in a specific pocket? You can write a macro to track which tool is in a pocket and a reorder macro to return each tool in its initial pocket at the end of the program. But in involve a lot of useless tool change. Maybe if you explain what you really want to do and why you want to do this, with some details on your tool changer, we could find an efficient solution.
    I need put back the tools to the same packet because the diameter of the tool is big.
    When the program is running the tools are put in any packet back so when tools of large diameter come together it's lockup each other and how to prevent this from happening is keeping them always in the same packete

  9. #9
    Join Date
    Apr 2012
    Posts
    43

    Re: Toolchange macro to make multiple parts

    You should be able to flag the tool as large or big or heavy in the offset page.

    Read your manual to be sure

    Sent from my SAMSUNG-SGH-I747 using Tapatalk 2

  10. #10
    Join Date
    Feb 2007
    Posts
    314
    You should be able to flag the tool as large or big or heavy in the offset page.

    Read your manual to be sure
    If you can do that go this way.

    Another way is to call always the same tool before the ''real tool change''.
    let a pocket empty, suppose it is T20=empty

    O1234
    G17 G40 ...
    T20 M6 (spindle is empty)
    T1 M6 (first tool in spindle pocket 1 empty)
    X... Y... M3 s....
    T20 M6 (spindle empty first tool back in pocket 1)
    T2 M6 (second tool in spindle pocket 2 empty)
    X... Y...
    T20 M6 (spindle empty second tool back in pocket 2)
    T3 M6 (third tool in spindle, pocket 3 empty)
    etc. etc. ....

    Even if T20 is not empty, it works.

  11. #11
    Join Date
    Aug 2011
    Posts
    92
    Has anyone tried this macro? Results? Sounds like it could be pretty useful!

  12. #12
    Join Date
    Feb 2007
    Posts
    314
    Quote Originally Posted by blkaplan View Post
    Has anyone tried this macro? Results? Sounds like it could be pretty useful!
    Like i said, I tried something similar but with a 10 tool 1000 block program, it is not very fast because when you jump out of the macro, the control have to search from the beginning of the main program for the block you want to loop. The farther the block is, the longer is search time. Maybe with a recent control it doesn't affect so much but with my 0M-D, just for about 180 blocks, it takes about five second!!! The solution is to separate each tool in a sub and search for the program number of this tool which is much more faster than search for a block number. Here is the macro (tested, i use it on a regular basis)

    ************************************************** ****
    * ALLOW TO LOOP MANY PROG ON MANY WORK OFFSET *
    * FORMAT: G65 A... B... C... D...F... P9201 *
    * A=FIRST WORK OFFSET(G54, G55, G56 ECT) *
    * B=QUANTITY OF WORK OFFSET *
    * C=FIRST PROG NUMBER TO LOOP *
    * D=LAST PROG NUMBER TO LOOP *
    * F=SET TO 1 TO BEGGIN BY THE LAST WORK OFFSET *
    ************************************************** ****
    %
    O9201
    #11=#7-#3 (QUANTITY OF PROGRAM TO LOOP)
    #12=#3 (WORKING COPY OF THE FIRST PROG)
    #13=0 (PROGRAM COUNTER)
    N10DO1
    #10=0 (LOOP COUNTER)
    IF[#9NE1]GOTO11 (IF YOU DON'T WANT TO BEGIN BY THE LAST WORK OFFSET JUMP TO)
    #1=#1+#2-1 (SET LAST WORK OFFSET)
    GOTO16
    N11DO2
    G#1 (SET CURRENT WORK OFFSET)
    M98P#12 (CALL CURRENT PROGRAM)
    #10=#10+1 (INCREMENT LOOP COUNTER)
    IF[#10EQ#2]GOTO15 (IF CURRENT PROG HAS BEEN RUN ON ALL WORK OFFSET JUMP TO)
    #1=#1+1 (INCREMENT WORK OFFSET)
    END2
    N15#13=#13+1 (INCREMENT PROG COUNTER)
    IF[#13GT#11]GOTO18 (IF ALL PROG HAVE BEEN RUN JUMP TO)
    #10=0 (RESET LOOP COUNTER)
    #12=#12+1 (INCREMENT PROG NUMBER)
    N16DO2
    #9=0 (CLEAR THE BEGIN BY THE LAST OFFSET FLAG)
    G#1 (SET CURRENT WORK OFFSET)
    M98P#12 (CALL CURRENT PROG)
    #10=#10+1 (INCREMENT LOOP COUNTER)
    IF[#10EQ#2]GOTO17 (IF CURRENT PROG HAS BEEN RUN ON ALL WORK OFFSET JUMP TO)
    #1=#1-1 (DECREMENT WORK OFFSET)
    END2
    N17#13=#13+1 (INCREMENT PROG COUNTER)
    IF[#13GT#11]GOTO18 (IF ALL PROG HAVE BEEN RUN JUMP TO)
    #12=#12+1 (INCREMENT PROG NUMBER)
    END1
    N18M99
    %

  13. #13
    Join Date
    Aug 2011
    Posts
    92
    Samu,

    With this macro, how should each program be?

    Should it start like a normal stand alone program?

    for example

    G00 G17 G20 G40 G80 G90
    G91 G28 Z0.
    / T12
    / M06
    G00 G17 G90 G54 X-.1446 Y1.7821 S7000 M03
    ..
    ..
    ..

    M09
    M05
    G91 G28 Z0.
    G28 Y0.
    G90
    M30
    %

    and then be complete for that tool?

    If so, wouldn't I get an error when it runs the second time at the next work offset for the tool being called to the spindle being already loaded?

    Thanks

  14. #14
    Join Date
    Jul 2011
    Posts
    21
    Hey Samu thanks it work great I'm sorry so late

  15. #15
    Join Date
    Feb 2007
    Posts
    314
    Quote Originally Posted by blkaplan View Post
    Samu,

    With this macro, how should each program be?

    Should it start like a normal stand alone program?

    for example

    G00 G17 G20 G40 G80 G90
    G91 G28 Z0.
    / T12
    / M06
    G00 G17 G90 G54 X-.1446 Y1.7821 S7000 M03
    ..
    ..
    ..

    M09
    M05
    G91 G28 Z0.
    G28 Y0.
    G90
    M30
    %

    and then be complete for that tool?

    If so, wouldn't I get an error when it runs the second time at the next work offset for the tool being called to the spindle being already loaded?

    Thanks
    %
    O1234
    G0 G17 G40 G49 G80 (AND ALL PREPARATORY CODE YOU WANT)
    G91 G28 Z0
    G65 A54. B4. C1235. D1238. P9201
    G91 G28 Z0 M9
    G28 Y0
    M30

    O1235
    M6 T1
    G0 G90 X.. Y... M3 S...
    G43 H1 Z... M8
    X... Y...
    X... Y...
    .....
    .....
    G0 Z SAFE HEIGHT TO GO TO NEXT WORK OFFSET
    M99

    O1236
    M6 T2
    G0 G90 X.. Y... M3 S...
    G43 H2 Z... M8
    X... Y...
    X... Y...
    .....
    .....
    G0 Z SAFE HEIGHT TO GO TO NEXT WORK OFFSET
    M99

    O1237
    M6 T3
    G0 G90 X.. Y... M3 S...
    G43 H1 Z... M8
    X... Y...
    X... Y...
    .....
    .....
    G0 Z SAFE HEIGHT TO GO TO NEXT WORK OFFSET
    M99

    O1238
    M6 T4
    G0 G90 X.. Y... M3 S...
    G43 H1 Z... M8
    X... Y...
    X... Y...
    .....
    .....
    G0 Z SAFE HEIGHT TO GO TO NEXT WORK OFFSET
    M99
    %

    This example do each prog from O1235 to O1238 on G54 to G57 work offset
    Program number have to follow each other except the main that doesn't matter
    there is no tool change in the main, each tool change is in the sub of each tool. (I don't know how your machine act if you call the tool already in the spindle but if the tool change is well constructed, it should skip the tool change with no alarm. If you have a tool change macro, it is easy to make it act this way if it doesn't already do)
    There is no work offset written in any program, this is the macro that assign the work offset

    Keep me informed if you have any question or problem or even if it works perfectly

  16. #16
    Join Date
    Feb 2007
    Posts
    314
    Quote Originally Posted by fdonosos View Post
    Hey Samu thanks it work great I'm sorry so late
    Thank you for the feedback, I'm happy that it works for you

  17. #17
    Join Date
    Aug 2011
    Posts
    92
    My machine will throw and error and stop if i call a tool that is already in the spindle.

    It is a Mori Seiki running Fanuc 10M.

    Do you have any suggestions for that?

  18. #18
    Join Date
    Feb 2007
    Posts
    314
    Quote Originally Posted by blkaplan View Post
    My machine will throw and error and stop if i call a tool that is already in the spindle.

    It is a Mori Seiki running Fanuc 10M.

    Do you have any suggestions for that?
    Does it use a tool change macro? if so, post the tool change macro and I'll check possible edit to fix it. Another solution is to set a variable after the tool change that allow to jump over the subsequent tool change and reset this variable by the macro when program number change.

    %
    O9201
    #11=#7-#3 (QUANTITY OF PROGRAM TO LOOP)
    #12=#3 (WORKING COPY OF THE FIRST PROG)
    #13=0 (PROGRAM COUNTER)
    #130=0(FIRST TOOL CHANGE FLAG)
    N10DO1
    #10=0 (LOOP COUNTER)
    IF[#9NE1]GOTO11 (IF YOU DON'T WANT TO BEGIN BY THE LAST WORK OFFSET JUMP TO)
    #1=#1+#2-1 (SET LAST WORK OFFSET)
    GOTO16
    N11DO2
    G#1 (SET CURRENT WORK OFFSET)
    M98P#12 (CALL CURRENT PROGRAM)
    #10=#10+1 (INCREMENT LOOP COUNTER)
    IF[#10EQ#2]GOTO15 (IF CURRENT PROG HAS BEEN RUN ON ALL WORK OFFSET JUMP TO)
    #1=#1+1 (INCREMENT WORK OFFSET)
    END2
    N15#13=#13+1 (INCREMENT PROG COUNTER)
    IF[#13GT#11]GOTO18 (IF ALL PROG HAVE BEEN RUN JUMP TO)
    #10=0 (RESET LOOP COUNTER)
    #130=0
    #12=#12+1 (INCREMENT PROG NUMBER)
    N16DO2
    #9=0 (CLEAR THE BEGIN BY THE LAST OFFSET FLAG)
    G#1 (SET CURRENT WORK OFFSET)
    M98P#12 (CALL CURRENT PROG)
    #10=#10+1 (INCREMENT LOOP COUNTER)
    IF[#10EQ#2]GOTO17 (IF CURRENT PROG HAS BEEN RUN ON ALL WORK OFFSET JUMP TO)
    #1=#1-1 (DECREMENT WORK OFFSET)
    END2
    N17#13=#13+1 (INCREMENT PROG COUNTER)
    IF[#13GT#11]GOTO18 (IF ALL PROG HAVE BEEN RUN JUMP TO)
    #130=0
    #12=#12+1 (INCREMENT PROG NUMBER)
    END1
    N18 #130=0
    M99
    %


    O1235
    IF[#130 EQ 1] GOTO 5
    M6 T1
    #130=1
    N5 G0 G90 X.. Y... M3 S...
    G43 H1 Z... M8
    X... Y...
    X... Y...
    .....
    .....
    G0 Z SAFE HEIGHT TO GO TO NEXT WORK OFFSET
    M99


    I use variable #130 to jump over problematic tool change
    at the beginning of the macro and before each sub change, macro reset #130 to 0
    At the beginning of each sub, i check for the value of #131
    if #130=0, that means that it is the first time the sub is executed
    right after the tool change block, I set #131 to 1 (in the sub ) so, for the subsequent execution of this sub, i will jump over the tool change.

    I use that trick for rigid taping to avoid computing the M29 code at each work offset. (in that case you must have a G80 following #130=0 in the macro)
    But I think in your case, it will be easier to work on the tool change logic and avoid hand coding. Do you know if you have a tool change macro?? If you don't have,no problem, we will create a macro called by M6 to watch if we need to call a tool change(M6 inside this macro will act as usual so we can call the tool change the way you already done)

  19. #19
    Join Date
    Aug 2011
    Posts
    92
    When i unlocked the 8000 and 9000 programs on mill there is no macro tool change visible.

    So to my knowledge there is no tool change macro.


    It uses a randomly assigned pots.

  20. #20
    Join Date
    Feb 2007
    Posts
    314
    so i think the problem is with the T number and not with M6. M6 just swap the tool in spindle with the tool in the tool changer , but logically you cannot ask to prepare the pocket containing the tool in the spindle. More complicated than i thought! At least, the solution exposed in my previous post should work according that you jump above the M6 and the next tool Txx.
    %
    O1 (main)
    T1 (TOOL FOR THE FIRS SUB )
    G65 A54. B4. C2. D4. P9201
    G91 G28 Z0 M9
    G28 Y0
    M30

    O2
    IF[#130=1] GOTO 5
    M6
    T2(TOOL FOR THE NEXT SUB)
    N5 #130=1
    (REST OF THE SUB)
    M99

    O3
    IF[#130=1] GOTO 5
    M6
    T3(TOOL FOR THE NEXT SUB)
    N5 #130=1
    (REST OF THE SUB)
    M99

    O4
    IF[#130=1] GOTO 5
    M6
    T1(TOOL FOR THE FIRST SUB)
    N5 #130=1
    (REST OF THE SUB)
    M99
    %

    Give it a try and give me feed back! I'll continue thinking a way to avoid hand coding of the "IF GOTO ........."

Page 1 of 2 12

Similar Threads

  1. How do I make multiple passes on arc.
    By Andrew96 in forum Vectric
    Replies: 4
    Last Post: 07-02-2011, 05:16 AM
  2. Toolchange macro/sub for OSP5000L
    By nlh in forum Okuma
    Replies: 7
    Last Post: 10-02-2010, 11:31 AM
  3. how to get multiple parts from a bar
    By firekoe in forum Fanuc
    Replies: 13
    Last Post: 02-11-2010, 03:23 PM
  4. KIWA excel 510 toolchange macro help
    By bensoli in forum Uncategorised MetalWorking Machines
    Replies: 0
    Last Post: 12-29-2009, 06:49 PM
  5. Macro b multiple choice menu?
    By tomi6678 in forum Parametric Programing
    Replies: 2
    Last Post: 12-12-2009, 09:16 PM

Posting Permissions

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