heater.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. Reprap heater funtions based on Sprinter
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /*
  14. This softwarepart for Heatercontrol is based on Sprinter
  15. big thanks to kliment (https://github.com/kliment/Sprinter)
  16. */
  17. #include "Configuration.h"
  18. #include "thermistortables.h"
  19. #if defined HEATER_USES_THERMISTOR
  20. #define temp2analogh( c ) temp2analog_thermistor(c,temptable,NUMTEMPS)
  21. #define analog2temp( c ) analog2temp_thermistor(c,temptable,NUMTEMPS)
  22. #elif defined HEATER_USES_AD595
  23. #define temp2analogh( c ) temp2analog_ad595(c)
  24. #define analog2temp( c ) analog2temp_ad595(c)
  25. #elif defined HEATER_USES_MAX6675
  26. #define temp2analogh( c ) temp2analog_max6675(c)
  27. #define analog2temp( c ) analog2temp_max6675(c)
  28. #endif
  29. #if defined BED_USES_THERMISTOR
  30. #define temp2analogBed( c ) temp2analog_thermistor((c),bedtemptable,BNUMTEMPS)
  31. #define analog2tempBed( c ) analog2temp_thermistor((c),bedtemptable,BNUMTEMPS)
  32. #elif defined BED_USES_AD595
  33. #define temp2analogBed( c ) temp2analog_ad595(c)
  34. #define analog2tempBed( c ) analog2temp_ad595(c)
  35. #elif defined BED_USES_MAX6675
  36. #define temp2analogBed( c ) temp2analog_max6675(c)
  37. #define analog2tempBed( c ) analog2temp_max6675(c)
  38. #endif
  39. #if defined (HEATER_USES_THERMISTOR) || defined (BED_USES_THERMISTOR)
  40. int temp2analog_thermistor(int celsius, const short table[][2], int numtemps);
  41. int analog2temp_thermistor(int raw,const short table[][2], int numtemps);
  42. #endif
  43. #if defined (HEATER_USES_AD595) || defined (BED_USES_AD595)
  44. int temp2analog_ad595(int celsius);
  45. int analog2temp_ad595(int raw);
  46. #endif
  47. #if defined (HEATER_USES_MAX6675) || defined (BED_USES_MAX6675)
  48. int temp2analog_max6675(int celsius);
  49. int analog2temp_max6675(int raw);
  50. #endif
  51. extern int target_raw;
  52. extern int target_temp;
  53. extern int current_raw;
  54. extern int current_raw_maxval;
  55. extern int current_raw_minval;
  56. extern int tt_maxval;
  57. extern int tt_minval;
  58. extern int target_bed_raw;
  59. extern int current_bed_raw;
  60. extern unsigned long previous_millis_heater, previous_millis_bed_heater;
  61. extern unsigned char manage_monitor;
  62. #ifdef PIDTEMP
  63. extern volatile unsigned char g_heater_pwm_val;
  64. extern unsigned char PWM_off_time;
  65. extern unsigned char PWM_out_on;
  66. extern int temp_iState;
  67. extern int temp_dState;
  68. extern int prev_temp;
  69. extern int pTerm;
  70. extern int iTerm;
  71. extern int dTerm;
  72. extern int error;
  73. extern int heater_duty;
  74. #endif
  75. #ifdef AUTOTEMP
  76. extern float autotemp_max;
  77. extern float autotemp_min;
  78. extern float autotemp_factor;
  79. extern int autotemp_setpoint;
  80. extern bool autotemp_enabled;
  81. #endif
  82. #ifdef SMOOTHING
  83. extern uint32_t nma;
  84. #endif
  85. #ifdef WATCHPERIOD
  86. extern int watch_raw;
  87. extern unsigned long watchmillis;
  88. #endif
  89. #ifdef PID_SOFT_PWM
  90. void init_Timer2_softpwm(void);
  91. #endif
  92. void manage_heater();