What is Klipper's homing sampling rate?

Thanx for the link, the material regarding the probes at the start was good, but the discussion of the mechanical switches is pretty cringe-worthy.

I’m trying to remember if I’ve ever used the MakerBot switch PCBs in any of my printers. I have a half dozen in a parts drawer but I think the two times or so I wanted to try them out in a printer either their mounting holes were in the wrong spot of the cable coming out of the end was a problem. I don’t think I ever have - I went with plain microswitches as that gave me more control over their placement. I have used them in some robot projects because of the built in LED but not for printers.

When I got my first 3D printer (2011) there were people who were making their own end switches out of a couple of pieces of copper sheet and bouncing was a real concern but snap action microswitches or dome switch buttons are, for all intents and purposes bounce free. Here’s are links that discusses what’s inside them and kind of describes how they work:

I know people will come back with “all switches bounce” but that’s really not the case - it’s ironically demonstrated by the Makerbot board which inadvertently defeats the bounce filtering. If you think switches bounce then set up a microswitch or a dome press button with a power supply with an LED/resistor and an oscilloscope and look at the voltage across the LED.

It was interesting to look back and see that using Normally Closed switches was a safety feature. I don’t know how practical it was because without any kind of reasonably sophisticated programming, the MCU is going to read a broken cable as the endstop being active and keep moving the gantry/bed in the opposite direction until it crashes into something at the other end.

You noted:

That’s not quite true, the direct connection of the NO contact to Vcc in the Makerbot design bypasses the two 10k resistors which eliminates the low pass filter function that they seem to feel is necessary…

Actually, the driving reason in my memory was that triggering HIGH had the big disadvantage that faulty endstops or wiring were only detected when it is too late. If the pin is default HIGH and pull to GND when the switch opens (NC design) then you would easily detect, e.g. a broken cable

Damn, most of this blurp, I have written pretty exactly 6 years ago: Endstop documentation by Sineos · Pull Request #164 · MarlinFirmware/MarlinDocumentation · GitHub

I’d say, mainly because the optical were unreliable like hell as they are still today.

Not sure how reliable the simulation is (and my electronics knowledge is not sufficient), but still interesting:

  1. Adding the 10k pull-up in the VCC line changes the simulation completely
  2. Adding the “boards” Cap to GND and it will no longer work

I wonder about the reasons for this behavior or my modelling is just crap.

IF the switch weren’t tied to VCC and it did have the RC time constant, since the resistors and capacitors on both sides are in parallel and the same values (at least in the circuits we’ve been looking at). The capacitance would double but the resistance would halve and you’d end up with the same RC time constant.

So it’s just redundant components with no additional value and no change in delay.

Again, The Makerbot switch ties directly to VCC so that bypasses the whole thing and makes the resistor and capacitor useless anuyways.

You take that back!

https://www.mouser.com/datasheet/2/414/OPB960_990-3241431.pdf

5.0 uS propagation delay, 70nS rise/fall time.

I personally have hall effect endstops on my main printer for no real compelling reason, They use a ratiometric hall effect sensor and an analog comparator. There are analog comparators with picosecond response times if someone wanted to be that extreme.

I think you already got your answer. But, to confirm, Klipper samples the endstop faster when the axis is moving faster. The code snippet cited by @gaolst above is correct - the goal is to perform an endstop sample for every step pulse sent to the stepper motor driver. That is, one endstop sample per microstep.

The ENDSTOP_SAMPLE_TIME and ENDSTOP_SAMPLE_COUNT are separate (and perhaps confusingly named). These indicate the number of additional samples to perform after the first trigger report. This implements a kind of “debouncing” on the endstop line to filter out high frequency line noise. That is, the endstop must remain triggered for four consecutive readings each 15us apart. Note that this additional time should not impact the endstop precision as the host goes on to calculate the trigger position from the original trigger time.

For what it is worth, I wouldn’t worry too much about minor timing delays in the endstop switch. As long as those delays are constant (and one keeps the homing speed constant), they’ll “fall out” of the overall homing operation. The core goal of homing is to find a reproducible position. Once one has a reproducible position, the standard tuning of the position_endstop setting will automatically encompass any static delays or static offsets.

Cheers,
-Kevin

3 Likes

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