I need to run 100’s of small parts from aluminum sheets (1/8 to 1/2 thk). I have the G-code for a single part and want to make a macro to make a grid of parts, e.g. 3 parts in X by 2 parts in Y, by incrementing the work offsets (using G92). I’m close, but am struggling to “get it right”. It seems this is a common problem that should have been already solved. Does anybody have any example code they want to share? This is not high-volume production, so I don’t need to optimize tool changes, etc. Just repeating the part software (called by an M98) would be fine. Thanks in advance!
Use Marco Variables, and make this a program loaded in your machine. If not using a Haas, change these macro variable numbers to match whatever free ones you have on your control.
(*** This will be a sub-program called out at each tool change ***)
O05002 (MULTIPLE WORK OFFSET SETUP);
(#500 IS THE STARTING WORK OFFSET);
(#501 IS THE NUMBER OF OFFSETS);
(#502 IS THE CURRENT WORK OFFSET);
(#504 IS THE FINAL WORK OFFSET);
#504= [ #500 + #501 - 1 ];
IF [ [ [ #504 ] GE 60. ] AND [ [ #500 + #501 ] LT 111. ] ] THEN #504= [ #500 + #501 + 49. ];
IF [ #502 EQ 60. ] THEN #502= 110.;
G [ #502 ]; (*** where each operation is pulling its Work Coordinate from ***)
#502 = [ #502 + 1. ];
M99;
(*** Your main program should have this at the header ***)
(STARTING WORK OFFSET)
#500= 54 (*** Most common work offset to start on )
(NUMBER OF OFFSETS)
#501= 1 ( how many parts you want to loop ***)
(SET INITIAL OFFSET)
#502= #500
N100
M98 P5002
(FACE)
N20 G80 G40 G0 G20
T20 M06 (2" Iscar Shell Mill)
G0 G90 X-.99 Y-.5 S4000 M3
G43 H20 Z1.0 T02
M8
Z.1
G17 G1 Z-.01 F100.
X36.74 F100.
G0 Z1.
IF[ #502 LE #504 ]GOTO100
#502= #500
M9
G90
M5
M1
If you are manually programming, you could place your part program as a sub routine and then add 6 work offset locations and then call the sub for each work offset. Multiple Parts using Work Offsets, Subroutines and Sequential Serial Numbers - YouTube
Thanks for the reply! I am looking for a macro where I push the green button once and the mill cranks out a grid of n x m parts (e.g. 2 parts tall by 3 parts wide), with only one work offset.
Yitz, My experience with this has been that when using an m98 and m99 has been that I had to do my regular routine in all incremental moves. (G91). This can be done, but it was always tricky to get just right, and can be tough to troubleshoot if you are unfamiliar. However, the concept of incremental G91 moves is pretty powerful. Especially if you don’t have a CAM system. In MasterCAM, you can copy and offset before you post the code.
Best of luck.,
Eddie
Eddie - Thanks for the reply! Yes, it sounds like your approach might work. However, I think the answer lies in work offset transformations. I’m making some progress on the code, but still have some tweaking to do. Thanks again!
IT all depends on your machine and the G-code dialect used.
Normal G-codes are the same across machines but special things like using parameters and stuff like IF or WHILE loops highly depend on your machine.
Using G92 could be a good option. Just have 2 while loops and increment the X and Y offsets using G92
I used this (on a Haas VF3) to probe a grid using my Renishaw probe.
The code below is what I used, that could be a nice starting point.
The G65 P9810 line performs a move to the given X Y and #1 #2 are the parameters used
G65 P9811 is the probing command and the DPRNT line prints out a line with the X, Y and Z (probed) position to a file (the [33] specifies that each number is printer with 3 digits before the decimal point a 3 after the decimal point
%
O2002
G04 P1.
G103 P1
DPRNT[------------------]
T30 M06 G43 H30
G103 P1
G65 P9832 (switch probe on)
G65 P9810 Z5. F3000.
#1=25. (X var)
#2= 25. (Y var)
DPRNT[Start]
WHILE [#2 LT 375. ] DO2
WHILE [#1 LT 400. ] DO1
G65 P9810 X#1 Y#2
G65 P9811 Z0
DPRNT[#1[33],*#2[33],*#187[33]]
#1=#1+50.
END1
#1= 25.
#2=#2 + 25.
END2
G103
M30
Rob - Thanks for replying. Yep, I am using nested while loops, although I might switch to nested M97 P100 L#5 lines as my “counter”. Seems more straightforward to me some how. I will have to look up DPRNT; seems useful. Although I think I would like to print values to the counter window…
Use Marco Variables, and make this a program loaded in your machine. If not using a Haas, change these macro variable numbers to match whatever free ones you have on your control.
(*** This will be a sub-program called out at each tool change ***)
O05002 (MULTIPLE WORK OFFSET SETUP);
(#500 IS THE STARTING WORK OFFSET);
(#501 IS THE NUMBER OF OFFSETS);
(#502 IS THE CURRENT WORK OFFSET);
(#504 IS THE FINAL WORK OFFSET);
#504= [ #500 + #501 - 1 ];
IF [ [ [ #504 ] GE 60. ] AND [ [ #500 + #501 ] LT 111. ] ] THEN #504= [ #500 + #501 + 49. ];
IF [ #502 EQ 60. ] THEN #502= 110.;
G [ #502 ]; (*** where each operation is pulling its Work Coordinate from ***)
#502 = [ #502 + 1. ];
M99;
(*** Your main program should have this at the header ***)
(STARTING WORK OFFSET)
#500= 54 (*** Most common work offset to start on )
(NUMBER OF OFFSETS)
#501= 1 ( how many parts you want to loop ***)
(SET INITIAL OFFSET)
#502= #500
N100
M98 P5002
(FACE)
N20 G80 G40 G0 G20
T20 M06 (2" Iscar Shell Mill)
G0 G90 X-.99 Y-.5 S4000 M3
G43 H20 Z1.0 T02
M8
Z.1
G17 G1 Z-.01 F100.
X36.74 F100.
G0 Z1.
IF[ #502 LE #504 ]GOTO100
#502= #500
M9
G90
M5
M1