- GCode and Part Programs
- O Codes (subroutines) and NGCGUI
- calling subroutine from G54, G55, G56, but it acts weird
calling subroutine from G54, G55, G56, but it acts weird
- johnbump
- Away
- New Member
-
Less
More
- Posts: 16
- Thank you received: 1
23 Nov 2025 00:19 #339013
by johnbump
calling subroutine from G54, G55, G56, but it acts weird was created by johnbump
I touch off G54, X=0, Y=0, Z=0. Then I run my program, which uses G10 to set up work offsets, in theory every 30mm away from G54, each calling the same subroutine. (Kinda weird subroutine: I'm trying to cut t-slots in the edge of oak and it tears out, so I'm finessing the toolbit into the wood.)
What I'm seeing is that I set all three axes at 0, then it switches to G55, and I very strongly think the G10 offset should read G10 L20 P2 X-30 Y0 Z0. If I do that, it runs to X-30, Y0, Z3. In all the subsequent, identical, work offsets, it also runs to Z3.
If I touch off X0 Y0 Z0 in G54, and then instead do, as the below program shows, G10 L20 P2 X-30 Y0 Z3, it runs perfectly.
I do not understand where three millimeters in Z is coming from, when both X and Y work exactly as I expected.
Is there a secret stateful variable somewhere I need to reset?
For that matter, is there a better way to do this? This is my first time trying work offsets. I've always previously either used a cam program or written multiple sites by hand as a single file without a subprogram, but I thought it would be fun to try learning work offsets.
Thanks for any advice. LinuxCNC, version 2.9.6.
G17 G21 G40 G49 G80 G90
M08
G54
M05
M09M6 T1
G10 L20 P1 X0 Y0 Z0
G10 L20 P2 X-30 Y0 Z3
G10 L20 P3 X-60 Y0 Z3
G10 L20 P4 X-90 Y0 Z3
G10 L20 P5 X-120 Y0 Z3
G10 L20 P6 X-150 Y0 Z3
o199 sub
G0 X2 Y-20
G1 Z-8 F20
G1 Y-12 F10
G0 Y-20
G0 X3.237
G1 Y-12 F10
G1 y-20 F40
G0 x-3.237
G1 y0 F10
g2 x0 Y3.237 R3.237
g2 x3.237 Y0 R3.237
g1 y-20
g0 z2
o199 endsub
G55
o199 call
G56
o199 call
G57
o199 call
G58
o199 call
G59
o199 call
G0 Z10
G54 G0 X0 Y0
M2
What I'm seeing is that I set all three axes at 0, then it switches to G55, and I very strongly think the G10 offset should read G10 L20 P2 X-30 Y0 Z0. If I do that, it runs to X-30, Y0, Z3. In all the subsequent, identical, work offsets, it also runs to Z3.
If I touch off X0 Y0 Z0 in G54, and then instead do, as the below program shows, G10 L20 P2 X-30 Y0 Z3, it runs perfectly.
I do not understand where three millimeters in Z is coming from, when both X and Y work exactly as I expected.
Is there a secret stateful variable somewhere I need to reset?
For that matter, is there a better way to do this? This is my first time trying work offsets. I've always previously either used a cam program or written multiple sites by hand as a single file without a subprogram, but I thought it would be fun to try learning work offsets.
Thanks for any advice. LinuxCNC, version 2.9.6.
G17 G21 G40 G49 G80 G90
M08
G54
M05
M09M6 T1
G10 L20 P1 X0 Y0 Z0
G10 L20 P2 X-30 Y0 Z3
G10 L20 P3 X-60 Y0 Z3
G10 L20 P4 X-90 Y0 Z3
G10 L20 P5 X-120 Y0 Z3
G10 L20 P6 X-150 Y0 Z3
o199 sub
G0 X2 Y-20
G1 Z-8 F20
G1 Y-12 F10
G0 Y-20
G0 X3.237
G1 Y-12 F10
G1 y-20 F40
G0 x-3.237
G1 y0 F10
g2 x0 Y3.237 R3.237
g2 x3.237 Y0 R3.237
g1 y-20
g0 z2
o199 endsub
G55
o199 call
G56
o199 call
G57
o199 call
G58
o199 call
G59
o199 call
G0 Z10
G54 G0 X0 Y0
M2
Please Log in or Create an account to join the conversation.
- GCode and Part Programs
- O Codes (subroutines) and NGCGUI
- calling subroutine from G54, G55, G56, but it acts weird
Time to create page: 0.050 seconds