Printer.query_endstops.last_query['z'] unexpexted value

Basic Information:

Ender3 / BTT SKR mini E3 V3 / BTT PI v1.2 / Sprite printhead
Nothing in klippy.log even after energency stop.

Describe your issue:

Trying to add Klicky probe on magnets, connected to z-endstop switch pins.

z-endstop switch removed, probe for z-axis homing.

To deploy the probe I need to move unhomed Z-axis down until magnets attach the probe.

The unhomed z-axis can be anywhere after the previous print, so the idea was to move Z-axis down step by step by 5 mm, checking after each step the switch status until the probe is attached and the switch status changes from TRIGGERED to open.

I use
endstop_pin: probe:z_virtual_endstop in [stepper_z] section
[homing_override] as in Klipper docs
Envoke QUERY_ENDSTOPS each time before trying to get printer.query_endstops.last_query[‘z’]

Due to unexpected values I get I made a small macro that does nothing but 2 times reading printer.query_endstops.last_query[‘z’]

[gcode_macro MY_TEST_MACRO]
description: find solution
gcode:
M118 “running MY_TEST_MACRO”
QUERY_ENDSTOPS
{% if printer.query_endstops.last_query[‘z’] == TRUE %}
M118 printer.query_endstops.last_query[‘z’] is TRUE i.e. z-endstop switch is triggered
M118 safe to move Z-Axis down by 5mm
M118
{% else %}
M118 printer.query_endstops.last_query[‘z’] is NOT TRUE
{% endif %}
G4 P3000 ### PAUSE 3sec
QUERY_ENDSTOPS
{% if printer.query_endstops.last_query[‘z’] == TRUE %}
M118 printer.query_endstops.last_query[‘z’] is TRUE i.e. z-endstop switch is triggered
M118 safe to move Z-Axis down by 5mm
M118
{% else %}
M118 printer.query_endstops.last_query[‘z’] is NOT TRUE
{% endif %}

So the results of macro executing. Probe is not attached = swith triggererd.
Firmware restart and running macro:

23:08 echo:
23:08 echo: safe to move Z-Axis down by 5mm
23:08 echo: printer.query_endstops.last_query[‘z’] is TRUE i.e. z-endstop switch is triggered
23:08 x:open y:open z:TRIGGERED
23:08 echo:
23:08 echo: safe to move Z-Axis down by 5mm
23:08 echo: printer.query_endstops.last_query[‘z’] is TRUE i.e. z-endstop switch is triggered
23:08 x:open y:open z:TRIGGERED
23:08 echo: “running MY_TEST_MACRO”
23:08 MY_TEST_MACRO

Everything as expected.
Doing nothing and running macro again.

23:11 echo: printer.query_endstops.last_query[‘z’] is NOT TRUE
23:11 x:open y:open z:TRIGGERED
23:11 echo: printer.query_endstops.last_query[‘z’] is NOT TRUE
23:11 x:open y:open z:TRIGGERED
23:11 echo: “running MY_TEST_MACRO”
23:11 MY_TEST_MACRO

And this is not what was expected/ z:triggered that is ok, but printer.query_endstops.last_query[‘z’] is NOT TRUE

Please can anyone help me? I’m in a deep dead end (

Hello @PaulS !

Please attach it to your next post anyway.

And please: When pasting code, use the Preformatted Text feature of the forum editor. Else the code can be messed up.

Format

klippy.log (49.6 KB)]

Sorry, log appeared after emergency stop. Attached.

I have found my problem / solution.

  1. Calling QUERY_ENDSTOPS is to be done before starting MACRO, that checks printer.query_endstops.last_query[‘z’] value. This is RTFM )
  2. Changing check condition from
`{% if printer.query_endstops.last_query[‘z’] == TRUE %}`

to

{% if printer.query_endstops.last_query[‘z’] %}

works good.

Thnks everybody! )

1 Like

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