Macro to stop printing, run some code and then resume print



  • I'm looking to mace a macro on my printer pause the current print, run a set of gcode commands that pulse a pin and delay, and then return to the print as if nothing has happened. The machine is a DuetWifi and DueX5

    I have created "Trigger2.g" in the "sys" folder and have added "M581 T2 S1 E2 C0" in config.g that will invoke trigger 2 on rising edge on E2 endstop regardless of print status. I have attached a switch to the E2 endstop connector on the dueX5 and when i have the "Trigger2.g" contain just

    M42 P100 S255
    G4 P10
    M42 P100 S0
    
    ```the pin is pulsed, however after adding more commands to the file the commands seem to be interlaced with the print commands and the print doesnt stop.
    

    [[language]]
    ;Switch to relative, lift Z 10 mm and return to absolute.
    G90
    G1 Z10
    G91

    G1 X100 Y300 F4800; Move to purge location

    ;Pulse to open the valve
    M42 P100 S255
    G4 P10
    M42 P100 S0

    G4 S60; Delay for 60 seconds

    ;Pulse to close the valve
    M42 P100 S255
    G4 P10
    M42 P100 S0

    G4 S5; Delay for pressure build up

    I'm stuck on how to proceed with pausing the print, running commands and then resuming the print properly.


  • Try to add a M400 command at the beginning of your macro…


  • administrators

    Use M25 to pause the print, then do the M42 commands, then M25 M24 to resume the print.



  • Resume with M25 or M24?


  • administrators

    M24.


Locked
 

Looks like your connection to Duet3D was lost, please wait while we try to reconnect.