Conditional Gcode: Load Filament Macro



  • Goal

    Heat extruder and extrude filament until the Duet Filament Sensor observes movement.

    Issue

    Need help configuring the monitor to measure all filament movement. I am able to make this work by starting a fake print and monitoring movement (see below) but I would prefer not commanding the print head move.

    Here's what I've tried so far.

    M591 D0 S0 A1  ; disable pausing and monitor all extruder motion.
    G1 E75 F600  ; Extrude 75mm of filament
    

    But I receive this (no calibration data)

    Duet3D rotating magnet filament monitor v2 on pin e0stop, disabled, sensitivity 25.80mm/rev, allow 50% to 150%, check every 6.0mm, version 2, no calibration data
    

    Unfortunately, even though I've asked it to monitor all extruder movement, no calibration data is received.

    Using a The Macro and Gcode

    The overly complicated macro and print gcode below work, but would prefer not having to trick the printer into thinking it's printing and instead only extrude.

    Macro 0:/macros/Filament - Load 240c

    M591 D0 S0	; disable print pausing and check all extruder motion
    ;
    ; Run filament load print once
    M32 "0:/gcodes/Utilities/filament_load_240.gcode"	; run print to collect filament monitor data
    while state.status = "processing"					; wait for print to finish
    	G4 S1					; delay one second
    	continue
    ;
    ;
    ; continue if percentMin is still 0
    while sensors.filamentMonitors[0].calibrated.percentMin < 10
    	if iterations = 10		; after the tenth iteration
    		break				; stop
    	;
    	; beep to notify user of no filament
    	M300 P300 S1000
    	G4 P300
    	M300 P300 S2000
    	G4 P300
    	M300 P300 S3000
    	G4 P300
    	;
    	M32 "0:/gcodes/Utilities/filament_load_240.gcode"	; run print to collect filament monitor data
    	while state.status = "processing"					; wait for print to finish
    		G4 S1					; delay one second
    		continue
    	continue
    ;
    M591 D0 S1 	; enable print pausing and check print moves only
    

    0:/gcodes/Utilities/filament_load_240.gcode

    G90                                                          ; absolute positioning
    M83                                                          ; set extruder to relative mode enable relative extruder distances in the slicer
    T0                                                           ; select tool
    G10 P0 S240 R0						 	 ; Set active and standby hotend temperatures
    if !move.axes[0].homed || !move.axes[1].homed 	; If the printer hasn't been homed, home it
      G28 Y
      G28 X
    if heat.heaters[1].current < 200
    	M116
    G1 X0 Y-5 F24000
    G1 X100 E35 F2000
    G1 X0 E35 F2000
    G1 E-1 F600
    M400
    
    FIRMWARE_NAME: RepRapFirmware for Duet 2 WiFi/Ethernet FIRMWARE_VERSION: 3.01-RC3+1 ELECTRONICS: Duet Ethernet 1.02 or later FIRMWARE_DATE: 2020-03-10b4
    

    Edit: Have since upgraded to a Duet3

    Board: Duet 3 MB6HC 1.0 
    Firmware: RepRapFirmware for Duet 3 MB6HC 3.01-RC4 (2020-03-16b1) 
    


  • @dc42 Wondering if you can look at this before the next RC? A1 option of M591 does not appear to be checking all extruder movement. Does A1 still require a print to be in progress?

    Trying to find a way the filament monitor can be used to detect the filament movement for nonprint moves, I.E. has filament been loaded.



  • @dc42 I know you’re incredibly busy but can you take a look at this? I believe I have the filament monitor set properly to monitor all extruder movement but it still requires a print to be running in order to collect calibration data.



  • @dc42 This post is a week old and would appreciate a reply.

    Ran into another issue. When integrating this script into a print by adding the command below in the slicer. The print fails and is locked in a weird state with no errors in the log. It appears you cannot call a print from another print.

    Would like to run M591 D0 S0 A1 and have the filament monitor collect data for all extruder moves, not just prints.

    M98 P"0:/macros/Filament - Load 240c"		; verify filament is loaded
    

  • Moderator

    Thank you for your patience. The doctor will be with you shortly.



  • Shouldn't you have a P4 in the M591 to tell it the sensor type?



  • @OwenD said in Conditional Gcode: Load Filament Macro:

    Shouldn't you have a P4 in the M591 to tell it the sensor type?

    This is already in config.g

    M591 D0 P3 C"io8.in" S1 R50:150 L25.8 E6.0
    

  • administrators

    @mwolter, what do you want to achieve by monitoring filament movement while loading? It may be that enabling filament monitoring for extruder-only moves won't help anyway.

    If you want to load filament until it reaches the hot end, you can do that using extruder stall detection. See https://duet3d.dozuki.com/Wiki/Stall_detection_and_sensorless_homing#Section_Using_extruder_stall_detection_during_filament_loading.



  • @dc42 My attempt is to make a filament load macro that ensures a certain amount of filament has been extruded and it seems like the magnetic filament monitor would be perfect for this. Not sure stall detection would be very reliable. There could be cases where the filament is blocked in the hotend and a stall is detected but filament hasn't actually been extruded. By using the filament monitor, you can be sure the filament has been extruded.

    It seems like adding this capability (monitor filament movement without printing) would be useful in many situations and would sell quite a few filament monitors.

    A couple of weeks ago there was a discussion regarding adding the stall info (most recent load, max load and min load) to the object model in this post. This would be helpful also.


  • administrators

    Thanks for the clarification. There is more than one way to do this. One option might be to define another value of the M591 S parameter, which causes filament to be monitored during extrusion-only moves and a new calibration cycle to be started. Does that sound sufficient to you?



  • @dc42 Yes, an additional S parameter which monitors filament movement during all extruder moves (not just when printing from the SD card) would be perfect.

    Thanks for your time.


Log in to reply