Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.1.x] Fix M428 #8397

Merged
merged 2 commits into from Nov 13, 2017
Merged

Conversation

RowanMeara
Copy link
Contributor

@RowanMeara RowanMeara commented Nov 13, 2017

Addressing #8362

This fixes the old implementation of M428 which was broken and did not
match the official documentation. The implementation is basically the same as the M206 implementation.

I also fixed a typo in M114 which applied the wrong offsets to the Y position.

I can prepare a version for 2.0.x if people think this doesn't need any changes.

BUZZ(100, 698);
}
LOOP_XYZ(i)
set_home_offset((AxisEnum)i, -1.0f * current_position[i]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this is that it doesn't account for min versus max endstops. The "home position" for a max endstop might be something like 300. Simply setting the home offset based on the current position assumes that the home position set in the configuration is always going to be zero. The logic needs to account for the difference between the current position and the endstop — so the current implementation simply works from the distance between the current position and the nearest end of the axis.

bool err = false;
LOOP_XYZ(i) {
if (axis_homed[i]) {
const float base = (current_position[i] > (soft_endstop_min[i] + soft_endstop_max[i]) * 0.5) ? base_home_pos((AxisEnum)i) : 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recent issues with M428 are probably primarily related to the broken report_current_position function, but might also be related to the fact that we changed soft endstops to use the borders of the printable (bed) region and no longer the hard endstops (MIN|MAX)_[XYZ]_POS. To revert to the previous (non-broken) behavior, the base_min_pos() and base_max_pos() might be better than soft_endstop_(min|max) here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The website describes M428 this way:

The current position is set to the native home position.

It doesn't describe the case where "home position" is something like X200 Y0 Z0 so that needs to be added. But the idea is, shortly after you home, you would move the axes a little until you have your preferred position within the bed, but relatively close to the endstop. The M428 command makes the current point correspond to the configured endstop position by setting home_offset appropriately.

@thinkyhead thinkyhead force-pushed the rm-M428-1.1.x branch 14 times, most recently from 3f2f181 to ea35b40 Compare November 13, 2017 07:01
@thinkyhead
Copy link
Member

thinkyhead commented Nov 13, 2017

Reviewing the intent of M428

  • I agree it's important for the axes to be homed.
  • Distance to the nearest endstop should apply, as this is meant to be used shortly after G28.
  • Since that may be inconvenient, in the case of "too far" it will try the distance from 0 instead.

If that last item sounds like the existing implementation, you're starting to see why it was done that way. However, I have clarified the code so it should make more sense to the casual reader, and maybe even improved it a little.

Description:

M428 will set the home_offset based on the distance between the nearest endstop or the opposite end of the axis. You must be within 2cm of the edge or M428 will throw an error. This command is not available on DELTA or SCARA.

@thinkyhead thinkyhead force-pushed the rm-M428-1.1.x branch 3 times, most recently from 80acc92 to fac5484 Compare November 13, 2017 07:30
This fixes the old implementation of M428 which was broken, did not
match the website, and made no sense.
@thinkyhead thinkyhead changed the title [1.1.x] Fix M428 #8362 [1.1.x] Fix M428 Nov 13, 2017
@thinkyhead thinkyhead merged commit 8b68463 into MarlinFirmware:bugfix-1.1.x Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants