Page 1 of 2 12 LastLast
Results 1 to 12 of 14

Thread: Macro for multi part

  1. #1
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    49
    Downloads
    0
    Uploads
    0

    Macro for multi part

    Hi, all just got started on modifying a program we have for our cnc router (fanuc control) all they want to do is make multiple parts using a small program (the piece is 4"o.d. 1" i.d.) so I began writing macro into the program and it repeats what I want but it just stays in the same cutting area I have the program below and hope someone can help , thanks . %
    N1(UHMW_1IN1.OUT 31-UHMW-0033)
    (MCULMS NAME"MACH1S")
    (MCUSTOCK X120. Y48. Z1. OBL)
    N2G00G17G20G28G40G80G91Z0M5
    N3G90
    N4 (#508 AMOUNT OF BLANKS REQUIRED)
    N5 (#509 AMOUNT OF BLANKS RAN)
    N6 IF[#509 GE 1] GOTO8
    N7 IF[#509 EQ 0] GOTO9
    N8 G91X5.25
    N9G52X0Y0Z0
    N10G08P1
    N11M08
    N12(MCUTOOL TOOL2006 D0.750 R0.000 L4.000 NAME "ROUTER-BIT .75 DIA." I1)
    N13G28G91Z0M05
    N14G90T2006M06
    N15T102
    N16M03S15000
    N17G00G17G55X2.777Y2.8749
    N18G00G43H6Z1.25
    N19Z1.1
    N20G41D06G01X3.1342Y3.0812F150.
    N21Z.25
    N22G03X3.1379Y3.0948I-.005J.0087F300.
    N23I-.1178J-.068
    N24X3.1242Y3.0985I-.0087J-.005
    N25G00Z1.25
    N26G40G00X2.767Y2.8922
    N27X2.777Y2.8749
    N28Z1.1
    N29G41D06G01X3.1342Y3.0812F150.
    N30G00Z.35
    N31G01Z0.
    N32G03X3.1379Y3.0948I-.005J.0087F300.
    N33I-.1178J-.068
    N34X3.1242Y3.0985I-.0087J-.005
    N35G00Z1.25
    N36G40G00X2.767Y2.8922
    N37X5.307Y2.1715
    N38S12000
    N39Z1.1
    N40G42D06G01X5.3789Y2.5777F175.
    N41G03X5.0761Y4.2138Z.25I-2.3377J.4134
    N42I-2.0559J-1.187F350.
    N43X4.8415Y4.5495Z.045I-2.0559J-1.187F350.
    N44I-1.8214J-1.5226
    N45X4.2783Y5.04I-1.8214J-1.5226F350.
    N46X3.7299Y5.3033Z.35I-1.2931J-1.9909
    N47G00Z1.25
    N48G40G00X3.3382Y5.4327
    N49(MCUTOOL TOOL2009 D0.250 R0.000 L4.000 NAME "EDGE RADIUS" I1)
    N50G28G91Z0M05
    N51G90T2009M06
    N52T102
    N53M03S20000
    N54G00G17G55X3.0949Y3.4878
    N55G00G43H9Z1.25
    N56Z1.1
    N57G42D09G01X3.1446Y3.4739F375.
    N58G02X3.422Y3.2589Z.92I-.1245J-.4471
    N59I-.4019J-.232F750.
    N60X3.4842Y3.0198I-.4019J-.232F750.
    N61X3.3465Y2.6969Z1.1I-.464J.007
    N62G00Z1.25
    N63G40G00X3.3098Y2.6606
    N64X4.9612Y3.6753
    N65Z1.1
    N66G42D09G01X4.9436Y3.7238F375.
    N67G03X4.7919Y4.0498Z.92I-1.9235J-.697
    N68I-1.7718J-1.0229F750.
    N69X4.654Y4.2581I-1.7718J-1.0229F750.
    N70X4.4132Y4.5251Z1.1I-1.6339J-1.2313
    N71G00Z1.25
    N72G40G00X4.3755Y4.5603
    N73G28G91Z0M5
    N74#509=#509+1
    N75 IF[#509 GE #508] GOTO77
    /N76 M99
    N77G28G91X0M09
    N78G90
    N79G52X0Y0Z0
    N80G08P0
    N81 #509=0
    N82M30
    %
    Last edited by DocHod; 06-05-2007 at 10:03 PM.


  2. #2
    Registered
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    11,960
    Downloads
    0
    Uploads
    0
    I only see one work coordinate in your program. You need multiple work coordinates in all the locations you want to cut parts. You can put them in by hand in all the G54, G55, etc values or by using G52 X Y to create 'child' coordinates.

    A similar problem was discussed in this thread; Automatic work shift on lathe, is it possible?

    This is for a lathe but the same principles apply. Look particularly at Post #19 it describes a macro for calculating values to use with G52. You would need to extend it to two values that step out a grid.

    If your controller can handle multi-nested subroutines it is possible to do the same thing but then your actual program has to be written in incremental.
    An open mind is a virtue...so long as all the common sense has not leaked out.


  3. #3
    gar
    gar is offline
    Registered
    Join Date
    Mar 2005
    Location
    USA
    Posts
    1,498
    Downloads
    0
    Uploads
    0
    070603-1333 EST USA

    DocHod:

    First, I want to criticize your question.

    You have presented a program of one long sequence of compacted unintelligible alpha-numeric characters, and few if any comments on the program logic.

    If you put this program away for a year, then after that time away from your memory how long will it take to reunderstand what the program does?

    I would like to see line numbers only when required. For example: need for a GOTO or subroutine call, or a reference point for some other reason.

    I like fields separated by at least a space, or even better formatting where Xs, Ys, etc. are aligned. What is a field? A logical element representing an entity within a record (a record is usually a line). For example: in a spread sheet each column in a row would be a field, and in a CNC program I would classify G10 or, X 0.9, or N1000 as fields.

    I like to see line spacing between major sections of a program. For example: a local subroutine would be preceded by a blank line as follows:

    GOTO 1000 (Just some code before the subroutine. Nothing to do with the subroutine.)

    N200 (subroutine to calculate a point on an ellipse with center at 0, 0)
    #100 = #121 COS #120 (X value)
    #101 = #122 SIN #120 (Y value)
    M99 (command to return from subroutine to the line following the call to the subroutine)
    (HAAS uses the description "Return from subroutine", but at M99 you have not yet returned.)

    N201 (some other subroutine)

    What I have also shown here is supplying comments to ease understanding. Normally I would not provide any comment on an M99 at the end of a subroutine. But in other uses of M99 I might add a comment.

    I have no idea what is in your program because there is too much clutter to wade thru.


    Second, to help you.
    The essence of what you want to do is this:

    1. Set up a starting reference point with maybe G54. This is not necessarily the reference point of the first part. And at this level work in absolute (G90).
    2. Create two loop points, counters, and count limits.
    3. Use G52 as Geof has mentioned to set your changing base position for each part. At this level you must be in G90 for your move to the next position.
    4. Create an internal or external subroutine for one part. This can be in either absolute or incremental.

    Now part of what you want follows:

    G54
    G52 X0 Y0 (this will start first part at the G54 location)
    ( otherwise put in initial values relative to G54 for the start)

    #100 = a value ( X offset from one part to the next )
    #101 = a value ( Y offset from one part to another )

    #110 = a value ( number of parts in the x direction )
    #111 = a value ( number of parts in the y direction )

    #120 = 0 ( X direction part count initialized to zero )
    #121 = 0 ( Y direction part count initialized to zero )

    N1100 ( Y loop )
    N1101 ( X loop )

    call your subroutine

    #120 = #120 + 1 ( increment X count )
    #5201 = #5201 + #100 ( increment the G52 X position )
    if [#120 LT #110] GOTO 1101 (this is the X loop)

    #120 = 0 ( reset X count to zero )
    #121 = #121 + 1 ( increment Y count )
    #5202 = #5202 + #101 ( increment the G52 Y position )
    if [#121 LT #111] GOTO 1100 (this is the Y loop)

    GOTO DONE --- the program is all done except ending things.

    See if there are any mistakes. Note in actual operation you may need decimal points, and there could be sign problems, as there were in our 1993 HAAS.

    Also note this can be very inefficient if there are tool changes within the subroutine. I have techniques that get around the tool change problem on multiple parts, but these are not a free giveaway.

    .


  4. #4
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    49
    Downloads
    0
    Uploads
    0
    gar I know it's a mess and was going to clean it up later, all I added to the program that someone else generated was macro calls from N4-N7 and N74- N82 . I'm not the programmer of the machine but someone that was asked if there is a way to do multiparts with a short program. geof the program uses G52 for the tool change and G55 for the actual work coordinate , yes I could use other work coordinate but I would run out of work coordinate before I get the required parts.


  • #5
    Registered
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    11,960
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by DocHod View Post
    ...geof the program uses G52 for the tool change and G55 for the actual work coordinate , yes I could use other work coordinate but I would run out of work coordinate before I get the required parts.
    First comment: The G52 ahead of the tool change is doing nothing. All that G52 X0 Y0 Z0 does is put zero into the G52 register. If you are not using G52 to set any child coordinates the G52 register is zero anyway.

    Second comment: You never run out of G52 child coordinates. During a program you can enters values into G52 as many times as you want because the new value overwrites the old and you can always set the G52 register to zero at any time with G52 X0 Y0 Z0.

    Using G52 you simply need to know the locations with reference to G55 of all your parts; these have to be at the head of the program and the actual operations have to be called as a local subroutine or as an external sub program.

    You would have something like:

    G55
    G52 X4. Y0. Z0.
    M98 P(Prog number) The P might have to be an O
    G52 X8. Y0. Z0.
    M98 P(Prog number)
    etc
    etc
    for as many X locations at the same Y until you have to move Y
    G52 X(n*4) Y4. Z0.
    M98 P(Prog number)
    and step back through the X's

    The problem with this is that it can be a lengthy program because if you are doing 10 steps in X and 10 steps in Y across a grid pattern and making a part at each point you need 100 G52 lines. And if you want to change your X or Y location you have to edit 100 lines.

    This is why I suggested calculating the G52 coordinates using a macro. This requires many fewer program lines and editing for a change in X or Y is trivial.


    Final comment regarding the G52 X0 Y0 Z0 in the program: It is possible the programmer was getting confused with G53. G53 X0 Y0. Z0. will send the machine home.
    An open mind is a virtue...so long as all the common sense has not leaked out.


  • #6
    gar
    gar is offline
    Registered
    Join Date
    Mar 2005
    Location
    USA
    Posts
    1,498
    Downloads
    0
    Uploads
    0
    070603-1612 EST USA

    DocHod:

    Do lines N4 and N5 have any other purpose than to hold a comment. If not then where are #508 and #509 loaded.

    Where is the machine ever set at a start point?
    What happens if #509 is negative?
    What is the initial value of #509?
    What does N74 = #509 + 1 do? Should be an error.

    Is it correct that all the code from N8 thru N73 was original?
    What is the purpose of G91 in the following line?
    N50G28G91Z0M05

    It looks like you never go below Z 0 relative to G55, and it looks like Z 1.25 may be a clearance plane. Further it appears that cut comp is ended by first going to Z 1.25, than ramping out. Thus, you do not ramp away from the cut. I would think this would leave a mark at the path end from the vertical move.

    Why the G28G91Z0 just before G90T2009? I would think you could eliminate G91 and G90 here. G28 Z0 should take you to machine Z home position.

    Can you define what G52 is supposed to do in your machine?

    .


  • #7
    Registered
    Join Date
    Jul 2005
    Location
    Canada
    Posts
    11,960
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by gar View Post
    ....G28 Z0 should take you to machine Z home position...
    gar; But this takes you first to Z0. in the current coordinate system, then to machine home. At least that is what it does on my machines and I think that it is a standard that G28 commands the machine to go to the identified reference point then home. Putting an incremental command with the G28 tells the machine to move Z0. incrementally then go home.
    An open mind is a virtue...so long as all the common sense has not leaked out.


  • #8
    gar
    gar is offline
    Registered
    Join Date
    Mar 2005
    Location
    USA
    Posts
    1,498
    Downloads
    0
    Uploads
    0
    070603-1844 EST USA

    Geof:

    I will have to try this sometime. G28 is something I never use.

    However, from the HAAS on-line manual is the following quote:

    "HOME G28 - Returns all axes to machine zero in rapid motion. Home G28 will also home a single axis in the
    same manner if you enter an axis letter and press the home G28 button. CAUTION! There is no warning
    message to alert the operator of any possible collision. For example, if the Z-axis is down in amongst parts on
    the table when X or Y is zeroed, a crash can result."

    This maybe incomplete, or inaccurate, or maybe G28 Z performs the above, and G28 Z0 does not.

    On rereading this appears to relate to the G28 button. Thus, it should indicate that this does not apply to use of G28 in a program. Great lack of consistency. Also in my opinion misuse of the G91 code which is really being used in the G28 line of code as a modifier to inhibit the thru point. It probably has the unintended effect of putting the machine into incremental mode when not wanted.

    If one does G53 Z0, then we do not have do the the G91 and back to G90 thing.

    On p118 your definition is defined and the strange use of G91 is included. But the use of G91 is not clearly defined and all of its effects.

    .


  • #9
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    49
    Downloads
    0
    Uploads
    0
    gar , yes N74 is an incorrect statement it should be #509=#509+1 and I corrected it in my post , line 4 and 5 are just notes to the operator line 6 and 7 are for counting the parts ran , the operator would put in variable #508 the amount of parts he needs and #509 will be set to 0 , variable #509 would count how many part are ran .the plan is when the first part is ran at the initial work coordinate that it counts it (N74 #509=#509+1) then jumps to N76 (M99) when it goes back to the top of the program it reads N6 and then jumps to N8 this is the amount to move an incremental move and do another part. But the G55 is getting in the way because it read it again and moves back to the initial start point of the first part . I hope I don't give anyone a head ache that reads this lol . I will get this program to run properly when I get a chance , thanks everone for the help so far .


  • #10
    gar
    gar is offline
    Registered
    Join Date
    Mar 2005
    Location
    USA
    Posts
    1,498
    Downloads
    0
    Uploads
    0
    070605-2148 EST USA

    DocHod:

    Is there a reason to have the operator initialize #509 instead of the program? If not put it in the program and relieve the operator of a possible error.

    Or do you want to start at some particular part count with a non-zero value in #509? This will require a program modification further down.

    How easy is it for an operator to load a #500 series variable vs some other like #100, or some other method of loading the information?

    If you use the count * increment for the offset position, then you can start at any desired count location by the initialized count value of #509. This preferably means using G52 for your offset.

    .


  • #11
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    49
    Downloads
    0
    Uploads
    0
    gar , it is up to the operator to put in how many parts he wants because of time restraints of run time that the machine can be ran for how long on a particular part and accessing the variables is quite easy on a Fanuc controller.


  • #12
    gar
    gar is offline
    Registered
    Join Date
    Mar 2005
    Location
    USA
    Posts
    1,498
    Downloads
    0
    Uploads
    0
    070607-2018 EST USA

    DocHod:

    #508 is the count of what you want made as I understand your notes. #509 is the count of where you are in the sequence. #509 has to be set to zero at the start of the new run and this is not done in your program. Thus, the operator has to set this value as well as the number required. This #509 can always be initiallized to 0 in the program if you never need to restart part way thru your part sequence.

    To start part way thru the sequence you have to change the way the program is written.

    .


  • Page 1 of 2 12 LastLast

    Similar Threads

    1. Multi-Part Fixturing
      By Geof in forum Work Fixtures and Hold-Down Solutions
      Replies: 12
      Last Post: 10-09-2009, 09:25 AM
    2. How to multi part
      By Toddjones in forum Mastercam
      Replies: 6
      Last Post: 04-23-2009, 11:02 AM
    3. Multi-motors
      By Tsukuyomi in forum Stepper Motors and Drives
      Replies: 5
      Last Post: 05-02-2006, 09:45 PM
    4. multi-boot two HDs
      By Karl_T in forum Computers and Networking
      Replies: 3
      Last Post: 06-21-2005, 12:58 AM
    5. Multi Bit Drill Head
      By smythe in forum WoodWorking
      Replies: 0
      Last Post: 11-16-2004, 01:02 PM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.