Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While correcting issues in the xhc-whb04b-6 module (#3810), I found an issue in axis.c.
This can result in a crash, especially in Z axis if you have a tool in the spindle.
Steps to reproduce
I would expect the machine to move to x=-253.88
This happens on all axis and all limits. For simplicity, I just described X negative.
Analysis
The issue lies in https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/motion/axis.c
After homing, axis->pos_cmd is 0.0
G53 G0 X-254 moves the machine exactly to one of the limits.
Due to this, update_teleop_with_check returns true and axis->pos_cmd is not updated with the actual position:
https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/motion/axis.c#L677
When jogging in velocity mode, axis->pos_cmd is used to limit the next set-point:
https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/motion/axis.c#L421
Now with axis->pos_cmd == 0.0 while the machine is at -254, it moves with full speed to x=-0.914.
This issue exists on any axis when moving with gcode to one of the limits or your home position is at one of the limits and then manually jog in velocity mode to any direction.
I analyzed this with some printf debugging. See:
https://github.com/hdiethelm/linuxcnc-fork/tree/printf-debug
This was changed quite some time ago in:
784db03 control.c line 1312
Suggested fix
This fixes the above behavior. I will do some future testing next week in simulation and on my machine, but until now, I did not see any side effects.