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

MBL print area #4183

Merged
merged 34 commits into from
Sep 13, 2023
Merged

MBL print area #4183

merged 34 commits into from
Sep 13, 2023

Conversation

leptun
Copy link
Collaborator

@leptun leptun commented May 1, 2023

Similar implementation of the print area UBL from the Buddy firmware, but instead of using M555 for defining the print area, G80 uses additional parameters. The G80 print area is defined with X, Y, W and H, just like with M555. If the print area is not specified, the whole bed is probed. Gcode future and backward compatibility is maintained since old firmware will ignore these extra parameters.

With this PR, if a print area is provided, the 7x7 MBL will only probe those points. This results in a quicker, precise MBL where precision is needed. Besides the print area probed points, the rest of the 7x7 mesh uses interpolation of the data sorted in eeprom during Z calibration so that the toolhead can safely exit the print area and not cause a nozzle crash with a warped bed.

Tasks after merge

  • Update rep-rap Gcode documentation
  • Update PrusaSlicer profiles
  • Update translation (kill(PSTR("Mesh bed leveling failed. Please run Z calibration."));)
  • Add O in G80 [ N | R | L | R | F | B | X | Y | W | H ] list
IMG_1223.MOV

image (25)

IMG_1227.MOV

In case the 3x3 mesh in eeprom from Z calibration is missing/invalid, the 3x3 points are also probed besides the print area:

IMG_1221.MOV

Another interesting feature enabled by this PR is the ability to load and activate the mesh stored in eeprom without probing any point (besides point 0). This can be achieved with G80 W since it results in the print area being completely outside the bed.

Closes #3224

@leptun
Copy link
Collaborator Author

leptun commented May 3, 2023

In order to use the feature, change the G80 call in the slicer startup script to this:

G80 X{first_layer_print_min[0]} Y{first_layer_print_min[1]} W{(first_layer_print_max[0]) - (first_layer_print_min[0])} H{(first_layer_print_max[1]) - (first_layer_print_min[1])}; mesh bed leveling

MBL 7x7 must also be enabled on the printer. Otherwise, the entire bed will be probed with 3x3.

@leptun leptun force-pushed the mbl_print_area branch 3 times, most recently from ff558d2 to 75d5d56 Compare May 5, 2023 10:40
Firmware/Marlin_main.cpp Outdated Show resolved Hide resolved
@leptun
Copy link
Collaborator Author

leptun commented May 5, 2023

I pushed a lot of changes to the PR. I fixed the point counter behavior. It now computes in advance how many points will be probed, so it no longer skips the counter on the status screen.
I also improved a lot the eeprom mesh code and the code that determines the approximate range where the current probed point should be located. I am now using the upsampled eeprom mesh (in the past it was just hardcoded to current_position=0.f for all points not on the 3x3 mesh for some weird reason). So now I finally fixed the issue where certain warped beds have lots and lots and lots of rechecks on certain points. This was especially an issue on MK2.5(S) since the bed there was generally more warped.
I also improved how the Z is lifted to the next point. Previously it was computed relative to the height of the last measured point. Now I compute it based on the upsampled mesh from eeprom. This results in a much more consistent MBL on warped beds, while still being super fast.
I also no longer have to probe the first point. Only the print area needs to be probed now. So G80 W doesn't probe any point now, but this time for real 🙂. I tested it on my machine with a calibrated eeprom mesh and the first layer was still spot on.

Commands I use for testing:

G80 R1 N3                       ; regular 3x3 MBL
G80 R1 N7                       ; regular 7x7 MBL
G80 R3 N7 W                     ; load eeprom MBL. No probing
G80 R3 N7 R1 X20 Y10 W10 H10    ; Small 2x2 mesh near origin
G80 R3 N7 X115 Y91 W32 H24      ; Small 3x3 mesh at the center of the bed
G80 R3 N7 X100 Y80 W70 H70      ; Small 4x4 mesh near the center of the bed
G80 R3 N7 X70 Y50 W109 H109     ; Small 5x5 mesh at the center of the bed

Useful tool for visualizing the bed data. Dump the mesh with G81. Beware that the Y axis is flipped:
http://lokspace.eu/3d-printer-auto-bed-leveling-mesh-visualizer/

@leptun leptun changed the title 🚧 MBL print area MBL print area May 5, 2023
@leptun leptun marked this pull request as ready for review May 5, 2023 23:47
@leptun
Copy link
Collaborator Author

leptun commented May 5, 2023

Marked it as ready for review. Don't really have anything else I'd like to change besides maybe some optimizations here and there. Functionality wise, everything seems to be working fine. I still need to test how MBL performs with no Z calibration data. All other tests were performed on two printers: MK3S+_MMU3 and MK2.5_MMU2SR.

@leptun
Copy link
Collaborator Author

leptun commented May 6, 2023

Up to date video of a centered small 3x3 mesh. Counter works fine, first point is no longer measured. Still a bit disappointed that the superpinda needs to slow down on certain points due to the higher hysteresis. Pinda V2 would not have those slowdowns as is the case on the MK2.5 printer.

IMG_1233.MOV

@leptun leptun force-pushed the mbl_print_area branch from b9f4310 to 9bf0c0a Compare May 7, 2023 16:54
@ojrik
Copy link

ojrik commented May 7, 2023

Hello. Very nice work. It would be good to remove the return to Home, at the end of leveling.

@leptun
Copy link
Collaborator Author

leptun commented May 7, 2023

@ojrik Thank you. I need to keep the return to origin for backwards compatibility with old gcodes. But I understand it could be a useful setting to disable somehow if the purge line is printed next to the object. I'm thinking I could add an "O<0,1>" parameter to specify if return to origin is needed after G80, with a default of 1. Still need to think about the implications of this.

@ojrik
Copy link

ojrik commented May 7, 2023

Nice thought.
I have this PR applied in Firmware 3.12.2, it works well on MK2.5S + MMU2S, MK3S + MMU2S.

@leptun leptun force-pushed the mbl_print_area branch from db68c04 to 2e6c0d9 Compare May 8, 2023 06:31
@leptun
Copy link
Collaborator Author

leptun commented May 8, 2023

@ojrik I added the O parameter like I described in my previous comment. You may now add O0 to the G80 command to disable the return to origin.

I have this PR applied in Firmware 3.12.2, it works well on MK2.5S + MMU2S, MK3S + MMU2S.

I'm surprised the PR can be rebased so easily onto 3.12. In any case this PR is for 3.14 at the earliest since the 3.13 release is already packed full of changes. Thank you also for testing the PR on your printers. Feedback is greatly appreciated. Do you mind if you also post the G81 output from both printers of the commands listed in this comment? #4183 (comment). I want to see how closely the mesh saved in eeprom matches the real hardware. Also, did you perform Z/XYZ calibration recently on any of those printers?

@ojrik
Copy link

ojrik commented May 8, 2023

Do you mean something like this?
The XYZ calibration was about a month ago when I mounted the Super Pinda on the MK3S MMU2S.
Test MBL.txt

@leptun
Copy link
Collaborator Author

leptun commented May 8, 2023

Yes, something like that. I'm also interested in G80 O0 N7 W. This should load the Z calibration mesh from eeprom. This mesh data was stored there during Z calibration. The Z calibration is different than MBL and is performed at the end of XYZ calibration or manually via the menu ("Calibration->Calibrate Z"). That calibration probes 9 MBL points and stores them in eeprom. That data is later used by G80 while probing to validate measurements. With this PR, we rely much more on this eeprom data than in the past, so it's critical that the data in eeprom is correct.
Since you ran the XYZ calibration a month ago, the data in eeprom should be quite fresh still. Unless you did some work on the printer hardware in the meantime, it should still be fine.

@ojrik
Copy link

ojrik commented May 8, 2023

Zadal som príkaz G80 N7 O0 W, potom G81 my vyšlo toto.

