Fully Automate YOUR 3D Printer: Auto-ejection, Queues and Loops!
Let’s get straight into it. If you have a Klipper printer this is very easy. These features are actually built into Klipper Firmware. Still, it is often overlooked.
We’re working with Orca slicer for the following guide but you can apply this to any slicer.
‼️ WARNING ‼️ WARNING ‼️ WARNING ‼️ WARNING ‼️ WARNING ‼️
The following guide concerns editing G-code and firmware, which, if done incorrectly, could damage your printer. Proceed at your own risk!
‼️ WARNING ‼️ WARNING ‼️ WARNING ‼️ WARNING ‼️ WARNING ‼️
Setting up a Job Queue
Go to Orca Slicer and your device page, then go to the machine options in your left toolbar for mainsail or configuration for fluidd and go to moonrake.conf and add the following:
[job_queue]
load_on_startup: True
automatic_transition: True
job_transition_delay: 10
job_transition_gcode: CLEAR_BED
Also make sure the following is there:
[file_manager]
queue_gcode_uploads: True
enable_object_processing: False
Then save and restart.
This will set up a queue, so one print job will automatically follow the next. That is what the first two lines do, the transition delay gives a delay of 10 seconds, you can change this if you wish. The transition G-Code is the G-Code that will be followed as the first print transitions to the next, so we need to set this up so that the printer will autoeject the print before the next one starts.
So now go back to machine and then to the gcode_macro.cfg and add the following:
[gcode_macro CLEAR_BED]
G-Code:
M190 S30 #wait for bed temp to be 30
G91 #relative positioning
G1 Z10 #Raise Z10
G90 #absolute positioning
G1 X110 Y218 F3000 #Move printhead to middle and back
G1 Z1 #Move printhead down
G90 #absolute positioning
G1 X110 Y1 Z1 F2400 #Push Print off
This macro clears the bed between print jobs. The first command waits for the bed temp to go down to 30 °C. 30 worked for us with a standard 3DJake textured PEI, but you might need to experiment with this if you have a different plate, or you’re using a different filament - we’re using our own 3DJake ecoPLA for all tests.
G91 sets relative positioning, meaning the following move commands will be relative to the current position of the printhead. G1 moves the printhead up and away from the printed part. G90 sets absolute positioning, so the printhead will move to the XY coordinates of the print area rather than relative to the current position. The next G1 command moves the printhead to right in the middle of the horizontal axis, and also right to the back of the bed at a speed of 3000 mm/min. The next G1 moves the printhead down so it is only 1 mm away from the bed, and G90 moves the printhead forward to push off the model.
That’s basically it. Now just prepare a file and print it, and get your next one and print that too. You’ll see in your device page that a queue has started and when the print is finished it will trigger the CLEAR_BED macro and will wait for it to cool down to 30 °C before clearing the bed.
Looping a print
That’s job queues out of the way. What about repeating the same file over and over again? For this you can use the SD_LOOP command.
To do this, simply go to your printer.cfg and insert [sdcard_loop], doesn’t really matter where. This will allow loops for prints, but we need a G-Code command to trigger this. The best way to do this is to add the G-Code to your slicer - I would set up a new profile for this so you can switch easily.
In your printer profile settings go to machine G-Code and in the start G-Code add “SDCARD_LOOP_BEGIN COUNT=5”. In this case I am telling it to loop the print 5 times, but you can change it to whatever and if you want it to go indefinitely then change it to 0.
We’re not using a job queue, but we can still use the same G-Code macro for clearing the bed. You have two options here. Either copy the contents of the G-Code macro we used before and paste that into the end G-Code, or write the actual macro command “CLEAR_BED” in the end G-Code if you already have the macro written in your macro cfg.
After that, at the very end of the end G-Code include SDCARD_LOOP_END. This tells the printer that this is where the loop ends, so everything between SDCARD_LOOP_BEGIN COUNT=5 and SDCARD_LOOP_END will be repeated.
Save that and then just start your print.
When the print is finished the progress indicator will just stay at 99% until the temperature goes down to 30 then it will clear the bed and then restart.
If you want to stop the loop at the end of the current print you can type SDCARD_LOOP_DESIST in the console.
Marlin Printers
So what if you don’t have a Klipper printer? Well, you can do a pretty similar thing than what we just did, simply adding the end G-Code for automatic ejection, but the values may be different depending on your printer. Let’s look at it again:
M190 S30 #wait for bed temp to be 30
G91 #relative positioning
G1 Z10 #Raise Z10
G90 #absolute positioning
G1 X110 Y218 F3000 #Move printhead to middle and back
G1 Z1 #Move printhead down
G90 #absolute positioning
G1 X110 Y1 Z1 F2400 #Push Print off
You can use everything here for any printer, but the commands G1 for X and Y (line 5 and 8) are only suitable for the K1 printer we used or similar CoreXY printers with the same build area. You need to know how big your build area is, so if it is 250 mm across then line 5 should read:
G1 X125 Y248 F3000 #Move printhead to middle and back
This moves the printhead to the middle of the X-axis (125 mm from the edge) and to the back on the Y-axis which is only 2 mm away from the edge.
Then line 8 should read:
G1 X125 Y1 Z1 F2400 #Push Print off
This keeps the printhead in the middle but moves the printhead closer to the front (only 1 mm away from the very front) to push off the print.
Keep in mind this is suitable for printhead pushing, you don’t have to use the printhead to push, actually it might be better to use the whole gantry to push instead. However, for the K1 the belts are in the way of the gantry so it would be better if not much force was put on those hence pushing with the printhead. If you want to push with the gantry then the only thing you need to change is where the printhead is on the X- axis, so simply move the printhead to the side in which case the following can be used for line 5 and 8 for a 250 mm build plate:
Line 5: G1 X1 Y248 F3000 #Move printhead to middle and back
Line 8: G1 X1 Y1 Z1 F2400 #Push Print off
What about looping? If you have a marlin printer you can do the exact same thing we did for looping on Klipper however this is with an M808 command, and you do pretty much the same thing. You can find extra details on the Marlin website.
Lots of people still have Marlin, but what if you have a printer that is not “officially” Marlin or Klipper, it is a bit more DIY to do loops.
Looping for non-Klipper printers
What you can do is stitch G-Codes together and then print those via your SD card or export it as a 3mf which is just a compressed folder.
In Orca, slice your file as normal, then export it as a plate sliced file. Open that as a zip archive (we used WINRAR), in the metadata folder open the G-Code in a text editor.
Then select and copy the entire contents. If you want to just loop the print of the same object, then just paste the code over the original as many times as you want to repeat it. If you want to set up a job queue with different models, then slice the G-Code for that and copy and paste it in this one after the original G-Code.
Now save the text file and exit. In WINRAR it will ask if you want to update the archive with the edit, click yes and it will save. Now open the 3mf file back in Orca. You can see in the preview that the models overlap and the print time has changed.
Then you can just send that off to the printer, and it will auto eject and repeat the print as many times as you repeated the G-Code.
► If you’re doing this with a Bambu Lab printer, an A, P or X series you’re doing pretty much the same thing, however I would highly recommend you to check out Factorian Design’s videos on this because he goes into so much detail and put in a ton of work to get the actual G-Code changes absolutely perfect for those printers:
- Factorian Designs video on automating your P1/X1
- Factorian Designs video on automating the A series printers
There are some considerations to note:
► Editing end G-Code
You might get an error message and for us this was telling us that the printer needed to home all axes before proceeding to the clear bed macro.
It turned out there was an M84 command in the END_PRINT macro in the end G-Code. This might happen to you, lots of printers use a macro in the end G-Code instead of writing each line of G-Code there. You might need to find the macro in the macro cfg and edit it there or maybe the offending G-Code is written in full in the End-G-Code in which case just edit it there.
► Replacing End-G-Code entirely
For some printers without access to editing macros it might be necessary to fully replace the End-G-Code entirely. You can replace it with something pretty basic like the following:
M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off (if you have it)
G91 ;relative positioning
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure
G1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
M84 ;steppers off
G90 ;absolute positioning
If your printer has a nozzle wiper you could also add G-Code to move the nozzle over it. This is pretty easy, just using G1 commands to move the nozzle over the area.
► Space considerations
Your printhead needs to position itself for the push so there needs to be space for it to move close to the bed before moving forward and pushing the model off.
For our test, we positioned the printhead at the back which means, given the size of the K1 printhead, the back 55 mm of the build plate are unusable. Measure the clearance of your printhead before trying this and make sure the model you’re printing is not in that danger zone.
Also keep in mind the size of your model. This method just isn’t going to work with smaller models or low models with a large footprint. And very large models might have too much adhesion to be ejected easily. For larger items it would be better to use the gantry to push rather than the printhead.
► Adhesion
Bad build plate adhesion and good build plate adhesion can both be problems. If the adhesion is bad then looped prints on the exact same spot on the build plate will be hard to keep up continuously. If the adhesion is too good then the printhead won’t be able to eject the part and could damage the printer. A good build plate and perfect z offset is key to this method.
► Compatible filaments
Any filament that requires an enclosure is going to be problematic, you need to keep the door open for this method to work. So ABS, Nylon, ASA and others are not suitable for this method. Even PETG might be troublesome because it can be pretty sticky.
► Purge lines
If your printer runs a purge line before the start of the print it would be best to replace this with a small brim. We had a KAMP purge line running on our K1 and repeating that purge without removing it could create problems. But your printer will still need to purge to prep the extruder before each print, so it is best to replace the purge line with a small 2 mm brim which should be removed with the print as it is ejected.
► Oozing hotend
You might also need to turn off the hotend as the bed cools. This might happen if you completely remove the End-G-Code macro command so END_PRINT or equivalent does not run. If the hotend stays on while the bed is cooling between prints it will likely ooze which could ruin your first layer. Putting in an M104 S0 command in the end gcode will set the hotend heater to 0 make sure it is entered before the SDCARD_LOOP_END command.
► Using Gravity!
It might be that your print doesn’t fully push off the bed. Tilting your printer like in Factorian Designs video is a great option for more reliable ejection. Check out his video, and if you’re doing something like this, make sure it is a rigid set up and that input shaping calibration is done again after repositioning.
► Rolling Off!
It might also be that if you have a bedslinger, the part will get trapped between the bed and the base of the printer, putting a piece of paper securely under the build plate will ensure the part can roll off out of the way.
► Pusher plate
For extra reliability consider printing a plate to attach to your printhead to help push off the print. Keep in mind the max moveable area of your printer so the plate does not collide with anything.
Related products
Magazine Articles:
-
Great Britain: Free standard delivery from £59.90
-
Free
returns More than 10.450 products
We deliver worldwide to
more than 40 countries