Преглед на файлове

Add FAN_MAX_PWM for M106-controlled fans

Jiri Jaburek преди 6 години
родител
ревизия
43ddb29f9e
променени са 4 файла, в които са добавени 45 реда и са изтрити 8 реда
  1. 13
    3
      Marlin/Configuration_adv.h
  2. 13
    3
      Marlin/src/config/default/Configuration_adv.h
  3. 17
    0
      Marlin/src/inc/Conditionals_post.h
  4. 2
    2
      Marlin/src/module/planner.cpp

+ 13
- 3
Marlin/Configuration_adv.h Целия файл

@@ -208,10 +208,20 @@
208 208
 // before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
209 209
 //#define FAN_KICKSTART_TIME 100
210 210
 
211
-// This defines the minimal speed for the main fan, run in PWM mode
212
-// to enable uncomment and set minimal PWM speed for reliable running (1-255)
213
-// if fan speed is [1 - (FAN_MIN_PWM-1)] it is set to FAN_MIN_PWM
211
+/**
212
+ * PWM Fan Scaling
213
+ *
214
+ * Define the min/max speeds for PWM fans (as set with M106).
215
+ *
216
+ * With these options the M106 0-255 value range is scaled to a subset
217
+ * to ensure that the fan has enough power to spin, or to run lower
218
+ * current fans with higher current. (e.g., 5V/12V fans with 12V/24V)
219
+ * Value 0 always turns off the fan.
220
+ *
221
+ * Define one or both of these to override the default 0-255 range.
222
+ */
214 223
 //#define FAN_MIN_PWM 50
224
+//#define FAN_MAX_PWM 128
215 225
 
216 226
 // @section extruder
217 227
 

+ 13
- 3
Marlin/src/config/default/Configuration_adv.h Целия файл

@@ -208,10 +208,20 @@
208 208
 // before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
209 209
 //#define FAN_KICKSTART_TIME 100
210 210
 
211
-// This defines the minimal speed for the main fan, run in PWM mode
212
-// to enable uncomment and set minimal PWM speed for reliable running (1-255)
213
-// if fan speed is [1 - (FAN_MIN_PWM-1)] it is set to FAN_MIN_PWM
211
+/**
212
+ * PWM Fan Scaling
213
+ *
214
+ * Define the min/max speeds for PWM fans (as set with M106).
215
+ *
216
+ * With these options the M106 0-255 value range is scaled to a subset
217
+ * to ensure that the fan has enough power to spin, or to run lower
218
+ * current fans with higher current. (e.g., 5V/12V fans with 12V/24V)
219
+ * Value 0 always turns off the fan.
220
+ *
221
+ * Define one or both of these to override the default 0-255 range.
222
+ */
214 223
 //#define FAN_MIN_PWM 50
224
+//#define FAN_MAX_PWM 128
215 225
 
216 226
 // @section extruder
217 227
 

+ 17
- 0
Marlin/src/inc/Conditionals_post.h Целия файл

@@ -980,6 +980,23 @@
980 980
 #define HAS_FANMUX PIN_EXISTS(FANMUX0)
981 981
 
982 982
 /**
983
+ * MIN/MAX fan PWM scaling
984
+ */
985
+#ifndef FAN_MIN_PWM
986
+  #define FAN_MIN_PWM 0
987
+#endif
988
+#ifndef FAN_MAX_PWM
989
+  #define FAN_MAX_PWM 255
990
+#endif
991
+#if FAN_MIN_PWM < 0 || FAN_MIN_PWM > 255
992
+  #error "FAN_MIN_PWM must be a value from 0 to 255."
993
+#elif FAN_MAX_PWM < 0 || FAN_MAX_PWM > 255
994
+  #error "FAN_MAX_PWM must be a value from 0 to 255."
995
+#elif FAN_MIN_PWM > FAN_MAX_PWM
996
+  #error "FAN_MIN_PWM must be less than or equal to FAN_MAX_PWM."
997
+#endif
998
+
999
+/**
983 1000
  * Bed Probe dependencies
984 1001
  */
985 1002
 #if HAS_BED_PROBE

+ 2
- 2
Marlin/src/module/planner.cpp Целия файл

@@ -1108,8 +1108,8 @@ void Planner::check_axes_activity() {
1108 1108
 
1109 1109
     #endif // FAN_KICKSTART_TIME > 0
1110 1110
 
1111
-    #ifdef FAN_MIN_PWM
1112
-      #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? ( FAN_MIN_PWM + (tail_fan_speed[f] * (255 - FAN_MIN_PWM)) / 255 ) : 0)
1111
+    #if FAN_MIN_PWM != 0 || FAN_MAX_PWM != 255
1112
+      #define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? map(tail_fan_speed[f], 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : 0)
1113 1113
     #else
1114 1114
       #define CALC_FAN_SPEED(f) tail_fan_speed[f]
1115 1115
     #endif

Loading…
Отказ
Запис