Commit a6879c86 authored by MagoKimbra's avatar MagoKimbra

Update Temperature.cpp

parent 03bb009c
...@@ -18,40 +18,40 @@ ...@@ -18,40 +18,40 @@
#define MSG_BED_SETTING "Bed Setting" #define MSG_BED_SETTING "Bed Setting"
#define MSG_SET_HOME_OFFSETS "Set home offsets" #define MSG_SET_HOME_OFFSETS "Set home offsets"
#define MSG_SET_ORIGIN "Aseta origo" #define MSG_SET_ORIGIN "Aseta origo"
#define MSG_PREHEAT_PLA "Esilammita PLA" #define MSG_PREHEAT_PLA "Esil" STR_ae "mmit" STR_ae " PLA"
#define MSG_PREHEAT_PLA_ALL "Esila. PLA Kaikki" #define MSG_PREHEAT_PLA_ALL "Esil" STR_ae ". PLA Kaikki"
#define MSG_PREHEAT_PLA_BEDONLY "Esila. PLA Alusta" #define MSG_PREHEAT_PLA_BEDONLY "Esil" STR_ae ". PLA Alusta"
#define MSG_PREHEAT_PLA_SETTINGS "Esilamm. PLA konf" #define MSG_PREHEAT_PLA_SETTINGS "Esil" STR_ae "mm. PLA konf"
#define MSG_PREHEAT_ABS "Esilammita ABS" #define MSG_PREHEAT_ABS "Esil" STR_ae "mmit" STR_ae " ABS"
#define MSG_PREHEAT_ABS_ALL "Esila. ABS Kaikki" #define MSG_PREHEAT_ABS_ALL "Esil" STR_ae ". ABS Kaikki"
#define MSG_PREHEAT_ABS_BEDONLY "Esila. ABS Alusta" #define MSG_PREHEAT_ABS_BEDONLY "Esil" STR_ae ". ABS Alusta"
#define MSG_PREHEAT_ABS_SETTINGS "Esilamm. ABS konf" #define MSG_PREHEAT_ABS_SETTINGS "Esil" STR_ae "mm. ABS konf"
#define MSG_PREHEAT_GUM "Preheat GUM" #define MSG_PREHEAT_GUM "Esil" STR_ae "mmit" STR_ae " GUM"
#define MSG_PREHEAT_GUM_ALL "Preheat GUM All" #define MSG_PREHEAT_GUM_ALL "Esil" STR_ae ". GUM Kaikki"
#define MSG_PREHEAT_GUM_BEDONLY "Preheat GUM Bed" #define MSG_PREHEAT_GUM_BEDONLY "Esil" STR_ae ". GUM Alusta"
#define MSG_PREHEAT_GUM_SETTINGS "Preheat GUM conf" #define MSG_PREHEAT_GUM_SETTINGS "Esil" STR_ae "mm. GUM konf"
#define MSG_COOLDOWN "Jaahdyta" #define MSG_COOLDOWN "J" STR_ae "" STR_ae "hdyt" STR_ae ""
#define MSG_SWITCH_PS_ON "Virta paalle" #define MSG_SWITCH_PS_ON "Virta p" STR_ae "" STR_ae "lle"
#define MSG_SWITCH_PS_OFF "Virta pois" #define MSG_SWITCH_PS_OFF "Virta pois"
#define MSG_EXTRUDE "Pursota" #define MSG_EXTRUDE "Pursota"
#define MSG_RETRACT "Veda takaisin" #define MSG_RETRACT "Ved" STR_ae " takaisin"
#define MSG_MOVE_AXIS "Liikuta akseleita" #define MSG_MOVE_AXIS "Liikuta akseleita"
#define MSG_MOVE_X "Move X" #define MSG_MOVE_X "Liikuta X"
#define MSG_MOVE_Y "Move Y" #define MSG_MOVE_Y "Liikuta Y"
#define MSG_MOVE_Z "Move Z" #define MSG_MOVE_Z "Liikuta Z"
#define MSG_MOVE_E "Extruder" #define MSG_MOVE_E "Extruder"
#define MSG_MOVE_01MM "Move 0.1mm" #define MSG_MOVE_01MM "Liikuta 0.1mm"
#define MSG_MOVE_1MM "Move 1mm" #define MSG_MOVE_1MM "Liikuta 1mm"
#define MSG_MOVE_10MM "Move 10mm" #define MSG_MOVE_10MM "Liikuta 10mm"
#define MSG_SPEED "Nopeus" #define MSG_SPEED "Nopeus"
#define MSG_NOZZLE "Suutin" #define MSG_NOZZLE "Suutin"
#define MSG_BED "Alusta" #define MSG_BED "Alusta"
#define MSG_FAN_SPEED "Tuul. nopeus" #define MSG_FAN_SPEED "Tuul. nopeus"
#define MSG_FLOW "Virtaus" #define MSG_FLOW "Virtaus"
#define MSG_CONTROL "Kontrolli" #define MSG_CONTROL "Kontrolli"
#define MSG_MIN " " STR_THERMOMETER " Min" #define MSG_MIN STR_THERMOMETER " Min"
#define MSG_MAX " " STR_THERMOMETER " Max" #define MSG_MAX STR_THERMOMETER " Max"
#define MSG_FACTOR " " STR_THERMOMETER " Fact" #define MSG_FACTOR STR_THERMOMETER " Kerr"
#define MSG_AUTOTEMP "Autotemp" #define MSG_AUTOTEMP "Autotemp"
#define MSG_ON "On " #define MSG_ON "On "
#define MSG_OFF "Off" #define MSG_OFF "Off"
...@@ -78,22 +78,22 @@ ...@@ -78,22 +78,22 @@
#define MSG_E1STEPS "E1 steps/mm" #define MSG_E1STEPS "E1 steps/mm"
#define MSG_E2STEPS "E2 steps/mm" #define MSG_E2STEPS "E2 steps/mm"
#define MSG_E3STEPS "E3 steps/mm" #define MSG_E3STEPS "E3 steps/mm"
#define MSG_TEMPERATURE "Lampotila" #define MSG_TEMPERATURE "L" STR_ae "mp" STR_oe "tila"
#define MSG_MOTION "Liike" #define MSG_MOTION "Liike"
#define MSG_VOLUMETRIC "Filament" #define MSG_VOLUMETRIC "Filament"
#define MSG_VOLUMETRIC_ENABLED "E in mm" STR_h3 #define MSG_VOLUMETRIC_ENABLED "E in mm" STR_h3
#define MSG_FILAMENT_SIZE_EXTRUDER "Fil. Dia." #define MSG_FILAMENT_SIZE_EXTRUDER "Fil. Dia."
#define MSG_CONTRAST "LCD contrast" #define MSG_CONTRAST "LCD kontrasti"
#define MSG_STORE_EPROM "Tallenna muistiin" #define MSG_STORE_EPROM "Tallenna muistiin"
#define MSG_LOAD_EPROM "Lataa muistista" #define MSG_LOAD_EPROM "Lataa muistista"
#define MSG_RESTORE_FAILSAFE "Palauta oletus" #define MSG_RESTORE_FAILSAFE "Palauta oletus"
#define MSG_REFRESH "Paivita" #define MSG_REFRESH "P" STR_ae "ivit" STR_ae ""
#define MSG_WATCH "Seuraa" #define MSG_WATCH "Seuraa"
#define MSG_PREPARE "Valmistele" #define MSG_PREPARE "Valmistele"
#define MSG_TUNE "Saada" #define MSG_TUNE "S" STR_ae "" STR_ae "d" STR_ae ""
#define MSG_PAUSE_PRINT "Keskeyta tulostus" #define MSG_PAUSE_PRINT "Keskeyt" STR_ae " tulostus"
#define MSG_RESUME_PRINT "Jatka tulostusta" #define MSG_RESUME_PRINT "Jatka tulostusta"
#define MSG_STOP_PRINT "Pysayta tulostus" #define MSG_STOP_PRINT "Pys" STR_ae "yt" STR_ae " tulostus"
#define MSG_CARD_MENU "Korttivalikko" #define MSG_CARD_MENU "Korttivalikko"
#define MSG_NO_CARD "Ei korttia" #define MSG_NO_CARD "Ei korttia"
#define MSG_DWELL "Nukkumassa..." #define MSG_DWELL "Nukkumassa..."
...@@ -103,9 +103,9 @@ ...@@ -103,9 +103,9 @@
#define MSG_NO_MOVE "Ei liiketta." #define MSG_NO_MOVE "Ei liiketta."
#define MSG_KILLED "KILLED. " #define MSG_KILLED "KILLED. "
#define MSG_STOPPED "STOPPED. " #define MSG_STOPPED "STOPPED. "
#define MSG_CONTROL_RETRACT "Veda mm" #define MSG_CONTROL_RETRACT "Ved" STR_ae " mm"
#define MSG_CONTROL_RETRACT_SWAP "Va. Veda mm" #define MSG_CONTROL_RETRACT_SWAP "Va. Ved" STR_ae " mm"
#define MSG_CONTROL_RETRACTF "Veda V" #define MSG_CONTROL_RETRACTF "Ved" STR_ae " V"
#define MSG_CONTROL_RETRACT_ZLIFT "Z mm" #define MSG_CONTROL_RETRACT_ZLIFT "Z mm"
#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm" #define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Va. UnRet +mm" #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Va. UnRet +mm"
...@@ -123,11 +123,11 @@ ...@@ -123,11 +123,11 @@
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Endstop abort"
#ifdef DELTA #ifdef DELTA
#define MSG_DELTA_CALIBRATE "Delta Calibration" #define MSG_DELTA_CALIBRATE "Delta Kalibrointi"
#define MSG_DELTA_CALIBRATE_X "Calibrate X" #define MSG_DELTA_CALIBRATE_X "Kalibroi X"
#define MSG_DELTA_CALIBRATE_Y "Calibrate Y" #define MSG_DELTA_CALIBRATE_Y "Kalibroi Y"
#define MSG_DELTA_CALIBRATE_Z "Calibrate Z" #define MSG_DELTA_CALIBRATE_Z "Kalibroi Z"
#define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center" #define MSG_DELTA_CALIBRATE_CENTER "Kalibroi Center"
#endif // DELTA #endif // DELTA
#define MSG_LASER "Laser Preset" #define MSG_LASER "Laser Preset"
......
...@@ -418,99 +418,102 @@ int getHeaterPower(int heater) { ...@@ -418,99 +418,102 @@ int getHeaterPower(int heater) {
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \ #if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \ (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1)
#if defined(FAN_PIN) && FAN_PIN > -1 #if defined(FAN_PIN) && FAN_PIN > -1
#if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN
#error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN" #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN"
#endif #endif
#if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN #if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN
#error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN" #error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN"
#endif #endif
#if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN #if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN
#error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN" #error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN"
#endif
#if EXTRUDER_3_AUTO_FAN_PIN == FAN_PIN
#error "You cannot set EXTRUDER_3_AUTO_FAN_PIN equal to FAN_PIN"
#endif #endif
#endif #endif
void setExtruderAutoFanState(int pin, bool state) void setExtruderAutoFanState(int pin, bool state)
{ {
unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0; unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0;
// this idiom allows both digital and PWM fan outputs (see M42 handling). // this idiom allows both digital and PWM fan outputs (see M42 handling).
pinMode(pin, OUTPUT); pinMode(pin, OUTPUT);
digitalWrite(pin, newFanSpeed); digitalWrite(pin, newFanSpeed);
analogWrite(pin, newFanSpeed); analogWrite(pin, newFanSpeed);
} }
void checkExtruderAutoFans()
{
uint8_t fanState = 0;
// which fan pins need to be turned on? void checkExtruderAutoFans()
#if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1 {
if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) uint8_t fanState = 0;
fanState |= 1;
#endif
#ifndef SINGLENOZZLE // which fan pins need to be turned on?
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 #if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{
if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1; fanState |= 1;
else #endif
fanState |= 2;
}
#endif
#if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1
if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{
if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1;
else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
fanState |= 2;
else
fanState |= 4;
}
#endif
#if defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1
if (current_temperature[3] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{
if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
fanState |= 2;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_2_AUTO_FAN_PIN)
fanState |= 4;
else
fanState |= 8;
}
#endif
#endif // !SINLGENOZZE
// update extruder auto fan states
#if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
#endif
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1 #if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); {
#endif if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
#if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1 fanState |= 1;
if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN else
&& EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) fanState |= 2;
setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0); }
#endif #endif
#if defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1 #if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1
if (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE)
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) {
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0); fanState |= 1;
#endif else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
#endif // !SINLGENOZZE fanState |= 2;
} else
fanState |= 4;
}
#endif
#if defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1
if (current_temperature[3] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{
if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
fanState |= 2;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_2_AUTO_FAN_PIN)
fanState |= 4;
else
fanState |= 8;
}
#endif
#endif // !SINLGENOZZE
// update extruder auto fan states
#if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
#endif
#ifndef SINGLENOZZLE
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0);
#endif
#if defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1
if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
&& EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0);
#endif
#if defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1
if (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN)
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0);
#endif
#endif // !SINLGENOZZE
}
#endif // any extruder auto fan pins set #endif // any extruder auto fan pins set
void manage_heater() void manage_heater()
...@@ -524,12 +527,10 @@ void manage_heater() ...@@ -524,12 +527,10 @@ void manage_heater()
updateTemperaturesFromRawValues(); updateTemperaturesFromRawValues();
#ifdef HEATER_0_USES_MAX6675 #ifdef HEATER_0_USES_MAX6675
if (current_temperature[0] > 1023 || current_temperature[0] > HEATER_0_MAXTEMP) if (current_temperature[0] > 1023 || current_temperature[0] > HEATER_0_MAXTEMP) {
{
max_temp_error(0); max_temp_error(0);
} }
if (current_temperature[0] == 0 || current_temperature[0] < HEATER_0_MINTEMP) if (current_temperature[0] == 0 || current_temperature[0] < HEATER_0_MINTEMP) {
{
min_temp_error(0); min_temp_error(0);
} }
#endif //HEATER_0_USES_MAX6675 #endif //HEATER_0_USES_MAX6675
...@@ -541,132 +542,119 @@ void manage_heater() ...@@ -541,132 +542,119 @@ void manage_heater()
#endif // !SINLGENOZZE #endif // !SINLGENOZZE
{ {
#if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS); thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
pid_input = current_temperature[e]; pid_input = current_temperature[e];
#ifndef PID_OPENLOOP #ifndef PID_OPENLOOP
pid_error[e] = target_temperature[e] - pid_input; pid_error[e] = target_temperature[e] - pid_input;
if(pid_error[e] > PID_FUNCTIONAL_RANGE) if(pid_error[e] > PID_FUNCTIONAL_RANGE) {
{ pid_output = BANG_MAX;
pid_output = BANG_MAX; pid_reset[e] = true;
pid_reset[e] = true;
}
else if(pid_error[e] < -PID_FUNCTIONAL_RANGE || target_temperature[e] == 0)
{
pid_output = 0;
pid_reset[e] = true;
}
else
{
if(pid_reset[e] == true)
{
temp_iState[e] = 0.0;
pid_reset[e] = false;
} }
pTerm[e] = Kp[e] * pid_error[e]; else if(pid_error[e] < -PID_FUNCTIONAL_RANGE || target_temperature[e] == 0) {
temp_iState[e] += pid_error[e]; pid_output = 0;
temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]); pid_reset[e] = true;
iTerm[e] = Ki[e] * temp_iState[e]; }
else {
//K1 defined in Configuration.h in the PID settings if(pid_reset[e] == true) {
#define K2 (1.0-K1) temp_iState[e] = 0.0;
dTerm[e] = (Kd[e] * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]); pid_reset[e] = false;
pid_output = pTerm[e] + iTerm[e] - dTerm[e]; }
if (pid_output > PID_MAX) pTerm[e] = Kp[e] * pid_error[e];
{ temp_iState[e] += pid_error[e];
if (pid_error[e] > 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]);
pid_output=PID_MAX; iTerm[e] = Ki[e] * temp_iState[e];
} else if (pid_output < 0)
{ //K1 defined in Configuration.h in the PID settings
if (pid_error[e] < 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration #define K2 (1.0-K1)
pid_output=0; dTerm[e] = (Kd[e] * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]);
pid_output = pTerm[e] + iTerm[e] - dTerm[e];
if (pid_output > PID_MAX) {
if (pid_error[e] > 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration
pid_output=PID_MAX;
}
else if (pid_output < 0) {
if (pid_error[e] < 0 ) temp_iState[e] -= pid_error[e]; // conditional un-integration
pid_output=0;
}
} }
temp_dState[e] = pid_input;
#else
pid_output = constrain(target_temperature[e], 0, PID_MAX);
#endif //PID_OPENLOOP
#ifdef PID_DEBUG
SERIAL_ECHO_START;
SERIAL_ECHO(" PID_DEBUG ");
SERIAL_ECHO(e);
SERIAL_ECHO(": Input ");
SERIAL_ECHO(pid_input);
SERIAL_ECHO(" Output ");
SERIAL_ECHO(pid_output);
SERIAL_ECHO(" pTerm ");
SERIAL_ECHO(pTerm[e]);
SERIAL_ECHO(" iTerm ");
SERIAL_ECHO(iTerm[e]);
SERIAL_ECHO(" dTerm ");
SERIAL_ECHOLN(dTerm[e]);
#endif //PID_DEBUG
#else //NO PIDTEMP
pid_output = 0;
if(current_temperature[e] < target_temperature[e]) {
pid_output = PID_MAX;
} }
temp_dState[e] = pid_input; #endif //PIDTEMP
#else
pid_output = constrain(target_temperature[e], 0, PID_MAX);
#endif //PID_OPENLOOP
#ifdef PID_DEBUG // Check if temperature is within the correct range
SERIAL_ECHO_START; if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e])) {
SERIAL_ECHO(" PID_DEBUG "); soft_pwm[e] = (int)pid_output >> 1;
SERIAL_ECHO(e); }
SERIAL_ECHO(": Input "); else {
SERIAL_ECHO(pid_input); soft_pwm[e] = 0;
SERIAL_ECHO(" Output ");
SERIAL_ECHO(pid_output);
SERIAL_ECHO(" pTerm ");
SERIAL_ECHO(pTerm[e]);
SERIAL_ECHO(" iTerm ");
SERIAL_ECHO(iTerm[e]);
SERIAL_ECHO(" dTerm ");
SERIAL_ECHOLN(dTerm[e]);
#endif //PID_DEBUG
#else //NO PIDTEMP
pid_output = 0;
if(current_temperature[e] < target_temperature[e])
{
pid_output = PID_MAX;
} }
#endif //PIDTEMP
// Check if temperature is within the correct range
if((current_temperature[e] > minttemp[e]) && (current_temperature[e] < maxttemp[e]))
{
soft_pwm[e] = (int)pid_output >> 1;
}
else
{
soft_pwm[e] = 0;
}
#ifdef WATCH_TEMP_PERIOD #ifdef WATCH_TEMP_PERIOD
if(watchmillis[e] && millis() - watchmillis[e] > WATCH_TEMP_PERIOD) if(watchmillis[e] && millis() - watchmillis[e] > WATCH_TEMP_PERIOD) {
{ if(degHotend(e) < watch_start_temp[e] + WATCH_TEMP_INCREASE) {
if(degHotend(e) < watch_start_temp[e] + WATCH_TEMP_INCREASE) setTargetHotend(0, e);
{ LCD_MESSAGEPGM("Heating failed");
setTargetHotend(0, e); SERIAL_ECHO_START;
LCD_MESSAGEPGM("Heating failed"); SERIAL_ECHOLN("Heating failed");
SERIAL_ECHO_START; }
SERIAL_ECHOLN("Heating failed"); else {
} watchmillis[e] = 0;
else }
{
watchmillis[e] = 0;
} }
} #endif //WATCH_TEMP_PERIOD
#endif //WATCH_TEMP_PERIOD
#ifdef TEMP_SENSOR_1_AS_REDUNDANT #ifdef TEMP_SENSOR_1_AS_REDUNDANT
if(fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) if(fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
{ disable_heater();
disable_heater(); if(IsStopped() == false) {
if(IsStopped() == false) SERIAL_ERROR_START;
{ SERIAL_ERRORLNPGM("Extruder switched off. Temperature difference between temp sensors is too high !");
SERIAL_ERROR_START; LCD_ALERTMESSAGEPGM("Err: REDUNDANT TEMP ERROR");
SERIAL_ERRORLNPGM("Extruder switched off. Temperature difference between temp sensors is too high !"); }
LCD_ALERTMESSAGEPGM("Err: REDUNDANT TEMP ERROR"); #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
Stop();
#endif
} }
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE #endif //TEMP_SENSOR_1_AS_REDUNDANT
Stop(); } //End extruder for loop
#endif
}
#endif //TEMP_SENSOR_1_AS_REDUNDANT
} // End extruder for loop
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \ #if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \ (defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) (defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1) || \
if(millis() - extruder_autofan_last_check > 2500) // only need to check fan state very infrequently (defined(EXTRUDER_3_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN > -1)
{ if(millis() - extruder_autofan_last_check > 2500) { // only need to check fan state very infrequently
checkExtruderAutoFans(); checkExtruderAutoFans();
extruder_autofan_last_check = millis(); extruder_autofan_last_check = millis();
} }
#endif #endif
#ifndef PIDTEMPBED #ifndef PIDTEMPBED
if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL)
...@@ -675,14 +663,12 @@ void manage_heater() ...@@ -675,14 +663,12 @@ void manage_heater()
#endif #endif
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
#if defined(THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0 #if defined(THERMAL_RUNAWAY_PROTECTION_BED_PERIOD) && THERMAL_RUNAWAY_PROTECTION_BED_PERIOD > 0
thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS); thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS);
#endif #endif
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
pid_input = current_temperature_bed; pid_input = current_temperature_bed;
#ifndef PID_OPENLOOP #ifndef PID_OPENLOOP
pid_error_bed = target_temperature_bed - pid_input; pid_error_bed = target_temperature_bed - pid_input;
pTerm_bed = bedKp * pid_error_bed; pTerm_bed = bedKp * pid_error_bed;
...@@ -699,7 +685,8 @@ void manage_heater() ...@@ -699,7 +685,8 @@ void manage_heater()
if (pid_output > MAX_BED_POWER) { if (pid_output > MAX_BED_POWER) {
if (pid_error_bed > 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration if (pid_error_bed > 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
pid_output=MAX_BED_POWER; pid_output=MAX_BED_POWER;
} else if (pid_output < 0){ }
else if (pid_output < 0) {
if (pid_error_bed < 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration if (pid_error_bed < 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
pid_output=0; pid_output=0;
} }
...@@ -723,8 +710,7 @@ void manage_heater() ...@@ -723,8 +710,7 @@ void manage_heater()
SERIAL_ECHOLN(dTerm_bed); SERIAL_ECHOLN(dTerm_bed);
#endif //PID_BED_DEBUG #endif //PID_BED_DEBUG
if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) {
{
soft_pwm_bed = (int)pid_output >> 1; soft_pwm_bed = (int)pid_output >> 1;
} }
else { else {
...@@ -733,101 +719,88 @@ void manage_heater() ...@@ -733,101 +719,88 @@ void manage_heater()
#elif !defined(BED_LIMIT_SWITCHING) #elif !defined(BED_LIMIT_SWITCHING)
// Check if temperature is within the correct range // Check if temperature is within the correct range
if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) {
{ if(current_temperature_bed >= target_temperature_bed) {
if(current_temperature_bed >= target_temperature_bed)
{
soft_pwm_bed = 0; soft_pwm_bed = 0;
} }
else else {
{
soft_pwm_bed = MAX_BED_POWER>>1; soft_pwm_bed = MAX_BED_POWER>>1;
} }
} }
else else {
{
soft_pwm_bed = 0; soft_pwm_bed = 0;
WRITE(HEATER_BED_PIN,LOW); WRITE(HEATER_BED_PIN,LOW);
} }
#else //#ifdef BED_LIMIT_SWITCHING #else //#ifdef BED_LIMIT_SWITCHING
// Check if temperature is within the correct band // Check if temperature is within the correct band
if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) {
{ if(current_temperature_bed > target_temperature_bed + BED_HYSTERESIS) {
if(current_temperature_bed > target_temperature_bed + BED_HYSTERESIS)
{
soft_pwm_bed = 0; soft_pwm_bed = 0;
} }
else if(current_temperature_bed <= target_temperature_bed - BED_HYSTERESIS) else if(current_temperature_bed <= target_temperature_bed - BED_HYSTERESIS) {
{
soft_pwm_bed = MAX_BED_POWER>>1; soft_pwm_bed = MAX_BED_POWER>>1;
} }
} }
else else {
{
soft_pwm_bed = 0; soft_pwm_bed = 0;
WRITE(HEATER_BED_PIN,LOW); WRITE(HEATER_BED_PIN,LOW);
} }
#endif #endif //BED_LIMIT_SWITCHING
#endif #endif //TEMP_SENSOR_BED != 0
//code for controlling the extruder rate based on the width sensor //code for controlling the extruder rate based on the width sensor
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
if(filament_sensor) if(filament_sensor) {
{ meas_shift_index=delay_index1-meas_delay_cm;
meas_shift_index=delay_index1-meas_delay_cm; if(meas_shift_index<0)
if(meas_shift_index<0) meas_shift_index = meas_shift_index + (MAX_MEASUREMENT_DELAY+1); //loop around buffer if needed
meas_shift_index = meas_shift_index + (MAX_MEASUREMENT_DELAY+1); //loop around buffer if needed
//get the delayed info and add 100 to reconstitute to a percent of the nominal filament diameter
//get the delayed info and add 100 to reconstitute to a percent of the nominal filament diameter //then square it to get an area
//then square it to get an area
if(meas_shift_index<0)
if(meas_shift_index<0) meas_shift_index=0;
meas_shift_index=0; else if (meas_shift_index>MAX_MEASUREMENT_DELAY)
else if (meas_shift_index>MAX_MEASUREMENT_DELAY) meas_shift_index=MAX_MEASUREMENT_DELAY;
meas_shift_index=MAX_MEASUREMENT_DELAY;
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = pow((float)(100+measurement_delay[meas_shift_index])/100.0,2);
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = pow((float)(100+measurement_delay[meas_shift_index])/100.0,2); if (volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] <0.01)
if (volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] <0.01) volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01;
volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]=0.01; }
} #endif //FILAMENT_SENSOR
#endif
} }
#define PGM_RD_W(x) (short)pgm_read_word(&x) #define PGM_RD_W(x) (short)pgm_read_word(&x)
// Derived from RepRap FiveD extruder::getTemperature() // Derived from RepRap FiveD extruder::getTemperature()
// For hot end temperature measurement. // For hot end temperature measurement.
static float analog2temp(int raw, uint8_t e) { static float analog2temp(int raw, uint8_t e)
#ifdef TEMP_SENSOR_1_AS_REDUNDANT {
if(e > EXTRUDERS) #ifdef TEMP_SENSOR_1_AS_REDUNDANT
#else if(e > EXTRUDERS)
if(e >= EXTRUDERS) #else
#endif if(e >= EXTRUDERS)
#endif
{ {
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERROR((int)e); SERIAL_ERROR((int)e);
SERIAL_ERRORLNPGM(" - Invalid extruder number !"); SERIAL_ERRORLNPGM(" - Invalid extruder number !");
kill(); kill();
return 0.0; return 0.0;
} }
#ifdef HEATER_0_USES_MAX6675 #ifdef HEATER_0_USES_MAX6675
if (e == 0) if (e == 0)
{
return 0.25 * raw; return 0.25 * raw;
}
#endif #endif
if(heater_ttbl_map[e] != NULL) if(heater_ttbl_map[e] != NULL) {
{
float celsius = 0; float celsius = 0;
uint8_t i; uint8_t i;
short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]); short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]);
for (i=1; i<heater_ttbllen_map[e]; i++) for (i=1; i<heater_ttbllen_map[e]; i++) {
{ if (PGM_RD_W((*tt)[i][0]) > raw) {
if (PGM_RD_W((*tt)[i][0]) > raw) celsius = PGM_RD_W((*tt)[i-1][1]) +
{ (raw - PGM_RD_W((*tt)[i-1][0])) *
celsius = PGM_RD_W((*tt)[i-1][1]) +
(raw - PGM_RD_W((*tt)[i-1][0])) *
(float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) /
(float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0])); (float)(PGM_RD_W((*tt)[i][0]) - PGM_RD_W((*tt)[i-1][0]));
break; break;
...@@ -844,17 +817,16 @@ static float analog2temp(int raw, uint8_t e) { ...@@ -844,17 +817,16 @@ static float analog2temp(int raw, uint8_t e) {
// Derived from RepRap FiveD extruder::getTemperature() // Derived from RepRap FiveD extruder::getTemperature()
// For bed temperature measurement. // For bed temperature measurement.
static float analog2tempBed(int raw) { static float analog2tempBed(int raw)
{
#ifdef BED_USES_THERMISTOR #ifdef BED_USES_THERMISTOR
float celsius = 0; float celsius = 0;
byte i; byte i;
for (i=1; i<BEDTEMPTABLE_LEN; i++) for (i=1; i<BEDTEMPTABLE_LEN; i++) {
{ if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) {
if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) +
{ (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) *
celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) +
(raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) *
(float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) /
(float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0])); (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0]));
break; break;
...@@ -867,9 +839,9 @@ static float analog2tempBed(int raw) { ...@@ -867,9 +839,9 @@ static float analog2tempBed(int raw) {
return celsius; return celsius;
#elif defined BED_USES_AD595 #elif defined BED_USES_AD595
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET; return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
#else #else //NO BED_USES_THERMISTOR
return 0; return 0;
#endif #endif //BED_USES_THERMISTOR
} }
/* Called to get the raw values into the the actual temperatures. The raw values are created in interrupt context, /* Called to get the raw values into the the actual temperatures. The raw values are created in interrupt context,
...@@ -882,89 +854,77 @@ static void updateTemperaturesFromRawValues() ...@@ -882,89 +854,77 @@ static void updateTemperaturesFromRawValues()
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
for(uint8_t e=0;e<EXTRUDERS;e++) for(uint8_t e=0;e<EXTRUDERS;e++)
{
#else #else
uint8_t e=0; uint8_t e=0;
{
#endif // !SINGLENOZZLE #endif // !SINGLENOZZLE
current_temperature[e] = analog2temp(current_temperature_raw[e], e); {
} current_temperature[e] = analog2temp(current_temperature_raw[e], e);
current_temperature_bed = analog2tempBed(current_temperature_bed_raw); }
#ifdef TEMP_SENSOR_1_AS_REDUNDANT current_temperature_bed = analog2tempBed(current_temperature_bed_raw);
redundant_temperature = analog2temp(redundant_temperature_raw, 1); #ifdef TEMP_SENSOR_1_AS_REDUNDANT
#endif redundant_temperature = analog2temp(redundant_temperature_raw, 1);
#if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported #endif
filament_width_meas = analog2widthFil(); #if defined (FILAMENT_SENSOR) && (FILWIDTH_PIN > -1) //check if a sensor is supported
#endif filament_width_meas = analog2widthFil();
//Reset the watchdog after we know we have a temperature measurement. #endif
watchdog_reset(); //Reset the watchdog after we know we have a temperature measurement.
watchdog_reset();
CRITICAL_SECTION_START; CRITICAL_SECTION_START;
temp_meas_ready = false; temp_meas_ready = false;
CRITICAL_SECTION_END; CRITICAL_SECTION_END;
} }
// For converting raw Filament Width to milimeters // For converting raw Filament Width to milimeters
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
float analog2widthFil() { float analog2widthFil() {
return current_raw_filwidth/16383.0*5.0; return current_raw_filwidth/16383.0*5.0;
//return current_raw_filwidth; //return current_raw_filwidth;
} }
// For converting raw Filament Width to a ratio
int widthFil_to_size_ratio() {
float temp;
temp=filament_width_meas;
if(filament_width_meas<MEASURED_LOWER_LIMIT)
temp=filament_width_nominal; //assume sensor cut out
else if (filament_width_meas>MEASURED_UPPER_LIMIT)
temp= MEASURED_UPPER_LIMIT;
return(filament_width_nominal/temp*100);
} // For converting raw Filament Width to a ratio
int widthFil_to_size_ratio() {
float temp;
temp=filament_width_meas;
if(filament_width_meas<MEASURED_LOWER_LIMIT)
temp=filament_width_nominal; //assume sensor cut out
else if (filament_width_meas>MEASURED_UPPER_LIMIT)
temp= MEASURED_UPPER_LIMIT;
return(filament_width_nominal/temp*100);
}
#endif #endif
void tp_init() void tp_init()
{ {
#if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
//disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
MCUCR=(1<<JTD); MCUCR=(1<<JTD);
MCUCR=(1<<JTD); MCUCR=(1<<JTD);
#endif #endif
// Finish init of mult extruder arrays // Finish init of mult extruder arrays
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
for (uint8_t e = 0; e < EXTRUDERS; e++) for (uint8_t e = 0; e < EXTRUDERS; e++)
{
#else #else
uint8_t e = 0; uint8_t e = 0;
{
#endif // !SINGLENOZZLE #endif // !SINGLENOZZLE
{
// populate with the first value // populate with the first value
maxttemp[e] = maxttemp[0]; maxttemp[e] = maxttemp[0];
#ifdef PIDTEMP #ifdef PIDTEMP
temp_iState_min[e] = 0.0; temp_iState_min[e] = 0.0;
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki[e]; temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki[e];
#endif //PIDTEMP #endif //PIDTEMP
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
temp_iState_min_bed = 0.0; temp_iState_min_bed = 0.0;
temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi;
#endif //PIDTEMPBED #endif //PIDTEMPBED
} }
#if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1) #if defined(HEATER_0_PIN) && (HEATER_0_PIN > -1)
SET_OUTPUT(HEATER_0_PIN); SET_OUTPUT(HEATER_0_PIN);
#endif #endif
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
#if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1) #if defined(HEATER_1_PIN) && (HEATER_1_PIN > -1)
SET_OUTPUT(HEATER_1_PIN); SET_OUTPUT(HEATER_1_PIN);
...@@ -976,22 +936,22 @@ void tp_init() ...@@ -976,22 +936,22 @@ void tp_init()
SET_OUTPUT(HEATER_3_PIN); SET_OUTPUT(HEATER_3_PIN);
#endif #endif
#endif // !SINGLENOZZLE #endif // !SINGLENOZZLE
#if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1) #if defined(HEATER_BED_PIN) && (HEATER_BED_PIN > -1)
SET_OUTPUT(HEATER_BED_PIN); SET_OUTPUT(HEATER_BED_PIN);
#endif #endif
#if defined(FAN_PIN) && (FAN_PIN > -1)
#if defined(FAN_PIN) && (FAN_PIN > -1)
SET_OUTPUT(FAN_PIN); SET_OUTPUT(FAN_PIN);
#ifdef FAST_PWM_FAN #ifdef FAST_PWM_FAN
setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8 setPwmFrequency(FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
#endif #endif
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
soft_pwm_fan = fanSpeedSoftPwm / 2; soft_pwm_fan = fanSpeedSoftPwm / 2;
#endif #endif
#endif #endif
#ifdef HEATER_0_USES_MAX6675 #ifdef HEATER_0_USES_MAX6675
#ifndef SDSUPPORT #ifndef SDSUPPORT
SET_OUTPUT(SCK_PIN); SET_OUTPUT(SCK_PIN);
WRITE(SCK_PIN,0); WRITE(SCK_PIN,0);
...@@ -1004,11 +964,10 @@ void tp_init() ...@@ -1004,11 +964,10 @@ void tp_init()
#else #else
pinMode(SS_PIN, OUTPUT); pinMode(SS_PIN, OUTPUT);
digitalWrite(SS_PIN, HIGH); digitalWrite(SS_PIN, HIGH);
#endif #endif //SDSUPPORT
SET_OUTPUT(MAX6675_SS); SET_OUTPUT(MAX6675_SS);
WRITE(MAX6675_SS,1); WRITE(MAX6675_SS,1);
#endif //HEATER_0_USES_MAX6675 #endif //HEATER_0_USES_MAX6675
// Set analog inputs // Set analog inputs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment