Hello. Old thread I came across: https://klipper.discourse.group/t/feature-request-volumetric-flow-rate-limit/2739
And here is masterxq’s github: https://github.com/masterxq/klipper/blob/master/klippy/kinematics/extruder.py
I have made some changes to extruder.py. Here I have made some changes, so that I can read settings in the macro. This so that I can change settings while printing via the display. Since I am not good at python, I would like help to weed out any errors.
I have also tried to get filament diameter with, but had to use filament area. I can’t see that this is something I have a use for, but I’m trying to learn a bit too.
[gcode_macro P2]
description: P2 [A e0-dia] [B e1-dia] [C e0-speed] [D e1-speed]
gcode:
{% if 'A' in params%}
{% if (params.A|float <= 4.00) and (params.A >= 1.500) %}
SET_FILAMENT_DIAMETER EXTRUDER=extruder DIAMETER={params.A}
SET_MAX_EXTRUDER_VELOCITY EXTRUDER=extruder VOLUMETRIC_SPEED={printer.extruder.max_e_volumetric_speed} # Write back to provoke a new calculation after
{% endif %} # the filament diameter has changed.
{% endif %}
{% if 'B' in params%}
{% if (params.B|float <= 4.00) and (params.B >= 1.500) %}
SET_FILAMENT_DIAMETER EXTRUDER=extruder1 DIAMETER={params.B}
SET_MAX_EXTRUDER_VELOCITY EXTRUDER=extruder1 VOLUMETRIC_SPEED={printer.extruder1.max_e_volumetric_speed} # Write back to provoke a new calculation after
{% endif %} # the filament diameter has changed.
{% endif %}
{% if 'C' in params%}
{% if (params.C|float <= 50.00) and (params.C >= 1.000) %}
SET_MAX_EXTRUDER_VELOCITY EXTRUDER=extruder VOLUMETRIC_SPEED={params.C}
{% endif %}
{% endif %}
{% if 'D' in params%}
{% if (params.D|float <= 50.00) and (params.D >= 1.000) %}
SET_MAX_EXTRUDER_VELOCITY EXTRUDER=extruder1 VOLUMETRIC_SPEED={params.D}
{% endif %}
{% endif %}
{% if rawparams == "" %}
SET_MAX_EXTRUDER_VELOCITY EXTRUDER=extruder VOLUMETRIC_SPEED={printer.extruder.max_e_volumetric_speed} # Write back to provoke a new calculation after
SET_MAX_EXTRUDER_VELOCITY EXTRUDER=extruder1 VOLUMETRIC_SPEED={printer.extruder1.max_e_volumetric_speed} # the filament diameter has changed.
{% set vole0 = (printer.extruder.max_e_volumetric_speed*1000+0.5)|int/1000 %}
{% set movee0 = (printer.extruder.max_e_move_velocity*1000+0.5)|int/1000 %}
{% set diae0 = (((printer.extruder.filament_area/3.141592)**(1/2))*2000+0.5)|int/1000 %}
M118 Extruder0 Max Volumetric {vole0} Max Velocity {movee0} F-Diameter {diae0}
{% set vole1 = (printer.extruder1.max_e_volumetric_speed*1000+0.5)|int/1000 %}
{% set movee1 = (printer.extruder1.max_e_move_velocity*1000+0.5)|int/1000 %}
{% set diae1 = (((printer.extruder1.filament_area/3.141592)**(1/2))*2000+0.5)|int/1000 %}
M118 Extruder1 Max Volumetric {vole1} Max Velocity {movee1} F-Diameter {diae1}
{% endif %}
Understand what you plan about the menu is, this makes totally sense, but to be honest I don’t remember if I exposed the variables and how to access them.
Sadly I have currently no time to work on this, but a workaround could be to wrap the functionality through a macro and save this into a variable which can be access in other macros.
Did already solve the problem in python code?
If yes feel free to make a pull request against my repo, I will review it if I can find some time for it, and optionally merge it. If you want it merged please also update the documentation.
It will 99% never come into main klipper, but I update from main Klipper repo from time to time and I test the releases (only with single extruder), maybe you can skip this extra work…
Hi, and thanks for your reply! I kind of solved this in python. But I don’t know python. So it is possible that I will crash Klipper. And without me knowing that this is the problem. I have tried to make a pull request. The problem is that my brain protests every time I try to learn something new. Since it’s the first time, I don’t know if everything turned out the way I wanted it to. Hope you find time to look at this. These things have been given variables that can be used in macros:
{printer.extruder.rotation_distance}
{printer.extruder.max_e_move_velocity}
{printer.extruder.max_e_volumetric_speed}
{printer.extruder.filament_area}
{printer.extruder.nozzle_diameter}
I am a little unsure whether you can use extruder1 on everyone.
If I remember correctly, your extruder.py had 1 bug:
After restarting Klipper you must use
“SET_FILAMENT_DIAMETER EXTRUDER=extruder DIAMETER=”
before you can use (for each extruder)
“SET_MAX_EXTRUDER_VELOCITY EXTRUDER=extruder VOLUMETRIC_SPEED=/EXTRUDER_VELOCITY=”
I also don’t think that this is included in the main Klipper. It looks like the developers are very restrictive. But what you have achieved will remain on my printer as long as I manage to add it.
Again, many thanks, and I hope you find time to look at my pull request (and that I have actually managed to create a pull request).
Pull request failed, adding a zip file here. extruder.zip (4.7 KB)
Forgot:
I haven’t fixed the bug.
“Pull request creation failed. Validation failed: must be a collaborator”. I don’t know how this works. And I don’t know if there is any purpose in me becoming a collaborator. But I try to learn something new, even if my brain protests.