585,679 active members*
5,536 visitors online*
Register for free
Login
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2005
    Posts
    109

    Help with subprogram

    Hi
    Is there an easy way of writing a sub that will feed down Z-0.400, run the sub then rapid up to Z0.100 then loop intel it reaches Z-1.600, then start over. The way I have it wrote now will not retract out of the part
    Thanks for the help
    N18 G00 G90 G54 X-2.0.0 Y1.0
    N33 G00 Z0.1000
    N12 M98 P1300L4
    N12 G90 G00 Z0.100
    N12 M98 P1301L4
    N12 G90 G00 Z0.100
    N12 M98 P1302L4
    N12 G90 G00 Z0.100


    O1300
    (1ST ROUGH)
    N247 G00 X4.1396 Y-12.7000
    N248 G91 G01 Z-0.5000 F14.00
    N249 G90 G01 X5.7000 Y-11.1396 F14.0
    N250 G91 G00 Z0.1000
    N251 G90 G00 X4.1396 Y-12.7000
    M99

    O1301
    (2ND ROUGH)
    N266 G00 X-1.2493 Y-7.8085
    N267 G91 G01 Z-0.5000 F20.00
    N268 G90 G02 X-0.4538 Y-6.7504 I4.1493 J-2.2915 F14.00
    N269 G03 X-0.2900 Y-6.3547 I-0.3962 J0.3957
    N270 G01 Y-2.4863
    N271 G01 X-0.5400
    N272 G91 G00 Z0.1000
    N273 G90 G00 X-1.2493 Y-7.8085
    M99

  2. #2
    Join Date
    Oct 2005
    Posts
    672
    Add a variable which increments.

    N18 G00 G90 G54 X-2.0.0 Y1.0
    N33 G00 Z0.1000
    #100=.05
    N12 M98 P1300L4
    N12 G90 G00 Z0.100
    #100=.05
    N12 M98 P1301L4
    N12 G90 G00 Z0.100
    #100=.05
    N12 M98 P1302L4
    N12 G90 G00 Z0.100


    O1300
    (1ST ROUGH)
    N247 G00 X4.1396 Y-12.7000
    N248 G91 G01 Z-#100 F14.00
    N249 G90 G01 X5.7000 Y-11.1396 F14.0
    N250 G00 Z0.1000
    N251 G90 G00 X4.1396 Y-12.7000
    #100=#100+.05
    M99

    O1301
    (2ND ROUGH)
    N266 G00 X-1.2493 Y-7.8085
    N267 G91 G01 Z-#100 F20.00
    N268 G90 G02 X-0.4538 Y-6.7504 I4.1493 J-2.2915 F14.00
    N269 G03 X-0.2900 Y-6.3547 I-0.3962 J0.3957
    N270 G01 Y-2.4863
    N271 G01 X-0.5400
    N272 G00 Z0.1000
    N273 G90 G00 X-1.2493 Y-7.8085
    #100=#100+.05
    M99

  3. #3
    Join Date
    Apr 2008
    Posts
    29
    You could put the Z.100 in your subprogram
    O1301
    (2ND ROUGH)
    G00G90Z.100
    N266 G00 X-1.2493 Y-7.8085
    *
    *
    *
    *
    N273 G90 G00 X-1.2493 Y-7.8085
    Z.100
    M99

  4. #4
    Join Date
    Nov 2006
    Posts
    174

    DO WHILE

    I prefer to use DO WHILE loops rather than subs. G91 can get messy and staying in G90 is easier to track. All blocks are in one prog rather than storing loads of subs for one part.

    Try it this way......

    N18 G00 G90 G54 X-2.0.0 Y1.0
    N33 G00 Z0.1000
    (1ST ROUGH)
    #500=-0.4 (sets variable to first cut)
    WHILE[#500GE-1.6]DO1 (starts loop, which ends at -1.6)
    N247 G00 X4.1396 Y-12.7000 (rapid to start position)
    N248 G01 Z#500 F14.00 (feed to Z position)
    N249 G01 X5.7000 Y-11.1396 F14.0
    N250 G00 Z0.1000 (rapid to Z0.1)
    #500=#500-0.4 (adds -0.4 for next Z position)
    END1 (return to start of loop, or carry on if Z is at desired depth)



    Your prog would feed from Z0.1 down to the next Z position, which wastes time cutting air. Add an extra line to rapid down to 0.1 above your next Z position.


    N18 G00 G90 G54 X-2.0.0 Y1.0
    N33 G00 Z0.1000
    (1ST ROUGH)
    #500=-0.4 (sets variable to first cut)
    WHILE[#500GE-1.6]DO1 (starts loop, which ends at -1.6)
    N247 G00 X4.1396 Y-12.7000 (rapid to start position)
    G00 Z[#500+0.5] (rapid to 0.5 above next Z position)
    N248 G01 Z#500 F14.00 (feed to Z position)
    N249 G01 X5.7000 Y-11.1396 F14.0
    N250 G00 Z0.1000 (rapid to Z0.1)
    #500=#500-0.4 (adds -0.4 for next Z position)
    END1


    Hope it makes sense. Just another way of doing the same thing.

  5. #5
    Join Date
    May 2005
    Posts
    109
    Thanks Guys for all the ideas. The only Problem I'm having is when I send the program to the DNC from Bobcad - predator,the control (Fanuc 6M) shows this N7 1001000.400 instead of this N7 #100=#100+0.400 basically all the variables are the same way, I tried without the line number but same thing.
    Any Ideas

  6. #6
    Join Date
    Jul 2008
    Posts
    24

    No If/Then abilities?

    I'm not understanding the .100 move BUT, I agree with Chattman that G91's can get messy...but here's an example of jumping back & forth a SubRoutine & your Main Program.

    We're talking Mits Wire EDM Macro here, it really doesn't apply to a mill application, but maybe your machine's IF/THEN statement might work for you...

    H=a variable
    you have a multitude of variables available, for example:

    Let H50=4 (the # of passes you wish to run)
    Let H51=-.400 (the amount of the z move that you wish to have each pass equal)

    You could put a counter on it such as
    N100 H50=H50-1
    N102 G91
    N104 G01 ZH51 F5. M90

    Move Z -the value of H51 @ a Feed of 5"/minute with Adaptive Control on
    N110 G22 (Send it to your X&Y move subroutine)
    When it returns from the routine - It does compares the current value of Variable #50
    N200 G202 A220 B0 CH50
    IF B = C THEN Branch/Jump to the Block # that's in A (in this case Block #220) without returning.
    IF B does NOT = C, then continue to the next block
    N210 G200 A100 (Branch/Jump to Block #100)
    (here's the loop - it will keep sending it to Block #100 until H51=0)

    (return to zero area)
    N220 G90
    N230 G92 X0 Y0 Z-H50*H51

    Here you're telling it that Z = -.400 X 4 (-.400 times the # of reps)
    N240 G01 Z0 F25. M91
    And here, returning to the original Z.

    Macro is such a confusing but powerful thing.
    Good luck

    - Brent
    www.videotech.me

  7. #7
    Join Date
    May 2007
    Posts
    1003
    Quote Originally Posted by 69owb View Post
    Thanks Guys for all the ideas. The only Problem I'm having is when I send the program to the DNC from Bobcad - predator,the control (Fanuc 6M) shows this N7 1001000.400 instead of this N7 #100=#100+0.400 basically all the variables are the same way, I tried without the line number but same thing.
    Any Ideas
    Seems you may not have Macro B capability. Otherwise it should have read the line.

    We have Macro B on an older Hardinge. I have the same macro program loaded in all the barfeeds. It wasn't until I went to use it in the OT control machine that I found out it doesn't support the THEN statement.

    When the macro program loads it makes the THEN statement T space H space END (3 separate words). Not exactly what I wanted.

    Did you ever get the problem solved?

  8. #8
    Join Date
    May 2005
    Posts
    109
    I did some research on macro A & B and I was able to turn some parameters on. So now it shows the varibles but I haven't tried it yet to see if it works. Had to start making metal chips so I wrote the program a littel different to get it up and running.

Similar Threads

  1. eia subprogram
    By rs1982 in forum Mazak, Mitsubishi, Mazatrol
    Replies: 4
    Last Post: 04-11-2008, 02:10 PM
  2. having trouble with subprogram
    By dshowald in forum Milltronics
    Replies: 10
    Last Post: 02-10-2007, 09:32 PM
  3. Restarting an EIA subprogram
    By ajl6549 in forum Mazak, Mitsubishi, Mazatrol
    Replies: 6
    Last Post: 08-09-2006, 12:06 PM
  4. Fanuc 16T subprogram example??
    By stex in forum Fanuc
    Replies: 11
    Last Post: 03-27-2006, 09:15 PM
  5. Mazatrol subprogram
    By BeanO in forum Mazak, Mitsubishi, Mazatrol
    Replies: 5
    Last Post: 11-24-2005, 10:12 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
  •