Help with tool change macro please

  • Thanks Tony, I'm getting there. So now tfree just has G10 ; retract, tpre is empty and tpost has this:
    G90 ; set absolute positioning …..(just to be on the safe side)
    M83 ; Set relative extruder.........(just in case)
    G1 X300 Y300 F21000 ;move to near the far right hand corner of the bed at 350mm/sec
    G11 ; unretract - to cancel out the retract in tfree
    G1 E20.0000 F600 ; extrude 20mm of filament at 10mm/sec
    G10 ; retract to stop any more oozing out.
    G1 R1 F21000; move back from whence we came
    G11; unretract

    I've created a dummy tool (T90) and used a T90 in my config.g to have this as the first tool selected. I'll put the same T90 command in my start gcode file, followed by an M109. This is to prevent running foul of errors associated with trying to drive a tool without the heater being up to temperature as will happen when I first select a tool (because it always tries to extrude and the heater is cold).

    So, I've tried changing tools from DWC with the machine static and it's working fine. The only thing that doesn't happen is that it doesn't move back from whence it came (G1 R1 F21000;). I'm guessing that's because it only knows where the origin was while it's actively printing and not when the machine is stationary. It's no big deal but is there a way around it?


  • administrators

    I have not tested the R1 functionality of G1.

    Glad it's starting to work for you!

  • Quick update. The macros are working and doing what I expect. There a couple of things that I have to overcome. I may need to put a bit of Z hop in, mostly because on selecting the first tool the nozzle is at or very close to the bed when it does the first extruder purge. The second thing is that it needs something to physically wipe the nozzle. This isn't easy to do on my machine because the bed is larger than the printable area. That is to say, there is no place where the nozzle isn't over the bed. It needs some thought but methinks this could be a fairly major re-design of the printer. Still, it's showing promise….....

  • One idea would be to make a hole in the bed to install a scraper into.

  • administrators

    This goes back to printing a tower for purging, investigation of that might be quicker than redesigning your printer to allow for a purge bucket within the movement range of your XY axis.

    I have not looked at Prusa's smart tower yet but my idea would be to calculate the amount of filament required to purge the layer that needed the most purging, (ie the one where the most tool changes occurred before a Z movement). Then build a tower that had enough volume at 100% infil to absorb that many purges in one layer. All layers with less purges would print at a minimum the perimeter of the tower and as much infil as required to purge that layer. Maybe modify so the first layer was printed at 100% infil even if not required do the tower was firmly anchored on the bed.

    This is definitely something that the slicer should be doing because it needs knowledge of the whole print job in advance. Also a good slicer would allow you to place the print tower anywhere on the bed as an object.

    Even cleverer slicers should be able to allow you to purge as part of infil but that would require even more development work.

    Not that any of this helps you, except for the idea of seeing how Prusa is doing it.

  • I could make a hole in the bed - bit difficult though - I have 10mm thick aluminium with 240v silicone heat mat stuck to the underside and semi rigid insulation under that, oh and then 6mm glass on top. Actually, I may be able to slide the entire ting forward enough - dunno - have to investigate.

    Tony - the smart tower is a good ides but exactly how it's done seems to be a bit of secret. How do you purge say 3 different colours that are to be printed on the same layer in such a way that each one is printed sequentially after each purge (as is needed with a single nozzle) ?

    Purging at layer change is a piece of cake. In fact, if the object is a reasonable size, you don't even need to. You can just set 3 or 4 perimeters and the slicer will always do the inner ones before the outer ones so the inner perimeters effectively act to purge the new filament through. It doesn't matter is they are a bit "streaky" because they get covered up.

    Say you have 3 tools (colours) A, B and C. With a mixing nozzle, you start with A and print that part of the layer - change to B move away and purge B - move back and print that part of the same layer - change to C - move away and purge that colour - move back and print that part of the layer using C - change back to A - go to the next layer and start over. If you have tower, you have to print it every layer, whether there is tool change or not. How else could it work if you have say 20 layers before a tool change? How do you cope with 3 colours on the same layer? 3 towers? Prusa talks about "slots" within a tower. Maybe that's 3 towers in one? Dunno…....

    Prusa's approach is all done post processing, so it's not native to the slicer. However it's done it's very clever.

    I'll have to dig around some more.


  • administrators


    My thought process in more detail:

    For layers where you have no tool change you just print the perimeter of the tower in whatever tool is selected.

    At every tool change, be that during a layer, or on the layer change, you print enough of the tower so that the nozzle is purged, the rest of the tower is not printed. Once per layer, the perimeter is printed before anything else is done.

    The size of the tower is determined by the number of tool, changes so if you need 3mm^3 of filament extrusion to purge and the print has 4 tool changes on the most complex layer, then the tower must be large enough to absorb 3x4 = 12mm^3 of filament on this worst case layer, printed in 4 sections one after each tool change.

    Experimentation would be required to see if some infill was required, or a double perimeter for any tower dimension to work, especially if you had a situation where the tool changes were not evenly distributed through the print.

    It could be optimised significantly for time and filament usage by printing a smaller tower if under the worst case layers there was a big enough gap so that the tower effectively became a purge bucket for these worst case layers.


    If I get a chance I will look into how Prusa's post processing script does it,

  • Tony,

    Yes, I think I see where you are coming from - effectively printing purge "bucket" on the bed, the inside of which is basically a container for whatever filament (s) need to be purged. Hmmmmmmmmm

  • administrators


    Yes, just optimising to use as little filament for purge bucket printing as required, however as an interim measure you could literally print a bucket that was oversized so you were sure to capture every purge and then just purge into it by printing in 1 separate place for each tool change.

  • Quick update. I've commented out the codes that I had in tpfree/post etc and put them into the Custom Gcode - Tool Change section of Slic3r. Did a quick slice and taking a gander at the resultant gcode file, it looks like it'll work. It's much more elegant doing it this way as the commands will only be executed during a print and not at other times when I'm playing around with things. So I don't need the dummy tool in my config.g. Also, the codes are only executed on tool change and not tool selection so it doesn't do this extra purge thing at the start of a print, therefore I won't need the Z hop. Now to figure out the tower thing….....


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