Update Work Offsets with G Code

More
15 Jul 2024 03:04 #305188 by Joz
Hi all!
I have a custom program in which I really need the ability to update a work offset with G code. On my Haas, I can use G90 G10 L2 P2 X1 Y1 Z1 to change G55 XYZ to 1. If I change to using G91 it'll add 1 to G55 XYZ instead of setting G55 XYZ to 1. On my Linux router G90 and G91 both set G55 to 1 instead of G91 updating it. Does anybody know how I can update work offsets with G code? TIA!

Please Log in or Create an account to join the conversation.

More
15 Jul 2024 03:23 - 15 Jul 2024 03:34 #305189 by Joz
Replied by Joz on topic Update Work Offsets with G Code
Also for a second I thought I might be able to make it work with L20 instead of L2 but I don't think that's the case.
Last edit: 15 Jul 2024 03:34 by Joz.

Please Log in or Create an account to join the conversation.

More
15 Jul 2024 09:47 - 15 Jul 2024 09:59 #305218 by Aciera
see below
Last edit: 15 Jul 2024 09:59 by Aciera.

Please Log in or Create an account to join the conversation.

More
15 Jul 2024 09:48 #305219 by Aciera
I think this would require a custom Gcode using a remap. I made an example remap for a command 'G10.1 Xn Yn Zn'

Try this:

Add this to the [RS274NGC] section of your ini file:
          REMAP = G10.1  modalgroup=1   argspec=xyz  ngc=g10_increment

Create a new file with the Gcode below and save as 'g10_increment.ngc' to a folder in your
[RS274NGC] SUBROUTINE_PATH   
o<g10_increment>sub
M66 L0 E0                    ;force sync, stop read ahead    

o100 if [EXISTS [#<X>]]      ;check for X-word, set to zero if missing                       
o100 else
    #<X> = 0                                                  
o100 endif
o101 if [EXISTS [#<Y>]]     ;check for Y-word, set to zero if missing  
o101 else
    #<Y> = 0                                                  
o101 endif
o102 if [EXISTS [#<Z>]]     ;check for Z-word, set to zero if missing  
o102 else
    #<Z> = 0                                                  
o102 endif

; calculate which parameter contains the current X,Y,Z offset values
#<x_current> = [5201 + #5220 * 20]
#<y_current> = [5202 + #5220 * 20]
#<z_current> = [5203 + #5220 * 20]

; add the passed X,Y,Z words to the current offset values
G10 L2 P0 X[#[#<x_current>] + #<X>] Y[#[#<y_current>] + #<Y>] Z[#[#<z_current>] + #<Z>]

M66 L0 E0                   ;force sync, stop read ahead
o<g10_increment>endsub
m2

Note:
This will always apply to the currently active offset system.

You could use another unallocated  GCODE :
linuxcnc.org/docs/2.9/html/remap/remap.h...:unallocated-g-codes

You could extend this to query the state of G90/91 and/or add a  'P' word to pick an offset system other then the currently active one.
The following user(s) said Thank You: tommylight, Joz

Please Log in or Create an account to join the conversation.

Time to create page: 0.255 seconds
Powered by Kunena Forum