Trying to Understand and use M585



  • Background:

    3d Printer (Railcore 2 250 ZL, duet and duex5). Firmware 2.02 (release)

    Prior to M585, G10 L1 P0 reports offsets all zeroes.

    Macro:

    M574 Z0 S1
    G90
    G1 Z15 F300
    G1 X8 Y84 F1200
    M585 Z11.15 E2 L0 F60 S1

    Switch is connected to ZMin; triggers appropriately as reported by M119. The macro aligns the nozzle with the switch and probes to it. It stops on switch trigger. The switch triggers at 3.85mm above 0 on the bed, and we want to set the tool offset for this nozzle such that the nozzle tip will be at ~0 if we command a G0 Z0 for Tool 0 (in this case).

    Running this macro results in:

    G10 L1 P0
    Tool 0 offsets: X0.00 Y0.00 Z22.29, active/standby temperature(s): 0.0/0.0

    So I think, maybe it wants the actual trigger height, and try it with:

    M585 Z3.85 E2 L0 F60 S1

    Which results in:

    G10 L1 P0
    Tool 0 offsets: X0.00 Y0.00 Z14.99, active/standby temperature(s): 0.0/0.0

    So I really want the M585 to set this tool's Z offset such that it will be at 0 when we command T0; G0 Z0.

    What is it that I'm failing to understand here? I'm fairly certain I can make it work with a single tool by homing Z to this switch and setting the offset to 3.85, but that won't help with multiple tools (which is the problem we want to solve - i.e., offsets for T0 and T1 and T2 😄 )

    Thanks!

    jstevewhite



  • Ok. A little more information - this appears to do what I want it to do now:

    M574 Z0 S1
    G90
    G1 Z15 F300
    G1 X8 Y84 F1200
    M585 Z-11.05 E2 L0 F60 S1

    So the trick is to take the trigger heigh (4.95, in this case), subtract it from the travel distance (15mm; that's where we start the M585 from). Then we put it in the Z parameter, negative: Z-11.05. This produces a tool offset of ~0.0 (sometimes 0.01, sometimes -0.01), which is what I would expect as Z was set with an offset for this tool in the Z probe for Z homing. Adjusting the nozzle so the height changes alters the tool offset predictably.

    Next test will be to take out the Z value in the probe setting - or set it to 0 - and see if it gives me the same value for the offset I have now (1.92mm).

    Thanks!

    jstevewhite



  • One last update:

    So I set my bed probe Z offset to 0 (BLtouch). I then homed Z, and ran the "tool offset" macro, and it assigned a very similar number to the tool offset ( I had 2.05 in my Z probe offset, and the tool offset macro set it to 2.04 ). Then I commanded G0 Z0 and it behaved correctly.

    So I believe if I add M501 to my config, run the tool offset, issue M500, I should be good to go. Then when I change nozzles or hot ends, I can run the tool offset macro and M500; no more paper tests for offset config >:)


  • administrators

    I'm glad you got it working. Chrishamm is the person who implemented and used M585, so he knows more about it than I do and may have some observations.



  • I was following this thread out of curiosity and one observation I have is that the documentation seems to be backward. Based on the documentation I also would have guessed to have a positive Z value as @jstevewhite tried first. But it turned out a negative value had to be used. So @chrishamm, does the documentation need to be fixed there? Or is the implementation wrong?


  • administrators

    @wilriker The documentation says:

    The values of the XYZ parameters are the absolute distances between the position at which the endstop is actually triggered and your own start position. It is mandatory to measure this distance once before M585 can be used reliably.

    So say the endstop is triggered at X=20 and you started probing at X=10, the X parameter would be -10. Is this not the case?

    I think we could change the behaviour of M585 with another parameter to specify the expected trigger position instead of the expected deviation/offset (there's another post about this topic here on the forum) but I am still wondering which parameter would be suitable for this. Also, I don't have access to a tool probe any more so it would be rather difficult for me to test any changes. I implemented and tested M585 in July when I had access to a more sophisticated machine.



  • @chrishamm said in Trying to Understand and use M585:

    So say the endstop is triggered at X=20 and you started probing at X=10, the X parameter would be -10. Is this not the case?

    As I said I was just following this thread out of curiosity. As far as I understood @jstevewhite's setup the starting point was at Z=15 and the trigger point was at Z=3.85 (absolute values above Z=0). This would mean he needs a Z parameter of 11.15 as he originally tried. But in the end it turned out that he needs to set Z-11.15 so the negative value.

    Now it might be that I did not understand something here correctly as I don't have a tool probe nor do I even have a changeable tool in the first place. Just what I got from following and reading on the M585 documentation.



  • I have since gotten the system working (mostly) properly. Here's my macro (note I changed switches, so trigger height changed to 2.92):

    ;; NB Your G31 must be set to 0 G31 X0 Y30 Z0 P1
    ;; M585 needs 15 (because that's where we start ) - trigger height of switch
    ;; so mine is 15-2.92 -12.08
    ;;G1 X0 Y82.1 moves my nozzle over the switch. YMMV. 😄

    M574 Z0 S0 ; set up the Z min endstop
    G10 L1 P0 Z0 ; remove any existing offset
    G28 Z ; home Z
    T0 ; select tool
    G90
    G1 Z15 F300 ; go to 15mm
    G1 X0 Y82.1 F3200 ; move to switch
    M585 Z-12.08 E2 L0 F60 S1 ; probe
    G1 Z15 F600; move back off the switch

    I've tested this ... many 🙂 ... times and it produces the behavior I expected; that is, it sets the tool offset such that when I G0 Z0, the nozzle is at the bed. I can swap hot ends or nozzles, run the tool offset macro, M500, and start printing. I'm starting at 15 and moving towards 0. It's not intuitive which sign should be the right one, in either sense, though I think the way it's implemented makes sense to folks who've grown up using CNC mills.


 

Looks like your connection to Duet3D was lost, please wait while we try to reconnect.