Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knomi 2 Macro G28 called recursively #63

Open
rmilyard opened this issue Feb 10, 2024 · 7 comments
Open

Knomi 2 Macro G28 called recursively #63

rmilyard opened this issue Feb 10, 2024 · 7 comments

Comments

@rmilyard
Copy link

When trying to home printer with sensorless-homing,cfg we are getting error: Macro G28 called recursively

What is going on? I believe I have newest firmware that was posted 2 months ago.

@Biffes
Copy link

Biffes commented Feb 27, 2024

Got this problem too. Maybe it is a collision between the sensorless.cfg and the knomi macro. Mainsail console logs about five g28 commands while the error happens.

@Specker
Copy link

Specker commented Feb 29, 2024

I was able to solve this.
If you have a [homing_override] in your printer.cfg you will have to change G28 in there with G28.1.
Similar to mine:
image
There might be more similar recursive calls that you will have to look for.

Think of it like.
old G28 gets renamed to G28.1,
new G28 sets variable to true, then calls old G28 by it's new name G28.1, and after it finishes sets variable to false.

When you try homing from the UI it will execute G28 and by extension [homing_override]. Which most likely also calls G28 with parameters X, Y or Z.
So without changing those variables it will call itself over and over again.

@Biffes
Copy link

Biffes commented Mar 2, 2024

Thanks for the reply, Specker!
I tested your solution and it worked! But i had to change the G28s in the sensorless.cfg too. I found another solution after looking for a fix to the bed mesh calibration for kamp here:
#25

I commented the Knomi G28 macro completly out

#[gcode_macro G28]
#rename_existing: G28.1
#gcode:
#SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=True
#G28.1 {rawparams}
#SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=False

and changed the macros in my sensorless.cfg like this:

{% if home_all or 'X' in params %}
SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=True
_HOME_X
SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=False
{% endif %}

{% if home_all or 'Y' in params %}
SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=True
_HOME_Y
SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=False
{% endif %}

{% if home_all or 'Z' in params %}
SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=True
G90
G0 X150 Y150
G28 Z
G1 Z10
SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=False

Worked perfectly and i dont have to mess around with modified G28s.

@jeffalanmcclain
Copy link

jeffalanmcclain commented Sep 11, 2024

It is STUPID that this is still an OPEN issue and affecting even pretty base setups. Thanks for your help figuring this out (I have same issue on bed mesh too). This is on FlashForge 5M Pro running KlipperMOD. Also, mine isn't seeming to pick up the nozzle temp change and initiate the graphic. But it does on bed temp?

...and I managed to recompile new FW with a new graphic for the start too replacing the Voron animated logo!
flashforgeicon

@jeffalanmcclain
Copy link

jeffalanmcclain commented Sep 11, 2024

Ok, I found a slightly BETTER way to do this. I don't like having to edit other config files when I add things (like knomi). And I really don't want things to break if I stop including knomi.cfg with the redefined macros intercepts in the revised [homing_override]. And, it looks like the problem is that [homing_override] is a pretty special macro that does NOT go through the macro rename checks first, it just calls RAW G28 function even if you redefine G28 (it doesn't call your new macro). And it doesn't work to redefine G28 rename old to G28.1 THEN create [homing_override] last (I was hoping it would try to resolve whatever was in place at that point, but it doesn't). HOWEVER, Klipper doesn't seem to complain if you REDEFINE [homing_override] again later (and, no, you can't do rename_existing: in homing_override..Klipper doesn't allow it...sigh). So, I cut and paste the original [homing_override] from my printer.base.cfg that runs / includes in printer.cfg earlier, and paste it at the bottom of my knomi.cfg and change the G28 to G28.1 THERE locally and it works beautifully. It would be better if defining the routine AFTER the rename G28 to G28.1 would just work with G28, but it don't. Now, if I ever want to remove knomi, I just remove the [include knomi.cfg] and the original [homing_override] that is still untouched never gets stomped and everything works.

@xdased14x
Copy link

Ok, I found a slightly BETTER way to do this. I don't like having to edit other config files when I add things (like knomi). And I really don't want things to break if I stop including knomi.cfg with the redefined macros intercepts in the revised [homing_override]. And, it looks like the problem is that [homing_override] is a pretty special macro that does NOT go through the macro rename checks first, it just calls RAW G28 function even if you redefine G28 (it doesn't call your new macro). And it doesn't work to redefine G28 rename old to G28.1 THEN create [homing_override] last (I was hoping it would try to resolve whatever was in place at that point, but it doesn't). HOWEVER, Klipper doesn't seem to complain if you REDEFINE [homing_override] again later (and, no, you can't do rename_existing: in homing_override..Klipper doesn't allow it...sigh). So, I cut and paste the original [homing_override] from my printer.base.cfg that runs / includes in printer.cfg earlier, and paste it at the bottom of my knomi.cfg and change the G28 to G28.1 THERE locally and it works beautifully. It would be better if defining the routine AFTER the rename G28 to G28.1 would just work with G28, but it don't. Now, if I ever want to remove knomi, I just remove the [include knomi.cfg] and the original [homing_override] that is still untouched never gets stomped and everything works.

can you show me the knomi cfg you use trying to fix mine

@jeffalanmcclain
Copy link

jeffalanmcclain commented Oct 20, 2024

well, mine is quite a bit different from anything anyone uses because I have a pretty custom status for LED control and a bunch of other things all broken out...but I can add it here. Doubt it helps.

`
[gcode_macro _KNOMI_STATUS]
variable_homing: False
variable_probing: False
variable_qgling: False
variable_heating_nozzle: False
variable_heating_bed: False
gcode:

[gcode_macro _STATUS_KNOMI]
gcode:
{% set status = printer['gcode_macro _STATUS_VARIABLES'].printer_status %}

{ action_respond_info("Printer status in KNOMI.CFG is: " ~ status) }

{% if status in ["READY", "PRINTING", "BUSY", "HEAT_SOAKING", "HEAT_SOAKING_END"] %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=False
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=probing VALUE=False
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=qgling VALUE=False
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=heating_nozzle VALUE=False
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=heating_bed VALUE=False
{% elif status == "HEATING_EXTRUDER" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=heating_nozzle VALUE=True
{% elif status == "HEATING_EXTRUDER_END" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=heating_nozzle VALUE=False
{% elif status == "HOMING" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=True
{% elif status == "HOMING_END" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=homing VALUE=False
{% elif status == "HEATING_BED" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=heating_bed VALUE=True
{% elif status == "HEATING_BED_END" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=heating_bed VALUE=False
{% elif status == "BEDMESH" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=probing VALUE=True
{% elif status == "BEDMESH_END" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=probing VALUE=False
{% elif status == "EVELING" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=qgling VALUE=True
{% elif status == "EVELING" %}
	SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=qgling VALUE=False

{% elif status == "CRITICAL_ERROR" %}

{% elif status == "NOZZLE_CLEANING" %}

{% endif %}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants