Help needed with GCode editing problem



  • I was doing a 7 hour print and on checking it found that the x axis had JUST skipped a step. I managed to stop the print before it had done more than print the border on that layer, so the print would be recoverable with just a single layer about 0.5mm shifted. My plan was to get into the gcode file and edit it to start at the point I had stopped it, with the axis reset to the correct position after homing. I used jViewer (great program) to locate the exact point, cut the first part of the file out (the part which had printed) and pasted the setup part of the file (the first few lines) in uploaded it and started the print. It didnt work. The printer went to the correct point but just sat there pouring hot plastic onto the print. Can someone please tell me what is wrong with the file I created. I have a Duet 2 wifi and the printer is a standard cartesian with the bed as the z axis.

    This part was cut and pasted from the beginning of the original file

    M107
    M190 S55 ; set bed temperature and wait for it to be reached
    M104 S210 ; set temperature
    G28 ; home all axes
    G1 Z5 F5000 ; lift nozzle

    ; Filament gcode

    M109 S210 ; set temperature and wait for it to be reached
    G21 ; set units to millimeters
    G90 ; use absolute coordinates
    M82 ; use absolute distances for extrusion
    G92 E0
    G92 E0
    G1 E-4.00000 F6000.00000
    G92 E0

    I then cut out the already printed section. This is where I wanted it to start printing, starting at line 73550 of the original file.
    G1 Z18.600 F7800.000
    This next line I put in just to move the nozzle to the right spot.
    G1 X209.000 Y63.000 F7800.000
    Then the rest is just copied from the original file.
    G1 E4.00000 F6000.00000
    G1 F2400
    G1 X209.134 Y63.784 E1472.39774
    G1 X223.302 Y49.616 E1476.18263
    G1 X222.098 Y49.616 E1476.41017
    G1 X207.930 Y63.784 E1480.19505
    G1 X206.725 Y63.784 E1480.42259
    G1 X220.893 Y49.616 E1484.20747
    G1 X219.689 Y49.616 E1484.43501
    G1 X205.521 Y63.784 E1488.21989
    G1 X204.316 Y63.784 E1488.44743
    G1 X218.484 Y49.616 E1492.23231
    G1 X217.280 Y49.616 E1492.45985
    G1 X203.112 Y63.784 E1496.24473
    G1 X201.907 Y63.784 E1496.47227
    G1 X216.075 Y49.616 E1500.25715
    G1 X214.871 Y49.616 E1500.48469
    G1 X200.703 Y63.784 E1504.26957
    G1 X199.498 Y63.784 E1504.49711
    G1 X213.666 Y49.616 E1508.28199
    G1 X212.461 Y49.616 E1508.50953
    G1 X198.294 Y63.784 E1512.29441
    G1 X197.089 Y63.784 E1512.52195
    G1 X211.257 Y49.616 E1516.30683
    G1 X210.052 Y49.616 E1516.53437
    G1 X195.885 Y63.784 E1520.31925
    G1 X194.680 Y63.784 E1520.54679
    G1 X208.848 Y49.616 E1524.33168

    etc, etc, etc.

    I know I must have missed something basic, but comparing it with the original file I cant see what I have done wrong. Then again my knowledge of G code is to put it politely minimal! I want to learn which is why I am asking instead of just doing another print (plus its about €20 of carbon fiber reinforced plastic!).

    One last question - if something similar happens - the nozzle hits a "bump" and skips a few steps and I spot it quickly, is there a series of commands I can send to pause the print, re-home the axis and then continue the print at the point I paused it?



  • Hi. Looks like you put your extrusion in absolute mode and then :G1 X209.134 Y63.784 E1472.39774. Means printer have to extrude almost 1.5 m of filament before it can continue. So you should put your extruder to the point you paused the print with, something like this:
    G1 E4.00000 F6000.00000
    G1 F2400
    G92 E14xx.xxxxx (whatever numbers you had there instead of x)
    G1 X209.134 Y63.784 E1472.39774

    Just my guess, actually i never had tried something like this.



  • Ha! Of course, the the extruder value is constantly incrementing as the print progresses and as I just started the file part way through it would just sit there until it had extruded filament equal to the total for the first part of the print. That was really stupid of me! Ok, I will give it a try.



  • I agree with @aidar - the issue is your extrusion being on Absolute mode (M82) and you should set your extrusion to relative mode first (M82) , but also your "G92 E0" E parameter should be changed to be very close "1472.39774" - the distance it is at before it needs to continue.

    Right now, with your current gcode, it tells the printer to do the following:

    • Move to location X209, Y63 - this is what you have put in and is fine.
    • Move to location X209.134, Y63.784 at a speed of (F, previous value used if not present) 2400mm/min and extrude a total of 1472.39774mm of filament while doing it.
    • Move to location X223.302 Y49.616 at the same speed as before, while extruding a total of 1476.18263mm of filament.

    As you can see, in the first move, it only moves a fraction of a mm, while having to extrude so much filament (the total that was already used, or the total since the last time the slicer Zero it) so due to your extruder max speed and acceleration, this takes a long time, and the movement speed (in X and Y) is reduced since the Extruder is the speed limiting factor. Then when that is done, in the new movement, it have to extrude the same amount again.

    What you can do to correct it:

    • Insert the correct extruded amount up to that point, using G92 and set the extruder to be in the same mode (absolute vs relative as your slicer).

    When I notice (a) skipped step(s) like this late in a print, I would not stop the print, but rather pause it - the default pause script save current position, and simply returns to it on resume. While it is paused, Home X and Y before continuing the print.

    With it being in a pause, we can do a few nice things, including manually change filament, home X and Y, prime the nozzle etc. before simply pressing the resume and it will continue where it left off (and since after the Home it knows where it is, now in the right position). I did test it with a non-vital print, and recommend testing it on a non-vital print first to ensure you know how it works and fix possible issues in the scripts, before it causes more damage than it solves.



  • @aidar Thanks a load! It worked perfectly! Thats a lot of expensive filament saved.



  • @jacotheron Thanks for the information, it will save me a lot of grief! I knew you could change filament but I didnt know I could redo the homing, I thought issuing any commands would make it lose track of what it was doing. that really useful, thanks!


  • administrators

    Also worth noting is that any time you press Pause, unless you are using really old firmware then a resurrect.g file is created, to make it possible to resume the print later. But you should set up and test your resurrect-prologue file in advance.



  • @dc42 said in Help needed with GCode editing problem:

    Also worth noting is that any time you press Pause, unless you are using really old firmware then a resurrect.g file is created, to make it possible to resume the print later. But you should set up and test your resurrect-prologue file in advance.

    And to add here: use M916 (without any parameters) to resume the print specified in resurrect.g.

    P.S.: Also is there a specific reason you are using absolute extrusion? Relative extrusion is preferable as it will not suffer from any rounding error (as much) as absolute extrusion does. Plus in your case it would just have worked how you tried it first.



  • @dc42 Thanks, I will check it out.



  • @wilriker Thanks for the tips!
    I didnt actually know I was using absolute extrusion! I have not seen any setting in Slic3r to select absolute/relative extrusion and this is the first time I have really edited a gcode file.
    Ok, I have just checked on slic3r and found it (I think) under printer settings>general>advanced>use relative E distances When I hover over it I get a message saying "most firmware uses absolute value" I will give it a try on my next small print and see what happens!



  • @splathammer Interesting and strange tool tip since even Marlin supports relative extrusion for some time now. 😕 Privacy no one has touched this text for a long time.


 

Looks like your connection to Duet3D was lost, please wait while we try to reconnect.