<p><strong>G-code commands are not in the firmware</strong>. You're trying to find something in the code that simply isn't there. Your slicer is responsible for generating a g-code file, which you can then send to your printer (either by printing from an SD-card) or using a host program like repetier or cura. The commands in the G-code file are then executed by the firmware, but they're not part of it.</p>

<p>How the commands are actually processed is not trivial, and it happens in multiple places.</p>

<p>The commands are processed in the <code>process_commands</code> of Marlin_main.cpp. Upon reading a G1 command, it calls <code>get_coordinates</code> to parse the X/Y/Z/feedrate values from the command. Next, the <code>prepare_move</code> function is called, which applies the necessary transformations (clamping to endstops, and the reverse kinematics if you have a delta) before calling <code>plan_buffer_line</code> (which is in <code>planner.cpp</code>) which does some more preprocessing and computes a "block" which is pushed onto the buffer. Next, <code>planner_recalculate</code> is called, which iterates over the blocks to find feasible acceleration patterns for them. Finally, an interrupt (in stepper.cpp, <code>ISR(TIMER1_COMPA_vect)</code>) periodically reads blocks from the buffer and actually sends the signals to the steppers.</p>

CC BY-SA 3.0
2016-11-01T15:49:18.037Z
I get that G-Code commands are not in the firmware I am just trying to find the exact part where they are fetched and executed. I would like to edit the fetched code it before it is executed.
make it happen
CC BY-SA 3.0
2016-11-01T18:50:16.467Z
@makeithappen This was not clear from your question. I've edited my answer to explain (roughly) how the motion planning works. I don't understand why you are pursuing the firmware route, if you want to change F1500 to F200 just do it before you send the file to the printer!
Tom van der Zanden
CC BY-SA 3.0
2016-11-01T07:53:24.020Z
2016-11-01T18:48:59.760Z
2016-11-01T18:48:59.760Z
Tom van der Zanden
<p>I'm currently using Marlin firmware (1.1.0-RC7 - 31 July 2016) and would like to experiment with print speed. </p>

<p>In the file <code>Marlin_main.cpp</code> I see in the <code>process_next_command()</code> function, there is a variable called <code>current_command</code> which (supposedly) holds the G-Code values for travel distance and feedrate(speed). </p>

<p>I'm expecting the actual command for travelling to look something like this:</p>

<pre><code>G1 X50 Y25.3 E22.4 F1500 
</code></pre>

<p>but I'm getting tied up figuring out exactly where it is. I'm assuming if I can change <code>F1500</code> to <code>F200</code>, I can effectively slow down the print speed. </p>

<p>I'm aware of line 753 in the <code>configuration.h</code> file:</p>

<pre><code>#define DEFAULT_MAX_FEEDRATE {300, 300, 5, 25}  // (mm/sec)
</code></pre>

<p>I'm not interested in setting a fixed slow feedrate but would rather change individual G-Code commands. Can someone tell me where I can find the actual G-Code command to edit it?</p>

<marlin><g-code><speed>
Marlin - slowing down print speed
make it happen
# Marlin - slowing down print speed

(Asked by: username_0 on 2016-11-01)

I'm currently using Marlin firmware (1.1.0-RC7 - 31 July 2016) and would like to experiment with print speed.

In the file `Marlin_main.cpp` I see in the `process_next_command()` function, there is a variable called `current_command` which (supposedly) holds the G-Code values for travel distance and feedrate(speed).

I'm expecting the actual command for travelling to look something like this:

```
G1 X50 Y25.3 E22.4 F1500 

```

but I'm getting tied up figuring out exactly where it is. I'm assuming if I can change `F1500` to `F200`, I can effectively slow down the print speed.

I'm aware of line 753 in the `configuration.h` file:

```
#define DEFAULT_MAX_FEEDRATE {300, 300, 5, 25}  // (mm/sec)

```

I'm not interested in setting a fixed slow feedrate but would rather change individual G-Code commands. Can someone tell me where I can find the actual G-Code command to edit it?

**Tags:** marlin, g-code, speed


---

## 1 answers

### Answer by username_1 on 2016-11-01. Score: 1

**G-code commands are not in the firmware**. You're trying to find something in the code that simply isn't there. Your slicer is responsible for generating a g-code file, which you can then send to your printer (either by printing from an SD-card) or using a host program like repetier or cura. The commands in the G-code file are then executed by the firmware, but they're not part of it.

How the commands are actually processed is not trivial, and it happens in multiple places.

The commands are processed in the `process_commands` of Marlin\_main.cpp. Upon reading a G1 command, it calls `get_coordinates` to parse the X/Y/Z/feedrate values from the command. Next, the `prepare_move` function is called, which applies the necessary transformations (clamping to endstops, and the reverse kinematics if you have a delta) before calling `plan_buffer_line` (which is in `planner.cpp`) which does some more preprocessing and computes a "block" which is pushed onto the buffer. Next, `planner_recalculate` is called, which iterates over the blocks to find feasible acceleration patterns for them. Finally, an interrupt (in stepper.cpp, `ISR(TIMER1_COMPA_vect)`) periodically reads blocks from the buffer and actually sends the signals to the steppers.

> **Comments:**
> **username_0**: I get that G-Code commands are not in the firmware I am just trying to find the exact part where they are fetched and executed. I would like to edit the fetched code it before it is executed.  
> **username_1**: @username_0 This was not clear from your question. I've edited my answer to explain (roughly) how the motion planning works. I don't understand why you are pursuing the firmware route, if you want to change F1500 to F200 just do it before you send the file to the printer!  

---

