Potential flow width comp macro

I’ve only got the start of it currently. As it stands, it doesn’t do any sort of buffering nor compensate for a preset flow if you use a filament preset macro or extension.

I’ll paste it here so you can see, mind you I haven’t tested it.

[gcode_macro _width_comp]
variable_diameter_pure: 1.75
variable_diameter_current: 1.75
varable_filament_used: 0
gcode:
    {% if printer["gcode_macro _variable_loop_width_comp2"].length_saved <= printer["gcode_macro _width_comp"].filament_used %}
    {% set flow_multiplier = ( 1.75 - printer["gcode_macro _width_comp"].diameter_current) / printer["gcode_macro _width_comp"].diameter_current * 100 %}
    M221 S{flow_multiplier}

[delayed_gcode _variable_loop_width_comp]
gcode:
    save_gcode_variable macro=_width_comp variable=filament_diameter_current value={'%.2F' % printer.hall_filament_width_sensor.Diameter}
    save_gcode_variable macro=_width_comp variable=filament_used value={printer.print_stats.filament_used|float}
    _width_comp
    update_delayed_gcode id=_variable_loop_width_comp duration=1

[delayed_gcode _variable_loop_width_comp2]
variable_length_saved: 1.75
gcode:
    save_gcode_variable macro=_variable_loop_width_comp2 variable=length_saved value={printer.print_stats.filament_used|float}
    update_delayed_gcode id=_variable_loop_width_comp2 duration=10

I have a basic rundown of it as it stands but work needs to be done (and I need to get a width sensor made :sweat_smile:)

_width_comp is what largely controls the flowrate with the sensor, however polling the extruder isn’t easy, or possibly accurate, with just macros, this might get thrown off with really slow speeds like in arc overhangs. it basically gets the percent of the read vs an ideal size, then sets it to that.

the two loop macros are largely meant to read the filament width and the extrusion length. Since a filament width sensor only polls every 10mm of filament. I tried to get down to that metric. Thankfully TheRationalPi came in clutch with how he did it for his delayed runout.

I don’t think it’ll be accurate in its current state. I have no clue how to buffer the values based on the extruded filament for it with just macros. I may have to upgrade to polling from moonraker. There’s also the fact that it might interfere with other macros or post scripts that modify the flow via M221, and I’m not sure if PA will need to be adjusted as well.

It’s also been mentioned a lot that only 1 measurement isn’t enough, as the filament is usually an oval. with that in mind, you’d just need 3 of them per extruder and then take the mean, but they’d all be offset unless you managed to make 3 sensors read from the same point.

Again it’s only a concept at best, an untested one at that, which is why I posted it in general, but I’m hoping I can get some semblance of Marlin’s width sensor flow comp working, or potentially a better version.

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