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

[BUG] Incorrect offset applied to Bed level mesh when using a fixed Home Switch/Z stop and seperate level probe. #27680

Open
1 task done
Maker-Paul opened this issue Feb 9, 2025 · 4 comments

Comments

@Maker-Paul
Copy link

Maker-Paul commented Feb 9, 2025

Did you test the latest bugfix-2.1.x code?

Yes, and the problem still exists.

Bug Description

When using a fixed stop for homing connected to default Z min and a probe connected to the default separate probe connector.

The bed level mesh is created relative to the fixed Z0 and therefore an unwanted offset between the fixed Z0 and the probe Z0 is added to the mesh values. This offset can be compensated for by setting a probe Z offset, but this offset is then inappropriately applied to the fixed Z stop/Homing switch when homing and therefore has to be removed for subsequent homing. Z values on the status screen are therefore very confusing.

I have included modified files in the upload section below as a possible fix. The readme file details the line numbers in the files where code has been added or changed. Hope this helps. Last upload of updated files 20th Feb 2025.

Bug Timeline

Not sure

Expected behavior

The probe should be used to establish the Probe Z0 reference for the purpose of creating the mesh points (the same as when only a probe exists and has been used to home)
Optional When a fixed Z stop/Home switch is used a probe offset is not needed as the nozzle offset is actually relative to the fixed stop so the menu option setting a probe Z offset could be removed and it would be more logical to enable the Z bed offset that is present in the menu when only a fixed stop is used.

Please note using just a Z stop or just using a probe both work as expected.

Actual behavior

I have to find the offset between the fixed Z Stop/Home switch and the Probe Z0. Then enter that value as a Z probe offset before I run a bed level. store the mesh and set the probe Z offset back to 0, then home the machine as a workaround way to set it up. I have enable bed leveling after homing enabled.
Because a Fixed Z stop/Home switch to probe Z0 is not a recognized offset the numbers can get very confusing.

Steps to Reproduce

  1. Fit a fixed Z Stop and separate Level probe each connected to their respective default connectors
  2. // #define Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN and // #define USE_PROBE_FOR_Z_HOMING are both disabled
  3. set the fixed Z stop switch physically to match the nozzle to bed paper pinch test. (this will mean the Fixed Z stop 0 to Probe Z 0 offset will be the same as the Z probe to nozzle offset or as near as)
  4. If you run a bed level at this point and inspect the values you will see they are large.
  5. run a Z offset wizard or enter the Z offset and then run a bed level.
  6. save the results
  7. set the probe Z offset back to 0 and save settings (No offset is needed with a fixed Home Z0 switch)
  8. Home the machine. Enable the stored bed level mesh if not set to automatically restore it.

Version of Marlin Firmware

Latest Bugfix 2.1.x

Printer model

Tronxy XY2 Pro

Electronics

Stock

LCD/Controller

Stock

Other add-ons

No response

Bed Leveling

ABL Bilinear mesh

Your Slicer

Prusa Slicer

Host Software

None

Don't forget to include

  • A ZIP file containing your Configuration.h and Configuration_adv.h.

Additional information & file uploads

Configuration.zip

PaulsBugfix.zip

Readme.txt

@Maker-Paul Maker-Paul changed the title [BUG] Incorrect offset applied to Bed level mesh when using a fixed Home Switch/Z stop and level probe. [BUG] Incorrect offset applied to Bed level mesh when using a fixed Home Switch/Z stop and seperate level probe. Feb 9, 2025
@borland1
Copy link
Contributor

Maker-Paul,

Why are you using a mechanical limit switch for the Z-axis when your Z-probe can perform the same function?

@Maker-Paul
Copy link
Author

Maker-Paul commented Feb 11, 2025 via email

@Maker-Paul
Copy link
Author

I have successfully edited G29.cpp to correct the error at least for ABL Bilinear mesh. It only required 4 lines of code and 1 line edited to make it work. I have edited config.h by adding a new compiler directive to enable my changes called USE_PROBE_FOR_MESH_REF.

As I don't use git and have definitely not extensively tested it, I am not going to be so presumptuous as to try and submit the code officially as a fix. But I am more than happy to let any Marlin developer have the file as it will at least provide a method.

My printer now does perfect first layers every time simply by selecting the file to print. Homing is part of the print file custom Gcode and restore level after homing is enabled in config.h.

Re-leveling is only required after physical adjustments and as the frame mounted Z end-stop/Homing switch provides a real Z zero homing point there is no need of any probe z offset or offset wizards. I am using an adjustable mount for the frame mounted Z end-stop/Homing switch which allows better than 0.01mm adjustments for setting the switch physical position so the nozzle just pinches a piece of paper when homing. Assisted tramming still works as it should..

@Maker-Paul
Copy link
Author

Maker-Paul commented Feb 12, 2025

Glad you got it working.

Mechanical limit switches are generally less accurate than a capacitive or inductive probes, however the homing accuracy is more limited by a combination of the lead screw thread pitch and your Z-axis stepper motor's micro-stepping resolution (1/16 stepping vs. 1/256 stepping).

It's easier to adjust the Z-offset, than a mechanical Z-axis limit switch, when adjusting the print's first layer squish. You might run some test prints using a first layer mesh test print, to see if you have your mesh properly dialed in. I am more familiar with Cura Slicer, but Prusa Slicer might also have similar built-in tools for generating single layer mesh test print files.

