586,640 active members*
2,705 visitors online*
Register for free
Login
Page 1 of 2 12
Results 1 to 20 of 36
  1. #1

    Theres got to be a better way

    I am struggling with making multiple parts on a fixture. For instance I have a fixture that holds ten parts. I would like to program the first one then tell the machine to make them all. This was very simple on Fanuc and Yasnac controls. I have tried using multiple "G' alignments but when I do that it messes with the tool diameter offsets for some reason. Unfortunately I am kind of old school and like to program manually. Seems also that my machine does not have ay kind of CAM program on it. When I try to open BOBCAM nothing happens. Is there a better operating system for people like me? I really need to figure this out before I sell the machine and buy something that works the way I want. Here is an example of a program that I have used on Fanuc based machines. Take a look at the simplicity of using the G25 to do multiple parts.
    Mike

    %
    O1485
    (REPLICAPARTS.COM)
    (RPC-0005)
    (SEATBELT TRIM RING)
    (ON FIXTURE 10 AT A TIME.)
    N100G90G80G40G0
    T10M6(5/8 DIA. END MILL)
    G55X.75Y-1.S3000M3
    G43Z.1H10T11D31
    N45G92X0Y0
    X-.375Y1.
    G1Z0F30.M8
    Y-3.
    G3X.375Y-3.R.375
    G1Y0F30.
    G3X-.375Y0R.375
    G1Y-2.F30.
    Y-3.Z.002
    G90G0Z.1
    X0Y0
    N50X1.5
    G25P45Q50L9
    G92X15.75Y-1.
    G90G0Z.1M9
    G53Y0Z0H0M19
    M01
    N200G90G80G40G0
    T11M6(.187 DIA CARB. E.M.)
    G55X.75Y-1.S7000M3
    G43Z.1H11D31T12
    N5G92X0Y0
    X.75M8Y1.
    G1Z-.2F10.
    Y-4.
    G90G0Z.1
    X0Y0
    G1Z0F7.M8
    Y-3.Z-.2
    Y0
    G41X-.125F20.
    Y-3.
    G3X.125Y-3.R.125F5.
    G1Y0F20.
    G3X-.125Y0R.125F5.
    G1Y-3.F20.
    G40X0
    G90G0Z.1
    X-.8Y-3.5
    G1Z-.2F20.
    G41X-.63
    Y0
    G2X.63Y0R.63
    G1Y-3.
    G2X-.63Y-3.R.63
    G1G40X-.725
    G41X-.625
    G1Y0
    G2X.625Y0R.625
    G1Y-3.
    G2X-.625Y-3.R.625
    G1G40X-.725
    G90G0Z.1
    X0Y0
    N10X1.5
    G25P5Q10L9
    G92X15.75Y-1.
    G90G0Z.1M9
    G53Y0Z0H0M19
    M01
    N300G90G80G40G0
    T12M6(.062 RADIUS CUTTER)
    G55X.75Y-1.S7000M3
    G43Z.1H12T10D32
    N15G92X0Y0
    G1Z-.065F30.M8
    G41X-.125
    Y-3.
    G3X.125Y-3.R.125F5.
    G1Y0F30.
    G3X-.125Y0R.125F5.
    G1Y-3.F30.
    G40X0
    G90G0Z.1
    X-.8Y-3.5
    G1Z-.065
    G41X-.625
    G1Y0
    G2X.625Y0R.625
    G1Y-3.
    G2X-.625Y-3.R.625
    G1G40X-.725
    G90G0Z.1
    X0Y0
    N20X1.5
    G25P15Q20L9
    G92X15.75Y-1.
    G90G0Z.1M9
    G53Y0Z0H0M19
    M6T10
    M30
    %

  2. #2
    Join Date
    Jun 2008
    Posts
    1082

    Re: Theres got to be a better way

    I have a macro template that I've been honing down. I haven't tried it with any machine except my own (a Brother) but I imagine it would work wit' Mach3 or PathPilot or whatev's. I've been wanting to make a video to share it, but making videos is tedious, so I guess I'll just put it here for now...

    Note: just to reiterate, although this code works for me, it hasn't been used by anyone else so it should probably be considered untested and caution should be exercised.

    Basically, the way it works is you have your code for a single instance in one file, and the macro "calling program" in a second file. In the macro you tell it how many rows and columns you have, the distance between them, and how many "subroutine sequence numbers" there are ("subroutine sequence numbers" are explained below). It'll run each "subroutine sequence" at every position in the grid, starting at one corner, then going through that column, then move to the beginning of the next column, and when it's completed all the positions it'll move on to the next "subroutine sequence". When it's moving between positions it'll raise the tool to the "Z safe rapid plane", so that variable must be defined too. This macro uses G52 extensively.

    "Subroutine Sequence Numbers"
    The actual part code needs to be separated into sections with "N" subroutine sequence-numbers at their beginnings and "M99"s at their ends. The whole code can be just one "subroutine sequence" if you just put "N1" at the beginning and put "M99" at the end. The way I do it, is I separate the subroutine sequences by tool. Like this...

    Code:
    N1
    (tool 1)
    (op 1)
    M99
    
    N2
    (tool 2)
    (op 2)
    (op 3)
    M99
    (etc...)
    M30
    This way it'll run "op 1" with "tool 1" at each position, then do a tool change (or ask for one) and do "op 2" and "op 3" with "tool 2" at each position, and so on.

    It inserts an "M01" (optional stop) commands before each "subroutine sequence". I have it do that because "M01"s in the part code have the potential to mess it up. Also, of course, any "M30"s accidentally left within the code will mess things up too. Also watch out for "G54"s, "G17"s, and the like within your subroutine sequences.

    OK, so here it is... I've actually been incrementing the version number as I've edited it. Below is the macro as it stands right now, for me. I invite people to edit this file and I only ask that 1. please consider sharing working code and 2. version numbers are changed in shared code. You can take my name off it if you want, or maybe call it something like "Jim-Bob's array macro v.1.0 (modified from Hirudin's v1.8 to work with Mach3)".
    I've tried to comment the lines to avoid confusion (though I fear they might, somehow, add to the confusion)...
    Code:
    (Hirudin's array macro v1.8)
    N99900 (unique reference marker)
    (user vars #101 #102     )
    (     #170 #171 #175 #179)
    (     #180 #181 #185 #189)
    (          #191 #195 #199)
    
    ( : rows)
    #170 = ?.        (Y offset - distance between rows)
    #171 = ?         (first row)
    #179 = ?         (last row)
    
    (.. columns)
    #180 = ?.        (X offset - distance between columns)
    #181 = ?         (first column)
    #189 = ?         (last column)
    
    (subroutines)
    #101 = ????      (subroutine file number)
    #102 = ?.        (Z safe rapid plane)
    #191 = ?         (first subroutine sequence-number)
    #199 = ?         (last subroutine sequence-number)
    (/user vars)
    
    (**** NOTES ****)
    (Remember, add "M98P?????" to the end of this calling program, after M30.)
    (To skip tool-change on rows and columns other than the first add...)
    (IF[#175 NE #171]GOTO99999)
    (IF[#185 NE #181]GOTO99999)
    (... before the tool-change of each subroutine. You must also add...)
    (N99999)
    (... after each tool-change of each subroutine.)
    (**** /NOTES ****)
    
    (**** START ****)
    IF[#179 LT #171]GOTO99909 (stop processing if the last row is less than the first)
    IF[#189 LT #181]GOTO99909 (stop processing if the last column is less than the first)
    IF[#199 LT #191]GOTO99909 (stop processing if the last subroutine sequence-number is less than the first)
    #195 = #191 (initial current subroutine sequence-number)
    
    N99901 (start the current subroutine sequence-number)
    M01 (optional stop before executing new subroutine sequence-number)
    (**** CAUTION: M01 command will stop the spindle and cancel any coolant commands ****)
    #175 = #171 (set current row to first row)
    #185 = #181 (set current column to first column)
    
    N99902 (start the current column)
    G52 X[[#185 - 1] * #180] (set local X offset to the current column)
    
    N99903 (process each row in the current column)
    G52 Y[[#175 - 1] * #170] (set local Y offset to the current row)
    M98 P#101 H#195 (run current subroutine sequence-number in the subroutine file)
    G00 Z#102 (rapid up to Z safe rapid plane)
    IF[#175 EQ #179]GOTO99904 (stop processing rows if the current row is the last row)
    #175 = #175 + 1 (continue to the next row)
    GOTO99903 (restart row processing)
    
    N99904 (change columns or proceed to subroutine sequence-number processing)
    #175 = #171 (reset current row to the first row)
    IF[#185 EQ #189]GOTO99905 (stop processing columns if the current column is the last column)
    #185 = #185 + 1 (continue to the next column)
    GOTO99902 (start processing the new column)
    
    N99905 (change subroutine sequence-number or finish)
    IF[#195 EQ #199]GOTO99909 (stop processing everything when last subroutine sequence-number completes)
    #195 = #195 + 1 (move to the next subroutine sequence-number)
    GOTO99901 (restart processing with new subroutine sequence-number)
    
    N99909 (end processing)
    #101 = #0
    #102 = #0
    #170 = #0
    #171 = #0
    #175 = #0
    #179 = #0
    #180 = #0
    #181 = #0
    #185 = #0
    #189 = #0
    #191 = #0
    #195 = #0
    #199 = #0
    (**** END ****)
    
    M30
    (Add M98P????? after this line to load the subroutine file)
    I wrote the code with the intent to share it, so I tried to note some things within the code...


    • For instance, at the top is a list of all the variables it uses. I chose those variables because they work well with my Brother, but it might be better to use different variables with Mach3 (or whatever). A "find and replace" on each variable should sort that out.

    • There's a note in the macro that says "(Remember, add "M98P?????" to the end of this calling program, after M30.)". On my machine the "part" file needs to be specified after the "M30" at the bottom of the "calling program". So, if my part program is "o1002.NC" I need to add the command "M98P1002" to the end of the "calling program" macro file. Unfortunately, it didn't seem possible to do this using a variable on my machine so I must do this manually each time.

    • There's a note in the macro that says...
      "(To skip tool-change on rows and columns other than the first add...)
      (IF[#175 NE #171]GOTO99999)
      (IF[#185 NE #181]GOTO99999)
      (... before the tool-change of each subroutine. You must also add...)
      (N99999)
      (... after each tool-change of each subroutine.)
      "
      With my machine, it'll bring the spindle to the top of its travel when a tool-change is commanded, even if the commanded tool is already loaded in the spindle. To save time, I have my CAM program insert this code around tool-changes in the "part code". This code check to see if the "current row" variable (#175) does not equal (NE) the "first row" variable (#171). If those two variables do not match, it'll skip the tool-change command. In other words, it only does a tool change if it's currently working on the first row, otherwise the tool-change command is skipped. It does the same for the column, it skips the tool change during columns other than the first. So, since it skips the tool-change during rows other than the first AND columns other than the first it'll only do a tool change when it's about to start the first position in the grid and skips it for all the rest.

      After being modified, the subroutine sequence code might look something like this...
      Code:
      N05
      (IF[#175 NE #171]GOTO99999)
      (IF[#185 NE #181]GOTO99999)
      (<the tool change goes here>)
      (N99999)
      M08
      G01 Z1.
      Z-2.
      (blah blah blah...)
      M99

    • A quick note about the "N" numbers. I'm not sure how they behave in Mach3, but in the Brother control it does not care if the "N" numbers are placed out-of-sequence. In other words you could have your program look like this...
      Code:
      N1
      N900
      N2
      N1
      N5290
      N1
      (etc...)
      If an "N" number is called it'll start scanning from its current position and continue until one is found. If it's not found, it'll continue to look starting at the beginning of the file. If it's still not found I'm sure it'll throw an error or something. I'm guessing other machines work the same way, but, again, I haven't tried this with other machines (nor have I read their manuals so exhaustively) so I can't be sure. So, with the Brother it's OK to have many instances of "N99999", I hope it's the same for Mach3 (and others).

    • At the end of the macro it resets all the variables to "#0". This is another area that I'm uncertain about with Mach3 (or whatever). On the Brother control, the variable "#0" represents an empty set. In other words, the lines in the code similar to "#101 = #0" are deleting those variables instead of simply setting them to equal "0". I'm assuming Mach3 has some kind of similar functionality, and I wouldn't be surprised if it works exactly the same. If not, I'm sure simply setting them to equal "0" would be good enough.

    • When moving between different parts you only need to modify the "user vars" section and add M98P???? to the end.

    • You can easily have multiple copies of this macro in the same "calling program" by having multiple "part code" files and by doing some quick edits to each instance of the macro. I use this fact to first cut large blocks into multiple parts, then run separate code on each of the individual parts.

      Note the "N" numbers in the macro; they follow this format: 999?X. The reference sequence numbers range from 999?1 to 999?9.

      If you need to have multiple copies of the macro in the same file, prepare the second macro in a temporary file and do a "find and replace" on the string "9990" to be replaced with "9991", then copy the whole thing to your permanent file. This will maintain the structure of each macro separately, but give each section a unique reference number. Obviously, if you needed more than two, you'd replace the string with "9992". This will allow you to run a maximum of 9 macros within the same file ("9990 - "9998"). Make sure not to try to use "9999" as that sequence number set is already being used by the macro.

    • Positive or negative values for the "Y offset - distance between rows" and "X offset - distance between columns" (#170 and #180, respectively) should work, depending on where you like to set your XY reference point.

    • The first row, column, or subroutine sequence number does not need to be set to "1". Sometimes you might only fill half your fixture, or sometimes you may want to rerun the code on only a few parts in a fixture. Same with the subroutine sequences, if you decide you want to run subroutine sequence number "5" again for some reason you can just enter "5" as the value for both the "first subroutine sequence-number" and "last subroutine sequence-number" variables (#191 and #199, respectively). The macro will run that subroutine sequence at every position and stop when it's done.

    • You may want to copy and paste the G codes from the beginning and end of your CAM generated files to the beginning and end of the macro. For instance, I frequently place the following sections of code to the beginning and end of my calling macros...
      Code:
      G00 G90 G40 G80
      G94
      M280
      G54
      G17
      Code:
      M09
      G91 G28 Z0
      G90
      G53 X-550 Y0


    I hope this stuff makes sense and is helpful. It's complicated (or, I find it to be complicated) and though I've tried to explain it, I imagine there will still be some confusion. If there are any questions I'd be happy to try to answer them.

  3. #3
    Join Date
    Jun 2014
    Posts
    1780

    Re: Theres got to be a better way

    I dont hand code other than simple ops.

    I draw my multi part files in Rhino, export as an .igs file, import into sprutcam , there is a transform function that can be used for multiple parts and ops by selecting the ops for the first part, then using the transform function, select the cordinates and the number of parts you want.
    mike sr

  4. #4
    Join Date
    Mar 2009
    Posts
    1863

    Re: Theres got to be a better way

    When you post process your part, there should be a box that asks for 'NUMBER OF PARTS". That will allow you to decide how many parts you want to run every time you press cycle start.

    Or, you can make a G53 move to a new location and then run your program again. I don't care for doing it that way because I don't understand it.
    You can buy GOOD PARTS or you can buy CHEAP PARTS, but you can't buy GOOD CHEAP PARTS.

  5. #5
    Join Date
    Feb 2006
    Posts
    7063

    Re: Theres got to be a better way

    Quote Originally Posted by Steve Seebold View Post
    I don't care for doing it that way because I don't understand it.
    Perhaps because a G53 move would be completely useless in this instance. G53 moves in Machine Coordinates, rather than Work Coordinates. Once he presses CycleStart, it will re-run the program exactly how, and where, it did the first time.

    G52 can be used to effect a temporary shift in Work Coordinates, which has the same effect as shifting your fixture zeros to a new point, for cutting a second identical part using the same G-code.

    Regards,
    Ray L.

  6. #6
    Join Date
    Jun 2016
    Posts
    22

    Re: Theres got to be a better way

    I would use G10 L2. Let me know if you are still looking for an "easier" way, and I'll explain.

  7. #7
    Join Date
    Apr 2013
    Posts
    1788

    Re: Theres got to be a better way

    I'll bite! Please explain.

  8. #8
    Join Date
    Jun 2016
    Posts
    22

    Re: Theres got to be a better way

    I think you have a Tormach machine, so I wrote a little routine to help explain what I'm talking about. The way it works is, (in this case), I want to drill a grid of holes, (although the hole drilling code could be replaced with any operation). So, I would probe my work so that so that G59 X0,Y0 would be the position of my first hole, or at least I know the position of my first hole relative to my G59 X0,Y0,Z0. Then I go into the Conversational Programming and set it up to drill 1 hole using G59.1 offsets at X0,Y0. Using G10 L2, and some named variables, I can copy G59's work offset values over to G59.1, and then manipulate them any way I want, (including rotation). One nice thing about this is that I never have to change my orginal G59 offsets which might be probed to the corner of a vice or something. so, anyway, to copy the offsets over I use code like this to replace the simple G59.1 line that was created by the conversational programming :

    (WORK PROBED TO G59 CONVERTED TO G59.1)
    #<59X>=#5321 (GET G59 X WORK COORDINATE)
    #<59Y>=#5322 (GET G59 Y WORK COORDINATE)
    #<59Z>=#5323 (GET G59 Z WORK COORDINATE)

    So, now I can modify the variables "#<59X>,#<59Y>,#<59Z>, and then load them into work offset table G59.1, which is in position P7. G54 is P1 through G59.3 which is P9. That code is this:
    G10 L2 P7 X#<59X> Y#<59Y> Z#<59Z> R0 (COPY MODIFIED G59 OFFSETS TO G59.1)
    G59.1 (USE G59.1 FOR WORK OFFSETS)
    Now, what I just did makes G59.1 offsets identical to G59 offsets, but if I had written:
    #<59X>=#5321 (GET G59 X WORK COORDINATE)
    #<59Y>=#5322 (GET G59 Y WORK COORDINATE)
    #<59Z>=#5323 (GET G59 Z WORK COORDINATE)
    #<59X>=[#<59X>+1.0]
    #<59Y>=[#<59Y>+1.0]
    #<59Z>=[#<59Z>+0.0]
    G10 L2 P7 X#<59X> Y#<59Y> Z#<59Z> R0 (COPY MODIFIED G59 OFFSETS TO G59.1)
    G59.1 (USE G59.1 FOR WORK OFFSETS)
    Now, G59.1 X,Y offsets are 1 inch in the positive direction from G59's but the Z offset was left alone. As a side note, had I also written that: #<59Z>=[#<59Z>+0.5], then I could do a "dry run" 0.5 inches above the work, and then go back and change it to #<59Z>=[#<59Z>+0.0], to do the actual run. Also, the "R" value in the G10 L2 statement is rotation around the center point, so if I wanted to do a 4 cornered bolt circle pattern of 4 holes on a 2 inch radius I would just have the position of the first hole be X0,Y2, and then drill the holes like this:
    G10 L2 P7 R45
    Drill
    G10 L2 P7 R135
    Drill
    G10 L2 P7 R225
    Drill
    G10 L2 P7 R315
    Drill
    I wouldn't have to do the math what the X,Y coordinates should be for each hole because G10 L2 will do it for me.
    So, getting back to the "step & repeat", and my grid of holes, I would write the code like below. If you test it out, for fixturing, you would just replace my drill routine with your code, and change the following parameters:
    #<NUMBER_OF_OPERATIONS_X>=5
    #<NUMBER_OF_OPERATIONS_Y>=3
    #<DISTANCE_BETWEEN_OPERATIONS_X>=0.5
    #<DISTANCE_BETWEEN_OPERATIONS_Y>=0.5
    to whatever you want for your fixture. So here it is:


    (----- Start of G-code -----)

    G17 G90 (XY Plane, Absolute Distance Mode)
    G64 P 0.0050 Q 0.0010 (Path Blending)
    G20 (units in inches)
    G30 (Go to preset G30 location)


    T26 M6 G43 H26
    S 5000 (RPM)
    M8 (Coolant ON)
    M3 (Spindle ON, Forward)
    F 10.00 (Z Feed, inches/minute)

    #<NUMBER_OF_OPERATIONS_X>=5
    #<NUMBER_OF_OPERATIONS_Y>=3
    #<DISTANCE_BETWEEN_OPERATIONS_X>=0.5
    #<DISTANCE_BETWEEN_OPERATIONS_Y>=0.5


    #<OPERATION_COUNTER>=0
    #<ROW_COUNTER>=0
    #<X_INCREMENT>=0
    #<Y_INCREMENT>=0
    #<SWITCH_X_DIRECTION>=1

    o101 WHILE [#<ROW_COUNTER> LT [#<NUMBER_OF_OPERATIONS_Y>]]

    (WORK PROBED TO G59 CONVERTED TO G59.1)
    #<59X>=#5321 (GET G59 X WORK COORDINATE)
    #<59Y>=#5322 (GET G59 Y WORK COORDINATE)
    #<59Z>=#5323 (GET G59 Z WORK COORDINATE)
    #<59X>=[#<59X>+#<X_INCREMENT>]
    #<59Y>=[#<59Y>+#<Y_INCREMENT>]
    #<59Z>=[#<59Z>+0.0]
    G10 L2 P7 X#<59X> Y#<59Y> Z#<59Z> R0 (COPY MODIFIED G59 OFFSETS TO G59.1)
    G59.1 (USE G59.1 FOR WORK OFFSETS)

    (DRILL THE HOLE)
    G0 X 0.0000 Y 0.0000
    G0 Z 0.2000 (Z Clear)
    G90 G98 (Absolute Distance Mode, Canned return to Z or R)
    G83 Z -0.125 R 0.0000 Q 0.125 (Canned Peck Drill)
    G80 (Cancel canned cycle)
    G0 Z 0.2000

    (INCREMENT THE COUNTERS AND DISTANCES)
    #<OPERATION_COUNTER>=[#<OPERATION_COUNTER>+1]
    o102 IF[#<OPERATION_COUNTER> MOD #<NUMBER_OF_OPERATIONS_X> EQ 0]
    #<ROW_COUNTER>=[#<ROW_COUNTER>+1]
    #<SWITCH_X_DIRECTION>=[#<SWITCH_X_DIRECTION>*-1]
    #<Y_INCREMENT>=[#<Y_INCREMENT>+#<DISTANCE_BETWEEN_OPERATIONS_Y>]
    o102 ELSE
    #<X_INCREMENT>=[#<X_INCREMENT>+[#<DISTANCE_BETWEEN_OPERATIONS_X>*#<SWITCH_X_DIRECT ION>]]
    o102 ENDIF

    o101 ENDWHILE

    (RESET G59.1 OFFSETS BACK TO ORIGINAL G59 OFFSETS FOR SAFTY'S SAKE)
    #<59X>=#5321 (GET G59 X WORK COORDINATE)
    #<59Y>=#5322 (GET G59 Y WORK COORDINATE)
    #<59Z>=#5323 (GET G59 Z WORK COORDINATE)
    G10 L2 P7 X#<59X> Y#<59Y> Z#<59Z> R0 (COPY MODIFIED G59 OFFSETS TO G59.1)
    G59.1 (USE G59.1 FOR WORK OFFSETS)


    M9 (Coolant OFF)
    M5 (Spindle OFF)

    G30 Z 0.2 (Go in Z only to preset G30 location)
    G30 (Go to preset G30 location)

    M30 (End of Program)

  9. #9
    Join Date
    Jun 2016
    Posts
    22

    Re: Theres got to be a better way

    Kstrauss,
    I'm attaching a PDF that shows all the "P" numbers as well as the X,Y,Z, etc. variable numbers for work offset tables 54-59.3. I think I have the same info for Fanuc, (or at least HAAS in Fanuc mode), if you have any HAAS machines.

  10. #10
    Join Date
    Aug 2015
    Posts
    58

    Re: Theres got to be a better way

    Thanks GenInt for taking the time to explain that and give an example. I've been trying to think of a way to do this. It only hurt my brain a little to understand your explanation.

  11. #11
    Join Date
    Jun 2016
    Posts
    22

    Re: Theres got to be a better way

    Your welcome extdrive, Are you running a Tormach with PathPilot?

  12. #12
    Join Date
    Aug 2015
    Posts
    58

    Re: Theres got to be a better way

    Yep

  13. #13
    Join Date
    Aug 2015
    Posts
    58

    Re: Theres got to be a better way

    Quote Originally Posted by SCzEngrgGroup View Post
    Perhaps because a G53 move would be completely useless in this instance. G53 moves in Machine Coordinates, rather than Work Coordinates. Once he presses CycleStart, it will re-run the program exactly how, and where, it did the first time.

    G52 can be used to effect a temporary shift in Work Coordinates, which has the same effect as shifting your fixture zeros to a new point, for cutting a second identical part using the same G-code.

    Regards,
    Ray L.

    I was unfamiliar with G52 until you mentioned it. After checking it out a little it seems like a great and simple solution for temporarily changing the work offsets to do multiple parts. Any reasons I should avoid this and use G10 L2 instead? I noticed the documentation does indicate G52 can not be used in conjunction with G92. G92 is apparently used by the internal control software. Am I going to run into conflicts if I try to use G52?

  14. #14
    Join Date
    Jun 2016
    Posts
    22

    Re: Theres got to be a better way

    Ok, well, as you have probably already figured out, there's another big reason to use the G10 L2 method using 1 set of offsets (such as G59), as a locked in position, and another set of offsets for a "floater". Let's suppose that you want a nice press fit for an R8 flange bearing in a piece of 0.250 inch thick plate, and you want it centered in a spot that is X-1, Y-1.5 away from your G59 offsets that are probed to the right hand side of your vice in X, to the inside of the fixed jaw for Y, and are probed to the surface that your parallels sit on down between the jaws of the vice. So, you go in to your conversational programming or CAM software and you indicate that you want to use G59, and you want the center of your pocket to be X-1, Y-1,5, and you put in the other parameters, (depth, stepover, diameter, etc), and then you generate the code. Here's the problem. Since PathPilot, and most CAM programs generate all the code for that pocket in absolute coordinates, that code that you just generated, and maybe tweaked, is only good for when you want to do the same pocket exactly X-1, Y-1.5 away from a set work coordinate, be it G59, G54, or some other coordinate. Futhermore, if you also want the same bearing pocket a little further down the piece, say, X-3, Y-1.5, you have to go in and generate new code for that bearing pocket as well.

    HOWEVER, if you go in and, (using any set of work coordinates), and specify that you want the center of that bearing pocket to be X0, Y0, and then you can use G10 L2 to put that pocket anywhere you want. And duplicate it and put the second one anywhere you want. You also know that relative to your work offsets, (G59 in this case), that if you have that 0.250 thick piece of plate sitting on a set of 1 inch parallels, that your Z to the surface is +1.25 from your probed offsets. In fact the reason you use 2 sets of offsets within the G10 L2 routine, is so that you can leave the one that you took the time to probe alone, so that you will always know what it's origin is. So, in short, generate the code for pocket at X0, Y0 then go into the code, and where it says "G59" or "G54", or whatever, replace that with:

    #<59X>=#5321 (GET G59 X WORK COORDINATE)
    #<59Y>=#5322 (GET G59 Y WORK COORDINATE)
    #<59Z>=#5323 (GET G59 Z WORK COORDINATE)
    #<59X>=[#<59X>-1.0]
    #<59Y>=[#<59Y>-1.5]
    #<59Z>=[#<59Z>+1.25]
    G10 L2 P7 X#<59X> Y#<59Y> Z#<59Z> R0 (COPY MODIFIED G59 OFFSETS TO G59.1)
    G59.1 (USE G59.1 FOR WORK OFFSETS)


    and then the code for pocket 1 goes here.

    And then,

    #<59X>=#5321 (GET G59 X WORK COORDINATE)
    #<59Y>=#5322 (GET G59 Y WORK COORDINATE)
    #<59Z>=#5323 (GET G59 Z WORK COORDINATE)
    #<59X>=[#<59X>-3.0]
    #<59Y>=[#<59Y>-1.5]
    #<59Z>=[#<59Z>+1.25]
    G10 L2 P7 X#<59X> Y#<59Y> Z#<59Z> R0 (COPY MODIFIED G59 OFFSETS TO G59.1)
    G59.1 (USE G59.1 FOR WORK OFFSETS)


    and then the same code for pocket 2 goes here.


    and then if you find that that second bearing really should have been 0.01 inch closer to the first bearing, then you just change this code so that it reads "#<59X>=[#<59X>-2.99]

    AND if you want to use the same code for another R8 bearing pocket in a different position a month from now you can do that! See what I mean?

    I use this method for almost every bit of code that I generate.

  15. #15
    Join Date
    Jun 2016
    Posts
    22

    Re: Theres got to be a better way

    [QUOTE=extdrive;1901730]I was unfamiliar with G52 until you mentioned it. After checking it out a little it seems like a great and simple solution for temporarily changing the work offsets to do multiple parts. Any reasons I should avoid this and use G10 L2 instead? I noticed the documentation does indicate G52 can not be used in conjunction with G92. G92 is apparently used by the internal control software. Am I going to run into conflicts if I try to use G52?[/QUOT

    extdrive, to answer your question about G52, it should work fine, but anything that can have an effect on G92 makes me nervous. Below is a warning that I copied from linuxcnc.org.
    Caution As a temporary offset, set and unset within the localized scope of a part program, in other g-code interpreters G52 does not persist after machine reset, M02 or M30. In LinuxCNC, G52 shares parameters with G92, which, for historical reasons, does persist these parameters. SeeG92 Persistence Cautions below.

    Caution G52 and G92 share the same offset registers. Therefore, setting G52 will override any earlier G92 setting, and G52 will persist across machine reset when G92 persistence is enabled. These interactions may result in unexpected offsets. See G92 and G52 Interaction Cautions below.

  16. #16
    Join Date
    Aug 2015
    Posts
    58

    Re: Theres got to be a better way

    Quote Originally Posted by GenInt View Post
    extdrive, to answer your question about G52, it should work fine, but anything that can have an effect on G92 makes me nervous. Below is a warning that I copied from linuxcnc.org.
    Caution As a temporary offset, set and unset within the localized scope of a part program, in other g-code interpreters G52 does not persist after machine reset, M02 or M30. In LinuxCNC, G52 shares parameters with G92, which, for historical reasons, does persist these parameters. SeeG92 Persistence Cautions below.

    Caution G52 and G92 share the same offset registers. Therefore, setting G52 will override any earlier G92 setting, and G52 will persist across machine reset when G92 persistence is enabled. These interactions may result in unexpected offsets. See G92 and G52 Interaction Cautions below.
    Also it looks like G52 isn't included in any of the pathpilot documentation. Might not even be supported in pathpilot. G10 L2 seems like a safer route. Thanks for all the input GenInt.

  17. #17
    Join Date
    Jun 2008
    Posts
    1082

    Re: Theres got to be a better way

    It seems like having the G52 offsets persistent is a crash waiting to happen. If I set G54 to X1.23 Y3.45 Z5.67, I wouldn't want the G52 offsets I applied to G57 the day before to alter it to X0.23 Y1.95 Z2.67! That's insane.

    Setting G59.1 seems like a good alternative, albeit requiring more lines of code. If I was running LinuxCNC I'd be damn sure to fix the persistence flaw by setting "DISABLE_G92_PERSISTENCE = 1" in whatever ini file they're talking about as quickly as I could.

    Could the eight lines above be simplified (well, depending on your definition of "simple") to something like the following..?
    Code:
    G10 L2 P7 X#5321-3. Y#5322-1.5 Z#5323+1.25 R0 (COPY MODIFIED G59 OFFSETS TO G59.1)
    G59.1 (USE G59.1 FOR WORK OFFSETS)
    In other words, can the math be done inside the G10 line?

  18. #18
    Join Date
    Jun 2016
    Posts
    22

    Re: Theres got to be a better way

    Quote Originally Posted by Hirudin View Post
    It seems like having the G52 offsets persistent is a crash waiting to happen. If I set G54 to X1.23 Y3.45 Z5.67, I wouldn't want the G52 offsets I applied to G57 the day before to alter it to X0.23 Y1.95 Z2.67! That's insane.

    Setting G59.1 seems like a good alternative, albeit requiring more lines of code. If I was running LinuxCNC I'd be damn sure to fix the persistence flaw by setting "DISABLE_G92_PERSISTENCE = 1" in whatever ini file they're talking about as quickly as I could.

    Could the eight lines above be simplified (well, depending on your definition of "simple") to something like the following..?
    Code:
    G10 L2 P7 X#5321-3. Y#5322-1.5 Z#5323+1.25 R0 (COPY MODIFIED G59 OFFSETS TO G59.1)
    G59.1 (USE G59.1 FOR WORK OFFSETS)
    In other words, can the math be done inside the G10 line?
    Hirudin,
    To answer your coding question, as with any coding, (in any language), there's always 10 different ways to skin the same cat, although, in order to have the correct syntax, I think you would need to bracket your expressions so that it would read "G10 L2 P7 X[#5321-3.0] Y[#5322-1.5] Z[#5323+1.25]". Also, you don't really need the "G59.1" statement if you had previously set G59.1 as the work coordinates that you wanted to use. I just do that way for safety. It's the "P7" that's referencing offsets G59.1. P6 would reference G59, P5 would reference G58, on down to P1 which references G54.

    So, code like this:
    G59.1
    Drill a hole at X0,Y0. (or perform any other operation at G59.1 X0,Y0)
    G10 L2 P7 X2.0
    Drill another hole at X0,Y0.

    Would drill 2 holes 2 inches apart in the X direction. However this code:

    G54
    Drill a hole at X0,Y0. (or perform any other operation at G54 X0,Y0)
    G10 L2 P7 X2.0
    Drill another hole at X0,Y0.

    Would drill 2 holes at the same location, i.e. G54 X0,Y0, because you manipulated the G59.1 work coordinates, but you're working in G54 work coordinates. The code to drill 2 holes 2 inches apart using G54 work coordinates would be:

    G54
    Drill a hole at X0,Y0. (or perform any other operation at G54 X0,Y0)
    G10 L2 P1 X2.0
    Drill another hole at X0,Y0.

    Note the P1 instead of P7. Note also that if you do it this way, (instead of using a "floater" Gxx offset, you are modifying the G54 offset table.

    By adding the "G59.1" statement after the G10 L2 P7 statement, I'm just making sure that the machine is working in the work coordinate space that I'm manipulating.

    I would say that it is probably a good idea to just allocate 1 set of work coordinates to be a "floater", (such as G59.1, - which is P7 in the G10 L2 statement) and leave the rest of them alone as they may be probed to fixed points that you want to keep. Also, the reason that I make a habit of assigning the original coordinates of a work space to named variables is that I may want to manipulate those variables within my code. For an example, let's say that I have my G54 work offsets probed to the left side of my vice in the X direction, to the inside of the fixed jaw in the Y direction, and to the bottom of the vice between the jaws, (the surface that I place my parallels on), in the Z direction. Now, let's say that I have a 1 inch wide, 6 inch long, 1/4 inch thick piece of aluminum, and I want to drill 1/16 inch holes, spaced 1/8 inch apart, all the way down the 6 inch X direction and centered on the 1 inch Y direction.

    So, the first thing I do is to divide 6 by 0.125 and that gives me 48 spaces, or 47 holes. Rather then go into my conversational and put in 47 different coordinates, I just generate one hole drilled at X0,Y0 using any coordinate workspace, (because I'm going to replace that workspace when I edit the code). Now, with my piece of plate lined up with the left hand side of my vice, and sitting on 1 inch parallels, I take the hole drilling code generated by the conversational and use it like this:

    This replaces the Gxx value generated by conversational:

    #<MyX>=#5221 (GET G54 X WORK COORDINATE)
    #<MyY>=#5222 (GET G54 Y WORK COORDINATE)
    #<MyZ>=#5223 (GET G54 Z WORK COORDINATE)
    #<MyX>=[#<MyX>+0.0] (Don't do anything with #<MyX> yet, but put it here for clarity)
    #<MyY>=#<MyY>-0.5] (#<MyY> will center the holes in the Y direction)
    #<MyZ>=[#<MyZ>+1.25] (because I have a 1/4 inch plate sitting on 1 inch paralells)

    G10 L2 P7 X#<MyX> Y#<MyY> Z#<MyZ> R0 (COPY MODIFIED G54 OFFSETS TO G59.1, - G59.1 because P=7 in the statement)
    G59.1 (USE G59.1 FOR WORK OFFSETS)

    Then just do a little loop:
    #<COUNTER>=0
    o101 WHILE [COUNTER LT 47]
    #<COUNTER>=[#<COUNTER>+1]
    #<MyX>=[#<MyX>+0.125]
    G0 X#<MyX> Y#<MyY>

    DRILL CODE GOES HERE

    G0 Z0.2 (RAISE THE TIP OF THE DRILL UP TO MOVE TO THE NEXT HOLE)

    o101 END WHILE

    You may already know much of what I've written here, but I want to be as clear as possible for others that may read these posts and may want to do a little macro programming as well. Also, as far as the amount of code that you may have to write to do things like this, after you get a few done, cut & paste is pretty quick.

  19. #19
    Join Date
    May 2008
    Posts
    77

    Re: Theres got to be a better way

    a million and one ways to skin a cat but wouldn't it just be easier to make the program a subroutine to update the workoff. If you wanted to add a "tweak" number so that you can shift all positions a certain amount but adding a variable like #(SHIFTX), and #(SHIFTY), then added that to each O1485 call [4] [0]. Making it look like O1485 call [4+#(SHIFTX] [0+#SHIFTY]

    G54 Would be anchor location. Everything would be relative from this location. Probe or sweep in this location.

    Code:
    O1485 sub
    
    G10 L2 P2 X[#1+#5221] Y[#2+#5222]  (updates G55 to offsets passed from main routine )
    ( Pass thru number + anchor location )
    
    (REPLICAPARTS.COM)
    (RPC-0005)
    (SEATBELT TRIM RING)
    N100G90G80G40G0 
    T10M6(5/8 DIA. END MILL)
    G55X.75Y-1.S3000M3
    G43Z.1H10T11D31 
    N45G92X0Y0
    X-.375Y1. 
    G1Z0F30.M8
    ...
    ...
    **REST OF THE MACHINE CODE***
    
    O1485 endsub



    In the main routine you have

    Code:
    O1480 
    (REPLICAPARTS.COM)
    (RPC-0005)
    (SEATBELT TRIM RING)
    (ON FIXTURE 10 AT A TIME.)
    ( calls subprogram O1485 )
    
    
    ( FIRST POSITION )
    O1485 call [0] [0] 
    
    ( 2ND POSITION )
    O1485 call [2] [0] 
    
    ( 3RD POSITION )
    O1485 call [4] [0] 
    
    ( 4TH POSITION )
    O1485 call [6] [0] 
    
    ( 5TH POSITION )
    O1485 call [8] [0] 
    
    ( 2nd ROW )
    
    ( FIRST POSITION )
    ( 1ST BRACKET X, 2ND Y ) 
    O1485 call [0] [-2] 
    
    ( 7TH POSITION
    O1485 call [2] [-2] 
    
    ( 8TH POSITION )
    O1485 call [4] [-2] 
    
    ( 9TH POSITION )
    O1485 call [6] [-2] 
    
    ( 10TH POSITION )
    O1485 call [8] [-2] 
    M30 
    %
    a nice thing i like about doing it this way would be that you can skip a location pretty easy. Just go the which ever position you want and block skip it. This makes things a lot easier if other people are going to be running the program as well.

  20. #20
    Join Date
    Jun 2008
    Posts
    1082

    Re: Theres got to be a better way

    GenInt, I appreciate the thorough explanations, thanks! I think I'll stick with G52, since it's already working for me, but if I ever start using LinuxCNC (or PathPilot, I guess) I hope I remember this thread and turn off that nutty persistence setting.

    soymilk - Seems like skipping an instance could be useful. I've thought about adding that to my array macro, but a way to do it cleanly/efficiently hasn't become apparent to me. Ideally you'd be able to simply write out a comma separated list of numbers and the macro would parse them out and skip each one. The best my macro will do at the moment is skip entire columns at the beginning or end (by having it start at a column other than #1 or end at a column other than the last one). It would be real easy to manually skip some instances if you were writing out each set of offsets, but doing many pieces would get tedious, especially if the offsets weren't whole numbers. I'd be afraid of making some boneheaded mistake, like accidentally incrementing one of the offsets two times but only incrementing the other once. I wonder if the missing parenthesis in the 7th position would throw an error. :/

Page 1 of 2 12

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
  •