Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    How can I print 2 files consecutively?

    Scheduled Pinned Locked Moved
    General Discussion
    3
    12
    526
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jens55undefined
      jens55 @usinjin
      last edited by jens55

      @usinjin, I am probably not understanding what you are trying to do but PrusaSlicer and probably most other slicers offer to print things consecutively or at the same time. In most instances you would choose to print the two (or more) items at the same time but if the parts are not very tall then you might have clearance to print consecutively. I am only familiar with corexy and cartesian printers and other systems (Delta ... ) might have less of an issue with clearances.

      usinjinundefined 1 Reply Last reply Reply Quote 1
      • usinjinundefined
        usinjin @jens55
        last edited by

        @jens55 In this case, it's for a pen plotter--2D only. The first gcode file is generated at runtime from text inputted by the user into a textbox and plotted at the top of the substrate. The second gcode file is plotted directly below it. The Duet is running in standalone mode with some Python helper functions running in the background.

        This macro seems to work fine, though I'm sure there's a better way of doing things--if anyone needs a more through explanation I am happy to provide one..I realize this is not trivial implementation of the system.

        G28            # home
        M32 "0:/gcodes/plot1.gc"
        while state.status = "processing"
            M102       # used as a NOP
        G4 P500        # Allow the state to switch
        M32 "0:/gcodes/plot2.gc"
        
        nikschaundefined 1 Reply Last reply Reply Quote 0
        • nikschaundefined
          nikscha @usinjin
          last edited by

          @usinjin
          Maybe use a global variable that is set at the end of the first gcode?

          while global.is_not_finished
              M400
          

          But to be honest I don't see anything wrong with you solution ^^

          You could also use daemon.g to check whether your first file is done printing (by checking `state.status == "idle") and then start the new "print". This might become a bit bloated though.

          Stay in school

          usinjinundefined 1 Reply Last reply Reply Quote 0
          • usinjinundefined
            usinjin @nikscha
            last edited by

            @nikscha A global is a good idea, I may try that. I thought the code I posted worked, but it broke the ability to stop or pause the print (both prints), and the console says nothing.

            nikschaundefined 1 Reply Last reply Reply Quote 0
            • nikschaundefined
              nikscha @usinjin
              last edited by nikscha

              @usinjin I see, that's annoying ^^
              you probably want something like this:

              ;daemon.g
              if global.first_file_finished
                  set global.first_file_finished = false
                  G4 P5000 ; wait 5 seconds 
                  M32 "0:/gcodes/plot2.gc"
              

              Your first gcode file should then end with
              set global.first_file_finished = true

              Keep in mind that daemon.g only runs about every 10 seconds, so the delay could end up anywhere between 5 and 15 seconds. Let me know if that's a problem cause I got a solution ^^

              Edit: and you will need to add global first_file_finished = false to your config.g

              Stay in school

              usinjinundefined 1 Reply Last reply Reply Quote 0
              • usinjinundefined
                usinjin @nikscha
                last edited by

                @nikscha Yeah, I considered using daemon.g but you're right in that the variable time gap between the prints would be an issue--interested to hear your potential alternative!

                nikschaundefined 1 Reply Last reply Reply Quote 0
                • nikschaundefined
                  nikscha @usinjin
                  last edited by

                  @usinjin
                  Do the following:

                  ;daemon.g
                  while true
                     G4 P1 
                     "rest of the code"
                  

                  This will run "rest of the code" about 3-6 times a second, depending on your code, NOT 1000 times a second as the G4 P1 might suggest. AFAIK the G4 P1 gives controll back to the main process. You can read more here https://docs.duet3d.com/User_manual/Reference/Gcode_meta_commands under the daemon.g section

                  Stay in school

                  usinjinundefined 1 Reply Last reply Reply Quote 0
                  • usinjinundefined
                    usinjin @nikscha
                    last edited by

                    @nikscha This seems to work okay, except there's a 10 second delay between the prints.

                    nikschaundefined 1 Reply Last reply Reply Quote 0
                    • usinjinundefined
                      usinjin
                      last edited by usinjin

                      Oh, because the while loop isn't keeping daemon.g open.

                      This worked better:

                      while state.status != "idle" & job.file.fileName = "0:/gcodes/file1.gc"
                          G4 P1        ; Now daemon.g will remain open until file1.gc is done
                      
                      if global.metadata_finished == true
                          set global.file1_finished = false
                          G4 P100
                          echo "Starting print 2.."
                          M32 "0:/gcodes/design2.gc
                      

                      Instead of M2 at the end of the first file I have set global.file1_done = true.

                      In the event that it takes less than 10 seconds to plot the first message after daemon.g was last opened, the while loop doesn't keep the file open and it takes a bit longer to start printing the second file, but I can live with that.

                      Pause and stop seem to be working again.

                      1 Reply Last reply Reply Quote 0
                      • nikschaundefined
                        nikscha @usinjin
                        last edited by

                        @usinjin Did you indent the code? It should be inside the while loop.

                        Stay in school

                        usinjinundefined 1 Reply Last reply Reply Quote 0
                        • usinjinundefined
                          usinjin @nikscha
                          last edited by

                          @nikscha I did--for some reason it didn't like that.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Unless otherwise noted, all forum content is licensed under CC-BY-SA