Merge pull request #1328 from DinoMesina/development

Some corrections and new features
This commit is contained in:
Bo Herrmannsen 2015-01-06 23:52:32 +01:00
commit addf52fd4a
7 changed files with 321 additions and 77 deletions

View File

@ -148,6 +148,7 @@
#ifdef PIDTEMP #ifdef PIDTEMP
//#define PID_DEBUG // Sends debug data to the serial port. //#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
//#define SLOW_PWM_HEATERS // PWM with very low frequency (circa 0.125Hz=8s) and miminum state time of circa 1s usefoul for heater drived by relay
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
// is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. // is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
#define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term #define PID_INTEGRAL_DRIVE_MAX PID_MAX //limit for the integral term
@ -564,7 +565,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// The Elefu RA Board Control Panel // The Elefu RA Board Control Panel
// http://www.elefu.com/index.php?route=product/product&product_id=53 // http://www.elefu.com/index.php?route=product/product&product_id=53
// REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARUDINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C // REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARDUINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C
//#define RA_CONTROL_PANEL //#define RA_CONTROL_PANEL
//automatic expansion //automatic expansion

View File

@ -571,7 +571,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// The Elefu RA Board Control Panel // The Elefu RA Board Control Panel
// http://www.elefu.com/index.php?route=product/product&product_id=53 // http://www.elefu.com/index.php?route=product/product&product_id=53
// REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARUDINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C // REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARDUINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C
//#define RA_CONTROL_PANEL //#define RA_CONTROL_PANEL
//automatic expansion //automatic expansion

View File

@ -475,7 +475,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// The Elefu RA Board Control Panel // The Elefu RA Board Control Panel
// http://www.elefu.com/index.php?route=product/product&product_id=53 // http://www.elefu.com/index.php?route=product/product&product_id=53
// REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARUDINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C // REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARDUINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C
//#define RA_CONTROL_PANEL //#define RA_CONTROL_PANEL
// Delta calibration menu // Delta calibration menu

View File

@ -543,7 +543,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// The Elefu RA Board Control Panel // The Elefu RA Board Control Panel
// http://www.elefu.com/index.php?route=product/product&product_id=53 // http://www.elefu.com/index.php?route=product/product&product_id=53
// REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARUDINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C // REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARDUINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C
//#define RA_CONTROL_PANEL //#define RA_CONTROL_PANEL
//automatic expansion //automatic expansion

View File

@ -557,7 +557,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// The Elefu RA Board Control Panel // The Elefu RA Board Control Panel
// http://www.elefu.com/index.php?route=product/product&product_id=53 // http://www.elefu.com/index.php?route=product/product&product_id=53
// REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARUDINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C // REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARDUINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C
//#define RA_CONTROL_PANEL //#define RA_CONTROL_PANEL
//automatic expansion //automatic expansion

View File

@ -15,37 +15,37 @@
#define MSG_AUTOSTART "Autostart" #define MSG_AUTOSTART "Autostart"
#define MSG_DISABLE_STEPPERS "Disabilita Motori" #define MSG_DISABLE_STEPPERS "Disabilita Motori"
#define MSG_AUTO_HOME "Auto Home" #define MSG_AUTO_HOME "Auto Home"
#define MSG_SET_HOME_OFFSETS "Set home offsets" #define MSG_SET_HOME_OFFSETS "Setta offset home"
#define MSG_SET_ORIGIN "Imposta Origine" #define MSG_SET_ORIGIN "Imposta Origine"
#define MSG_PREHEAT_PLA "Preriscalda PLA" #define MSG_PREHEAT_PLA "Preriscalda PLA"
#define MSG_PREHEAT_PLA0 "Preriscalda PLA 1" #define MSG_PREHEAT_PLA0 "Preriscalda PLA 1"
#define MSG_PREHEAT_PLA1 "Preriscalda PLA 2" #define MSG_PREHEAT_PLA1 "Preriscalda PLA 2"
#define MSG_PREHEAT_PLA2 "Preriscalda PLA 3" #define MSG_PREHEAT_PLA2 "Preriscalda PLA 3"
#define MSG_PREHEAT_PLA012 "Preris. PLA Tutto" #define MSG_PREHEAT_PLA012 "Prer. PLA Tutto"
#define MSG_PREHEAT_PLA_BEDONLY "Preri. PLA Piatto" #define MSG_PREHEAT_PLA_BEDONLY "Prer. PLA Piatto"
#define MSG_PREHEAT_PLA_SETTINGS "Preris. PLA Conf" #define MSG_PREHEAT_PLA_SETTINGS "Config. prer. PLA"
#define MSG_PREHEAT_ABS "Preriscalda ABS" #define MSG_PREHEAT_ABS "Preriscalda ABS"
#define MSG_PREHEAT_ABS0 "Preriscalda ABS 1" #define MSG_PREHEAT_ABS0 "Preriscalda ABS 1"
#define MSG_PREHEAT_ABS1 "Preriscalda ABS 2" #define MSG_PREHEAT_ABS1 "Preriscalda ABS 2"
#define MSG_PREHEAT_ABS2 "Preriscalda ABS 3" #define MSG_PREHEAT_ABS2 "Preriscalda ABS 3"
#define MSG_PREHEAT_ABS012 "Preris. ABS Tutto" #define MSG_PREHEAT_ABS012 "Prer. ABS Tutto"
#define MSG_PREHEAT_ABS_BEDONLY "Preri. ABS Piatto" #define MSG_PREHEAT_ABS_BEDONLY "Prer. ABS Piatto"
#define MSG_PREHEAT_ABS_SETTINGS "Preris. ABS Conf" #define MSG_PREHEAT_ABS_SETTINGS "Config. prer. ABS"
#define MSG_COOLDOWN "Raffredda" #define MSG_COOLDOWN "Raffredda"
#define MSG_SWITCH_PS_ON "Switch Power On" #define MSG_SWITCH_PS_ON "Accendi aliment."
#define MSG_SWITCH_PS_OFF "Switch Power Off" #define MSG_SWITCH_PS_OFF "Spegni aliment."
#define MSG_EXTRUDE "Estrudi" #define MSG_EXTRUDE "Estrudi"
#define MSG_RETRACT "Ritrai" #define MSG_RETRACT "Ritrai"
#define MSG_MOVE_AXIS "Muovi Asse" #define MSG_MOVE_AXIS "Muovi Asse"
#define MSG_MOVE_X "Move X" #define MSG_MOVE_X "Muovi X"
#define MSG_MOVE_Y "Move Y" #define MSG_MOVE_Y "Muovi Y"
#define MSG_MOVE_Z "Move Z" #define MSG_MOVE_Z "Muovi Z"
#define MSG_MOVE_E "Extruder" #define MSG_MOVE_E "Estrusore"
#define MSG_MOVE_E1 "Extruder2" #define MSG_MOVE_E1 "Estrusore 2"
#define MSG_MOVE_E2 "Extruder3" #define MSG_MOVE_E2 "Estrusore 3"
#define MSG_MOVE_01MM "Move 0.1mm" #define MSG_MOVE_01MM "Muovi di 0.1mm"
#define MSG_MOVE_1MM "Move 1mm" #define MSG_MOVE_1MM "Muovi di 1mm"
#define MSG_MOVE_10MM "Move 10mm" #define MSG_MOVE_10MM "Muovi di 10mm"
#define MSG_SPEED "Velcità" #define MSG_SPEED "Velcità"
#define MSG_NOZZLE "Ugello" #define MSG_NOZZLE "Ugello"
#define MSG_NOZZLE1 "Ugello2" #define MSG_NOZZLE1 "Ugello2"
@ -61,13 +61,13 @@
#define MSG_MAX " \002 Max:" #define MSG_MAX " \002 Max:"
#define MSG_FACTOR " \002 Fact:" #define MSG_FACTOR " \002 Fact:"
#define MSG_AUTOTEMP "Autotemp" #define MSG_AUTOTEMP "Autotemp"
#define MSG_ON "On " #define MSG_ON "ON "
#define MSG_OFF "Off" #define MSG_OFF "OFF"
#define MSG_PID_P "PID-P" #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I" #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D" #define MSG_PID_D "PID-D"
#define MSG_PID_C "PID-C" #define MSG_PID_C "PID-C"
#define MSG_ACC "Accel" #define MSG_ACC "Accel."
#define MSG_VXY_JERK "Vxy-jerk" #define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk" #define MSG_VZ_JERK "Vz-jerk"
#define MSG_VE_JERK "Ve-jerk" #define MSG_VE_JERK "Ve-jerk"
@ -87,11 +87,11 @@
#define MSG_TEMPERATURE "Temperatura" #define MSG_TEMPERATURE "Temperatura"
#define MSG_MOTION "Movimento" #define MSG_MOTION "Movimento"
#define MSG_VOLUMETRIC "Filament" #define MSG_VOLUMETRIC "Filament"
#define MSG_VOLUMETRIC_ENABLED "E in mm3" #define MSG_VOLUMETRIC_ENABLED "E in mm³"
#define MSG_FILAMENT_SIZE_EXTRUDER_0 "Fil. Dia. 1" #define MSG_FILAMENT_SIZE_EXTRUDER_0 "Diam. filo 1"
#define MSG_FILAMENT_SIZE_EXTRUDER_1 "Fil. Dia. 2" #define MSG_FILAMENT_SIZE_EXTRUDER_1 "Diam. filo 2"
#define MSG_FILAMENT_SIZE_EXTRUDER_2 "Fil. Dia. 3" #define MSG_FILAMENT_SIZE_EXTRUDER_2 "Diam. filo 3"
#define MSG_CONTRAST "LCD contrast" #define MSG_CONTRAST "Contrasto LCD"
#define MSG_STORE_EPROM "Salva in EEPROM" #define MSG_STORE_EPROM "Salva in EEPROM"
#define MSG_LOAD_EPROM "Carica da EEPROM" #define MSG_LOAD_EPROM "Carica da EEPROM"
#define MSG_RESTORE_FAILSAFE "Impostaz. default" #define MSG_RESTORE_FAILSAFE "Impostaz. default"
@ -100,17 +100,17 @@
#define MSG_PREPARE "Prepara" #define MSG_PREPARE "Prepara"
#define MSG_TUNE "Adatta" #define MSG_TUNE "Adatta"
#define MSG_PAUSE_PRINT "Pausa" #define MSG_PAUSE_PRINT "Pausa"
#define MSG_RESUME_PRINT "Riprendi Stampa" #define MSG_RESUME_PRINT "Riprendi stampa"
#define MSG_STOP_PRINT "Arresta Stampa" #define MSG_STOP_PRINT "Arresta stampa"
#define MSG_CARD_MENU "SD Card Menu" #define MSG_CARD_MENU "SD Card Menu"
#define MSG_NO_CARD "No SD Card" #define MSG_NO_CARD "No SD Card"
#define MSG_DWELL "Sospensione..." #define MSG_DWELL "Sospensione..."
#define MSG_USERWAIT "Attendi Utente..." #define MSG_USERWAIT "Attendi Utente..."
#define MSG_RESUMING "Riprendi Stampa" #define MSG_RESUMING "Riprendi Stampa"
#define MSG_PRINT_ABORTED "Print aborted" #define MSG_PRINT_ABORTED "Stampa abortita"
#define MSG_NO_MOVE "Nessun Movimento." #define MSG_NO_MOVE "Nessun Movimento"
#define MSG_KILLED "UCCISO. " #define MSG_KILLED "UCCISO "
#define MSG_STOPPED "ARRESTATO. " #define MSG_STOPPED "ARRESTATO "
#define MSG_CONTROL_RETRACT "Ritrai mm" #define MSG_CONTROL_RETRACT "Ritrai mm"
#define MSG_CONTROL_RETRACT_SWAP "Scamb. Ritrai mm" #define MSG_CONTROL_RETRACT_SWAP "Scamb. Ritrai mm"
#define MSG_CONTROL_RETRACTF "Ritrai V" #define MSG_CONTROL_RETRACTF "Ritrai V"
@ -128,16 +128,16 @@
#define MSG_BABYSTEP_X "Babystep X" #define MSG_BABYSTEP_X "Babystep X"
#define MSG_BABYSTEP_Y "Babystep Y" #define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort" #define MSG_ENDSTOP_ABORT "Finecorsa abort"
#define MSG_RECTRACT "Ritrai" #define MSG_RECTRACT "Ritrai"
#ifdef DELTA_CALIBRATION_MENU #ifdef DELTA_CALIBRATION_MENU
#define MSG_DELTA_CALIBRATE "Delta Calibration" #define MSG_DELTA_CALIBRATE "Calibraz. Delta"
#define MSG_DELTA_CALIBRATE_X "Calibrate X" #define MSG_DELTA_CALIBRATE_X "Calibra X"
#define MSG_DELTA_CALIBRATE_Y "Calibrate Y" #define MSG_DELTA_CALIBRATE_Y "Calibra Y"
#define MSG_DELTA_CALIBRATE_Z "Calibrate Z" #define MSG_DELTA_CALIBRATE_Z "Calibra Z"
#define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center" #define MSG_DELTA_CALIBRATE_CENTER "Calibra Center"
#endif // DELTA_CALIBRATION_MENU #endif // DELTA_CALIBRATION_MENU
#endif // LANGUAGE_IT_H #endif // LANGUAGE_IT_H

View File

@ -497,7 +497,7 @@ void manage_heater()
SERIAL_ECHO(" iTerm "); SERIAL_ECHO(" iTerm ");
SERIAL_ECHO(iTerm[e]); SERIAL_ECHO(iTerm[e]);
SERIAL_ECHO(" dTerm "); SERIAL_ECHO(" dTerm ");
SERIAL_ECHOLN(dTerm[e]); SERIAL_ECHOLN(dTerm[e]);
#endif //PID_DEBUG #endif //PID_DEBUG
#else /* PID off */ #else /* PID off */
pid_output = 0; pid_output = 0;
@ -1221,68 +1221,311 @@ ISR(TIMER0_COMPB_vect)
static unsigned char temp_state = 10; static unsigned char temp_state = 10;
static unsigned char pwm_count = (1 << SOFT_PWM_SCALE); static unsigned char pwm_count = (1 << SOFT_PWM_SCALE);
static unsigned char soft_pwm_0; static unsigned char soft_pwm_0;
#if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL) #ifdef SLOW_PWM_HEATERS
static unsigned char slow_pwm_count = 0;
static unsigned char state_heater_0 = 0;
static unsigned char state_timer_heater_0 = 0;
#endif
#if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL)
static unsigned char soft_pwm_1; static unsigned char soft_pwm_1;
#endif #ifdef SLOW_PWM_HEATERS
#if EXTRUDERS > 2 static unsigned char state_heater_1 = 0;
static unsigned char state_timer_heater_1 = 0;
#endif
#endif
#if EXTRUDERS > 2
static unsigned char soft_pwm_2; static unsigned char soft_pwm_2;
#endif #ifdef SLOW_PWM_HEATERS
#if HEATER_BED_PIN > -1 static unsigned char state_heater_2 = 0;
static unsigned char state_timer_heater_2 = 0;
#endif
#endif
#if HEATER_BED_PIN > -1
static unsigned char soft_pwm_b; static unsigned char soft_pwm_b;
#endif #ifdef SLOW_PWM_HEATERS
static unsigned char state_heater_b = 0;
static unsigned char state_timer_heater_b = 0;
#endif
#endif
#if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1) #if defined(FILWIDTH_PIN) &&(FILWIDTH_PIN > -1)
static unsigned long raw_filwidth_value = 0; //added for filament width sensor static unsigned long raw_filwidth_value = 0; //added for filament width sensor
#endif #endif
#ifndef SLOW_PWM_HEATERS
/*
* standard PWM modulation
*/
if(pwm_count == 0){ if(pwm_count == 0){
soft_pwm_0 = soft_pwm[0]; soft_pwm_0 = soft_pwm[0];
if(soft_pwm_0 > 0) { if(soft_pwm_0 > 0) {
WRITE(HEATER_0_PIN,1); WRITE(HEATER_0_PIN,1);
#ifdef HEATERS_PARALLEL #ifdef HEATERS_PARALLEL
WRITE(HEATER_1_PIN,1); WRITE(HEATER_1_PIN,1);
#endif #endif
} else WRITE(HEATER_0_PIN,0); } else WRITE(HEATER_0_PIN,0);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
soft_pwm_1 = soft_pwm[1]; soft_pwm_1 = soft_pwm[1];
if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0); if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0);
#endif #endif
#if EXTRUDERS > 2 #if EXTRUDERS > 2
soft_pwm_2 = soft_pwm[2]; soft_pwm_2 = soft_pwm[2];
if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1); else WRITE(HEATER_2_PIN,0); if(soft_pwm_2 > 0) WRITE(HEATER_2_PIN,1); else WRITE(HEATER_2_PIN,0);
#endif #endif
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
soft_pwm_b = soft_pwm_bed; soft_pwm_b = soft_pwm_bed;
if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0); if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0);
#endif #endif
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
soft_pwm_fan = fanSpeedSoftPwm / 2; soft_pwm_fan = fanSpeedSoftPwm / 2;
if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0); if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
#endif #endif
} }
if(soft_pwm_0 < pwm_count) { if(soft_pwm_0 < pwm_count) {
WRITE(HEATER_0_PIN,0); WRITE(HEATER_0_PIN,0);
#ifdef HEATERS_PARALLEL #ifdef HEATERS_PARALLEL
WRITE(HEATER_1_PIN,0); WRITE(HEATER_1_PIN,0);
#endif #endif
} }
#if EXTRUDERS > 1 #if EXTRUDERS > 1
if(soft_pwm_1 < pwm_count) WRITE(HEATER_1_PIN,0); if(soft_pwm_1 < pwm_count) WRITE(HEATER_1_PIN,0);
#endif #endif
#if EXTRUDERS > 2 #if EXTRUDERS > 2
if(soft_pwm_2 < pwm_count) WRITE(HEATER_2_PIN,0); if(soft_pwm_2 < pwm_count) WRITE(HEATER_2_PIN,0);
#endif #endif
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
if(soft_pwm_b < pwm_count) WRITE(HEATER_BED_PIN,0); if(soft_pwm_b < pwm_count) WRITE(HEATER_BED_PIN,0);
#endif #endif
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0); if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0);
#endif #endif
pwm_count += (1 << SOFT_PWM_SCALE); pwm_count += (1 << SOFT_PWM_SCALE);
pwm_count &= 0x7f; pwm_count &= 0x7f;
#else //ifndef SLOW_PWM_HEATERS
/*
* SLOW PWM HEATERS
*
* for heaters drived by relay
*/
#ifndef MIN_STATE_TIME
#define MIN_STATE_TIME 16 // MIN_STATE_TIME * 65.5 = time in milliseconds
#endif
if (slow_pwm_count == 0) {
// EXTRUDER 0
soft_pwm_0 = soft_pwm[0];
if (soft_pwm_0 > 0) {
// turn ON heather only if the minimum time is up
if (state_timer_heater_0 == 0) {
// if change state set timer
if (state_heater_0 == 0) {
state_timer_heater_0 = MIN_STATE_TIME;
}
state_heater_0 = 1;
WRITE(HEATER_0_PIN, 1);
#ifdef HEATERS_PARALLEL
WRITE(HEATER_1_PIN, 1);
#endif
}
} else {
// turn OFF heather only if the minimum time is up
if (state_timer_heater_0 == 0) {
// if change state set timer
if (state_heater_0 == 1) {
state_timer_heater_0 = MIN_STATE_TIME;
}
state_heater_0 = 0;
WRITE(HEATER_0_PIN, 0);
#ifdef HEATERS_PARALLEL
WRITE(HEATER_1_PIN, 0);
#endif
}
}
#if EXTRUDERS > 1
// EXTRUDER 1
soft_pwm_1 = soft_pwm[1];
if (soft_pwm_1 > 0) {
// turn ON heather only if the minimum time is up
if (state_timer_heater_1 == 0) {
// if change state set timer
if (state_heater_1 == 0) {
state_timer_heater_1 = MIN_STATE_TIME;
}
state_heater_1 = 1;
WRITE(HEATER_1_PIN, 1);
}
} else {
// turn OFF heather only if the minimum time is up
if (state_timer_heater_1 == 0) {
// if change state set timer
if (state_heater_1 == 1) {
state_timer_heater_1 = MIN_STATE_TIME;
}
state_heater_1 = 0;
WRITE(HEATER_1_PIN, 0);
}
}
#endif
#if EXTRUDERS > 2
// EXTRUDER 2
soft_pwm_2 = soft_pwm[2];
if (soft_pwm_2 > 0) {
// turn ON heather only if the minimum time is up
if (state_timer_heater_2 == 0) {
// if change state set timer
if (state_heater_2 == 0) {
state_timer_heater_2 = MIN_STATE_TIME;
}
state_heater_2 = 1;
WRITE(HEATER_2_PIN, 1);
}
} else {
// turn OFF heather only if the minimum time is up
if (state_timer_heater_2 == 0) {
// if change state set timer
if (state_heater_2 == 1) {
state_timer_heater_2 = MIN_STATE_TIME;
}
state_heater_2 = 0;
WRITE(HEATER_2_PIN, 0);
}
}
#endif
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
// BED
soft_pwm_b = soft_pwm_bed;
if (soft_pwm_b > 0) {
// turn ON heather only if the minimum time is up
if (state_timer_heater_b == 0) {
// if change state set timer
if (state_heater_b == 0) {
state_timer_heater_b = MIN_STATE_TIME;
}
state_heater_b = 1;
WRITE(HEATER_BED_PIN, 1);
}
} else {
// turn OFF heather only if the minimum time is up
if (state_timer_heater_b == 0) {
// if change state set timer
if (state_heater_b == 1) {
state_timer_heater_b = MIN_STATE_TIME;
}
state_heater_b = 0;
WRITE(HEATER_BED_PIN, 0);
}
}
#endif
} // if (slow_pwm_count == 0)
// EXTRUDER 0
if (soft_pwm_0 < slow_pwm_count) {
// turn OFF heather only if the minimum time is up
if (state_timer_heater_0 == 0) {
// if change state set timer
if (state_heater_0 == 1) {
state_timer_heater_0 = MIN_STATE_TIME;
}
state_heater_0 = 0;
WRITE(HEATER_0_PIN, 0);
#ifdef HEATERS_PARALLEL
WRITE(HEATER_1_PIN, 0);
#endif
}
}
#if EXTRUDERS > 1
// EXTRUDER 1
if (soft_pwm_1 < slow_pwm_count) {
// turn OFF heather only if the minimum time is up
if (state_timer_heater_1 == 0) {
// if change state set timer
if (state_heater_1 == 1) {
state_timer_heater_1 = MIN_STATE_TIME;
}
state_heater_1 = 0;
WRITE(HEATER_1_PIN, 0);
}
}
#endif
#if EXTRUDERS > 2
// EXTRUDER 2
if (soft_pwm_2 < slow_pwm_count) {
// turn OFF heather only if the minimum time is up
if (state_timer_heater_2 == 0) {
// if change state set timer
if (state_heater_2 == 1) {
state_timer_heater_2 = MIN_STATE_TIME;
}
state_heater_2 = 0;
WRITE(HEATER_2_PIN, 0);
}
}
#endif
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
// BED
if (soft_pwm_b < slow_pwm_count) {
// turn OFF heather only if the minimum time is up
if (state_timer_heater_b == 0) {
// if change state set timer
if (state_heater_b == 1) {
state_timer_heater_b = MIN_STATE_TIME;
}
state_heater_b = 0;
WRITE(HEATER_BED_PIN, 0);
}
}
#endif
#ifdef FAN_SOFT_PWM
if (pwm_count == 0){
soft_pwm_fan = fanSpeedSoftPwm / 2;
if (soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
}
if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0);
#endif
pwm_count += (1 << SOFT_PWM_SCALE);
pwm_count &= 0x7f;
// increment slow_pwm_count only every 64 pwm_count circa 65.5ms
if ((pwm_count % 64) == 0) {
slow_pwm_count++;
slow_pwm_count &= 0x7f;
// Extruder 0
if (state_timer_heater_0 > 0) {
state_timer_heater_0--;
}
#if EXTRUDERS > 1
// Extruder 1
if (state_timer_heater_1 > 0)
state_timer_heater_1--;
#endif
#if EXTRUDERS > 2
// Extruder 2
if (state_timer_heater_2 > 0)
state_timer_heater_2--;
#endif
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
// Bed
if (state_timer_heater_b > 0)
state_timer_heater_b--;
#endif
} //if ((pwm_count % 64) == 0) {
#endif //ifndef SLOW_PWM_HEATERS
switch(temp_state) { switch(temp_state) {
case 0: // Prepare TEMP_0 case 0: // Prepare TEMP_0
#if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1) #if defined(TEMP_0_PIN) && (TEMP_0_PIN > -1)