Encoder runout will only pause when switching to T0, T1 and T2 runout does not trigger

Home built Core XY (Rail core XL meets Hypercube)
Rockpi4b+ / BTT Octopus V1.1
X Y are MKS servo42c
3 in 1 out non-mixing hotend.
3 BTT encoder type runout switches.
klippy.log (905.9 KB)
printer.cfg (22.9 KB)
3_color_test plate_1_2_3.gcode (309.4 KB)

I have a core XY printer with the X and Y are MKS servo42c closed loop. Duel Z with the TMC2209. 3 extruders also TMC2209. Each with a BTT encoder runout switches.

When I run a 3 color test print (or any color print) anytime it switches back to the default extruder T0 it will pause. The other two extruders are fine, only when it goes to the T0. It is fine switching from any other extruder to any other one, it is only if you go back to the T0. I changed the pins around in the config to make sure it was not the encoder runout switch or my programing. To make the encoder runout switch to work when there is no filament it it, I have the switches disabled when not in use.

To help figure it out I set the pause on runout to False and requested the statics of the switches when triggered. As the print is printing I can see when it switches to the next color the switch will show empty for a split sec, but it does not trigger but only if it is switched back to T0.
I also used both Cura 5.4 and Simplified 3d

FYI if when you look at the log I have the Macro for T0 enabling the runout switch before T0 and T1 and T2 has it after it is switched… I tried it every different combination… it is just left the last way when I tried it last…so please do not point that out… I already did that… Yes I moved the switch to a different extruder and I tried the cable to see if it moved from T0 and I said above I moved T0 to T2. via the pins and it stayed with T0

Thank you for verify this as a bug. I may suggest a option to do a “re-check” before it triggers switch just incase it is enabled when the encoder is at a dead / open spot. but again I saw that on each switch, but it only triggered a runout event on T0

Hello all, I think I have an idea to help. Can someone help me understand the delay_gcode and how i can use it when switching the extruder to not enable the runout switch for 3 sec?

Will the below work? If not please help me with it.

###########################################################

[delayed_gcode ENABLEFILAMENTSENSORT0]
initial_duration: 3
gcode:
SET_FILAMENT_SENSOR SENSOR=my_sensor_T0 ENABLE=1

[delayed_gcode ENABLEFILAMENTSENSORT1]
initial_duration: 3
gcode:
SET_FILAMENT_SENSOR SENSOR=my_sensor_T1 ENABLE=1

[delayed_gcode ENABLEFILAMENTSENSORT2]
initial_duration: 3
gcode:
SET_FILAMENT_SENSOR SENSOR=my_sensor_T2 ENABLE=1

[gcode_macro T0]
gcode:
# Deactivate stepper in my_extruder_stepper
SYNC_EXTRUDER_MOTION EXTRUDER=belted_extruder1 MOTION_QUEUE=“”
SYNC_EXTRUDER_MOTION EXTRUDER=belted_extruder2 MOTION_QUEUE=“”
# Activate stepper in extruder
SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE=extruder
UPDATE_DELAYED_GCODE ID=ENABLEFILAMENTSENSORT0 DURATION=1
# Deactivate Runout encoders not used
SET_FILAMENT_SENSOR SENSOR=my_sensor_T1 ENABLE=0
SET_FILAMENT_SENSOR SENSOR=my_sensor_T2 ENABLE=0

[gcode_macro T1]
gcode:
# Deactivate stepper in my_extruder_stepper
SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE=“”
SYNC_EXTRUDER_MOTION EXTRUDER=belted_extruder2 MOTION_QUEUE=“”
# Activate stepper in extruder
SYNC_EXTRUDER_MOTION EXTRUDER=belted_extruder1 MOTION_QUEUE=extruder
UPDATE_DELAYED_GCODE ID=ENABLEFILAMENTSENSORT1 DURATION=1
# Deactivate Runout encoders not used
SET_FILAMENT_SENSOR SENSOR=my_sensor_T0 ENABLE=0
SET_FILAMENT_SENSOR SENSOR=my_sensor_T2 ENABLE=0

