Introduction: 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 :)

  1. Configuring Switch for HOTEND HEATSINK fan
  2. Configuring Temperatureswitch to control hotendheatsinkfan

Step 1: 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.

  1. 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.
  2. We use .enable true to enable the switch.
  3. I have setup, but commented out the .input_on_command, .input_off_command and .subcode for our switch.
    1. 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.
    2. 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.
    3. Example: M106.2 toturn 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
    4. 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.
  4. The .output_pin defines the pin our fan is attached to. In this case we use 2.6 which is the Heater2 terminals.
  5. 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.
  6. The .max_pwm setting defines maximum output to our fan. Mine is rather loud and cool just fine at speed 200.
    1. 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.
  7. 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.
    1. 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

Step 2: 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).

  1. First write a descriptive headline and comment it out: # Toggle the switch hotendheatsink on/off at 50c
  2. We use .enable true to enable the switch
  3. The .designator is used to designate which temperature_controlmodule we are going to monitor. We want to monitor our hotend, which is deginated with the letter T as default.
    1. 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.
  4. Now we define which .switch is used when conditions are met. We set it as our hotendheatsinkswitch.
  5. 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.
  6. .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.
  7. .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

Comments

author
MichaelR560 (author)2016-10-20

I think there is a slight mistake in the config switch:

temperatureswitch.hotend.switch hotendheatsink <--- should be hotendheatsinkfan

author
MichaelR560 (author)MichaelR5602016-10-20

without that, you get the error "// Failed to get switch state."

author
MartinM190 (author)2016-09-19

How much current can TH4 deliver and which voltage range is supported? I have only 24V fans and don't want to fry my board and / or have my fans running too slow (would like to control two fans simultanously over that pin)

Thank you very much for your instructions! They helped me a lot already.

author
dintid (author)MartinM1902016-09-20

I guess you know the board can handle 12-24v? It means it can output the same voltage as you provide as input.

I do not know max current of any output. Talking 40x40 fans or similar, you do not have to worry about it though.

You can ask the manufacturer if you really want to know :)

https://www.aliexpress.com/store/product/3Dpriter-control-board-MKS-SBase-V1-0-32-s-Motherboard-compatible-Smoothieware-open-source-firmware-support/1047297_32384368763.html

About This Instructable

4,236views

18favorites

License:

Bio: I'm blogging about my projects before they make it to Instructables.com Once I've finished a subject on my blog, I'll put ... More »
More by dintid:Ultimaker 2 – Use 5v controlled fan to also get a 24v controlled fan.Duex5 - Use Build in 12v Switching Regulator on 24v SystemSbase/Smoothieware - Use a Free PWM Pin and Power Expander or SSR to Control Fans.
Add instructable to: