Hello everyone!
I’m trying to install a Smart BTT Sensor on my Sovol SV08 printer. The sensor has 3 pins: S, V, G. It’s an optical endstop with a wheel that moves along with the filament during printing. If the wheel stops moving, it means there’s a clog, and the printer should pause for cleaning.
I connected this sensor instead of the standard filament_switch_sensor filament_sensor.
Here is the code I’m using:
#[filament_switch_sensor filament_sensor]
#pause_on_runout: True
#event_delay: 3.0
#pause_delay: 0.5
#switch_pin: PE9
[filament_motion_sensor BTT_Smart_Filament_Sensor]
switch_pin: PE9
detection_length: 7.0
extruder: extruder
pause_on_runout: True
event_delay: 3.0
pause_delay: 0.5
runout_gcode:
#PAUSE # [pause_resume] is required in printer.cfg
M117 Filament encoder runout
SET_IDLE_TIMEOUT TIMEOUT=600000
insert_gcode:
M117 Filament encoder inserted
When I start a print, an error appears in the console and the printer stops with an error.
The error message is:
18:10
Error evaluating ‘gcode_macro CANCEL_PRINT:gcode’: jinja2.exceptions.UndefinedError: ‘extras.gcode_macro.GetStatusWrapper object’ has no attribute ‘filament_switch_sensor filament_sensor’
18:10
Error evaluating ‘gcode_macro START_PRINT:gcode’: jinja2.exceptions.UndefinedError: ‘extras.gcode_macro.GetStatusWrapper object’ has no attribute ‘filament_switch_sensor filament_sensor’
I think the issue is caused by some kind of macro conflict, but I don’t have enough experience to fix it.
Could someone help me with this?
Alright, I figured it out. This solution might not be the most correct one, but it works.
Here’s what to do:
[filament_switch_sensor filament_sensor]
pause_on_runout: True
event_delay: 3.0
pause_delay: 0.5
switch_pin: extra_mcu:PA9
[filament_motion_sensor encoder_sensor]
switch_pin: PE9
detection_length: 7.0
extruder: extruder
pause_on_runout: True
event_delay: 3.0
pause_delay: 0.5
runout_gcode:
#PAUSE # [pause_resume] is required in printer.cfg
M117 Filament encoder runout
insert_gcode:
M117 Filament encoder inserted
Now the printer thinks that extra_mcu:PA9 always has filament inserted, and it only processes pause/runout errors from PE9.
Make sure to turn off the switch shown in the screenshot.
Welcome to the forum.
Your issue is the start_print macro looks for the filament sensor by the name you commented out.
[gcode_macro START_PRINT]
description:
variable_state: 'Prepare'
variable_record_extruder_temp:0
variable_max_record_extruder_temp:0
gcode:
{% set mesh_name = "default" %}
{% set mesh_calibrate_temp = printer['gcode_macro _global_var'].bed_mesh_calibrate_target_temp|int %}
{% set extruder_target_temp = printer.extruder.target|int %}
{% set bed_targer_temp = printer.heater_bed.target|int %}
M400
CLEAR_PAUSE
G90
{% if state == 'Prepare' %}
{action_respond_info("Prepare!")}
{% if printer.toolhead.homed_axes|lower != "xyz" %}
G28
{% endif %}
{% if printer**['filament_switch_sensor filament_sensor']**.enable == True and
printer**['filament_switch_sensor filament_sensor'].**filament_detected != True
%}
M117 No filament!!!
{action_respond_info("Please Insert filament in Sensor!")}
CANCEL_PRINT
{% endif %}
{action_respond_info("Check Heating!")}
M140 S{bed_targer_temp}
M104 S{extruder_target_temp}
{% if printer.heater_bed.temperature < bed_targer_temp %}
M117 Bed heating...
{action_respond_info("Bed heating...")}
M190 S{bed_targer_temp}
{% endif %}
{% if printer.extruder.temperature < extruder_target_temp %}
M117 Nozzle heating...
{action_respond_info("Nozzle heating...")}
M109 S{extruder_target_temp}
{% endif %}
{% if printer.quad_gantry_level.applied|lower != 'true' %}
QUAD_GANTRY_LEVEL
{% endif %}
BED_MESH_CALIBRATE ADAPTIVE=1
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=state VALUE='"Start"'
UPDATE_DELAYED_GCODE ID=_print_start_wait DURATION=0.5
{% elif state == 'Start' %}
M117 Printing now!!!
{action_respond_info("Start!")}
{% endif %}
Note under Klipper a [filament_switch_sensor]
And a [filament_motion_sensor]
Are not the same thing.
Configure the new sensor correctly. Uncomment the [‘filament_switch_sensor filament_sensor’] section and change the pin reference to an unused pin.
Add this near the top of your configuration.
[delayed_gcode startup_disable_filament_sensor]
initial_duration: 0.5
gcode:
SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0
OR search every macro for [‘filament_switch_sensor filament_sensor’] and edit it. Delete the check or point it at the new sensor. AFAIK Klipper sets the senor true at initialization. That would allow a print to start with no filament loaded but would stop when the sensor failed to toggle after 7mm of extruder moves.
Oops, cross posted. Glad you got it sorted.