Jump to content

Why does CURA add extra unwanted G-code above starting G-code


Cheddar_C137

Recommended Posts

Posted · Why does CURA add extra unwanted G-code above starting G-code

 

I want to get the bed and extruder heating first, then while its doing that home and calibrate the level.  Then wait for temps to reach, then start the print.

Regardless of my starting gcode, cura adds the below.

 

I know the reasons why you might not want to home and calibrate before the bed is heated but this is what I want.  Tested by manually editing the gcode after slicing to remove the unwanted heating sequence and it works just fine for me with no issue.  If it causes a problem in future I will act from there.

 

see below sample g-code.

 

this bit is added regardless of what my starting gcode is supposed to be

;FLAVOR:Marlin
;TIME:5040
;Filament used: 5.36136m
;Layer height: 0.28
;MINX:77.939
;MINY:66.85
;MINZ:0.28
;MAXX:162.769
;MAXY:152.116
;MAXZ:22.12
;Generated with Cura_SteamEngine main
M140 S60
M105
M190 S60
M104 S215
M105
M109 S215
M82 ;absolute extrusion mode

 

and then only after the above does my custom start code show up

G92 E0 ; Reset Extruder
M104 S215 ; set extruder to 215 and continue
M140 S60 ; set bed to 60 and continue
G28 ; Home all axes
G29 ; BLTOuCH
M109 S215 ; if extruder is still not heated, wait for extruder to reach 215 before continuing
M190 S60 ; if bed is still not heated, wait for extruder to reach 60 before continuing
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed

etc etc

 

 

Why does cura do this and how do I make it stop please

  • Link to post
    Share on other sites

    Posted · Why does CURA add extra unwanted G-code above starting G-code

    In case anyone else wants a solution, I managed a shitty workaround to halfway automate the process and its only a mild pain in the ass.  Basically, you want to remove the two short lines below (added by cura, and not in your starting code), and keep the two long lines (added by you in your starting gcode)

     

    remove - "M190 S60"

    remove - "M109 S215"

     

    keep - "M109 S215 ; if extruder is still not heated, wait for extruder to reach 215 before continuing"
    keep - "M190 S60 ; if bed is still not heated, wait for bed to reach 60 before continuing"

     

    This batch file will remove all instances of "M190 S60" and "M109 S215", including the ones you want to keep!

    This will leave the two short lines blank, and leave the long lines as such;

    " ; if extruder is still not heated, wait for extruder to reach 215 before continuing"
    " ; if bed is still not heated, wait for bed to reach 60 before continuing"

     

    The batch file will then find the remains of the lines you want to keep and replace them with what you had originally.

     

    You will be left with the two bad lines gone, and the two lines you want still there.  This will fix this issue.  All you have to do is make the batch file, and drag your gcode files onto it before uploading to octoprint or sd card or however you like to print, every time you slice.

     

    This is a pain in the ass, and your file name cant any any spaces etc, but still faster than editing each gcode file, or manually heating up your hotend every time you start a print.  I really hope someone can give me a simpler solution, or this apparent bug in cura can be fixed soon.  I dont like this solution much but its all I could come up with.

     

    Hope this helps anyone in my same situation.

     

    see below, contents of batch file, gcodefix.bat or whatever you want to call it

     

    @echo removing all M190 commands
    powershell -Command "(gc %1) -replace 'M190 S60', '' | Out-File -encoding ASCII %1"
    @echo removing all M109 commands
    powershell -Command "(gc %1) -replace 'M109 S215', '' | Out-File -encoding ASCII %1"
    @echo re-adding M190 command
    powershell -Command "(gc %1) -replace ' ; if bed is still not heated, wait for bed to reach 60 before continuing', 'M190 S60 ; if bed is still not heated, wait for bed to reach 60 before continuing' | Out-File -encoding ASCII %1"
    @echo re-adding M109 command
    powershell -Command "(gc %1) -replace ' ; if extruder is still not heated, wait for extruder to reach 215 before continuing', 'M109 S215 ; if extruder is still not heated, wait for extruder to reach 215 before continuing' | Out-File -encoding ASCII %1"
     

     

  • Link to post
    Share on other sites

    Posted · Why does CURA add extra unwanted G-code above starting G-code

    @Cheddar_C137 doing as AHoeben says in that post that @gr5 linked will work in most cases.  Since you have the G29 in your StartUp Gcode you might want it to be a bit different to keep the nozzle from drooling during leveling.  This will work for a printer with the Origin in the left front corner.  If you have an Origin at Center machine you would need to adjust the "go to left front corner" line to G1 F6000 X-115 Y-115 or whatever works.

    ;-----StartUp Gcode

    G90 ;Absolute Movement

    G21 ;Metric

    M82 ;Absolute Extrusion

    M220 S100 ;reset printer feed rate modifier

    M221 S100 ;reset printer flow rate modifier

    M104 S160 ;Heat the hot end partway but below ooze temperature

    M190 S{material_bed_temperature_layer_0} ;Heat the bed to Initial Layer Bed Temp and wait

    G28 ;Home All

    G29 ;ABL

    G1 F1000 Z5 ;move up

    G1 F6000 X0 Y0 ;go to the left front corner

    M109 S{material_print_temperature_layer_0} ;Heat the hot end to the initial layer print temp and wait

    G92 E0 ;reset extruder

    etc. etc.

    Paste that into your StartUp Gcode in the Cura machine settings.  You will replace up to and including

    "G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed".  If there are purge lines below that code they will be fine.

     

    • Like 2
    Link to post
    Share on other sites

    • 2 weeks later...
    Posted · Why does CURA add extra unwanted G-code above starting G-code

    I've had the problem that if I add the G29 autolever code, the hot end starts cooling down during the autolevel.
    When print starts it does start heating up but doesn't reach temperature quite soon enough.

    With the suggestions above, do you have to manually edit the gcode to specify the temperature rather than it be set in the  UI settings?

    Since the cooling process has been a concern of mine, as a workaround I simply avoided putting the g29 code in pre-process gcode, and autolevel before starting a print.  Not sure though if the CR Touch stock firmware for Ender 3v2 board 4.2.2 maintains the level settings between manually initiating auto-level and when you start a print.

  • 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
    • Our picks

      • Introducing the UltiMaker Factor 4
        We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
          • Thanks
          • Like
        • 3 replies
      • UltiMaker Cura 5.7 stable released
        Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more. 
         
          • Like
        • 27 replies
    ×
    ×
    • Create New...