- 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
- Offline
- New Member
-
Less
More
- Posts: 18
- 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.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4613
- Thank you received: 2042
23 Nov 2025 17:27 - 23 Nov 2025 17:28 #339063
by Aciera
touching off in G54 will actually run 'g10 l20 p1 z0' which will set the z-offset value in G54 such that the axis position is equal to zero. This is the value you would need in the other offset systems as well. Which I guess is 3.
Replied by Aciera on topic calling subroutine from G54, G55, G56, but it acts weird
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.
touching off in G54 will actually run 'g10 l20 p1 z0' which will set the z-offset value in G54 such that the axis position is equal to zero. This is the value you would need in the other offset systems as well. Which I guess is 3.
Last edit: 23 Nov 2025 17:28 by Aciera.
Please Log in or Create an account to join the conversation.
- johnbump
- Offline
- New Member
-
Less
More
- Posts: 18
- Thank you received: 1
25 Nov 2025 02:30 #339179
by johnbump
Replied by johnbump on topic calling subroutine from G54, G55, G56, but it acts weird
I wasn't good with my phrasing. I touch off G54, and explicitly set G10 L20 P1 X0 Y0 Z0 to force G54 (I may not need to do this? because it's what automatically happens when I touch off if I have the popup set to G54?), but don't ever use that except for touchoff/part location. (I *think* this is how I should be doing this?) Then I subsequently set up G10 P2, G10 P3, and so forth, and only machine at the work offsets referenced by those.
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4613
- Thank you received: 2042
25 Nov 2025 06:43 #339187
by Aciera
Replied by Aciera on topic calling subroutine from G54, G55, G56, but it acts weird
'P0' will set the currently active offsets, while 'P1','P2' ... will set the values of a particular offset system.
You could also stay in G54 and use different G52 offsets.
You could also stay in G54 and use different G52 offsets.
Please Log in or Create an account to join the conversation.
- johnbump
- Offline
- New Member
-
Less
More
- Posts: 18
- Thank you received: 1
28 Nov 2025 00:43 #339359
by johnbump
Replied by johnbump on topic calling subroutine from G54, G55, G56, but it acts weird
I will go read some more about G52, thanks!
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.060 seconds