My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

temperature.h 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. temperature.h - temperature controller
  24. Part of Marlin
  25. Copyright (c) 2011 Erik van der Zalm
  26. Grbl is free software: you can redistribute it and/or modify
  27. it under the terms of the GNU General Public License as published by
  28. the Free Software Foundation, either version 3 of the License, or
  29. (at your option) any later version.
  30. Grbl is distributed in the hope that it will be useful,
  31. but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. GNU General Public License for more details.
  34. You should have received a copy of the GNU General Public License
  35. along with Grbl. If not, see <http://www.gnu.org/licenses/>.
  36. */
  37. #ifndef TEMPERATURE_H
  38. #define TEMPERATURE_H
  39. #include "Marlin.h"
  40. #include "planner.h"
  41. #if ENABLED(PID_ADD_EXTRUSION_RATE)
  42. #include "stepper.h"
  43. #endif
  44. // public functions
  45. void tp_init(); //initialize the heating
  46. void manage_heater(); //it is critical that this is called periodically.
  47. #if ENABLED(FILAMENT_WIDTH_SENSOR)
  48. // For converting raw Filament Width to milimeters
  49. float analog2widthFil();
  50. // For converting raw Filament Width to an extrusion ratio
  51. int widthFil_to_size_ratio();
  52. #endif
  53. // low level conversion routines
  54. // do not use these routines and variables outside of temperature.cpp
  55. extern int target_temperature[4];
  56. extern float current_temperature[4];
  57. #if ENABLED(SHOW_TEMP_ADC_VALUES)
  58. extern int current_temperature_raw[4];
  59. extern int current_temperature_bed_raw;
  60. #endif
  61. extern int target_temperature_bed;
  62. extern float current_temperature_bed;
  63. #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
  64. extern float redundant_temperature;
  65. #endif
  66. #if HAS_CONTROLLERFAN
  67. extern unsigned char soft_pwm_bed;
  68. #endif
  69. #if ENABLED(PIDTEMP)
  70. #if ENABLED(PID_PARAMS_PER_EXTRUDER)
  71. extern float Kp[EXTRUDERS], Ki[EXTRUDERS], Kd[EXTRUDERS], Kc[EXTRUDERS]; // one param per extruder
  72. #define PID_PARAM(param, e) param[e] // use macro to point to array value
  73. #else
  74. extern float Kp, Ki, Kd, Kc; // one param per extruder - saves 20 or 36 bytes of ram (inc array pointer)
  75. #define PID_PARAM(param, e) param // use macro to point directly to value
  76. #endif // PID_PARAMS_PER_EXTRUDER
  77. float scalePID_i(float i);
  78. float scalePID_d(float d);
  79. float unscalePID_i(float i);
  80. float unscalePID_d(float d);
  81. #endif
  82. #if ENABLED(PIDTEMPBED)
  83. extern float bedKp, bedKi, bedKd;
  84. #endif
  85. #if ENABLED(BABYSTEPPING)
  86. extern volatile int babystepsTodo[3];
  87. #endif
  88. //high level conversion routines, for use outside of temperature.cpp
  89. //inline so that there is no performance decrease.
  90. //deg=degreeCelsius
  91. FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }
  92. FORCE_INLINE float degBed() { return current_temperature_bed; }
  93. #if ENABLED(SHOW_TEMP_ADC_VALUES)
  94. FORCE_INLINE float rawHotendTemp(uint8_t extruder) { return current_temperature_raw[extruder]; }
  95. FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }
  96. #endif
  97. FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }
  98. FORCE_INLINE float degTargetBed() { return target_temperature_bed; }
  99. #if ENABLED(THERMAL_PROTECTION_HOTENDS)
  100. void start_watching_heater(int e = 0);
  101. #endif
  102. FORCE_INLINE void setTargetHotend(const float& celsius, uint8_t extruder) {
  103. target_temperature[extruder] = celsius;
  104. #if ENABLED(THERMAL_PROTECTION_HOTENDS)
  105. start_watching_heater(extruder);
  106. #endif
  107. }
  108. FORCE_INLINE void setTargetBed(const float& celsius) { target_temperature_bed = celsius; }
  109. FORCE_INLINE bool isHeatingHotend(uint8_t extruder) { return target_temperature[extruder] > current_temperature[extruder]; }
  110. FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
  111. FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { return target_temperature[extruder] < current_temperature[extruder]; }
  112. FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
  113. #define HOTEND_ROUTINES(NR) \
  114. FORCE_INLINE float degHotend##NR() { return degHotend(NR); } \
  115. FORCE_INLINE float degTargetHotend##NR() { return degTargetHotend(NR); } \
  116. FORCE_INLINE void setTargetHotend##NR(const float c) { setTargetHotend(c, NR); } \
  117. FORCE_INLINE bool isHeatingHotend##NR() { return isHeatingHotend(NR); } \
  118. FORCE_INLINE bool isCoolingHotend##NR() { return isCoolingHotend(NR); }
  119. HOTEND_ROUTINES(0);
  120. #if EXTRUDERS > 1
  121. HOTEND_ROUTINES(1);
  122. #else
  123. #define setTargetHotend1(c) do{}while(0)
  124. #endif
  125. #if EXTRUDERS > 2
  126. HOTEND_ROUTINES(2);
  127. #else
  128. #define setTargetHotend2(c) do{}while(0)
  129. #endif
  130. #if EXTRUDERS > 3
  131. HOTEND_ROUTINES(3);
  132. #else
  133. #define setTargetHotend3(c) do{}while(0)
  134. #endif
  135. int getHeaterPower(int heater);
  136. void disable_all_heaters();
  137. void updatePID();
  138. void PID_autotune(float temp, int extruder, int ncycles, bool set_result=false);
  139. void setExtruderAutoFanState(int pin, bool state);
  140. void checkExtruderAutoFans();
  141. FORCE_INLINE void autotempShutdown() {
  142. #if ENABLED(AUTOTEMP)
  143. if (autotemp_enabled) {
  144. autotemp_enabled = false;
  145. if (degTargetHotend(active_extruder) > autotemp_min)
  146. setTargetHotend(0, active_extruder);
  147. }
  148. #endif
  149. }
  150. #endif // TEMPERATURE_H