Change the axis limit

More
14 Aug 2024 20:46 #307744 by Moutomation
Hello, 
Can I change the axis limits, maximum speed and ramp with the variable addresses I wrote in the G-code file or with classicladder without entering the ini file?
For example :
eg.ngc
℅ 
#100 = 1000 (x-axis positive limit) 
#101 = 200 (ramp) 
m2

Or can I do it with the Classic Ladder?

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

More
15 Aug 2024 07:32 - 15 Aug 2024 07:43 #307778 by Aciera
Replied by Aciera on topic Change the axis limit
The short answer is, yes, you can change axis limits through HAL connections as well as through GCODE but there are a few things you need to be aware of.

- Axis limits are exposed as hal pins only after the GUI has started up. So any hal connections would need to be made in the POSTGUI_HALFILE
linuxcnc.org/docs/html/gcode/overview.html#gcode:ini-hal-params
As stated in the documentation #<_ini[section]key> parameters are read_only so if you want to change the value from Gcode you have to use a custom Mcode that uses a script language (eg tcl or bash) to execute a 'halcmd'

- Changes to ini parameters during GCODE execution will only become effective AFTER a quebuster command (eg M66 E0 L0)

My usual solution to change ini parameters from GCode is this:

1. save this bash script as 'M123' to a folder named 'mcodes' in your machine config folder and mark as executable:
#!/bin/bash
P=${1%.*}
Q=${2%.*} # in case you want to use the second parameter to0
echo " P: ${P} Q: ${Q}";

case $P in
11) echo „X min limit“
halcmd setp ini.x.min_limit $Q;;
12) echo „X max_limit“
halcmd setp ini.x.max_limit $Q;;
21) echo „Y min_limit“
halcmd setp ini.y.min_limit $Q;;
22) echo „Y max_limit“
halcmd setp ini.y.max_limit $Q;;
esac
exit 0

To make sure that the changes are actually used we call the above script from a GCODE subroutine.

2. Save the following code as 'm123_wrapper.ngc' and save to a folder in your [RS274NGC]
SUBROUTINE_PATH
; this is the wrapper for the bash script
o<m123_wrapper>sub
M66 L0 E0                 ;force sync, stop read ahead    
o100 if [EXISTS [#<P>]]
o100 else
    #<P> = 0              ;if no P word has been passed we use the default (0)      
o100 endif
o101 if [EXISTS [#<Q>]]
o101 else
    #<Q> = 0              ;if no Q word has been passed we use the default (0)      
o101 endif
M123 P#<P> Q#<Q>          ;call the bash script
M66 L0 E0                 ;force sync, stop read ahead
o<m123_wrapper>endsub
m2

To make linuxcnc aware of these mcodes add these lines to the [RS274NGC] section of your ini file
USER_M_PATH = ./mcodes
      REMAP = M423  modalgroup=10 argspec=PQ  ngc=m123_wrapper

Note 'argspec=PQ' will enforce that the 'M423' command is followed by a 'P' word containing the code for which axis [X(1),Y(2)] and which limit [min (1), max(2)] should be changed and a 'Q' word containing the limit value.
example usage:
M423 P12 Q401
will set 'ini.x.max_limit' to '401'


The parameter handling can be changed to your specific requirements in the 'case' part of the bash script above.
Last edit: 15 Aug 2024 07:43 by Aciera. Reason: clarification
The following user(s) said Thank You: tommylight, Moutomation

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

More
15 Aug 2024 16:23 #307826 by Moutomation
Replied by Moutomation on topic Change the axis limit
Thanks to you, many of my problems were solved. Thank you very much for your help. You are truly an expert.
The following user(s) said Thank You: tommylight

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

More
17 Aug 2024 11:14 #307999 by Moutomation
Replied by Moutomation on topic Change the axis limit
I cannot find the limits I marked in the picture on halshow.
When I change the limits below joint_0, the machine stops at the limit, but I cannot move it again with the jog keys.


 
Attachments:

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

More
17 Aug 2024 11:41 #308001 by Aciera
Replied by Aciera on topic Change the axis limit
You are looking at 'ini.0.' values. Those correspond to the [JOINT_0] section in the ini file. If you want to see the [AXIS_X] values you would need to navigate to 'ini.x.' which should be lower down in the list on the left hand side of the screen shot.
The following user(s) said Thank You: Moutomation

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

More
17 Aug 2024 13:04 #308003 by Moutomation
Replied by Moutomation on topic Change the axis limit
You're right, I found it, thanks a lot

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

Time to create page: 0.095 seconds
Powered by Kunena Forum