Automatically setting M558 Z value
I would like to automatically set the Z offset of my BLTouch. is that something that can be done? How I want to do it is by using the stall detection or some other means to detect contact with the actual tool tip. Then after I have a Z=0 of the tool tip, I can probe the same spot with the probe. Is there a way to take that report of the triggered height from an M30 S-1 command and use it to set the Z in the M558?
Or perhaps I'm thinking of this incorrectly. If I use the BLTouch and give it an arbitrary Z of say 3mm. I can then probe the bed and set that as Z=0. I can then switch to using stall detection for my Z probe and use the G30 S-2 to adjust the Z offset of the current tool.
Would either of those methods work? I'm just looking for a rather user simplified way of getting the Z offsets set up to simplify getting a print started. I want this because I often change my nozzles, and my secondary nozzle is adjustable so I can raise and lower it manually if I want to get it out of the way for single nozzle prints or if I want to get the primary out of the way by lowering the secondary below the primary. But this all takes time to get the Z offset setup each time I do this. And I do this quite frequently and for nearly each print.
Yes, this can be done with a macro.
Whether or not you can use stall detection on the Z axis will depend on your z axis setup. Works best with a single motor, ungeared connection to the lead screws, and little flex in the print head or bed. An alternative to stall detection would be using manual probing which prompts you to jog the print head down until it touches the bed. This isn't exactly automatic at that point though. Once Z0 is defined you can script the move to actually measure the offset and save it with G30 S-3 and M500 P31 to save it and M501 at the end of config.g to load them at startup.
@Phaedrux I do have a single direct drive ball screw for my Z. I tried playing with the stall detection in the past but I had absolutely no luck getting it to trigger. I reduced the motor current to the point where it would skip steps trying to even move.
I decided to have a look at that script (macro) that I was using for those test and it is apparent to me now that it would have never worked. I was using just a regular G1 Z-2 F200 command. I seem to have forgotten or didn't know I needed the H1 parameter. So it is possible that the stall detection was working, but nothing was paying any attention to it.
I'm not sure why I never noticed that G30 S-3 parameter before, but that would let me do option 1.
Is either option better than the other, to use the probe as essentially my min endstop and set my tool offsets relative to that? Or use tool 1 as my 0 and set the probe offset to it?
The head reference point 0,0,0 is usually the nozzle tip of the T0 and every other offset is from that. It just keeps things simple. So I guess I don't really understand your question.
If you give stall detection another try and it works for you, you might even be able to use it as your main probe and eliminate the probe offset entirely.
@Phaedrux I managed to get the stall detection working. I just reduced the motor current to 25% and then set the sensitivity to 10 and that seems to work nicely.
but the M500 P10:31 does save the probe offset but only the Z part, the X and Y it set both to 0 rather than what they are supposed to be set at(X55 and Y48). is there a way to change that?
I'm not sure. Have you tried just using M500 P31? I thought you were trying to save the height offset. The X Y offset isn't changing so you can just set it in your normal G31. Not sure why you'd want to save a tool offset as well.
@Phaedrux nope but I’ll give that a try.
@Phaedrux I seem to be having an issue with the M500 P31 command while executed inside of a macro.
;Macro for Z probless testing ;G28 X Y Z ;Home all individually M561 ; do not use mesh tranform M400 ;Configure to probe bed with BLTouch M558 P9 C"^io4.in" H60 F200 T12000 ; set Z probe type to BL touch and the dive height + speeds G1 X-55 Y-48 F12000 ; Move BLTouch to center of the bed M18 E0:1 ; Disable stepper drivers for extruders G30 ; Probe bed and set position to probe offset G1 X0 Y0 F12000 ; Move tool head to center of bed ;G1 Z100 F600 ; Move Z-axis to 100mm G1 Z10 F350 ; Move Z-axis slowly to 10mm ; configure the sensorless homeing here M400 ; make sure everything has stopped before we make changes M574 Z1 S3 ; set Z endstop to use motor stall M915 Z S10 F1 H200 R1 ; Configure stall detection M913 Z25 ; reduce motor current to 25% to prevent belts slipping ; Start to move Z axis to test the stall detection G1 H1 Z-2 F300 ; move the bed up until it hits something then stop and set to limit minimum G92 Z0 ; Set current postion to Z0 rather than axis minimum G91 ; Set to relative movement G1 Z5 F650 ; Move bed down a few mm so that we can centre the head G90 ; back to absolute positioning ; Configure stall detection as a bed probe ;M400 ; compete all moves before makeing changes ;M558 P10 X0 Y0 Z0 F200 T12000 H3 ; Configure Z probe as stall detection with Z offset of 0 ;G1 X0 Y0 F12000 ; Move to center of the bed ;G30 ; Probe the bed in the center with stall detection and set position to Z offset ;G1 Z10 F300 ; Move the bed down to 10mm ; Set back the probe to BLTouch M400 M558 P9 C"^io4.in" H3 F200 T12000 ; set Z probe type to BL touch and the dive height + speeds G1 X-55 Y-48 F12000 ; Move BLTouch to center of the bed M18 E0:1 ; Disable stepper drivers for extruders G30 S-3 ; Probe the bed and report the height at which the probe was triggered ; Restore the use of the maximum limit switch on Z. M400 ; make sure everything has stopped before we reset the motor currents M913 Z100 ; motor currents back to normal M574 Z2 S1 P"io2.in" ; configure active-high endstop for high end on Z via pin io2.in use a NC switch G1 Z10 F250 ; Move Z axis to 10mm M400 ; Wait until all code is executed G31 X-55 Y-48 ; Reset probe offsets G31 ; Recall Probe parameters M500 P10:31 ; Save parameters to Config-overide.g
If I check the config-overide.g after this has executed the
; Z probe parameters G31 P500 X0.0 Y0.0 Z0.70
which is not correct.
If i run the M500 P31 after the macro has finished executing then I get
; Z probe parameters G31 P500 X-55.0 Y-48.0 Z2.68
Which is correct. Am I chasing a dead end trying to run M500 from inside a macro as it is not possible, or have I missed something in my macro.
baird1fa last edited by baird1fa
@Phaedrux 3.1.1. I upgraded at your recommendation on the BLTouch issue I was having which turned out to be interference from the extruder steppers being active.
Ah yes. We'll have to see what @DC42 has to say about the difference between in the macro and out of the macro execution of M500 P31.
@Phaedrux I've also setup my bed.g to call that macro as part of the bed calibration so that it is super easy to call with the G32. I end off the bed.g with an M500 G31 to see if that helps. But right now I have a failed print laying on the bed and I don't feel like driving across down for an hour to clear it off. So I won't be able to do anymore testing where the nozzle has to touch the bed for a day or so.
@Phaedrux well I was able to get the bed cleared off and run my G32 (bed.g) which I added a link to my macro and after the macro I added the M500 P31 in the bed.g and that saved the offsets correctly. So that gets me a work around.