How to remove automatic g54 after M2/M30 ?

  • zz912
  • zz912's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
31 May 2026 09:01 #346795 by zz912
M2 and M30 commands have the following effects:
  • Origin offsets are set to the default (like G54).
linuxcnc.org/docs/devel/html/gcode/m-code.html#mcode:m2-m30

In LCNC 2.7 it fortunately did not work.
In LCNC 2.9 it UNfortunately works.

My friends used LCNC 2.7.  They used G54 for vise number 1 G55 for vise number 2 and so on. They dont use G5X in ngc files. They have many many ngc files. They were happy.

They started use Mesa cards 7i96s so they had to upgrade to LCNC 2.9. But in LCNC 2.9 automatic Ǵ54 UNfortunately works again. It is very dangerous for them. They works on vise number 2 with active G55, but after program end G54 is activated.

I need help. Where is "automatic Ǵ54 after M2/M30" in source code? I want delete it for us using.

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

More
31 May 2026 11:30 #346797 by rodw
Seems this G54 reset occurs in Interp::convert_stop()
in interp_convert.cc
github.com/LinuxCNC/linuxcnc/blob/master...erp_convert.cc#L5052
edit at your own risk :)

Note this is where Gcode is converted to blocks that are stored in a circular buffer and subsequently executed by motion.
The following user(s) said Thank You: zz912

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

More
31 May 2026 11:42 - 31 May 2026 11:44 #346798 by rodw
Pretty sure you would just comment out these two lines
github.com/LinuxCNC/linuxcnc/blob/master...erp_convert.cc#L5177
// settings->origin_index = 1;
// settings->parameters[5220] = 1.0;

1 = G54 so this is where the reset is happening
parameters like 5220 are described here linuxcnc.org/docs/html/gcode/overview.ht...:numbered-parameters
Last edit: 31 May 2026 11:44 by rodw.
The following user(s) said Thank You: zz912

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

More
31 May 2026 12:25 #346799 by rodw
Actually, A neat way of dealing with this could be adding a new parameter (5391?) and modify the code so that if it was set to true, the original 2.7 buggy behaivour was restored eg
if settings->parameters[5391] == 0.0{
    settings->origin_index = 1;
    settings->parameters[5220] = 1.0;
}

Be worth playing with that.

 
The following user(s) said Thank You: zz912

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

  • zz912
  • zz912's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
31 May 2026 13:47 #346801 by zz912
Replied by zz912 on topic How to remove automatic g54 after M2/M30 ?
Thank you for help.

I preffer:
if (INI configuration "AUTOMATIC_G54") == TRUE
{ settings->origin_index = 1;
settings->parameters[5220] = 1.0; }

Default value AUTOMATIC_G54 = TRUE
 

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

More
31 May 2026 16:35 #346807 by Aciera
Replied by Aciera on topic How to remove automatic g54 after M2/M30 ?
+1

I have wished for a possibility to op-out of this automatic resetting to G54 on M2/M30 several times in the past.
The following user(s) said Thank You: zz912

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

More
31 May 2026 17:49 - 31 May 2026 19:31 #346809 by Aciera
Replied by Aciera on topic How to remove automatic g54 after M2/M30 ?
Have a look at this PR:
github.com/LinuxCNC/linuxcnc/pull/4093
Last edit: 31 May 2026 19:31 by Aciera. Reason: Changed to link to PR
The following user(s) said Thank You: zz912

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

  • zz912
  • zz912's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
31 May 2026 18:55 #346813 by zz912
Replied by zz912 on topic How to remove automatic g54 after M2/M30 ?
I would like ask you for add this information in manual for M2 and M30 definition.

linuxcnc.org/docs/devel/html/gcode/m-code.html#mcode:m2-m30

How M99 works? What M99 do? I didnt find definition.

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

More
31 May 2026 19:13 - 31 May 2026 19:16 #346816 by Aciera
Replied by Aciera on topic How to remove automatic g54 after M2/M30 ?
see updated link above, also note changed usage as I wanted to follow the 'disable_g92_persistence' setting.

for M99 see (I have never used it myself):
linuxcnc.org/docs/scratch/html/gcode/o-c...fanuc-style-programs
Last edit: 31 May 2026 19:16 by Aciera.
The following user(s) said Thank You: zz912

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

  • zz912
  • zz912's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
31 May 2026 19:28 #346817 by zz912
Replied by zz912 on topic How to remove automatic g54 after M2/M30 ?
M99 is not working in Gmoccapy. 


I tested it in master branch and in feature_g54_on_program_stop branch.
It doesnt work in both branch.
It works in Axis GUI. 

M99 link is not working too:
 
Attachments:

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

Time to create page: 1.097 seconds
Powered by Kunena Forum