Jump to content
UltiMaker Community of 3D Printing Experts

Extra gcode in the files from Cura.


toreae
 Share

Recommended Posts

Posted · Extra gcode in the files from Cura.

Hello. I have rebuilt Ender 5. It has been rebuilt so that it has 2 hotends on 1 carriage, and 2 extruders. When it needs to change the hot end, I drive to a corner and prime the new hot end in a purge bucket there.
My problem is that I can't get the retract and priming right. Below is the gcode snippet. The first time it uses extruder 1, it get extra Reset Extruder (G92 E0) and Retrackt (G1 F2700 E-6.5). The first time it uses extruder 2, I get extra Retrackt (G1 F2100 E-8.5). Maybe these shouldn't be here. This is something I have in Machine Settings, Extruder x. These extra lines are not included later, when I change the hot end.
I know my explanation is not easy to understand....

 

Extruder 1, 1. time:
G92 E0                ; ***RESET EXTRUDER***?
G1 F2700 E-6.5            ; ******RETRACT*******?
;LAYER_COUNT:16
;LAYER:0
M117 Layer 1 of 16
M107                ; M107: Fan Off
M104 T1 S250            ; Set Hotend Temperature
M204 S1250            ; Set Starting Acceleration
M205 X12 Y12            ; Set Advanced Settings, Jerk

 

Extruder 2, 1. time:
M105                ; Report Temperatures
M109 S250            ; Wait for Hotend Temperature
G1 F2100 E-8.5            ; ******RETRACT*******?
M204 S1000            ; Set Starting Acceleration
M205 X8 Y8            ; Set Advanced Settings, Jerk

 

Extruder 1, 2. time:
M105                ; Report Temperatures
M109 S220            ; Wait for Hotend Temperature
M106 S255            ; Set Fan Speed
M204 S1250            ; Set Starting Acceleration
M205 X12 Y12            ; Set Advanced Settings, Jerk

 

Extruder 2, 2. time and further:
M107                ; M107: Fan Off
M204 S1000            ; Set Starting Acceleration
M205 X8 Y8            ; Set Advanced Settings, Jerk


Extruder 1, 3. time and further:
M106 S255
M204 S1250
M205 X12 Y12

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    Getting a dual extruder to switch correctly does require some experimenting.  You seem to be able to read some gcode so you don't actually have to print things, just experiment with settings and read the code.

    The "Dual Extrusion" settings in Cura can handle most situations without resorting to Start and End gcodes for each extruder.

    You can simplify some of what you have there by setting the Accel and Jerk the same for both hot ends.  Both nozzles are on the same platform/drive system so what is good for one should be good for the other.

     

    Load your models into Cura and set everything up the way you like.  Use the "File } Save Project" command to create a 3mf project file.  Post the 3mf file here and someone will take a look.

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    Thanks for reply. Since I don't use Prime Tower, I have to have another way to prime. I can't see that there is any other way than using Start and End gcodes. Accel and Jerk are not a problem here.
    Now I use Search and Replace to get this right. I see that there are many people who prefer not to use Prime Tower. Start and End gcodes are perfect for this. But then this must not be destroyed by Reset Extruder and Retract before the first use. In case of later use of the Extruder, this is correct.

    2-circle.3mf

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    This is the beginning of the gcode for Ender 3 Pro (Single extruder, single hotend):

     

    M82 ;absolute extrusion mode
    ; Ender 3 Custom Start G-code
    G92 E0 ; Reset Extruder
    G28 ; Home all axes
    M104 S175 ; Start heating up the nozzle most of the way
    M190 S50.0 ; Start heating the bed, wait until target temperature reached
    M109 S200 ; Finish heating the nozzle
    G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
    G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
    G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
    G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
    G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
    G92 E0 ; Reset Extruder
    G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
    G1 X5 Y20 Z0.3 F5000.0 ; Move over to prevent blob squish
    G92 E0
    G92 E0
    G1 F1500 E-6
    ;LAYER_COUNT:4
    ;LAYER:0
    M107
    M204 S500
    M205 X5 Y5
    G0 F7500 X87.745 Y88.147 Z0.28
    G0 X80.779 Y99.097
    M205 X8 Y8
    ;TYPE:SKIRT
    G1 F1500 E0

     

     

    This is how I would have the gcode for Ender 3 Pro.

     

    M82 ;absolute extrusion mode
    ; Ender 3 Custom Start G-code
    G92 E0 ; Reset Extruder
    G28 ; Home all axes
    M104 S175 ; Start heating up the nozzle most of the way
    M190 S50.0 ; Start heating the bed, wait until target temperature reached
    M109 S200 ; Finish heating the nozzle
    G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
    G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
    G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
    G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
    G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
    G1 F1500 E24                              ;****** Retract in the correct place ******
    G92 E0 ; Reset Extruder
    G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
    G1 X5 Y20 Z0.3 F5000.0 ; Move over to prevent blob squish
    G92 E0
    G92 E-6                 ****** This line in Extruder Start gcode *******
    ; G92 E0               ****** Remove this line ******
    ; G1 F1500 E-6         ****** Remove this line ******
    ;LAYER_COUNT:4
    ;LAYER:0
    M107
    M204 S500
    M205 X5 Y5
    G0 F7500 X87.745 Y88.147 Z0.28
    G0 X80.779 Y99.097
    M205 X8 Y8
    ;TYPE:SKIRT
    G1 F1500 E0

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    I sliced the project.  These comments are in regards to the gcode file that was created:

    Cura always refers to E0 in movements and adjusts the location of E1 by adjusting the gcode so E0 is offset and E1 prints where it should.  You have elected to not have Cura offset the gcode.

    This image is from AutoCad.  It's the gcode file I created.  You can see the movement off the build plate.  In addition, there is no "disallowed" area for either extruder.  That means there is no offset between the extruders?

    Dual.thumb.png.e907bc2248179823d066390e68839fbf.png

     

    This is my "virtual" Ender 3 Pro.  There is 25mm between the nozzles in the X (side by side mounted to the print head) so E1 can't make it all the way to the left and E0 can't make it all the way to the right.

    image.thumb.png.67c9263780243d2a3094cf3eaecaf14a.png

     

    The way your startup is written - if you have all models set to E1 the print mistakenly starts with E0.

    Within the Startup gcode you have a beep.  Right before the beep I suggest you add

    T{initial_extruder_nr}

    M300

    That will make sure that a print starts with the correct extruder.

     

     

    Right after the G28 line in the StartUp gcode you are moving the X and Y at Z=0.

    G28
    G1 X236 Y180 F6000

     

    I would move the Z up to make sure it doesn't drag on the bed.  With the Z=0 there is no room under the nozzle for the first purges that follow in the gcode.  (I see you are off the bed for your purges.)

    G28

    G1 Z{layer_height_0} F600 ;Move the Z up
    G1 X236 Y180 F6000                                ; Go to X240 at 100mm/s
     

    The print head is at X236 Y180 when this line comes up

    ;                          Cura has just reset the extruder
    G1 X236 Y-20 F1500.0 E30 ; Go to X243 Y-20 at 100mm/s, extrude 25mm

    So you are extruding filament down the right side of the printer bed and going to a location (Y-20) that my Ender 3 Pro can't get to.

     

    Once the print starts then things should print correctly.  The location of the end of the filament in relation to the hole in the nozzle is a key number.  When an extruder is done printing the filament must end up "retraction distance" behind the nozzle.

     

    Prime towers are pretty easy to use.

     

     

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    The project file prints perfectly on my printer. In the gcode you can see 2 places I have entered 'removed with Search and Replace'. I have to, so as not to have filament retracted for Extruder 1. For Extruder 2 I don't really need it.

     

    #define HOTEND_OFFSET_X { 0.0, 0.00 }   // (mm) relative X-offset for each nozzle
    #define HOTEND_OFFSET_Y { 0.0, 48.20 }  // (mm) relative Y-offset for each nozzle
    #define HOTEND_OFFSET_Z { 0.0, 0.00 }   // (mm) relative Z-offset for each nozzle

    #define X_BED_SIZE 230
    #define Y_BED_SIZE 225
    #define X_MIN_POS 0
    #define Y_MIN_POS -20                        
    #define Z_MIN_POS 0
    #define X_MAX_POS 245
    #define Y_MAX_POS Y_BED_SIZE 

     

    11 hours ago, GregValiant said:

    I would move the Z up to make sure it doesn't drag on the bed.


    I have not done any XYZ movements, I have only corrected Extruder movements to get things right with retraction and forward retraction.

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    When you get a chance post a picture of the printhead of your printer.  This sounds like an interesting setup.

    What firmware are you running?

     

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    A picture will not show this in a good way. I have made a mirrored copy of the carrige (only the disc). This plate is mounted on the back of the first, with wheels and X-gantry in between. And there is the second hotend mounted. Firmware is Marlin 2.1.1.

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    A fore-and-aft mount.  I haven't seen one of those.

    I had assumed you altered the firmware.  That's an interesting approach.

     

    Here is a Project File.  I played around with the StartUp Gcode.  When you open the file in Cura make sure you select "Create New" and NOT "Update Dual" in the printer options.  You don't want to over-write your current startup gcode.

    The main change is initializing both extruders in the Startup so if a print starts with extruder 2 it will be ready.

     

    One thing I found out is that there is no "retraction_amount" that can be called for each extruder.  Since you have different amounts (6.5 and 8.5) for the extruders the amount must be hard coded into the StarrtUp Gcode.  Cura uses the correct amounts when the extruders change.  I altered the extruder starts to reflect that.

     

    GV_2-circle.3mf

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.
    47 minutes ago, GregValiant said:

    One thing I found out is that there is no "retraction_amount" that can be called for each extruder.  Since you have different amounts (6.5 and 8.5) for the extruders the amount must be hard coded into the StarrtUp Gcode.  Cura uses the correct amounts when the extruders change.  I altered the extruder starts to reflect that.

     

    There is absolute retraction for each extruder. There is also a separate retraction for switching between extruders. Try creating a new profile, e.g. Geeetech A10M.

  • Link to post
    Share on other sites

    Posted (edited) · Extra gcode in the files from Cura.

    There is no confusion during a print as Cura knows which tool is active.   It would appear that when doing the StartUp Gcode that isn't the case.  Cura considers the "Tool Number" that goes in before the startup gcode to be the active extruder.

    Within the Replacement Keywords list I have not found a way to say "{retraction_amount_extruder_1}" or {switch_extruder_retraction_amount_extruder_1}.  Cura defaults to what it believes to be the active extruder and that's the retraction amount it gets.  One of the extruders will be wrong in the startup.

    It all works correctly elsewhere.

    The same sort of thing happens with Search and Replace.  If you change the retraction distance or speed the Search line needs to change.  There is no way to say

    Search = G1 F{retraction_speed} E-{retraction_amount} because at that point they are treated as text and not replacement keywords.

    Edited by GregValiant
  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    See attached picture. If you switch between extruders (1), you can set different retraction (2).

     

    image.thumb.jpeg.b4305ad5d18bf248e937cb7042c1a257.jpeg

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    Yes.  No problem setting different retraction distance per extruder and they work correctly during the print.

    The problem is in describing that in the StartUp Gcode.

    Example:  You have Extruder 1 set to 6.5 retraction at 45mm/sec and Extruder 2 set to 8.5 retraction at 35mm/sec.

    Your startup gcode might contain something like this:

    T1

    G1 F{retraction_speed} E-{retraction_amount}

    T0

    G1 F{retraction_speed} E-{Retraction_amount}

     

    That will result in a gcode:

    ;generated with Cura 5.2.1

    T1

    ;begin startup gcode

    T1

    G1 F2700 E-8.5

    T0

    G1 F2700 E-8.5

     

    I think it's because Cura doesn't actually "read" the startup gcode.  It just looks for replacements that need to be made and then pastes the startup code into the file.  I haven't been able to change the active extruder (from a Cura viewpoint) within the startup gcode.  The printer will see it just fine.  But Cura makes the "Initial Extruder" based on the extruder that starts the print and that tool stays active (from a Cura viewpoint) until the print starts.

     

    T1

    G1 F{retraction_speed} E-{retraction_amount}

    T0

    G1 F{retraction_speed} E-{Retraction_amount}

     

    This time T0 starts the print

    ;generated with Cura 5.2.1

    T0

    ;begin startup gcode

    T1

    G1 F2100 E-6.5

    T0

    G1 F2100 E-6.5

     

    One of them is going to be wrong.

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    My conclusion: If you have 2 hotends, then Cura is really only made for use with Prime Tower. My way of solving this:
    Using extruder start stop gcode.
    In 'Dual Extrusion', I need to have the 'Nozzle Switch Retraction Distance' to the same as the 'Retraction Distance'. I also need to set 'Nozzle Switch Extra Prime Amount' to negative which corresponds to retraction. So 6.5mm retraction gives -15.626mm^3.
    In 'Post Processing' I have to have a 'Search and Replace' that takes away 'G92 E0' the first time the first extruder is put into use (besides my priming in 'Extruder Start Gcode).

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    I always use Search and Replace to remove that first retraction (I replace it with G92 E-2.5).  My "Build Plate Adhesion" always starts perfect without little beads of plastic that get dragged around.  It's what works for me.

     

    I have installed alternate Ender 3 Pro's in Cura because I use a different StartUp Gcode and different Search and Replace for PLA, PETG, and TPU.  The Ender I select is the one for the material I will be using.  Maybe something like that would work for you.

     

    The system you were working on seems to be OK except for the initial retractions that must occur within the startup gcode.  If your retraction distance and retraction speed were the same for both extruders there wouldn't be a problem.  With different values for retraction distance and speed - the first call to the "other" extruder is going to result in either a blob, or an under-extrusion until the filament catches up.  After that it would be fine.

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    I don't understand why you talk about Retracting Distance and Speed, and you have talked about Accel and Jerk. I can assure you that is not the problem. The problem is, as I have written before, extra G92 E0, and errors with Retraction. The filament must be in the Nozzle when the printer starts printing. Not 6.5mm or 8.5mm retraced. Or vice versa, when the printer starts printing, 6.5mm or 8.5mm should not come out at one point.
    The reason for the different speed etc. is, among other things, that I have PLA in extruder 1, and PETG in extruder 2.
    But as I wrote above, I have found a kind of solution. But maybe others may have a better solution than mine.

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    I have tested with Prime Power. This is the 1st time changing the extruder, to extruder no. 2.
    The first time it is switched to extruder 2, and the first time it is switched back to extruder 1, it is an M109 command. Firstly, it is unnecessary, it is the same temperature. Secondly, an M109 command entails a 10 second wait. If there is to be a new temperature after changing the extruder, it should come immediately after the Tx command. As it is now, there are 10 seconds of oozing. Gcode snippet:


    T1
                                           *******BUT HERE************
    G92 E0
    ;                              Start Extruder 2
    ;                              Cura has just reset the extruder
    M106 S255                    ; Fan at full blast
    G1 E10 F1500                 ; Extrude 10mm
    G1 X236 Y22 F1500.0 E30      ; Go to X236 Y-28 @ 25mm/s, extrude 30mm
    G92 E0                       ; Reset Extruder
    G1 X240 Y24.5 F1500          ; Get ready for WIPE
    G3 X243 Y27 I2.5 J-0.8 E-8.5 F720 ; WIPE and retract
    G1 X115 Y112 F12000          ; Go to X236 Y100 at 200mm/s
    ;                              End of start Extruder 2
    M105
    M109 S250                   *******NOT HERE************
    G1 F2700 E-8.5
    M205 X8 Y8
    ;MESH:2-sirklerB.stl
    G0 F7200 X126.104 Y97.337 Z0.32
    G0 X127.477 Y96.028
    G0 X129.055 Y97.352
    G0 X130.494 Y98.826
    G0 X131.779 Y100.437
    G0 X132.897 Y102.169
    G0 X133.836 Y104.001
    G0 X134.589 Y105.919
    G0 X135.147 Y107.903
    G0 X135.504 Y109.931
    G0 X138.443 Y164.101
    M205 X12 Y12
    ;TYPE:SKIRT
    G1 F2100 E-8.49547

  • Link to post
    Share on other sites

    Posted (edited) · Extra gcode in the files from Cura.

    Maybe you are telling it to do to much with your Extruder Start and End scripts.  Clear that out (maybe install another Ender 5 and start fresh) and see how the gcode looks.

     

    This is with the default 16mm retraction for nozzle switch and a T0 retraction distance of 6.5mm.

    G1 F1500 X25.978 Y17.096 E119.96555 >last extrusion with T1
    G0 F7200 X25.218 Y17.096
    G1 F1200 E103.96555 >Retract T1 16mm
    G1 F600 Z0.6
    G92 E0
    T0    >Switch to T0
    G92 E0
    M104 T1 S180 >T1 to standby temp
    M105
    M109 S205  >T0 to print temp with the filament 16mm behind the nozzle and wait for temperature
    G1 F1200 E9.5 >After heating advance the filament up to "retraction distance" behind the nozzle
    G1 F600 Z0.4
    ;MESH:X-Y Ref Block.stl
    G0 F9000 X180.048 Y123.037  >Travel to the prime tower location
    G0 X176.445 Y126.445
    ;TYPE:PRIME-TOWER
    G1 F2100 E16 > T0 unretract the last 6.5mm over the prime tower.  The filament is right at the nozzle.

     

    Since you have gone back to the prime tower maybe everything should go back to default and see how it looks.  You have a heavily customized machine and it will require experimentation to get it to work.

     

    If your Extruder start Gcodes were to include ONLY this line;

    G1 X{prime_tower_position_x} Y{prime_tower_position_y} F12000

    Then you get this in the gcode:

    T0
    G92 E0
    G1 X185 Y115 F12000 >Move to the prime tower location
    M104 T1 S180
    M105
    M109 S205 >heat to print temp

    If there was to be any oozing it would be over the prime tower.

    Edited by GregValiant
  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    I can only repeat myself:

    "I have tested with Prime Power. This is the 1st time changing the extruder, to extruder no. 2.
    The first time it is switched to extruder 2, and the first time it is switched back to extruder 1, it is an M109 command. Firstly, it is unnecessary, it is the same temperature. Secondly, an M109 command entails a 10 second wait. If there is to be a new temperature after changing the extruder, it should come immediately after the Tx command. As it is now, there are 10 seconds of oozing."

    I can't see that you reply to what I have written.
    Extra M109 command, introduces extra 10 second wait. Completely unnecessary. M109 is to check if the correct temperature has been reached, and if it is stable. This leads to 10 seconds of oozing.

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    "I have rebuilt Ender 5. It has been rebuilt so that it has 2 hotends on 1 carriage, and 2 extruders."

    "This is how I would have the gcode for Ender 3 Pro."

     

    Yes, I may be confused.

     

    Without your Extruder Startup Gcode the M109 is just below the T1 line.  The reason it uses M109 is because the temperature may be coming up from the Standby Temperature and so the machine must wait for the hot end to get up to extrusion temperature.

    T1
    G92 E0
    M105
    M109 S250                   *******NOT HERE************

     

    You have a custom one-off printer with (what appears to be) your own firmware version.  Maybe you need a custom slicer or a custom post-processor that will adjust the gcode to your liking.

     

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    Hello again. Never mind how my printer is set up. Try setting up any printer that has 2 extruders and 2 hotends.
    Slice 2 parts so that one part is printed with one extruder hotend, and the other part is printed with the other extruder hotend.
    Check the Gcode. Is there extra M109 that comes after priming?
    I'm pretty sure the problem will be the same.

  • Link to post
    Share on other sites

    Posted · Extra gcode in the files from Cura.

    Two models.  One assigned to each extruder.

    40 instances of M109 and 80 instances of M104.

    40 of the M104's set the inactive extruder to standby temperature.

    40 of the M104's bring the inactive extruder up to print temperature while the active extruder is working.  The actual placement of those M104's is per the "Heat Up Speed" in the printer settings.

    The M109's all occur right after the tool change.  I think it is safe to assume that it is to insure that the hot end is up to temperature before it starts extruding.

     

    The single M104's occur like this:

    G1 F1500 X47.671 Y46.102 E156.54109
    G0 F7200 X46.361 Y45.999
    M104 T0 S220
    G1 F1500 X59.456 Y32.904 E158.08096
    G0 F7200 X58.591 Y32.354

     

    When paired with an M109 they occur like this:

    T0
    G92 E0
    M104 T1 S180
    M105
    M109 S220

    G0 F4800 X192.945 Y160.926 Z3.2
    G1 F600 Z3.1
    G0 F4800 X188.45 Y159.253 Z3.1
    M204 S800
    ;TYPE:PRIME-TOWER

    G1 F600 Z3
    G1 F1500 E16

     

    The prime occurs over the prime tower.

     

  • 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
        • 14 replies
    ×
    ×
    • Create New...