<p>After trying many different things, I found out that the solution is quite simple and requires only a few lines of code. I'll answer my own question in the hope that this will help someone.</p>
<p>First, I defined a few constants (macros actually). To keep my own additions separate, I created a new file for them called <em>myconfig.h</em>:</p>
<pre><code>#define MY_BED_TEMP_THRESHOLD 50
#define MY_BED_AUTO_FAN_PIN 6
#define MY_BED_AUTO_FAN_SPEED 255
</code></pre>
<p>The pin constant corresponds to D6 which is the green marked output of the RRD Fan Extender where I connected the fans under my bed.</p>
<p><a href="https://i.sstatic.net/X7gcS.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/X7gcS.png" alt="enter image description here" /></a></p>
<p>Second, in the file <em>temperature.cpp</em> of the Marlin Firmware, I included my file and added four lines of code:</p>
<pre><code>#include &quot;myconfig.h&quot;

... 

#if HAS_AUTO_FAN

  void Temperature::checkExtruderAutoFans() {
  
    ...

    HOTEND_LOOP() {
      if (current_temperature[e] &gt; EXTRUDER_AUTO_FAN_TEMPERATURE)
        SBI(fanState, fanBit[e]);
    }


    // --- start of my code ----------
    if (current_temperature_bed &gt; MY_BED_TEMP_THRESHOLD)
      digitalWrite(MY_BED_AUTO_FAN_PIN, MY_BED_AUTO_FAN_SPEED);
    else
      digitalWrite(MY_BED_AUTO_FAN_PIN, 0); 
    // --- end of my code ------------

    ...

#endif // HAS_AUTO_FAN    
...
</code></pre>
<p>Now my fans automatically turn on when the bed temperature is above 50 °C, and turn off again when the bed has cooled below that temperature.</p>

CC BY-SA 4.0
2018-01-10T20:33:14.197Z
2022-01-29T08:15:51.493Z
2022-01-29T08:15:51.493Z
xoric
<p>I have successfully assembled my custom-built 3D printer and configured Marlin for two extruders and one heated bed. Here is a picture of the printer.</p>
<p><a href="https://i.sstatic.net/eudic.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/eudic.jpg" alt="enter image description here" /></a></p>
<p>My heated bed runs on a linear axis with ball bearings. When the printer has been running for an hour or so these parts get really hot and I am afraid that the plastic parts will melt if I print any longer or with higher temperatures. So I decided to add fans below the heated bed to keep them cool.</p>
<p>A known problem when using two extruders and a heated bed is that all three power outputs D8, D9, D10 are in use (in my setup D8 belongs to the first extruder, D9 to the bed, and D10 to the second extruder). If you want to have software-controlled fans on top of that, you need to use a workaround. I bought the <a href="http://www.geeetech.com/wiki/index.php/Reprap_Ramps1.4_RRD_Fan_Extender" rel="nofollow noreferrer">RRD fan extender</a> which does exactly what I need. You plug it into the RAMPS 1.4 board and get two new outputs D6 and D11.</p>
<p><a href="https://i.sstatic.net/ihNqh.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ihNqh.jpg" alt="Picture of the RRD fan extender" /></a></p>
<p>Previously I had configured the firmware as follows:</p>
<pre><code>#define E0_AUTO_FAN_PIN 11
#define E1_AUTO_FAN_PIN 6
</code></pre>
<p>This automatically enabled the fan of the left extruder E0 when its hotend exceeds 50 °C. The same goes for the right extruder E1. The fans are plugged into the fan extender's outputs D6 and D11. It all worked fine.</p>
<p>Now to add fans to the heated bed, I have modified the firmware so that D11 controls both extruder fans. As long as at least one extruder is hot, both fans are running. For that purpose, I connected both extruder fans in parallel to D11 and modified the firmware as follows:</p>
<pre><code>#define E0_AUTO_FAN_PIN 11
#define E1_AUTO_FAN_PIN 11
</code></pre>
<p>This part works fine and was quite easy to achieve. What I would like to do next is connect the other pin, D6, to the temperature sensor of the heated bed so that the fans underneath it become active when the bed is at 50 °C or more.</p>
<p>I made several attempts to trick the firmware into believing that there are three hotends, registering the heated bed as E2.</p>
<pre><code>#define E2_AUTO_FAN_PIN 6
</code></pre>
<p>I manually defined the temperature sensor of the bed for E2 and commented out some sanity checks and conditionals to enable some parts of the firmware that control the auto-fans. While I get the code to compile, the printer usually halts immediately after it is turned on or as soon as an extruder or the bed is activated. The error messages are not very helpful (&quot;killed, please restart&quot; etc.).</p>
<p>Does anybody know a good way how to achieve my goal? Any help would be appreciated. Thank you in advance.</p>

<marlin><ramps-1.4><dual-nozzle><print-fan>
How to configure Marlin to enable auto-fans with dual extruder
xoric
# How to configure Marlin to enable auto-fans with dual extruder

(Asked by: username_0 on 2018-01-04)

I have successfully assembled my custom-built 3D printer and configured Marlin for two extruders and one heated bed. Here is a picture of the printer.

[![enter image description here](https://i.sstatic.net/eudic.jpg)](https://i.sstatic.net/eudic.jpg)

My heated bed runs on a linear axis with ball bearings. When the printer has been running for an hour or so these parts get really hot and I am afraid that the plastic parts will melt if I print any longer or with higher temperatures. So I decided to add fans below the heated bed to keep them cool.

A known problem when using two extruders and a heated bed is that all three power outputs D8, D9, D10 are in use (in my setup D8 belongs to the first extruder, D9 to the bed, and D10 to the second extruder). If you want to have software-controlled fans on top of that, you need to use a workaround. I bought the [RRD fan extender](http://www.geeetech.com/wiki/index.php/Reprap_Ramps1.4_RRD_Fan_Extender) which does exactly what I need. You plug it into the RAMPS 1.4 board and get two new outputs D6 and D11.

[![Picture of the RRD fan extender](https://i.sstatic.net/ihNqh.jpg)](https://i.sstatic.net/ihNqh.jpg)

Previously I had configured the firmware as follows:

```
#define E0_AUTO_FAN_PIN 11
#define E1_AUTO_FAN_PIN 6

```

This automatically enabled the fan of the left extruder E0 when its hotend exceeds 50 °C. The same goes for the right extruder E1. The fans are plugged into the fan extender's outputs D6 and D11. It all worked fine.

Now to add fans to the heated bed, I have modified the firmware so that D11 controls both extruder fans. As long as at least one extruder is hot, both fans are running. For that purpose, I connected both extruder fans in parallel to D11 and modified the firmware as follows:

```
#define E0_AUTO_FAN_PIN 11
#define E1_AUTO_FAN_PIN 11

```

This part works fine and was quite easy to achieve. What I would like to do next is connect the other pin, D6, to the temperature sensor of the heated bed so that the fans underneath it become active when the bed is at 50 °C or more.

I made several attempts to trick the firmware into believing that there are three hotends, registering the heated bed as E2.

```
#define E2_AUTO_FAN_PIN 6

```

I manually defined the temperature sensor of the bed for E2 and commented out some sanity checks and conditionals to enable some parts of the firmware that control the auto-fans. While I get the code to compile, the printer usually halts immediately after it is turned on or as soon as an extruder or the bed is activated. The error messages are not very helpful ("killed, please restart" etc.).

Does anybody know a good way how to achieve my goal? Any help would be appreciated. Thank you in advance.

**Tags:** marlin, ramps-1.4, dual-nozzle, print-fan


---

## 1 answers

### Answer by username_0 on 2018-01-10. Score: 9 | Accepted answer

After trying many different things, I found out that the solution is quite simple and requires only a few lines of code. I'll answer my own question in the hope that this will help someone.

First, I defined a few constants (macros actually). To keep my own additions separate, I created a new file for them called *myconfig.h*:

```
#define MY_BED_TEMP_THRESHOLD 50
#define MY_BED_AUTO_FAN_PIN 6
#define MY_BED_AUTO_FAN_SPEED 255

```

The pin constant corresponds to D6 which is the green marked output of the RRD Fan Extender where I connected the fans under my bed.

[![enter image description here](https://i.sstatic.net/X7gcS.png)](https://i.sstatic.net/X7gcS.png)

Second, in the file *temperature.cpp* of the Marlin Firmware, I included my file and added four lines of code:

```
#include "myconfig.h"

... 

#if HAS_AUTO_FAN

  void Temperature::checkExtruderAutoFans() {
  
    ...

    HOTEND_LOOP() {
      if (current_temperature[e] > EXTRUDER_AUTO_FAN_TEMPERATURE)
        SBI(fanState, fanBit[e]);
    }

    // --- start of my code ----------
    if (current_temperature_bed > MY_BED_TEMP_THRESHOLD)
      digitalWrite(MY_BED_AUTO_FAN_PIN, MY_BED_AUTO_FAN_SPEED);
    else
      digitalWrite(MY_BED_AUTO_FAN_PIN, 0); 
    // --- end of my code ------------

    ...

#endif // HAS_AUTO_FAN    
...

```

Now my fans automatically turn on when the bed temperature is above 50 °C, and turn off again when the bed has cooled below that temperature.


---