Since you XY2 Pro is a bed slinger, you might want consider replacing the factory bed springs, with similar, but thicker springs (higher spring constant). The weak stock springs tend to loosen up from constant vibrations as print time accumulates. Also smaller diameter thumb screws are less likely to get accidentally bumped out of any proper adjustment.

Hi Borland1. I do feel a bit like I'm having to defend this. I have to disagree with almost every assertion you have made but I'm glad at the same time that your interested.

Even a cheap mechanical limit switch can certainly achieve a repeatability better that 0.01mm. Its the repeatability that matters in this application because what we are interested in is the relative position to other components in this case the nozzle. So it doesn't matter whether the measurement is mm, inches, standard cabbages or a piece of paper. As I have already said my switch is mounted on an adjustable mount that lets me adjust its position relative to the bed just by turning a thumb wheel with a resolution of 0.5mm per revolution. It takes a minute to literally dial in the Home position using the paper pinch test. Once it is set it stays set day in day out. Of course I could use a higher quality switch or optical trigger that would be highly accurate, is easily available and also cheap but I haven't found that to be necessary. As for the mechanical accuracy of lead screws and micro stepping resolution, these are both outside the remit of this modification or the bugfix and have been addressed separately on my machines.

A proximity sensor which may have a higher resolution, which is what I think your confusing with accuracy., but has appalling long term repeatability. My proximity sensors trigger point varies by up to 2mm depending on temperature. That doesn't matter for comparative measurements where all the reading are gathered within a short enough time that the environment cant have significantly changed. A proximity sensor will only give accurate repeatability once it has settled but not during the first half hour of being switched on and not from day to day.. So creating a mesh is fine, but will my home position be the same tomorrow morning as it is at 4oc in the afternoon. I can guarantee it won't be. That is why so many people constantly have to reset the Z offset every time before they start a new print. As my firmware modification/bug fix means the unwanted fixed Z/Home switch to probe offset is measured as the first thing a bed level routine does the unwanted offset is taken off the mesh values with the same accuracy as the mesh measurements themselves. the result is that my machines home position on the status screen with the mesh applied is Z 0. The produced mesh has values both slightly above and slightly below zero with a range of about 0.2 mm as would be expected from a PEI sheet on a magnetic base with a warped hot plate. The fix doesn't change the relative values of the mesh points to each other as the same value is applied to all points. All it does is move the mesh down to the zero plane.

It is not easier to drill down menu options to adjust a Z offset than it is to move a thumb wheel by 1 notch. especially when having the homing switch set properly eliminates the need to ever have to set a Z offset either with the wizard or any other method allowing the menu options to be simplified and the status screen to show the actual Z value. I have enabled a Bed Z menu option to allow the Fixed Z stop/Home switch to be deliberately set a little above the bed if wanted. the extra clearance allows homing and bed leveling to keep the nozzle clear of the bed even if there is a bit of set oozed plastic. the bed Z setting does the same as it does when there is only a fixed Z stop. As it is an offset between the fixed Z stop and the bed it doesn't change with environmental changes. In practice I haven't found the Bed Z option necessary as setting the Fixed Z stop using the paper pinch test works perfectly well and I'm pretty good at making sure my nozzle is clean before I home or level.

I have of course carried out many first layer mesh test prints. I am now at the point where I can deliberately adjust my bed level, set the home position, run a bed level and do a mesh test print without any further adjustments and its perfect every time, even with the bed badly out of tram.

I have three XY2 Pros all highly modified including bed springs. I started experimenting with using separate Z stop and probe 5 years ago but because of the restrictions of proprietary firmware the only way I could implement it was with a physical switch to change between them. The result was stable machines that would work for weeks without having to mess with them but they were not easy to set up. This latest machine (I picked up two wrecks for £30 on the local buy and sell) is as easy to use as the most expensive consumer grade machines (Bamboo Labs) Easy to set up! Stays set! Thanks to Marlin finally bringing it together (all be it I have had to bug fix it myself at the moment) This set up is as close as it gets to true automatic bed leveling and much better than the Sunlu I have with a BL touch

Pros
Cheap readily available components, will work on any board with at least 1 unused end stop socket, easy to implement (with the bug fixed firmware). doesn't require a fast mother board. brings any machine as close as possible to the elusive promise of ABL.
cons
Not widely accepted as many people perceive a proximity sensor to be an upgrade and resist the idea of fitting a mechanical switch as being somehow a retrograde step, even though each excels in its own role.

Pros and cons of other alternatives
BL touch and clones :- Roughly the same mechanical accuracy as my solution, Not affected by environment changes, mechanically complex, prone to damage, expensive, difficult to implement as a non stock upgrade on many machines.

Bed distance sensor :- (This is the future) Should be environmentally stable but I haven't tested it. Still requires a Z offset but should stay set. compensates for state of the bed in real time so no mesh, requires a capable fast mother board, expensive at the moment, complex to implement as a non stock upgrade.

I really do feel I have the best easily implemented solution to a problem that plagues so many 3D printer users. Its affordable easy to install and simplifies the operation of existing machines even for non enthusiast operators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants