MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.18k stars 19.21k forks source link

[2.0.x] Losing steps when using Firmware Retraction #11512

Closed tcm0116 closed 5 years ago

tcm0116 commented 6 years ago

Description

Using firmware retraction appears to cause missing steps. I made several attempts at a print that consisted of multiple cubes while using firmware retraction, but each attempt resulted in the cubes becoming skewed towards the origin of the bed on my printer. I finally got the print to succeed by having the slicer perform the retraction instead of using G10/G11.

Steps to Reproduce

  1. Create a GCode file that has multiple cubes and uses G10/G11 commands for retraction.
  2. Print the GCode file on a cartesian machine that has Firmware Retraction enabled.
  3. The cubes will be skewed towards the origin of the bed.

Expected behavior: The cubes are not skewed,

Actual behavior: The cubes are skewed.

Additional Information

I'm fairly sure this is due to the call to SYNC_PLAN_POSITION_KINEMATIC() in FWRetract::retract(). My thinking is that the re-computation of Planner::position in Planner::_set_position_mm() is causing current_position and Planner::position to become out of sync, possibly due to rounding errors. I haven't looked into this hypothesis in detail, but it seems like a likely place for steps to get dropped.

tcm0116 commented 6 years ago

I just ran a test with some added debugging information added to FWRetract::retract() to display the X and Y stepper positions at the beginning and end of the function. As the X and Y positions aren't being modified by FWRetract::retract(), the stepper positions should be the same at the end of the function as they were at the beginning of the function. However, the log file snippet below shows a different story.

Recv: stepper.position[x] 9513
Recv: stepper.position[y] 10447
Recv: stepper.position[x] 9158
Recv: stepper.position[y] 10152
Recv: delta stepper.position[x] -355
Recv: delta stepper.position[y] -295
[...]
Recv: stepper.position[x] 9342
Recv: stepper.position[y] 10447
Recv: stepper.position[x] 9250
Recv: stepper.position[y] 10447
Recv: delta stepper.position[x] -92
Recv: delta stepper.position[y] 0
[...]
Recv: stepper.position[x] 9456
Recv: stepper.position[y] 11207
Recv: stepper.position[x] 9464
Recv: stepper.position[y] 11152
Recv: delta stepper.position[x] 8
Recv: delta stepper.position[y] -55
[...]
Recv: stepper.position[x] 9307
Recv: stepper.position[y] 11169
Recv: stepper.position[x] 9278
Recv: stepper.position[y] 11152
Recv: delta stepper.position[x] -29
Recv: delta stepper.position[y] -17
[...]
Recv: stepper.position[x] 7413
Recv: stepper.position[y] 11169
Recv: stepper.position[x] 7384
Recv: stepper.position[y] 11152
Recv: delta stepper.position[x] -29
Recv: delta stepper.position[y] -17

This seems to jive with my original hypothesis that the re-computation of the stepper positions in Planner::_set_position_mm() is likely the cause of the issue I was seeing.

The simplest fix would be to replaced the call to SYNC_PLAN_POSITION_KINEMATIC() with calls to sync_plan_position_e() and a new function sync_plan_position_z(). However, this has several downsides. First, it won't work for kinematic machines. Ans second, it really just masks the issue with re-computing the positions in Planner::_set_position_mm(), as the same issue could be occurring with the Z and E axes.

I think the better solution would be to replace the current method of adjusting the planner position with an approach that provides an offset to the planner in a similar way to how bed leveling works. This would eliminate the possibility of the stepper positions being incorrectly offset by allowing the planner to be away of the retraction offsets and the actual physical position of the machine at all times.

brucehvn commented 6 years ago

This may be related to a problem I've been seeing. I'm seeing my z-axis lowering on every retract/unretract. It's happening both with firmware retraction and manual retraction. I've swapped out every piece of hardware involved, ramps board, mega board, stepper driver, LCD display. I even removed the extruder cable and then the E stepper driver, but can still recreate the problem. The Z axis motors move for the exact amount of time the extruder motor is moving. Even if I slow the retract speed down to 4 mm/s2 which is consistent with normal extrusion, it still turns the z motors so it's definitely related to retract/unretract. The Z motors always turn the same direction regardless of extruder direction. This is using bugfix-2.0.x from around Aug 26 and I downloaded the latest on Sep 7.

This is a prusa I3 variant running a Mega 2560 R3 and RAMPS 1.4.

configs.zip

thinkyhead commented 6 years ago

@brucehvn — Try #11578 and see if it solves the issue for you. The branch to download is at https://github.com/tcm0116/Marlin/tree/2.0.x_fwretract

brucehvn commented 6 years ago

@thinkyhead @tcm0116 I downloaded that fork and started moving my config settings into it, but the Configuration.h has no section for UBL. I don't know how old that branch was when you started, but the problem I'm having seems to be related to UBL. My configs are from 2.0.x and it looks like your branch is from the 1.1.x series so I don't want to just blast my UBL settings in there. I see there is a ubl_retract branch in there. Perhaps, that's the one I should be trying?

tcm0116 commented 6 years ago

@brucehvn you probably need to explicitly checkout the "2.0.x_fwretract" branch after you clone the repository as that's not the default branch.

brucehvn commented 6 years ago

haha, yup that's the problem. Doh! Silly me.

I just verified that printing with UBL off with my current version of bugfix-2.0.x from a couple days ago works with no problem. I'll try your branch now with UBL enabled again.

brucehvn commented 6 years ago

@tcm0116 printing with your code I don't see any problem with the z motors moving on retract/unretract. I'm able to print again with UBL. Yay!

Any idea on when this will be merged into the main bugfix-2.0.x branch?

thinkyhead commented 6 years ago

@brucehvn — We're just waiting for confirmation that delta motion is still working properly with that PR, and then it will be merged.

studiodyne commented 6 years ago

Same issue for dual color printing that use a purge bucket for each tool change , that go outside of the bed and back to the object ' i'm Using Fwretract zlift for all dual color printing' Really happy !!!! Good Job !!!!

Note : Since you are working on 'buffer line kinematics', I discovered a bug, which does not respect the feedrate with UBL + MESH LOADED, I created the issue, it is visible in the tab issue

brucehvn commented 5 years ago

@tcm0116 @thinkyhead, just checking back to see if this ever got merged.

tcm0116 commented 5 years ago

@brucehvn - yes, it did! I'll go ahead and close this issue.

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.