Jump to content

Custom G-Code before heating (Prusa)


woodworker2001

Recommended Posts

Posted (edited) · Custom G-Code before heating (Prusa)

I am trying to get a custom G-code set up for my Prusa Mi3 MK3S.  I have an MMU2 on it.  Mostly use it for single material prints in an educational setting.  The start code with the profile in cura works great, but doesnt allow you to select which filament you use.  You can add the "Tx;" command to it, but then you have to wait for heating.  I did some digging and found where you can make the Cura SteamEngine not put the heating codes at the beginning buy putting them in your code.  This works great for my Ender 3 so I can get the nozzle and bed heating at the same time as my homing to make that a shorter process.  Here is the start G-Code I am using for my Prusa.

 

M140 S{material_bed_temperature_layer_0} ;Start heating bed

M104 S{material_print_temperature_layer_0} ;Start heating extruder

Tx ; Choose filament

M190 S{material_bed_temperature_layer_0} ;Wait for bed to reach temp before proceeding

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

 

G90 ; use absolute coordinates

M83 ; extruder relative mode

 

G28 W ; home all without mesh bed level

G80 ; mesh bed leveling

 

The issue is it is not picking up the variable for the temperatures from the settings.... My post processed G-code looks like this.....

 

;FLAVOR:Marlin
;TIME:10841
;Filament used: 14.9701m
;Layer height: 0.2
;MINX:96
;MINY:76
;MINZ:0.2
;MAXX:154
;MAXY:134
;MAXZ:50.8
;POSTPROCESSED
;Generated with Cura_SteamEngine 4.11.0
M82 ;absolute extrusion mode   --------------------------------------------------------------This is not in my custom start code.... added by steamengine for some reason
M140 S{material_bed_temperature_layer_0} ;Start heating bed
M104 S{material_print_temperature_layer_0} ;Start heating extruder
;Tx ; Choose filament
M190 S{material_bed_temperature_layer_0} ;Wait for bed to reach temp before proceeding
M109 S{material_print_temperature_layer_0} ;Wait for extruder to reach temp before proceeding

G90 ; use absolute coordinates
M83 ; extruder relative mode

G28 W ; home all without mesh bed level
G80 ; mesh bed leveling
 

 

The exact same start code works with my ender and it plugs in the temperatures, but does not work with the Prusa.... What am I doing wrong???

The Cura SteamEngine is also adding an M82 to the code which is not in my custom start code.... not sure why????

Edited by woodworker2001
  • Link to post
    Share on other sites

    Posted (edited) · Custom G-Code before heating (Prusa)

    I think this is a question for a Prusa support site but I'll give it a try.

     

    When I plug your code into Cura in a StartUp G-Code it works and the keywords are properly replaced by Cura during the Gcode generation.

    You cannot add keywords with a post-processor because the Gcode generation is completed prior to any post-processing and I believe it's during the Gcode generation that the keyword replacements are made.

     

    ;StartUp Gcode

    M140 S{material_bed_temperature_layer_0} ;Start heating bed

    M104 S{material_print_temperature_layer_0} T0 ;Start heating extruder #1

    M104 S{material_print_temperature_layer_0} T1 ;Start heating extruder #2

    ;Tx ; take this out and see how it works.  (This may be Prusa specific and might require your input on the LCD?)

    M190 S{material_bed_temperature_layer_0} ;Wait for bed to reach temp before proceeding

    M109 S{material_print_temperature_layer_0} T0 ;Wait for extruder #1

    M109 S{material_print_temperature_layer_0} T1 ;Wait for extruder #2

    ;Blah, Blah, Blah, more code

    ;End of Start Gcode

     

    By explicitly stating the Extruder numbers both would start heating.  I don't know what effect that will have when you have an extruder disabled - it may heat anyway because of the above commands.  You would need to check that.  Also - the above code heats the bed and both extruders at the same time.  That requires a fairly robust power supply and you might find it necessary to reorder the commands.

    I'm not sure why Cura always adds the M82.  If you are using relative extrusion then an M83 will be added after the start gcode.  A lot of printers have purge lines in their start gcode and they are pretty much exclusively Absolute extrusions.  Maybe that has something to do with it.

    Edited by GregValiant
  • Link to post
    Share on other sites

    Posted · Custom G-Code before heating (Prusa)

    The keywords aren’t being replaced in cura during code generation. When I look at the g code in notepad the keywords are still there when the prusa machine is selected in cura. When I select the ender they replace just fine. I have removed the Tx as that is a prusa code that has you select the filament on the screen. 
     

    cura is not picking up the keyword when post processing and replacing it with the temp setting. Opening the g code with notepad the keyword is still there but not when using my ender profile with the identical start g code

  • Link to post
    Share on other sites

    Posted · Custom G-Code before heating (Prusa)

    Load a model and your Prusa printer in Cura and then setup Cura for a slice.  Then use the "File | Save Project" command to save the whole mess as a 3mf project file and post that here.  Maybe something will jump out.

     

    I added the definition for the "Prusa i3 mk3/mk3s" and it has the keywords in the StartUp G-Code.  Everything worked fine and the temperatures are in the gcode file so the keyword replacement worked for me.

  • Link to post
    Share on other sites

    Posted · Custom G-Code before heating (Prusa)

    Ok so I had copied start code from Pursa Slicer.... apparently Cura didnt like these lines.... once these were removed it replaces the keywords as expected.....

     

    M221 S{if layer_height<0.075}100{else}95{endif}

    G92 E0.0

     

    ; Don't change E values below. Excessive value can damage the printer.

    {if print_settings_id=~/.*(DETAIL @MK3|QUALITY @MK3).*/}M907 E430 ; set extruder motor current{endif}

    {if print_settings_id=~/.*(SPEED @MK3|DRAFT @MK3).*/}M907 E538 ; set extruder motor current{endif}

     

     

    I am still getting the M82 inserted by the Cura SteamEngine.... Here is my latest file from Cura and start Gcode... maybe I have something else in there Cura doesnt like... Here is my current start code

     

     

    ;Prusa Custom Start G-code

    G90 ; use absolute coordinates

    M83 ; extruder relative mode

     

    M140 S{material_bed_temperature_layer_0} ;Start heating bed

    M104 S{material_print_temperature_layer_0} ;Start heating extruder

    ;Tx ; Choose filament

    M190 S{material_bed_temperature_layer_0} ;Wait for bed to reach temp before proceeding

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

     

    G28 W ; home all without mesh bed level

    G80 ; mesh bed leveling

     

    ;go outside print area

    G1 Y-3.0 F1000.0

    G1 Z0.4 F1000.0

    ; select extruder

    Tc ; load filament

    ; purge line

    G1 X55.0 F2000.0

    G1 Z0.3 F1000.0

    G92 E0.0

    G1 X240.0 E25.0 F2200.0

    G1 Y-2.0 F1000.0

    G1 X55.0 E25 F1400.0

    G1 Z0.20 F1000.0

    G1 X5.0 E4.0 F1000.0

    G92 E0;

     

     

     

    PI3MK3M_2 Inch Calibration Cube.gcode PI3MK3M_2 Inch Calibration Cube.3mf

  • Link to post
    Share on other sites

    Posted · Custom G-Code before heating (Prusa)

    Cura doesn't do math or logic when going through the StartUp G-Code.  It looks like PrusaSlicer may do both.  It's good that you sorted that out.

    Cura always puts the M82 in at the beginning to set the printer to absolute extrusion mode.

    I notice that you have an M83 in the start gcode and the extrusions in your purge lines are "relative" so that is fine.

    G1 X240.0 E25.0 F2200.0

    G1 Y-2.0 F1000.0

    G1 X55.0 E25 F1400.0

    G1 Z0.20 F1000.0

    G1 X5.0 E4.0 F1000.0

    But the rest of the file was sliced in "absolute" extrusion mode and when your start up gcode ends it is leaving the printer in "relative" mode so I don't think that file would print correctly.

    You either need to enable "Special Modes / Relative Extrusion" in Cura, or add an M82 at the very end of your start up g-code.  The printer needs to know how to interpret the E numbers it sees.  That would be true for the Ender as well.

     

  • Link to post
    Share on other sites

    Posted · Custom G-Code before heating (Prusa)

    Great... thank you for that catch.... I would have probably pulled my hair out trying to find it.  

     

    I copied start code from prusa slicer for this.  

     

    The only reason I am trying to get a profile for this in cura, is so my students can print on all the printers we have and just use one software.  Plus it is a pain for me to get my tech department to install another software onto the computers at this junction of the year....  I will test on Monday and see if this takes care of issues and how the cube prints.

     

    I will post results here when done.

  • 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

      • 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
        • 16 replies
      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
         
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
    ×
    ×
    • Create New...