Auto Bed vs. Mesh Grid Compensation



  • Can someone clarify the differences here. This is what I see:

    • Two forms of bed compensation
    • Two options to disable said compensations

    Bed Compensation

    Yet, when I run either one the process and apparent results seem to be the same. The points I defined in config.g, are probed and a map of the result is displayed:

    M557 X50:280 Y50:280 S46                     ; Define mesh grid
    
    • What is the difference, if any, between "Auto Bed Compensation" and "Run Mesh Grid Compensation"?
    • When would you use one versus the other, and why?
    • Does running either of these commands always result in activating compensation (after a successful run)?

    To be clear, what I think about when I say "bed compensation" is a procedure that maps flatness irregularities with the print surface to be used during printing to move the z axis up and down as necessary in order to maintain a constant tip-to-bed distance.

    I understand "Auto Bed Compensation" corresponds to G32 and "Mesh Grid Compensation" to G29. Having read the documentation on both, this is what I think each does:

    G32 ("Auto Bed Compensation")
    Runs the commands in "bed.g" and enables compensation. In my case:

    M561 ; clear any bed transform
    G28  ; home all axes
    G29  ; probe the bed and enable compensation
    

    G29 ("Mesh Grid Compensation" )

    Probes the points defined in M557 and enables compensation. It does not seem to run G28 before probing. I can't tell because the G-code isn't reflected in the G-code console.

    If the end result is the same, why are there two ways to disable compensation in the Machine Control page? "Disable Bed Compensation" and "Disable Mesh Grid Compensation".

    Am I correct to presume that if I want to probe the build-plate before every print I simply add these commands to my startup g-code?

    M561 ; clear any bed transform
    G28  ; home all axes
    G29  ; probe the bed and enable compensation
    

    Thanks,

    -Martin

    EDIT:

    I should add that the one distinguishing factor I am able to garner from what is reflected in the g-code console is:

    "Auto Bed Compensation" runs the g-code in bed.g, saves to "heightmap.csv" and DOES NOT seem to enable mesh leveling.

    "Mesh Grid Compensation" runs G29 and then explicitly enables it by running G29 S1

    If I understand the documentation on G29 correctly the plain G29 or G29 P0 command DOES NOT enable compensation, only G29 P1 does:

    S0 (default if no S parameter) Probe the bed, save the height map in a file on the SD card, and activate 
    bed compensation. The height map is stored in file is /sys/heightmap.csv.
    
    S1 Load the height map from file and activate bed compensation. The default filename is as for S0 but a 
    different filename an be specified using the P parameter.


  • Hi,

    Did you read this:

    https://duet3d.dozuki.com/Wiki/Setting_up_automatic_probing_of_the_print_bed

    As to your bed.g file naturally when it contains the commands you use it will yield the same result as mesh compensation.

    I have tried using auto bed compensation to invoke the bed leveling assistant and while it was informative I didn't find it very useful as I was unable to adjust my bed leveling screws the tiny amounts the assistant called for.

    Auto bed compensation can also be used for bed leveling if you have multiple z axis steppers arranged as needed for that purpose.

    Auto bed compensation serves a specific purpose for delta printers which mesh compensation cannot do.

    While I am planning on installing multiple Z axis steppers for now I am leveling my bed using 4 point mesh compensation, displaying the height map and adjusting the leveling screws as best I can. I repeat the process until I am satisfied.

    Then I could run multiple point mesh compensation to handle bed irregularities but I am getting very good print results just using 4 point mesh compensation.



  • OK, following up on this. I have to say I am still confused by the options. Yes, I have solved the problem but what I read in the documentation does not square-up with what I have seen happening.

    First, how did I fix it?

    I modified my startup script to include this before every single print job:

    M561    ; Clear any bed transform
    G28       ; Home machine
    G29       ; Probe the bed and enable compensation
    G29 S1  ; Enable mesh compensation
    

    This does exactly as the comments say. The machine changed from being unpredictable and not putting down a good first layer to reliably putting down an excellent first layer every single time.

    Menu

    What was I doing before? I was:

    • Manually turning on bed heating
    • Allowing the printbed to warm-up and stabilize (5 to 10 minutes)
    • Manually turning on the nozzleater
    • Allowing it to stabilize
    • Cleaning the tip from any ooze
    • Homing all axis
    • Using a feeler gauge to ensure the tip was 0.1 to 0.2 mm from the bed surface
    • Clean the print surface
    • Clicking the "Auto Bed Compensation" button
    • Waiting for results
    • Then I would launch the print job

    The above produced inconsistent results and it was hard to get a good first layer.

    I then changed my startup code to what's shown below and the printer went from having nothing but problems to being as reliable as can be. I also eliminated all the busywork as it became unnecessary to do all of that stuff. Today I simply run clean the print surface and launch the job. No problems. To be clear, I don't click on the "Auto Bed Compensation" button any more. It seems to be useless, at least for this purpose.

    I am trying to understand how it is that these changes made such a massive difference. In addition to this I am trying to understand why this many has seemingly equivalent options.

    The easiest question is:

    What's the difference between "Auto Bed Compensation" and "Run Mesh Grid Compensation"?

    The next question would be:

    What's the difference between "Disable Bed Compensation" and "Disable Mesh Grid Compensation"?

    And yet another:

    What's the difference between "Show Probed Points" and "Show Mesh Grid Heightmap"?

    Finally:

    Are the height maps generated by G32 and G29 the same? Why would you disable one vs. the other then?

    My current thinking is that the "Auto Bed Compensation" button seems to go through the motions of measuring the bed and that's where it stops. It does not seem to actually enable the compensation.

    Going by the documentation and UI, "Auto Bed Compensation" runs G32 and "Run Mesh Grid Compensation" runs G29.

    Despite what the documentation says, G29 by itself, does seem to enable bed compensation. I had to insert a G29 S1 in my startup code. In fact, my machine is only probing ONCE, despite having a G29 followed by a G29 S1.

    G32, again, per the docs, is supposed to load "bed.g". My "bed.g" has this in it:

     bed.g
    ; called to perform automatic bed compensation via G32
    ;
    ; generated by RepRapFirmware Configuration Tool v2 on Wed Aug 14 2019 16:30:15 GMT-0700 (Pacific Daylight Time)
    M561 ; clear any bed transform
    G28  ; home all axes
    G29  ; probe the bed and enable compensation
    

    Which is confusing, because it G32 documentation says:

    It probes the bed at 3 or more pre-defined points (see M557) and updates transformation matrix for bed levelling compensation.
    
    The firmware executes macro file bed.g if present instead of using the M557 coordinates.
    

    So...G32 doesn't actually run because I have a "bed.g" file that was generated when I used the RepRap Firmware Configuration Tool to setup the machine?

    In other words, do both "Auto Bed Compensation" and "Run Mesh Grid Compensation" run G29, resulting in compensation actually not being enabled?

    I would love to understand what's going on. As I said, I fixed it by no longer using this menu and resorting to the addition of a G29/G29 S1 probing cycle at the start of every print. Still, it would be great to understand.

    Thanks.


  • Moderator

    @martincho said in Auto Bed vs. Mesh Grid Compensation:

    It probes the bed at 3 or more pre-defined points (see M557) and updates transformation matrix for bed levelling compensation.

    This is the old, deprecated form of leveling. It has been superceded by G29, which is far more flexible. The old way of using G32 as described in your quote was limited in the points it could use and how it could compensate. G29 can use very few or very many points and can interpolate between them.

    So for all intents and purposes, G32 is now just a shortcut to run bed.g which is just a macro that can contain whatever you want rather than the fixed function that G32 used to use.

    So really the best way to look at it going forward is that G32 calls bed.g and bed.g can contain the procedure you want to use to execute a G29, including automating all the preheating, etc that you do manually.

    G29 S1 at the start of a print is the correct place for it at any rate. It would also belong at the end of homeall.g after the Z0 point has been determined by a G30. That's the important thing; the heightmap should only be created or loaded after the Z0 point has been determined with G30, otherwise you can get inconsistent first layer positioning as you found.

    See my previous reply to your other thread for other details.



  • @Phaedrux I saw your other response and dug into it, thanks.

    I guess I am now wondering if my firmware is out of date? The "Auto Bed Compensation" button --which I thought would probe and then enable compensation-- only seemed to do the first half of that. The only evidence I have in support of this is that it wasn't until I added probing code to the start of every part that my first layer became predictable and reliable.

    My problem is solved now. I am only continuing to dig in this discussion for the potential benefit of others who might run into this. This issue cost me weeks of pulling my hair trying to figure out what I was doing wrong.

    It would be nice if someone from Duet could answer and explain what the various buttons do in that menu.


  • Moderator



  • Ah, OK, thanks for that. The button isn't labeled correctly then. Even then, the whole thing is really confusing because it runs "bed.g", which has G29 in it.

    Per the documentation on "Auto Bed Compensation" button:

    The "Auto Bed Compensation" button on a Cartesian or "Auto Delta Calibration" button runs G32. 
    This has different functions . On a Cartesian/CoreXY/SCARA machine it is used for 
    Bed levelling using multiple independent Z motors.
    

    Yet, if you look at documentation for G32:

    The firmware executes macro file bed.g if present instead of using the M557 coordinates.
    

    What does "bed.g" contain?

    bed.g
    ; called to perform automatic bed compensation via G32
    ;
    ; generated by RepRapFirmware Configuration Tool v2 on Wed Aug 14 2019 16:30:15 GMT-0700 (Pacific Daylight Time)
    M561 ; clear any bed transform
    G28  ; home all axes
    G29  ; probe the bed and enable compensation
    

    So...G32 really runs G29 but it seems it doesn't enable mesh compensation, for that you would need:

    G29 S1
    

    I don't know, the feeling I am getting is that the documentation isn't correct somewhere, the "Auto Bed Leveling" button isn't labeled correctly and the documentation sends in into a circular trip devoid of clarity. The fact that I was able to fix a bunch of problems by effectively adding just the "S1" portion to the G29 command tells me this might warrant a look by the Duet guys.

    This has caused weeks of consternation on my part. I am sure I'm not the only one who read "Auto Bed Compensation" and thought, well, that's what the button was for. Then, after using it, when the printer has problems, the last thing you think about is bed leveling...because you've already done it, including seeing the nice pop-up graphic showing you the measurements. You look at the documentation and it goes in circles, pretty much confirming that, again, you did the right thing. Until you notice "S1", try it, and all problems go away instantly.

    @dc42 a bit of wisdom on this might help. Thanks.



  • Hi,

    I am using the most recent Duet WiFi firmware.

    For me G29 probes AND enables mesh compensation.

    As to the "Auto Bed Compensation" button: Yes it invokes the bed.g file (if it exists) but the contents of that file is up to you. The contents you have listed will do mesh compensation but it can be created using other commands to do other things - like auto bed leveling using multiple Z-axis steppers.

    Frederick



  • This confused me at first until I realised there was a difference between "Bed Levelling" and "Mesh Compensation".
    Bed Levelling (G32) is to do with physically levelling the bed via the motion of the z-axis steppers. For instance on my D-Bot I have 3 z-axis leadscrews controlled by 3 independent motors (see Bed_levelling_using_multiple_independent_Z_motors).

    In my bed.g I have:

    G28				; home
    G30 P0 X10  Y60  Z-99999 	; probe near a leadscrew
    G30 P1 X290 Y60  Z-99999 	; probe near a leadscrew
    G30 P2 X150 Y290 Z-99999 S3 	; probe near a leadscrew and calibrate 3 motors
    
    ; re-home z axis in case it has shifted
    G28 Z
    
    

    When this runs it probes the bed adjacent to each screw and then moves 1 or more z motors to physically level the bed.

    There is no reason to use G32 on a Cartesian or core-xy printer unless you have multiple z-axis motors that can physically adjust the bed levelling.

    Then there is Mesh Compensation (G29). This is to do with ironing out the imperfections in your (already levelled) bed.
    The Z motors will move the bed up & down as the head moves in x & y to simulate a perfectly flat, level bed.

    I run everything from a single macro rather than call G32 from the drop-down in DWC. It levels the bed using G32 then does a G29 probe in a 3x3 grid.

    Calibrate.g

    ; Warm Hotend and Bed
    T0			        ; Select Tool 0
    M104 S130		; Set Tool 0 temperature to 130 - no wait
    M190 S60		; Set Bed temperature to 60 - wait
    
    ; Clear Values
    G29 S2			; Clear Mesh Compensation Values
    M290 R0 S0      	; Clear Baby-stepping
    
    ; Home all Axes
    G28
    
    ; Bed levelling (G32)
    G30 P0 X10  Y50  Z-99999 	; probe near a leadscrew
    G30 P1 X290 Y48  Z-99999 	; probe near a leadscrew
    G30 P2 X148 Y284 Z-99999 S3 	; probe near a leadscrew and calibrate 3 motors
    
    ; Re-home z axis in case it has shifted
    G28 Z
    
    M557 X25:275 Y25:275 S125:125             ; Define mesh grid (3x3)
    
    ; Mesh Compensation (G29)
    G29 S2			; Clear Mesh Compensation Values
    G29			; Run Mesh Compensation
    G1 Z30 F310             ; Move bed down
    G1 X150 Y145 F15600	; Move to centre
    
    

    In my slicer startup gcode I have

    G29 S1                          	; Load Mesh Compensation Settings from file
    

    amongst other things, to reload the Mesh Compensation Height Map created by the G29 in Calibration.g.
    This way I only need to run the calibration once at power-on then simply re-home between prints.



  • Thanks for the input.

    I should clarify that my bed.g file is what was created by configtool.reprapfirmware.org. In other words, it's precisely what someone who goes to use a Duet for the first time on a custom build or retrofit is likely to end-up with.

    Now I know better, of course. However, the default bed.g created by this config tool seems to be, if I may be so bold to say, wrong.

    I'll bet if you polled 100 people as to what "Auto Bed Leveling" does or means they are likely to describe mesh leveling. I'll also bet that not one of them would conclude that the button does NOT load and activate the mesh leveling function.

    Anyhow, I figured this out after weeks of hair pulling. I am only posting this for the benefit of others who might be confused by first layer and other problems thinking they are doing everything correctly when, in reality, that button and the configuration file associated with it are part of the problem.



  • My initial bed.g as downloaded from the configurator contained:

    ; bed.g
    ; called to perform automatic bed compensation via G32
    ;
    ; generated by RepRapFirmware Configuration Tool on Thu Dec 28 2017 14:34:20 GMT+0000 (GMT)
    M561 ; clear any bed transform
    G28  ; home all axes
    ; Probe the bed at 4 points
    G30 P0 X60 Y60 H0 Z-99999
    G30 P1 X60 Y220 H0 Z-99999
    G30 P2 X240 Y220 H0 Z-99999
    G30 P3 X240 Y60 H0 Z-99999 S
    

    At the time I had no idea what it was meant to do.



  • @martincho said in Auto Bed vs. Mesh Grid Compensation:

    However, the default bed.g created by this config tool seems to be, if I may be so bold to say, wrong.

    While it may be a bit confusing It's not wrong. The bed.g file is used for different things depending on your printer type and hardware.

    For a simple Cartesian the created bed.g simply gives you the ability to click the "Auto Bed Compensation" button to do mesh compensation. Mesh compensation is a more advanced approach replacing the older method.

    The configurator generates different bed.g depending on settings you enter.

    Select a delta printer and it will generate a bed.g file appropriate for a delta printer. Specify a CoreXY printer and you will get yet a different bed.g file - one that is out of date, I think.

    I went back and ran the tool again for a Cartesian printer and got that same bed.g - a different one from the first run.

    I suspect the tool needs some work.

    I never used the configurator tool. The Duet WiFi comes with example config files. I studied those to get an idea of what my config file needed to contain and I created my own. There is knowledge to be gained doing that way.

    Glad to hear you finally got it sorted out.

    Frederick



  • The default bed.g I got for the cartesian configuration does not enable mesh compensation. It runs everything but the map is never loaded. It's all the theatrics without the final functionality being enabled.

    This requires G29 S01, which is not included in the default bed.g.

    That was the root of the problem. G29 vs. G29 S01.

    BTW, I am not blaming anyone. This is just part of learning. My only input is that someone needs to consider that this might have become quite confusing and convoluted over time.

    As an aerospace engineer I don't think I am a dummy, and this had me going around in circles for quite some time because things would look like they worked better at times and then they would inexplicably break. Adding "S01" made the difference between an inconsistent printer and one I don't have to worry about any more. Surely I am not the only one who has fallen into this trap.



  • @martincho said in Auto Bed vs. Mesh Grid Compensation:

    The default bed.g I got for the cartesian configuration does not enable mesh compensation. It runs everything but the map is never loaded. It's all the theatrics without the final functionality being enabled.

    This requires G29 S01, which is not included in the default bed.g.

    That was the root of the problem. G29 vs. G29 S01.

    Then how do you explain that on my printer I don't need G29 S1 (I assume you mean S1) to enable mesh compensation.

    I can run the mesh bed probing and check if mesh compensation is enable and it is.

    Are you using the most recent firmware?

    Frederick



  • @fcwilt said in Auto Bed vs. Mesh Grid Compensation:

    Then how do you explain that on my printer I don't need G29 S1 (I assume you mean S1) to enable mesh compensation.

    I can run the mesh bed probing and check if mesh compensation is enable and it is.

    Are you using the most recent firmware?

    I can't explain it. That's why I asked @dc42 to chip in if possible. I'll check my firmware tomorrow, long day.

    Thanks.


Log in to reply