Help with a Tool Change Script

  • So, I have a Raise3D Pro2, and I'm looking to perfect a tool change script for it, the goal of which is to reduce or eliminate the excess plastic that tends to build up on the nozzle when using the dual extruder. The printer uses the Marlin G-code flavor, and although I'm not sure this matters, I'm slicing in ideaMaker. The script is supposed to flow as follows:




    • Retract current tool

    • Move to X30 Y300

    • Check if the new active tool is T0


      • If T0, wipe nozzle 2mm circle

      • If T0, cool T1 to 165C

      • If T0, heat T0 to 230C

      • If T0 and not layer 1, recover

      • If T0, wipe nozzle again, this time for the new tool


    • Check if the new active tool is T1


      • If T1, wipe nozzle 2mm circle

      • If T1, cool T0 to 165C

      • If T1, heat T1 to 230C

      • If T1 and not layer 1, recover

      • If T1, wipe nozzle again, this time for the new tool




    The current script I have looks like this:



    ; extruder switch gcode start
    G10 S1; Retract for current nozzle
    G1 X30 Y300 F6000; Move to X:30 Y:300
    [if {new_extruder}=0]; LEFT Extruder is active (T0)
    [if {new_extruder}=0]G12 P2 R2; Clean inactive nozzle 2mm circle
    [if {new_extruder}=0]M104 S165 T1; Cool inactive extruder to 165c (T1)
    [if {new_extruder}=0]M109 S230 T0; Heat active extruder to 230c (T0) and wait.
    [[if {new_extruder}=0] and [{layer_index} NE 1]]G11; Recover current nozzle when not first layer
    [if {new_extruder}=0]G12 P2 R2; Clean active nozzle 2mm circle
    [if {new_extruder}=1]; RIGHT Extruder is active (T1)
    [if {new_extruder}=1]G12 P2 R2; Clean inactive nozzle 2mm circle
    [if {new_extruder}=1]M104 S165 T0; Cool inactive extruder to 165c (T0)
    [if {new_extruder}=1]M109 S230 T1; Heat active extruder to 230c (T1) and wait.
    [[if {new_extruder}=1] and [{layer_index} NE 1]]G11; Recover current nozzle
    [if {new_extruder}=1]G12 P2 R2; Clean active nozzle 2mm circle
    ; extruder switch gcode end


    The issue is that, when I run a print with this, it doesn't seem to run all of the commands. It does the move, and the cooling/heating, but the retract/recover and nozzle wipe doesn't seem to read. I'm not sure if that's because of a printer or syntax issue, or because those commands don't work the way I think they do.



    EDIT: (by Pᴀᴜʟsᴛᴇʀ2 - Added new code and logic back in)



    New logic:




    • Retract current tool

    • Move to X30 Y300

    • Check if the new active tool is T0


      • If T0, wipe nozzle 2mm circle

      • If T0, cool T1 to 165C

      • If T0, heat T0 to 230C

      • If T0 and not layer 1, recover

      • If T0, wipe nozzle again, this time for the new tool


    • Check if the new active tool is T1


      • If T1, wipe nozzle 2mm circle

      • If T1, cool T0 to 165C

      • If T1, heat T1 to 230C

      • If T1 and not layer 1, recover

      • If T1, wipe nozzle again, this time for the new tool




    The new script I have looks like this:



    ; extruder switch gcode start
    G10 S1; Retract for current nozzle
    G1 X30 Y300 F6000; Move to X:30 Y:300
    [if {new_extruder}=0]; LEFT Extruder is active (T0)
    [if {new_extruder}=0]G12 P2 R2; Clean inactive nozzle 2mm circle
    [if {new_extruder}=0]M104 S165 T1; Cool inactive extruder to 165c (T1)
    [if {new_extruder}=0]M109 S230 T0; Heat active extruder to 230c (T0) and wait.
    [[if {new_extruder}=0] and [{layer_index} NE 1]]G11; Recover current nozzle when not first layer
    [if {new_extruder}=0]G12 P2 R2; Clean active nozzle 2mm circle
    [if {new_extruder}=1]; RIGHT Extruder is active (T1)
    [if {new_extruder}=1]G12 P2 R2; Clean inactive nozzle 2mm circle
    [if {new_extruder}=1]M104 S165 T0; Cool inactive extruder to 165c (T0)
    [if {new_extruder}=1]M109 S230 T1; Heat active extruder to 230c (T1) and wait.
    [[if {new_extruder}=1] and [{layer_index} NE 1]]G11; Recover current nozzle
    [if {new_extruder}=1]G12 P2 R2; Clean active nozzle 2mm circle
    ; extruder switch gcode end

    Welcome to 3D Printing! In your example, I'm not seeing the "S" value, which should indicate the number of repetitions of the pattern you're looking to print. I'm thinking your line should look like: **G12 P2 S1 R2 ;** (after the "if" statement, of course). Also, where is your G11 command after the G10? From what I'm reading, the G10 will be ignored if it isn't followed by the G11 command.

    @Pᴀᴜʟsᴛᴇʀ2, The G11 is in the lines "[[if {new_extruder}=0] and [{layer_index} NE 1]]G11;", should be lines 8 and 14 in that code snippet. As for the S value, I'll give that a go and see if it changes anything.

    I see the G11 now ... sorry I missed it. BTW, I'm no expert on this stuff, just kinda poking around. Hope it works for you.

    One other thought ... if you have inactivated the nozzle, wouldn't giving it commands conflict with the assignment you've given it (ie: inactive)? (or is your comment at end of the G12 command (line 5) inaccurate and supposed to state "Clean ***active*** nozzle ...")

    @Pᴀᴜʟsᴛᴇʀ2 has a good point: try reorganizing so you send commands only to the currently active extruder, even if you have to add extra "activate" commands.

    @Carl Witthoft I haven't gotten the chance to try it yet, but I did update the script in the code listing. I figure if I just remove those two G12's, and replace them with one that runs before it starts checking for the tools, that might work. If you or Paulster2 have any other suggestions, I'd appreciate it.

    BTW, please don't edit what you put originally, add it in below as a new portion and mark it as an edit. You will confuse those who are looking at the question.

  • As far as I can recognize, the g-code file cannot be evaluated by printer firmware.



    It is expected that slicer software will be aware of tool head selection and process tool changes according to g-code provided in an on-tool change in most slicers.



    The best way to think about g-code (in RepRap word) is a one-way communication as the file is not treated as a script that can read and evaluate parameters on the go. (firmware capabilities).



    references:



    RepRap G-code list
    Printer quick start guide


    @CarlWitthoft thanks for your remark & may I see an example? as per https://reprap.org/wiki/G-code, I did not find that in a RepRap 3d printing word, also provided printer manual does not mention that. So at this stage, if the printer producer is not mentioning that in firmware capabilities I am treating that printer as a RepRap like one, therefore I am threating g-code as read-only. I edited my text to direct to firmware capabilities not GCode itself

    Ok, fair enough. Please move your references into the answer?

    So... The commands can't be read by the printer then? Figures. I'll just see if using a prime tower fixes my issues. I'm trying to do this with ABS/HIPS, and the print I want to get off has some complex geometry, and will take at least 8-14 hrs, so I can't run that until I'm sure it won't screw up at 50% of the way. Thanks for the help guys.

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM