Close



Page 1 of 7 123 ... LastLast
Results 1 to 10 of 68
  1. #1
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,120

    Auto_Bed_Leveling: Z-Probe Repeatability code

    UPDATED 04-28-2014 to include the L (legs of movement) parameter.

    If you have Auto_Bed_Leveling running on your Rep_Rep, you may be interested in this thread. My printer's Z-Probe uses the cheapest micro-switch on eBay. I have the servo for the Z-Probe embedded in my heavily modified Wade's extruder. I am getting very good results with the Auto_Bed_Leveling, but I'm curious if a higher quality micro-switch would help me. I am also curious how good the mechanical repeatability of my various axis are. The problem is the tools don't exist to know this answer.

    As a result of this, I've written a Z-Probe Repeatability function for Marlin. It will return the standard deviation of a set of sampled points. The code is attached for those that want to compare their results to mine and share it in this thread. To use this code, edit Marlin_Main.cpp and search for:

    else if(code_seen('M'))
    {
    switch( (int)code_value() )
    {

    Insert the attached code at this point. Recompile and upload the new firmware to your board.

    To use the code, issue a G28 command to home all of the axis. Then issue an appropriate M48 command. The defaults for the M48 command are reasonable and should produce results with no extra parameters. Just a simple G28 followed by M48 will get you preliminary results.

    The code lets you specify a number of additional parameters. You can specify the X and Y coordinate where you want the sample taken. The Z-Probe's offset is factored into these numbers. If you specify the samples should be taken at (X,Y) = (50,75) it will move the nozzle such that the probe is being done at (50,75). This can be done by sending an M48 x 50 y 75 to your printer.

    You can specify the number of samples with the n parameter. If you want the M48 command to take 20 samples at the current location, this can be accomplished by sending an M48 n 20 to your printer. It is important to note that the parameters to the M48 command can be either upper or lower case letters with the exception of the n parameter. This must be lower case because Marlin has already grabbed the capital N for its protocol to communicate with the program sending it data. You will make Marlin horribly sick if you use a capital N. I could have picked a different letter, but n made sense for the sample set size.

    There is a V parameter to control verboseness. The default value is 1. You can set it as high as 4. You can limit chit chat by setting it to 0. The main value to setting it higher such as 3 or 4 is you will see the mean and standard deviation change slightly as more and more points are taken. You can safely ignore this parameter. If you want to play with this you can send your printer a M48 V 4 command.

    The latest addition is the L parameter. This specifies how many legs of movement to do prior to taking a measurement. It is used to stress the X and Y axis to help you understand if there is any slop on these axis that is contributing to unrepeatability in the Z-axis. Normally this code is not invoked but when specified it will decide on a rotational direction at random and move some nominal radius from the probe point. It will step along an arc that is more or less at the originally decided radius until the specified number of legs is accomplished. Then the measurement will be taken. You can try this parameter by sending a M48 n10 v4 l8 to your printer and seeing if it increases your typical standard deviation at the measurement location.

    Lastly, there is an E parameter. This Engages and Retracts the Z-Probe for each sample. It is a good way to see if your Z-Probe mechanism is adding any instability to your system. To check this, you could do a G28 and then a M48 n 15 x 50 y 50 followed by a M48 n 15 x 50 y 50 e command. At the end of each M48 command you will be told the standard deviation for the sampled points. If the M48 command with the e parameter has a higher standard deviation it is likely to indicate you have some inconsistencies in where the Z-Probe is being positioned between engagements.


    OK... Now for the good stuff. Here is a cut & paste of my printer getting two M48 commands telling it to measure things at the center of the bed. One is with the Z-Probe down the entire time and the other is with the Z-Probe engaging and retracting.

    Connecting...
    Printer is now online.
    >>>G28
    SENDING:G28
    >>>M48 x 100 y 100
    SENDING:M48 x 100 y 100
    M48 Z-Probe Repeatability test. Version 1.50
    Mean: 4.162425
    Standard Deviation: 0.009255
    echo:endstops hit: Z:4.17
    >>>M48 x 100 y 100 e
    SENDING:M48 x 100 y 100 e
    M48 Z-Probe Repeatability test. Version 1.50
    Mean: 4.166162
    Standard Deviation: 0.015431
    echo:endstops hit: Z:4.16

    I have very limited data to work with. I only know that my printer is doing well with the Auto_Bed_Leveling. With more people contributing their results to this thread we will probably be able to determine how much repeatability is necessary to get good results. My G29 command is modified so the Z-Probe stays engaged the entire time. Most of you will not have that feature so you probably should be paying more attention to the second standard deviation with the e parameter specified. Right now, my standard deviation is 1/30 of my typical layer height (because I'm comparing myself to the first result). It is possible the rational I'm using to choose the number I'm comparing against is flawed. I'm most certainly open to criticism and to being corrected!

    So, with a sample size of 1 (me!!!), I'm thinking you probably will get good results if your standard deviation for Z-Probes is 1/30 of your layer height!
    Attached Files Attached Files
    • File Type: c M48.c (7.5 KB, 60 views)
    Last edited by Roxy; 04-28-2014 at 11:41 AM. Reason: Updated to include new L parameter to stress X & Y mechanics

  2. #2
    Technologist
    Join Date
    Oct 2013
    Location
    Honolulu, HI
    Posts
    199
    Roxy,

    This is a very nice contribution to the field. I'd be very interested if you can measure "slop" this way. The nice thing about being able to measure it is that you can make it better then.

    Cheers,

    KDog

  3. #3
    Super Moderator DrLuigi's Avatar
    Join Date
    Oct 2013
    Location
    Belgium
    Posts
    503
    Just did it a sec ago,

    Seems to work quiet well, I use a tower pro SG90 btw,

    >>>M48 n 15 x 50 y 50 e
    SENDING:M48 n 15 x 50 y 50 e
    M48 Z-Probe Repeatability test. Version 1.50
    Mean: 2.885400
    Standard Deviation: 0.008681
    echo:endstops hit: Z:2.88

    When doing a M48 for the first time it did the probing at x100 y100. The play was then (Standard Deviation: 0.018029)




    The e command should make it retract and extend right? Well that doesnt seem to do anything here tho.

  4. #4
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,120
    Quote Originally Posted by DrLuigi View Post
    Just did it a sec ago,

    Seems to work quiet well, I use a tower pro SG90 btw,

    >>>M48 n 15 x 50 y 50 e
    SENDING:M48 n 15 x 50 y 50 e
    M48 Z-Probe Repeatability test. Version 1.50
    Mean: 2.885400
    Standard Deviation: 0.008681
    echo:endstops hit: Z:2.88
    You did specify the 'e' option so the Z-Probe should have been engaging and disengaging. But OK, ignoring that, your Standard Deviation of .0086 is better than what I'm getting when the probe is staying engaged. Are you printing with a layer height of .30 mm ? I'm guessing you are getting good results with your Auto_Bed_Leveling, right?

    I've noticed something else I don't understand. The standard deviation varies depending upon the bed temperature. I'm getting better results with the bed hot. It doesn't seem like that should matter.

    Quote Originally Posted by DrLuigi View Post
    When doing a M48 for the first time it did the probing at x100 y100. The play was then (Standard Deviation: 0.018029)
    If you don't specify where to do the probe, it should do it where ever the nozzle is currently located. Was the nozzle at (x,y) = (100,100) ?

    Quote Originally Posted by DrLuigi View Post
    The e command should make it retract and extend right? Well that doesnt seem to do anything here tho.
    Can you try sending it an M401 and an M402 command? Does that engage and retract the Z-Probe? This new M48 command uses the same support functions as the M401 and M402 command use. Specifically: engage_z_probe() & retract_z_probe()

  5. #5
    Super Moderator DrLuigi's Avatar
    Join Date
    Oct 2013
    Location
    Belgium
    Posts
    503
    Ye it does work on M401 and M402.

    M48 n 15 x 50 y 50 e
    Thats what i entered.
    Used it on diffrent places, max deviation ive had was 0.02 so is still okay.
    I have a 0.35mm nozzle, so normaly i use a layerheight of 0.1-0.25

    Well its okay, its almost always print able, But there is some diffrence with PLA and ABS, Atleast i think that,
    That or my diameter was entered wrong (On PLA same settings the nozzle isnt close enough to the bed, The way around with ABS and its a bit to near the bed.)


  6. #6
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,120
    Quote Originally Posted by DrLuigi View Post
    Ye it does work on M401 and M402.

    M48 n 15 x 50 y 50 e
    Thats what i entered.
    Used it on diffrent places, max deviation ive had was 0.02 so is still okay.
    I have a 0.35mm nozzle, so normaly i use a layerheight of 0.1-0.25

    Well its okay, its almost always print able, But there is some diffrence with PLA and ABS, Atleast i think that,
    That or my diameter was entered wrong (On PLA same settings the nozzle isnt close enough to the bed, The way around with ABS and its a bit to near the bed.)


    That is very strange that it doesn't engage and retract. I've changed things around a little bit to make a couple of improvements. I've attached the new code if you are in the mood to mess with it. One of the things I did was add confirmation the M48 command sees the 'e' option if the Verboseness is greater than 1.

    >>>M48 n 10 x 75 y 75 e v 2
    SENDING:M48 n 10 x 75 y 75 e v 2
    M48 Z-Probe Repeatability test. Version 1.60
    M48 'e' option specified.
    1 of 10 .......

    I just had a thought what might be going on... I bet you have your servo delay times set very short. I'm going to update the code to handle that. I've tested the updates and they are attached. (I suspect you can use the 'e' option now to compare the results of engaging and retracting the probe versus leaving it down.)
    Last edited by Roxy; 04-29-2014 at 11:29 AM.

  7. #7
    Super Moderator DrLuigi's Avatar
    Join Date
    Oct 2013
    Location
    Belgium
    Posts
    503
    Will try it tomorow or so,

    Will edit this post to tell you what happend!

    /edit

    Seems to work fine now

    Like the update, It didnt gave the (3 of 10 z: 2.918500)
    before

    M48 Z-Probe Repeatability test. Version 1.60
    M48 'e' option specified.
    1 of 10 z: 2.907250
    2 of 10 z: 2.903000
    3 of 10 z: 2.918500
    4 of 10 z: 2.918250
    5 of 10 z: 2.911250
    6 of 10 z: 2.918500
    7 of 10 z: 2.918750
    8 of 10 z: 2.907500
    9 of 10 z: 2.926250
    10 of 10 z: 2.907000
    Mean: 2.913625
    Standard Deviation: 0.007037
    echo:endstops hit: Z:2.91

    Seems nice. I guess i should do a first layer of 0.2 tho. To calibrate i did it to 0.1 for my first layer to fine tune it. But when i retry it on 0.1 it is sometime iffy, not at the sweet spot.

    /edit second try on another place,
    SENDING:M48 n 10 x 124 y 100 e v 2
    M48 Z-Probe Repeatability test. Version 1.60
    M48 'e' option specified.
    1 of 10 z: 2.789000
    2 of 10 z: 2.769000
    3 of 10 z: 2.760750
    4 of 10 z: 2.786000
    5 of 10 z: 2.760000
    6 of 10 z: 2.781250
    7 of 10 z: 2.759750
    8 of 10 z: 2.767750
    9 of 10 z: 2.772000
    10 of 10 z: 2.774750
    Mean: 2.772025
    Standard Deviation: 0.010128
    echo:endstops hit: Z:2.78


    I am kinda suprised, i thought it wouldnt be this accurate!

    Thanks for the script
    Last edited by DrLuigi; 04-14-2014 at 05:00 PM.

  8. #8
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,120
    Quote Originally Posted by DrLuigi View Post
    Will try it tomorow or so,

    Will edit this post to tell you what happend!
    I guess tomorrow means after mid-night to you!

    Quote Originally Posted by DrLuigi View Post
    Seems to work fine now

    Like the update, It didnt gave the (3 of 10 z: 2.918500)
    before

    M48 Z-Probe Repeatability test. Version 1.60
    M48 'e' option specified.
    1 of 10 z: 2.907250
    2 of 10 z: 2.903000
    3 of 10 z: 2.918500
    4 of 10 z: 2.918250
    5 of 10 z: 2.911250
    6 of 10 z: 2.918500
    7 of 10 z: 2.918750
    8 of 10 z: 2.907500
    9 of 10 z: 2.926250
    10 of 10 z: 2.907000
    Mean: 2.913625
    Standard Deviation: 0.007037
    echo:endstops hit: Z:2.91
    No... It did do that, but you had to turn the 'v' option up to a high enough level. You can specify 'v 4' to get even more detail and a running calculation of standard deviation.

    OK... I'll take the "M48 'e' option specified." out of the code now... I just wanted to see if that was really being seen since it wasn't working. With a very small servo delay, the probe didn't have time to get all the way up before it got kicked down again. Now there is a 1 second delay anytime the probe is getting moved.

    Quote Originally Posted by DrLuigi View Post
    Seems nice. I guess i should do a first layer of 0.2 tho. To calibrate i did it to 0.1 for my first layer to fine tune it. But when i retry it on 0.1 it is sometime iffy, not at the sweet spot.
    I have a something for you to keep in the back of your mind. When I get my stuff crossed over to the current release you will want my G29 code for two reasons. I am running with n=5 for the number of probe points. It slows things down and is a little bit annoying. With that said, you will want it because the Z-Probe isn't being engaged and retracted again and again. That is going to help your accuracy. But the other reason is it will print a topographical map of the bed. You are going to be amazed at how the glass is not flat. I think you are going to find you have high and low spots that consistently show up. I have one spot on my bed that I know to avoid on certain types of prints. Just crossing the changes over to the new code base shouldn't be too hard. But I'm thinking the G29 code should have run time options like how big 'n' is and how verbose to be. So it might take a little bit longer to get it all together.

    Quote Originally Posted by DrLuigi View Post
    /edit second try on another place,
    SENDING:M48 n 10 x 124 y 100 e v 2
    M48 Z-Probe Repeatability test. Version 1.60
    M48 'e' option specified.
    1 of 10 z: 2.789000
    2 of 10 z: 2.769000
    3 of 10 z: 2.760750
    4 of 10 z: 2.786000
    5 of 10 z: 2.760000
    6 of 10 z: 2.781250
    7 of 10 z: 2.759750
    8 of 10 z: 2.767750
    9 of 10 z: 2.772000
    10 of 10 z: 2.774750
    Mean: 2.772025
    Standard Deviation: 0.010128
    echo:endstops hit: Z:2.78
    Those are good numbers! Was the first set of numbers with the 'e' option not included? In other words, was the first set of numbers with the probe staying down and that is why its standard deviation is a little bit better than the second set of numbers?

    Quote Originally Posted by DrLuigi View Post
    I am kinda suprised, i thought it wouldnt be this accurate!

    Thanks for the script
    Before I fold my changes into the new code base I'm thinking I want to check out how much 'slop' is in the X and Y axis. I know what I want to do and soon there will be an extra parameter you can give the M48 code to stress the mechanics a little bit harder. I'm thinking your machine is going to do better than mine.
    Last edited by Roxy; 04-14-2014 at 05:49 PM.

  9. #9
    Super Moderator DrLuigi's Avatar
    Join Date
    Oct 2013
    Location
    Belgium
    Posts
    503
    Both copy/pasts are with the E option in my previous post,

    Well its not a whole lot diffrence then my first post when i didnt get the E option done.

    Well ye i kinda noticed that, that my glass isnt that flat, Thats why i actualy thought to get more probing points set into my marlin software, I've got 9 at the moment (config set at 3 per dimension)


    Wouldnt a X pattern for probbing points be better, To make the printer see the diffrence in the glass.
    Then what we have now in a Square.
    Last edited by DrLuigi; 04-15-2014 at 11:57 AM.

  10. #10
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,120
    Quote Originally Posted by DrLuigi View Post
    Wouldnt a X pattern for probbing points be better, To make the printer see the diffrence in the glass.
    Then what we have now in a Square.
    I don't know about that. However, the way the least squares fit of the data points works, it doesn't care about the pattern probed. It would not be very hard to probe in an X pattern if there was a good way to measure the results. I believe the correction matrix could be used to determine that.

    That raises another idea. Rather than having a generic pattern to handle everybody's needs, would it make more sense to allow the user to omit areas from the probing and least squares fit? If I know I have a small high spot, would it make sense to level the bed with some number of points but not include the 'bad' spot in the calculations? That very possibly is worth playing around with.

Page 1 of 7 123 ... LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •