My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

temperature.h 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. temperature.h - temperature controller
  3. Part of Marlin
  4. Copyright (c) 2011 Erik van der Zalm
  5. Grbl is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. Grbl is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Grbl. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef temperature_h
  17. #define temperature_h
  18. #include "Marlin.h"
  19. #include "planner.h"
  20. #ifdef PID_ADD_EXTRUSION_RATE
  21. #include "stepper.h"
  22. #endif
  23. // public functions
  24. void tp_init(); //initialise the heating
  25. void manage_heater(); //it is critical that this is called periodically.
  26. //low leven conversion routines
  27. // do not use this routines and variables outsie of temperature.cpp
  28. extern int target_temperature[EXTRUDERS];
  29. extern float current_temperature[EXTRUDERS];
  30. extern int target_temperature_bed;
  31. extern float current_temperature_bed;
  32. #ifdef PIDTEMP
  33. extern float Kp,Ki,Kd,Kc;
  34. #endif
  35. #ifdef PIDTEMPBED
  36. extern float bedKp,bedKi,bedKd;
  37. #endif
  38. //high level conversion routines, for use outside of temperature.cpp
  39. //inline so that there is no performance decrease.
  40. //deg=degreeCelsius
  41. FORCE_INLINE float degHotend(uint8_t extruder) {
  42. return current_temperature[extruder];
  43. };
  44. FORCE_INLINE float degBed() {
  45. return current_temperature_bed;
  46. };
  47. FORCE_INLINE float degTargetHotend(uint8_t extruder) {
  48. return target_temperature[extruder];
  49. };
  50. FORCE_INLINE float degTargetBed() {
  51. return target_temperature_bed;
  52. };
  53. FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {
  54. target_temperature[extruder] = celsius;
  55. };
  56. FORCE_INLINE void setTargetBed(const float &celsius) {
  57. target_temperature_bed = celsius;
  58. };
  59. FORCE_INLINE bool isHeatingHotend(uint8_t extruder){
  60. return target_temperature[extruder] > current_temperature[extruder];
  61. };
  62. FORCE_INLINE bool isHeatingBed() {
  63. return target_temperature_bed > current_temperature_bed;
  64. };
  65. FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {
  66. return target_temperature[extruder] < current_temperature[extruder];
  67. };
  68. FORCE_INLINE bool isCoolingBed() {
  69. return target_temperature_bed < current_temperature_bed;
  70. };
  71. #define degHotend0() degHotend(0)
  72. #define degTargetHotend0() degTargetHotend(0)
  73. #define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
  74. #define isHeatingHotend0() isHeatingHotend(0)
  75. #define isCoolingHotend0() isCoolingHotend(0)
  76. #if EXTRUDERS > 1
  77. #define degHotend1() degHotend(1)
  78. #define degTargetHotend1() degTargetHotend(1)
  79. #define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
  80. #define isHeatingHotend1() isHeatingHotend(1)
  81. #define isCoolingHotend1() isCoolingHotend(1)
  82. #else
  83. #define setTargetHotend1(_celsius) do{}while(0)
  84. #endif
  85. #if EXTRUDERS > 2
  86. #define degHotend2() degHotend(2)
  87. #define degTargetHotend2() degTargetHotend(2)
  88. #define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
  89. #define isHeatingHotend2() isHeatingHotend(2)
  90. #define isCoolingHotend2() isCoolingHotend(2)
  91. #else
  92. #define setTargetHotend2(_celsius) do{}while(0)
  93. #endif
  94. #if EXTRUDERS > 3
  95. #error Invalid number of extruders
  96. #endif
  97. int getHeaterPower(int heater);
  98. void disable_heater();
  99. void setWatch();
  100. void updatePID();
  101. FORCE_INLINE void autotempShutdown(){
  102. #ifdef AUTOTEMP
  103. if(autotemp_enabled)
  104. {
  105. autotemp_enabled=false;
  106. if(degTargetHotend(active_extruder)>autotemp_min)
  107. setTargetHotend(0,active_extruder);
  108. }
  109. #endif
  110. }
  111. void PID_autotune(float temp, int extruder, int ncycles);
  112. #endif