Jump to content
Ultimaker Community of 3D Printing Experts

Cura generating gcodes before start gcode


jens3
 Share

Recommended Posts

Posted (edited) · Cura generating gcodes before start gcode

 

Latest version of Cura but probably an issue for a long time.

When Cura generates a gcode file, it looks at the start gcode file that the user sets up. If it doesn't find certain things, it adds it's own set of start gcodes in front of the user requested start g codes. In my case there were four lines added by Cura:

 

T0

M104 Sxxx

M190 Sxxx

M109 Sxxx

 

Searching on the internet, I have been able to prevent Cura from adding the 'M' codes but I have not found a way to eliminate Cura calling a tool (T0).

Unfortunately, this screws up my printer that throws an error when you try to home with a tool selected. In my case I need to do the homing and the main gcode file selects the tool and the temperatures.

Is there a way to prevent Cura from deciding that a tool needs to be selected ?

I am hoping for something similar to what I found for deleting the other three g codes.

 

 

Edited by jens3
fixed typos
  • Link to post
    Share on other sites

    Posted · Cura generating gcodes before start gcode

    Additional info: I am using a Jubilee tool changing printer, When it receives the T0, it loads tool 0. I can place a 'T-1' as the first line in the user start gcode section but there is a considerable amount of action to first load a tool and then unload it and it seems like a lot of action for no reason.

     

  • Link to post
    Share on other sites

    Posted · Cura generating gcodes before start gcode

     Cura checks if you add a heatup sequence in your start gcode. If you don't, it adds its own heatup before your start gcode. If you don't want Cura to add these lines, make sure your start gcode contains lines which have {material_print_temperature_layer_0} and {material_bed_temperature_layer_0} in them respectively (exactly as typed, Cura will replace the {}-text with the temperatures). eg:

    G21 ;metric values
    G90 ;absolute positioning
    M82 ;set extruder to absolute mode
    M107 ;start with the fan off
    ; etc
    
    M140 S{material_bed_temperature_layer_0}   ;Start heating bed
    M190 S{material_bed_temperature_layer_0}   ;Wait for bed to reach temp before proceeding
    M104 S{material_print_temperature_layer_0} ;Start heating extruder 
    M109 S{material_print_temperature_layer_0} ;Wait for extruder to reach temp before proceeding
    
    ;etc
    

    Having this in your start gcode prevents Cura from putting heatup commands in front of your start gcode. This means that you can insert your T-1 command anywhere you want to relative to your heatup commands.

  • Link to post
    Share on other sites

    Posted · Cura generating gcodes before start gcode

    Not quite ... when I did the fix for the temperatures, the T0 command stayed.

     

    This is my start gcode:

    ;G28 ;Home

    M104 S{material_print_temperature} ;Start heating extruder

    M190 S{material_bed_temperature} ;Start heating bed and wait to bed reach temp before proceeding

    M109 S{material_print_temperature} ;Wait for extruder to reach temp before proceeding

    G1 Z15.0 F6000 ;Move the platform down 15mm

     

    and this is what Cura generates:

     

    ;Generated with Cura_SteamEngine mb-master-20210619
    T0
    M82 ;absolute extrusion mode
    ;G28 ;Home


    M104 S200 ;Start heating extruder
    M190 S60 ;Start heating bed and wait to bed reach temp before proceeding
    M109 S200 ;Wait for extruder to reach temp before proceeding
    G1 Z15.0 F6000 ;Move the platform down 15mm
    ;Prime the extruder
    ;G92 E0
    ;G1 F200 E3
    ;G92 E0
    M83 ;relative extrusion mode
    G1 F1500 E-0.4
    ;LAYER_COUNT:99

     

    In other words, the T0 command stayed

  • Link to post
    Share on other sites

    Posted · Cura generating gcodes before start gcode

    I call 4 out of 5 lines fixed a success.

    https://media.comicbook.com/2019/10/avengers-endgame-hulk-absolute-win-1192272-1280x0.jpeg

     

    There is no easy way to prevent Cura from putting that T0 there (from the top of my head). You can try to remove it though, using a Search and Replace postprocessing script.

  • Link to post
    Share on other sites

    Posted · Cura generating gcodes before start gcode

    Well that is a bummer .... having to manually edit the gcode that Cura generates would be a major pain in the behind.

    A work around of course is to always home te printer before executing the gcode file and a secondary work around would be to not turn off idle hold in the end gcode so that home is never lost as long as power is on.

     

    Ok, thanks for responding !!!

  • Link to post
    Share on other sites

    Posted (edited) · Cura generating gcodes before start gcode

    BTW, I also tried to issue a T{whatever the variable is} in the start script after a home. I was hoping that just like the temperature lines that Cura would recognize this. Alas, it still issued the T0, then it did the G28 from the start script followed by T0  (ie it properly replaced the variable as expected)

     

    The command was

    T{initial_extruder_nr}

    as per your page here :

    http://files.fieldofview.com/cura/Replacement_Patterns.html

    Edited by jens3
    additional info
  • Link to post
    Share on other sites

    Posted · Cura generating gcodes before start gcode

    Have the same problem. I edit the G-code by myself before every print 😞

  • Link to post
    Share on other sites

    Posted (edited) · Cura generating gcodes before start gcode

    Yes I’m also having issues with this. I’m running a Duet2WIFI with 4 extruder switching for multi-color and with cura calling a tool before the start g-code means that the hotend hasn’t had any temperatures set yet as there in the start code and as such it will not load any tools. I’m forced to manually heat up my hotend before starting a part which allows filament to drip while probing the bed or editing the gcode which is a annoying when your forget.  Would be nice to get this fixed so that we can enter the variable for the first extruder or the adhesion extruder so that it works like the other temperature setting where cura will leave them out if you include them in your start code.

    Edited by Cbldwn
  • Link to post
    Share on other sites

    Posted (edited) · Cura generating gcodes before start gcode

    How about using the Search and Replace plugin.  You just need a temperature prior to T0?

    Search :     ;Generated with

    Replace:    M109 S125 T0 ;Generated with

     

    Remember the semi-colon after the T0.

    Edited by GregValiant
    • Like 1
    Link to post
    Share on other sites

    Posted (edited) · Cura generating gcodes before start gcode

    I have what appears to be a working solution. It does need to be tweaked still but the overall concept works. The user does not need to worry about anything special to modify the g code, the purge works properly with the tool warmed up.

     

    This works for a Duet controller but note that the line after 'T-1' only works with version 3.3 or higher. It may or may not work for a duet2

     

    Details as follows:

     

    Duet start.g:
    ; This file is called before any print job file is started
    T-1  ;(probably not needed)
    if !move.axes[0].homed || !move.axes[1].homed|| !move.axes[2].homed ; If the printer hasn't been homed, home it
    G28 ; home the printer before Cura has a chance to mess it up with loading a tool

     

    Duet tpost0.g:
    ; tpost0.g
    ; called after firmware thinks Tool 0 is selected
    ; Note: tool offsets are applied at this point!
    ; Note that commands preempted with G53 will NOT apply the tool offset.

    M116 P0 ; Wait for set temperatures to be reached
    M302 P0 ; Prevent Cold Extrudes, just in case temp setpoints are at 0
    M83 ; use relative extrusion
    G0 E10 F300 ; purge
    G4 T10 ; wait
    G90 ; Ensure the machine is in absolute mode before issuing movements.

    G53 G1 X-3 Y339 F6000 ; Move to the pickup position with tool-0.
    M98 P"/macros/tool_lock.g" ; Lock the tool

    G1 R2 Z0 ; Restore prior Z position before tool change was initiated.
    ; Note: tool tip position is automatically saved to slot 2 upon the start of a tool change.
    ; Restore Z first so we don't crash the tool on retraction.
    G1 R0 Y0 ; Retract tool by restoring Y position next now accounting for new tool offset.
    ; Restoring Y next ensures the tool is fully removed from parking post.
    G1 R0 X0 ; Restore X position now accounting for new tool offset.
    M106 R2 ; restore print cooling fan speed

    Note that there are several tool changer commands in there that are specific to my setup. All tpost(n).g files are basically the same with only the tool changing and the tool position changing.

     

    Cura post processing, search and replace search string:
    T[0-9]\n

    replacement string is empty
    Regular expression check box checked
    Note: this only works for tools T0 thru T9. If more tools are defined then you need to change this.

     

    Cura startg:
    G10 P{initial_extruder_nr} S{material_print_temperature} R{material_print_temperature}
    T-1
    M190 S{material_bed_temperature} ;Start heating bed and wait to bed reach temp before proceeding
    G1 Z15.0 F6000 ;Move the platform down 15mm

    Note: the T-1 deselects the initial tool that Cura insists on selecting (probably no longer needed)

     

    Cura tool start.g, same for all tools:
    G10 P{extruder_nr} S{material_print_temperature} R{material_print_temperature}
    T{extruder_nr};

    Note: the ";" at the end of the last line is critical!
    What is happening is that all instances of T(n) (only those on their own line, not those as part of another command) are located and a G10 plus a T(n); command is added. Later on, in the post processing search and replace, the original T(n) command is deleted. The T(n); command only remains because of the semicolon so if that is missing no tools will ever get selected.

    I think that covers all points.
    I hope somebody can make use of this ... it certainly caused me lots of grief to sort this out.

     

    0

    Edited by jens3
  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    • Our picks

      • New here? Get ahead with a free onboarding course
        Hi,
         
        Often getting started is the most difficult part of any process. A good start sets you up for success and saves you time and energy that could be spent elsewhere. That is why we have a onboarding course ready for
        Ultimaker S5 Pro Bundle, Ultimaker S5, Ultimaker S3 Ultimaker 2+ Connect.   
        They're ready for you on the Ultimaker Academy platform. All you need to do to gain access is to register your product to gain free access. 
        Ready? Register your product here in just 60 seconds.
          • Like
        • 11 replies
    ×
    ×
    • Create New...