Przeglądaj źródła

✨ Controllerfan PWM scaling, kickstart (#24873)

InsanityAutomation 2 lat temu
rodzic
commit
02c43f44c7
No account linked to committer's email address

+ 8
- 4
Marlin/Configuration_adv.h Wyświetl plik

@@ -552,10 +552,14 @@
552 552
   #endif
553 553
 #endif
554 554
 
555
-// When first starting the main fan, run it at full speed for the
556
-// given number of milliseconds.  This gets the fan spinning reliably
557
-// before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
558
-//#define FAN_KICKSTART_TIME 100
555
+/**
556
+ * Fan Kickstart
557
+ * When part cooling or controller fans first start, run at a speed that
558
+ * gets it spinning reliably for a short time before setting the requested speed.
559
+ * (Does not work on Sanguinololu with FAN_SOFT_PWM.)
560
+ */
561
+//#define FAN_KICKSTART_TIME  100  // (ms)
562
+//#define FAN_KICKSTART_POWER 180  // 64-255
559 563
 
560 564
 // Some coolers may require a non-zero "off" state.
561 565
 //#define FAN_OFF_PWM  1

+ 16
- 0
Marlin/src/feature/controllerfan.cpp Wyświetl plik

@@ -72,6 +72,22 @@ void ControllerFan::update() {
72 72
       ? settings.active_speed : settings.idle_speed
73 73
     );
74 74
 
75
+    speed = CALC_FAN_SPEED(speed);
76
+
77
+    #if FAN_KICKSTART_TIME
78
+      static millis_t fan_kick_end = 0;
79
+      if (speed > FAN_OFF_PWM) {
80
+        if (!fan_kick_end) {
81
+          fan_kick_end = ms + FAN_KICKSTART_TIME; // May be longer based on slow update interval for controller fn check. Sets minimum
82
+          speed = FAN_KICKSTART_POWER;
83
+        }
84
+        else if (PENDING(ms, fan_kick_end))
85
+          speed = FAN_KICKSTART_POWER;
86
+      }
87
+      else
88
+        fan_kick_end = 0;
89
+    #endif
90
+
75 91
     #if ENABLED(FAN_SOFT_PWM)
76 92
       thermalManager.soft_pwm_controller_speed = speed;
77 93
     #else

+ 11
- 0
Marlin/src/inc/Conditionals_adv.h Wyświetl plik

@@ -1074,3 +1074,14 @@
1074 1074
 #if ANY(DISABLE_INACTIVE_X, DISABLE_INACTIVE_Y, DISABLE_INACTIVE_Z, DISABLE_INACTIVE_I, DISABLE_INACTIVE_J, DISABLE_INACTIVE_K, DISABLE_INACTIVE_U, DISABLE_INACTIVE_V, DISABLE_INACTIVE_W, DISABLE_INACTIVE_E)
1075 1075
   #define HAS_DISABLE_INACTIVE_AXIS 1
1076 1076
 #endif
1077
+
1078
+// Fan Kickstart
1079
+#if FAN_KICKSTART_TIME && !defined(FAN_KICKSTART_POWER)
1080
+  #define FAN_KICKSTART_POWER 180
1081
+#endif
1082
+
1083
+#if FAN_MIN_PWM == 0 && FAN_MAX_PWM == 255
1084
+  #define CALC_FAN_SPEED(f) (f ?: FAN_OFF_PWM)
1085
+#else
1086
+  #define CALC_FAN_SPEED(f) (f ? map(f, 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM)
1087
+#endif

+ 5
- 0
Marlin/src/inc/SanityCheck.h Wyświetl plik

@@ -1513,6 +1513,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
1513 1513
   #error "To use BED_LIMIT_SWITCHING you must disable PIDTEMPBED."
1514 1514
 #endif
1515 1515
 
1516
+// Fan Kickstart
1517
+#if FAN_KICKSTART_TIME && defined(FAN_KICKSTART_POWER) && !WITHIN(FAN_KICKSTART_POWER, 64, 255)
1518
+  #error "FAN_KICKSTART_POWER must be an integer from 64 to 255."
1519
+#endif
1520
+
1516 1521
 /**
1517 1522
  * Synchronous M106/M107 checks
1518 1523
  */

+ 5
- 11
Marlin/src/module/planner.cpp Wyświetl plik

@@ -1282,16 +1282,10 @@ void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_s
1282 1282
 
1283 1283
   void Planner::sync_fan_speeds(uint8_t (&fan_speed)[FAN_COUNT]) {
1284 1284
 
1285
-    #if FAN_MIN_PWM != 0 || FAN_MAX_PWM != 255
1286
-      #define CALC_FAN_SPEED(f) (fan_speed[f] ? map(fan_speed[f], 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM)
1287
-    #else
1288
-      #define CALC_FAN_SPEED(f) (fan_speed[f] ?: FAN_OFF_PWM)
1289
-    #endif
1290
-
1291 1285
     #if ENABLED(FAN_SOFT_PWM)
1292
-      #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F);
1286
+      #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(fan_speed[F]);
1293 1287
     #else
1294
-      #define _FAN_SET(F) hal.set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F));
1288
+      #define _FAN_SET(F) hal.set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(fan_speed[F]));
1295 1289
     #endif
1296 1290
     #define FAN_SET(F) do{ kickstart_fan(fan_speed, ms, F); _FAN_SET(F); }while(0)
1297 1291
 
@@ -1306,13 +1300,13 @@ void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_s
1306 1300
 
1307 1301
     void Planner::kickstart_fan(uint8_t (&fan_speed)[FAN_COUNT], const millis_t &ms, const uint8_t f) {
1308 1302
       static millis_t fan_kick_end[FAN_COUNT] = { 0 };
1309
-      if (fan_speed[f]) {
1303
+      if (fan_speed[f] > FAN_OFF_PWM) {
1310 1304
         if (fan_kick_end[f] == 0) {
1311 1305
           fan_kick_end[f] = ms + FAN_KICKSTART_TIME;
1312
-          fan_speed[f] = 255;
1306
+          fan_speed[f] = FAN_KICKSTART_POWER;
1313 1307
         }
1314 1308
         else if (PENDING(ms, fan_kick_end[f]))
1315
-          fan_speed[f] = 255;
1309
+          fan_speed[f] = FAN_KICKSTART_POWER;
1316 1310
       }
1317 1311
       else
1318 1312
         fan_kick_end[f] = 0;

+ 7
- 7
Marlin/src/module/temperature.cpp Wyświetl plik

@@ -306,19 +306,19 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
306 306
 #endif
307 307
 
308 308
 #if EITHER(AUTO_POWER_E_FANS, HAS_FANCHECK)
309
-  uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 }
309
+  uint8_t Temperature::autofan_speed[HOTENDS] = ARRAY_N_1(HOTENDS, FAN_OFF_PWM);
310 310
 #endif
311 311
 
312 312
 #if ENABLED(AUTO_POWER_CHAMBER_FAN)
313
-  uint8_t Temperature::chamberfan_speed; // = 0
313
+  uint8_t Temperature::chamberfan_speed = FAN_OFF_PWM;
314 314
 #endif
315 315
 
316 316
 #if ENABLED(AUTO_POWER_COOLER_FAN)
317
-  uint8_t Temperature::coolerfan_speed; // = 0
317
+  uint8_t Temperature::coolerfan_speed = FAN_OFF_PWM;
318 318
 #endif
319 319
 
320 320
 #if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN)
321
-  uint8_t Temperature::soft_pwm_controller_speed;
321
+  uint8_t Temperature::soft_pwm_controller_speed = FAN_OFF_PWM;
322 322
 #endif
323 323
 
324 324
 // Init fans according to whether they're native PWM or Software PWM
@@ -342,11 +342,11 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
342 342
 // HAS_FAN does not include CONTROLLER_FAN
343 343
 #if HAS_FAN
344 344
 
345
-  uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 }
345
+  uint8_t Temperature::fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, FAN_OFF_PWM);
346 346
 
347 347
   #if ENABLED(EXTRA_FAN_SPEED)
348 348
 
349
-    Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT];
349
+    Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, FAN_OFF_PWM);
350 350
 
351 351
     /**
352 352
      * Handle the M106 P<fan> T<speed> command:
@@ -373,7 +373,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
373 373
 
374 374
   #if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE)
375 375
     bool Temperature::fans_paused; // = false;
376
-    uint8_t Temperature::saved_fan_speed[FAN_COUNT]; // = { 0 }
376
+    uint8_t Temperature::saved_fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, FAN_OFF_PWM);
377 377
   #endif
378 378
 
379 379
   #if ENABLED(ADAPTIVE_FAN_SLOWING)

+ 1
- 1
Marlin/src/module/tool_change.cpp Wyświetl plik

@@ -917,7 +917,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
917 917
     #if HAS_FAN && TOOLCHANGE_FS_FAN >= 0
918 918
       thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed;
919 919
       gcode.dwell(SEC_TO_MS(toolchange_settings.fan_time));
920
-      thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = 0;
920
+      thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = FAN_OFF_PWM;
921 921
     #endif
922 922
   }
923 923
 

Ładowanie…
Anuluj
Zapisz