Recv: 0.12000 0.11556 0.11222 0.11000 0.10889 0.10889 0.11000
Recv: 0.10556 0.10296 0.10037 0.09778 0.09519 0.09259 0.09000
Recv: 0.09889 0.09556 0.09185 0.08824 0.08333 0.07852 0.07333
Recv: 0.10000 0.09333 0.08667 0.08000 0.07380 0.06667 0.06000
Recv: 0.10889 0.09630 0.08481 0.07528 0.06519 0.05704 0.05000
Recv: 0.12556 0.10444 0.08630 0.07111 0.05889 0.04963 0.04333
Recv: 0.15000 0.11778 0.09111 0.07000 0.05444 0.04444 0.04000

@leptun
Copy link
Collaborator Author

leptun commented May 8, 2023

Wow, your printer is considerably straighter than mine :).
Were the measurements in Test.MBL.txt done while the printer is hot or cold?

@ojrik
Copy link

ojrik commented May 8, 2023

cold

@ojrik
Copy link

ojrik commented May 8, 2023

I use Prusa Leveling Guide in Octoprint to set BED.

@ojrik
Copy link

ojrik commented May 8, 2023

MK2.5S Test
Test MBL1.txt

@leptun
Copy link
Collaborator Author

leptun commented May 8, 2023

Oy. That's one bent bed 😅. Does this PR help with rechecks during MBL? Both 7x7 and 3x3. In my case on the MK2.5, the points on the last row always had to be rechecked. With this PR, those issues were gone for me. Is this also the case for you?

@ojrik
Copy link

ojrik commented May 8, 2023

I rarely use MK2.5S, I just tested your PR with FIRMWARE 3.12.2, FW 3.13.0, I don't have FW for MMU2S

@leptun
Copy link
Collaborator Author

leptun commented May 8, 2023

If all goes well, the new MMU firmware should be released at the end of this month. You can still use FW 3.13.0 on your printer, but you have to disable the MMU in settings

@ojrik
Copy link

ojrik commented May 8, 2023

I know that, I tried that too, I have it adjusted according to this PR.

@ojrik
Copy link

ojrik commented May 8, 2023

I use Visual Studio Code. With FW3.13.0 I have some problems compiling. MK2.5S date 1970-01-01, languages ​​not applicable. MK3S also date, and some small things in FW. But that's a small point.

@leptun
Copy link
Collaborator Author

leptun commented May 8, 2023

The compile date is intentional. It's done like this so that the FW build is consistent, so if you build now and again later, the same compiled hex will be output. The build server should use the correct time and date, so those builds are not affected.
MK2.5S language not applicable: which cmake target are you using for building?
What other fw issues are you encountering with the mk3s?

@ojrik
Copy link

ojrik commented May 8, 2023

Here is my Test MK2.5S FW3.12.2
Fantastic, because it's greasy and the bed is so bent.

20230508_140027
20230508_140100
20230508_140721
20230508_141206
20230508_141844
20230508_142707
20230508_143257
20230508_143314

gudnimg and others added 8 commits August 17, 2023 07:52
@github-actions
Copy link

github-actions bot commented Aug 17, 2023

Target ΔFlash (bytes) ΔSRAM (bytes)
MK3S_MULTILANG -264 -1
MK3_MULTILANG -278 -1

Copy link
Collaborator

@3d-gussner 3d-gussner left a comment

Choose a reason for hiding this comment

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

Tested on MK404 and real printer

@3d-gussner 3d-gussner merged commit 2e70697 into prusa3d:MK3 Sep 13, 2023
@@ -4957,29 +4858,26 @@ void process_commands()
Default 3x3 grid can be changed on MK2.5/s and MK3/s to 7x7 grid.
#### Usage

G80 [ N | R | V | L | R | F | B ]
G80 [ N | R | L | R | F | B | X | Y | W | H ]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just noticed I forgot to add O here

@leptun leptun deleted the mbl_print_area branch September 13, 2023 08:37
sarusani added a commit to sarusani/Prusa-Firmware that referenced this pull request Sep 13, 2023
Clean up mesh definitions that where made obsolete by prusa3d#4183
sarusani added a commit to sarusani/Prusa-Firmware that referenced this pull request Sep 13, 2023
Clean up mesh definitions that where made obsolete by prusa3d#4183
3d-gussner added a commit to 3d-gussner/Prusa-Firmware that referenced this pull request Sep 13, 2023
sarusani added a commit to sarusani/Prusa-Firmware that referenced this pull request Sep 13, 2023
Clean up mesh definitions that where made obsolete by prusa3d#4183
@3d-gussner 3d-gussner added the Post release tasks open Tasks after release label Sep 13, 2023
@sarusani
Copy link
Collaborator

sarusani commented Sep 14, 2023

@leptun
I noticed that when I use "G80 C0 N3" the bed gets probed once at each point as expected. (1 probe, 0 repeats) But G81 wont return any data.

Log with "G80 C0 N3":

Send: G80 C0 N3
echo:Enqueing to the front: "G28 W"
Recv: tmc2130_home_enter(axes_mask=0x01)
Recv:   0 step=30 mscnt= 480
Recv: tmc2130_goto_step 0 61 2 1000
Recv: tmc2130_home_exit tmc2130_sg_homing_axes_mask=0x01
Recv: tmc2130_home_enter(axes_mask=0x02)
Recv: echo:busy: processing
Recv:   0 step=18 mscnt= 288
Recv: tmc2130_goto_step 1 33 2 1000
Recv: tmc2130_home_exit tmc2130_sg_homing_axes_mask=0x02

Send: G81
Recv: Num X,Y: 7,7
Recv: Z search height: 5.0f
Recv: Measured points:
Recv:   0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
Recv:   0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
Recv:   0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
Recv:   0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
Recv:   0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
Recv:   0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000
Recv:   0.00000  0.00000  0.00000  0.00000  0.00000  0.00000  0.00000

Log with "G80 C1 N3":

Send: G80 C1 N3
Recv: echo:Enqueing to the front: "G28 W"
Recv: tmc2130_home_enter(axes_mask=0x01)
Recv:   0 step=29 mscnt= 479
Recv: tmc2130_goto_step 0 61 2 1000
Recv: tmc2130_home_exit tmc2130_sg_homing_axes_mask=0x01
Recv: tmc2130_home_enter(axes_mask=0x02)
Recv:   0 step=18 mscnt= 290
Recv: tmc2130_goto_step 1 33 2 1000
Recv: tmc2130_home_exit tmc2130_sg_homing_axes_mask=0x02

Send: G81
Recv: Num X,Y: 7,7
Recv: Z search height: 5.0f
Recv: Measured points:
Recv:   0.14750  0.20333  0.24167  0.26250  0.26583  0.25167  0.22000
Recv:   0.14167  0.19525  0.22775  0.23917  0.22951  0.19877  0.14694
Recv:   0.13917  0.18654  0.21127  0.21333  0.19275  0.14951  0.08361
Recv:   0.14000  0.17722  0.19222  0.18500  0.15556  0.10389  0.03000
Recv:   0.14417  0.16728  0.17062  0.15417  0.11793  0.06191  -0.01389
Recv:   0.15167  0.15673  0.14645  0.12083  0.07988  0.02358  -0.04806
Recv:   0.16250  0.14556  0.11972  0.08500  0.04139  -0.01111  -0.07250

@leptun
Copy link
Collaborator Author

leptun commented Sep 14, 2023

C0 is not a valid parameter. Only C >= 1 is allowed. The first probing try is always discarded. That's why C1 probes twice. That initial probe is used for detecting deviations only afaik. In any case, this PR didn't touch that part of the code.

@sarusani
Copy link
Collaborator

👍 Thanks for the info!

3d-gussner added a commit that referenced this pull request Sep 15, 2023
@leptun
Copy link
Collaborator Author

leptun commented Nov 5, 2023

Fyi, PrusaSlicer 2.7.0-alpha1 now has the updated startup gcode for the MK3/S/+ and MK2.5/S variants to make use of the MBL print area feature.

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.

[ENHANCEMENT] Add repetition limit on enforcing Z calibration during mesh bed leveling
5 participants