Nozzle Z-position measuring

Hello!

I made a lever that a servo motor can rotate above the plane of the bed. At the end of this arm, there is a small wire brush that wipes off the melted material from the nozzle, and behind the brush is a small metal cylinder under which there is a microswitch push button (Voron SexBolt endstop).

The plan is that with this tool, the machine can measure the exact Z distance of the tip of the nozzle, so that in the event of a possible nozzle replacement/hotend replacement/head replacement, it always automatically knows at what height the nozzle tip is.

According to my plans, the implementation would take place as follows:

1.: The servo raises the arm.

2.: Move the probe of BL-touch over the microswitch in X-Y.

3.: Homeing on Z axis, i.e. measures the Z position of the upper surface of the cylinder above the microswitch and resets itself to it. (As if we wanted to print on the push button.)

4.: He wipes his nose on the wire brush, so that no molten material remains on it, which would prevent accurate measurement.

5.: Moves the nozzle over the microswitch in X-Y.

6.: Slowly start to raise the bed, as well as the servo arm and the push button on it, until the microswitch is pressed. Practically, it is homeing only now not with the BL-touch but with the microswitch.

7.: The two Z values (the one with BL-touch and the one with microswitch) are subtracted from each other and saved by Klipper as “z_offset” in the [bltouch] section.

The problem with this is that I don’t know if it is possible or how to make it home once with BL-touch and once with endstop. For this, the configuration settings on the machine should be changed while it is running. Is this even possible?

The other question is that if you first homeing with the BL-touch and then somehow also with the microswitch, then I will not have two measured values, since all that happens (I think) is that the BL-touch is overwritten during the new homeing measurement result obtained with. That is, perhaps it would be more necessary to not perform real homing on the microswitch with the tip of the nose, but to slowly raise the stage and as soon as the microswitch switches to stop and save the current Z value.

I wrote a macro in Klipper with a cycle that raises the bed by 0.005mm and then checks if the microswitch is switched on. If not, raise it further and look again. If the button is on, save the Z value and exit the cycle. But I found out that, unfortunately, Ninja2 only evaluates the parameters when the macro is called, so it doesn’t work.

Even if all this is in place, it must be resolved that the z_offset value of the [bltouch] section in the configuration should be a variable that is sometimes overwritten by the machine itself with such measurements, and loaded by itself when Klipper starts.

There is this Klipper mod:

https://github.com/protoloft/klipper_z_calibration

This might be right for me, but the more I read, the less sure I am.

So, unfortunately, I don’t really know how to write macros and Klipper yet. Can anyone help me implement the above? ![:slightly_smiling_face:

(On the video, BL-touch does not work yet.)

Well, If you want a really messy Klipper module that does what you’re describing here you go.

tap_o_matic.zip (4.0 KB)

and your config is setup like

[tap_o_matic]
touch_pin: !Z3:PA0
touch_xy_position: 175,175
move_speed: 100
probe_speed: 15
touch_plate_clearance: 15

Be aware though, I was working on it over a month ago and got distracted with other stuff and glancing at it now it’s very… :grimacing:

In the sense of I barely made it past trying different ways to go about it.
It works but the code is an atrocious mess because I didn’t go back and clean it up.

Don’t know how familiar you are with python, but that should get you started.

Also be aware that doesn’t contain the servo code but your implementation is roughly what I was considering. I just didn’t make it that far.

Thanks! Please help, what do I need to do with this python file to use it in Klipper?

That’s a massive question.

I’d suggest you fork the repository if you haven’t already and start reading here:

https://www.klipper3d.org/Code_Overview.html

Look at the existing modules as you read the code overview to see examples of what is described until you get a “feel” for how the Klipper code is laid out and works.

To effectively be able to work on Klipper you’re going to need to setup an IDE and remote debugging (there is also a way with a “virtual printer” but I never figured that one out.)

Personally what I use is…

There is a free “community” version and a paid PyCharm Professional.
I have the Professional as I pay a monthly fee to use all the Jetbrains tools so I’m not sure if community can do this.

I believe VSCode can also remote debugging but not sure how to set that up.

How I have mine setup is as described here

When you set that up it tells you exactly how to set it up on your Pi running Klipper as well. Then you can set breakpoints and step through the Klipper code and watch it run and watch its values.

Sorry I can’t give an easy answer to that one. It’s akin to you saying “I want to put a Supercharger in my car” and me saying “I have this Supercharger I cobbled together with bits and pieces of parts to fit my car. I got it roughly working but decided to remove it later. Here you can have it.”

And you saying “Cool, How can I put this in my car?”

Maybe not QUITE as bad as that, since we’re all driving the same “Car” but trying to explain to you step by step how to install something like that is… Well… Extremely tedious for both of us and then you wouldn’t understand how to diagnose the problems that come up.

How can I call this code in Klipper?
And what is the “touch_plate_clearance”?

https://www.klipper3d.org/Code_Overview.html#adding-a-host-module

and touch plate clearance is how far the touch plate is above the bed

Thanks for the reply! I managed to add this mod to Klipper. I have set the [tap_o_matic] settings. But how can I perform this tap-o-matic measurement method? What command do I need to issue for the tap-o-matic measurement to be performed?

self.gcode.register_command("TAP_O_MATIC", self.cmd_TAP_O_MATIC,
                                    desc=self.cmd_TAP_O_MATIC_help)

It’s defined there.

The gcode is just “TAP_O_MATIC”

TAP_O_MATIC error
:frowning:

Yeah, Like I said it’s not going to be drop in plug and play. You’re going to have to setup a development environment and learn how to the Klipper code works.

I only meant to give you a little jump start, not a full solution.

At best it’ll keep you from having to totally reinvent the wheel.

I can’t program, so unfortunately I won’t be able to solve this. If someone could rewrite this code for me so that it works, I would be very grateful.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.