585,728 active members*
4,759 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Fanuc > Help writing chip breaker custom macro
Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2011
    Posts
    261

    Question Help writing chip breaker custom macro

    I thought that I had a copy of the chip breaker turn/dwell program from my old machine but I seem to have misplaced it. So anyone want to help me write one? or if you have one post it?

    I want to turn/dwell/turn/dwell/turn...ect

    I thought it looked something like this:

    %9010

    #1 =z end
    #2 =turn distance/chip break
    #3 =dwell
    #4 =feed

    IF [#2 LT0] goto2
    IF [#3 LT0] goto3
    IF [#4 LT0] goto4

    while [#5041 LT #1] DO1
    G1 W#2 f#4
    G4 U#3
    END1

    N1 #3000=1 (No Z)
    N2 #3000=2 (No Q)
    N3 #3000=3 (No D)
    N4 #3000=4 (No F)
    %

    My questions are
    -How do I define my current Z position. If I remember the old program correctly I thought it was #1=#5401 but I could be wrong. I just looked in the Fanuc manual and think I need to use a #5041-5048 macro but can someone confirm this. Also how do I determine what axis number my X and Z are?

    -I want to write the code in the program as G65 Z(end) Q(chip break) D(dwell) F(feed). How do I link Z,Q,D, and F to my sub program? Can I say #2=Q? Or do I use some parameter #'s like Q=#5403?

    -In my WHILE statement should I use a Z or W for my feed move? Does it matter? Do I have it written correctly that the loop will end when it hits my end point or could it possibly over-turn by going to the end of the last chip break assuming the chip break distance is not divisible by the overall distance.

    -How do I signify the end of the loop? m99?

    I know thats kinda a lot so thanks a bunch in advance!
    CNC Product Manager / Training Consultant

  2. #2
    Join Date
    Aug 2011
    Posts
    2517
    Quote Originally Posted by MCImes View Post
    -I want to write the code in the program as G65 Z(end) Q(chip break) D(dwell) F(feed). How do I link Z,Q,D, and F to my sub program? Can I say #2=Q? Or do I use some parameter #'s like Q=#5403?
    In the G65 line if you want to use D, F, Q & Z use this list below to reference them in your macro program. These are called Local Variables.
    a simple example is if you want to use D in your G65 and you need to check it is greater than 0 you put this into your macro....
    IF [#7 GT 0] GOTO 100
    etc

    A #1
    B #2
    C #3
    D #7
    E #8
    F #9
    H #11
    I #4
    J #5
    K #6
    M #13
    Q #17
    R #18
    S #19
    T #20
    U #21
    V #22
    W #23
    X #24
    Y #25
    Z #26

    So that's one of your questions answered

  3. #3
    Join Date
    Aug 2011
    Posts
    2517
    I'm no macro expert but if you think about this it's not far off a G74 peck cycle on a lathe but instead of back-off at the peck depth it dwells instead.
    There is a drill peck cycle macro in the Fanuc 16/18/21 series operator's manual (and probably other series manuals too) but using a totally different method.
    Anyway, based on your method something like this should work....

    Z end point = -10.00" (#26)
    Peck Q = 0.200" (#17). must be positive value
    Dwell D = 1 second (#7)
    Feed F = 0.014" (#9)
    Back-off in X at end of pass as incremental U value. sign important! U is positive for OD turning and minus for ID boring (#21)
    #5042 = Z axis current pos (#5041 = X axis current pos)

    G65 P9010 Z-10.0 Q0.200 D1.0 U0.04 F0.014

    %
    O9010
    #1 = #5042 (remember start Z position)
    WHILE [#5042 LT #26] DO (or maybe GT because #26 is a negative Z and current pos is also negative, but less negative if face = Z0)
    IF [[#5042 - #26] LT #17] THEN #17 = #5042 - #26 (prevent over-run)
    G1 W-#17 F#9 (peck W-0.200 at feed 0.014")
    G4 U#7 (dwell 1 second)
    END
    N1 G1 U#21 (at end of pass move away incrementally)
    G0 Z#1 (rapid back to initial start point)
    %

    The 'prevent over-run' line basically checks current position (which will be a minus Z value) and subtracts the end position (also a negative Z value). If that amount is less than the peck amount then the peck amount becomes the remainder between current position and end position.
    For example if current pos = Z-9.9 then peck W = -9.9 minus -10.0 = 0.100"
    At least in theory anyway

    To use this as a custom G-code set parameter 6050 to the number of your custom G-code. 6050 corresponds to program 9010. 6051 to 9011. 6052 to 9012 etc.

    You may need to fine tune this on the machine in case some of the logic is wrong, especially the 'prevent over-run' part

  4. #4
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by fordav11 View Post
    Anyway, based on your method something like this should work....

    Z end point = -10.00" (#26)
    Peck Q = 0.200" (#17). must be positive value
    Dwell D = 1 second (#7)
    Feed F = 0.014" (#9)
    Back-off in X at end of pass as incremental U value. sign important! U is positive for OD turning and minus for ID boring (#21)
    #5042 = Z axis current pos (#5041 = X axis current pos)

    G65 P9010 Z-10.0 Q0.200 D1.0 U0.04 F0.014

    %
    O9010
    #1 = #5042 (remember start Z position)
    WHILE [#5042 LT #26] DO (or maybe GT because #26 is a negative Z and current pos is also negative, but less negative if face = Z0)
    G1 W-#17 F#9 (peck W-0.200 at feed 0.014")

    G4 U#7 (dwell 1 second)
    END
    G1 U#21 (at end of pass move away incrementally)
    G0 Z#1 (rapid back to initial start point)
    %

    To use this as a custom G-code set parameter 6050 to the number of your custom G-code. 6050 corresponds to program 9010. 6051 to 9011. 6052 to 9012 etc.
    I understand that yours is just an example, but the logic in red could result in an over cut in Z of up to 0.001 less than the amount of the peck value.

    Something like the following in Blue would fix this. This example is based on end of workpiece being Z Zero.
    %
    O9010
    #1 = #5042 (remember start Z position)
    WHILE [#5042 GT #26] DO1
    #2=ABS[#26-#5042]
    IF[#2LT#17]TH#17=#2

    G1 W-#17 F#9 (peck W-0.200 or W-#2 value at feed 0.014")
    G4 U#7 (dwell 0.1 second)
    END1
    G1 U#21 (at end of pass move away incrementally)
    G0 Z#1 (rapid back to initial start point)
    %

    Regards,

    Bill

  5. #5
    Join Date
    Mar 2005
    Posts
    14

    Drilling macro

    O9010 (DRILL MACRO)
    #100=#7(SET VARIABLE #100 EQUAL TO
    D – PECK AMOUNT)
    #101=ABS [#26] (SET VARIABLE #101 EQUAL TO Z - HOLE DEPTH)
    #102=#6 (SET VARIABLE #102 EQUAL TO K – DRILL RETURN OFFSET)
    #103=#18 (SET VARIABLE #103 EQUAL TO R – RETRACT LOCATION)
    #104=#100 (TEMPORARILY SET VARIABLE #104 EQUAL TO PECK AMOUNT)
    #105=#9 (SET VARIABLE #105 EQUAL TO F, FEED RATE)
    WHILE [#104LT#101] DO1 (LOOP WHILE TEMP Z-VALUE IS LESS THAN FINISH DEPTH)
    G1 Z-#104 F#105 (FEED TO PECK DEPTH = VALUE OF #104)
    G0 Z#103 (CLEAR CHIP - RAPID TO RETRACT LOCATION)
    Z- [#104-#102] (RAPID RETURN TO LAST LOCATION LESS K VALUE)
    #104=#104+#100 (SET TEMP Z EQUAL TO TEMP Z PLUS PECK VALUE)
    END1 (END LOOP)
    G1 Z-#101 (DRILL TO FINISH DEPTH)
    G0 Z#103 (RAPID OUT TO RETRACT LOCATION)
    M99 (RETURN TO MAIN PROGRAM)

    This closely resembles the subprogram call illustrated earlier, except that now the subroutine is called up with a G65 instead of an M98. Calling subprograms with a G65 allows you to "pass" variables to the subprogram. Variables make it easy to alter a program as cutting conditions require by simply changing the value of D, R, K, etc. It also makes it easy to use these macros for other jobs, as you can simply change a few values in the G65 macro call instead of rewriting the entire drilling routine.

    A cleaner way to use this program would be to assign it a G code, like this:

    O0001 (MAIN PROGRAM)
    N4 G97 M3 S1000 T404
    G0 X4. Z1.
    G183 Z-1.5 D.35 R.07 F.012 K.02
    G28 U0 W0
    M30

    This makes the macro program appear to be just like any other canned cycle in your machine. If you want to assign a G code to your macro programs, you will need to open the parameter manual for your control and find the specific parameter that maps the program number (usually a 9000-series program) to the G code.

    In fact, as you may have already realized, there are few differences between a macro program and a canned cycle. But while canned cycles are fixed, macro programs give you the freedom to accomplish any programming task you desire. And that usually is a big plus when conducting drilling operations on a CNC lathe.

  6. #6
    Join Date
    Aug 2011
    Posts
    2517
    Quote Originally Posted by angelw View Post
    Something like the following in Blue would fix this. This example is based on end of workpiece being Z Zero.
    I took care of the over-run around 8 minutes before you posted.....
    Anyway, I find it very interesting that you waited 2 days to answer this after I took the time to read up in the manual and provided a possible solution. Hmmmm interesting :stickpoke

  7. #7
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by fordav11 View Post
    I took care of the over-run around 8 minutes before you posted.....
    Anyway, I find it very interesting that you waited 2 days to answer this after I took the time to read up in the manual and provided a possible solution. Hmmmm interesting :stickpoke
    What's you point regarding how long it took to respond to this thread? Not that I'm obliged to answer to you or anyone as to when I reply to a thread, but I do so when I have time and I contribute to more than this thread and this forum. I had already contributed substantially to MCImes's other thread dealing with Custom G Codes. The fact that Forum members take the time to make a contribution should be seen as a bonus in my opinion, and is the basis on which a Forum operates. I and many members of this and other Forums operate on a "Play it Forward" philosophy; each making a beneficial contribution.

    I hadn't noticed that you'd edited your post whilst I was typing.
    Regards,

    Bill

  8. #8
    Join Date
    Feb 2011
    Posts
    640
    Quote Originally Posted by geach73 View Post
    O9010 (DRILL MACRO)
    #100=#7(SET VARIABLE #100 EQUAL TO
    D – PECK AMOUNT)
    #101=ABS [#26] (SET VARIABLE #101 EQUAL TO Z - HOLE DEPTH)
    #102=#6 (SET VARIABLE #102 EQUAL TO K – DRILL RETURN OFFSET)
    #103=#18 (SET VARIABLE #103 EQUAL TO R – RETRACT LOCATION)
    #104=#100 (TEMPORARILY SET VARIABLE #104 EQUAL TO PECK AMOUNT)
    #105=#9 (SET VARIABLE #105 EQUAL TO F, FEED RATE)
    WHILE [#104LT#101] DO1 (LOOP WHILE TEMP Z-VALUE IS LESS THAN FINISH DEPTH)
    G1 Z-#104 F#105 (FEED TO PECK DEPTH = VALUE OF #104)
    G0 Z#103 (CLEAR CHIP - RAPID TO RETRACT LOCATION)
    Z- [#104-#102] (RAPID RETURN TO LAST LOCATION LESS K VALUE)
    #104=#104+#100 (SET TEMP Z EQUAL TO TEMP Z PLUS PECK VALUE)
    END1 (END LOOP)
    G1 Z-#101 (DRILL TO FINISH DEPTH)
    G0 Z#103 (RAPID OUT TO RETRACT LOCATION)
    M99 (RETURN TO MAIN PROGRAM)

    This closely resembles the subprogram call illustrated earlier, except that now the subroutine is called up with a G65 instead of an M98. Calling subprograms with a G65 allows you to "pass" variables to the subprogram. Variables make it easy to alter a program as cutting conditions require by simply changing the value of D, R, K, etc. It also makes it easy to use these macros for other jobs, as you can simply change a few values in the G65 macro call instead of rewriting the entire drilling routine.

    A cleaner way to use this program would be to assign it a G code, like this:

    O0001 (MAIN PROGRAM)
    N4 G97 M3 S1000 T404
    G0 X4. Z1.
    G183 Z-1.5 D.35 R.07 F.012 K.02
    G28 U0 W0
    M30

    This makes the macro program appear to be just like any other canned cycle in your machine. If you want to assign a G code to your macro programs, you will need to open the parameter manual for your control and find the specific parameter that maps the program number (usually a 9000-series program) to the G code.

    In fact, as you may have already realized, there are few differences between a macro program and a canned cycle. But while canned cycles are fixed, macro programs give you the freedom to accomplish any programming task you desire. And that usually is a big plus when conducting drilling operations on a CNC lathe.
    great thread

    I never knew (never looked) for a gcode call to a 9000 program

  9. #9
    Join Date
    Aug 2011
    Posts
    0
    Quote Originally Posted by tc429 View Post
    great thread

    I never knew (never looked) for a gcode call to a 9000 program
    fordav11 had made that suggestion in Post #3, and creating a custom G code was covered for the OP MCImes in his other Thread "How do I set a Custom G code?"

  10. #10
    Join Date
    Aug 2011
    Posts
    2517
    Quote Originally Posted by angelw View Post
    What's you point regarding how long it took to respond to this thread?
    my point is I noticed you reading the OP 2 days ago (the bottom of the page shows who is reading the page) but of course at that time there was no solution posted and you didn't post one either. I waited a couple of days in case someone who knows more about macro answered it but no one did so I posted my reply after doing some research.
    then 2 days later you nit-pick my reply after I supplied a possible solution without fully reading/refreshing. You could have re-read it after and it would have been courteous to correct your reply acknowledging my solution and/or removing your unnecessary post entirely. The main problem was the OP cross-posted causing duplicate info/posts. On most forums cross-posting will get you banned although here it's kind of ok I think because 90% of the forums here are dead and a newcomer wouldn't know that. Anyway I don't require a reply here so please don't as this is getting off-topic and the original post was answered in full.

    The only thing remaining now is to wait for MCImes to come back here and say whether it worked on his machine and solved his problem....

  11. #11
    Join Date
    Sep 2011
    Posts
    261
    Thanks everyone. Ill try loading up one of those sometime this week when I get a slow day and report back with how it works
    CNC Product Manager / Training Consultant

Similar Threads

  1. Chip Breaker for Aluminum
    By tpsimer in forum MetalWork Discussion
    Replies: 25
    Last Post: 10-10-2014, 05:56 PM
  2. custom macro
    By hillafbmike in forum Fanuc
    Replies: 2
    Last Post: 04-14-2011, 03:30 AM
  3. "difference between Custom Macro A and Custom Macro B"
    By arulthambi in forum Parametric Programing
    Replies: 4
    Last Post: 10-05-2009, 09:34 PM
  4. Writing a custom M code?
    By greeder88 in forum Dynapath
    Replies: 1
    Last Post: 06-24-2009, 02:52 PM
  5. Custom Macro B On A 18t.
    By JIMMYZ in forum Fanuc
    Replies: 3
    Last Post: 10-19-2006, 04:08 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
  •