How can I print 2 files consecutively?
-
I'm trying to figure out a good way to print 2 gcode files right after each other without rehoming/other intervention. I'm running into issues where I'm asking the Duet to select the new file for printing too soon, or the Duet is busy waiting for itself to not be busy. I tried this:
G28 M32 "0:/gcodes/file1.gc" while state.status = "processing" G4 P10 M32 "0:/gcodes/file2.gc"
Which ended up being rather hit or miss (it worked fine a couple of times). Leaving nothing in the while loop didn't work, but I don't think the dwell is the right answer either. Is there a better way to do this?
-
@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.
-
@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"
-
@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.
-
@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.
-
@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 -
@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!
-
@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
-
@nikscha This seems to work okay, except there's a 10 second delay between the prints.
-
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.
-
@usinjin Did you indent the code? It should be inside the while loop.
-
@nikscha I did--for some reason it didn't like that.