2016-03-25 07:19:46 +01:00
|
|
|
/**
|
2016-03-24 19:01:20 +01:00
|
|
|
* Marlin 3D Printer Firmware
|
|
|
|
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-25 07:19:46 +01:00
|
|
|
/**
|
2016-04-29 03:18:13 +02:00
|
|
|
* temperature.h - temperature controller
|
|
|
|
*/
|
2012-03-08 21:43:21 +01:00
|
|
|
|
2015-04-02 14:10:14 +02:00
|
|
|
#ifndef TEMPERATURE_H
|
2015-10-03 08:08:58 +02:00
|
|
|
#define TEMPERATURE_H
|
2012-03-08 21:43:21 +01:00
|
|
|
|
|
|
|
#include "Marlin.h"
|
|
|
|
#include "planner.h"
|
2016-04-29 03:18:13 +02:00
|
|
|
|
2015-07-31 07:29:30 +02:00
|
|
|
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
2012-03-08 21:43:21 +01:00
|
|
|
#include "stepper.h"
|
|
|
|
#endif
|
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#ifndef SOFT_PWM_SCALE
|
|
|
|
#define SOFT_PWM_SCALE 0
|
|
|
|
#endif
|
2012-03-08 21:43:21 +01:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
class Temperature {
|
2015-10-03 08:08:58 +02:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
public:
|
2014-08-07 02:30:57 +02:00
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
static int current_temperature_raw[HOTENDS];
|
|
|
|
static float current_temperature[HOTENDS];
|
|
|
|
static int target_temperature[HOTENDS];
|
2012-03-08 21:43:21 +01:00
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static int current_temperature_bed_raw;
|
|
|
|
static float current_temperature_bed;
|
|
|
|
static int target_temperature_bed;
|
2013-11-28 02:23:06 +01:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
2016-05-26 20:58:38 +02:00
|
|
|
static float redundant_temperature;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
2016-04-28 03:06:32 +02:00
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static unsigned char soft_pwm_bed;
|
2015-01-11 03:50:17 +01:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(FAN_SOFT_PWM)
|
2016-05-26 20:58:38 +02:00
|
|
|
static unsigned char fanSpeedSoftPwm[FAN_COUNT];
|
2016-04-17 04:19:40 +02:00
|
|
|
#endif
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED)
|
|
|
|
#define PID_dT ((OVERSAMPLENR * 12.0)/(F_CPU / 64.0 / 256.0))
|
2016-04-17 04:19:40 +02:00
|
|
|
#endif
|
Allow Edit menu to call fn after edit; Fix PID Ki and Kd display in menus; Actually use changed PID and Max Accel values
Add new 'callback' edit-menu types that call a function after the edit is done. Use this to display and edit Ki and Kd correctly (removing the scaling first and reapplying it after). Also use it to reset maximum stepwise acceleration rates, after updating mm/s^2 rates via menus. (Previously, changes did nothing to affect planner unless saved back to EEPROM, and the machine reset).
Add calls to updatePID() so that PID loop uses updated values whether set by gcode (it already did this), or by restoring defaults, or loading from EEPROM (it didn't do those last two). Similarly, update the maximum step/s^2 accel rates when the mm/s^2 values are changed - whether by menu edits, restore defaults, or EEPROM read.
Refactor the acceleration rate update logic, and the PID scaling logic, into new functions that can be called from wherever, including the callbacks.
Add menu items to allow the z jerk and e jerk to be viewed/edited in the Control->Motion menu, as per xy jerk.
Conflicts:
Marlin/language.h
2013-03-19 15:05:11 +01:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(PIDTEMP)
|
2015-04-04 01:38:05 +02:00
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
#if ENABLED(PID_PARAMS_PER_HOTEND)
|
2015-10-03 08:08:58 +02:00
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
static float Kp[HOTENDS], Ki[HOTENDS], Kd[HOTENDS];
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
2016-05-27 02:43:20 +02:00
|
|
|
static float Kc[HOTENDS];
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
#define PID_PARAM(param, e) Temperature::param[e]
|
2015-10-03 08:08:58 +02:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#else
|
2012-03-08 21:43:21 +01:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
static float Kp, Ki, Kd;
|
|
|
|
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
|
|
|
static float Kc;
|
|
|
|
#endif
|
|
|
|
#define PID_PARAM(param, e) Temperature::param
|
2012-03-08 21:43:21 +01:00
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
#endif // PID_PARAMS_PER_HOTEND
|
2013-10-12 15:41:23 +02:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
// Apply the scale factors to the PID values
|
|
|
|
#define scalePID_i(i) ( (i) * PID_dT )
|
|
|
|
#define unscalePID_i(i) ( (i) / PID_dT )
|
|
|
|
#define scalePID_d(d) ( (d) / PID_dT )
|
|
|
|
#define unscalePID_d(d) ( (d) * PID_dT )
|
2012-03-08 21:43:21 +01:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
2015-05-21 21:07:37 +02:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(PIDTEMPBED)
|
2016-05-26 20:58:38 +02:00
|
|
|
static float bedKp, bedKi, bedKd;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
2016-04-15 18:27:18 +02:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(BABYSTEPPING)
|
2016-05-26 20:58:38 +02:00
|
|
|
static volatile int babystepsTodo[3];
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
2012-03-08 21:43:21 +01:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
|
2016-05-27 02:43:20 +02:00
|
|
|
static int watch_target_temp[HOTENDS];
|
|
|
|
static millis_t watch_heater_next_ms[HOTENDS];
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
2012-03-08 21:43:21 +01:00
|
|
|
|
2016-06-21 11:13:41 +02:00
|
|
|
#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
|
2016-05-26 20:58:38 +02:00
|
|
|
static int watch_target_bed_temp;
|
|
|
|
static millis_t watch_bed_next_ms;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
|
2016-05-26 20:58:38 +02:00
|
|
|
static float extrude_min_temp;
|
2016-05-31 02:06:50 +02:00
|
|
|
static bool tooColdToExtrude(uint8_t e) { return degHotend(e) < extrude_min_temp; }
|
2016-04-29 03:18:13 +02:00
|
|
|
#else
|
2016-05-31 02:06:50 +02:00
|
|
|
static bool tooColdToExtrude(uint8_t e) { UNUSED(e); return false; }
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
2016-05-26 20:58:38 +02:00
|
|
|
static int redundant_temperature_raw;
|
|
|
|
static float redundant_temperature;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static volatile bool temp_meas_ready;
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(PIDTEMP)
|
2016-05-27 02:43:20 +02:00
|
|
|
static float temp_iState[HOTENDS];
|
|
|
|
static float temp_dState[HOTENDS];
|
|
|
|
static float pTerm[HOTENDS];
|
|
|
|
static float iTerm[HOTENDS];
|
|
|
|
static float dTerm[HOTENDS];
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
2016-05-27 02:43:20 +02:00
|
|
|
static float cTerm[HOTENDS];
|
|
|
|
static long last_position[HOTENDS];
|
2016-05-26 20:58:38 +02:00
|
|
|
static long lpq[LPQ_MAX_LEN];
|
|
|
|
static int lpq_ptr;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
static float pid_error[HOTENDS];
|
|
|
|
static float temp_iState_min[HOTENDS];
|
|
|
|
static float temp_iState_max[HOTENDS];
|
|
|
|
static bool pid_reset[HOTENDS];
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(PIDTEMPBED)
|
2016-05-26 20:58:38 +02:00
|
|
|
static float temp_iState_bed;
|
|
|
|
static float temp_dState_bed;
|
|
|
|
static float pTerm_bed;
|
|
|
|
static float iTerm_bed;
|
|
|
|
static float dTerm_bed;
|
|
|
|
static float pid_error_bed;
|
|
|
|
static float temp_iState_min_bed;
|
|
|
|
static float temp_iState_max_bed;
|
2016-04-29 03:18:13 +02:00
|
|
|
#else
|
2016-05-26 20:58:38 +02:00
|
|
|
static millis_t next_bed_check_ms;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
2015-03-30 01:58:46 +02:00
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static unsigned long raw_temp_value[4];
|
|
|
|
static unsigned long raw_temp_bed_value;
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
// Init min and max temp with extreme values to prevent false errors during startup
|
2016-05-27 02:43:20 +02:00
|
|
|
static int minttemp_raw[HOTENDS];
|
|
|
|
static int maxttemp_raw[HOTENDS];
|
|
|
|
static int minttemp[HOTENDS];
|
|
|
|
static int maxttemp[HOTENDS];
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#ifdef BED_MINTEMP
|
2016-05-26 20:58:38 +02:00
|
|
|
static int bed_minttemp_raw;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BED_MAXTEMP
|
2016-05-26 20:58:38 +02:00
|
|
|
static int bed_maxttemp_raw;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
2016-05-26 20:58:38 +02:00
|
|
|
static int meas_shift_index; // Index of a delayed sample in buffer
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_AUTO_FAN
|
2016-05-26 20:58:38 +02:00
|
|
|
static millis_t next_auto_fan_check_ms;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
static unsigned char soft_pwm[HOTENDS];
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(FAN_SOFT_PWM)
|
2016-05-26 20:58:38 +02:00
|
|
|
static unsigned char soft_pwm_fan[FAN_COUNT];
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
2014-06-30 20:22:37 +02:00
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
2016-05-26 20:58:38 +02:00
|
|
|
static int current_raw_filwidth; //Holds measured filament diameter - one extruder only
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instance Methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
Temperature();
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
/**
|
|
|
|
* Static (class) methods
|
|
|
|
*/
|
|
|
|
static float analog2temp(int raw, uint8_t e);
|
|
|
|
static float analog2tempBed(int raw);
|
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
/**
|
|
|
|
* Called from the Temperature ISR
|
|
|
|
*/
|
2016-05-26 20:58:38 +02:00
|
|
|
static void isr();
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Call periodically to manage heaters
|
|
|
|
*/
|
2016-05-26 20:58:38 +02:00
|
|
|
static void manage_heater();
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
2016-05-26 20:58:38 +02:00
|
|
|
static float analog2widthFil(); // Convert raw Filament Width to millimeters
|
|
|
|
static int widthFil_to_size_ratio(); // Convert raw Filament Width to an extrusion ratio
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//high level conversion routines, for use outside of temperature.cpp
|
|
|
|
//inline so that there is no performance decrease.
|
|
|
|
//deg=degreeCelsius
|
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
#if HOTENDS == 1
|
|
|
|
#define HOTEND_ARG 0
|
|
|
|
#else
|
|
|
|
#define HOTEND_ARG hotend
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static float degHotend(uint8_t hotend) {
|
|
|
|
#if HOTENDS == 1
|
|
|
|
UNUSED(hotend);
|
|
|
|
#endif
|
|
|
|
return current_temperature[HOTEND_ARG];
|
|
|
|
}
|
2016-05-31 02:06:50 +02:00
|
|
|
static float degBed() { return current_temperature_bed; }
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
2016-05-27 02:43:20 +02:00
|
|
|
static float rawHotendTemp(uint8_t hotend) {
|
|
|
|
#if HOTENDS == 1
|
|
|
|
UNUSED(hotend);
|
|
|
|
#endif
|
|
|
|
return current_temperature_raw[HOTEND_ARG];
|
|
|
|
}
|
2016-05-31 02:06:50 +02:00
|
|
|
static float rawBedTemp() { return current_temperature_bed_raw; }
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
static float degTargetHotend(uint8_t hotend) {
|
|
|
|
#if HOTENDS == 1
|
|
|
|
UNUSED(hotend);
|
|
|
|
#endif
|
|
|
|
return target_temperature[HOTEND_ARG];
|
|
|
|
}
|
2016-05-31 02:06:50 +02:00
|
|
|
static float degTargetBed() { return target_temperature_bed; }
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
|
2016-05-26 20:58:38 +02:00
|
|
|
static void start_watching_heater(int e = 0);
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
|
2016-05-26 20:58:38 +02:00
|
|
|
static void start_watching_bed();
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
static void setTargetHotend(const float& celsius, uint8_t hotend) {
|
|
|
|
#if HOTENDS == 1
|
|
|
|
UNUSED(hotend);
|
|
|
|
#endif
|
|
|
|
target_temperature[HOTEND_ARG] = celsius;
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
|
2016-05-27 02:43:20 +02:00
|
|
|
start_watching_heater(HOTEND_ARG);
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-05-31 02:06:50 +02:00
|
|
|
static void setTargetBed(const float& celsius) {
|
2016-04-29 03:18:13 +02:00
|
|
|
target_temperature_bed = celsius;
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
|
|
|
|
start_watching_bed();
|
|
|
|
#endif
|
2015-02-24 13:46:11 +01:00
|
|
|
}
|
2016-04-29 03:18:13 +02:00
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
static bool isHeatingHotend(uint8_t hotend) {
|
|
|
|
#if HOTENDS == 1
|
|
|
|
UNUSED(hotend);
|
|
|
|
#endif
|
|
|
|
return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG];
|
|
|
|
}
|
2016-05-31 02:06:50 +02:00
|
|
|
static bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
|
2016-04-29 03:18:13 +02:00
|
|
|
|
2016-05-27 02:43:20 +02:00
|
|
|
static bool isCoolingHotend(uint8_t hotend) {
|
|
|
|
#if HOTENDS == 1
|
|
|
|
UNUSED(hotend);
|
|
|
|
#endif
|
|
|
|
return target_temperature[HOTEND_ARG] < current_temperature[HOTEND_ARG];
|
|
|
|
}
|
2016-05-31 02:06:50 +02:00
|
|
|
static bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The software PWM power for a heater
|
|
|
|
*/
|
2016-05-26 20:58:38 +02:00
|
|
|
static int getHeaterPower(int heater);
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Switch off all heaters, set all target temperatures to 0
|
|
|
|
*/
|
2016-05-26 20:58:38 +02:00
|
|
|
static void disable_all_heaters();
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform auto-tuning for hotend or bed in response to M303
|
|
|
|
*/
|
|
|
|
#if HAS_PID_HEATING
|
2016-05-27 02:43:20 +02:00
|
|
|
static void PID_autotune(float temp, int hotend, int ncycles, bool set_result=false);
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the temp manager when PID values change
|
|
|
|
*/
|
2016-05-26 20:58:38 +02:00
|
|
|
static void updatePID();
|
2016-04-29 03:18:13 +02:00
|
|
|
|
2016-05-31 02:06:50 +02:00
|
|
|
static void autotempShutdown() {
|
2016-04-29 03:18:13 +02:00
|
|
|
#if ENABLED(AUTOTEMP)
|
|
|
|
if (planner.autotemp_enabled) {
|
|
|
|
planner.autotemp_enabled = false;
|
|
|
|
if (degTargetHotend(active_extruder) > planner.autotemp_min)
|
|
|
|
setTargetHotend(0, active_extruder);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-05-05 23:57:24 +02:00
|
|
|
#if ENABLED(BABYSTEPPING)
|
|
|
|
|
2016-05-31 02:06:50 +02:00
|
|
|
static void babystep_axis(AxisEnum axis, int distance) {
|
2016-05-20 22:27:49 +02:00
|
|
|
#if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
|
2016-05-05 23:57:24 +02:00
|
|
|
#if ENABLED(BABYSTEP_XY)
|
|
|
|
switch (axis) {
|
2016-05-20 22:27:49 +02:00
|
|
|
case CORE_AXIS_1: // X on CoreXY and CoreXZ, Y on CoreYZ
|
|
|
|
babystepsTodo[CORE_AXIS_1] += distance * 2;
|
2016-05-05 23:57:24 +02:00
|
|
|
babystepsTodo[CORE_AXIS_2] += distance * 2;
|
|
|
|
break;
|
2016-05-20 22:27:49 +02:00
|
|
|
case CORE_AXIS_2: // Y on CoreXY, Z on CoreXZ and CoreYZ
|
|
|
|
babystepsTodo[CORE_AXIS_1] += distance * 2;
|
2016-05-05 23:57:24 +02:00
|
|
|
babystepsTodo[CORE_AXIS_2] -= distance * 2;
|
|
|
|
break;
|
2016-05-20 22:32:30 +02:00
|
|
|
case NORMAL_AXIS: // Z on CoreXY, Y on CoreXZ, X on CoreYZ
|
|
|
|
babystepsTodo[NORMAL_AXIS] += distance;
|
2016-05-05 23:57:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-05-20 22:27:49 +02:00
|
|
|
#elif ENABLED(COREXZ) || ENABLED(COREYZ)
|
|
|
|
// Only Z stepping needs to be handled here
|
|
|
|
babystepsTodo[CORE_AXIS_1] += distance * 2;
|
|
|
|
babystepsTodo[CORE_AXIS_2] -= distance * 2;
|
2016-05-05 23:57:24 +02:00
|
|
|
#else
|
|
|
|
babystepsTodo[Z_AXIS] += distance;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
babystepsTodo[axis] += distance;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // BABYSTEPPING
|
|
|
|
|
2016-04-29 03:18:13 +02:00
|
|
|
private:
|
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static void set_current_temp_raw();
|
2016-04-29 03:18:13 +02:00
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static void updateTemperaturesFromRawValues();
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(HEATER_0_USES_MAX6675)
|
2016-05-26 20:58:38 +02:00
|
|
|
static int read_max6675();
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static void checkExtruderAutoFans();
|
2016-04-29 03:18:13 +02:00
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static float get_pid_output(int e);
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(PIDTEMPBED)
|
2016-05-26 20:58:38 +02:00
|
|
|
static float get_pid_output_bed();
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static void _temp_error(int e, const char* serial_msg, const char* lcd_msg);
|
|
|
|
static void min_temp_error(uint8_t e);
|
|
|
|
static void max_temp_error(uint8_t e);
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
|
|
|
|
|
2016-05-09 02:01:46 +02:00
|
|
|
typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
|
2016-04-29 03:18:13 +02:00
|
|
|
|
2016-05-26 20:58:38 +02:00
|
|
|
static void thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
|
2016-04-29 03:18:13 +02:00
|
|
|
|
|
|
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
2016-05-27 02:43:20 +02:00
|
|
|
static TRState thermal_runaway_state_machine[HOTENDS];
|
|
|
|
static millis_t thermal_runaway_timer[HOTENDS];
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_THERMALLY_PROTECTED_BED
|
2016-05-26 20:58:38 +02:00
|
|
|
static TRState thermal_runaway_bed_state_machine;
|
|
|
|
static millis_t thermal_runaway_bed_timer;
|
2016-04-29 03:18:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // THERMAL_PROTECTION
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
extern Temperature thermalManager;
|
2012-03-08 21:43:21 +01:00
|
|
|
|
2015-04-02 14:10:14 +02:00
|
|
|
#endif // TEMPERATURE_H
|