Smoothieware Switch Module for Automatic Fan Control
by dintid in Workshop > 3D Printing
11841 Views, 24 Favorites, 0 Comments
Smoothieware Switch Module for Automatic Fan Control
This is a follow up to my Instructable about Configuring MKS Sbase v1.2 32-bit Controller basics and intro to Smoothieware.
As the previous one, this is using Sbase but it Works equally fine on the original Smoothieboard.
This time I am going to take a look at one of the advanced interesting features, which will allow us to control fans based on a temperature of our choosing.
The fan cooling the heatsink on the hotend fan can be rather loud, and there is no need for it to be active unless the hotend is in use. To do something about this we are going to use the temperatureswitch module, which have a few options, to turn the fan on when the hotend reaches 50c and off again, when the temperature drops below 50c.
The 15th of may I just added a deal of notes regarding using switches and M-codes. In case you want to reread it :)
- Configuring Switch for HOTEND HEATSINK fan
- Configuring Temperatureswitch to control hotendheatsinkfan
Configuring Switch for HOTEND HEATSINK Fan
We start by creating a standard switch which have a lot of options we can use.
I am defining the name a hotendheatsinkfan as this switch is going to manage the fan on our hotend heatsink.
All options are prepended with switch.hotendheatsinkfan which denotes it is a switch and the name of the switch.
- We make a new section a headline descriptive name of our switch, in this case Switch for HOTEND HEATSINK fan. I use caps to be able to spot it easily in my config.txt file.
- We use .enable true to enable the switch.
- I have setup, but commented out the .input_on_command, .input_off_command and .subcode for our switch.
- They are commented out, as Smoothieware is currently in need of a planned update to fix a few bugs related to the switches.
Note. For general usage it makes no different wheter you have them uncommented or not. The firmware does not use the M-codes to control the fan. - The commands are used to manually turn the fan on and off, where the subcode specifies the specific object assigned to a switch, in this case a fan, we want to control, in case we have more of them.
- Example: M106.2 to turn it on and M107.2 to turn it off. If I had an additional switch with subcode 3, I would control it using M106.3 and M107.3
- Note: when using MKS TFT displays you do not want to add a subcode to FAN, which is the one cooling your printed objects, as you are going to be unable to control it from the display. You can still use subcodes for other fans.
Do not add on and off _command to several switches without using subcodes, unless you want all of them to be turned on and off with the same command.
- They are commented out, as Smoothieware is currently in need of a planned update to fix a few bugs related to the switches.
- The .output_pin defines the pin our fan is attached to. In this case we use 2.6 which is the Heater2 terminals.
- The .output_type is either pwm or digital. PWM can be setup with power from 0-100% defined by 0-255 where digital is on or off.
- The .max_pwm setting defines maximum output to our fan. Mine is rather loud and cool just fine at speed 200.
- You don't want to set this too low as you risk heatcreep up the hotend where the filament gets soft and clogs up the hotend.
- The .fail_safe_set_to defines what to do in case our printer goes into Crash or HALT mode (maybe some other failture mode as well). I have set it to 1 which Means the fan will keep up spinning if the the printer encounters problems.
- I don't want the hotend heatsink fan to stop working in case I have a case of overheating!
# Switch for HOTEND HEATSINK fan switch.hotendheatsinkfan.enable true # true/false # switch.hotendheatsinkfan.input_on_command M106 # # switch.hotendheatsinkfan.input_off_command M107 # # switch.hotendheatsinkfan.subcode 2 # switch.hotendheatsinkfan.output_pin 2.6 # Heater2 switch.hotendheatsinkfan.output_type pwm # digital would be on/off switch.hotendheatsinkfan.max_pwm 200 # default is 255 switch.hotendheatsinkfan.fail_safe_set_to 1 # CRASH or HALT. 0 or 1
Configuring Temperatureswitch to Control Hotendheatsinkfan
We have now setup a switch which gives us, and the controller, access to turn the hotendheatsink fan on and off and we are now going to setup a temperatureswitch to do just that depending on a readout of a temperature designator, which is the letter T for our hotend in this case.
All options are prepended with temperatureswitch.hotend which denotes it is a temperatureswitch and the name of the temperatureswitch (hotend).
- First write a descriptive headline and comment it out: # Toggle the switch hotendheatsink on/off at 50c
- We use .enable true to enable the switch
- The .designator is used to designate which temperature_control module we are going to monitor. We want to monitor our hotend, which is deginated with the letter T as default.
- As it is now you must not use anything else than a single letter, and it is not recommend changing the letter T. I hope this will change in later firmware updates.
- Now we define which .switch is used when conditions are met. We set it as our hotendheatsink switch.
- The .threshold_temp is the temperature at which point the the above is set into motion. We set it at 50c which is a good setting for our hotend.
- .heatup_poll defines how often the controller checks the temperature on heating up. The default i 15 seconds, but my hotends can get very hot in 15 seconds, so I've set it at 3 seconds instead.
- .cooldow_poll defines how oten the controller checks the temperature on cooldown. 30 seconds is default, but I'd rather have my fan to be quiet as fast as reasonable possible, so I've set it at 3 seconds.
# Toggle the switch hotendheatsink on/off at 50c temperatureswitch.hotend.enable true # temperatureswitch.hotend.designator T # From: temperature_control.hotend.designator temperatureswitch.hotend.switch hotendheatsink # Select which switch to use. temperatureswitch.hotend.threshold_temp 50.0 # Temperature to turn on/off temperatureswitch.hotend.heatup_poll 3 # Default is 15 - Poll heatup temperatureswitch.hotend.cooldown_poll 3 # Default is 30 - Poll cooldown