Skip to content

Commit dba1768

Browse files
committed
1 parent ef837ee commit dba1768

File tree

309 files changed

+14750
-1255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

309 files changed

+14750
-1255
lines changed

config/default/Configuration.h

+48-4
Original file line numberDiff line numberDiff line change
@@ -613,10 +613,12 @@
613613
//===========================================================================
614614
//============================= PID Settings ================================
615615
//===========================================================================
616-
// PID Tuning Guide here: https://reprap.org/wiki/PID_Tuning
617616

618-
// Comment the following line to disable PID and enable bang-bang.
619-
#define PIDTEMP
617+
// Enable PIDTEMP for PID control or MPCTEMP for Predictive Model.
618+
// temperature control. Disable both for bang-bang heating.
619+
#define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning
620+
//#define MPCTEMP // ** EXPERIMENTAL **
621+
620622
#define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current
621623
#define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
622624
#define PID_K1 0.95 // Smoothing factor within any PID loop
@@ -636,7 +638,49 @@
636638
#define DEFAULT_Ki 1.08
637639
#define DEFAULT_Kd 114.00
638640
#endif
639-
#endif // PIDTEMP
641+
#endif
642+
643+
/**
644+
* Model Predictive Control for hotend
645+
*
646+
* Use a physical model of the hotend to control temperature. When configured correctly
647+
* this gives better responsiveness and stability than PID and it also removes the need
648+
* for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model.
649+
*/
650+
#if ENABLED(MPCTEMP)
651+
//#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash)
652+
//#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash)
653+
654+
#define MPC_MAX BANG_MAX // (0..255) Current to nozzle while MPC is active.
655+
#define MPC_HEATER_POWER { 40.0f } // (W) Heat cartridge powers.
656+
657+
#define MPC_INCLUDE_FAN // Model the fan speed?
658+
659+
// Measured physical constants from M306
660+
#define MPC_BLOCK_HEAT_CAPACITY { 16.7f } // (J/K) Heat block heat capacities.
661+
#define MPC_SENSOR_RESPONSIVENESS { 0.22f } // (K/s per ∆K) Rate of change of sensor temperature from heat block.
662+
#define MPC_AMBIENT_XFER_COEFF { 0.068f } // (W/K) Heat transfer coefficients from heat block to room air with fan off.
663+
#if ENABLED(MPC_INCLUDE_FAN)
664+
#define MPC_AMBIENT_XFER_COEFF_FAN255 { 0.097f } // (W/K) Heat transfer coefficients from heat block to room air with fan on full.
665+
#endif
666+
667+
// For one fan and multiple hotends MPC needs to know how to apply the fan cooling effect.
668+
#if ENABLED(MPC_INCLUDE_FAN)
669+
//#define MPC_FAN_0_ALL_HOTENDS
670+
//#define MPC_FAN_0_ACTIVE_HOTEND
671+
#endif
672+
673+
#define FILAMENT_HEAT_CAPACITY_PERMM { 5.6e-3f } // 0.0056 J/K/mm for 1.75mm PLA (0.0149 J/K/mm for 2.85mm PLA).
674+
//#define FILAMENT_HEAT_CAPACITY_PERMM { 3.6e-3f } // 0.0036 J/K/mm for 1.75mm PETG (0.0094 J/K/mm for 2.85mm PETG).
675+
676+
// Advanced options
677+
#define MPC_SMOOTHING_FACTOR 0.5f // (0.0...1.0) Noisy temperature sensors may need a lower value for stabilization.
678+
#define MPC_MIN_AMBIENT_CHANGE 1.0f // (K/s) Modeled ambient temperature rate of change, when correcting model inaccuracies.
679+
#define MPC_STEADYSTATE 0.5f // (K/s) Temperature change rate for steady state logic to be enforced.
680+
681+
#define MPC_TUNING_POS { X_CENTER, Y_CENTER, 1.0f } // (mm) M306 Autotuning position, ideally bed center at first layer height.
682+
#define MPC_TUNING_END_Z 10.0f // (mm) M306 Autotuning final Z position.
683+
#endif
640684

641685
//===========================================================================
642686
//====================== PID > Bed Temperature Control ======================

config/examples/3DFabXYZ/Migbot/Configuration.h

+48-4
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,12 @@
596596
//===========================================================================
597597
//============================= PID Settings ================================
598598
//===========================================================================
599-
// PID Tuning Guide here: https://reprap.org/wiki/PID_Tuning
600599

601-
// Comment the following line to disable PID and enable bang-bang.
602-
#define PIDTEMP
600+
// Enable PIDTEMP for PID control or MPCTEMP for Predictive Model.
601+
// temperature control. Disable both for bang-bang heating.
602+
#define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning
603+
//#define MPCTEMP // ** EXPERIMENTAL **
604+
603605
#define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current
604606
#define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
605607
#define PID_K1 0.95 // Smoothing factor within any PID loop
@@ -620,7 +622,49 @@
620622
#define DEFAULT_Ki 3.22
621623
#define DEFAULT_Kd 65.83
622624
#endif
623-
#endif // PIDTEMP
625+
#endif
626+
627+
/**
628+
* Model Predictive Control for hotend
629+
*
630+
* Use a physical model of the hotend to control temperature. When configured correctly
631+
* this gives better responsiveness and stability than PID and it also removes the need
632+
* for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model.
633+
*/
634+
#if ENABLED(MPCTEMP)
635+
//#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash)
636+
//#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash)
637+
638+
#define MPC_MAX BANG_MAX // (0..255) Current to nozzle while MPC is active.
639+
#define MPC_HEATER_POWER { 40.0f } // (W) Heat cartridge powers.
640+
641+
#define MPC_INCLUDE_FAN // Model the fan speed?
642+
643+
// Measured physical constants from M306
644+
#define MPC_BLOCK_HEAT_CAPACITY { 16.7f } // (J/K) Heat block heat capacities.
645+
#define MPC_SENSOR_RESPONSIVENESS { 0.22f } // (K/s per ∆K) Rate of change of sensor temperature from heat block.
646+
#define MPC_AMBIENT_XFER_COEFF { 0.068f } // (W/K) Heat transfer coefficients from heat block to room air with fan off.
647+
#if ENABLED(MPC_INCLUDE_FAN)
648+
#define MPC_AMBIENT_XFER_COEFF_FAN255 { 0.097f } // (W/K) Heat transfer coefficients from heat block to room air with fan on full.
649+
#endif
650+
651+
// For one fan and multiple hotends MPC needs to know how to apply the fan cooling effect.
652+
#if ENABLED(MPC_INCLUDE_FAN)
653+
//#define MPC_FAN_0_ALL_HOTENDS
654+
//#define MPC_FAN_0_ACTIVE_HOTEND
655+
#endif
656+
657+
#define FILAMENT_HEAT_CAPACITY_PERMM { 5.6e-3f } // 0.0056 J/K/mm for 1.75mm PLA (0.0149 J/K/mm for 2.85mm PLA).
658+
//#define FILAMENT_HEAT_CAPACITY_PERMM { 3.6e-3f } // 0.0036 J/K/mm for 1.75mm PETG (0.0094 J/K/mm for 2.85mm PETG).
659+
660+
// Advanced options
661+
#define MPC_SMOOTHING_FACTOR 0.5f // (0.0...1.0) Noisy temperature sensors may need a lower value for stabilization.
662+
#define MPC_MIN_AMBIENT_CHANGE 1.0f // (K/s) Modeled ambient temperature rate of change, when correcting model inaccuracies.
663+
#define MPC_STEADYSTATE 0.5f // (K/s) Temperature change rate for steady state logic to be enforced.
664+
665+
#define MPC_TUNING_POS { X_CENTER, Y_CENTER, 1.0f } // (mm) M306 Autotuning position, ideally bed center at first layer height.
666+
#define MPC_TUNING_END_Z 10.0f // (mm) M306 Autotuning final Z position.
667+
#endif
624668

625669
//===========================================================================
626670
//====================== PID > Bed Temperature Control ======================

config/examples/ADIMLab/Gantry v1/Configuration.h

+48-4
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,12 @@
595595
//===========================================================================
596596
//============================= PID Settings ================================
597597
//===========================================================================
598-
// PID Tuning Guide here: https://reprap.org/wiki/PID_Tuning
599598

600-
// Comment the following line to disable PID and enable bang-bang.
601-
#define PIDTEMP
599+
// Enable PIDTEMP for PID control or MPCTEMP for Predictive Model.
600+
// temperature control. Disable both for bang-bang heating.
601+
#define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning
602+
//#define MPCTEMP // ** EXPERIMENTAL **
603+
602604
#define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current
603605
#define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
604606
#define PID_K1 0.95 // Smoothing factor within any PID loop
@@ -618,7 +620,49 @@
618620
#define DEFAULT_Ki 1.08
619621
#define DEFAULT_Kd 114.00
620622
#endif
621-
#endif // PIDTEMP
623+
#endif
624+
625+
/**
626+
* Model Predictive Control for hotend
627+
*
628+
* Use a physical model of the hotend to control temperature. When configured correctly
629+
* this gives better responsiveness and stability than PID and it also removes the need
630+
* for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model.
631+
*/
632+
#if ENABLED(MPCTEMP)
633+
//#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash)
634+
//#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash)
635+
636+
#define MPC_MAX BANG_MAX // (0..255) Current to nozzle while MPC is active.
637+
#define MPC_HEATER_POWER { 40.0f } // (W) Heat cartridge powers.
638+
639+
#define MPC_INCLUDE_FAN // Model the fan speed?
640+
641+
// Measured physical constants from M306
642+
#define MPC_BLOCK_HEAT_CAPACITY { 16.7f } // (J/K) Heat block heat capacities.
643+
#define MPC_SENSOR_RESPONSIVENESS { 0.22f } // (K/s per ∆K) Rate of change of sensor temperature from heat block.
644+
#define MPC_AMBIENT_XFER_COEFF { 0.068f } // (W/K) Heat transfer coefficients from heat block to room air with fan off.
645+
#if ENABLED(MPC_INCLUDE_FAN)
646+
#define MPC_AMBIENT_XFER_COEFF_FAN255 { 0.097f } // (W/K) Heat transfer coefficients from heat block to room air with fan on full.
647+
#endif
648+
649+
// For one fan and multiple hotends MPC needs to know how to apply the fan cooling effect.
650+
#if ENABLED(MPC_INCLUDE_FAN)
651+
//#define MPC_FAN_0_ALL_HOTENDS
652+
//#define MPC_FAN_0_ACTIVE_HOTEND
653+
#endif
654+
655+
#define FILAMENT_HEAT_CAPACITY_PERMM { 5.6e-3f } // 0.0056 J/K/mm for 1.75mm PLA (0.0149 J/K/mm for 2.85mm PLA).
656+
//#define FILAMENT_HEAT_CAPACITY_PERMM { 3.6e-3f } // 0.0036 J/K/mm for 1.75mm PETG (0.0094 J/K/mm for 2.85mm PETG).
657+
658+
// Advanced options
659+
#define MPC_SMOOTHING_FACTOR 0.5f // (0.0...1.0) Noisy temperature sensors may need a lower value for stabilization.
660+
#define MPC_MIN_AMBIENT_CHANGE 1.0f // (K/s) Modeled ambient temperature rate of change, when correcting model inaccuracies.
661+
#define MPC_STEADYSTATE 0.5f // (K/s) Temperature change rate for steady state logic to be enforced.
662+
663+
#define MPC_TUNING_POS { X_CENTER, Y_CENTER, 1.0f } // (mm) M306 Autotuning position, ideally bed center at first layer height.
664+
#define MPC_TUNING_END_Z 10.0f // (mm) M306 Autotuning final Z position.
665+
#endif
622666

623667
//===========================================================================
624668
//====================== PID > Bed Temperature Control ======================

config/examples/ADIMLab/Gantry v2/Configuration.h

+48-4
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,12 @@
595595
//===========================================================================
596596
//============================= PID Settings ================================
597597
//===========================================================================
598-
// PID Tuning Guide here: https://reprap.org/wiki/PID_Tuning
599598

600-
// Comment the following line to disable PID and enable bang-bang.
601-
#define PIDTEMP
599+
// Enable PIDTEMP for PID control or MPCTEMP for Predictive Model.
600+
// temperature control. Disable both for bang-bang heating.
601+
#define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning
602+
//#define MPCTEMP // ** EXPERIMENTAL **
603+
602604
#define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current
603605
#define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
604606
#define PID_K1 0.95 // Smoothing factor within any PID loop
@@ -618,7 +620,49 @@
618620
#define DEFAULT_Ki 1.08
619621
#define DEFAULT_Kd 114.00
620622
#endif
621-
#endif // PIDTEMP
623+
#endif
624+
625+
/**
626+
* Model Predictive Control for hotend
627+
*
628+
* Use a physical model of the hotend to control temperature. When configured correctly
629+
* this gives better responsiveness and stability than PID and it also removes the need
630+
* for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model.
631+
*/
632+
#if ENABLED(MPCTEMP)
633+
//#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash)
634+
//#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash)
635+
636+
#define MPC_MAX BANG_MAX // (0..255) Current to nozzle while MPC is active.
637+
#define MPC_HEATER_POWER { 40.0f } // (W) Heat cartridge powers.
638+
639+
#define MPC_INCLUDE_FAN // Model the fan speed?
640+
641+
// Measured physical constants from M306
642+
#define MPC_BLOCK_HEAT_CAPACITY { 16.7f } // (J/K) Heat block heat capacities.
643+
#define MPC_SENSOR_RESPONSIVENESS { 0.22f } // (K/s per ∆K) Rate of change of sensor temperature from heat block.
644+
#define MPC_AMBIENT_XFER_COEFF { 0.068f } // (W/K) Heat transfer coefficients from heat block to room air with fan off.
645+
#if ENABLED(MPC_INCLUDE_FAN)
646+
#define MPC_AMBIENT_XFER_COEFF_FAN255 { 0.097f } // (W/K) Heat transfer coefficients from heat block to room air with fan on full.
647+
#endif
648+
649+
// For one fan and multiple hotends MPC needs to know how to apply the fan cooling effect.
650+
#if ENABLED(MPC_INCLUDE_FAN)
651+
//#define MPC_FAN_0_ALL_HOTENDS
652+
//#define MPC_FAN_0_ACTIVE_HOTEND
653+
#endif
654+
655+
#define FILAMENT_HEAT_CAPACITY_PERMM { 5.6e-3f } // 0.0056 J/K/mm for 1.75mm PLA (0.0149 J/K/mm for 2.85mm PLA).
656+
//#define FILAMENT_HEAT_CAPACITY_PERMM { 3.6e-3f } // 0.0036 J/K/mm for 1.75mm PETG (0.0094 J/K/mm for 2.85mm PETG).
657+
658+
// Advanced options
659+
#define MPC_SMOOTHING_FACTOR 0.5f // (0.0...1.0) Noisy temperature sensors may need a lower value for stabilization.
660+
#define MPC_MIN_AMBIENT_CHANGE 1.0f // (K/s) Modeled ambient temperature rate of change, when correcting model inaccuracies.
661+
#define MPC_STEADYSTATE 0.5f // (K/s) Temperature change rate for steady state logic to be enforced.
662+
663+
#define MPC_TUNING_POS { X_CENTER, Y_CENTER, 1.0f } // (mm) M306 Autotuning position, ideally bed center at first layer height.
664+
#define MPC_TUNING_END_Z 10.0f // (mm) M306 Autotuning final Z position.
665+
#endif
622666

623667
//===========================================================================
624668
//====================== PID > Bed Temperature Control ======================

config/examples/Alfawise/U20-bltouch/Configuration.h

+48-4
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,12 @@
650650
//===========================================================================
651651
//============================= PID Settings ================================
652652
//===========================================================================
653-
// PID Tuning Guide here: https://reprap.org/wiki/PID_Tuning
654653

655-
// Comment the following line to disable PID and enable bang-bang.
656-
#define PIDTEMP
654+
// Enable PIDTEMP for PID control or MPCTEMP for Predictive Model.
655+
// temperature control. Disable both for bang-bang heating.
656+
#define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning
657+
//#define MPCTEMP // ** EXPERIMENTAL **
658+
657659
#define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current
658660
#define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
659661
#define PID_K1 0.95 // Smoothing factor within any PID loop
@@ -677,7 +679,49 @@
677679
#define DEFAULT_Ki 1.00
678680
#define DEFAULT_Kd 74.22
679681
#endif
680-
#endif // PIDTEMP
682+
#endif
683+
684+
/**
685+
* Model Predictive Control for hotend
686+
*
687+
* Use a physical model of the hotend to control temperature. When configured correctly
688+
* this gives better responsiveness and stability than PID and it also removes the need
689+
* for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model.
690+
*/
691+
#if ENABLED(MPCTEMP)
692+
//#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash)
693+
//#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash)
694+
695+
#define MPC_MAX BANG_MAX // (0..255) Current to nozzle while MPC is active.
696+
#define MPC_HEATER_POWER { 40.0f } // (W) Heat cartridge powers.
697+
698+
#define MPC_INCLUDE_FAN // Model the fan speed?
699+
700+
// Measured physical constants from M306
701+
#define MPC_BLOCK_HEAT_CAPACITY { 16.7f } // (J/K) Heat block heat capacities.
702+
#define MPC_SENSOR_RESPONSIVENESS { 0.22f } // (K/s per ∆K) Rate of change of sensor temperature from heat block.
703+
#define MPC_AMBIENT_XFER_COEFF { 0.068f } // (W/K) Heat transfer coefficients from heat block to room air with fan off.
704+
#if ENABLED(MPC_INCLUDE_FAN)
705+
#define MPC_AMBIENT_XFER_COEFF_FAN255 { 0.097f } // (W/K) Heat transfer coefficients from heat block to room air with fan on full.
706+
#endif
707+
708+
// For one fan and multiple hotends MPC needs to know how to apply the fan cooling effect.
709+
#if ENABLED(MPC_INCLUDE_FAN)
710+
//#define MPC_FAN_0_ALL_HOTENDS
711+
//#define MPC_FAN_0_ACTIVE_HOTEND
712+
#endif
713+
714+
#define FILAMENT_HEAT_CAPACITY_PERMM { 5.6e-3f } // 0.0056 J/K/mm for 1.75mm PLA (0.0149 J/K/mm for 2.85mm PLA).
715+
//#define FILAMENT_HEAT_CAPACITY_PERMM { 3.6e-3f } // 0.0036 J/K/mm for 1.75mm PETG (0.0094 J/K/mm for 2.85mm PETG).
716+
717+
// Advanced options
718+
#define MPC_SMOOTHING_FACTOR 0.5f // (0.0...1.0) Noisy temperature sensors may need a lower value for stabilization.
719+
#define MPC_MIN_AMBIENT_CHANGE 1.0f // (K/s) Modeled ambient temperature rate of change, when correcting model inaccuracies.
720+
#define MPC_STEADYSTATE 0.5f // (K/s) Temperature change rate for steady state logic to be enforced.
721+
722+
#define MPC_TUNING_POS { X_CENTER, Y_CENTER, 1.0f } // (mm) M306 Autotuning position, ideally bed center at first layer height.
723+
#define MPC_TUNING_END_Z 10.0f // (mm) M306 Autotuning final Z position.
724+
#endif
681725

682726
//===========================================================================
683727
//====================== PID > Bed Temperature Control ======================

0 commit comments

Comments
 (0)