[gcode_macro T2]
gcode:
# Deactivate stepper in my_extruder_stepper
SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE=“”
SYNC_EXTRUDER_MOTION EXTRUDER=belted_extruder1 MOTION_QUEUE=“”
# Activate stepper in extruder
SYNC_EXTRUDER_MOTION EXTRUDER=belted_extruder2 MOTION_QUEUE=extruder
UPDATE_DELAYED_GCODE ID=ENABLEFILAMENTSENSORT2 DURATION=1
# Deactivate Runout encoders not used
SET_FILAMENT_SENSOR SENSOR=my_sensor_T0 ENABLE=0
SET_FILAMENT_SENSOR SENSOR=my_sensor_T1 ENABLE=0

Probably not. initial_duration: 3 will call all these macros 3 seconds after printer start. If you want to delay the execution you need to do it via the UPDATE_DELAYED_GCODE DURATION

Maybe something like:

[gcode_macro __MYVARIABLES]
# Hidden helper macro for the sensor variable to be used later
variable_my_sensor: ''

[gcode_macro enable_runout_sensor]
# Helper macro to enable runout sensor
gcode:
    # Get the sensor that was specified in the tool macro
    {% set my_sensor = printer['gcode_macro __MYVARIABLES'].my_sensor %}
    # Activate the sensor
    SET_FILAMENT_SENSOR SENSOR={my_sensor} ENABLE=1

[gcode_macro T0]
gcode:
    # make sure all filament sensors are deactivated
    SET_FILAMENT_SENSOR SENSOR=my_sensor_T0 ENABLE=0
    SET_FILAMENT_SENSOR SENSOR=my_sensor_T1 ENABLE=0
    SET_FILAMENT_SENSOR SENSOR=my_sensor_T2 ENABLE=0
    # Deactivate stepper in my_extruder_stepper
    SYNC_EXTRUDER_MOTION EXTRUDER=belted_extruder1 MOTION_QUEUE=""
    SYNC_EXTRUDER_MOTION EXTRUDER=belted_extruder2 MOTION_QUEUE=""
    # Activate stepper in extruder
    SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE=extruder
    # "Globally" set the sensor to activate
    SET_GCODE_VARIABLE MACRO=__MYVARIABLES VARIABLE=my_sensor VALUE='my_sensor_T0'
    # Call enable_runout_sensor with a delay of 3 sec
    UPDATE_DELAYED_GCODE ID=enable_runout_sensor DURATION=3

You will need to repeat this for the other tools and adapt the SET_GCODE_VARIABLE MACRO=__MYVARIABLES VARIABLE=my_sensor VALUE='my_sensor_T0' to the respective sensor.

Untested, may burn down your house.

Edit:

  1. Fixed typo
  2. Yet another one
  3. Reserved for future fixes
  4. Reserved for future fixes

Thank you, I am beginning to understand the flow… I will give this a try and let you know.

Sorry your code has an error in it. I tried to fix but was unable too.

And the error would be?

This is missing the gcode:

{% set my_sensor = {printer[‘gcode_macro __MYVARIABLES’].my_sensor }

This one first had "expected : receved } " I addedd the : and also I tried to closed the missing } at the end. but no good

I am testing a deferent code now with just switching the encoder off and on without delay, but I added the pull up “^” in front of the pin (per a voron build… google) Setup a BTT Smart Filament Sensor | Voron Documentation It worked on my small test three times with out issue, I am doing a more complex print now to test it… It will be nice to only have to use the pull up to give it a “detected state” when enabled. I do like the way your idea was flowing. I may still try to figures it out with help.

Did I mention I hate macros?

{% set my_sensor = {printer['gcode_macro __MYVARIABLES'].my_sensor }

to

{% set my_sensor = printer['gcode_macro __MYVARIABLES'].my_sensor %}
2 Likes

thanks… I will give it a try again I like this. it is “cleaner” then what I have working.

I am sorry but your code does not fix the T0 is the only motion sensor working.T1 and T2 does not trigger regardless of my config. It has to be within the code of the “motion que” but I did get it to work with enabling the sensor. I can also get it to work if I switched out the smart runout sensor with a dumb switch. but then why use Klipper if I have to dumb it down? I will switch back to Marlin if I have too. I need the encoder type runout switches not a dumb runout.

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