1. About
  2. Features
  3. Explore

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

enter image description here

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 (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 which does exactly what I need. You plug it into the RAMPS 1.4 board and get two new outputs D6 and D11.

enter image description here

Currently I have configured the firmware as follows:

#define E0_AUTO_FAN_PIN 11 #define E1_AUTO_FAN_PIN 6 

This automatically enables the fan of the left extruder E0 when its hotend exceeds 50° celsius. The same goes for the right extruder E1. The fans are plugged into the fan extender's outputs D6 and D11. It all works 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, both extruder fans are connected in parallel to D11 and the firmware setup looks like this:

#define E0_AUTO_FAN_PIN 11 #define E1_AUTO_FAN_PIN 11 

That part works fine and was quite easy to achieve. What I would like to do now is connect the other pin, D6, to the temperature sensor of the heated bed, so that the fans underneath the bed are active when the bed is at 50° celsius 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 those 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.

1 Answer 1

After trying many different things, I found out that the solution is really 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. To keep my own stuff as separate as possible, I made a new file that I called myconfig.h:


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.

<a href=enter image description here">

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

... #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 are automatically turned on while the bed temperature is higher than 50°C and are turned off again after the bed has cooled down far enough.