Browse Source

🐛 Fix heater timeout PID output (#24682)

Giuliano Zaro 2 years ago
parent
commit
dc0b490bf0
No account linked to committer's email address
1 changed files with 4 additions and 3 deletions
  1. 4
    3
      Marlin/src/module/temperature.cpp

+ 4
- 3
Marlin/src/module/temperature.cpp View File

1391
   float Temperature::get_pid_output_hotend(const uint8_t E_NAME) {
1391
   float Temperature::get_pid_output_hotend(const uint8_t E_NAME) {
1392
     const uint8_t ee = HOTEND_INDEX;
1392
     const uint8_t ee = HOTEND_INDEX;
1393
 
1393
 
1394
+    const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out);
1395
+
1394
     #if ENABLED(PIDTEMP)
1396
     #if ENABLED(PIDTEMP)
1395
 
1397
 
1396
       typedef PIDRunner<hotend_info_t, 0, PID_MAX> PIDRunnerHotend;
1398
       typedef PIDRunner<hotend_info_t, 0, PID_MAX> PIDRunnerHotend;
1400
         REPEAT(HOTENDS, _HOTENDPID)
1402
         REPEAT(HOTENDS, _HOTENDPID)
1401
       };
1403
       };
1402
 
1404
 
1403
-      const float pid_output = hotend_pid[ee].get_pid_output();
1405
+      const float pid_output = is_idling ? 0 : hotend_pid[ee].get_pid_output();
1404
 
1406
 
1405
       #if ENABLED(PID_DEBUG)
1407
       #if ENABLED(PID_DEBUG)
1406
         if (ee == active_extruder)
1408
         if (ee == active_extruder)
1463
         hotend.modeled_ambient_temp += delta_to_apply > 0.f ? _MAX(delta_to_apply, MPC_MIN_AMBIENT_CHANGE * MPC_dT) : _MIN(delta_to_apply, -MPC_MIN_AMBIENT_CHANGE * MPC_dT);
1465
         hotend.modeled_ambient_temp += delta_to_apply > 0.f ? _MAX(delta_to_apply, MPC_MIN_AMBIENT_CHANGE * MPC_dT) : _MIN(delta_to_apply, -MPC_MIN_AMBIENT_CHANGE * MPC_dT);
1464
 
1466
 
1465
       float power = 0.0;
1467
       float power = 0.0;
1466
-      if (hotend.target != 0 && TERN1(HEATER_IDLE_HANDLER, !heater_idle[ee].timed_out)) {
1468
+      if (hotend.target != 0 && !is_idling) {
1467
         // Plan power level to get to target temperature in 2 seconds
1469
         // Plan power level to get to target temperature in 2 seconds
1468
         power = (hotend.target - hotend.modeled_block_temp) * constants.block_heat_capacity / 2.0f;
1470
         power = (hotend.target - hotend.modeled_block_temp) * constants.block_heat_capacity / 2.0f;
1469
         power -= (hotend.modeled_ambient_temp - hotend.modeled_block_temp) * ambient_xfer_coeff;
1471
         power -= (hotend.modeled_ambient_temp - hotend.modeled_block_temp) * ambient_xfer_coeff;
1489
 
1491
 
1490
     #else // No PID or MPC enabled
1492
     #else // No PID or MPC enabled
1491
 
1493
 
1492
-      const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out);
1493
       const float pid_output = (!is_idling && temp_hotend[ee].is_below_target()) ? BANG_MAX : 0;
1494
       const float pid_output = (!is_idling && temp_hotend[ee].is_below_target()) ? BANG_MAX : 0;
1494
 
1495
 
1495
     #endif
1496
     #endif

Loading…
Cancel
Save