Version
This contain some functions added in the following version, make sure you are on this or newer.
Firmware: RepRapFirmware for STM32F4 based Boards 3.3RC2+1_1 (2021-05-13)
Intro
On my previous printers I always had as many things as possible automated.
Fan on the extruder for when the hotend was over a certain temperature, fan to cool the drivers and mosfets when any of them was online, but that function isn’t in RepRapFirmware, as it is in Marlin, there is an even easier way to do it!
daemon.g
If found, RepRapFirmware will start it every 10th second, and once completed, it will wait a second and start it again. This file should be made to execute as fast as possible with as short as delays as possible. Control should be handed back to the main process at least once every half second.
If the file isn’t found on your printer, you just head over to the System tab and press the New file button to create it.
Object Model
Now we got an empty daemon.g file, but we need to figure out what to put into it.
In this case I want to check if any of the heaters are active, or if any of the stepper drivers are active. To find their definitions we need the Object Model Browser plugin, which can be found on the RRF webgui. You can find that under Settings > General > Built-in plugins where you press the start button next to it. After starting the plugin, make sure to refresh the page.
Now we can see the plugin under Settings > Object Model. Under this there is a list of the heaters, axis, different printer properties…. and a lot of other stuff. First we are interested in the heaters, so we open the heaters array and look at its content. Inside there is a list of heaters, in my case 0 and 1. Here we can see what temperature they are set to reach, mine are both idle, so they are set to zero. Clicking on the active value opens up a tab to the right which show the node and a short summary.
heat.heaters[0].active
Summary
Active temperature of the heater (in C)
With this we can head back to…
daemon.g
We now know how to get the value of each heater, we just need to compare them and figure out what to do with that.
To figure out if a heater is on, it is as simple as
if heat.heaters[0].active > 0
and all we then need to do is to add all the heaters and stepper drivers we want to monitor.
if heat.heaters[0].active > 0 || heat.heaters[1].active > 0 || move.axes[0].homed || move.axes[1].homed || move.axes[2].homed
For the stepper drivers we just check if the axis is homed or not. We can do this because the axis is no longer homed if the stepper driver is disabled.
Next we have to add the functions to turn the fan on and off.
if heat.heaters[0].active > 0 || heat.heaters[1].active > 0 || move.axes[0].homed || move.axes[1].homed || move.axes[2].homed
M106 P2 S1
else
M106 P2 S0
This will turn Fan2 on when any of the heaters or stepper drivers are active, and turn it off if they are all inactive.
Delayed fan stop
With the fan turning on and off, we can now make it a bit more advanced, and make the fan run for some time after everything has returned to inactive.
To do this we need a global variable, to create this add global fan_controller = 0 to the bottom of the config.g file. This will create a global variable which we will use to store the uptime in.
Now we got a variable, which we will store the uptime in, every time we determine the fan should be running.
When everything returns to idle, we will then use that value to determine if enough time has passed, and if it has, we will turn the fan off. And it looks something like this.
if heat.heaters[0].active > 0 || heat.heaters[1].active > 0 || move.axes[0].homed || move.axes[1].homed || move.axes[2].homed
M106 P2 S1
set global.fan_controller = state.upTime
else
if {state.upTime - global.fan_controller} >= 30
M106 P2 S0
With this the fan will continue to run 30 seconds after all stepper drivers and heaters has been turned off.