Hey all. I’ve seen related questions come up multiple times about repeating cuts at different offsets. I managed to create a program that will allow you to setup different offsets relative to the main offset (G54). You then place your main gcode in a subroutine and call it each time you change the current offset. Here is the code:
G90 ; Absolute
G20 ; Inches
M05 ; Stop spindle
M0 (MSG, Insert 1/16" endmill)
T112 M06 ; Set tool to 1/16" endmill
M3S18000 ; Start spindle and set to 18000 RPM
(Set the other work offsets according to G54 in 5" increments to the right)
G10 L2 P2 X[#5221+5] Y[#5222] ; P2 is a reference to G55
G10 L2 P3 X[#5221+10] Y[#5222] ; P3 is a reference to G56
G10 L2 P4 X[#5221+15] Y[#5222] ; P4 is a reference to G57
G10 L2 P5 X[#5221+20] Y[#5222] ; P5 is a reference to G58
G10 L2 P6 X[#5221+25] Y[#5222] ; P6 is a reference to G59
(Main cut subroutine)
o100 sub
==== ALL OF YOUR MOVEMENT AND CUTTING GCODE GOES HERE ====
o100 endsub
(Set to each coord system and run subroutine)
G54 ; Set current coord system to G54
o100 call
G55 ; Set current coord system to G55
o100 call
G56 ; Set current coord system to G56
o100 call
G57 ; Set current coord system to G57
o100 call
G58 ; Set current coord system to G58
o100 call
G59 ; Set current coord system to G59
o100 call
(Set work coords back to G54)
G54
(Stop spindle and end program)
M05
M02
The first 10 lines are normal setup in most gcode scripts
11 - 15 is setting up the actual offset coordinates
18 - 22 is a subroutine that can be called multiple times later in the script. This is where the rest of your normal gcode would go. Note, this should exclude your startup and shutdown gcode
25 - 36 is used to select each offset as the current offset and then run the subroutine
39 - Sets machine back to using G54 (default) offset
43+ is just your normal shutdown code
#5221 and #5222 are global variables used to reference the coordinates of your current standard offset (G54).
Hope this helps!!!