<p>Fairly long winded, but hopefully makes sense;</p>

<p>I understand that G-code is executed line-by-line, and in the main printing phase each instruction is effectively go to location XY (assuming staying within the layer) at a set speed with a set extrusion amount (not rate, as far as I can tell).  </p>

<p>Imagine you were printing a single road width, say 10&nbsp;mm long. If the single instruction says to move that 10&nbsp;mm at a set speed and extrude 10mm of material (which is, I guess, not 10mm of filament), with infinite acceleration and deceleration of the nozzle and extruder gears, then a linear amount of material would be extruded per unit length along the 10&nbsp;mm. However, given that there is some acceleration and deceleration, that extrusion must be non-linear. </p>

<p>My questions are as follows;
- Is it possible to counteract this within a single line of Gcode by having a variable extrusion rate? 
- Can the machine do so regardless of the instructions given to it? 
- Is this effect embraced somehow? 
- Does the need to accelerate both the nozzle position and filament effectively cancel out? 
-Would/could you aim instead to split a single straight line of filament into multiple lines of G-code, some extruding (say in the middle), and some not (say at each end)?</p>

[{'answer_id': 8246, 'author': 'Trish', 'author_id': 8884, 'author_profile': 'https://3dprinting.stackexchange.com/users/8884', 'pm_score': 0, 'selected': False, 'text': '<h1>No</h1>\n<p>G-code is written line separated, starting with one command what to do, then who does it with what factors. For example <code>G1 X10 F100 E10</code> says this:</p>\n<ul>\n<li><code>G1</code> Move...</li>\n<li><code>X10</code> The X axis by 10</li>\n<li><code>F100</code> Use the factor to 100 units</li>\n<li><code>E10</code> Also: the Extruder by 10</li>\n</ul>\n<p>To my knowledge any repeated or invalid expression is simply ignored (or overwritten). So <code>G1 X10 F100 E10 F200</code> gets parsed as either  <code>G1 X10 F100 E10</code> or  <code>G1 X10 E10 F200</code>, depending on how your firmware interpreter is set up.</p>\n'}, {'answer_id': 8248, 'author': 'mbmcavoy', 'author_id': 5704, 'author_profile': 'https://3dprinting.stackexchange.com/users/5704', 'pm_score': 1, 'selected': False, 'text': "<p>My understanding is that the printer firmware will define the maximum acceleration and speeds for each axis (X, Y, Z, and E). When executing a line of g-code that involves more than one axis, the acceleration for each will be limited such that they all begin and end, including acceleration together.</p>\n\n<p>During the start and end of a line, when the print nozzle is moving more slowly, the extruder will also move slowly. In the middle of the line, the extruder will move faster. The amount of material extruded per distance will be constant over the length of the line.</p>\n\n<p>Another way to look at it - suppose you could accelerate quickly on X with a high top speed, but slowly on Y. A move only in the X direction could happen quickly. A move only in the Y direction would be slower. If you want to move at a 45-degree angle,  you will need to slow down X so that it doesn't get ahead of Y.</p>\n\n<p>If you did want to intentionally vary the amount of extrusion per distance during a line, you would need to break it into multiple segments with individual lines of g-code.</p>\n"}, {'answer_id': 8249, 'author': 'user77232', 'author_id': 12857, 'author_profile': 'https://3dprinting.stackexchange.com/users/12857', 'pm_score': 1, 'selected': False, 'text': "<p>Let's see...</p>\n\n<blockquote>\n  <p>Is it possible to counteract this within a single line of Gcode by having a variable extrusion rate?</p>\n</blockquote>\n\n<p><strong>No,</strong> it cannot. G Code executes line by line. If you have a line : G1 X10 F100 F200 F300\nsome parseres will accept the first (F100), some will only accept the last (F300)</p>\n\n<blockquote>\n  <p>Can the machine do so regardless of the instructions given to it? </p>\n</blockquote>\n\n<p>If you program a <strong>custom</strong> G code parser to do so, you still couldn't because there is no time scale to which you would want the effect to apply. To do this you would have to introduce a new letter to your parser (let's call it K), which you could use to instruct the machine to scale the extrusion accordingly (e.g. G1 X10 F100 K0.24). The machine would then know to scale the F parameter by 0.24 over the course of the movement.</p>\n\n<blockquote>\n  <p>Is this effect embraced somehow? </p>\n</blockquote>\n\n<p>Uhm... no?</p>\n\n<blockquote>\n  <p>Does the need to accelerate both the nozzle position and filament effectively cancel out? </p>\n</blockquote>\n\n<p>Cancel out how? The filament stepper as well as the gantry steppers are step synchronized so that they operate at the correct feedrate, at all times. </p>\n\n<blockquote>\n  <p>Would/could you aim instead to split a single straight line of\n     filament into multiple lines of G-code, some extruding (say in the\n     middle), and some not (say at each end)?</p>\n</blockquote>\n\n<p><strong>Absolutely not.</strong> Each line of gcode has to be completed by the machine before any other line can be considered. You can't have one motion governed by multiple lines of g-code, because there will be not way to control the timing of the execution of the lines.</p>\n"}, {'answer_id': 8251, 'author': 'Lux Claridge', 'author_id': 13883, 'author_profile': 'https://3dprinting.stackexchange.com/users/13883', 'pm_score': 1, 'selected': False, 'text': '<p>While Trish directly answers the G-Code part of your question, my answer offers an alternative if you use Marlin. RepRap has a similar feature called pressure advance, but this answer is focusing on Marlin\'s feature.</p>\n\n<p>According to <a href="http://marlinfw.org/docs/features/lin_advance.html" rel="nofollow noreferrer">Marlin</a>:</p>\n\n<blockquote>\n  <p>Under default conditions, extruder axis movement is treated in the same way as the XYZ linear axes. The extruder motor moves in linear proportion to all the other motors, maintaining exactly the same acceleration profile and start/stop points. But an extruder is not a linear system, so this approach leads, most obviously, to extra material being extruded at the end of each linear movement.</p>\n</blockquote>\n\n<p>In short, corners result in being rounded instead of sharp due to the constant extrusion when laying down a line. One can mitigate this by changing the flow, though this might affect straight lines in other parts of the print, namely under extruding them. Marlin\'s answer to this is linear advance.</p>\n\n<p>With linear advance, the extrusion rate changes as the print head speed changes. When the print head moves faster, more plastic has to be pushed out to lay a consistent line and as soon as the head slows down, the extrusion rate slows down to compensate. The print should then have a consistent line. This is all done using a new factor called k. From <a href="http://marlinfw.org/docs/features/lin_advance.html#special-notes-for-v1.5" rel="nofollow noreferrer">Marlin</a>:</p>\n\n<blockquote>\n  <p>K is now a meaningful value with the unit [mm of filament compression needed per 1mm/s extrusion speed] or [mm/mm/s].</p>\n</blockquote>\n\n<p>One can determine the k value for their printer using Marlin\'s <a href="http://marlinfw.org/tools/lin_advance/k-factor.html" rel="nofollow noreferrer">k calibration tool</a> which prints out multiple straight lines and instructs the printer to print the start of each line slowly, then print fast, and end the line slow again. Each line has a different k value and the user chooses the k value from the line that is most consistent. </p>\n\n<h2>Some caveats</h2>\n\n<p>Bowden style extruders require larger k values which, even then, linear advancing may not work. This is due to the bowden tube itself and the material between the extruder motor and the hot end. This is along the same issue as trying to print flexible plastics with a bowden extruder. While linear advance is better suited for direct drives, it\'s not impossible to use it on a bowden.</p>\n\n<p>Setting up linear advance requires an extra set of tuning. While this primarily means tuning the k value, print speeds may need adjusting (potentially allowing for faster speeds even).</p>\n\n<p>Older linear advance version, at least on Marlin, had the extruder motor a lot more active. Some people report that printing is noticeably noisier. This feature might also add an extra load to the CPU. These issues should not be a problem anymore, as of v1.5, but YMMV.</p>\n\n<p>One needs to change the firmware/G-Code so that each print can use linear advance. If the printer is only using one material the firmware can be changed. However, if multiple materials will be used within the printer\'s lifetime, the G-Code will have to include the following command at the end of the start script ( more found <a href="http://marlinfw.org/docs/features/lin_advance.html#adding-the-k-factor-to-the-g-code-start-script" rel="nofollow noreferrer">here</a>). This k value will be different for each material. An example of the command is as follows:</p>\n\n<pre><code>M900 K75 ; Set k-factor for PLA\n</code></pre>\n\n<p>The link also recommends setting the k factor value to 0 when turning the feature on in the firmware. This essentially disables the hard-coded value in the firmware.</p>\n\n<p>Finally, slicer settings like pressure advance, Coast at end, extra restart length after retract should be disabled when using linear advance as they do a similar operation. On the flip side, these settings may work for your printer so you may not need to even use linear advance.</p>\n'}, {'answer_id': 8258, 'author': 'Davo', 'author_id': 4922, 'author_profile': 'https://3dprinting.stackexchange.com/users/4922', 'pm_score': 1, 'selected': False, 'text': '<p><strong>Not on one line, but...</strong></p>\n\n<p>On Hyrel systems, you <em>can, manually</em>, split one long move into several smaller moves, each with a different extrusion rate.</p>\n\n<p>For example, let\'s start at X100 Y100, and move to X100 Y200. On a Hyrel, this would look like this (with an inherited F rate if not specified):</p>\n\n<pre><code>  G1 X100 Y200 E1\n</code></pre>\n\n<p>We could change this by specifying our Feed Rate Multiplier:</p>\n\n<pre><code>  M221 S0.9 ; set feed rate multiplier to 90%\n  G1 X100 Y110 E1 ; print 10mm\n  M221 S0.95 ; set feed rate multiplier to 95%\n  G1 X100 Y120 E1 ; print 10mm\n  M221 S1 ; set feed rate multiplier to 100%\n  G1 X100 Y130 E1 ; print 10mm\n  M221 S1.05 ; set feed rate multiplier to 105% \n  ...\n</code></pre>\n\n<p>We can also vary all of the parameters between moves, including print speed, acceleration, deceleration, cooling, and UV curing.</p>\n\n<p>And we do use "linear advance" as well, so extrusion ramps up with travel speed.</p>\n\n<p>Note: I work for Hyrel.</p>\n'}]
['https://3dprinting.stackexchange.com/questions/8241', 'https://3dprinting.stackexchange.com', 'https://3dprinting.stackexchange.com/users/14514/']