G-Code Loop



  • In the current object model, is there a way to loop a section of gcode to continue during the duration of the print? I have a prototype pellet fed extruder with a Duet 3 6HC and a 3HC expansion all up to date running 3.1.1 and my pelllets feed was being controlled by a capacitive sensor, which has gone bad on me. I have another coming but i would like to continue printing in the mean time. I figured there would be a way to implement a while loop in the prints gcode to activate my air solenoid with M42, wait a small amount of time, deactivate the solenoid, then wait another amount of time, then repeat that while the print is going.

    I am having trouble finding much information on the current object model and have little experience in this type of logic. Any help would be appreciated.

    Thanks,



  • @R3D
    You should be able to do that by creating a daemon.g file

    You'll need to check if the state is printing, do your solenoid code then add a G4 for your dwell time.



  • How does RRF handle the daemon.g file? does it only run it during prints?



  • @R3D
    No it runs all the time so you have to check the state

    There's some more info here
    https://forum.duet3d.com/topic/14701/daemon-g-usage-cases/6



  • I'm not in front of a computer but something like

    if (state.status = "printing") && (layerheight > 0)
    M42 P5 S1
    G4 S10

    I can't remember the object model for the layer height but you may not care what layer it's on.
    Obviously I don't know what pin you want to control either.

    Be careful as if you make a mistake the daemon can't be stopped.
    You have to rename it to something else then delete it.



  • Ok, that is some interesting stuff... daemon.g is available in 3.1.1 or would I have to go to RC11 as it states in the last post? and in your statement it has a simple if statement, i'm guessing the daemon.g is being constantly queried causing the if statement to act as a loop?



  • @R3D
    Yes it is available in 3.1.1 but you must create it and place it in the system folder.

    And yes, the file is looped anyway so no need to create a loop in this instance.
    You must have the pause to suit your circumstances



  • Well this is definitely going to be a game changer for me, I will have to do some testing on one of my other test rigs to play around with this.

    Thanks a million @OwenD, I am constantly amazed on how helpful the Duet Community is and i hope one day I know enough to be able to help others out as you have helped me.

    🙂


Log in to reply