Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
8.99k stars 5.17k forks source link

Added QuadBedLevel feature #6452

Open Phil1988 opened 5 months ago

Phil1988 commented 5 months ago

Quad bed level: Adds QBL feature

QBL is a new function for moving beds with 4 independent z steppers. It is able to flatten/level beds of any shapes like ones with a hyperbolic parabola effect (potato chip). It's based/derived on quad_gantry_level. I did several successfull tests and had no issue at all.

Signed-off-by: Phil Groenewold philgroenewold@gmx.de

Some examples: Bed before: image

Bed after 3 iterations of leveling (took ~6min) image

Here is the console output during another test of the quad_bed_level:

16:24:52
Retries: 3/5 Probed points range: 0.006000 tolerance: 0.010000
16:24:49
Making the following Z adjustments:
stepper_z = -0.003839
stepper_z1 = 0.001486
stepper_z2 = 0.003822
stepper_z3 = -0.001469
16:24:49
Adjustment positions:
z: -0.003839 z1: 0.001486 z2: 0.003822 z3: -0.001469
16:24:49
Average: 16.647960
16:24:49
Actuator Positions:
z: 16.651799 z1: 16.646474 z2: 16.644138 z3: 16.649429
16:24:49
Bed-relative probe points:
0: 16.651242 1: 16.646742 2: 16.645242 3: 16.649742
16:24:49
probe at 540.000,60.000 is z=3.350258
16:24:36
probe at 540.000,600.000 is z=3.354758
16:24:23
probe at 50.000,600.000 is z=3.353258
16:24:10
probe at 50.000,60.000 is z=3.348758
16:24:01
Retries: 2/5 Probed points range: 0.029000 tolerance: 0.010000
16:23:58
Making the following Z adjustments:
stepper_z = 0.027657
stepper_z1 = -0.018258
stepper_z2 = -0.000115
stepper_z3 = -0.009283
16:23:58
Adjustment positions:
z: 0.027657 z1: -0.018258 z2: -0.000115 z3: -0.009283
16:23:58
Average: 16.648247
16:23:57
Actuator Positions:
z: 16.620591 z1: 16.666506 z2: 16.648362 z3: 16.657531
16:23:57
Bed-relative probe points:
0: 16.628740 1: 16.657740 2: 16.651240 3: 16.651740
16:23:57
probe at 540.000,60.000 is z=3.348260
16:23:44
probe at 540.000,600.000 is z=3.348760
16:23:32
probe at 50.000,600.000 is z=3.342260
16:23:19
probe at 50.000,60.000 is z=3.371260
16:23:10
Retries: 1/5 Probed points range: 0.121000 tolerance: 0.010000
16:23:06
Making the following Z adjustments:
stepper_z = 0.089295
stepper_z1 = -0.095760
stepper_z2 = 0.010195
stepper_z3 = -0.003730
16:23:06
Adjustment positions:
z: 0.089295 z1: -0.095760 z2: 0.010195 z3: -0.003730
16:23:06
Average: 16.649476
16:23:06
Actuator Positions:
z: 16.560181 z1: 16.745237 z2: 16.639282 z3: 16.653206
16:23:06
Bed-relative probe points:
0: 16.581330 1: 16.702330 2: 16.653330 3: 16.638830
16:23:06
probe at 540.000,60.000 is z=3.361170
16:22:53
probe at 540.000,600.000 is z=3.346670
16:22:40
probe at 50.000,600.000 is z=3.297670
16:22:27
probe at 50.000,60.000 is z=3.418670
16:22:18
Retries: 0/5 Probed points range: 1.017500 tolerance: 0.010000
16:22:14
Making the following Z adjustments:
stepper_z = 0.269584
stepper_z1 = -1.088170
stepper_z2 = 0.395465
stepper_z3 = 0.423121
16:22:14
Adjustment positions:
z: 0.269584 z1: -1.088170 z2: 0.395465 z3: 0.423121
16:22:14
Average: 16.643972
16:22:14
Actuator Positions:
z: 16.374388 z1: 17.732142 z2: 16.248507 z3: 16.220851
16:22:14
Bed-relative probe points:
0: 16.354000 1: 17.265000 2: 16.447000 3: 16.247500
16:22:14
probe at 540.000,60.000 is z=3.752500
16:22:01
probe at 540.000,600.000 is z=3.553000
16:21:48
probe at 50.000,600.000 is z=2.735000
16:21:35
probe at 50.000,60.000 is z=3.646000
16:21:29
quad_bed_level

It started from points range: 1.017500 after 3 iterations it went down to points range: 0.006000

Configuration is similar to "[quad_gantry_level]"

So the section would look like this:

[quad_bed_level]
#bed_corners:
# X/Y coordinates describing the location of each bed "pivot point".
# These points beeing measured from the coordinates of the nozzle
# This parameter must be provided
#points:
# X/Y coordinates of each probe point during a Quad_bed_level command.
# The location is measured from the nozzle coordinates, so make sure to adjust the coordinate according to the probe offset
#speed: 150
#   The speed (in mm/s) of non-probing moves during the calibration.
#   The default is 50.
#horizontal_move_z: 30
#   The height (in mm) that the head should be commanded to move to
#   just prior to starting a probe operation. The default is 5.
#max_adjust: 7
#   Safety limit if an adjustment greater than this value is requested
#   quad_gantry_level will abort.
#retries: 5
#   Number of times to retry if the probed points aren't within
#   tolerance.
#retry_tolerance: 0.010
#   If retries are enabled then retry if largest and smallest probed
#   points differ more than retry_tolerance.
JamesH1978 commented 5 months ago

Thank you for submitting a PR, please refer to point 3 in "What to expect in a review" in https://github.com/Klipper3d/klipper/blob/master/docs/CONTRIBUTING.md and provide a signed off by line.

Thanks James

Phil1988 commented 5 months ago

Thanks @JamesH1978 for your comment. Added the Signed-off-by line.

Is it sufficient or am I missing something?

devond76180 commented 5 months ago

Looks like a useful feature, will need test it out. Can you add the files for command documentation. Thanks.

Phil1988 commented 5 months ago

Can you add the files for command documentation. Thanks.

Hey @devond76180 , thanks for your interest. What files do you exactly mean?

devond76180 commented 5 months ago

What are the parameters for the command?  Is it the same as quad_gantry_level?  The file would be Config_Reference.md with quadbedlevel added.Sent from my Galaxy -------- Original message --------From: Phil1988 @.> Date: 1/25/24 1:49 PM (GMT-05:00) To: Klipper3d/klipper @.> Cc: Devon Davis @.>, Mention @.> Subject: Re: [Klipper3d/klipper] Added QuadBedLevel feature (PR #6452)

Can you add the files for command documentation. Thanks.

Hey @devond76180 , thanks for your interest. What files do you exactly mean?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

Phil1988 commented 5 months ago

@devond76180 : Please have a look at the config section in my first comment here. Its all you need, but if you have questions, please reach out to me :)

madnezzm commented 5 months ago

bed_corners parameters same as quad_gantry_level.gantry_corners? Can you show example?

Phil1988 commented 5 months ago

@madnezzm yes, its similar. Here an example:

[quad_bed_level]
bed_corners:
# X/Y coordinates describing the location of each bed "pivot point".
# These points beeing measured from the coordinates of the nozzle
     -170, -5
     -170, 634
     604, 630
     604, -5
points:
# X/Y coordinates of each probe point during a Quad_bed_level command.
# The location is measured from the nozzle coordinates, so make sure to adjust the coordinate according to the probe offset
     50, 60
     50, 600
     540, 600
     540, 60
speed: 150
#   The speed (in mm/s) of non-probing moves during the calibration.
#   The default is 50.
horizontal_move_z: 20
#   The height (in mm) that the head should be commanded to move to
#   just prior to starting a probe operation. The default is 5.
max_adjust: 7
#   Safety limit if an adjustment greater than this value is requested
#   quad_gantry_level will abort.
retries: 5
#   Number of times to retry if the probed points aren't within
#   tolerance.
retry_tolerance: 0.010
#   If retries are enabled then retry if largest and smallest probed
#   points differ more than retry_tolerance.
clearchris commented 4 months ago

I'm currently running this code on two machines, and I really like it. In the coming weeks, I'll likely be depolying it to at least 2 more. It's of particular use on larger beds as it's easier for them to get twisted out of plane. Even on my machine, which has a 9.5mm thick bed, it's pretty easy for the z axis to twist the bed.

So far in testing, one machine went from 0.581mm bed range to 0.395mm range, big improvement IMHO. But even more importantly, this will lead to increased consistency because any bed twist throws off the bed_mesh. Having the probe points bent back into place before each print assures the mesh actually works for the bed. The second machine didn't see much improvement, the bed was pretty flat to begin with. However this module ensures that the bed will return to the same position prior to print.

What's really nice about this has not many changes from code that has been run by voron users for a very long time now, so I don't expect many (if any) strange bugs to pop up in this well tested code.

Thank you Phil for doing the work on this!

Note the "Range" in the before and after pics. Before: unnamed-1

After (please forgive the floating bed, someone messed with the z-offset, and the machine was turned off for the weekend): unnamed

devond76180 commented 4 months ago

Tried the command. got the following error. Used the same config as quad_gantry_level. Assume I did something bad in the config but not sure. Send: quad_bed_level Recv: // probe at 5.000,10.000 is z=1.391418 Recv: // probe at 5.000,580.000 is z=1.338918 Recv: // probe at 250.000,580.000 is z=1.361418 Recv: // probe at 250.000,10.000 is z=1.346418 Recv: // Bed-relative probe points: Recv: // 0: 3.608582 1: 3.661082 2: 3.638582 3: 3.653582 Recv: // Klipper state: Shutdown Recv: !! Internal error on command:"QUAD_BED_LEVEL"

Do you want the klippy.log and where do I send it?

Here is the short cut of the error from the log

Bed-relative probe points: 0: 3.608582 1: 3.661082 2: 3.638582 3: 3.653582

quad_bed_level f1: (0.00018367346938663798, 3.601602818273141), f2: (-9.183673469394933e-05, 3.664572206028035) Internal error on command:"QUAD_BED_LEVEL" Traceback (most recent call last): File "/home/pi/klipper/klippy/gcode.py", line 198, in _process_commands handler(gcmd) File "/home/pi/klipper/klippy/gcode.py", line 135, in func = lambda params: origfunc(self._get_extended_params(params)) File "/home/pi/klipper/klippy/extras/quad_bed_level.py", line 53, in cmd_QUAD_BED_LEVEL self.probe_helper.start_probe(gcmd) File "/home/pi/klipper/klippy/extras/probe.py", line 425, in start_probe done = self._move_next() File "/home/pi/klipper/klippy/extras/probe.py", line 394, in _move_next res = self.finalize_callback(self.probe_offsets, self.results) File "/home/pi/klipper/klippy/extras/quad_bed_level.py", line 80, in probe_finalize self.plot(slope_x_pp03, self.bed_corners[3][0])] IndexError: tuple index out of range Transition to shutdown state: Internal error on command:"QUAD_BED_LEVEL"

Phil1988 commented 4 months ago

@devond76180
Very little information on this one. With these pieces I can not help. Show us your config and add the full log. Then we might be able to help you.

@clearchris Thanks for your nice feedback and I'm happy with your good result 👍

devond76180 commented 4 months ago

The bed_corners and gantry_corners are very different. Gantry is only z and z2 which should cover all needed information. Bed_corners is z, z1, z2, z3. If there are cases where Z1 and Z3 cannot be derived in the bed_level case, would this also be true for the gantry_level?

Phil1988 commented 4 months ago

Please show us your config :)

clearchris commented 4 months ago

The bed_corners and gantry_corners are very different. Gantry is only z and z2 which should cover all needed information. Bed_corners is z, z1, z2, z3. If there are cases where Z1 and Z3 cannot be derived in the bed_level case, would this also be true for the gantry_level?

You need to enter all 4 points, whether or not they can be derived.

github-actions[bot] commented 4 months ago

Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html

There are some steps that you can take now:

  1. Perform a self-review of your Pull Request by following the steps at: https://www.klipper3d.org/CONTRIBUTING.html#what-to-expect-in-a-review If you have completed a self-review, be sure to state the results of that self-review explicitly in the Pull Request comments. A reviewer is more likely to participate if the bulk of a review has already been completed.
  2. Consider opening a topic on the Klipper Discourse server to discuss this work. The Discourse server is a good place to discuss development ideas and to engage users interested in testing. Reviewers are more likely to prioritize Pull Requests with an active community of users.
  3. Consider helping out reviewers by reviewing other Klipper Pull Requests. Taking the time to perform a careful and detailed review of others work is appreciated. Regular contributors are more likely to prioritize the contributions of other regular contributors.

Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available.

Best regards, ~ Your friendly GitIssueBot

PS: I'm just an automated script, not a human being.

Phil1988 commented 4 months ago

It would be great, if a reviewer can have a look and make this feature availible for others. Already 4 different people showed interessed in this here and the results looking good to me.

Chris-Jayden commented 4 months ago

I have a Anycubic Chiron into VORON Quadent conversion in the works, so this is a really exciting feature; I'd love to see it ported/supported in Klipper-main!~